Save help received to prefs file
This commit is contained in:
@@ -1096,9 +1096,14 @@ void load_prefs(){
|
|||||||
PSD[SDF_EASY_MODE] = get_bool_pref("EasyMode");
|
PSD[SDF_EASY_MODE] = get_bool_pref("EasyMode");
|
||||||
PSD[SDF_LESS_WANDER_ENC] = get_bool_pref("LessWanderingMonsters");
|
PSD[SDF_LESS_WANDER_ENC] = get_bool_pref("LessWanderingMonsters");
|
||||||
PSD[SDF_GAME_SPEED] = get_int_pref("GameSpeed");
|
PSD[SDF_GAME_SPEED] = get_int_pref("GameSpeed");
|
||||||
|
|
||||||
|
std::vector<int> help = get_iarray_pref("ReceivedHelp");
|
||||||
|
for(int i : help)
|
||||||
|
if(i < 120)
|
||||||
|
univ.party.help_received[i] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_prefs(){
|
void save_prefs(bool resetHelp){
|
||||||
set_pref("GiveIntroHint", give_intro_hint);
|
set_pref("GiveIntroHint", give_intro_hint);
|
||||||
set_pref("DisplayMode", display_mode);
|
set_pref("DisplayMode", display_mode);
|
||||||
set_pref("PlaySounds", play_sounds);
|
set_pref("PlaySounds", play_sounds);
|
||||||
@@ -1118,6 +1123,8 @@ void save_prefs(){
|
|||||||
set_pref("GameSpeed", PSD[SDF_GAME_SPEED]);
|
set_pref("GameSpeed", PSD[SDF_GAME_SPEED]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(resetHelp) clear_pref("ReceivedHelp");
|
||||||
|
|
||||||
bool success = sync_prefs();
|
bool success = sync_prefs();
|
||||||
if(!success){
|
if(!success){
|
||||||
giveError("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.");
|
giveError("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.");
|
||||||
@@ -1127,7 +1134,7 @@ void save_prefs(){
|
|||||||
bool prefs_event_filter (cDialog& me, std::string id, eKeyMod mods)
|
bool prefs_event_filter (cDialog& me, std::string id, eKeyMod mods)
|
||||||
{
|
{
|
||||||
// TODO: I should no longer need done_yet as this now only handles the okay and cancel buttons; the LEDs are now handled automatically by the cLed class (and the cLedGroup class, for LED groups).
|
// TODO: I should no longer need done_yet as this now only handles the okay and cancel buttons; the LEDs are now handled automatically by the cLed class (and the cLedGroup class, for LED groups).
|
||||||
bool done_yet = false,did_cancel = false;
|
bool done_yet = false,did_cancel = false,reset_help = false;
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
if(id == "okay") {
|
if(id == "okay") {
|
||||||
@@ -1169,13 +1176,15 @@ bool prefs_event_filter (cDialog& me, std::string id, eKeyMod mods)
|
|||||||
PSD[SDF_GAME_SPEED] = 2;
|
PSD[SDF_GAME_SPEED] = 2;
|
||||||
else if(speed == "snail")
|
else if(speed == "snail")
|
||||||
PSD[SDF_GAME_SPEED] = 3;
|
PSD[SDF_GAME_SPEED] = 3;
|
||||||
if(dynamic_cast<cLed&>(me["resethelp"]).getState() == led_red)
|
if(dynamic_cast<cLed&>(me["resethelp"]).getState() == led_red) {
|
||||||
for (i = 0; i < 120; i++)
|
for (i = 0; i < 120; i++)
|
||||||
univ.party.help_received[i] = 0;
|
univ.party.help_received[i] = 0;
|
||||||
|
reset_help = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
save_maps = 1 - PSD[SDF_NO_MAPS];
|
save_maps = 1 - PSD[SDF_NO_MAPS];
|
||||||
give_delays = PSD[SDF_NO_FRILLS];
|
give_delays = PSD[SDF_NO_FRILLS];
|
||||||
save_prefs();
|
save_prefs(reset_help);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ void pick_preferences() ;
|
|||||||
//void check_pref_file() ;
|
//void check_pref_file() ;
|
||||||
//long open_pref_file();
|
//long open_pref_file();
|
||||||
//void make_pref_file(FSSpec pref);
|
//void make_pref_file(FSSpec pref);
|
||||||
void save_prefs();
|
void save_prefs(bool resetHelp = false);
|
||||||
void load_prefs();
|
void load_prefs();
|
||||||
void tip_of_day();
|
void tip_of_day();
|
||||||
short pick_a_scen();
|
short pick_a_scen();
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "restypes.hpp"
|
#include "restypes.hpp"
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include "prefs.hpp"
|
||||||
|
|
||||||
short mage_spell_pos = 0,priest_spell_pos = 0,skill_pos = 0;
|
short mage_spell_pos = 0,priest_spell_pos = 0,skill_pos = 0;
|
||||||
cPlayer *store_pc;
|
cPlayer *store_pc;
|
||||||
@@ -1219,6 +1220,7 @@ void give_help(short help1,short help2,cDialog* parent)
|
|||||||
return;
|
return;
|
||||||
//if (help1 >= 20)
|
//if (help1 >= 20)
|
||||||
univ.party.help_received[help1] = 1;
|
univ.party.help_received[help1] = 1;
|
||||||
|
append_iarray_pref("ReceivedHelp", help1);
|
||||||
str1 = get_str("help",help1);
|
str1 = get_str("help",help1);
|
||||||
if (help2 > 0)
|
if (help2 > 0)
|
||||||
str2 = get_str("help",help2);
|
str2 = get_str("help",help2);
|
||||||
|
@@ -268,9 +268,6 @@ void init_party(short mode)
|
|||||||
univ.party.party_event_timers.clear();
|
univ.party.party_event_timers.clear();
|
||||||
for (i = 0; i < 50; i++)
|
for (i = 0; i < 50; i++)
|
||||||
univ.party.spec_items[i] = 0;
|
univ.party.spec_items[i] = 0;
|
||||||
for (i = 0; i < 120; i++) {
|
|
||||||
univ.party.help_received[i] = 0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 200; i++)
|
for (i = 0; i < 200; i++)
|
||||||
univ.party.m_killed[i] = 0;
|
univ.party.m_killed[i] = 0;
|
||||||
univ.party.scen_name = "";
|
univ.party.scen_name = "";
|
||||||
|
Reference in New Issue
Block a user