Skip to content

Commit f8707ab

Browse files
committed
Add a top banner to each settings page, that shows the game (if game-specific) and a help link
1 parent 9d84791 commit f8707ab

5 files changed

+50
-11
lines changed

UI/EmuScreen.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ void EmuScreen::focusChanged(ScreenFocusChange focusChange) {
505505
void EmuScreen::sendMessage(UIMessage message, const char *value) {
506506
// External commands, like from the Windows UI.
507507
if (message == UIMessage::REQUEST_GAME_PAUSE && screenManager()->topScreen() == this) {
508-
screenManager()->push(new GamePauseScreen(gamePath_));
508+
std::string gameID = g_paramSFO.GetValueString("DISC_ID");
509+
screenManager()->push(new GamePauseScreen(gamePath_, gameID));
509510
} else if (message == UIMessage::REQUEST_GAME_STOP) {
510511
// We will push MainScreen in update().
511512
PSP_Shutdown();
@@ -587,8 +588,8 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
587588
if (!KeyMap::IsKeyMapped(DEVICE_ID_PAD_0, VIRTKEY_PAUSE) || !KeyMap::IsKeyMapped(DEVICE_ID_PAD_1, VIRTKEY_PAUSE)) {
588589
// If it's a TV (so no built-in back button), and there's no back button mapped to a pad,
589590
// use this as the fallback way to get into the menu.
590-
591-
screenManager()->push(new GamePauseScreen(gamePath_));
591+
std::string gameID = g_paramSFO.GetValueString("DISC_ID");
592+
screenManager()->push(new GamePauseScreen(gamePath_, gameID));
592593
}
593594
}
594595
} else if (message == UIMessage::REQUEST_PLAY_SOUND) {
@@ -1215,7 +1216,8 @@ void EmuScreen::update() {
12151216

12161217
if (pauseTrigger_) {
12171218
pauseTrigger_ = false;
1218-
screenManager()->push(new GamePauseScreen(gamePath_));
1219+
std::string gameID = g_paramSFO.GetValueString("DISC_ID");
1220+
screenManager()->push(new GamePauseScreen(gamePath_, gameID));
12191221
}
12201222

12211223
if (saveStatePreview_ && !bootPending_) {

UI/GameSettingsScreen.cpp

+38-3
Original file line numberDiff line numberDiff line change
@@ -229,32 +229,67 @@ void GameSettingsScreen::PreCreateViews() {
229229
iAlternateSpeedPercentAnalog_ = (g_Config.iAnalogFpsLimit * 100) / 60;
230230
}
231231

232+
void GameSettingsScreen::CreateBanner(UI::LinearLayout *parent, const char *category, const char *url) {
233+
using namespace UI;
234+
auto ms = GetI18NCategory(I18NCat::MAINSETTINGS);
235+
236+
LinearLayout *banner = new LinearLayout(ORIENT_HORIZONTAL);
237+
std::string title = category;
238+
bool hasGameConfig = false;
239+
if (g_Config.hasGameConfig(gameID_)) {
240+
auto info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0);
241+
title = info->GetTitle() + " - " + gameID_;
242+
hasGameConfig = true;
243+
}
244+
if (hasGameConfig) {
245+
banner->Add(new ImageView(ImageID("I_GEAR"), "", UI::ImageSizeMode::IS_KEEP_ASPECT, new LinearLayoutParams(50, 50, 0.0f, G_CENTER)));
246+
}
247+
banner->Add(new TextView(title, new LinearLayoutParams(Margins(10, 10))));
248+
banner->Add(new Spacer(0.0f, new LinearLayoutParams(1.0f)));
249+
if (strlen(url)) {
250+
banner->Add(new Button(ms->T("Help"), new LinearLayoutParams(Margins(8, 8))))->OnClick.Add([=](UI::EventParams &e) {
251+
std::string fullUrl = StringFromFormat("https://www.ppsspp.org/docs/settings/%s", url);
252+
System_LaunchUrl(LaunchUrlType::BROWSER_URL, fullUrl.c_str());
253+
return UI::EVENT_DONE;
254+
});
255+
}
256+
banner->SetBG(UI::Drawable(0x30000000));
257+
parent->Add(banner);
258+
}
259+
232260
void GameSettingsScreen::CreateTabs() {
233261
using namespace UI;
234262
auto ms = GetI18NCategory(I18NCat::MAINSETTINGS);
235263

236264
LinearLayout *graphicsSettings = AddTab("GameSettingsGraphics", ms->T("Graphics"));
265+
CreateBanner(graphicsSettings, ms->T("Graphics"), "graphics");
237266
CreateGraphicsSettings(graphicsSettings);
238267

239268
LinearLayout *controlsSettings = AddTab("GameSettingsControls", ms->T("Controls"));
269+
CreateBanner(controlsSettings, ms->T("Controls"), "controls");
240270
CreateControlsSettings(controlsSettings);
241271

242272
LinearLayout *audioSettings = AddTab("GameSettingsAudio", ms->T("Audio"));
273+
CreateBanner(audioSettings, ms->T("Audio"), "audio");
243274
CreateAudioSettings(audioSettings);
244275

245276
LinearLayout *networkingSettings = AddTab("GameSettingsNetworking", ms->T("Networking"));
277+
CreateBanner(networkingSettings, ms->T("Networking"), "network");
246278
CreateNetworkingSettings(networkingSettings);
247279

248-
LinearLayout *tools = AddTab("GameSettingsTools", ms->T("Tools"));
249-
CreateToolsSettings(tools);
280+
LinearLayout *toolsSettings = AddTab("GameSettingsTools", ms->T("Tools"));
281+
CreateBanner(toolsSettings, ms->T("Tools"), "tools");
282+
CreateToolsSettings(toolsSettings);
250283

251284
LinearLayout *systemSettings = AddTab("GameSettingsSystem", ms->T("System"));
252285
systemSettings->SetSpacing(0);
286+
CreateBanner(systemSettings, ms->T("System"), "system");
253287
CreateSystemSettings(systemSettings);
254288

255289
int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE);
256290
if (deviceType == DEVICE_TYPE_VR) {
257-
LinearLayout *vrSettings = AddTab("GameSettingsVR", ms->T("VR"));
291+
LinearLayout *vrSettings = AddTab("GameSettingsVR", ms->T("VR"), "");
292+
CreateBanner(vrSettings, ms->T("VR"), "");
258293
CreateVRSettings(vrSettings);
259294
}
260295
}

UI/GameSettingsScreen.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class GameSettingsScreen : public TabbedUIDialogScreenWithGameBackground {
4747

4848
private:
4949
void PreCreateViews() override;
50+
void CreateBanner(UI::LinearLayout *parent, const char *category, const char *url);
5051

5152
void CreateGraphicsSettings(UI::ViewGroup *graphicsSettings);
5253
void CreateControlsSettings(UI::ViewGroup *tools);

UI/PauseScreen.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ void GamePauseScreen::update() {
264264
SetVRAppMode(VRAppMode::VR_MENU_MODE);
265265
}
266266

267-
GamePauseScreen::GamePauseScreen(const Path &filename)
268-
: UIDialogScreenWithGameBackground(filename) {
267+
GamePauseScreen::GamePauseScreen(const Path &filename, std::string gameID)
268+
: UIDialogScreenWithGameBackground(filename), gameID_(gameID) {
269269
// So we can tell if something blew up while on the pause screen.
270270
std::string assertStr = "PauseScreen: " + filename.GetFilename();
271271
SetExtraAssertInfo(assertStr.c_str());
@@ -454,7 +454,7 @@ void GamePauseScreen::CreateViews() {
454454
}
455455

456456
UI::EventReturn GamePauseScreen::OnGameSettings(UI::EventParams &e) {
457-
screenManager()->push(new GameSettingsScreen(gamePath_));
457+
screenManager()->push(new GameSettingsScreen(gamePath_, gameID_));
458458
return UI::EVENT_DONE;
459459
}
460460

UI/PauseScreen.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum class PauseScreenMode {
3232

3333
class GamePauseScreen : public UIDialogScreenWithGameBackground {
3434
public:
35-
GamePauseScreen(const Path &filename);
35+
GamePauseScreen(const Path &filename, std::string gameID);
3636
~GamePauseScreen();
3737

3838
void dialogFinished(const Screen *dialog, DialogResult dr) override;
@@ -68,4 +68,5 @@ class GamePauseScreen : public UIDialogScreenWithGameBackground {
6868
PauseScreenMode mode_ = PauseScreenMode::MAIN;
6969

7070
UI::Button *playButton_ = nullptr;
71+
std::string gameID_;
7172
};

0 commit comments

Comments
 (0)