diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b39fe238..a1a2543ca0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -790,6 +790,7 @@ set(NativeAppSource UI/GameInfoCache.cpp UI/MainScreen.cpp UI/MiscScreens.cpp + UI/PauseScreen.cpp UI/GameScreen.cpp UI/GameSettingsScreen.cpp UI/TiltAnalogSettingsScreen.cpp diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index dea9d5306a..5462301a2e 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -317,7 +317,7 @@ void CheatCheckBox::Draw(UIContext &dc) { int image = *toggle_ ? dc.theme->checkOn : dc.theme->checkOff; - Style style = dc.theme->itemStyle; + UI::Style style = dc.theme->itemStyle; if (!IsEnabled()) style = dc.theme->itemDisabledStyle; diff --git a/UI/CwCheatScreen.h b/UI/CwCheatScreen.h index 214a5b7c75..3f3dbcb85a 100644 --- a/UI/CwCheatScreen.h +++ b/UI/CwCheatScreen.h @@ -26,7 +26,6 @@ #include "UI/MiscScreens.h" #include "UI/GameSettingsScreen.h" -using namespace UI; extern std::string activeCheatFile; extern std::string gameTitle; @@ -55,16 +54,16 @@ private: }; // TODO: Instead just hook the OnClick event on a regular checkbox. -class CheatCheckBox : public ClickableItem, public CwCheatScreen { +class CheatCheckBox : public UI::ClickableItem, public CwCheatScreen { public: - CheatCheckBox(bool *toggle, const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = 0) - : ClickableItem(layoutParams), toggle_(toggle), text_(text) { + CheatCheckBox(bool *toggle, const std::string &text, const std::string &smallText = "", UI::LayoutParams *layoutParams = 0) + : UI::ClickableItem(layoutParams), toggle_(toggle), text_(text) { OnClick.Handle(this, &CheatCheckBox::OnClicked); } virtual void Draw(UIContext &dc); - EventReturn OnClicked(EventParams &e) { + UI::EventReturn OnClicked(UI::EventParams &e) { if (toggle_) { *toggle_ = !(*toggle_); } @@ -77,7 +76,7 @@ public: deactivatedCheat = text_; processFileOff(deactivatedCheat); } - return EVENT_DONE; + return UI::EVENT_DONE; } private: diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 49653b93a4..82a8629c1d 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -51,6 +51,7 @@ #include "UI/ui_atlas.h" #include "UI/OnScreenDisplay.h" #include "UI/GamepadEmu.h" +#include "UI/PauseScreen.h" #include "UI/MainScreen.h" #include "UI/EmuScreen.h" #include "UI/DevScreens.h" diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 50e58e6513..21112ab24e 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -33,7 +33,6 @@ #include "Core/System.h" #include "Core/Host.h" #include "Core/Reporting.h" -#include "Core/SaveState.h" #include "UI/BackgroundAudio.h" #include "UI/EmuScreen.h" @@ -41,10 +40,8 @@ #include "UI/GameScreen.h" #include "UI/GameInfoCache.h" #include "UI/GameSettingsScreen.h" -#include "UI/CwCheatScreen.h" #include "UI/MiscScreens.h" #include "UI/ControlMappingScreen.h" -#include "UI/ReportScreen.h" #include "UI/Store.h" #include "UI/ui_atlas.h" #include "Core/Config.h" @@ -178,6 +175,7 @@ void GameButton::Draw(UIContext &dc) { GameInfo *ginfo = g_gameInfoCache.GetInfo(dc.GetThin3DContext(), gamePath_, 0); Thin3DTexture *texture = 0; u32 color = 0, shadowColor = 0; + using namespace UI; if (ginfo->iconTexture) { texture = ginfo->iconTexture; @@ -325,7 +323,7 @@ class DirButton : public UI::Button { public: DirButton(const std::string &path, UI::LayoutParams *layoutParams) : UI::Button(path, layoutParams), path_(path), absolute_(false) {} - DirButton(const std::string &path, const std::string &text, LayoutParams *layoutParams = 0) + DirButton(const std::string &path, const std::string &text, UI::LayoutParams *layoutParams = 0) : UI::Button(text, layoutParams), path_(path), absolute_(true) {} virtual void Draw(UIContext &dc); @@ -345,6 +343,7 @@ private: }; void DirButton::Draw(UIContext &dc) { + using namespace UI; Style style = dc.theme->buttonStyle; if (HasFocus()) style = dc.theme->buttonFocusedStyle; @@ -881,13 +880,13 @@ UI::EventReturn MainScreen::OnDownloadUpgrade(UI::EventParams &e) { // Go directly to ppsspp.org and let the user sort it out LaunchBrowser("http://www.ppsspp.org/downloads.html"); #endif - return EVENT_DONE; + return UI::EVENT_DONE; } UI::EventReturn MainScreen::OnDismissUpgrade(UI::EventParams &e) { g_Config.DismissUpgrade(); - upgradeBar_->SetVisibility(V_GONE); - return EVENT_DONE; + upgradeBar_->SetVisibility(UI::V_GONE); + return UI::EVENT_DONE; } void MainScreen::sendMessage(const char *message, const char *value) { @@ -1003,6 +1002,8 @@ UI::EventReturn MainScreen::OnGameSelected(UI::EventParams &e) { } UI::EventReturn MainScreen::OnGameHighlight(UI::EventParams &e) { + using namespace UI; + #ifdef _WIN32 std::string path = ReplaceAll(e.s, "\\", "/"); #else @@ -1108,205 +1109,8 @@ void MainScreen::dialogFinished(const Screen *dialog, DialogResult result) { } } -void GamePauseScreen::update(InputState &input) { - UpdateUIState(UISTATE_PAUSEMENU); - UIScreen::update(input); -} - -GamePauseScreen::~GamePauseScreen() { - if (saveSlots_ != NULL) { - g_Config.iCurrentStateSlot = saveSlots_->GetSelection(); - g_Config.Save(); - } - __DisplaySetWasPaused(); -} - -void GamePauseScreen::CreateViews() { - static const int NUM_SAVESLOTS = 5; - - using namespace UI; - Margins actionMenuMargins(0, 100, 15, 0); - I18NCategory *gs = GetI18NCategory("Graphics"); - I18NCategory *i = GetI18NCategory("Pause"); - - root_ = new LinearLayout(ORIENT_HORIZONTAL); - - ViewGroup *leftColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); - root_->Add(leftColumn); - - root_->Add(new Spacer(new LinearLayoutParams(1.0))); - - ViewGroup *leftColumnItems = new LinearLayout(ORIENT_VERTICAL); - leftColumn->Add(leftColumnItems); - - saveSlots_ = leftColumnItems->Add(new ChoiceStrip(ORIENT_HORIZONTAL, new LinearLayoutParams(300, WRAP_CONTENT))); - for (int i = 0; i < NUM_SAVESLOTS; i++){ - std::stringstream saveSlotText; - saveSlotText << " " << i + 1 << " "; - saveSlots_->AddChoice(saveSlotText.str()); - if (SaveState::HasSaveInSlot(i)) { - saveSlots_->HighlightChoice(i); - } - } - - saveSlots_->SetSelection(g_Config.iCurrentStateSlot); - saveSlots_->OnChoice.Handle(this, &GamePauseScreen::OnStateSelected); - - saveStateButton_ = leftColumnItems->Add(new Choice(i->T("Save State"))); - saveStateButton_->OnClick.Handle(this, &GamePauseScreen::OnSaveState); - - loadStateButton_ = leftColumnItems->Add(new Choice(i->T("Load State"))); - loadStateButton_->OnClick.Handle(this, &GamePauseScreen::OnLoadState); - - if (g_Config.iRewindFlipFrequency > 0) { - UI::Choice *rewindButton = leftColumnItems->Add(new Choice(i->T("Rewind"))); - rewindButton->SetEnabled(SaveState::CanRewind()); - rewindButton->OnClick.Handle(this, &GamePauseScreen::OnRewind); - } - - ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); - root_->Add(rightColumn); - - LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); - rightColumn->Add(rightColumnItems); - - rightColumnItems->SetSpacing(0.0f); - if (getUMDReplacePermit()) { - rightColumnItems->Add(new Choice(i->T("Switch UMD")))->OnClick.Handle(this, &GamePauseScreen::OnSwitchUMD); - } - Choice *continueChoice = rightColumnItems->Add(new Choice(i->T("Continue"))); - root_->SetDefaultFocusView(continueChoice); - continueChoice->OnClick.Handle(this, &UIScreen::OnBack); - - std::string gameId = g_paramSFO.GetValueString("DISC_ID"); - if (g_Config.hasGameConfig(gameId)) - { - rightColumnItems->Add(new Choice(i->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); - rightColumnItems->Add(new Choice(i->T("Delete Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnDeleteConfig); - } - else{ - rightColumnItems->Add(new Choice(i->T("Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); - rightColumnItems->Add(new Choice(i->T("Create Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnCreateConfig); - } - if (g_Config.bEnableCheats) { - rightColumnItems->Add(new Choice(i->T("Cheats")))->OnClick.Handle(this, &GamePauseScreen::OnCwCheat); - } - - // TODO, also might be nice to show overall compat rating here? - // Based on their platform or even cpu/gpu/config. Would add an API for it. - if (Reporting::IsEnabled()) { - I18NCategory *rp = GetI18NCategory("Reporting"); - rightColumnItems->Add(new Choice(rp->T("ReportButton", "Report Feedback")))->OnClick.Handle(this, &GamePauseScreen::OnReportFeedback); - } - rightColumnItems->Add(new Spacer(25.0)); - rightColumnItems->Add(new Choice(i->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); - - UI::EventParams e; - e.a = g_Config.iCurrentStateSlot; - saveSlots_->OnChoice.Trigger(e); -} - -UI::EventReturn GamePauseScreen::OnGameSettings(UI::EventParams &e) { - screenManager()->push(new GameSettingsScreen(gamePath_)); - return UI::EVENT_DONE; -} - -UI::EventReturn GamePauseScreen::OnStateSelected(UI::EventParams &e) { - int st = e.a; - loadStateButton_->SetEnabled(SaveState::HasSaveInSlot(st)); - return UI::EVENT_DONE; -} - -void GamePauseScreen::onFinish(DialogResult result) { - // Do we really always need to "gpu->Resized" here? - if (gpu) - gpu->Resized(); - Reporting::UpdateConfig(); -} - -UI::EventReturn GamePauseScreen::OnExitToMenu(UI::EventParams &e) { - screenManager()->finishDialog(this, DR_OK); - return UI::EVENT_DONE; -} - -UI::EventReturn GamePauseScreen::OnReportFeedback(UI::EventParams &e) { - screenManager()->push(new ReportScreen(gamePath_)); - return UI::EVENT_DONE; -} - -UI::EventReturn GamePauseScreen::OnLoadState(UI::EventParams &e) { - SaveState::LoadSlot(saveSlots_->GetSelection(), SaveState::Callback(), 0); - - screenManager()->finishDialog(this, DR_CANCEL); - return UI::EVENT_DONE; -} - -UI::EventReturn GamePauseScreen::OnSaveState(UI::EventParams &e) { - SaveState::SaveSlot(saveSlots_->GetSelection(), SaveState::Callback(), 0); - - screenManager()->finishDialog(this, DR_CANCEL); - return UI::EVENT_DONE; -} - -UI::EventReturn GamePauseScreen::OnRewind(UI::EventParams &e) { - SaveState::Rewind(SaveState::Callback(), 0); - - screenManager()->finishDialog(this, DR_CANCEL); - return UI::EVENT_DONE; -} - -UI::EventReturn GamePauseScreen::OnCwCheat(UI::EventParams &e) { - screenManager()->push(new CwCheatScreen()); - return UI::EVENT_DONE; -} - -UI::EventReturn GamePauseScreen::OnSwitchUMD(UI::EventParams &e) { - screenManager()->push(new UmdReplaceScreen()); - return UI::EVENT_DONE; -} - -void GamePauseScreen::CallbackDeleteConfig(bool yes) -{ - if (yes) - { - GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0); - g_Config.deleteGameConfig(info->id); - g_Config.unloadGameConfig(); - screenManager()->RecreateAllViews(); - } -} - -UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e) -{ - std::string gameId = g_paramSFO.GetValueString("DISC_ID"); - g_Config.createGameConfig(gameId); - g_Config.changeGameSpecific(gameId); - g_Config.saveGameConfig(gameId); - - screenManager()->topScreen()->RecreateViews(); - return UI::EVENT_DONE; -} -UI::EventReturn GamePauseScreen::OnDeleteConfig(UI::EventParams &e) -{ - I18NCategory *d = GetI18NCategory("Dialog"); - I18NCategory *ga = GetI18NCategory("Game"); - screenManager()->push( - new PromptScreen(d->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), d->T("Cancel"), - std::bind(&GamePauseScreen::CallbackDeleteConfig, this, placeholder::_1))); - - return UI::EVENT_DONE; -} - - -void GamePauseScreen::sendMessage(const char *message, const char *value) { - // Since the language message isn't allowed to be in native, we have to have add this - // to every screen which directly inherits from UIScreen(which are few right now, luckily). - if (!strcmp(message, "language")) { - screenManager()->RecreateAllViews(); - } -} - void UmdReplaceScreen::CreateViews() { + using namespace UI; Margins actionMenuMargins(0, 100, 15, 0); I18NCategory *m = GetI18NCategory("MainMenu"); I18NCategory *d = GetI18NCategory("Dialog"); @@ -1368,16 +1172,16 @@ UI::EventReturn UmdReplaceScreen::OnGameSelected(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn UmdReplaceScreen:: OnCancel(UI::EventParams &e) { +UI::EventReturn UmdReplaceScreen::OnCancel(UI::EventParams &e) { screenManager()->finishDialog(this, DR_CANCEL); return UI::EVENT_DONE; } -UI::EventReturn UmdReplaceScreen:: OnGameSettings(UI::EventParams &e) { +UI::EventReturn UmdReplaceScreen::OnGameSettings(UI::EventParams &e) { screenManager()->push(new GameSettingsScreen("")); return UI::EVENT_DONE; } -UI::EventReturn UmdReplaceScreen:: OnGameSelectedInstant(UI::EventParams &e) { +UI::EventReturn UmdReplaceScreen::OnGameSelectedInstant(UI::EventParams &e) { __UmdReplace(e.s); screenManager()->finishDialog(this, DR_OK); return UI::EVENT_DONE; diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 5e863c8bf3..4e9e76df56 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -76,42 +76,6 @@ private: bool UseVerticalLayout() const; }; -class GamePauseScreen : public UIDialogScreenWithGameBackground { -public: - GamePauseScreen(const std::string &filename) : UIDialogScreenWithGameBackground(filename), saveSlots_(NULL) {} - virtual ~GamePauseScreen(); - - virtual void onFinish(DialogResult result); - -protected: - virtual void CreateViews(); - virtual void update(InputState &input); - virtual void sendMessage(const char *message, const char *value); - void CallbackDeleteConfig(bool yes); - -private: - UI::EventReturn OnMainSettings(UI::EventParams &e); - UI::EventReturn OnGameSettings(UI::EventParams &e); - UI::EventReturn OnExitToMenu(UI::EventParams &e); - UI::EventReturn OnReportFeedback(UI::EventParams &e); - - UI::EventReturn OnSaveState(UI::EventParams &e); - UI::EventReturn OnLoadState(UI::EventParams &e); - UI::EventReturn OnRewind(UI::EventParams &e); - - UI::EventReturn OnStateSelected(UI::EventParams &e); - UI::EventReturn OnCwCheat(UI::EventParams &e); - - UI::EventReturn OnCreateConfig(UI::EventParams &e); - UI::EventReturn OnDeleteConfig(UI::EventParams &e); - - UI::EventReturn OnSwitchUMD(UI::EventParams &e); - - UI::ChoiceStrip *saveSlots_; - UI::Choice *saveStateButton_; - UI::Choice *loadStateButton_; -}; - class UmdReplaceScreen : public UIDialogScreenWithBackground { public: UmdReplaceScreen() {} diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp new file mode 100644 index 0000000000..e4a929e5fa --- /dev/null +++ b/UI/PauseScreen.cpp @@ -0,0 +1,233 @@ +// Copyright (c) 2014- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include "i18n/i18n.h" +#include "ui/view.h" +#include "ui/viewgroup.h" + +#include "Core/Reporting.h" +#include "Core/SaveState.h" +#include "Core/System.h" +#include "Core/Config.h" +#include "Core/ELF/ParamSFO.h" + +#include "GPU/GPUCommon.h" + +#include "Core/HLE/sceDisplay.h" +#include "Core/HLE/sceUmd.h" + +#include "UI/PauseScreen.h" +#include "UI/GameSettingsScreen.h" +#include "UI/ReportScreen.h" +#include "UI/CwCheatScreen.h" +#include "UI/MainScreen.h" +#include "UI/GameInfoCache.h" + +void GamePauseScreen::update(InputState &input) { + UpdateUIState(UISTATE_PAUSEMENU); + UIScreen::update(input); +} + +GamePauseScreen::~GamePauseScreen() { + if (saveSlots_ != NULL) { + g_Config.iCurrentStateSlot = saveSlots_->GetSelection(); + g_Config.Save(); + } + __DisplaySetWasPaused(); +} + +void GamePauseScreen::CreateViews() { + static const int NUM_SAVESLOTS = 5; + + using namespace UI; + Margins actionMenuMargins(0, 100, 15, 0); + I18NCategory *gs = GetI18NCategory("Graphics"); + I18NCategory *i = GetI18NCategory("Pause"); + + root_ = new LinearLayout(ORIENT_HORIZONTAL); + + ViewGroup *leftColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); + root_->Add(leftColumn); + + root_->Add(new Spacer(new LinearLayoutParams(1.0))); + + ViewGroup *leftColumnItems = new LinearLayout(ORIENT_VERTICAL); + leftColumn->Add(leftColumnItems); + + saveSlots_ = leftColumnItems->Add(new ChoiceStrip(ORIENT_HORIZONTAL, new LinearLayoutParams(300, WRAP_CONTENT))); + for (int i = 0; i < NUM_SAVESLOTS; i++) { + std::stringstream saveSlotText; + saveSlotText << " " << i + 1 << " "; + saveSlots_->AddChoice(saveSlotText.str()); + if (SaveState::HasSaveInSlot(i)) { + saveSlots_->HighlightChoice(i); + } + } + + saveSlots_->SetSelection(g_Config.iCurrentStateSlot); + saveSlots_->OnChoice.Handle(this, &GamePauseScreen::OnStateSelected); + + saveStateButton_ = leftColumnItems->Add(new Choice(i->T("Save State"))); + saveStateButton_->OnClick.Handle(this, &GamePauseScreen::OnSaveState); + + loadStateButton_ = leftColumnItems->Add(new Choice(i->T("Load State"))); + loadStateButton_->OnClick.Handle(this, &GamePauseScreen::OnLoadState); + + if (g_Config.iRewindFlipFrequency > 0) { + UI::Choice *rewindButton = leftColumnItems->Add(new Choice(i->T("Rewind"))); + rewindButton->SetEnabled(SaveState::CanRewind()); + rewindButton->OnClick.Handle(this, &GamePauseScreen::OnRewind); + } + + ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); + root_->Add(rightColumn); + + LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); + rightColumn->Add(rightColumnItems); + + rightColumnItems->SetSpacing(0.0f); + if (getUMDReplacePermit()) { + rightColumnItems->Add(new Choice(i->T("Switch UMD")))->OnClick.Handle(this, &GamePauseScreen::OnSwitchUMD); + } + Choice *continueChoice = rightColumnItems->Add(new Choice(i->T("Continue"))); + root_->SetDefaultFocusView(continueChoice); + continueChoice->OnClick.Handle(this, &UIScreen::OnBack); + + std::string gameId = g_paramSFO.GetValueString("DISC_ID"); + if (g_Config.hasGameConfig(gameId)) { + rightColumnItems->Add(new Choice(i->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); + rightColumnItems->Add(new Choice(i->T("Delete Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnDeleteConfig); + } else { + rightColumnItems->Add(new Choice(i->T("Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); + rightColumnItems->Add(new Choice(i->T("Create Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnCreateConfig); + } + if (g_Config.bEnableCheats) { + rightColumnItems->Add(new Choice(i->T("Cheats")))->OnClick.Handle(this, &GamePauseScreen::OnCwCheat); + } + + // TODO, also might be nice to show overall compat rating here? + // Based on their platform or even cpu/gpu/config. Would add an API for it. + if (Reporting::IsEnabled()) { + I18NCategory *rp = GetI18NCategory("Reporting"); + rightColumnItems->Add(new Choice(rp->T("ReportButton", "Report Feedback")))->OnClick.Handle(this, &GamePauseScreen::OnReportFeedback); + } + rightColumnItems->Add(new Spacer(25.0)); + rightColumnItems->Add(new Choice(i->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); + + UI::EventParams e; + e.a = g_Config.iCurrentStateSlot; + saveSlots_->OnChoice.Trigger(e); +} + +UI::EventReturn GamePauseScreen::OnGameSettings(UI::EventParams &e) { + screenManager()->push(new GameSettingsScreen(gamePath_)); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnStateSelected(UI::EventParams &e) { + int st = e.a; + loadStateButton_->SetEnabled(SaveState::HasSaveInSlot(st)); + return UI::EVENT_DONE; +} + +void GamePauseScreen::onFinish(DialogResult result) { + // Do we really always need to "gpu->Resized" here? + if (gpu) + gpu->Resized(); + Reporting::UpdateConfig(); +} + +UI::EventReturn GamePauseScreen::OnExitToMenu(UI::EventParams &e) { + screenManager()->finishDialog(this, DR_OK); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnReportFeedback(UI::EventParams &e) { + screenManager()->push(new ReportScreen(gamePath_)); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnLoadState(UI::EventParams &e) { + SaveState::LoadSlot(saveSlots_->GetSelection(), SaveState::Callback(), 0); + + screenManager()->finishDialog(this, DR_CANCEL); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnSaveState(UI::EventParams &e) { + SaveState::SaveSlot(saveSlots_->GetSelection(), SaveState::Callback(), 0); + + screenManager()->finishDialog(this, DR_CANCEL); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnRewind(UI::EventParams &e) { + SaveState::Rewind(SaveState::Callback(), 0); + + screenManager()->finishDialog(this, DR_CANCEL); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnCwCheat(UI::EventParams &e) { + screenManager()->push(new CwCheatScreen()); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnSwitchUMD(UI::EventParams &e) { + screenManager()->push(new UmdReplaceScreen()); + return UI::EVENT_DONE; +} + +void GamePauseScreen::CallbackDeleteConfig(bool yes) +{ + if (yes) { + GameInfo *info = g_gameInfoCache.GetInfo(NULL, gamePath_, 0); + g_Config.deleteGameConfig(info->id); + g_Config.unloadGameConfig(); + screenManager()->RecreateAllViews(); + } +} + +UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e) +{ + std::string gameId = g_paramSFO.GetValueString("DISC_ID"); + g_Config.createGameConfig(gameId); + g_Config.changeGameSpecific(gameId); + g_Config.saveGameConfig(gameId); + + screenManager()->topScreen()->RecreateViews(); + return UI::EVENT_DONE; +} +UI::EventReturn GamePauseScreen::OnDeleteConfig(UI::EventParams &e) +{ + I18NCategory *d = GetI18NCategory("Dialog"); + I18NCategory *ga = GetI18NCategory("Game"); + screenManager()->push( + new PromptScreen(d->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), d->T("Cancel"), + std::bind(&GamePauseScreen::CallbackDeleteConfig, this, placeholder::_1))); + + return UI::EVENT_DONE; +} + + +void GamePauseScreen::sendMessage(const char *message, const char *value) { + // Since the language message isn't allowed to be in native, we have to have add this + // to every screen which directly inherits from UIScreen(which are few right now, luckily). + if (!strcmp(message, "language")) { + screenManager()->RecreateAllViews(); + } +} diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h new file mode 100644 index 0000000000..0b5707d630 --- /dev/null +++ b/UI/PauseScreen.h @@ -0,0 +1,59 @@ +// Copyright (c) 2014- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#pragma once + +#include "base/functional.h" +#include "ui/ui_screen.h" +#include "ui/viewgroup.h" +#include "UI/MiscScreens.h" + +class GamePauseScreen : public UIDialogScreenWithGameBackground { +public: + GamePauseScreen(const std::string &filename) : UIDialogScreenWithGameBackground(filename), saveSlots_(NULL) {} + virtual ~GamePauseScreen(); + + virtual void onFinish(DialogResult result); + +protected: + virtual void CreateViews(); + virtual void update(InputState &input); + virtual void sendMessage(const char *message, const char *value); + void CallbackDeleteConfig(bool yes); + +private: + UI::EventReturn OnMainSettings(UI::EventParams &e); + UI::EventReturn OnGameSettings(UI::EventParams &e); + UI::EventReturn OnExitToMenu(UI::EventParams &e); + UI::EventReturn OnReportFeedback(UI::EventParams &e); + + UI::EventReturn OnSaveState(UI::EventParams &e); + UI::EventReturn OnLoadState(UI::EventParams &e); + UI::EventReturn OnRewind(UI::EventParams &e); + + UI::EventReturn OnStateSelected(UI::EventParams &e); + UI::EventReturn OnCwCheat(UI::EventParams &e); + + UI::EventReturn OnCreateConfig(UI::EventParams &e); + UI::EventReturn OnDeleteConfig(UI::EventParams &e); + + UI::EventReturn OnSwitchUMD(UI::EventParams &e); + + UI::ChoiceStrip *saveSlots_; + UI::Choice *saveStateButton_; + UI::Choice *loadStateButton_; +}; diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index 23bf10daff..5a667f83a6 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -32,6 +32,7 @@ + @@ -54,6 +55,7 @@ + diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index c118f00537..38a4fcb250 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -50,6 +50,9 @@ Screens + + Screens + @@ -100,7 +103,9 @@ Screens - + + Screens + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index b49c2f5a2b..a289bf643c 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -302,6 +302,7 @@ LOCAL_SRC_FILES := \ $(SRC)/UI/MainScreen.cpp \ $(SRC)/UI/MiscScreens.cpp \ $(SRC)/UI/ReportScreen.cpp \ + $(SRC)/UI/PauseScreen.cpp \ $(SRC)/UI/Store.cpp \ $(SRC)/UI/GamepadEmu.cpp \ $(SRC)/UI/GameInfoCache.cpp \