Jeck - Stopgap update fixing WResourceManager slowdown until complete rewrite.

This commit is contained in:
wagic.jeck
2009-08-27 23:24:55 +00:00
parent c5b530bd3b
commit 62e12380a4
7 changed files with 63 additions and 37 deletions
+1
View File
@@ -168,6 +168,7 @@ private:
class OptionsMenu
{
public:
JLBFont * mFont;
OptionsList * tabs[MAX_OPTION_TABS];
int nbitems;
int current;
+2 -1
View File
@@ -44,13 +44,14 @@ public:
JSample * ssLoadSample(const char *fileName);
//Our new redirect system.
string graphicsFile(const string filename, const string specific = "");
string graphicsFile(const string filename, const string specific = "", bool bFont = false);
string musicFile(const string filename, const string specific = "");
string sfxFile(const string filename, const string specific = "");
int fileOK(string filename, bool relative = false);
private:
JResourceManager * jrm;
map<string,string> stopgap;
};
#endif
+1 -1
View File
@@ -196,7 +196,7 @@ GameSettings::~GameSettings(){
SAFE_DELETE(globalOptions);
SAFE_DELETE(profileOptions);
SAFE_DELETE(themeOptions);
SAFE_DELETE(themeOptions);
}
GameOption& GameSettings::operator[](string option_name){
+9 -10
View File
@@ -29,6 +29,7 @@ void GameStateOptions::Start()
OptionsList * optionsList;
optionsList = NEW OptionsList("Settings");
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"));
@@ -86,11 +87,11 @@ void GameStateOptions::Update(float dt)
else if (mState == SHOW_OPTIONS){
switch(optionsTabs->Submode()){
case OPTIONS_SUBMODE_RELOAD:
optionsTabs->acceptSubmode();
optionsTabs->reloadValues();
mState = SHOW_OPTIONS;
break;
// case OPTIONS_SUBMODE_RELOAD:
// optionsTabs->acceptSubmode();
// optionsTabs->reloadValues();
// mState = SHOW_OPTIONS;
// break;
case OPTIONS_SUBMODE_PROFILE:
mState = SHOW_OPTIONS_PROFILE;
break;
@@ -107,8 +108,6 @@ void GameStateOptions::Update(float dt)
}else if(mState == SHOW_OPTIONS_PROFILE){
confirmMenu->Update(dt);
}
}
void GameStateOptions::Render()
@@ -189,13 +188,13 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
switch (controlId){
case 1:
//Load the new profile.
optionsTabs->acceptSubmode();
optionsTabs->reloadValues();
//optionsTabs->acceptSubmode();
//optionsTabs->reloadValues();
//Reset the current settings to those of the profile...
mState = SHOW_OPTIONS;
break;
case 2:
optionsTabs->cancelSubmode();
//optionsTabs->cancelSubmode();
mState = SHOW_OPTIONS;
break;
}
+7 -9
View File
@@ -214,7 +214,6 @@ void OptionProfile::updateValue(){
}
void OptionProfile::populate(){
JRenderer * renderer = JRenderer::GetInstance();
string temp = options[Options::ACTIVE_PROFILE].str;
if(value < 0 || value >= selections.size()){ //TODO fail gracefully.
@@ -226,8 +225,10 @@ void OptionProfile::populate(){
SAFE_DELETE(mAvatar);
SAFE_DELETE(mAvatarTex);
mAvatarTex = JRenderer::GetInstance()->LoadTexture(options.profileFile("avatar.jpg","",true,true).c_str(), false);
if (mAvatarTex)
if (mAvatarTex){
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
renderer->BindTexture(mAvatarTex);
}
options.checkProfile();
PlayerData * pdata = NEW PlayerData(app->collection);
@@ -453,8 +454,6 @@ void OptionsList::Render(){
}
}
//Always fill screen
if(listHeight > SCREEN_HEIGHT)
{
@@ -564,15 +563,13 @@ void OptionsMenu::Add(OptionsList * tab){
}
void OptionsMenu::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("f3");
if (!nbitems){
if (nbitems == 0){
mFont->DrawString("NO OPTIONS AVAILABLE",SCREEN_WIDTH/2, 5, JGETEXT_RIGHT);
return;
}
JRenderer * renderer = JRenderer::GetInstance();
int offset = 0;
for(int i=0;i<nbitems;i++){
int w = mFont->GetStringWidth(tabs[i]->sectionName.c_str());
@@ -589,7 +586,7 @@ void OptionsMenu::Render(){
}
if(current > -1 && current < nbitems && tabs[current])
tabs[current]->Render();
tabs[current]->Render();
}
void OptionsMenu::Update(float dt){
@@ -625,6 +622,7 @@ void OptionsMenu::Update(float dt){
OptionsMenu::OptionsMenu(){
nbitems=0;
current=0;
mFont = GameApp::CommonRes->GetJLBFont("f3");
for(int x=0;x<MAX_OPTION_TABS;x++)
tabs[x] = NULL;
}
+1 -1
View File
@@ -16,7 +16,7 @@
SimpleKey::SimpleKey( string _ds, int _id){
displayValue = _ds; id = _id;
for(int x=0;x<4;x++)
adjacency[4] = KPD_NOWHERE;
adjacency[x] = KPD_NOWHERE;
}
void SimplePad::linkKeys(int from, int to, int dir){
+42 -15
View File
@@ -16,14 +16,29 @@ WResourceManager::~WResourceManager(){
SAFE_DELETE(jrm);
}
string WResourceManager::graphicsFile(const string filename, const string specific){
string WResourceManager::graphicsFile(const string filename, const string specific, bool bFont){
char buf[512];
char file[512];
char lookup[512];
if(bFont)
sprintf(file,"%s.dat",filename.c_str());
else
sprintf(file,"%s",filename.c_str());
if(stopgap.find(filename) != stopgap.end())
return stopgap[filename];
//Check the specific location, if any.
if(specific != ""){
sprintf(buf,"%s/%s",specific.c_str(),filename.c_str());
if(fileOK(buf,true))
sprintf(buf,"%s/%s",specific.c_str(),file);
sprintf(lookup,"%s/%s",specific.c_str(),file);
if(fileOK(lookup,true)){
stopgap[filename] = buf;
return buf;
}
}
//Check the theme folder.
@@ -32,8 +47,11 @@ string WResourceManager::graphicsFile(const string filename, const string specif
if(theme != "" || theme != "default"){
sprintf(buf,"themes/%s/%s",theme.c_str(),filename.c_str());
if(fileOK(buf,true))
return buf;
sprintf(lookup,"themes/%s/%s",theme.c_str(),file);
if(fileOK(lookup,true)){
stopgap[filename] = buf;
return buf;
}
}
//Failure. Check mode graphics
@@ -41,21 +59,30 @@ string WResourceManager::graphicsFile(const string filename, const string specif
std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
if(mode != "" && mode != "defualt"){
sprintf(buf,"modes/graphics/%s",mode,filename.c_str());
if(fileOK(buf,true))
return buf;
sprintf(buf,"modes/%s/graphics/%s",mode.c_str(),filename.c_str());
sprintf(lookup,"modes/%s/graphics/%s",mode.c_str(),file);
if(fileOK(lookup,true)){
stopgap[filename] = buf;
return buf;
}
}
//Failure. Check graphics
char graphdir[512];
sprintf(graphdir,"graphics/%s",filename.c_str());
if(fileOK(graphdir,true))
return graphdir;
sprintf(lookup,"graphics/%s",file);
if(fileOK(lookup,true)){
stopgap[filename] = graphdir;
return graphdir;
}
//Failure. Check sets.
sprintf(buf,"sets/%s",filename.c_str());
if(fileOK(buf,true))
return buf;
sprintf(lookup,"sets/%s",file);
if(fileOK(lookup,true)){
stopgap[filename] = buf;
return buf;
}
//Complete abject failure. Probably a crash...
return graphdir;
@@ -86,7 +113,7 @@ string WResourceManager::musicFile(const string filename, const string specific)
std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
if(mode != "" && mode != "defualt"){
sprintf(buf,"modes/sound/%s",mode,filename.c_str());
sprintf(buf,"modes/%s/sound/%s",mode.c_str(),filename.c_str());
if(fileOK(buf,true))
return buf;
}
@@ -125,7 +152,7 @@ string WResourceManager::sfxFile(const string filename, const string specific){
string mode = options[Options::ACTIVE_MODE].str;
std::transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
if(mode != "" && mode != "defualt"){
sprintf(buf,"modes/sound/sfx/%s",mode,filename.c_str());
sprintf(buf,"modes/%s/sound/sfx/%s",mode.c_str(),filename.c_str());
if(fileOK(buf,true))
return buf;
}
@@ -175,7 +202,7 @@ int WResourceManager::LoadJLBFont(const string &fontName, int height){
return jrm->LoadJLBFont(graphicsFile(fontName), height);
}
JLBFont* WResourceManager::GetJLBFont(const string &fontName){
return jrm->GetJLBFont(graphicsFile(fontName));
return jrm->GetJLBFont(graphicsFile(fontName, "", true));
}
JLBFont* WResourceManager::GetJLBFont(int id){