DRY advanced town help. Fix #611

This commit is contained in:
2025-02-15 17:41:06 -06:00
committed by Celtic Minstrel
parent 0f6aa4f139
commit 8cff2428a9
7 changed files with 20 additions and 10 deletions

View File

@@ -67,6 +67,9 @@ std::string scenario_temp_dir_name = "ed_scenario";
bool change_made = false, ae_loading = false;
std::vector<fs::path> extra_scen_dirs;
// Set this based on context before calling give_help():
std::string help_text_rsrc = "";
// Numbers of current areas being edited
short cur_town;
location cur_out;

View File

@@ -40,6 +40,7 @@ extern cScenario scenario;
extern cOutdoors* current_terrain;
extern location cur_out;
extern cUndoList undo_list;
extern std::string help_text_rsrc;
const char *day_str_1[] = {"Unused","Day creature appears","Day creature disappears",
"Unused","Unused","Unused","Unused","Unused","Unused"};
@@ -784,6 +785,7 @@ static bool edit_advanced_town_special(cDialog& me, std::string hit, eKeyMod) {
void edit_advanced_town() {
using namespace std::placeholders;
help_text_rsrc = "town-advanced-help";
cDialog town_dlg(*ResMgr::dialogs.get("edit-town-advanced"));
town_dlg["okay"].attachClickHandler(save_advanced_town);
@@ -808,10 +810,7 @@ void edit_advanced_town() {
auto iter = std::find(help_ids.begin(), help_ids.end(), which);
if(iter == help_ids.end()) return true;
int n = iter - help_ids.begin();
std::string str = get_str("town-advanced-help",1 + n);
cStrDlog display_help(str,"","Instant Help",24,PIC_DLOG, &me);
display_help.setSound(57);
display_help.show();
give_help(1 + n, 0, me, true);
return true;
}, help_ids);
// TODO: This should probably be a focus handler, but the focus handler doesn't receive the modifiers
@@ -821,10 +820,7 @@ void edit_advanced_town() {
auto iter = std::find(prop_ids.begin(), prop_ids.end(), which);
if(iter == prop_ids.end()) return true;
int n = iter - prop_ids.begin();
std::string str = get_str("town-advanced-help",10 + n);
cStrDlog display_help(str,"","Instant Help",24,PIC_DLOG, &me);
display_help.setSound(57);
display_help.show();
give_help(10 + n, 0, me, true);
return false;
}
dynamic_cast<cLed&>(me[which]).defaultClickHandler(me, which, mod);