Add basic NewUI in-game menu.

This commit is contained in:
Henrik Rydgard committed 2013-07-21 13:31:46 +02:00
1 parent 679a6a98b2
commit 2b35aa9050
13 files changed
+168 -53

No files matched your search

+2
View File
@@ -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);
+1
View File
@@ -94,6 +94,7 @@ public:
int iFpsLimit;
int iForceMaxEmulatedFPS;
int iMaxRecent;
int iCurrentStateSlot;
bool bEnableCheats;
bool bReloadCheats;
+12 -3
View File
@@ -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());
}
}
}
+1
View File
@@ -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_;
+2 -14
View File
@@ -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);
+7 -8
View File
@@ -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);
+102 -8
View File
@@ -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;
}
+27 -2
View File
@@ -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_;
};
+2 -1
View File
@@ -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() {
+9 -3
View File
@@ -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);
-7
View File
@@ -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", "");
+2 -6
View File
@@ -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
+1 -1
Submodule native updated: 4f279b3525...7421e1de67.