From e5843160fe622d26214ee13913155bd5862112ac Mon Sep 17 00:00:00 2001 From: iota97 Date: Mon, 14 Feb 2022 07:37:56 +0100 Subject: [PATCH] Add themes to assets --- CMakeLists.txt | 7 +++-- UI/Theme.cpp | 53 +++++++++++++++++---------------- UI/Theme.h | 3 ++ android/ab.cmd | 1 + android/ab.sh | 1 + assets/themes/defaultthemes.ini | 28 +++++++++++++++++ ppsspp.iss | 1 + 7 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 assets/themes/defaultthemes.ini diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a591daa71..91ad738c34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2261,6 +2261,7 @@ set(NativeAssets assets/debugger assets/lang assets/shaders + assets/themes assets/Roboto-Condensed.ttf assets/7z.png assets/compat.ini @@ -2367,6 +2368,7 @@ if(TargetBin) file(GLOB_RECURSE FLASH0_FILES assets/flash0/*) file(GLOB_RECURSE LANG_FILES assets/lang/*) file(GLOB_RECURSE SHADER_FILES assets/shaders/*) + file(GLOB_RECURSE THEME_FILE assets/themes/*) file(GLOB_RECURSE DEBUGGER_FILES assets/debugger/*) if(NOT IOS) @@ -2375,14 +2377,15 @@ if(TargetBin) set_source_files_properties(${FLASH0_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/flash0/font") set_source_files_properties(${LANG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/lang") set_source_files_properties(${SHADER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/shaders") + set_source_files_properties(${THEME_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/themes") set_source_files_properties(${DEBUGGER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/debugger") endif() if(IOS) - add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard") + add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${THEME_FILE} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard") file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/iOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPP.app/Frameworks/") else() - add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource}) + add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${THEME_FILE} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource}) file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/macOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPPSDL.app/Contents/Frameworks/") if(TARGET SDL2::SDL2 AND NOT USING_QT_UI) add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app") diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 2c600d0bb3..62a6888e49 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -81,6 +81,7 @@ static void LoadThemeInfo(const std::vector &directories) { def.name = "Default"; themeInfos.push_back(def); + // This will update the theme if already present, as such default in assets/theme will get priority if exist auto appendTheme = [&](const ThemeInfo &info) { auto beginErase = std::remove(themeInfos.begin(), themeInfos.end(), info.name); if (beginErase != themeInfos.end()) { @@ -122,34 +123,34 @@ static void LoadThemeInfo(const std::vector &directories) { 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("ItemStyleFg", &info.uItemStyleFg, info.uItemStyleFg); + section.Get("ItemStyleBg", &info.uItemStyleBg, info.uItemStyleBg); + section.Get("ItemFocusedStyleFg", &info.uItemFocusedStyleFg, info.uItemFocusedStyleFg); + section.Get("ItemFocusedStyleBg", &info.uItemFocusedStyleBg, info.uItemFocusedStyleBg); + section.Get("ItemDownStyleFg", &info.uItemDownStyleFg, info.uItemDownStyleFg); + section.Get("ItemDownStyleBg", &info.uItemDownStyleBg, info.uItemDownStyleBg); + section.Get("ItemDisabledStyleFg", &info.uItemDisabledStyleFg, info.uItemDisabledStyleFg); + section.Get("ItemDisabledStyleBg", &info.uItemDisabledStyleBg, info.uItemDisabledStyleBg); + section.Get("ItemHighlightedStyleFg", &info.uItemHighlightedStyleFg, info.uItemHighlightedStyleFg); + section.Get("ItemHighlightedStyleBg", &info.uItemHighlightedStyleBg, info.uItemHighlightedStyleBg); - 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("ButtonStyleFg", &info.uButtonStyleFg, info.uButtonStyleFg); + section.Get("ButtonStyleBg", &info.uButtonStyleBg, info.uButtonStyleBg); + section.Get("ButtonFocusedStyleFg", &info.uButtonFocusedStyleFg, info.uButtonFocusedStyleFg); + section.Get("ButtonFocusedStyleBg", &info.uButtonFocusedStyleBg, info.uButtonFocusedStyleBg); + section.Get("ButtonDownStyleFg", &info.uButtonDownStyleFg, info.uButtonDownStyleFg); + section.Get("ButtonDownStyleBg", &info.uButtonDownStyleBg, info.uButtonDownStyleBg); + section.Get("ButtonDisabledStyleFg", &info.uButtonDisabledStyleFg, info.uButtonDisabledStyleFg); + section.Get("ButtonDisabledStyleBg", &info.uButtonDisabledStyleBg, info.uButtonDisabledStyleBg); + section.Get("ButtonHighlightedStyleFg", &info.uButtonHighlightedStyleFg, info.uButtonHighlightedStyleFg); + section.Get("ButtonHighlightedStyleBg", &info.uButtonHighlightedStyleBg, info.uButtonHighlightedStyleBg); - 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); + section.Get("HeaderStyleFg", &info.uHeaderStyleFg, info.uHeaderStyleFg); + section.Get("InfoStyleFg", &info.uInfoStyleFg, info.uInfoStyleFg); + section.Get("InfoStyleBg", &info.uInfoStyleBg, info.uInfoStyleBg); + section.Get("PopupTitleStyleFg", &info.uPopupTitleStyleFg, info.uPopupTitleStyleFg); + section.Get("PopupStyleFg", &info.uPopupStyleFg, info.uPopupStyleFg); + section.Get("PopupStyleBg", &info.uPopupStyleBg, info.uPopupStyleBg); appendTheme(info); } diff --git a/UI/Theme.h b/UI/Theme.h index 9259313606..adff861c04 100644 --- a/UI/Theme.h +++ b/UI/Theme.h @@ -17,6 +17,9 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include + #include "Common/UI/Context.h" void ReloadAllThemeInfo(); diff --git a/android/ab.cmd b/android/ab.cmd index 18aecf6608..f205269c8b 100644 --- a/android/ab.cmd +++ b/android/ab.cmd @@ -2,6 +2,7 @@ mkdir assets > nul xcopy ..\assets\flash0 assets\flash0\ /s /y