mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-23 16:19:44 +00:00
Use flags to specify wanted data in gamecache.
This commit is contained in:
parent
0416f0d918
commit
a0340debd6
@ -296,7 +296,7 @@ public:
|
||||
info_->iconDataLoaded = true;
|
||||
}
|
||||
|
||||
if (info_->wantBG) {
|
||||
if (info_->wantFlags & GAMEINFO_WANTBG) {
|
||||
if (pbp.GetSubFileSize(PBP_PIC1_PNG) > 0) {
|
||||
lock_guard lock(info_->lock);
|
||||
pbp.GetSubFileAsString(PBP_PIC1_PNG, &info_->pic1TextureData);
|
||||
@ -343,7 +343,7 @@ handleELF:
|
||||
|
||||
ReadFileToString(&umd, "/PSP_GAME/ICON0.PNG", &info_->iconTextureData, &info_->lock);
|
||||
info_->iconDataLoaded = true;
|
||||
if (info_->wantBG) {
|
||||
if (info_->wantFlags & GAMEINFO_WANTBG) {
|
||||
ReadFileToString(&umd, "/PSP_GAME/PIC0.PNG", &info_->pic0TextureData, &info_->lock);
|
||||
info_->pic0DataLoaded = true;
|
||||
ReadFileToString(&umd, "/PSP_GAME/PIC1.PNG", &info_->pic1TextureData, &info_->lock);
|
||||
@ -371,7 +371,7 @@ handleELF:
|
||||
info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size());
|
||||
info_->ParseParamSFO();
|
||||
|
||||
if (info_->wantBG) {
|
||||
if (info_->wantFlags & GAMEINFO_WANTBG) {
|
||||
ReadFileToString(&umd, "/PSP_GAME/PIC0.PNG", &info_->pic0TextureData, &info_->lock);
|
||||
info_->pic0DataLoaded = true;
|
||||
ReadFileToString(&umd, "/PSP_GAME/PIC1.PNG", &info_->pic1TextureData, &info_->lock);
|
||||
@ -396,7 +396,6 @@ handleELF:
|
||||
|
||||
case FILETYPE_ARCHIVE_ZIP:
|
||||
info_->paramSFOLoaded = true;
|
||||
info_->wantBG = false;
|
||||
{
|
||||
// Read standard icon
|
||||
size_t sz;
|
||||
@ -412,7 +411,6 @@ handleELF:
|
||||
|
||||
case FILETYPE_ARCHIVE_RAR:
|
||||
info_->paramSFOLoaded = true;
|
||||
info_->wantBG = false;
|
||||
{
|
||||
// Read standard icon
|
||||
size_t sz;
|
||||
@ -429,12 +427,10 @@ handleELF:
|
||||
case FILETYPE_NORMAL_DIRECTORY:
|
||||
default:
|
||||
info_->paramSFOLoaded = true;
|
||||
info_->wantBG = false;
|
||||
break;
|
||||
}
|
||||
// probably only want these when we ask for the background image...
|
||||
// should maybe flip the flag to "onlyIcon"
|
||||
if (info_->wantBG) {
|
||||
|
||||
if (info_->wantFlags & GAMEINFO_WANTSIZE) {
|
||||
info_->gameSize = info_->GetGameSizeInBytes();
|
||||
info_->saveDataSize = info_->GetSaveDataSizeInBytes();
|
||||
info_->installDataSize = info_->GetInstallDataSizeInBytes();
|
||||
@ -525,20 +521,20 @@ void GameInfoCache::FlushBGs() {
|
||||
delete iter->second->pic1Texture;
|
||||
iter->second->pic1Texture = 0;
|
||||
}
|
||||
iter->second->wantBG = false;
|
||||
iter->second->wantFlags &= ~GAMEINFO_WANTBG;
|
||||
}
|
||||
}
|
||||
|
||||
// This may run off-main-thread and we thus can't use the global
|
||||
// pspFileSystem (well, we could with synchronization but there might not
|
||||
// even be a game running).
|
||||
GameInfo *GameInfoCache::GetInfo(const std::string &gamePath, bool wantBG) {
|
||||
GameInfo *GameInfoCache::GetInfo(const std::string &gamePath, int wantFlags) {
|
||||
GameInfo *info = 0;
|
||||
|
||||
auto iter = info_.find(gamePath);
|
||||
if (iter != info_.end()) {
|
||||
info = iter->second;
|
||||
if (!info->wantBG && wantBG) {
|
||||
if ((info->wantFlags & wantFlags) != wantFlags) {
|
||||
// Need to start over. We'll just add a new work item.
|
||||
goto again;
|
||||
}
|
||||
@ -562,7 +558,7 @@ again:
|
||||
}
|
||||
{
|
||||
lock_guard lock(info->lock);
|
||||
info->wantBG = wantBG;
|
||||
info->wantFlags |= wantFlags;
|
||||
}
|
||||
|
||||
GameInfoWorkItem *item = new GameInfoWorkItem(gamePath, info);
|
||||
|
@ -42,6 +42,11 @@ enum GameRegion {
|
||||
GAMEREGION_MAX,
|
||||
};
|
||||
|
||||
enum GameInfoWantFlags {
|
||||
GAMEINFO_WANTBG = 0x01,
|
||||
GAMEINFO_WANTSIZE = 0x02,
|
||||
};
|
||||
|
||||
// TODO: Need to fix c++11 still on Symbian and use std::atomic<bool> instead.
|
||||
class CompletionFlag {
|
||||
public:
|
||||
@ -86,7 +91,7 @@ class GameInfo {
|
||||
public:
|
||||
GameInfo()
|
||||
: disc_total(0), disc_number(0), region(-1), fileType(FILETYPE_UNKNOWN), paramSFOLoaded(false),
|
||||
iconTexture(NULL), pic0Texture(NULL), pic1Texture(NULL), wantBG(false),
|
||||
iconTexture(NULL), pic0Texture(NULL), pic1Texture(NULL), wantFlags(0),
|
||||
timeIconWasLoaded(0.0), timePic0WasLoaded(0.0), timePic1WasLoaded(0.0),
|
||||
gameSize(0), saveDataSize(0), installDataSize(0) {}
|
||||
|
||||
@ -128,7 +133,7 @@ public:
|
||||
std::string pic1TextureData;
|
||||
Texture *pic1Texture;
|
||||
|
||||
bool wantBG;
|
||||
int wantFlags;
|
||||
|
||||
double lastAccessedTime;
|
||||
|
||||
@ -161,7 +166,7 @@ public:
|
||||
// but filled in later asynchronously in the background. So keep calling this,
|
||||
// redrawing the UI often. Only set wantBG if you really want it because
|
||||
// it's big. bgTextures may be discarded over time as well.
|
||||
GameInfo *GetInfo(const std::string &gamePath, bool wantBG);
|
||||
GameInfo *GetInfo(const std::string &gamePath, int wantFlags);
|
||||
void Decimate(); // Deletes old info.
|
||||
void FlushBGs(); // Gets rid of all BG textures.
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "Core/Config.h"
|
||||
|
||||
void GameScreen::CreateViews() {
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
|
||||
I18NCategory *d = GetI18NCategory("Dialog");
|
||||
I18NCategory *ga = GetI18NCategory("Game");
|
||||
@ -92,7 +92,7 @@ void GameScreen::update(InputState &input) {
|
||||
UIScreen::update(input);
|
||||
|
||||
I18NCategory *ga = GetI18NCategory("Game");
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
|
||||
if (tvTitle_)
|
||||
tvTitle_->SetText(info->title + " (" + info->id + ")");
|
||||
@ -153,7 +153,7 @@ UI::EventReturn GameScreen::OnPlay(UI::EventParams &e) {
|
||||
}
|
||||
|
||||
UI::EventReturn GameScreen::OnGameSettings(UI::EventParams &e) {
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
if (info && info->paramSFOLoaded) {
|
||||
std::string discID = info->paramSFO.GetValueString("DISC_ID");
|
||||
screenManager()->push(new GameSettingsScreen(gamePath_, discID));
|
||||
@ -164,7 +164,7 @@ UI::EventReturn GameScreen::OnGameSettings(UI::EventParams &e) {
|
||||
UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) {
|
||||
I18NCategory *d = GetI18NCategory("Dialog");
|
||||
I18NCategory *ga = GetI18NCategory("Game");
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
if (info) {
|
||||
screenManager()->push(
|
||||
new PromptScreen(d->T("DeleteConfirmAll", "Do you really want to delete all\nyour save data for this game?"), ga->T("ConfirmDelete"), d->T("Cancel"),
|
||||
@ -176,7 +176,7 @@ UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) {
|
||||
}
|
||||
|
||||
void GameScreen::CallbackDeleteSaveData(bool yes) {
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, false);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, 0);
|
||||
if (yes) {
|
||||
info->DeleteAllSaveData();
|
||||
info->saveDataSize = 0;
|
||||
@ -187,7 +187,7 @@ void GameScreen::CallbackDeleteSaveData(bool yes) {
|
||||
UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) {
|
||||
I18NCategory *d = GetI18NCategory("Dialog");
|
||||
I18NCategory *ga = GetI18NCategory("Game");
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
if (info) {
|
||||
screenManager()->push(
|
||||
new PromptScreen(d->T("DeleteConfirmGame", "Do you really want to delete this game\nfrom your device? You can't undo this."), ga->T("ConfirmDelete"), d->T("Cancel"),
|
||||
@ -198,7 +198,7 @@ UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) {
|
||||
}
|
||||
|
||||
void GameScreen::CallbackDeleteGame(bool yes) {
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, false);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, 0);
|
||||
if (yes) {
|
||||
info->DeleteGame();
|
||||
g_gameInfoCache.Clear();
|
||||
@ -207,7 +207,7 @@ void GameScreen::CallbackDeleteGame(bool yes) {
|
||||
}
|
||||
|
||||
UI::EventReturn GameScreen::OnCreateShortcut(UI::EventParams &e) {
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, false);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, 0);
|
||||
if (info) {
|
||||
host->CreateDesktopShortcut(gamePath_, info->title);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ extern bool iosCanUseJit;
|
||||
#endif
|
||||
|
||||
void GameSettingsScreen::CreateViews() {
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true);
|
||||
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
|
||||
cap60FPS_ = g_Config.iForceMaxEmulatedFPS == 60;
|
||||
|
||||
|
@ -173,7 +173,7 @@ private:
|
||||
};
|
||||
|
||||
void GameButton::Draw(UIContext &dc) {
|
||||
GameInfo *ginfo = g_gameInfoCache.GetInfo(gamePath_, false);
|
||||
GameInfo *ginfo = g_gameInfoCache.GetInfo(gamePath_, 0);
|
||||
Texture *texture = 0;
|
||||
u32 color = 0, shadowColor = 0;
|
||||
|
||||
@ -936,7 +936,7 @@ bool MainScreen::DrawBackgroundFor(UIContext &dc, const std::string &gamePath, f
|
||||
|
||||
GameInfo *ginfo = 0;
|
||||
if (!gamePath.empty()) {
|
||||
ginfo = g_gameInfoCache.GetInfo(gamePath, true);
|
||||
ginfo = g_gameInfoCache.GetInfo(gamePath, GAMEINFO_WANTBG);
|
||||
// Loading texture data may bind a texture.
|
||||
dc.RebindTexture();
|
||||
|
||||
|
@ -105,7 +105,7 @@ void DrawBackground(UIContext &dc, float alpha = 1.0f) {
|
||||
}
|
||||
|
||||
void DrawGameBackground(UIContext &dc, const std::string &gamePath) {
|
||||
GameInfo *ginfo = g_gameInfoCache.GetInfo(gamePath, true);
|
||||
GameInfo *ginfo = g_gameInfoCache.GetInfo(gamePath, GAMEINFO_WANTBG);
|
||||
dc.Flush();
|
||||
|
||||
if (ginfo) {
|
||||
|
Loading…
Reference in New Issue
Block a user