From 1a2c0ed07b39bf5c54dcf8eacc4fa5c8cd888bd2 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Wed, 15 Jan 2025 19:53:54 -0600 Subject: [PATCH] editor validate the debug party preference --- src/scenedit/SConscript | 5 +++-- src/scenedit/scen.main.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/scenedit/SConscript b/src/scenedit/SConscript index e0b7958a..4e80d7de 100644 --- a/src/scenedit/SConscript +++ b/src/scenedit/SConscript @@ -1,5 +1,5 @@ -Import("env platform common_sources install_dir") +Import("env platform common_sources party_classes install_dir") scened_sources = Split(""" scen.actions.cpp @@ -11,6 +11,7 @@ scened_sources = Split(""" scen.main.cpp scen.townout.cpp ../view_dialogs.cpp + ../fileio/fileio_party.cpp """) if str(platform) == "darwin": @@ -30,7 +31,7 @@ elif str(platform) == "posix": scen.menu.cpp """)) -scened = env.Program("#build/bin/BoE Scenario Editor", scened_sources + common_sources) +scened = env.Program("#build/bin/BoE Scenario Editor", scened_sources + common_sources + party_classes) debug_symbols = None if str(platform) == "win32" and 'msvc' in env["TOOLS"] and not env['release']: debug_symbols = scened[0].abspath.replace('.exe', '.pdb') diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 61a6da24..17be5225 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -43,6 +43,7 @@ #include "tools/event_listener.hpp" #include "tools/drawable_manager.hpp" #include "tools/keymods.hpp" +#include "universe/universe.hpp" #ifdef __APPLE__ short menuChoiceId=-1; @@ -864,6 +865,21 @@ void pick_preferences() { cTextField& default_party_field = dynamic_cast(prefsDlog["party-path"]); default_party_field.setText(get_string_pref("DefaultPartyPath")); + default_party_field.attachFocusHandler([](cDialog& me, std::string id, bool losing) -> bool { + if(!losing) return true; + std::string debug_party = me[id].getText(); + // Validate the debug party + if(!debug_party.empty()){ + cUniverse univ; + if(!load_party(debug_party, univ)){ + showError("Your chosen debug party could not be loaded.", "", &me); + me[id].setText(get_string_pref("DefaultPartyPath")); + return false; + } + } + return true; + }); + cButton& choose_button = dynamic_cast(prefsDlog["choose-party"]); choose_button.attachClickHandler([&default_party_field](cDialog& me, std::string, eKeyMod) -> bool { fs::path new_path = nav_get_party();