turn resethelp pref led into a button with a confirmation dialog
This commit is contained in:
10
rsrc/dialogs/confirm-reset-help.xml
Normal file
10
rsrc/dialogs/confirm-reset-help.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||
<dialog defbtn='no'>
|
||||
<button name='no' type='regular' def-key='n' top='39' left='244'>No</button>
|
||||
<button name='yes' type='regular' def-key='y' top='39' left='178'>Yes</button>
|
||||
<pict type='dlog' num='11' top='9' left='9'/>
|
||||
<text top='4' left='51' width='251' height='32'>
|
||||
Really reset instant help messages?
|
||||
</text>
|
||||
</dialog>
|
@@ -31,13 +31,13 @@
|
||||
<led name='nosound' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='117'>No Sounds</led>
|
||||
<led name='repeatdesc' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='287'>Show room descriptions more than once</led>
|
||||
<led name='nohelp' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='306'>Never show instant help</led>
|
||||
<led name='resethelp' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='340'>
|
||||
Reset instant help (all help windows will reappear)
|
||||
</led>
|
||||
<led name='easier' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='352'>Make game easier (monsters much weaker)</led>
|
||||
<led name='lesswm' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='340'>Fewer wandering monsters</led>
|
||||
<led name='skipsplash' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='340'>Skip splash screen on startup</led>
|
||||
<text name='scale-head' size='large' relative='neg pos' anchor='skipsplash' top='17' left='10' width='260' height='17'>Scale UI:</text>
|
||||
<button name='resethelp' type='tiny' relative='pos-in pos' rel-anchor='prev' top='10' left='0' width='340'>
|
||||
Reset instant help (all help windows will reappear)
|
||||
</button>
|
||||
<text name='scale-head' size='large' relative='neg pos' rel-anchor='prev' top='17' left='10' width='260' height='17'>Scale UI:</text>
|
||||
<group name='scaleui'>
|
||||
<led name='1' relative='pos-in pos' anchor='scale-head' top='4' left='15' width='33'>1</led>
|
||||
<led name='1_5' relative='pos-in pos' anchor='scale-head' top='4' left='55' width='33'>1.5</led>
|
||||
|
@@ -1161,10 +1161,7 @@ void do_sign(short town_num, short which_sign, short sign_type) {
|
||||
sign.show();
|
||||
}
|
||||
|
||||
void save_prefs(bool resetHelp){
|
||||
|
||||
if(resetHelp) clear_pref("ReceivedHelp");
|
||||
|
||||
void save_prefs(){
|
||||
bool success = sync_prefs();
|
||||
if(!success){
|
||||
showWarning("There was a problem writing to the preferences file. When the game is next run the preferences will revert to their previously set values.","Should you manage to resolve the problem without closing the program, simply open the preferences screen and click \"OK\" to try again.");
|
||||
@@ -1172,7 +1169,7 @@ void save_prefs(bool resetHelp){
|
||||
}
|
||||
|
||||
static bool prefs_event_filter (cDialog& me, std::string id, eKeyMod) {
|
||||
bool did_cancel = false,reset_help = false;
|
||||
bool did_cancel = false;
|
||||
|
||||
if(id == "okay") {
|
||||
me.toast(true);
|
||||
@@ -1220,9 +1217,6 @@ static bool prefs_event_filter (cDialog& me, std::string id, eKeyMod) {
|
||||
set_pref("GameSpeed", 2);
|
||||
else if(speed == "snail")
|
||||
set_pref("GameSpeed", 3);
|
||||
if(dynamic_cast<cLed&>(me["resethelp"]).getState() == led_red) {
|
||||
reset_help = true;
|
||||
}
|
||||
std::string scale = dynamic_cast<cLedGroup&>(me["scaleui"]).getSelected();
|
||||
if(scale == "1")
|
||||
set_pref("UIScale", 1.0);
|
||||
@@ -1246,10 +1240,15 @@ static bool prefs_event_filter (cDialog& me, std::string id, eKeyMod) {
|
||||
else if(scale_map == "4")
|
||||
set_pref("UIScaleMap", 4.0);
|
||||
}
|
||||
save_prefs(reset_help);
|
||||
save_prefs();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool reset_help(cDialog& me, std::string id, eKeyMod) {
|
||||
if(cChoiceDlog("confirm-reset-help", {"yes", "no"}, &me).show() == "yes")
|
||||
clear_pref("ReceivedHelp");
|
||||
}
|
||||
|
||||
void pick_preferences(bool record) {
|
||||
if(record && recording){
|
||||
record_action("pick_preferences", "");
|
||||
@@ -1259,6 +1258,7 @@ void pick_preferences(bool record) {
|
||||
|
||||
cDialog prefsDlog(*ResMgr::dialogs.get("preferences"));
|
||||
prefsDlog.attachClickHandlers(&prefs_event_filter, {"okay", "cancel"});
|
||||
prefsDlog.attachClickHandlers(&reset_help, {"resethelp"});
|
||||
|
||||
cLedGroup& displayMode = dynamic_cast<cLedGroup&>(prefsDlog["display"]);
|
||||
switch(get_int_pref("DisplayMode")) {
|
||||
|
@@ -22,7 +22,7 @@ void do_talk(short personality, unsigned short m_num);
|
||||
void put_party_stats();
|
||||
void edit_party();
|
||||
void pick_preferences(bool record = true);
|
||||
void save_prefs(bool resetHelp = false);
|
||||
void save_prefs();
|
||||
void tip_of_day();
|
||||
struct scen_header_type pick_a_scen();
|
||||
|
||||
|
Reference in New Issue
Block a user