1 #include "InstallerMain.h"
2 #include "InstallerUtil.h"
3 #include "SelectGame.h"
5 #include "ChooseMethod.h"
6 #include "PerformInstall.h"
7 #include "LocalCopyMethod.h"
9 int selected_game_index = -1;
11 void UpdateGameListBox(HWND hDlg, game_list_t *gl)
13 HWND lbox = GetDlgItem(hDlg, IDC_SELGAME_LIST);
15 SendMessage(lbox, LB_RESETCONTENT, 0, 0);
17 for (unsigned int i = 0; i < gl->game_count; i++)
19 LRESULT res = SendMessage(lbox,
22 (LPARAM)g_games.game_list[gl->games[i]].name);
24 if (res == LB_ERR || res == LB_ERRSPACE)
29 SendMessage(lbox, LB_SETITEMDATA, i, gl->games[i]);
37 INT_PTR CALLBACK ChooseGameHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
43 HWND cbox = GetDlgItem(hDlg, IDC_SELGROUP_ACCOUNT);
44 SendMessage(cbox, CB_RESETCONTENT, 0, 0);
45 for (unsigned int i = 0; i < g_game_group->list_count; i++)
47 LRESULT res = SendMessage(cbox,
50 (LPARAM)g_game_group->lists[i]->root_name);
51 if (res == CB_ERR || res == CB_ERRSPACE)
55 SendMessage(cbox, CB_SETITEMDATA, i, (LPARAM)g_game_group->lists[i]);
57 SendMessage(cbox, CB_SETCURSEL, 0, 0);
59 UpdateGameListBox(hDlg, g_game_group->lists[0]);
61 SetToGlobalPosition(hDlg);
67 if (LOWORD(wParam) == ID_SELGAME_EXIT
68 || LOWORD(wParam) == ID_CLOSE)
70 return AskToExit(hDlg);
72 else if (LOWORD(wParam) == ID_SELGAME_BACK)
74 UpdateGlobalPosition(hDlg);
75 EndDialog(hDlg, (INT_PTR)DisplayChooseMethod);
78 else if (LOWORD(wParam) == IDC_SELGROUP_ACCOUNT)
80 if (HIWORD(wParam) == CBN_SELCHANGE)
82 HWND cbox = (HWND)lParam;
83 LRESULT cursel = SendMessage(cbox, CB_GETCURSEL, 0, 0);
90 LRESULT data = SendMessage(cbox, CB_GETITEMDATA, cursel, 0);
96 game_list_t *gl = (game_list_t *)data;
97 UpdateGameListBox(hDlg, gl);
101 else if (LOWORD(wParam) == IDC_SELGAME_LIST)
103 if (HIWORD(wParam) == LBN_SELCHANGE)
105 HWND lbox = (HWND)lParam;
106 LRESULT cursel = SendMessage(lbox, LB_GETCURSEL, 0, 0);
108 selected_game_index = -1;
110 if (cursel == LB_ERR)
115 LRESULT item = SendMessage(lbox, LB_GETITEMDATA, cursel, 0);
121 selected_game_index = (int)item;
123 HWND button = GetDlgItem(hDlg, ID_SELGAME_NEXT);
124 EnableWindow(button, TRUE);
127 else if (LOWORD(wParam) == ID_SELGAME_NEXT)
129 if (selected_game_index == -1)
134 g_LocalCopier.SetOutputPath(g_games.game_list[selected_game_index].game_path);
135 SetInstallMethod(&g_LocalCopier);
137 UpdateGlobalPosition(hDlg);
138 EndDialog(hDlg, (INT_PTR)DisplayPerformInstall);
140 return (INT_PTR)TRUE;
151 return (INT_PTR)FALSE;
154 void *DisplaySelectGame(HWND hWnd)
158 if ((val = DialogBox(
160 MAKEINTRESOURCE(IDD_SELECT_GAME),
162 ChooseGameHandler)) == -1)