From 965bfb2c55731373756ad7399105808a346c07bd Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 23 Jun 2025 13:09:41 -0500 Subject: [PATCH] add image editor preference to scenedit --- rsrc/dialogs/pref-scenario.xml | 18 +++++++++++------- src/scenedit/scen.main.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/rsrc/dialogs/pref-scenario.xml b/rsrc/dialogs/pref-scenario.xml index eb405f4a..552eeff7 100644 --- a/rsrc/dialogs/pref-scenario.xml +++ b/rsrc/dialogs/pref-scenario.xml @@ -8,12 +8,12 @@ No UI Sounds Scale UI: - 1 - 1.5 - 2 - 3 - 4 - + 1 + 1.5 + 2 + 3 + 4 + Debug Party: @@ -21,6 +21,10 @@ Force default party (ignore above) - + Image Editor: + + + + diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 607190aa..67bf12c7 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -903,6 +903,7 @@ static bool prefs_event_filter (cDialog& me, std::string id, eKeyMod) { set_pref("PlaySounds", dynamic_cast(me["nosound"]).getState() == led_off); set_pref("ForceDefaultParty", dynamic_cast(me["force-default-party"]).getState() == led_red); set_pref("DefaultPartyPath", dynamic_cast(me["party-path"]).getText()); + set_pref("ImageEditor", dynamic_cast(me["image-editor"]).getText()); } save_prefs(); return true; @@ -974,6 +975,23 @@ void pick_preferences() { return true; }); + cTextField& image_editor_field = dynamic_cast(prefsDlog["image-editor"]); + image_editor_field.setText(get_string_pref("ImageEditor")); + + image_editor_field.attachFocusHandler([](cDialog& me, std::string id, bool losing) -> bool { + if(!losing) return true; + std::string image_editor = me[id].getText(); + // Validate the debug party + if(!image_editor.empty()){ + if(!fs::exists(image_editor)){ + showError("Your chosen image editor cannot be found.", "", &me); + me[id].setText(get_string_pref("ImageEditor")); + return false; + } + } + return true; + }); + cButton& choose_button = dynamic_cast(prefsDlog["choose-party"]); choose_button.attachClickHandler([&default_party_field](cDialog&, std::string, eKeyMod) -> bool { fs::path new_path = nav_get_party(); @@ -982,6 +1000,15 @@ void pick_preferences() { } return true; }); + + cButton& choose_img_button = dynamic_cast(prefsDlog["choose-image-editor"]); + choose_img_button.attachClickHandler([&image_editor_field](cDialog&, std::string, eKeyMod) -> bool { + fs::path new_path = nav_get_rsrc({"exe", "app", ""}); + if(!new_path.empty()){ + image_editor_field.setText(new_path.string()); + } + return true; + }); prefsDlog.run();