diff --git a/Core/Config.cpp b/Core/Config.cpp index 5a3e965f9a..a973829ad2 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -62,6 +62,7 @@ void Config::Load(const char *iniFileName) general->Get("EnableCheats", &bEnableCheats, false); general->Get("MaxRecent", &iMaxRecent, 12); general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false); + general->Get("StateSlot", &iCurrentStateSlot, 0); // Fix issue from switching from uint (hex in .ini) to int (dec) if (iMaxRecent == 0) @@ -215,6 +216,7 @@ void Config::Save() general->Set("MaxRecent", iMaxRecent); general->Set("EnableCheats", bEnableCheats); general->Set("ScreenshotsAsPNG", bScreenshotsAsPNG); + general->Set("StateSlot", iCurrentStateSlot); IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU"); cpu->Set("Jit", bJit); diff --git a/Core/Config.h b/Core/Config.h index a284c89d05..72838c2003 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -94,6 +94,7 @@ public: int iFpsLimit; int iForceMaxEmulatedFPS; int iMaxRecent; + int iCurrentStateSlot; bool bEnableCheats; bool bReloadCheats; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 70460052d7..dbfbab4c33 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -53,7 +53,9 @@ #include "UI/MiscScreens.h" -EmuScreen::EmuScreen(const std::string &filename) : invalid_(true), pauseTrigger_(false) { +EmuScreen::EmuScreen(const std::string &filename) + : gamePath_(filename), invalid_(true), pauseTrigger_(false) { + bootGame(filename); } @@ -224,7 +226,10 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { // Should get rid of that but not now. #ifndef ANDROID case VIRTKEY_PAUSE: - screenManager()->push(new PauseScreen()); + if (g_Config.bNewUI) + screenManager()->push(new GamePauseScreen(gamePath_)); + else + screenManager()->push(new PauseScreen()); break; #endif @@ -436,7 +441,11 @@ void EmuScreen::update(InputState &input) { // This is here to support the iOS on screen back button. if (pauseTrigger_) { pauseTrigger_ = false; - screenManager()->push(new PauseScreen()); + if (g_Config.bNewUI) { + screenManager()->push(new GamePauseScreen(gamePath_)); + } else { + screenManager()->push(new PauseScreen()); + } } } diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 9d2ae88a9f..447eb05300 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -52,6 +52,7 @@ private: void setVKeyAnalogX(int stick, int virtualKeyMin, int virtualKeyMax); void setVKeyAnalogY(int stick, int virtualKeyMin, int virtualKeyMax); + std::string gamePath_; // Something invalid was loaded, don't try to emulate bool invalid_; std::string errorMessage_; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 2022a9fce8..f772e99557 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -266,15 +266,11 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new CheckBox(&g_Config.bFastMemory, s->T("Fast Memory", "Fast Memory (Unstable)"))); } -void DrawBackground(float alpha); - -void GameSettingsScreen::DrawBackground(UIContext &dc) { - ::DrawBackground(1.0f); - +void GameSettingsScreen::update(InputState &input) { + UIScreen::update(input); g_Config.iForceMaxEmulatedFPS = cap60FPS_ ? 60 : 0; } - void GlobalSettingsScreen::CreateViews() { using namespace UI; root_ = new ScrollView(ORIENT_VERTICAL); @@ -315,14 +311,6 @@ UI::EventReturn GlobalSettingsScreen::OnBack(UI::EventParams &e) { return UI::EVENT_DONE; } -void GlobalSettingsScreen::DrawBackground(UIContext &dc) { - ::DrawBackground(1.0f); -} - -void DeveloperToolsScreen::DrawBackground(UIContext &dc) { - ::DrawBackground(1.0f); -} - void DeveloperToolsScreen::CreateViews() { using namespace UI; root_ = new ScrollView(ORIENT_VERTICAL); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 412ea463ac..8e5ee91231 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -18,17 +18,18 @@ #pragma once #include "ui/ui_screen.h" - +#include "UI/MiscScreens.h" // Per-game settings screen - enables you to configure graphic options, control options, etc // per game. -class GameSettingsScreen : public UIScreen { +class GameSettingsScreen : public UIScreenWithBackground { public: - GameSettingsScreen(std::string gamePath, std::string gameID) : gamePath_(gamePath), gameID_(gameID) {} + GameSettingsScreen(std::string gamePath, std::string gameID = "") : gamePath_(gamePath), gameID_(gameID) {} + + virtual void update(InputState &input); protected: virtual void CreateViews(); - virtual void DrawBackground(UIContext &dc); private: std::string gamePath_, gameID_; @@ -45,13 +46,12 @@ private: }; // TODO: Move to its own file. -class GlobalSettingsScreen : public UIScreen { +class GlobalSettingsScreen : public UIScreenWithBackground { public: GlobalSettingsScreen() {} protected: virtual void CreateViews(); - virtual void DrawBackground(UIContext &dc); private: // Event handlers @@ -64,13 +64,12 @@ private: bool enableReports_; }; -class DeveloperToolsScreen : public UIScreen { +class DeveloperToolsScreen : public UIScreenWithBackground { public: DeveloperToolsScreen() {} protected: virtual void CreateViews(); - virtual void DrawBackground(UIContext &dc); private: UI::EventReturn OnBack(UI::EventParams &e); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 25f253782d..7c6c44b21a 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -15,15 +15,17 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include "Common/FileUtil.h" -#include "Core/System.h" - #include "base/colorutil.h" #include "base/timeutil.h" #include "math/curves.h" #include "ui/ui_context.h" #include "ui/view.h" #include "ui/viewgroup.h" + +#include "Common/FileUtil.h" +#include "Core/System.h" +#include "Core/SaveState.h" + #include "UI/EmuScreen.h" #include "UI/MainScreen.h" #include "UI/GameScreen.h" @@ -352,12 +354,9 @@ void MainScreen::sendMessage(const char *message, const char *value) { } } -void DrawBackground(float alpha); - -void MainScreen::DrawBackground(UIContext &dc) { +void MainScreen::update(InputState &input) { + UIScreen::update(input); globalUIState = UISTATE_MENU; - ::DrawBackground(1.0f); - dc.Flush(); } UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) { @@ -397,3 +396,98 @@ UI::EventReturn MainScreen::OnExit(UI::EventParams &e) { exit(0); return UI::EVENT_DONE; } + +void GamePauseScreen::update(InputState &input) { + globalUIState = UISTATE_PAUSEMENU; + UIScreen::update(input); +} + +void GamePauseScreen::DrawBackground(UIContext &dc) { + GameInfo *ginfo = g_gameInfoCache.GetInfo(gamePath_, true); + dc.Flush(); + + if (ginfo && ginfo->pic1Texture) { + ginfo->pic1Texture->Bind(0); + uint32_t color = whiteAlpha(ease((time_now_d() - ginfo->timePic1WasLoaded) * 3)) & 0xFFc0c0c0; + dc.Draw()->DrawTexRect(0,0,dp_xres, dp_yres, 0,0,1,1,color); + dc.Flush(); + dc.RebindTexture(); + } +} + +GamePauseScreen::~GamePauseScreen() { + g_Config.iCurrentStateSlot = saveSlots_->GetSelection(); + g_Config.Save(); +} + +void GamePauseScreen::CreateViews() { + using namespace UI; + Margins actionMenuMargins(0, 100, 15, 0); + + 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))); + saveSlots_->AddChoice("1"); + saveSlots_->AddChoice("2"); + saveSlots_->AddChoice("3"); + saveSlots_->AddChoice("4"); + saveSlots_->SetSelection(g_Config.iCurrentStateSlot); + + leftColumnItems->Add(new Choice("Save State"))->OnClick.Handle(this, &GamePauseScreen::OnSaveState); + leftColumnItems->Add(new Choice("Load State"))->OnClick.Handle(this, &GamePauseScreen::OnLoadState); + + ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); + root_->Add(rightColumn); + + ViewGroup *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); + rightColumn->Add(rightColumnItems); + +#ifdef _WIN32 + rightColumnItems->Add(new Choice("Continue"))->OnClick.Handle(this, &GamePauseScreen::OnContinue); +#endif + rightColumnItems->Add(new Choice("Game Settings"))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); + rightColumnItems->Add(new Choice("Main Settings"))->OnClick.Handle(this, &GamePauseScreen::OnMainSettings); + rightColumnItems->Add(new Choice("Exit to menu"))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); +} + +UI::EventReturn GamePauseScreen::OnMainSettings(UI::EventParams &e) { + screenManager()->push(new GlobalSettingsScreen()); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnGameSettings(UI::EventParams &e) { + screenManager()->push(new GameSettingsScreen(gamePath_)); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnContinue(UI::EventParams &e) { + screenManager()->finishDialog(this, DR_CANCEL); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnExitToMenu(UI::EventParams &e) { + screenManager()->switchScreen(new MainScreen()); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnLoadState(UI::EventParams &e) { + SaveState::LoadSlot(saveSlots_->GetSelection(), 0, 0); + + screenManager()->finishDialog(this, DR_CANCEL); + return UI::EVENT_DONE; +} + +UI::EventReturn GamePauseScreen::OnSaveState(UI::EventParams &e) { + SaveState::SaveSlot(saveSlots_->GetSelection(), 0, 0); + + screenManager()->finishDialog(this, DR_CANCEL); + return UI::EVENT_DONE; +} diff --git a/UI/MainScreen.h b/UI/MainScreen.h index ec784b8de0..6168fdc459 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -19,18 +19,20 @@ #include "base/functional.h" #include "ui/ui_screen.h" +#include "ui/viewgroup.h" +#include "UI/MiscScreens.h" // Game screen: Allows you to start a game, delete saves, delete the game, // set game specific settings, etc. // Uses GameInfoCache heavily to implement the functionality. -class MainScreen : public UIScreen { +class MainScreen : public UIScreenWithBackground { public: MainScreen() {} protected: virtual void CreateViews(); - virtual void DrawBackground(UIContext &dc); + virtual void update(InputState &input); virtual void sendMessage(const char *message, const char *value); private: @@ -42,3 +44,26 @@ private: UI::EventReturn OnSupport(UI::EventParams &e); UI::EventReturn OnExit(UI::EventParams &e); }; + +class GamePauseScreen : public UIScreen { +public: + GamePauseScreen(const std::string &filename) : UIScreen(), gamePath_(filename) {} + ~GamePauseScreen(); +protected: + virtual void DrawBackground(UIContext &dc); + virtual void CreateViews(); + virtual void update(InputState &input); + +private: + UI::EventReturn OnMainSettings(UI::EventParams &e); + UI::EventReturn OnGameSettings(UI::EventParams &e); + UI::EventReturn OnContinue(UI::EventParams &e); + UI::EventReturn OnExitToMenu(UI::EventParams &e); + + UI::EventReturn OnSaveState(UI::EventParams &e); + UI::EventReturn OnLoadState(UI::EventParams &e); + + std::string gamePath_; + + UI::ChoiceStrip *saveSlots_; +}; \ No newline at end of file diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 6cfb397d1c..e12d0f2972 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -29,8 +29,9 @@ void DrawBackground(float alpha); -void PromptScreen::DrawBackground(UIContext &dc) { +void UIScreenWithBackground::DrawBackground(UIContext &dc) { ::DrawBackground(1.0f); + dc.Flush(); } void PromptScreen::CreateViews() { diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index a1c6fe25ed..088d0bc7bf 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -27,7 +27,15 @@ inline void NoOpVoidBool(bool) {} -class PromptScreen : public UIScreen { +class UIScreenWithBackground : public UIScreen { +public: + UIScreenWithBackground() : UIScreen() {} +protected: + virtual void DrawBackground(UIContext &dc); +}; + + +class PromptScreen : public UIScreenWithBackground { public: PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText) : message_(message), yesButtonText_(yesButtonText), noButtonText_(noButtonText) { @@ -37,8 +45,6 @@ public: : message_(message), yesButtonText_(yesButtonText), noButtonText_(noButtonText), callback_(callback) {} virtual void CreateViews(); -protected: - virtual void DrawBackground(UIContext &dc); private: UI::EventReturn OnYes(UI::EventParams &e); diff --git a/UI/PluginScreen.cpp b/UI/PluginScreen.cpp index 285cb312b7..185e2092f9 100644 --- a/UI/PluginScreen.cpp +++ b/UI/PluginScreen.cpp @@ -32,13 +32,6 @@ #endif #endif -void DrawBackground(float alpha); - -void PluginScreen::DrawBackground(UIContext &dc) -{ - ::DrawBackground(1.0f); -} - PluginScreen::PluginScreen() { // Let's start by downloading the json. We'll find out in Update when it's finished. json_ = downloader_.StartDownload("http://www.ppsspp.org/update/at3plusdecoder.json", ""); diff --git a/UI/PluginScreen.h b/UI/PluginScreen.h index ee9eee625e..d1112be0ff 100644 --- a/UI/PluginScreen.h +++ b/UI/PluginScreen.h @@ -28,12 +28,9 @@ #include "file/file_util.h" #include "net/http_client.h" -// Uses the new UI framework through UIScreen for simplicity. -// Looks disappointingly like the old UI, right? Don't worry, it's just the theme. -// A redesign is coming. And note that you can control this new UI with your -// keyboard or Xbox controller. +#include "UI/MiscScreens.h" -class PluginScreen : public UIScreen { +class PluginScreen : public UIScreenWithBackground { public: PluginScreen(); @@ -41,7 +38,6 @@ public: protected: virtual void CreateViews(); - virtual void DrawBackground(UIContext &dc); private: // Event handlers diff --git a/native b/native index 4f279b3525..7421e1de67 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 4f279b3525db4e7c2d73d4ee4a6fdd07658ed7c7 +Subproject commit 7421e1de67fd97918c6f0da83fc84a9679ef3464