DRY advanced town help. Fix #611
This commit is contained in:
@@ -127,11 +127,17 @@ void showFatalError(std::string str1, std::string str2, cDialog* parent) {
|
||||
static void give_help(short help1,short help2,cDialog* parent,bool help_forced) {
|
||||
std::string str1,str2;
|
||||
|
||||
if(!help_forced && (!get_bool_pref("ShowInstantHelp", true) || get_iarray_pref_contains("ReceivedHelp", help1)))
|
||||
if(help_text_rsrc.empty()){
|
||||
throw std::string {"Tried to call give_help() without setting help_text_rsrc!"};
|
||||
}
|
||||
|
||||
if(!help_forced && help_text_rsrc == "help" &&
|
||||
(!get_bool_pref("ShowInstantHelp", true) || get_iarray_pref_contains("ReceivedHelp", help1))){
|
||||
return;
|
||||
}
|
||||
append_iarray_pref("ReceivedHelp", help1);
|
||||
append_iarray_pref("ReceivedHelp", help2);
|
||||
str1 = get_str("help",help1);
|
||||
str1 = get_str(help_text_rsrc,help1);
|
||||
if(help2 > 0)
|
||||
str2 = get_str("help",help2);
|
||||
cStrDlog display_strings(str1,str2,"Instant Help",24,PIC_DLOG, parent);
|
||||
|
@@ -87,6 +87,8 @@ void showWarning(std::string str1, std::string str2, cDialog* parent = nullptr);
|
||||
/// @param parent Optionally, a parent dialog.
|
||||
void showWarning(std::string str1, cDialog* parent = nullptr);
|
||||
|
||||
extern std::string help_text_rsrc;
|
||||
|
||||
// Show a help window with the given messages from rsrc/strings/help.txt:
|
||||
void give_help(short help1, short help2, bool help_forced = false);
|
||||
void give_help(short help1, short help2, cDialog& parent, bool help_forced = false);
|
||||
|
@@ -87,6 +87,7 @@ bool scen_arg_start = false;
|
||||
boost::optional<short> scen_arg_town, scen_arg_town_entrance;
|
||||
boost::optional<location> scen_arg_out_sec, scen_arg_loc;
|
||||
extern std::string last_load_file;
|
||||
std::string help_text_rsrc = "help";
|
||||
|
||||
struct cParseEntrance {
|
||||
boost::optional<short>& opt;
|
||||
|
@@ -49,6 +49,7 @@ rectangle pc_race_rect; //Holds current pc's race
|
||||
rectangle edit_rect[5]; //Buttons that bring up pc edit dialog boxs
|
||||
std::string scenario_temp_dir_name = "pc_scenario";
|
||||
std::vector<fs::path> extra_scen_dirs;
|
||||
std::string help_text_rsrc = "help";
|
||||
|
||||
short current_active_pc = 0;
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -11,6 +11,7 @@ std::string scenario_temp_dir_name = "test_scenario";
|
||||
cCustomGraphics spec_scen_g;
|
||||
cUniverse univ;
|
||||
std::vector<fs::path> extra_scen_dirs;
|
||||
std::string help_text_rsrc;
|
||||
|
||||
bool check_for_interrupt(std::string) { return false; }
|
||||
|
||||
|
Reference in New Issue
Block a user