Even less file I/O in menu screens, by caching "hasConfig" flag for game info. See #7807

This commit is contained in:
Henrik Rydgard 2015-09-10 17:17:26 +02:00
parent dc4fb4ca76
commit 05c625ed06
5 changed files with 12 additions and 3 deletions

View file

@ -556,6 +556,8 @@ handleELF:
break;
}
info_->hasConfig = g_Config.hasGameConfig(info_->id);
if (info_->wantFlags & GAMEINFO_WANTSIZE) {
info_->gameSize = info_->GetGameSizeInBytes();
info_->saveDataSize = info_->GetSaveDataSizeInBytes();

View file

@ -96,7 +96,7 @@ class GameInfo {
public:
GameInfo()
: disc_total(0), disc_number(0), region(-1), fileType(FILETYPE_UNKNOWN), paramSFOLoaded(false),
iconTexture(nullptr), pic0Texture(nullptr), pic1Texture(nullptr), wantFlags(0),
hasConfig(false), iconTexture(nullptr), pic0Texture(nullptr), pic1Texture(nullptr), wantFlags(0),
lastAccessedTime(0.0), timeIconWasLoaded(0.0), timePic0WasLoaded(0.0), timePic1WasLoaded(0.0),
gameSize(0), saveDataSize(0), installDataSize(0), fileLoader(nullptr) {}
~GameInfo();
@ -133,6 +133,7 @@ public:
IdentifiedFileType fileType;
ParamSFOData paramSFO;
bool paramSFOLoaded;
bool hasConfig;
// Pre read the data, create a texture the next time (GL thread..)
std::string iconTextureData;

View file

@ -89,7 +89,7 @@ void GameScreen::CreateViews() {
rightColumnItems->Add(play)->OnClick.Handle(this, &GameScreen::OnPlay);
if (info && !info->id.empty())
{
if (g_Config.hasGameConfig(info->id))
if (info->hasConfig)
{
rightColumnItems->Add(new Choice(ga->T("Game Settings")))->OnClick.Handle(this, &GameScreen::OnGameSettings);
rightColumnItems->Add(new Choice(ga->T("Delete Game Config")))->OnClick.Handle(this, &GameScreen::OnDeleteConfig);
@ -120,6 +120,7 @@ UI::EventReturn GameScreen::OnCreateConfig(UI::EventParams &e)
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_,0);
g_Config.createGameConfig(info->id);
g_Config.saveGameConfig(info->id);
info->hasConfig = true;
screenManager()->topScreen()->RecreateViews();
return UI::EVENT_DONE;

View file

@ -310,7 +310,7 @@ void GameButton::Draw(UIContext &dc) {
} else {
dc.Draw()->Flush();
}
if (!ginfo->id.empty() && g_Config.hasGameConfig(ginfo->id))
if (!ginfo->id.empty() && ginfo->hasConfig)
{
dc.Draw()->DrawImage(I_GEAR, x, y + h - ui_images[I_GEAR].h, 1.0f);
}

View file

@ -408,6 +408,7 @@ void GamePauseScreen::CallbackDeleteConfig(bool yes)
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0);
g_Config.unloadGameConfig();
g_Config.deleteGameConfig(info->id);
info->hasConfig = false;
screenManager()->RecreateAllViews();
}
}
@ -418,6 +419,10 @@ UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e)
g_Config.createGameConfig(gameId);
g_Config.changeGameSpecific(gameId);
g_Config.saveGameConfig(gameId);
GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0);
if (info) {
info->hasConfig = true;
}
screenManager()->topScreen()->RecreateViews();
return UI::EVENT_DONE;