CwCheats: Retry looking in g_gameInfoCache until the data is there.

Replaces #18733

Fixes at least one instance of #18694, don't know if there are other
causes.
This commit is contained in:
Henrik Rydgård 2024-01-20 20:07:38 +01:00
parent 97647a561d
commit f1d19cd736
3 changed files with 21 additions and 6 deletions

View File

@ -47,11 +47,13 @@ CwCheatScreen::~CwCheatScreen() {
delete engine_;
}
void CwCheatScreen::LoadCheatInfo() {
bool CwCheatScreen::TryLoadCheatInfo() {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0);
std::string gameID;
if (info && info->paramSFOLoaded) {
gameID = info->paramSFO.GetValueString("DISC_ID");
} else {
return false;
}
if ((info->id.empty() || !info->disc_total)
&& gamePath_.FilePathContainsNoCase("PSP/GAME/")) {
@ -76,6 +78,7 @@ void CwCheatScreen::LoadCheatInfo() {
// Let's also trigger a reload, in case it changed.
g_Config.bReloadCheats = true;
return true;
}
void CwCheatScreen::CreateViews() {
@ -86,7 +89,7 @@ void CwCheatScreen::CreateViews() {
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
LoadCheatInfo();
TryLoadCheatInfo(); // in case the info is already in cache.
Margins actionMenuMargins(50, -15, 15, 0);
LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(400, FILL_PARENT));
@ -134,6 +137,12 @@ void CwCheatScreen::CreateViews() {
}
void CwCheatScreen::update() {
if (gameID_.empty()) {
if (TryLoadCheatInfo()) {
RecreateViews();
}
}
if (fileCheckCounter_++ >= FILE_CHECK_FRAME_INTERVAL && engine_) {
// Check if the file has changed. If it has, we'll reload.
std::string str;

View File

@ -33,7 +33,7 @@ public:
CwCheatScreen(const Path &gamePath);
~CwCheatScreen();
void LoadCheatInfo();
bool TryLoadCheatInfo();
UI::EventReturn OnAddCheat(UI::EventParams &params);
UI::EventReturn OnImportCheat(UI::EventParams &params);

View File

@ -323,6 +323,9 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
return UI::EVENT_DONE;
});
msaaChoice->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && !g_Config.bSkipBufferEffects;
});
if (g_Config.iMultiSampleLevel > 1 && draw->GetDeviceCaps().isTilingGPU) {
msaaChoice->SetIcon(ImageID("I_WARNING"), 0.7f);
}
@ -429,7 +432,8 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
});
skipBufferEffects->SetDisabledPtr(&g_Config.bSoftwareRendering);
graphicsSettings->Add(new CheckBox(&g_Config.bDisableRangeCulling, gr->T("Disable culling")));
CheckBox *disableCulling = graphicsSettings->Add(new CheckBox(&g_Config.bDisableRangeCulling, gr->T("Disable culling")));
disableCulling->SetDisabledPtr(&g_Config.bSoftwareRendering);
static const char *skipGpuReadbackModes[] = { "No (default)", "Skip", "Copy to texture" };
@ -552,9 +556,11 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
anisoFiltering->SetDisabledPtr(&g_Config.bSoftwareRendering);
static const char *texFilters[] = { "Auto", "Nearest", "Linear", "Auto Max Quality"};
graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexFiltering, gr->T("Texture Filter"), texFilters, 1, ARRAY_SIZE(texFilters), I18NCat::GRAPHICS, screenManager()));
PopupMultiChoice *filters = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexFiltering, gr->T("Texture Filter"), texFilters, 1, ARRAY_SIZE(texFilters), I18NCat::GRAPHICS, screenManager()));
filters->SetDisabledPtr(&g_Config.bSoftwareRendering);
graphicsSettings->Add(new CheckBox(&g_Config.bSmart2DTexFiltering, gr->T("Smart 2D texture filtering")));
CheckBox *smartFiltering = graphicsSettings->Add(new CheckBox(&g_Config.bSmart2DTexFiltering, gr->T("Smart 2D texture filtering")));
smartFiltering->SetDisabledPtr(&g_Config.bSoftwareRendering);
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS)
bool showCardboardSettings = deviceType != DEVICE_TYPE_VR;