Skip to content

Commit

Permalink
Merge pull request #19471 from hrydgard/ingame-gameinfo-screen
Browse files Browse the repository at this point in the history
Add button to show the game-info screen from the in-game pause screen
  • Loading branch information
hrydgard authored Sep 18, 2024
2 parents c451b41 + 0c9605d commit 476c69c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
23 changes: 20 additions & 3 deletions UI/GameScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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);
Expand All @@ -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<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO);
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion UI/GameScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,4 +91,5 @@ class GameScreen : public UIDialogScreenWithGameBackground {
std::string CRC32string;

bool isHomebrew_ = false;
bool inGame_ = false;
};
2 changes: 1 addition & 1 deletion UI/MainScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
21 changes: 13 additions & 8 deletions UI/PauseScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")));
Expand Down

0 comments on commit 476c69c

Please sign in to comment.