| 73 | } |
| 74 | |
| 75 | static fs::path resolveLocoInstallPath() |
| 76 | { |
| 77 | autoCreateDirectory(Platform::getUserDirectory()); |
| 78 | auto& cfg = Config::get(); |
| 79 | |
| 80 | // Validate any existing configured install path first |
| 81 | auto path = fs::u8path(cfg.locoInstallPath); |
| 82 | if (!path.empty()) |
| 83 | { |
| 84 | if (validateLocoInstallPath(path)) |
| 85 | { |
| 86 | return path; |
| 87 | } |
| 88 | Logging::error("Configured Locomotion game folder is missing Data/g1.DAT."); |
| 89 | } |
| 90 | |
| 91 | // Try to detect the Locomotion install path |
| 92 | path = autoDetectLocoInstallPath(); |
| 93 | if (!path.empty()) |
| 94 | { |
| 95 | cfg.locoInstallPath = path.make_preferred().u8string(); |
| 96 | Config::write(); |
| 97 | return path; |
| 98 | } |
| 99 | |
| 100 | Logging::error("Unable to automatically find the Locomotion game folder.\n" |
| 101 | "Please provide the location manually."); |
| 102 | Ui::showMessageBox("OpenLoco", "Unable to automatically detect the Locomotion game folder.\n" |
| 103 | "Please locate the Locomotion game folder manually."); |
| 104 | |
| 105 | // Let user manually specify the Locomotion install folder, and verify files are present |
| 106 | // |
| 107 | // FIXME: Instead of passing the hwnd we should have a function to bring the window to the front after |
| 108 | // this call. |
| 109 | path = Platform::promptDirectory("Locate original Locomotion game files", Ui::hwnd()); |
| 110 | if (validateLocoInstallPath(path)) |
| 111 | { |
| 112 | cfg.locoInstallPath = path.make_preferred().u8string(); |
| 113 | Config::write(); |
| 114 | return path; |
| 115 | } |
| 116 | |
| 117 | // Files could not be located -- bail with a helpful error message |
| 118 | Logging::error("The selected folder does not contain Data/g1.DAT"); |
| 119 | Ui::showMessageBox("OpenLoco", "The selected folder does not contain Data/g1.DAT, suggesting it is not a Locomotion\n" |
| 120 | "install folder. Please verify the folder contains the original Locomotion game files,\n" |
| 121 | "then restart OpenLoco to try again."); |
| 122 | |
| 123 | std::exit(-1); |
| 124 | } |
| 125 | |
| 126 | #ifndef _WIN32 |
| 127 | /** |
no test coverage detected