5 #pragma comment(lib, "Shlwapi.lib")
7 #pragma comment(lib, "Shell32.lib")
15 if (msg == BFFM_INITIALIZED) {
16 SendMessageA(hwnd, BFFM_SETSELECTION,
true,
data);
21 INT_PTR __stdcall
DialogProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
26 SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)app);
30 IDC_RADIO_RENDERER_DIRECTDRAW,
31 IDC_RADIO_RENDERER_OPENGL,
32 IDC_RADIO_RENDERER_DIRECTDRAW);
37 if (LOWORD(wparam) == IDC_BUTTON_BROWSE_INSTALL) {
43 ZeroMemory(&bi,
sizeof(bi));
44 bi.lParam = (LPARAM)choice;
46 bi.ulFlags = BIF_USENEWUI;
47 PIDLIST_ABSOLUTE list = SHBrowseForFolder(&bi);
49 SHGetPathFromIDListA(list, choice);
51 SendDlgItemMessageA(hwnd, IDC_EDIT_MM7_INSTALL_DIR, WM_SETTEXT,
55 }
else if (LOWORD(wparam) == IDC_BUTTON_LAUNCH) {
56 char mm7_install_dir[2000];
57 GetWindowTextA(GetDlgItem(hwnd, IDC_EDIT_MM7_INSTALL_DIR),
58 mm7_install_dir, 2000);
62 if (IsDlgButtonChecked(hwnd, IDC_RADIO_RENDERER_DIRECTDRAW) == BST_CHECKED) {
64 }
else if (IsDlgButtonChecked(hwnd, IDC_RADIO_RENDERER_OPENGL) == BST_CHECKED) {
70 MessageBoxA(hwnd, config_errors.c_str(),
71 "Configuration error", MB_OK);
73 PostMessage(hwnd, WM_QUIT, 0, 0);
93 return this->
config.mm7_install_path;
98 GetModuleFileNameA(GetModuleHandle(0),
buf, 2000);
104 return filename.substr(0, filename.find_last_of(
"\\/"));
111 if (!PathFileExistsA(mm7_exe_path.c_str())) {
113 "Might and Magic VII exe not found in: " +
config.mm7_install_path;
121 CoInitializeEx(0, COINIT_APARTMENTTHREADED);
123 auto module = GetModuleHandleA(
nullptr);
124 HWND dialog = CreateDialogParamA(module, MAKEINTRESOURCEA(IDD_FORMVIEW),
127 (HICON)LoadImageA(module, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0,
128 LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
129 SendMessageA(dialog, WM_SETICON, ICON_BIG, (LPARAM)icon);
130 SendDlgItemMessageA(dialog, IDC_EDIT_MM7_INSTALL_DIR, WM_SETTEXT, 0,
131 (LPARAM)
config.mm7_install_path.c_str());
134 while (GetMessageA(&msg, dialog, 0, 0)) {
135 TranslateMessage(&msg);
136 DispatchMessageA(&msg);
140 ZeroMemory(&si,
sizeof(si));
143 PROCESS_INFORMATION
pi;
144 ZeroMemory(&
pi,
sizeof(
pi));
147 std::string command_line = womm_filename +
" -window -nointro -nologo -novideo -nomarg -render=" +
GetRenderer();
149 std::vector<char> cmd(command_line.begin(), command_line.end());
152 womm_filename.c_str(), cmd.data(),
nullptr,
nullptr, FALSE,
153 NORMAL_PRIORITY_CLASS,
nullptr,
154 config.mm7_install_path.c_str(), &si, &
pi);