|
ds@1952
|
1 |
#include "InstallerMain.h" |
|
ds@1952
|
2 |
#include "InstallerUtil.h" |
|
ds@1952
|
3 |
#include "SelectGame.h" |
|
ds@1952
|
4 |
#include "GamesList.h" |
|
ds@1952
|
5 |
#include "ChooseMethod.h" |
|
ds@1952
|
6 |
#include "PerformInstall.h" |
|
ds@1952
|
7 |
#include "LocalCopyMethod.h" |
|
ds@1952
|
8 |
|
|
ds@1952
|
9 |
int selected_game_index = -1; |
|
ds@1952
|
10 |
|
|
ds@1952
|
11 |
void UpdateGameListBox(HWND hDlg, game_list_t *gl) |
|
ds@1952
|
12 |
{ |
|
ds@1952
|
13 |
HWND lbox = GetDlgItem(hDlg, IDC_SELGAME_LIST); |
|
ds@1952
|
14 |
|
|
ds@1952
|
15 |
SendMessage(lbox, LB_RESETCONTENT, 0, 0); |
|
ds@1952
|
16 |
|
|
ds@1952
|
17 |
for (unsigned int i = 0; i < gl->game_count; i++) |
|
ds@1952
|
18 |
{ |
|
ds@1952
|
19 |
LRESULT res = SendMessage(lbox, |
|
ds@1952
|
20 |
LB_ADDSTRING, |
|
ds@1952
|
21 |
0, |
|
ds@1952
|
22 |
(LPARAM)g_games.game_list[gl->games[i]].name); |
|
ds@1952
|
23 |
|
|
ds@1952
|
24 |
if (res == LB_ERR || res == LB_ERRSPACE) |
|
ds@1952
|
25 |
{ |
|
ds@1952
|
26 |
continue; |
|
ds@1952
|
27 |
} |
|
ds@1952
|
28 |
|
|
ds@1952
|
29 |
SendMessage(lbox, LB_SETITEMDATA, i, gl->games[i]); |
|
ds@1952
|
30 |
} |
|
ds@1952
|
31 |
|
|
ds@1952
|
32 |
UpdateWindow(lbox); |
|
ds@1952
|
33 |
} |
|
ds@1952
|
34 |
|
|
ds@1952
|
35 |
#include "windowsx.h" |
|
ds@1952
|
36 |
|
|
ds@1952
|
37 |
INT_PTR CALLBACK ChooseGameHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) |
|
ds@1952
|
38 |
{ |
|
ds@1952
|
39 |
switch (message) |
|
ds@1952
|
40 |
{ |
|
ds@1952
|
41 |
case WM_INITDIALOG: |
|
ds@1952
|
42 |
{ |
|
ds@1952
|
43 |
HWND cbox = GetDlgItem(hDlg, IDC_SELGROUP_ACCOUNT); |
|
ds@1952
|
44 |
SendMessage(cbox, CB_RESETCONTENT, 0, 0); |
|
ds@1952
|
45 |
for (unsigned int i = 0; i < g_game_group->list_count; i++) |
|
ds@1952
|
46 |
{ |
|
ds@1952
|
47 |
LRESULT res = SendMessage(cbox, |
|
ds@1952
|
48 |
CB_ADDSTRING, |
|
ds@1952
|
49 |
0, |
|
ds@1952
|
50 |
(LPARAM)g_game_group->lists[i]->root_name); |
|
ds@1952
|
51 |
if (res == CB_ERR || res == CB_ERRSPACE) |
|
ds@1952
|
52 |
{ |
|
ds@1952
|
53 |
continue; |
|
ds@1952
|
54 |
} |
|
ds@1952
|
55 |
SendMessage(cbox, CB_SETITEMDATA, i, (LPARAM)g_game_group->lists[i]); |
|
ds@1952
|
56 |
} |
|
ds@1952
|
57 |
SendMessage(cbox, CB_SETCURSEL, 0, 0); |
|
ds@1952
|
58 |
UpdateWindow(cbox); |
|
ds@1952
|
59 |
UpdateGameListBox(hDlg, g_game_group->lists[0]); |
|
ds@1952
|
60 |
|
|
ds@1952
|
61 |
SetToGlobalPosition(hDlg); |
|
ds@1952
|
62 |
|
|
ds@1952
|
63 |
return (INT_PTR)TRUE; |
|
ds@1952
|
64 |
} |
|
ds@1952
|
65 |
case WM_COMMAND: |
|
ds@1952
|
66 |
{ |
|
ds@1952
|
67 |
if (LOWORD(wParam) == ID_SELGAME_EXIT |
|
ds@1952
|
68 |
|| LOWORD(wParam) == ID_CLOSE) |
|
ds@1952
|
69 |
{ |
|
ds@1952
|
70 |
return AskToExit(hDlg); |
|
ds@1952
|
71 |
} |
|
ds@1952
|
72 |
else if (LOWORD(wParam) == ID_SELGAME_BACK) |
|
ds@1952
|
73 |
{ |
|
ds@1952
|
74 |
UpdateGlobalPosition(hDlg); |
|
ds@1952
|
75 |
EndDialog(hDlg, (INT_PTR)DisplayChooseMethod); |
|
ds@1952
|
76 |
return (INT_PTR)TRUE; |
|
ds@1952
|
77 |
} |
|
ds@1952
|
78 |
else if (LOWORD(wParam) == IDC_SELGROUP_ACCOUNT) |
|
ds@1952
|
79 |
{ |
|
ds@1952
|
80 |
if (HIWORD(wParam) == CBN_SELCHANGE) |
|
ds@1952
|
81 |
{ |
|
ds@1952
|
82 |
HWND cbox = (HWND)lParam; |
|
ds@1952
|
83 |
LRESULT cursel = SendMessage(cbox, CB_GETCURSEL, 0, 0); |
|
ds@1952
|
84 |
|
|
ds@1952
|
85 |
if (cursel == LB_ERR) |
|
ds@1952
|
86 |
{ |
|
ds@1952
|
87 |
break; |
|
ds@1952
|
88 |
} |
|
ds@1952
|
89 |
|
|
ds@1952
|
90 |
LRESULT data = SendMessage(cbox, CB_GETITEMDATA, cursel, 0); |
|
ds@1952
|
91 |
if (data == CB_ERR) |
|
ds@1952
|
92 |
{ |
|
ds@1952
|
93 |
break; |
|
ds@1952
|
94 |
} |
|
ds@1952
|
95 |
|
|
ds@1952
|
96 |
game_list_t *gl = (game_list_t *)data; |
|
ds@1952
|
97 |
UpdateGameListBox(hDlg, gl); |
|
ds@1952
|
98 |
} |
|
ds@1952
|
99 |
break; |
|
ds@1952
|
100 |
} |
|
ds@1952
|
101 |
else if (LOWORD(wParam) == IDC_SELGAME_LIST) |
|
ds@1952
|
102 |
{ |
|
ds@1952
|
103 |
if (HIWORD(wParam) == LBN_SELCHANGE) |
|
ds@1952
|
104 |
{ |
|
ds@1952
|
105 |
HWND lbox = (HWND)lParam; |
|
ds@1952
|
106 |
LRESULT cursel = SendMessage(lbox, LB_GETCURSEL, 0, 0); |
|
ds@1952
|
107 |
|
|
ds@1952
|
108 |
selected_game_index = -1; |
|
ds@1952
|
109 |
|
|
ds@1952
|
110 |
if (cursel == LB_ERR) |
|
ds@1952
|
111 |
{ |
|
ds@1952
|
112 |
break; |
|
ds@1952
|
113 |
} |
|
ds@1952
|
114 |
|
|
ds@1952
|
115 |
LRESULT item = SendMessage(lbox, LB_GETITEMDATA, cursel, 0); |
|
ds@1952
|
116 |
if (item == LB_ERR) |
|
ds@1952
|
117 |
{ |
|
ds@1952
|
118 |
break; |
|
ds@1952
|
119 |
} |
|
ds@1952
|
120 |
|
|
ds@1952
|
121 |
selected_game_index = (int)item; |
|
ds@1952
|
122 |
|
|
ds@1952
|
123 |
HWND button = GetDlgItem(hDlg, ID_SELGAME_NEXT); |
|
ds@1952
|
124 |
EnableWindow(button, TRUE); |
|
ds@1952
|
125 |
} |
|
ds@1952
|
126 |
} |
|
ds@1952
|
127 |
else if (LOWORD(wParam) == ID_SELGAME_NEXT) |
|
ds@1952
|
128 |
{ |
|
ds@1952
|
129 |
if (selected_game_index == -1) |
|
ds@1952
|
130 |
{ |
|
ds@1952
|
131 |
break; |
|
ds@1952
|
132 |
} |
|
ds@1952
|
133 |
|
|
ds@1952
|
134 |
g_LocalCopier.SetOutputPath(g_games.game_list[selected_game_index].game_path); |
|
ds@1952
|
135 |
SetInstallMethod(&g_LocalCopier); |
|
ds@1952
|
136 |
|
|
ds@1952
|
137 |
UpdateGlobalPosition(hDlg); |
|
ds@1952
|
138 |
EndDialog(hDlg, (INT_PTR)DisplayPerformInstall); |
|
ds@1952
|
139 |
|
|
ds@1952
|
140 |
return (INT_PTR)TRUE; |
|
ds@1952
|
141 |
} |
|
ds@1952
|
142 |
break; |
|
ds@1952
|
143 |
} |
|
ds@1952
|
144 |
case WM_DESTROY: |
|
ds@1952
|
145 |
{ |
|
ds@1952
|
146 |
ReleaseGameDB(); |
|
ds@1952
|
147 |
break; |
|
ds@1952
|
148 |
} |
|
ds@1952
|
149 |
} |
|
ds@1952
|
150 |
|
|
ds@1952
|
151 |
return (INT_PTR)FALSE; |
|
ds@1952
|
152 |
} |
|
ds@1952
|
153 |
|
|
ds@1952
|
154 |
void *DisplaySelectGame(HWND hWnd) |
|
ds@1952
|
155 |
{ |
|
ds@1952
|
156 |
INT_PTR val; |
|
ds@1952
|
157 |
|
|
ds@1952
|
158 |
if ((val = DialogBox( |
|
ds@1952
|
159 |
g_hInstance, |
|
ds@1952
|
160 |
MAKEINTRESOURCE(IDD_SELECT_GAME), |
|
ds@1952
|
161 |
hWnd, |
|
ds@1952
|
162 |
ChooseGameHandler)) == -1) |
|
ds@1952
|
163 |
{ |
|
ds@1952
|
164 |
return NULL; |
|
ds@1952
|
165 |
} |
|
ds@1952
|
166 |
|
|
ds@1952
|
167 |
return (void *)val; |
|
ds@1952
|
168 |
} |
|
ds@1952
|
169 |
|