Skip to content

Commit

Permalink
Merge pull request #18736 from hrydgard/cwcheat-wait-gameinfo
Browse files Browse the repository at this point in the history
CwCheats: Retry looking in g_gameInfoCache until the data is there.
  • Loading branch information
hrydgard committed Jan 20, 2024
2 parents 97647a5 + f1d19cd commit 7cff030
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
13 changes: 11 additions & 2 deletions UI/CwCheatScreen.cpp
Expand Up @@ -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/")) {
Expand All @@ -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() {
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion UI/CwCheatScreen.h
Expand Up @@ -33,7 +33,7 @@ class CwCheatScreen : public UIDialogScreenWithGameBackground {
CwCheatScreen(const Path &gamePath);
~CwCheatScreen();

void LoadCheatInfo();
bool TryLoadCheatInfo();

UI::EventReturn OnAddCheat(UI::EventParams &params);
UI::EventReturn OnImportCheat(UI::EventParams &params);
Expand Down
12 changes: 9 additions & 3 deletions UI/GameSettingsScreen.cpp
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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" };

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7cff030

Please sign in to comment.