From f1d19cd736676393f2a3c705bb67239a7a0bfc4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 20 Jan 2024 20:07:38 +0100 Subject: [PATCH] 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. --- UI/CwCheatScreen.cpp | 13 +++++++++++-- UI/CwCheatScreen.h | 2 +- UI/GameSettingsScreen.cpp | 12 +++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 4b29880dc9d6..0da51d756f82 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -47,11 +47,13 @@ CwCheatScreen::~CwCheatScreen() { delete engine_; } -void CwCheatScreen::LoadCheatInfo() { +bool CwCheatScreen::TryLoadCheatInfo() { std::shared_ptr 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; diff --git a/UI/CwCheatScreen.h b/UI/CwCheatScreen.h index ec6414598de8..108a1052680a 100644 --- a/UI/CwCheatScreen.h +++ b/UI/CwCheatScreen.h @@ -33,7 +33,7 @@ class CwCheatScreen : public UIDialogScreenWithGameBackground { CwCheatScreen(const Path &gamePath); ~CwCheatScreen(); - void LoadCheatInfo(); + bool TryLoadCheatInfo(); UI::EventReturn OnAddCheat(UI::EventParams ¶ms); UI::EventReturn OnImportCheat(UI::EventParams ¶ms); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a206b091cca0..f814bd41d881 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -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;