1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
Minecraft Dynmap plugin for Miranda Instant Messenger
_____________________________________________
Copyright © 2015-17 Robert Pösel, 2017-20 Miranda NG team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
// Icons
static IconItem iconList[] =
{
{ "proto", LPGEN("Protocol icon"), IDI_PROTO },
};
static HANDLE hIconLibItem[_countof(iconList)];
void InitIcons(void)
{
g_plugin.registerIcon("Protocols/MinecraftDynmap", iconList, "MinecraftDynmap");
}
// Dialogs
static void LoadDBText(MinecraftDynmapProto* ppro, HWND hwnd, int idCtrl, const char* szSetting)
{
ptrW tstr(db_get_wsa(0, ppro->m_szModuleName, szSetting));
if (tstr)
SetDlgItemText(hwnd, idCtrl, tstr);
}
static void StoreDBText(MinecraftDynmapProto* ppro, HWND hwnd, int idCtrl, const char* szSetting)
{
wchar_t tstr[250 + 1];
GetDlgItemText(hwnd, idCtrl, tstr, _countof(tstr));
if (tstr[0] != '\0')
db_set_ws(0, ppro->m_szModuleName, szSetting, tstr);
else
db_unset(0, ppro->m_szModuleName, szSetting);
}
INT_PTR CALLBACK MinecraftDynmapAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
MinecraftDynmapProto *proto;
switch (message) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
proto = reinterpret_cast<MinecraftDynmapProto*>(lparam);
SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
LoadDBText(proto, hwnd, IDC_SERVER, MINECRAFTDYNMAP_KEY_SERVER);
LoadDBText(proto, hwnd, IDC_NAME, MINECRAFTDYNMAP_KEY_NAME);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wparam)) {
case IDC_NAME:
if (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus())
return TRUE;
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_NOTIFY:
if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY) {
proto = reinterpret_cast<MinecraftDynmapProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
StoreDBText(proto, hwnd, IDC_SERVER, MINECRAFTDYNMAP_KEY_SERVER);
StoreDBText(proto, hwnd, IDC_NAME, MINECRAFTDYNMAP_KEY_NAME);
return TRUE;
}
break;
}
return FALSE;
}
|