forked from kugelrund/LolSceneSwitch
/
MapsDialog.cpp
96 lines (82 loc) · 2.85 KB
/
MapsDialog.cpp
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
#include "MapsDialog.h"
#include "resource_maps.h"
#include "Log.h"
MapsDialog::MapsDialog(std::vector<CTSTR> scenes, MapScenes mapScenes) : scenes(scenes), selectedScenes(mapScenes)
{
}
_Success_(return) bool MapsDialog::Show(_In_ HINSTANCE hInstDLL, _In_ HWND hWnd, _Out_ MapScenes * scenes)
{
if (DialogBoxParam(hInstDLL, MAKEINTRESOURCE(IDD_MAPSDIALOG), hWnd, DialogProc, reinterpret_cast<LPARAM>(this)) == IDOK)
{
*scenes = selectedScenes;
return true;
}
return false;
}
void MapsDialog::GetControls(_In_ HWND hWnd)
{
cmbSummonersRift = GetDlgItem(hWnd, IDC_CMB_SUMMONERSRIFT);
cmbCrystalScar = GetDlgItem(hWnd, IDC_CMB_CRYSTALSCAR);
cmbTwistedTreeline = GetDlgItem(hWnd, IDC_CMB_TWISTEDTREELINE);
cmbHowlingAbyss = GetDlgItem(hWnd, IDC_CMB_HOWLINGABYSS);
}
void MapsDialog::LoadScenes()
{
for (auto it = scenes.begin(); it != scenes.end(); ++it)
{
LPARAM lParam = reinterpret_cast<LPARAM>(*it);
SendMessage(cmbSummonersRift, CB_ADDSTRING, 0, lParam);
SendMessage(cmbCrystalScar, CB_ADDSTRING, 0, lParam);
SendMessage(cmbTwistedTreeline, CB_ADDSTRING, 0, lParam);
SendMessage(cmbHowlingAbyss, CB_ADDSTRING, 0, lParam);
}
WPARAM index = SendMessage(cmbSummonersRift, CB_FINDSTRINGEXACT, -1,
reinterpret_cast<LPARAM>(static_cast<CTSTR>(selectedScenes.summonersRift)));
SendMessage(cmbSummonersRift, CB_SETCURSEL, index, 0);
index = SendMessage(cmbCrystalScar, CB_FINDSTRINGEXACT, -1,
reinterpret_cast<LPARAM>(static_cast<CTSTR>(selectedScenes.crystalScar)));
SendMessage(cmbCrystalScar, CB_SETCURSEL, index, 0);
index = SendMessage(cmbTwistedTreeline, CB_FINDSTRINGEXACT, -1,
reinterpret_cast<LPARAM>(static_cast<CTSTR>(selectedScenes.twistedTreeline)));
SendMessage(cmbTwistedTreeline, CB_SETCURSEL, index, 0);
index = SendMessage(cmbHowlingAbyss, CB_FINDSTRINGEXACT, -1,
reinterpret_cast<LPARAM>(static_cast<CTSTR>(selectedScenes.howlingAbyss)));
SendMessage(cmbHowlingAbyss, CB_SETCURSEL, index, 0);
}
void MapsDialog::ApplyScenes()
{
selectedScenes.summonersRift = GetCBText(cmbSummonersRift, CB_ERR);
selectedScenes.crystalScar = GetCBText(cmbCrystalScar, CB_ERR);
selectedScenes.twistedTreeline = GetCBText(cmbTwistedTreeline, CB_ERR);
selectedScenes.howlingAbyss = GetCBText(cmbHowlingAbyss, CB_ERR);
}
INT_PTR CALLBACK MapsDialog::DialogProc(_In_ HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
MapsDialog * dialog = (MapsDialog *)lParam;
SetWindowLongPtr(hWnd, DWLP_USER, lParam);
dialog->GetControls(hWnd);
dialog->LoadScenes();
return TRUE;
}
case WM_COMMAND:
{
MapsDialog * dialog = (MapsDialog *)GetWindowLongPtr(hWnd, DWLP_USER);
switch (LOWORD(wParam))
{
case IDOK:
dialog->ApplyScenes();
EndDialog(hWnd, IDOK);
break;
case IDCANCEL:
EndDialog(hWnd, IDCANCEL);
break;
}
break;
}
}
return 0;
}