Merge pull request #15394 from iota97/theme

Allow custom UI themes
This commit is contained in:
Henrik Rydgård
2022-02-17 10:45:13 +01:00
committed by GitHub
26 changed files with 342 additions and 174 deletions
+7 -2
View File
@@ -1235,6 +1235,8 @@ list(APPEND NativeAppSource
UI/TextureUtil.cpp
UI/ComboKeyMappingScreen.h
UI/ComboKeyMappingScreen.cpp
UI/Theme.h
UI/Theme.cpp
)
if(ANDROID)
@@ -2259,6 +2261,7 @@ set(NativeAssets
assets/debugger
assets/lang
assets/shaders
assets/themes
assets/Roboto-Condensed.ttf
assets/7z.png
assets/compat.ini
@@ -2365,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)
@@ -2373,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")
+6
View File
@@ -822,6 +822,12 @@ void AbstractChoiceWithValueDisplay::Draw(UIContext &dc) {
if (!IsEnabled()) {
style = dc.theme->itemDisabledStyle;
}
if (HasFocus()) {
style = dc.theme->itemFocusedStyle;
}
if (down_) {
style = dc.theme->itemDownStyle;
}
int paddingX = 12;
dc.SetFontStyle(dc.theme->uiFont);
+30 -38
View File
@@ -415,6 +415,9 @@ ClickableItem::ClickableItem(LayoutParams *layoutParams) : Clickable(layoutParam
void ClickableItem::Draw(UIContext &dc) {
Style style = dc.theme->itemStyle;
if (!IsEnabled()) {
style = dc.theme->itemDisabledStyle;
}
if (HasFocus()) {
style = dc.theme->itemFocusedStyle;
}
@@ -470,32 +473,13 @@ float Choice::CalculateTextScale(const UIContext &dc, float availWidth) const {
return 1.0f;
}
void Choice::HighlightChanged(bool highlighted){
highlighted_ = highlighted;
}
void Choice::Draw(UIContext &dc) {
if (!IsSticky()) {
ClickableItem::Draw(dc);
} else {
Style style = dc.theme->itemStyle;
if (highlighted_) {
style = dc.theme->itemHighlightedStyle;
}
if (down_) {
style = dc.theme->itemDownStyle;
}
if (HasFocus()) {
style = dc.theme->itemFocusedStyle;
}
DrawBG(dc, style);
}
Style style = dc.theme->itemStyle;
if (!IsEnabled()) {
style = dc.theme->itemDisabledStyle;
}
if (HasFocus()) style = dc.theme->itemFocusedStyle;
if (down_) style = dc.theme->itemDownStyle;
if (!IsEnabled()) style = dc.theme->itemDisabledStyle;
DrawBG(dc, style);
if (image_.isValid() && text_.empty()) {
dc.Draw()->DrawImageRotated(image_, bounds_.centerX(), bounds_.centerY(), imgScale_, imgRot_, style.fgColor, imgFlipH_);
@@ -510,7 +494,7 @@ void Choice::Draw(UIContext &dc) {
paddingX += image->w + 6;
availWidth -= image->w + 6;
// TODO: Use scale rotation and flip here as well (DrawImageRotated is always ALIGN_CENTER for now)
dc.Draw()->DrawImage(image_, bounds_.x + 6, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER);
dc.Draw()->DrawImage(image_, bounds_.x + 6, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
}
float scale = CalculateTextScale(dc, availWidth);
@@ -520,7 +504,8 @@ void Choice::Draw(UIContext &dc) {
dc.DrawTextRect(text_.c_str(), bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT);
} else {
if (rightIconImage_.isValid()) {
dc.Draw()->DrawImageRotated(rightIconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), rightIconScale_, rightIconRot_, style.fgColor, rightIconFlipH_);
uint32_t col = rightIconKeepColor_ ? 0xffffffff : style.fgColor; // Don't apply theme to gold icon
dc.Draw()->DrawImageRotated(rightIconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), rightIconScale_, rightIconRot_, col, rightIconFlipH_);
}
Bounds textBounds(bounds_.x + paddingX + textPadding_.left, bounds_.y, availWidth, bounds_.h);
dc.DrawTextRect(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT);
@@ -553,7 +538,7 @@ void InfoItem::Draw(UIContext &dc) {
UI::Style style = HasFocus() ? dc.theme->itemFocusedStyle : dc.theme->infoStyle;
if (choiceStyle_) {
style = HasFocus() ? dc.theme->buttonFocusedStyle : dc.theme->buttonStyle;
style = HasFocus() ? dc.theme->itemFocusedStyle : dc.theme->itemStyle;
}
@@ -702,8 +687,15 @@ EventReturn CheckBox::OnClicked(EventParams &e) {
void CheckBox::Draw(UIContext &dc) {
Style style = dc.theme->itemStyle;
if (!IsEnabled())
if (!IsEnabled()) {
style = dc.theme->itemDisabledStyle;
}
if (HasFocus()) {
style = dc.theme->itemFocusedStyle;
}
if (down_) {
style = dc.theme->itemDownStyle;
}
dc.SetFontStyle(dc.theme->uiFont);
ClickableItem::Draw(dc);
@@ -821,11 +813,11 @@ void Button::Click() {
}
void Button::Draw(UIContext &dc) {
Style style = dc.theme->buttonStyle;
Style style = dc.theme->itemStyle;
if (HasFocus()) style = dc.theme->buttonFocusedStyle;
if (down_) style = dc.theme->buttonDownStyle;
if (!IsEnabled()) style = dc.theme->buttonDisabledStyle;
if (HasFocus()) style = dc.theme->itemFocusedStyle;
if (down_) style = dc.theme->itemDownStyle;
if (!IsEnabled()) style = dc.theme->itemDisabledStyle;
// dc.Draw()->DrawImage4Grid(style.image, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y2(), style.bgColor);
DrawBG(dc, style);
@@ -840,13 +832,13 @@ void Button::Draw(UIContext &dc) {
dc.SetFontStyle(dc.theme->uiFont);
dc.SetFontScale(scale_, scale_);
if (imageID_.isValid() && (ignoreText_ || text_.empty())) {
dc.Draw()->DrawImage(imageID_, bounds_.centerX(), bounds_.centerY(), scale_, 0xFFFFFFFF, ALIGN_CENTER);
dc.Draw()->DrawImage(imageID_, bounds_.centerX(), bounds_.centerY(), scale_, style.fgColor, ALIGN_CENTER);
} else if (!text_.empty()) {
float textX = bounds_.centerX();
if (imageID_.isValid()) {
const AtlasImage *img = dc.Draw()->GetAtlas()->getImage(imageID_);
if (img) {
dc.Draw()->DrawImage(imageID_, bounds_.centerX() - tw / 2 - 5, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_CENTER);
dc.Draw()->DrawImage(imageID_, bounds_.centerX() - tw / 2 - 5, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER);
textX += img->w / 2.0f;
}
}
@@ -884,13 +876,13 @@ void RadioButton::Click() {
}
void RadioButton::Draw(UIContext &dc) {
Style style = dc.theme->buttonStyle;
Style style = dc.theme->itemStyle;
bool checked = *value_ == thisButtonValue_;
if (HasFocus()) style = dc.theme->buttonFocusedStyle;
if (down_) style = dc.theme->buttonDownStyle;
if (!IsEnabled()) style = dc.theme->buttonDisabledStyle;
if (HasFocus()) style = dc.theme->itemFocusedStyle;
if (down_) style = dc.theme->itemDownStyle;
if (!IsEnabled()) style = dc.theme->itemDisabledStyle;
DrawBG(dc, style);
+3 -10
View File
@@ -100,17 +100,10 @@ struct Theme {
ImageID whiteImage;
ImageID dropShadow4Grid;
Style buttonStyle;
Style buttonFocusedStyle;
Style buttonDownStyle;
Style buttonDisabledStyle;
Style buttonHighlightedStyle;
Style itemStyle;
Style itemDownStyle;
Style itemFocusedStyle;
Style itemDisabledStyle;
Style itemHighlightedStyle;
Style headerStyle;
Style infoStyle;
@@ -716,14 +709,14 @@ public:
: ClickableItem(layoutParams), image_(image), rightIconImage_(ImageID::invalid()), imgScale_(imgScale), imgRot_(imgRot), imgFlipH_(imgFlipH) {}
void Click() override;
virtual void HighlightChanged(bool highlighted);
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
void Draw(UIContext &dc) override;
std::string DescribeText() const override;
virtual void SetCentered(bool c) {
centered_ = c;
}
virtual void SetIcon(ImageID iconImage, float scale = 1.0f, float rot = 0.0f, bool flipH = false) {
virtual void SetIcon(ImageID iconImage, float scale = 1.0f, float rot = 0.0f, bool flipH = false, bool keepColor = true) {
rightIconKeepColor_ = keepColor;
rightIconScale_ = scale;
rightIconRot_ = rot;
rightIconFlipH_ = flipH;
@@ -742,9 +735,9 @@ protected:
float rightIconScale_;
float rightIconRot_;
bool rightIconFlipH_;
bool rightIconKeepColor_;
Padding textPadding_;
bool centered_ = false;
bool highlighted_ = false;
float imgScale_ = 1.0f;
float imgRot_ = 0.0f;
bool imgFlipH_ = false;
-6
View File
@@ -1505,12 +1505,6 @@ void ChoiceStrip::SetSelection(int sel, bool triggerClick) {
}
}
void ChoiceStrip::HighlightChoice(int choice) {
if (choice < (int)views_.size()) {
Choice(choice)->HighlightChanged(true);
}
}
void ChoiceStrip::EnableChoice(int choice, bool enabled) {
if (choice < (int)views_.size()) {
Choice(choice)->SetEnabled(enabled);
-1
View File
@@ -330,7 +330,6 @@ public:
int GetSelection() const { return selected_; }
void SetSelection(int sel, bool triggerClick);
void HighlightChoice(int choice);
void EnableChoice(int choice, bool enabled);
bool Key(const KeyInput &input) override;
+1 -28
View File
@@ -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),
};
+1 -29
View File
@@ -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;
+2
View File
@@ -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;
+1
View File
@@ -56,6 +56,7 @@ enum PSPDirectories {
DIRECTORY_MEMSTICK_ROOT,
DIRECTORY_EXDATA,
DIRECTORY_CUSTOM_SHADERS,
DIRECTORY_CUSTOM_THEMES,
};
class GraphicsContext;
+2 -2
View File
@@ -212,7 +212,7 @@ void ComboKeyScreen::CreateViews() {
vertLayout->Add(new CheckBox(show, co->T("Visible")));
Choice *icon = vertLayout->Add(new Choice(co->T("Icon")));
icon->SetIcon(ImageID(comboKeyImages[cfg->image].i), 1.0f, comboKeyImages[cfg->image].r*PI/180); // Set right icon on the choice
icon->SetIcon(ImageID(comboKeyImages[cfg->image].i), 1.0f, comboKeyImages[cfg->image].r*PI/180, false, false); // Set right icon on the choice
icon->OnClick.Add([=](UI::EventParams &e) {
auto iconScreen = new ButtonIconScreen(co->T("Icon"), &(cfg->image));
if (e.v)
@@ -223,7 +223,7 @@ void ComboKeyScreen::CreateViews() {
});
Choice *shape = vertLayout->Add(new Choice(co->T("Shape")));
shape->SetIcon(ImageID(comboKeyShapes[cfg->shape].l), 0.6f, comboKeyShapes[cfg->shape].r*PI/180, comboKeyShapes[cfg->shape].f); // Set right icon on the choice
shape->SetIcon(ImageID(comboKeyShapes[cfg->shape].l), 0.6f, comboKeyShapes[cfg->shape].r*PI/180, comboKeyShapes[cfg->shape].f, false); // Set right icon on the choice
shape->OnClick.Add([=](UI::EventParams &e) {
auto shape = new ButtonShapeScreen(co->T("Shape"), &(cfg->shape));
if (e.v)
+1 -1
View File
@@ -953,7 +953,7 @@ public:
void Draw(UIContext &dc) override {
uint32_t c = 0xFFFFFFFF;
if (HasFocus() || Selected())
c = dc.theme->buttonFocusedStyle.background.color;
c = dc.theme->itemFocusedStyle.background.color;
float scales[2]{};
if (bgImg_.isValid())
+11
View File
@@ -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<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0);
@@ -219,6 +221,7 @@ void GameSettingsScreen::CreateViews() {
auto dev = GetI18NCategory("Developer");
auto ri = GetI18NCategory("RemoteISO");
auto ps = GetI18NCategory("PostShaders");
auto th = GetI18NCategory("Themes");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
@@ -881,6 +884,14 @@ void GameSettingsScreen::CreateViews() {
if (backgroundChoice_ != nullptr) {
backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground);
}
PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, sy->T("Color Theme"), GetThemeInfoNames(), th->GetName(), 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()));
+7 -7
View File
@@ -401,7 +401,7 @@ void GameButton::Draw(UIContext &dc) {
if (gridStyle_ && g_Config.bShowIDOnGameIcon) {
dc.SetFontScale(0.5f*g_Config.fGameGridScale, 0.5f*g_Config.fGameGridScale);
dc.DrawText(ginfo->id_version.c_str(), x+5, y+1, 0xFF000000, ALIGN_TOPLEFT);
dc.DrawText(ginfo->id_version.c_str(), x+4, y, 0xFFffFFff, ALIGN_TOPLEFT);
dc.DrawText(ginfo->id_version.c_str(), x+4, y, dc.theme->infoStyle.fgColor, ALIGN_TOPLEFT);
dc.SetFontScale(1.0f, 1.0f);
}
if (overlayColor) {
@@ -441,11 +441,11 @@ private:
void DirButton::Draw(UIContext &dc) {
using namespace UI;
Style style = dc.theme->buttonStyle;
Style style = dc.theme->itemStyle;
if (HasFocus()) style = dc.theme->buttonFocusedStyle;
if (down_) style = dc.theme->buttonDownStyle;
if (!IsEnabled()) style = dc.theme->buttonDisabledStyle;
if (HasFocus()) style = dc.theme->itemFocusedStyle;
if (down_) style = dc.theme->itemDownStyle;
if (!IsEnabled()) style = dc.theme->itemDisabledStyle;
dc.FillRect(style.background, bounds_);
@@ -470,7 +470,7 @@ void DirButton::Draw(UIContext &dc) {
if (image == ImageID("I_FOLDER")) {
dc.DrawText(text.c_str(), bounds_.x + 5, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
} else {
dc.Draw()->DrawImage(image, bounds_.centerX(), bounds_.centerY(), gridStyle_ ? g_Config.fGameGridScale : 1.0, 0xFFFFFFFF, ALIGN_CENTER);
dc.Draw()->DrawImage(image, bounds_.centerX(), bounds_.centerY(), gridStyle_ ? g_Config.fGameGridScale : 1.0, style.fgColor, ALIGN_CENTER);
}
dc.PopScissor();
} else {
@@ -479,7 +479,7 @@ void DirButton::Draw(UIContext &dc) {
dc.PushScissor(bounds_);
scissor = true;
}
dc.Draw()->DrawImage(image, bounds_.x + 72, bounds_.centerY(), 0.88f*(gridStyle_ ? g_Config.fGameGridScale : 1.0), 0xFFFFFFFF, ALIGN_CENTER);
dc.Draw()->DrawImage(image, bounds_.x + 72, bounds_.centerY(), 0.88f*(gridStyle_ ? g_Config.fGameGridScale : 1.0), style.fgColor, ALIGN_CENTER);
dc.DrawText(text.c_str(), bounds_.x + 150, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
if (scissor) {
+3 -3
View File
@@ -767,11 +767,11 @@ void LogoScreen::render() {
// Manually formatting UTF-8 is fun. \xXX doesn't work everywhere.
snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T("created", "Created by"), 0xC3, 0xA5);
if (System_GetPropertyBool(SYSPROP_APP_GOLD)) {
dc.Draw()->DrawImage(ImageID("I_ICONGOLD"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER);
dc.Draw()->DrawImage(ImageID("I_ICONGOLD"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, 0xFFFFFFFF, ALIGN_CENTER);
} else {
dc.Draw()->DrawImage(ImageID("I_ICON"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER);
dc.Draw()->DrawImage(ImageID("I_ICON"), bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, 0xFFFFFFFF, ALIGN_CENTER);
}
dc.Draw()->DrawImage(ImageID("I_LOGO"), bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, textColor, ALIGN_CENTER);
dc.Draw()->DrawImage(ImageID("I_LOGO"), bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, 0xFFFFFFFF, ALIGN_CENTER);
//dc.Draw()->DrawTextShadow(UBUNTU48, "PPSSPP", bounds.w / 2, bounds.h / 2 - 30, textColor, ALIGN_CENTER);
dc.SetFontScale(1.0f, 1.0f);
dc.SetFontStyle(dc.theme->uiFont);
+3 -47
View File
@@ -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);
+207
View File
@@ -0,0 +1,207 @@
// 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 <algorithm>
#include "UI/Theme.h"
#include "Common/File/FileUtil.h"
#include "Common/File/VFS/VFS.h"
#include "Common/Data/Format/IniFile.h"
#include "Common/File/DirListing.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 = 0x55000000;
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<ThemeInfo> themeInfos;
static void LoadThemeInfo(const std::vector<Path> &directories) {
themeInfos.clear();
ThemeInfo def{};
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()) {
themeInfos.erase(beginErase, themeInfos.end());
}
themeInfos.push_back(info);
};
for (size_t d = 0; d < directories.size(); d++) {
std::vector<File::FileInfo> 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 &section = ini.Sections()[i];
ThemeInfo info;
section.Get("Name", &info.name, section.name().c_str());
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("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);
}
}
}
}
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.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<Path> directories;
directories.push_back(Path("themes")); // For VFS
directories.push_back(GetSysDirectory(DIRECTORY_CUSTOM_THEMES));
LoadThemeInfo(directories);
}
std::vector<std::string> GetThemeInfoNames() {
std::vector<std::string> names;
for (auto& i : themeInfos)
names.push_back(i.name);
return names;
}
+29
View File
@@ -0,0 +1,29 @@
#pragma once
// 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 <string>
#include <vector>
#include "Common/UI/Context.h"
void ReloadAllThemeInfo();
std::vector<std::string> GetThemeInfoNames();
void UpdateTheme();
UI::Theme *GetTheme();
+2
View File
@@ -67,6 +67,7 @@
<ClCompile Include="TouchControlLayoutScreen.cpp" />
<ClCompile Include="TouchControlVisibilityScreen.cpp" />
<ClCompile Include="InstallZipScreen.cpp" />
<ClCompile Include="Theme.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="BackgroundAudio.h" />
@@ -101,6 +102,7 @@
<ClInclude Include="TouchControlLayoutScreen.h" />
<ClInclude Include="TouchControlVisibilityScreen.h" />
<ClInclude Include="InstallZipScreen.h" />
<ClInclude Include="Theme.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ext\discord-rpc-build\discord-rpc.vcxproj">
+2
View File
@@ -396,6 +396,7 @@
<ClInclude Include="..\..\UI\GPUDriverTestScreen.h" />
<ClInclude Include="..\..\UI\HostTypes.h" />
<ClInclude Include="..\..\UI\InstallZipScreen.h" />
<ClInclude Include="..\..\UI\Theme.h" />
<ClInclude Include="..\..\UI\MainScreen.h" />
<ClInclude Include="..\..\UI\MemStickScreen.h" />
<ClInclude Include="..\..\UI\MiscScreens.h" />
@@ -431,6 +432,7 @@
<ClCompile Include="..\..\UI\GameSettingsScreen.cpp" />
<ClCompile Include="..\..\UI\GPUDriverTestScreen.cpp" />
<ClCompile Include="..\..\UI\InstallZipScreen.cpp" />
<ClCompile Include="..\..\UI\Theme.cpp" />
<ClCompile Include="..\..\UI\MainScreen.cpp" />
<ClCompile Include="..\..\UI\MemStickScreen.cpp" />
<ClCompile Include="..\..\UI\MiscScreens.cpp" />
+1
View File
@@ -2,6 +2,7 @@ mkdir assets > nul
xcopy ..\assets\flash0 assets\flash0\ /s /y <d.txt
xcopy ..\assets\lang assets\lang\ /s /y <d.txt
xcopy ..\assets\shaders assets\shaders\ /s /y <d.txt
xcopy ..\assets\themes assets\themes\ /s /y <d.txt
copy ..\assets\*.ini assets\
copy ..\assets\Roboto-Condensed.ttf assets\Roboto-Condensed.ttf
copy ..\assets\*.png assets\
+1
View File
@@ -2,6 +2,7 @@ mkdir -p assets
cp -r ../assets/flash0 assets/
cp -r ../assets/lang assets/
cp -r ../assets/shaders assets/
cp -r ../assets/themes assets/
cp -r ../assets/debugger assets/
cp ../assets/*.ini assets/
cp ../assets/Roboto-Condensed.ttf assets/Roboto-Condensed.ttf
+1
View File
@@ -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)
+4
View File
@@ -1211,6 +1211,10 @@ WARNING: Android battery save mode is on = WARNING: Android battery save mode is
WARNING: Battery save mode is on = WARNING: Battery save mode is on
Waves = Waves
YYYYMMDD = YYYYMMDD
Color Theme = Color Theme
[Themes]
Default = Default
[Upgrade]
Details = Details
+16
View File
@@ -0,0 +1,16 @@
[Default]
Name = Default
ItemStyleFg = 0xffffffff
ItemStyleBg = 0x55000000
ItemFocusedStyleFg = 0xffffffff
ItemFocusedStyleBg = 0xffedc24c
ItemDownStyleFg = 0xffffffff
ItemDownStyleBg = 0xffbd9939
ItemDisabledStyleFg = 0x80eeeeee
ItemDisabledStyleBg = 0x55000000
HeaderStyleFg = 0xffffffff
InfoStyleFg = 0xffffffff
InfoStyleBg = 0x00000000
PopupTitleStyleFg = 0xffe3be59
PopupStyleFg = 0xffffffff
PopupStyleBg = 0xff303030
+1
View File
@@ -74,6 +74,7 @@ Source: "README.md"; DestName: "README.txt"; DestDir: "{app}"; Flags: isreadme
Source: "notinstalled.txt"; DestName: "installed.txt"; DestDir: "{app}";
Source: "assets\*.*"; DestDir: "{app}\assets"
Source: "assets\shaders\*.*"; DestDir: "{app}\assets\shaders"
Source: "assets\themes\*.*"; DestDir: "{app}\assets\themes"
Source: "assets\debugger\*"; DestDir: "{app}\assets\debugger"; Flags: recursesubdirs
Source: "assets\lang\*.ini"; DestDir: "{app}\assets\lang"
Source: "assets\flash0\font\*.*"; DestDir: "{app}\assets\flash0\font"