From 0283811ba4c5191e52e9b3726aeed8ca4cb781e0 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 11 Aug 2025 12:33:34 -0500 Subject: [PATCH] When shifting to town entrance, show outdoor loc str Fix #693 --- rsrc/dialogs/shift-town-entrance.xml | 5 ++--- src/scenario/area.hpp | 11 +++++++++++ src/scenedit/scen.actions.cpp | 9 ++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/rsrc/dialogs/shift-town-entrance.xml b/rsrc/dialogs/shift-town-entrance.xml index c28ff69e..65ae29df 100644 --- a/rsrc/dialogs/shift-town-entrance.xml +++ b/rsrc/dialogs/shift-town-entrance.xml @@ -5,8 +5,7 @@ - - Shift to this town's entrance in this outdoor section? + + Shift to this town's entrance in outdoor section {sec} at {loc} ({loc_str})? - diff --git a/src/scenario/area.hpp b/src/scenario/area.hpp index 8308235d..7d308087 100644 --- a/src/scenario/area.hpp +++ b/src/scenario/area.hpp @@ -54,6 +54,17 @@ public: bool is_on_map(location loc) const { return loc.x < max_dim && loc.y < max_dim && loc.x >= 0 && loc.y >= 0; } + + std::string loc_str(location where) { + std::string str = name; + for(info_rect_t rect : area_desc){ + if(!rect.empty() && rect.contains(where)){ + str += ": " + rect.descr; + break; + } + } + return str; + } }; #endif diff --git a/src/scenedit/scen.actions.cpp b/src/scenedit/scen.actions.cpp index afe42965..e4e6ae80 100644 --- a/src/scenedit/scen.actions.cpp +++ b/src/scenedit/scen.actions.cpp @@ -2335,7 +2335,10 @@ void handle_editor_screen_shift(int dx, int dy) { if(town_entrances.size() == 1){ town_entrance_t only_entrance = town_entrances[0]; cChoiceDlog shift_prompt("shift-town-entrance", {"yes", "no"}); - shift_prompt->getControl("out-sec").setText(boost::lexical_cast(only_entrance.out_sec)); + cControl& text = shift_prompt->getControl("prompt"); + text.replaceText("{sec}", boost::lexical_cast(only_entrance.out_sec)); + text.replaceText("{loc}", boost::lexical_cast(only_entrance.loc)); + text.replaceText("{loc_str}", scenario.outdoors[only_entrance.out_sec.x][only_entrance.out_sec.y]->loc_str(only_entrance.loc)); if(shift_prompt.show() == "yes"){ set_current_out(only_entrance.out_sec, true); @@ -2350,9 +2353,9 @@ void handle_editor_screen_shift(int dx, int dy) { std::vector entrance_strings; for(town_entrance_t entrance : town_entrances){ std::ostringstream sstr; - sstr << "Entrance in section " << entrance.out_sec << " at " << entrance.loc; + sstr << "Entrance in section " << entrance.out_sec << " at " << entrance.loc + << " (" <loc_str(entrance.loc) << ")"; entrance_strings.push_back(sstr.str()); - } cStringChoice dlog(entrance_strings, "Shift to one of this town's entrances in the outdoors?"); size_t choice = dlog.show(-1);