From bb3c91f8bb8047a1b1020784cd74b76cb6bee064 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 8 Jun 2013 22:42:31 +0200 Subject: [PATCH] Some New-UI work (disabled, it's not really ready yet). --- CMakeLists.txt | 2 + UI/GameInfoCache.cpp | 2 + UI/GameInfoCache.h | 3 +- UI/GameScreen.cpp | 89 ++++++++++++++++++++++++++++++++++++++- UI/GameScreen.h | 30 ++++++++++++- UI/GameSettingsScreen.cpp | 88 ++++++++++++++++++++++++++++++++++++++ UI/GameSettingsScreen.h | 42 ++++++++++++++++++ UI/MenuScreens.cpp | 5 +++ UI/NativeApp.cpp | 17 ++++---- UI/UI.vcxproj | 2 + UI/UI.vcxproj.filters | 6 +++ android/jni/Android.mk | 2 + native | 2 +- 13 files changed, 277 insertions(+), 13 deletions(-) create mode 100644 UI/GameSettingsScreen.cpp create mode 100644 UI/GameSettingsScreen.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 04d732c097..c766a7d657 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1053,6 +1053,8 @@ set(NativeAppSource android/jni/TestRunner.cpp UI/GameInfoCache.cpp UI/MenuScreens.cpp + UI/GameScreen.cpp + UI/GameSettingsScreen.cpp UI/GamepadEmu.cpp UI/UIShader.cpp UI/OnScreenDisplay.cpp diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 56a7a90e83..51194c2067 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -149,6 +149,7 @@ public: lock_guard lock(info_->lock); info_->paramSFO.ReadSFO(sfoData, sfoSize); info_->title = info_->paramSFO.GetValueString("TITLE"); + info_->paramSFOLoaded = true; } delete [] sfoData; @@ -192,6 +193,7 @@ public: lock_guard lock(info_->lock); info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size()); info_->title = info_->paramSFO.GetValueString("TITLE"); + info_->paramSFOLoaded = true; } { diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index cf2745350a..e428d4f5e7 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -33,7 +33,7 @@ class GameInfo { public: - GameInfo() : fileType(FILETYPE_UNKNOWN), iconTexture(NULL), pic0Texture(NULL), pic1Texture(NULL) {} + GameInfo() : fileType(FILETYPE_UNKNOWN), iconTexture(NULL), pic0Texture(NULL), pic1Texture(NULL), paramSFOLoaded(false) {} bool DeleteGame(); // Better be sure what you're doing when calling this. bool DeleteAllSaveData(); @@ -56,6 +56,7 @@ public: std::string title; // for easy access, also available in paramSFO. EmuFileType fileType; ParamSFOData paramSFO; + bool paramSFOLoaded; // Pre read the data, create a texture the next time (GL thread..) std::string iconTextureData; diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 9a34e040f2..b9876a44c7 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -15,4 +15,91 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include "UI/GameScreen.h" \ No newline at end of file +#include "gfx_es2/draw_buffer.h" +#include "ui/view.h" +#include "ui/viewgroup.h" +#include "UI/EmuScreen.h" +#include "UI/GameScreen.h" +#include "UI/GameSettingsScreen.h" +#include "UI/GameInfoCache.h" + +void GameScreen::CreateViews() { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + + // Information in the top left. + // Back button to the bottom left. + // Scrolling action menu to the right. + using namespace UI; + + Margins actionMenuMargins(0, 100, 15, 0); + + root_ = new LinearLayout(ORIENT_HORIZONTAL); + + ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f)); + root_->Add(leftColumn); + + if (info) { + tvTitle_ = leftColumn->Add(new TextView(0, info->title, ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 10, NONE, NONE))); + } + + ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); + root_->Add(rightColumn); + + ViewGroup *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); + rightColumn->Add(rightColumnItems); + rightColumnItems->Add(new Choice("Play"))->OnClick.Handle(this, &GameScreen::OnPlay); + rightColumnItems->Add(new Choice("Game Settings"))->OnClick.Handle(this, &GameScreen::OnGameSettings); + rightColumnItems->Add(new Choice("Delete Save Data"))->OnClick.Handle(this, &GameScreen::OnDeleteSaveData); + rightColumnItems->Add(new Choice("Delete Game"))->OnClick.Handle(this, &GameScreen::OnDeleteGame); +} + +void DrawBackground(float alpha); + +void GameScreen::DrawBackground() { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + ::DrawBackground(1.0f); +} + +void GameScreen::update(InputState &input) { + UIScreen::update(input); + + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + if (tvTitle_) + tvTitle_->SetText(info->title); +} + +UI::EventReturn GameScreen::OnPlay(UI::EventParams &e) { + screenManager()->switchScreen(new EmuScreen(gamePath_)); + return UI::EVENT_DONE; +} + +UI::EventReturn GameScreen::OnGameSettings(UI::EventParams &e) { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + if (info && info->paramSFOLoaded) { + std::string discID = info->paramSFO.GetValueString("DISC_ID"); + screenManager()->push(new GameSettingsScreen(gamePath_, discID)); + } + return UI::EVENT_DONE; +} + +UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + if (info) { + // VERY DANGEROUS, must add confirmation dialog before enabling. + // info->DeleteAllSaveData(); + } + + RecreateViews(); + return UI::EVENT_DONE; +} + +UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + if (info) { + // VERY DANGEROUS + // info->DeleteGame(); + } + + RecreateViews(); + return UI::EVENT_DONE; +} diff --git a/UI/GameScreen.h b/UI/GameScreen.h index b7aeb7926d..801a760eaa 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -17,4 +17,32 @@ #pragma once -// Game screen: Contains options such as \ No newline at end of file +#include "ui/ui_screen.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 GameScreen : public UIScreen { +public: + GameScreen(std::string gamePath) : gamePath_(gamePath) {} + + virtual void update(InputState &input); + +protected: + virtual void CreateViews(); + virtual void DrawBackground(); + +private: + // Event handlers + UI::EventReturn OnPlay(UI::EventParams &e); + UI::EventReturn OnGameSettings(UI::EventParams &e); + UI::EventReturn OnDeleteSaveData(UI::EventParams &e); + UI::EventReturn OnDeleteGame(UI::EventParams &e); + + std::string gamePath_; + + // As we load metadata in the background, we need to be able to update these after the fact. + UI::TextView *tvTitle_; + UI::TextView *tvGameSize_; +}; \ No newline at end of file diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp new file mode 100644 index 0000000000..30c6f85981 --- /dev/null +++ b/UI/GameSettingsScreen.cpp @@ -0,0 +1,88 @@ +// Copyright (c) 2013- 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 "gfx_es2/draw_buffer.h" +#include "i18n/i18n.h" +#include "ui/view.h" +#include "ui/viewgroup.h" +#include "UI/EmuScreen.h" +#include "UI/PluginScreen.h" +#include "UI/GameSettingsScreen.h" +#include "UI/GameInfoCache.h" +#include "Core/Config.h" + +void GameSettingsScreen::CreateViews() { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + + // Information in the top left. + // Back button to the bottom left. + // Scrolling action menu to the right. + using namespace UI; + + I18NCategory *g = GetI18NCategory("General"); + I18NCategory *gs = GetI18NCategory("Graphics"); + + Margins actionMenuMargins(0, 0, 15, 0); + + root_ = new LinearLayout(ORIENT_HORIZONTAL); + + ViewGroup *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)); + root_->Add(leftColumn); + + leftColumn->Add(new Spacer(new LinearLayoutParams(1.0))); + leftColumn->Add(new Choice("Back"))->OnClick.Handle(this, &UIScreen::OnBack); + + TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new LinearLayoutParams(600, FILL_PARENT, actionMenuMargins)); + root_->Add(tabHolder); + + + // TODO: These currently point to global settings, not game specific ones. + + ViewGroup *graphicsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); + ViewGroup *graphicsSettings = new LinearLayout(ORIENT_VERTICAL); + graphicsSettingsScroll->Add(graphicsSettings); + tabHolder->AddTab("Graphics", graphicsSettingsScroll); + graphicsSettings->Add(new CheckBox(&g_Config.bLinearFiltering, gs->T("Linear Filtering"))); + graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display"))); + graphicsSettings->Add(new CheckBox(&g_Config.bBufferedRendering, gs->T("Buffered Rendering"))); + graphicsSettings->Add(new CheckBox(&g_Config.bDisplayFramebuffer, gs->T("Display Raw Framebuffer"))); + graphicsSettings->Add(new CheckBox(&g_Config.bMipMap, gs->T("Mipmapping"))); + graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gs->T("Vertex Cache"))); + graphicsSettings->Add(new CheckBox(&g_Config.bUseVBO, gs->T("Stream VBO"))); + graphicsSettings->Add(new CheckBox(&g_Config.bUseMediaEngine, gs->T("Use Media Engine"))); + graphicsSettings->Add(new CheckBox(&g_Config.SSAntiAliasing, gs->T("Anti Aliasing"))); + + ViewGroup *audioSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); + ViewGroup *audioSettings = new LinearLayout(ORIENT_VERTICAL); + audioSettingsScroll->Add(audioSettings); + tabHolder->AddTab("Audio", audioSettingsScroll); + audioSettings->Add(new CheckBox(&g_Config.bEnableSound, "Enable Sound")); + audioSettings->Add(new CheckBox(&g_Config.bEnableAtrac3plus, "Enable Atrac3+")); + audioSettings->Add(new Choice("Download Atrac3+ plugin"))->OnClick.Handle(this, &GameSettingsScreen::OnDownloadPlugin); +} + +UI::EventReturn GameSettingsScreen::OnDownloadPlugin(UI::EventParams &e) { + screenManager()->push(new PluginScreen()); + return UI::EVENT_DONE; +} + +void DrawBackground(float alpha); + +void GameSettingsScreen::DrawBackground() { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + ::DrawBackground(1.0f); +} diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h new file mode 100644 index 0000000000..85ce5d343a --- /dev/null +++ b/UI/GameSettingsScreen.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013- 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 "ui/ui_screen.h" + + +// Per-game settings screen - enables you to configure graphic options, control options, etc +// per game. +class GameSettingsScreen : public UIScreen { +public: + GameSettingsScreen(std::string gamePath, std::string gameID) : gamePath_(gamePath), gameID_(gameID) {} + +protected: + virtual void CreateViews(); + virtual void DrawBackground(); + +private: + // Event handlers + UI::EventReturn OnDownloadPlugin(UI::EventParams &e); + + std::string gamePath_, gameID_; + + // As we load metadata in the background, we need to be able to update these after the fact. + UI::TextView *tvTitle_; + UI::TextView *tvGameSize_; +}; \ No newline at end of file diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 7a8bade001..bd28052e3a 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -55,6 +55,7 @@ #include "Core/HLE/sceUtility.h" #include "UI/MenuScreens.h" +#include "UI/GameScreen.h" #include "UI/EmuScreen.h" #include "UI/PluginScreen.h" @@ -307,12 +308,16 @@ void MenuScreen::render() { } if (UITextureButton(ctx, (int)GEN_ID_LOOP(i), vgrid_recent, textureButtonWidth, textureButtonHeight, ginfo->iconTexture, ALIGN_LEFT, color, I_DROP_SHADOW)) { UIEnd(); + + // To try some new UI, enable this. + //screenManager()->switchScreen(new GameScreen(g_Config.recentIsos[i])); screenManager()->switchScreen(new EmuScreen(g_Config.recentIsos[i])); return; } } else { if (UIButton((int)GEN_ID_LOOP(i), vgrid_recent, textureButtonWidth, textureButtonHeight, filename.c_str(), ALIGN_LEFT)) { UIEnd(); + //screenManager()->switchScreen(new GameScreen(g_Config.recentIsos[i])); screenManager()->switchScreen(new EmuScreen(g_Config.recentIsos[i])); return; } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 2c07bdf563..b63b31e32a 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -392,20 +392,19 @@ void NativeInitGraphics() { ui_theme.checkOn = I_CHECKEDBOX; ui_theme.checkOff = I_SQUARE; ui_theme.whiteImage = SOLIDWHITE; - ui_theme.buttonStyle.bgColor = 0xFFFFFFFF; + ui_theme.buttonStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON); ui_theme.buttonStyle.fgColor = 0xFFFFFFFF; ui_theme.buttonStyle.image = I_BUTTON; - ui_theme.buttonFocusedStyle.bgColor = 0xFFe0e0e0; + ui_theme.buttonFocusedStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFFe0e0e0); ui_theme.buttonFocusedStyle.fgColor = 0xFFFFFFFF; - ui_theme.buttonFocusedStyle.image = I_BUTTON_SELECTED; - ui_theme.buttonDownStyle.bgColor = 0xFFFFFFFF; + ui_theme.buttonDownStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON_SELECTED, 0xFFFFFFFF); ui_theme.buttonDownStyle.fgColor = 0xFFFFFFFF; - ui_theme.buttonDownStyle.image = I_BUTTON_SELECTED; - ui_theme.buttonDisabledStyle.bgColor = 0xFF404040; + ui_theme.buttonDisabledStyle.background = UI::Drawable(UI::DRAW_4GRID, I_BUTTON, 0xFF404040); ui_theme.buttonDisabledStyle.fgColor = 0xFF707070; - ui_theme.buttonDisabledStyle.image = I_BUTTON; - ui_theme.itemFocusedStyle.bgColor = 0xFF808080; - ui_theme.itemDownStyle.bgColor = 0xFFFFc080; + ui_theme.itemStyle.background = UI::Drawable(0x55000000); + ui_theme.itemStyle.fgColor = 0xFFFFFFFF; + ui_theme.itemFocusedStyle.background = UI::Drawable(0xCC909080); + ui_theme.itemDownStyle.background = UI::Drawable(0xFFFFc080); ui_theme.itemDownStyle.fgColor = 0xFF000000; ui_draw2d.Init(); diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index c3c7a867a7..18903087c6 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -23,6 +23,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index 3063e7e919..70fb666141 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -19,6 +19,9 @@ Screens + + Screens + @@ -38,6 +41,9 @@ Screens + + Screens + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 14b88259cd..014c895b71 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -137,6 +137,8 @@ LOCAL_SRC_FILES := \ $(SRC)/UI/GameInfoCache.cpp \ $(SRC)/UI/OnScreenDisplay.cpp \ $(SRC)/UI/PluginScreen.cpp \ + $(SRC)/UI/GameScreen.cpp \ + $(SRC)/UI/GameSettingsScreen.cpp \ $(SRC)/native/android/app-android.cpp \ $(SRC)/ext/disarm.cpp \ $(SRC)/ext/libkirk/AES.c \ diff --git a/native b/native index 8e5890a7e2..166acebeff 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 8e5890a7e28af03f237eafaaa25e7a10d16899da +Subproject commit 166acebeffb5b90efc0e40704943731aedee9969