From 5e1062678fdf9e5f87f0435f7088398739797f52 Mon Sep 17 00:00:00 2001 From: iota97 Date: Fri, 11 Feb 2022 12:32:23 +0100 Subject: [PATCH] Allow custom UI themes --- CMakeLists.txt | 2 + Core/Config.cpp | 29 +---- Core/Config.h | 30 +---- Core/System.cpp | 2 + Core/System.h | 1 + UI/GameSettingsScreen.cpp | 10 ++ UI/NativeApp.cpp | 50 +------- UI/Theme.cpp | 238 ++++++++++++++++++++++++++++++++++++++ UI/Theme.h | 25 ++++ UI/UI.vcxproj | 2 + UWP/UI_UWP/UI_UWP.vcxproj | 2 + android/jni/Android.mk | 1 + 12 files changed, 288 insertions(+), 104 deletions(-) create mode 100644 UI/Theme.cpp create mode 100644 UI/Theme.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6882811733..0a591daa71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1235,6 +1235,8 @@ list(APPEND NativeAppSource UI/TextureUtil.cpp UI/ComboKeyMappingScreen.h UI/ComboKeyMappingScreen.cpp + UI/Theme.h + UI/Theme.cpp ) if(ANDROID) diff --git a/Core/Config.cpp b/Core/Config.cpp index cae5f22b5d..aca17187b6 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1169,34 +1169,7 @@ static ConfigSetting upgradeSettings[] = { }; static ConfigSetting themeSettings[] = { - ConfigSetting("ItemStyleFg", &g_Config.uItemStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemStyleBg", &g_Config.uItemStyleBg, 0x55000000, true, false), - ConfigSetting("ItemFocusedStyleFg", &g_Config.uItemFocusedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemFocusedStyleBg", &g_Config.uItemFocusedStyleBg, 0xFFEDC24C, true, false), - ConfigSetting("ItemDownStyleFg", &g_Config.uItemDownStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemDownStyleBg", &g_Config.uItemDownStyleBg, 0xFFBD9939, true, false), - ConfigSetting("ItemDisabledStyleFg", &g_Config.uItemDisabledStyleFg, 0x80EEEEEE, true, false), - ConfigSetting("ItemDisabledStyleBg", &g_Config.uItemDisabledStyleBg, 0x55E0D4AF, true, false), - ConfigSetting("ItemHighlightedStyleFg", &g_Config.uItemHighlightedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ItemHighlightedStyleBg", &g_Config.uItemHighlightedStyleBg, 0x55BDBB39, true, false), - - ConfigSetting("ButtonStyleFg", &g_Config.uButtonStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonStyleBg", &g_Config.uButtonStyleBg, 0x55000000, true, false), - ConfigSetting("ButtonFocusedStyleFg", &g_Config.uButtonFocusedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonFocusedStyleBg", &g_Config.uButtonFocusedStyleBg, 0xFFEDC24C, true, false), - ConfigSetting("ButtonDownStyleFg", &g_Config.uButtonDownStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonDownStyleBg", &g_Config.uButtonDownStyleBg, 0xFFBD9939, true, false), - ConfigSetting("ButtonDisabledStyleFg", &g_Config.uButtonDisabledStyleFg, 0x80EEEEEE, true, false), - ConfigSetting("ButtonDisabledStyleBg", &g_Config.uButtonDisabledStyleBg, 0x55E0D4AF, true, false), - ConfigSetting("ButtonHighlightedStyleFg", &g_Config.uButtonHighlightedStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("ButtonHighlightedStyleBg", &g_Config.uButtonHighlightedStyleBg, 0x55BDBB39, true, false), - - ConfigSetting("HeaderStyleFg", &g_Config.uHeaderStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("InfoStyleFg", &g_Config.uInfoStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("InfoStyleBg", &g_Config.uInfoStyleBg, 0x00000000U, true, false), - ConfigSetting("PopupTitleStyleFg", &g_Config.uPopupTitleStyleFg, 0xFFE3BE59, true, false), - ConfigSetting("PopupStyleFg", &g_Config.uPopupStyleFg, 0xFFFFFFFF, true, false), - ConfigSetting("PopupStyleBg", &g_Config.uPopupStyleBg, 0xFF303030, true, false), + ConfigSetting("ThemeName", &g_Config.sThemeName, "Default", true, false), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index bed269cd63..e2ff16ed99 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -255,35 +255,7 @@ public: bool bShowOnScreenMessages; int iBackgroundAnimation; // enum BackgroundAnimation - // TODO: Maybe move to a separate theme system. - uint32_t uItemStyleFg; - uint32_t uItemStyleBg; - uint32_t uItemFocusedStyleFg; - uint32_t uItemFocusedStyleBg; - uint32_t uItemDownStyleFg; - uint32_t uItemDownStyleBg; - uint32_t uItemDisabledStyleFg; - uint32_t uItemDisabledStyleBg; - uint32_t uItemHighlightedStyleFg; - uint32_t uItemHighlightedStyleBg; - - uint32_t uButtonStyleFg; - uint32_t uButtonStyleBg; - uint32_t uButtonFocusedStyleFg; - uint32_t uButtonFocusedStyleBg; - uint32_t uButtonDownStyleFg; - uint32_t uButtonDownStyleBg; - uint32_t uButtonDisabledStyleFg; - uint32_t uButtonDisabledStyleBg; - uint32_t uButtonHighlightedStyleFg; - uint32_t uButtonHighlightedStyleBg; - - uint32_t uHeaderStyleFg; - uint32_t uInfoStyleFg; - uint32_t uInfoStyleBg; - uint32_t uPopupTitleStyleFg; - uint32_t uPopupStyleFg; - uint32_t uPopupStyleBg; + std::string sThemeName; bool bLogFrameDrops; bool bShowDebugStats; diff --git a/Core/System.cpp b/Core/System.cpp index 31f720be2e..e3952524d6 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -645,6 +645,8 @@ Path GetSysDirectory(PSPDirectories directoryType) { return pspDirectory / "AUDIO"; case DIRECTORY_CUSTOM_SHADERS: return pspDirectory / "shaders"; + case DIRECTORY_CUSTOM_THEMES: + return pspDirectory / "themes"; case DIRECTORY_MEMSTICK_ROOT: return g_Config.memStickDirectory; diff --git a/Core/System.h b/Core/System.h index f28681e6d3..641e6444e8 100644 --- a/Core/System.h +++ b/Core/System.h @@ -56,6 +56,7 @@ enum PSPDirectories { DIRECTORY_MEMSTICK_ROOT, DIRECTORY_EXDATA, DIRECTORY_CUSTOM_SHADERS, + DIRECTORY_CUSTOM_THEMES, }; class GraphicsContext; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 180f79eaa1..37f4708867 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -51,6 +51,7 @@ #include "UI/TiltEventProcessor.h" #include "UI/GPUDriverTestScreen.h" #include "UI/MemStickScreen.h" +#include "UI/Theme.h" #include "Common/File/FileUtil.h" #include "Common/OSVersion.h" @@ -191,6 +192,7 @@ bool PathToVisualUsbPath(Path path, std::string &outPath) { void GameSettingsScreen::CreateViews() { ReloadAllPostShaderInfo(screenManager()->getDrawContext()); + ReloadAllThemeInfo(); if (editThenRestore_) { std::shared_ptr info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0); @@ -881,6 +883,14 @@ void GameSettingsScreen::CreateViews() { if (backgroundChoice_ != nullptr) { backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground); } + + PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, gr->T("Color Theme"), GetThemeInfoNames(), nullptr, screenManager())); + theme->OnChoice.Add([=](EventParams &e) { + UpdateTheme(); + + return UI::EVENT_CONTINUE; + }); + static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves", "Moving background" }; systemSettings->Add(new PopupMultiChoice(&g_Config.iBackgroundAnimation, sy->T("UI background animation"), backgroundAnimations, 0, ARRAY_SIZE(backgroundAnimations), sy->GetName(), screenManager())); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 2d94f47282..52a43b6f3c 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -115,6 +115,7 @@ #include "UI/RemoteISOScreen.h" #include "UI/TiltEventProcessor.h" #include "UI/TextureUtil.h" +#include "UI/Theme.h" #if !defined(MOBILE_DEVICE) && defined(USING_QT_UI) #include "Qt/QtHost.h" @@ -131,7 +132,6 @@ // The new UI framework, for initialization -static UI::Theme ui_theme; static Atlas g_ui_atlas; static Atlas g_font_atlas; @@ -873,49 +873,6 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch restarting = false; } -static UI::Style MakeStyle(uint32_t fg, uint32_t bg) { - UI::Style s; - s.background = UI::Drawable(bg); - s.fgColor = fg; - return s; -} - -static void UIThemeInit() { -#if defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) || defined(USING_QT_UI) - ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 22); - ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 15); - ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 12); -#else - ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), "", 20); - ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), "", 14); - ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), "", 11); -#endif - - ui_theme.checkOn = ImageID("I_CHECKEDBOX"); - ui_theme.checkOff = ImageID("I_SQUARE"); - ui_theme.whiteImage = ImageID("I_SOLIDWHITE"); - ui_theme.sliderKnob = ImageID("I_CIRCLE"); - ui_theme.dropShadow4Grid = ImageID("I_DROP_SHADOW"); - - ui_theme.itemStyle = MakeStyle(g_Config.uItemStyleFg, g_Config.uItemStyleBg); - ui_theme.itemFocusedStyle = MakeStyle(g_Config.uItemFocusedStyleFg, g_Config.uItemFocusedStyleBg); - ui_theme.itemDownStyle = MakeStyle(g_Config.uItemDownStyleFg, g_Config.uItemDownStyleBg); - ui_theme.itemDisabledStyle = MakeStyle(g_Config.uItemDisabledStyleFg, g_Config.uItemDisabledStyleBg); - ui_theme.itemHighlightedStyle = MakeStyle(g_Config.uItemHighlightedStyleFg, g_Config.uItemHighlightedStyleBg); - - ui_theme.buttonStyle = MakeStyle(g_Config.uButtonStyleFg, g_Config.uButtonStyleBg); - ui_theme.buttonFocusedStyle = MakeStyle(g_Config.uButtonFocusedStyleFg, g_Config.uButtonFocusedStyleBg); - ui_theme.buttonDownStyle = MakeStyle(g_Config.uButtonDownStyleFg, g_Config.uButtonDownStyleBg); - ui_theme.buttonDisabledStyle = MakeStyle(g_Config.uButtonDisabledStyleFg, g_Config.uButtonDisabledStyleBg); - ui_theme.buttonHighlightedStyle = MakeStyle(g_Config.uButtonHighlightedStyleFg, g_Config.uButtonHighlightedStyleBg); - - ui_theme.headerStyle.fgColor = g_Config.uHeaderStyleFg; - ui_theme.infoStyle = MakeStyle(g_Config.uInfoStyleFg, g_Config.uInfoStyleBg); - - ui_theme.popupTitle.fgColor = g_Config.uPopupTitleStyleFg; - ui_theme.popupStyle = MakeStyle(g_Config.uPopupStyleFg, g_Config.uPopupStyleBg); -} - void RenderOverlays(UIContext *dc, void *userdata); bool CreateGlobalPipelines(); @@ -962,10 +919,9 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) { ui_draw2d_front.SetAtlas(&g_ui_atlas); ui_draw2d_front.SetFontAtlas(&g_font_atlas); - UIThemeInit(); - + UpdateTheme(); uiContext = new UIContext(); - uiContext->theme = &ui_theme; + uiContext->theme = GetTheme(); ui_draw2d.Init(g_draw, texColorPipeline); ui_draw2d_front.Init(g_draw, texColorPipeline); diff --git a/UI/Theme.cpp b/UI/Theme.cpp new file mode 100644 index 0000000000..51659270b6 --- /dev/null +++ b/UI/Theme.cpp @@ -0,0 +1,238 @@ +// 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 "ppsspp_config.h" + +#include + +#include "UI/Theme.h" + +#include "Common/File/FileUtil.h" +#include "Common/File/VFS/VFS.h" +#include "Common/Data/Format/IniFile.h" + +#include "Core/Config.h" + +#include "Common/UI/View.h" +#include "Common/UI/Context.h" +#include "Core/System.h" + +struct themeInfo { + std::string name; + + uint32_t uItemStyleFg = 0xFFFFFFFF; + uint32_t uItemStyleBg = 0x55000000; + uint32_t uItemFocusedStyleFg = 0xFFFFFFFF; + uint32_t uItemFocusedStyleBg = 0xFFEDC24C; + uint32_t uItemDownStyleFg = 0xFFFFFFFF; + uint32_t uItemDownStyleBg = 0xFFBD9939; + uint32_t uItemDisabledStyleFg = 0x80EEEEEE; + uint32_t uItemDisabledStyleBg = 0x55E0D4AF; + uint32_t uItemHighlightedStyleFg = 0xFFFFFFFF; + uint32_t uItemHighlightedStyleBg = 0x55BDBB39; + + uint32_t uButtonStyleFg = 0xFFFFFFFF; + uint32_t uButtonStyleBg = 0x55000000; + uint32_t uButtonFocusedStyleFg = 0xFFFFFFFF; + uint32_t uButtonFocusedStyleBg = 0xFFBD9939; + uint32_t uButtonDownStyleFg = 0xFFFFFFFF; + uint32_t uButtonDownStyleBg = 0xFFBD9939; + uint32_t uButtonDisabledStyleFg = 0x80EEEEEE; + uint32_t uButtonDisabledStyleBg = 0x55E0D4AF; + uint32_t uButtonHighlightedStyleFg = 0xFFFFFFFF; + uint32_t uButtonHighlightedStyleBg = 0x55BDBB39; + + uint32_t uHeaderStyleFg = 0xFFFFFFFF; + uint32_t uInfoStyleFg = 0xFFFFFFFF; + uint32_t uInfoStyleBg = 0x00000000; + uint32_t uPopupTitleStyleFg = 0xFFE3BE59; + uint32_t uPopupStyleFg = 0xFFFFFFFF; + uint32_t uPopupStyleBg = 0xFF303030; + + bool operator == (const std::string &other) { + return name == other; + } + bool operator == (const themeInfo &other) { + return name == other.name; + } +}; + +static UI::Theme ui_theme; +static std::vector themeInfos; + +static void LoadThemeInfo(const std::vector &directories) { + themeInfos.clear(); + themeInfo def{}; + def.name = "Default"; + themeInfos.push_back(def); + + auto appendTheme = [&](const themeInfo &info) { + auto beginErase = std::remove(themeInfos.begin(), themeInfos.end(), info.name); + if (beginErase != themeInfos.end()) { + themeInfos.erase(beginErase, themeInfos.end()); + } + themeInfos.push_back(info); + }; + + for (size_t d = 0; d < directories.size(); d++) { + std::vector fileInfo; + VFSGetFileListing(directories[d].c_str(), &fileInfo, "ini:"); + + if (fileInfo.empty()) { + File::GetFilesInDir(directories[d], &fileInfo, "ini:"); + } + + for (size_t f = 0; f < fileInfo.size(); f++) { + IniFile ini; + bool success = false; + Path name = fileInfo[f].fullName; + Path path = directories[d]; + // Hack around Android VFS path bug. really need to redesign this. + if (name.ToString().substr(0, 7) == "assets/") + name = Path(name.ToString().substr(7)); + if (path.ToString().substr(0, 7) == "assets/") + path = Path(path.ToString().substr(7)); + + if (ini.LoadFromVFS(name.ToString()) || ini.Load(fileInfo[f].fullName)) { + success = true; + // vsh load. meh. + } + + if (!success) + continue; + + // Alright, let's loop through the sections and see if any is a themes. + for (size_t i = 0; i < ini.Sections().size(); i++) { + Section §ion = ini.Sections()[i]; + themeInfo info; + section.Get("Name", &info.name, section.name().c_str()); + + section.Get("ItemStyleFg", &info.uItemStyleFg, 0xFFFFFFFF); + section.Get("ItemStyleBg", &info.uItemStyleBg, 0x55000000); + section.Get("ItemFocusedStyleFg", &info.uItemFocusedStyleFg, 0xFFFFFFFF); + section.Get("ItemFocusedStyleBg", &info.uItemFocusedStyleBg, 0xFFEDC24C); + section.Get("ItemDownStyleFg", &info.uItemDownStyleFg, 0xFFFFFFFF); + section.Get("ItemDownStyleBg", &info.uItemDownStyleBg, 0xFFBD9939); + section.Get("ItemDisabledStyleFg", &info.uItemDisabledStyleFg, 0x80EEEEEE); + section.Get("ItemDisabledStyleBg", &info.uItemDisabledStyleBg, 0x55E0D4AF); + section.Get("ItemHighlightedStyleFg", &info.uItemHighlightedStyleFg, 0xFFFFFFFF); + section.Get("ItemHighlightedStyleBg", &info.uItemHighlightedStyleBg, 0x55BDBB39); + + section.Get("ButtonStyleFg", &info.uButtonStyleFg, 0xFFFFFFFF); + section.Get("ButtonStyleBg", &info.uButtonStyleBg, 0x55000000); + section.Get("ButtonFocusedStyleFg", &info.uButtonFocusedStyleFg, 0xFFFFFFFF); + section.Get("ButtonFocusedStyleBg", &info.uButtonFocusedStyleBg, 0xFFBD9939); + section.Get("ButtonDownStyleFg", &info.uButtonDownStyleFg, 0xFFFFFFFF); + section.Get("ButtonDownStyleBg", &info.uButtonDownStyleBg, 0xFFBD9939); + section.Get("ButtonDisabledStyleFg", &info.uButtonDisabledStyleFg, 0x80EEEEEE); + section.Get("ButtonDisabledStyleBg", &info.uButtonDisabledStyleBg, 0x55E0D4AF); + section.Get("ButtonHighlightedStyleFg", &info.uButtonHighlightedStyleFg, 0xFFFFFFFF); + section.Get("ButtonHighlightedStyleBg", &info.uButtonHighlightedStyleBg, 0x55BDBB39); + + section.Get("HeaderStyleFg", &info.uHeaderStyleFg, 0xFFFFFFFF); + section.Get("InfoStyleFg", &info.uInfoStyleFg, 0xFFFFFFFF); + section.Get("InfoStyleBg", &info.uInfoStyleBg, 0x00000000); + section.Get("PopupTitleStyleFg", &info.uPopupTitleStyleFg, 0xFFE3BE59); + section.Get("PopupStyleFg", &info.uPopupStyleFg, 0xFFFFFFFF); + section.Get("PopupStyleBg", &info.uPopupStyleBg, 0xFF303030); + + appendTheme(info); + } + } + } +} + +static UI::Style MakeStyle (uint32_t fg, uint32_t bg) { + UI::Style s; + s.background = UI::Drawable(bg); + s.fgColor = fg; + return s; +} + +void UpdateTheme() { + // First run, get the default in at least + if (themeInfos.empty()) { + ReloadAllThemeInfo(); + } + + size_t i; + for (i = 0; i < themeInfos.size(); ++i) { + if (themeInfos[i].name == g_Config.sThemeName) { + break; + } + } + + // Reset to Default if not found + if (i >= themeInfos.size()) { + g_Config.sThemeName = "Default"; + i = 0; + } + +#if defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) || defined(USING_QT_UI) + ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 22); + ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 15); + ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), g_Config.sFont.c_str(), 12); +#else + ui_theme.uiFont = UI::FontStyle(FontID("UBUNTU24"), "", 20); + ui_theme.uiFontSmall = UI::FontStyle(FontID("UBUNTU24"), "", 14); + ui_theme.uiFontSmaller = UI::FontStyle(FontID("UBUNTU24"), "", 11); +#endif + + ui_theme.checkOn = ImageID("I_CHECKEDBOX"); + ui_theme.checkOff = ImageID("I_SQUARE"); + ui_theme.whiteImage = ImageID("I_SOLIDWHITE"); + ui_theme.sliderKnob = ImageID("I_CIRCLE"); + ui_theme.dropShadow4Grid = ImageID("I_DROP_SHADOW"); + + // Actual configurable themes setting start here + ui_theme.itemStyle = MakeStyle(themeInfos[i].uItemStyleFg, themeInfos[i].uItemStyleBg); + ui_theme.itemFocusedStyle = MakeStyle(themeInfos[i].uItemFocusedStyleFg, themeInfos[i].uItemFocusedStyleBg); + ui_theme.itemDownStyle = MakeStyle(themeInfos[i].uItemDownStyleFg, themeInfos[i].uItemDownStyleBg); + ui_theme.itemDisabledStyle = MakeStyle(themeInfos[i].uItemDisabledStyleFg, themeInfos[i].uItemDisabledStyleBg); + ui_theme.itemHighlightedStyle = MakeStyle(themeInfos[i].uItemHighlightedStyleFg, themeInfos[i].uItemHighlightedStyleBg); + + ui_theme.buttonStyle = MakeStyle(themeInfos[i].uButtonStyleFg, themeInfos[i].uButtonStyleBg); + ui_theme.buttonFocusedStyle = MakeStyle(themeInfos[i].uButtonFocusedStyleFg, themeInfos[i].uButtonFocusedStyleBg); + ui_theme.buttonDownStyle = MakeStyle(themeInfos[i].uButtonDownStyleFg, themeInfos[i].uButtonDownStyleBg); + ui_theme.buttonDisabledStyle = MakeStyle(themeInfos[i].uButtonDisabledStyleFg, themeInfos[i].uButtonDisabledStyleBg); + ui_theme.buttonHighlightedStyle = MakeStyle(themeInfos[i].uButtonHighlightedStyleFg, themeInfos[i].uButtonHighlightedStyleBg); + + ui_theme.headerStyle.fgColor = themeInfos[i].uHeaderStyleFg; + ui_theme.infoStyle = MakeStyle(themeInfos[i].uInfoStyleFg, themeInfos[i].uInfoStyleBg); + + ui_theme.popupTitle.fgColor = themeInfos[i].uPopupTitleStyleFg; + ui_theme.popupStyle = MakeStyle(themeInfos[i].uPopupStyleFg, themeInfos[i].uPopupStyleBg); +} + +UI::Theme *GetTheme() { + return &ui_theme; +} + +void ReloadAllThemeInfo() { + std::vector directories; + directories.push_back(Path("themes")); // For VFS + directories.push_back(GetSysDirectory(DIRECTORY_CUSTOM_THEMES)); + LoadThemeInfo(directories); +} + +std::vector GetThemeInfoNames() { + std::vector names; + for (auto& i : themeInfos) + names.push_back(i.name); + + return names; +} \ No newline at end of file diff --git a/UI/Theme.h b/UI/Theme.h new file mode 100644 index 0000000000..e4e944efeb --- /dev/null +++ b/UI/Theme.h @@ -0,0 +1,25 @@ +// 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 "Common/File/DirListing.h" +#include "Common/UI/Context.h" + +void ReloadAllThemeInfo(); + +std::vector GetThemeInfoNames(); +void UpdateTheme(); +UI::Theme *GetTheme(); \ No newline at end of file diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index b56a983acd..3264c2878f 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -67,6 +67,7 @@ + @@ -101,6 +102,7 @@ + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj b/UWP/UI_UWP/UI_UWP.vcxproj index b85cfdce34..c6534b2cd9 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj +++ b/UWP/UI_UWP/UI_UWP.vcxproj @@ -396,6 +396,7 @@ + @@ -431,6 +432,7 @@ + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index b83f0223d9..bff3e7f199 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -686,6 +686,7 @@ LOCAL_SRC_FILES := \ $(SRC)/UI/ProfilerDraw.cpp \ $(SRC)/UI/NativeApp.cpp \ $(SRC)/UI/TextureUtil.cpp \ + $(SRC)/UI/Theme.cpp \ $(SRC)/UI/ComboKeyMappingScreen.cpp ifneq ($(SKIPAPP),1)