From 0c9605ddb2ee42ac5eebd1450b0742d16acc6d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 18 Sep 2024 13:37:38 +0200 Subject: [PATCH] Allow showing the game-info screen from in-game. Disable some options that can cause problems. --- UI/GameScreen.cpp | 23 ++++++++++++++++++++--- UI/GameScreen.h | 3 ++- UI/MainScreen.cpp | 2 +- UI/PauseScreen.cpp | 21 +++++++++++++-------- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 6aa5d10f82..baca52fc58 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -51,7 +51,7 @@ #include "UI/SavedataScreen.h" #include "Core/Reporting.h" -GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { +GameScreen::GameScreen(const Path &gamePath, bool inGame) : UIDialogScreenWithGameBackground(gamePath), inGame_(inGame) { g_BackgroundAudio.SetGame(gamePath); System_PostUIMessage(UIMessage::GAME_SELECTED, gamePath.ToString()); } @@ -209,10 +209,16 @@ void GameScreen::CreateViews() { btnGameSettings_ = rightColumnItems->Add(new Choice(ga->T("Game Settings"))); btnGameSettings_->OnClick.Handle(this, &GameScreen::OnGameSettings); + btnDeleteGameConfig_ = rightColumnItems->Add(new Choice(ga->T("Delete Game Config"))); btnDeleteGameConfig_->OnClick.Handle(this, &GameScreen::OnDeleteConfig); + if (inGame_) + btnDeleteGameConfig_->SetEnabled(false); + btnCreateGameConfig_ = rightColumnItems->Add(new Choice(ga->T("Create Game Config"))); btnCreateGameConfig_->OnClick.Handle(this, &GameScreen::OnCreateConfig); + if (inGame_) + btnCreateGameConfig_->SetEnabled(false); btnGameSettings_->SetVisibility(V_GONE); btnDeleteGameConfig_->SetVisibility(V_GONE); @@ -224,7 +230,12 @@ void GameScreen::CreateViews() { otherChoices_.clear(); - rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Delete Game"))))->OnClick.Handle(this, &GameScreen::OnDeleteGame); + // Don't want to be able to delete the game while it's running. + Choice *deleteChoice = rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Delete Game")))); + deleteChoice->OnClick.Handle(this, &GameScreen::OnDeleteGame); + if (inGame_) { + deleteChoice->SetEnabled(false); + } if (System_GetPropertyBool(SYSPROP_CAN_CREATE_SHORTCUT)) { rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Create Shortcut"))))->OnClick.Add([=](UI::EventParams &e) { std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO); @@ -235,9 +246,15 @@ void GameScreen::CreateViews() { return UI::EVENT_DONE; }); } + if (isRecentGame(gamePath_)) { - rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Remove From Recent"))))->OnClick.Handle(this, &GameScreen::OnRemoveFromRecent); + Choice *removeButton = rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Remove From Recent")))); + removeButton->OnClick.Handle(this, &GameScreen::OnRemoveFromRecent); + if (inGame_) { + removeButton->SetEnabled(false); + } } + #if (defined(USING_QT_UI) || PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(MAC)) && !PPSSPP_PLATFORM(UWP) rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Show In Folder"))))->OnClick.Handle(this, &GameScreen::OnShowInFolder); #endif diff --git a/UI/GameScreen.h b/UI/GameScreen.h index 5638eb33c6..e065927881 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -33,7 +33,7 @@ class NoticeView; class GameScreen : public UIDialogScreenWithGameBackground { public: - GameScreen(const Path &gamePath); + GameScreen(const Path &gamePath, bool inGame); ~GameScreen(); void update() override; @@ -91,4 +91,5 @@ private: std::string CRC32string; bool isHomebrew_ = false; + bool inGame_ = false; }; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 2730803e47..0ea08ddf27 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1511,7 +1511,7 @@ UI::EventReturn MainScreen::OnGameSelected(UI::EventParams &e) { restoreFocusGamePath_ = highlightedGamePath_; g_BackgroundAudio.SetGame(path); lockBackgroundAudio_ = true; - screenManager()->push(new GameScreen(path)); + screenManager()->push(new GameScreen(path, false)); return UI::EVENT_DONE; } diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index a5d2e078e8..bfa00f2949 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -51,6 +51,7 @@ #include "UI/ReportScreen.h" #include "UI/CwCheatScreen.h" #include "UI/MainScreen.h" +#include "UI/GameScreen.h" #include "UI/OnScreenDisplay.h" #include "UI/GameInfoCache.h" #include "UI/DisplayLayoutScreen.h" @@ -445,14 +446,18 @@ void GamePauseScreen::CreateViews() { } if (!Core_MustRunBehind()) { - if (middleColumn) { - playButton_ = middleColumn->Add(new Button("", g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"), new LinearLayoutParams(64, 64))); - playButton_->OnClick.Add([=](UI::EventParams &e) { - g_Config.bRunBehindPauseMenu = !g_Config.bRunBehindPauseMenu; - playButton_->SetImageID(g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY")); - return UI::EVENT_DONE; - }); - } + playButton_ = middleColumn->Add(new Button("", g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"), new LinearLayoutParams(64, 64))); + playButton_->OnClick.Add([=](UI::EventParams &e) { + g_Config.bRunBehindPauseMenu = !g_Config.bRunBehindPauseMenu; + playButton_->SetImageID(g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY")); + return UI::EVENT_DONE; + }); + + Button *infoButton = middleColumn->Add(new Button("", ImageID("I_INFO"), new LinearLayoutParams(64, 64))); + infoButton->OnClick.Add([=](UI::EventParams &e) { + screenManager()->push(new GameScreen(gamePath_, true)); + return UI::EVENT_DONE; + }); } else { auto nw = GetI18NCategory(I18NCat::NETWORKING); rightColumnHolder->Add(new TextView(nw->T("Network connected")));