Jeck - Fixed issue with destructor not being called on OptionProfile, split settings into tabs.

This commit is contained in:
wagic.jeck
2009-08-27 14:08:38 +00:00
parent 99aa284431
commit db1730ee7f
4 changed files with 37 additions and 45 deletions
+19 -20
View File
@@ -178,7 +178,6 @@ GameSettings::GameSettings()
globalOptions = NEW GameOptions(GLOBAL_SETTINGS); globalOptions = NEW GameOptions(GLOBAL_SETTINGS);
//Load profile options. //Load profile options.
char buf[512];
string temp = (*globalOptions)[Options::ACTIVE_PROFILE.substr(2)].str; string temp = (*globalOptions)[Options::ACTIVE_PROFILE.substr(2)].str;
if(temp == "") if(temp == "")
temp = "Default"; temp = "Default";
@@ -186,24 +185,6 @@ GameSettings::GameSettings()
profileOptions = NULL; profileOptions = NULL;
checkProfile(); checkProfile();
//Force a theme.
temp = (*profileOptions)[Options::ACTIVE_THEME].str;
if(temp == ""){
temp = "Default";
(*profileOptions)[Options::ACTIVE_THEME].str = "Default";
}
//Load theme options
if(temp == "Default")
sprintf(buf,RESPATH"/graphics/metrics.txt");
else{
sprintf(buf,RESPATH"/themes/%s/",temp.c_str());
MAKEDIR(buf);
sprintf(buf,RESPATH"/themes/%s/metrics.txt",temp.c_str());
}
themeOptions = NEW GameOptions(buf);
} }
GameSettings::~GameSettings(){ GameSettings::~GameSettings(){
@@ -284,7 +265,8 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
void GameSettings::checkProfile(){ void GameSettings::checkProfile(){
//Load current profile's options. Doesn't save prior set. //Load current profile's options. Doesn't save prior set.
if(profileOptions != NULL)
char buf[512];
SAFE_DELETE(profileOptions); SAFE_DELETE(profileOptions);
//Force our directories to exist. //Force our directories to exist.
@@ -296,6 +278,23 @@ void GameSettings::checkProfile(){
temp = profileFile(PLAYER_SETTINGS,"",false); temp = profileFile(PLAYER_SETTINGS,"",false);
profileOptions = NEW GameOptions(temp); profileOptions = NEW GameOptions(temp);
//Force a theme.
temp = (*profileOptions)[Options::ACTIVE_THEME].str;
if(temp == ""){
temp = "Default";
(*profileOptions)[Options::ACTIVE_THEME].str = "Default";
}
//Load theme options
if(temp == "Default")
sprintf(buf,RESPATH"/graphics/metrics.txt");
else{
sprintf(buf,RESPATH"/themes/%s/metrics.txt",temp.c_str());
}
themeOptions = NEW GameOptions(buf);
//Validation of collection, etc, only happens if the game is up. //Validation of collection, etc, only happens if the game is up.
if(theGame == NULL || theGame->collection == NULL) if(theGame == NULL || theGame->collection == NULL)
return; return;
+9 -9
View File
@@ -29,25 +29,25 @@ void GameStateOptions::Start()
OptionsList * optionsList; OptionsList * optionsList;
optionsList = NEW OptionsList("Settings"); optionsList = NEW OptionsList("Settings");
OptionProfile * pickProf = NEW OptionProfile(mParent);
optionsList->Add(pickProf);
OptionNewProfile * key = NEW OptionNewProfile("","New Profile");
key->bShowValue = false;
optionsList->Add(key);
optionsList->Add(NEW OptionHeader("General Options"));
if (GameApp::HasMusic) optionsList->Add(NEW OptionInteger(Options::MUSICVOLUME, "Music volume", 100, 10)); if (GameApp::HasMusic) optionsList->Add(NEW OptionInteger(Options::MUSICVOLUME, "Music volume", 100, 10));
optionsList->Add(NEW OptionInteger(Options::SFXVOLUME, "SFX volume", 100, 10)); optionsList->Add(NEW OptionInteger(Options::SFXVOLUME, "SFX volume", 100, 10));
optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information")); optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information"));
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number) if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
optionsList->Add(NEW OptionInteger(Options::DIFFICULTY, "Difficulty", 3, 1)); optionsList->Add(NEW OptionInteger(Options::DIFFICULTY, "Difficulty", 3, 1));
optionsList->Add(NEW OptionHeader("Interrupts"));
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1)); optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYSPELLS, "Interrupt my spells")); optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYSPELLS, "Interrupt my spells"));
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities")); optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities"));
optionsList->Add(NEW OptionHeader("System Options"));
optionsList->Add(NEW OptionInteger(Options::CACHESIZE, "Image Cache Size", 60, 5)); optionsList->Add(NEW OptionInteger(Options::CACHESIZE, "Image Cache Size", 60, 5));
optionsTabs = NEW OptionsMenu(); optionsTabs = NEW OptionsMenu();
optionsTabs->Add(optionsList);
optionsList = NEW OptionsList("Profiles");
OptionProfile * pickProf = NEW OptionProfile(mParent);
optionsList->Add(pickProf);
OptionNewProfile * key = NEW OptionNewProfile("","New Profile");
key->bShowValue = false;
optionsList->Add(key);
optionsTabs->Add(optionsList); optionsTabs->Add(optionsList);
optionsList = NEW OptionsList("Credits"); optionsList = NEW OptionsList("Credits");
optionsList->failMsg = ""; optionsList->failMsg = "";
+2 -6
View File
@@ -223,15 +223,11 @@ void OptionProfile::populate(){
options[Options::ACTIVE_PROFILE].str = selections[value]; options[Options::ACTIVE_PROFILE].str = selections[value];
SAFE_DELETE(mAvatar);
SAFE_DELETE(mAvatarTex); SAFE_DELETE(mAvatarTex);
mAvatarTex = JRenderer::GetInstance()->LoadTexture(options.profileFile("avatar.jpg","",true,true).c_str(), false); mAvatarTex = JRenderer::GetInstance()->LoadTexture(options.profileFile("avatar.jpg","",true,true).c_str(), false);
if (mAvatarTex) { if (mAvatarTex)
SAFE_DELETE(mAvatar);
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50); mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
renderer->BindTexture(mAvatarTex); //Prevents font corruption.
}
else
mAvatar = NULL;
options.checkProfile(); options.checkProfile();
PlayerData * pdata = NEW PlayerData(app->collection); PlayerData * pdata = NEW PlayerData(app->collection);
+5 -8
View File
@@ -13,11 +13,10 @@ WResourceManager::WResourceManager(){
jrm = NEW JResourceManager(); jrm = NEW JResourceManager();
} }
WResourceManager::~WResourceManager(){ WResourceManager::~WResourceManager(){
delete(jrm); SAFE_DELETE(jrm);
} }
string WResourceManager::graphicsFile(const string filename, const string specific) string WResourceManager::graphicsFile(const string filename, const string specific){
{
char buf[512]; char buf[512];
//Check the specific location, if any. //Check the specific location, if any.
@@ -62,8 +61,7 @@ string WResourceManager::graphicsFile(const string filename, const string specif
return graphdir; return graphdir;
} }
string WResourceManager::musicFile(const string filename, const string specific) string WResourceManager::musicFile(const string filename, const string specific){
{
char buf[512]; char buf[512];
//Check the specific location, if any. //Check the specific location, if any.
@@ -103,8 +101,7 @@ string WResourceManager::musicFile(const string filename, const string specific)
return defdir; return defdir;
} }
string WResourceManager::sfxFile(const string filename, const string specific) string WResourceManager::sfxFile(const string filename, const string specific){
{
char buf[512]; char buf[512];
//Check the specific location, if any. //Check the specific location, if any.
@@ -143,7 +140,7 @@ string WResourceManager::sfxFile(const string filename, const string specific)
return defdir; return defdir;
} }
bool WResourceManager::fileOK(string filename, bool relative){ int WResourceManager::fileOK(string filename, bool relative){
if(relative){ if(relative){
char buf[512]; char buf[512];