| 76 | Please select the folder where Midnight Club 2 was installed."; |
| 77 | |
| 78 | static boost::filesystem::path ask_game_path() { |
| 79 | HRESULT res; |
| 80 | int button; |
| 81 | boost::filesystem::path path; |
| 82 | |
| 83 | if (SUCCEEDED(res = CoInitializeEx(nullptr, |
| 84 | COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))) { |
| 85 | |
| 86 | button = MessageBox(nullptr, InfoBoxMessage, InfoBoxTitle, MB_OKCANCEL); |
| 87 | |
| 88 | while (SUCCEEDED(res) && button == IDOK) { |
| 89 | IFileDialog *dialog; |
| 90 | if (SUCCEEDED(res = CoCreateInstance(CLSID_FileOpenDialog, nullptr, |
| 91 | CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&dialog)))) { |
| 92 | |
| 93 | FILEOPENDIALOGOPTIONS opt; |
| 94 | if (SUCCEEDED(res = dialog->GetOptions(&opt))) { |
| 95 | if (SUCCEEDED(res = dialog->SetOptions(opt | FOS_PICKFOLDERS | FOS_DONTADDTORECENT))) { |
| 96 | |
| 97 | if (SUCCEEDED(res = dialog->Show(nullptr))) { |
| 98 | IShellItem *item; |
| 99 | if (SUCCEEDED(res = dialog->GetResult(&item))) { |
| 100 | |
| 101 | LPWSTR pathstr; |
| 102 | if (SUCCEEDED(res = item->GetDisplayName(SIGDN_FILESYSPATH, &pathstr))) { |
| 103 | path = pathstr; |
| 104 | if (boost::filesystem::is_regular_file(path / config_assets_name)) button = 0; |
| 105 | else path.clear(), button = MessageBox(nullptr, BadDirMessage, InfoBoxTitle, MB_OKCANCEL); |
| 106 | } |
| 107 | item->Release(); |
| 108 | } |
| 109 | } else if (res == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { |
| 110 | dialog->Release(); |
| 111 | CoUninitialize(); |
| 112 | std::exit(0); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | dialog->Release(); |
| 117 | } |
| 118 | } |
| 119 | CoUninitialize(); |
| 120 | } |
| 121 | |
| 122 | if (FAILED(res)) throw _com_error(res); |
| 123 | if (button != 0) std::exit(0); |
| 124 | |
| 125 | return path; |
| 126 | } |
| 127 | |
| 128 | static boost::filesystem::path get_config_path() { |
| 129 | return get_documents_path() / "OpenMC2" / "OpenMC2.config"; |