Fix scenario editor launch scenario feature run from .app

Fix #729
This commit is contained in:
2025-05-17 08:38:12 -05:00
parent 0f79f6fc9f
commit 99b0c9a227
2 changed files with 12 additions and 1 deletions

View File

@@ -122,16 +122,22 @@ static void launch_scenario(eLaunchType type) {
// Prompt to save first
if(!save_check("save-before-launch", false)) return;
fs::path app_folder = fs::current_path();
fs::path game_binary;
#ifdef SFML_SYSTEM_MACOS
game_binary = "Blades of Exile.app/Contents/MacOS/Blades of Exile";
// Run by double-click on app bundle
if(app_folder == "/"){
extern fs::path bundlePath();
app_folder = bundlePath().parent_path();
}
#elif defined(SFML_SYSTEM_WINDOWS)
game_binary = "Blades of Exile.exe";
#elif defined(SFML_SYSTEM_LINUX)
game_binary = "Blades of Exile";
#endif
game_binary = bp::search_path(game_binary, {fs::current_path()});
game_binary = bp::search_path(game_binary, {app_folder});
if(game_binary.empty()){
showError("The current working directory does not contain Blades of Exile.");
return;

View File

@@ -174,3 +174,8 @@ bool sync_prefs_mac() {
return [[NSUserDefaults standardUserDefaults] synchronize];
}
// Used in scen.main.cpp to find BoE app bundle, but uses a static function (convertValue()) in this file.
fs::path bundlePath() {
NSBundle *main = [NSBundle mainBundle];
return convertValue(main.bundlePath);
}