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

View File

@@ -178,7 +178,6 @@ GameSettings::GameSettings()
globalOptions = NEW GameOptions(GLOBAL_SETTINGS);
//Load profile options.
char buf[512];
string temp = (*globalOptions)[Options::ACTIVE_PROFILE.substr(2)].str;
if(temp == "")
temp = "Default";
@@ -186,24 +185,6 @@ GameSettings::GameSettings()
profileOptions = NULL;
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(){
@@ -284,8 +265,9 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
void GameSettings::checkProfile(){
//Load current profile's options. Doesn't save prior set.
if(profileOptions != NULL)
SAFE_DELETE(profileOptions);
char buf[512];
SAFE_DELETE(profileOptions);
//Force our directories to exist.
MAKEDIR(RESPATH"/profiles");
@@ -296,6 +278,23 @@ void GameSettings::checkProfile(){
temp = profileFile(PLAYER_SETTINGS,"",false);
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.
if(theGame == NULL || theGame->collection == NULL)
return;

View File

@@ -29,25 +29,25 @@ void GameStateOptions::Start()
OptionsList * optionsList;
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));
optionsList->Add(NEW OptionInteger(Options::SFXVOLUME, "SFX volume", 100, 10));
optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information"));
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
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::INTERRUPTMYSPELLS, "Interrupt my spells"));
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));
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);
optionsList = NEW OptionsList("Credits");
optionsList->failMsg = "";

View File

@@ -223,15 +223,11 @@ void OptionProfile::populate(){
options[Options::ACTIVE_PROFILE].str = selections[value];
SAFE_DELETE(mAvatar);
SAFE_DELETE(mAvatarTex);
mAvatarTex = JRenderer::GetInstance()->LoadTexture(options.profileFile("avatar.jpg","",true,true).c_str(), false);
if (mAvatarTex) {
SAFE_DELETE(mAvatar);
if (mAvatarTex)
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
renderer->BindTexture(mAvatarTex); //Prevents font corruption.
}
else
mAvatar = NULL;
options.checkProfile();
PlayerData * pdata = NEW PlayerData(app->collection);

View File

@@ -13,11 +13,10 @@ WResourceManager::WResourceManager(){
jrm = NEW JResourceManager();
}
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];
//Check the specific location, if any.
@@ -62,8 +61,7 @@ string WResourceManager::graphicsFile(const string filename, const string specif
return graphdir;
}
string WResourceManager::musicFile(const string filename, const string specific)
{
string WResourceManager::musicFile(const string filename, const string specific){
char buf[512];
//Check the specific location, if any.
@@ -103,8 +101,7 @@ string WResourceManager::musicFile(const string filename, const string specific)
return defdir;
}
string WResourceManager::sfxFile(const string filename, const string specific)
{
string WResourceManager::sfxFile(const string filename, const string specific){
char buf[512];
//Check the specific location, if any.
@@ -143,7 +140,7 @@ string WResourceManager::sfxFile(const string filename, const string specific)
return defdir;
}
bool WResourceManager::fileOK(string filename, bool relative){
int WResourceManager::fileOK(string filename, bool relative){
if(relative){
char buf[512];
@@ -214,4 +211,4 @@ JMusic * WResourceManager::ssLoadMusic(const char *fileName){
}
JSample * WResourceManager::ssLoadSample(const char *fileName){
return JSoundSystem::GetInstance()->LoadSample(sfxFile(fileName).c_str());
}
}