make give_help() DRY
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "dialogxml/widgets/pict.hpp"
|
||||
#include "fileio/resmgr/res_dialog.hpp"
|
||||
#include "mathutil.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
DialogDefn& cStrDlog::getDefn(short n_strs, ePicType type, bool hasTitle){
|
||||
std::ostringstream sout;
|
||||
@@ -121,3 +122,32 @@ void showFatalError(std::string str1, cDialog* parent) {
|
||||
void showFatalError(std::string str1, std::string str2, cDialog* parent) {
|
||||
giveError(25, "Error!!!", str1, str2, parent);
|
||||
}
|
||||
|
||||
// Call this anywhere, but don't forget parent!!!
|
||||
static void give_help(short help1,short help2,cDialog* parent) {
|
||||
bool help_forced = false;
|
||||
std::string str1,str2;
|
||||
|
||||
if(help1 >= 200) {
|
||||
help_forced = true;
|
||||
help1 -= 200;
|
||||
}
|
||||
if(!help_forced && (!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);
|
||||
if(help2 > 0)
|
||||
str2 = get_str("help",help2);
|
||||
cStrDlog display_strings(str1,str2,"Instant Help",24,PIC_DLOG, parent);
|
||||
display_strings.setSound(57);
|
||||
display_strings.show();
|
||||
}
|
||||
|
||||
void give_help(short help1, short help2) {
|
||||
give_help(help1, help2, nullptr);
|
||||
}
|
||||
|
||||
void give_help(short help1, short help2, cDialog& parent) {
|
||||
give_help(help1, help2, &parent);
|
||||
}
|
||||
@@ -87,4 +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);
|
||||
|
||||
// Show a help window with the given messages from rsrc/strings/help.txt:
|
||||
void give_help(short help1, short help2);
|
||||
void give_help(short help1, short help2, cDialog& parent);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -664,35 +664,6 @@ void add_to_journal(short event) {
|
||||
ASB("Something was added to your journal.");
|
||||
}
|
||||
|
||||
// Call call this anywhere, but don't forget parent!!!
|
||||
static void give_help(short help1,short help2,cDialog* parent) {
|
||||
bool help_forced = false;
|
||||
std::string str1,str2;
|
||||
|
||||
if(help1 >= 200) {
|
||||
help_forced = true;
|
||||
help1 -= 200;
|
||||
}
|
||||
if(!help_forced && (!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);
|
||||
if(help2 > 0)
|
||||
str2 = get_str("help",help2);
|
||||
cStrDlog display_strings(str1,str2,"Instant Help",24,PIC_DLOG, parent);
|
||||
display_strings.setSound(57);
|
||||
display_strings.show();
|
||||
}
|
||||
|
||||
void give_help(short help1, short help2) {
|
||||
give_help(help1, help2, nullptr);
|
||||
}
|
||||
|
||||
void give_help(short help1, short help2, cDialog& parent) {
|
||||
give_help(help1, help2, &parent);
|
||||
}
|
||||
|
||||
void put_quest_info(short which_i) {
|
||||
cQuest& quest = univ.scenario.quests[which_i];
|
||||
cDialog quest_dlg(*ResMgr::dialogs.get("quest-info"));
|
||||
@@ -736,7 +707,7 @@ void cStringRecorder::operator()(cDialog& me) {
|
||||
break;
|
||||
}
|
||||
if(univ.party.record(type, str1, location))
|
||||
give_help(58,0,&me);
|
||||
give_help(58,0,me);
|
||||
univ.party.record(type, str2, location);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ void display_alchemy(bool allowEdit,cDialog* parent);
|
||||
bool spend_xp(short pc_num, short mode, cDialog* parent);
|
||||
// TODO: There's probably a more logical way of arranging this
|
||||
|
||||
extern void give_help(short help1, short help2);
|
||||
extern void give_help(short help1, short help2, cDialog& parent);
|
||||
void display_skills(eSkill skill,cDialog* parent);
|
||||
|
||||
extern cUniverse univ;
|
||||
|
||||
@@ -455,39 +455,6 @@ bool verify_restore_quit(std::string dlog) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// These functions are duplicated here because they're used in the training dialog.
|
||||
void give_help(short help1, short help2);
|
||||
void give_help(short help1, short help2, cDialog& parent);
|
||||
void display_skills(eSkill skill,cDialog* parent);
|
||||
|
||||
static void give_help(short help1,short help2,cDialog* parent) {
|
||||
bool help_forced = false;
|
||||
std::string str1,str2;
|
||||
|
||||
if(help1 >= 200) {
|
||||
help_forced = true;
|
||||
help1 -= 200;
|
||||
}
|
||||
if(!help_forced && (!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);
|
||||
if(help2 > 0)
|
||||
str2 = get_str("help",help2);
|
||||
cStrDlog display_strings(str1,str2,"Instant Help",24,PIC_DLOG, parent);
|
||||
display_strings.setSound(57);
|
||||
display_strings.show();
|
||||
}
|
||||
|
||||
void give_help(short help1, short help2) {
|
||||
give_help(help1, help2, nullptr);
|
||||
}
|
||||
|
||||
void give_help(short help1, short help2, cDialog& parent) {
|
||||
give_help(help1, help2, &parent);
|
||||
}
|
||||
|
||||
void display_skills(eSkill skill,cDialog* parent) {
|
||||
extern std::map<eSkill,short> skill_cost;
|
||||
extern std::map<eSkill,short> skill_max;
|
||||
|
||||
Reference in New Issue
Block a user