From ce35f40f31c4b621f0cf241051593e1112f1bab9 Mon Sep 17 00:00:00 2001 From: fincs Date: Mon, 29 Jul 2019 17:36:59 +0200 Subject: [PATCH] Display "Applet Mode" indicator when running under an applet --- common/language.c | 12 +++++++++--- common/language.h | 1 + common/menu.c | 16 +++++++++++----- common/theme.c | 23 ++++++++++++++--------- common/theme.h | 1 + 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/common/language.c b/common/language.c index 9aaeb51..9d4de14 100644 --- a/common/language.c +++ b/common/language.c @@ -46,6 +46,12 @@ const char* const g_strings[StrId_Max][16] = STR_TW("加載中…"), }, + [StrId_AppletMode] = + { + STR_EN("● Applet Mode ●"), + STR_ES("● Modo Applet ●"), + }, + [StrId_Directory] = { STR_EN("Directory"), @@ -292,7 +298,7 @@ const char* const g_strings[StrId_Max][16] = STR_ZH("打开"), STR_TW("開啟"), }, - + [StrId_Actions_Back] = { STR_EN("Back"), @@ -336,13 +342,13 @@ const char* const g_strings[StrId_Max][16] = STR_EN("Star"), STR_ES("Agregar a favoritos"), }, - + [StrId_Actions_Unstar] = { STR_EN("Unstar"), STR_ES("Borrar de favoritos"), }, - + [StrId_ThemeMenu] = { STR_EN("Theme Menu"), diff --git a/common/language.h b/common/language.h index 1604f3d..95bbcd8 100644 --- a/common/language.h +++ b/common/language.h @@ -6,6 +6,7 @@ typedef enum { StrId_Loading = 0, + StrId_AppletMode, StrId_Directory, StrId_DefaultPublisher, StrId_IOError, diff --git a/common/menu.c b/common/menu.c index 1254cea..199ada3 100644 --- a/common/menu.c +++ b/common/menu.c @@ -104,7 +104,7 @@ void menuHandleAButton(void) { void menuHandleXButton(void) { menu_s* menu = menuGetCurrent(); - + if (menu->nEntries > 0 && hbmenu_state == HBMENU_DEFAULT) { int i; menuEntry_s* me; @@ -118,7 +118,7 @@ void launchApplyThemeTask(menuEntry_s* arg) { const char* themePath = arg->path; SetThemePathToConfig(themePath); themeStartup(themeGlobalPreset); - computeFrontGradient(themeCurrent.frontWaveColor, 280); + computeFrontGradient(themeCurrent.frontWaveColor, 280); } bool menuIsNetloaderActive(void) { @@ -471,13 +471,13 @@ void drawCharge() { bool validPower; validPower = powerGetDetails(&batteryCharge, &isCharging); - + if (validPower) { batteryCharge = (batteryCharge > 100) ? 100 : batteryCharge; sprintf(chargeString, "%d%%", batteryCharge); - + int tmpX = GetTextXCoordinate(interuiregular14, 1180 - 10, chargeString, 'r'); DrawText(interuiregular14, tmpX - 24 - 8, 0 + 47 + 10 + 21 + 4, themeCurrent.textColor, chargeString); @@ -604,6 +604,12 @@ void menuLoop(void) { drawImage(40, 20, 140, 60, themeCurrent.hbmenuLogoImage, IMAGE_MODE_RGBA32); DrawText(interuiregular14, 180, 46 + 18, themeCurrent.textColor, VERSION); + #ifdef __SWITCH__ + AppletType at = appletGetAppletType(); + if (at != AppletType_Application && at != AppletType_SystemApplication) { + DrawText(interuimedium30, 640-32, 46 + 18, themeCurrent.attentionTextColor, textGetString(StrId_AppletMode)); + } + #endif #ifdef PERF_LOG_DRAW//Seperate from the PERF_LOG define since this might affect perf. extern u64 g_tickdiff_frame; @@ -699,7 +705,7 @@ void menuLoop(void) { //DrawText(interuiregular18, getX, 30 + 26 + 32 + 10, themeCurrent.textColor, textGetString(StrId_ThemeMenu)); //DrawText(fontscale7, getX - 40, 30 + 26 + 32 + 10, themeCurrent.textColor, themeCurrent.buttonMText); } - + if(active_entry != NULL) { if (active_entry->type == ENTRY_TYPE_THEME) { DrawText(fontscale7, 1280 - 126 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, themeCurrent.buttonAText); diff --git a/common/theme.c b/common/theme.c index 5cf65a0..a67069f 100644 --- a/common/theme.c +++ b/common/theme.c @@ -12,8 +12,9 @@ bool colorFromSetting(config_setting_t *rgba, color_t *col) { void themeStartup(ThemePreset preset) { themeGlobalPreset = preset; - theme_t themeLight = (theme_t) { + theme_t themeLight = (theme_t) { .textColor = MakeColor(0, 0, 0, 255), + .attentionTextColor = MakeColor(255, 0, 0, 255), .frontWaveColor = MakeColor(100, 212, 250, 255), .middleWaveColor = MakeColor(100, 153, 255, 255), .backWaveColor = MakeColor(154, 171, 255, 255), @@ -34,9 +35,10 @@ void themeStartup(ThemePreset preset) { .labelStarOffText = "\u2606", .hbmenuLogoImage = assetsGetDataBuffer(AssetId_hbmenu_logo_light), }; - - theme_t themeDark = (theme_t) { + + theme_t themeDark = (theme_t) { .textColor = MakeColor(255, 255, 255, 255), + .attentionTextColor = MakeColor(255, 0, 0, 255), .frontWaveColor = MakeColor(96, 204, 204, 255), .middleWaveColor = MakeColor(66, 154, 159, 255), .backWaveColor = MakeColor(73, 103, 169, 255), @@ -65,7 +67,7 @@ void themeStartup(ThemePreset preset) { config_t cfg = {0}; config_init(&cfg); config_setting_t *theme = NULL; - color_t text, frontWave, middleWave, backWave, background, highlight, separator, borderColor, borderTextColor, progressBarColor; + color_t text, attentionText, frontWave, middleWave, backWave, background, highlight, separator, borderColor, borderTextColor, progressBarColor; int waveBlending; const char *AText, *BText, *XText, *YText, *PText, *MText, *starOnText, *starOffText; bool good_cfg = false; @@ -92,6 +94,8 @@ void themeStartup(ThemePreset preset) { if (theme != NULL) { if (!colorFromSetting(config_setting_lookup(theme, "textColor"), &text)) text = themeDefault->textColor; + if (!colorFromSetting(config_setting_lookup(theme, "attentionTextColor"), &attentionText)) + attentionText = themeDefault->attentionTextColor; if (!colorFromSetting(config_setting_lookup(theme, "frontWaveColor"), &frontWave)) frontWave = themeDefault->frontWaveColor; if (!colorFromSetting(config_setting_lookup(theme, "middleWaveColor"), &middleWave)) @@ -130,6 +134,7 @@ void themeStartup(ThemePreset preset) { starOffText = themeDefault->labelStarOffText; themeCurrent = (theme_t) { .textColor = text, + .attentionTextColor = attentionText, .frontWaveColor = frontWave, .middleWaveColor = middleWave, .backWaveColor = backWave, @@ -169,7 +174,7 @@ void GetThemePathFromConfig(char* themePath, size_t size) { snprintf(tmp_path, sizeof(tmp_path)-1, "%s/config/nx-hbmenu/settings.cfg", menuGetRootBasePath()); snprintf(tmp_path_theme, sizeof(tmp_path_theme)-1, "%s/config/nx-hbmenu/themes/", menuGetRootBasePath()); bool good_cfg = config_read_file(&cfg, tmp_path); - + if(good_cfg) { settings = config_lookup(&cfg, "settings"); if(settings != NULL) { @@ -187,7 +192,7 @@ void SetThemePathToConfig(const char* themePath) { char settingPath[PATH_MAX] = {0}; config_setting_t *root = NULL, - *group = NULL, + *group = NULL, *settings = NULL; themePath = getSlash(themePath); @@ -199,7 +204,7 @@ void SetThemePathToConfig(const char* themePath) { snprintf(settingPath, sizeof(settingPath)-1, "%s/config/nx-hbmenu/settings.cfg", menuGetRootBasePath()); bool good_cfg = config_read_file(&cfg, settingPath); - + if(good_cfg) { group = config_lookup(&cfg, "settings"); if(group != NULL) @@ -210,9 +215,9 @@ void SetThemePathToConfig(const char* themePath) { root = config_root_setting(&cfg); if(root != NULL) group = config_setting_add(root, "settings", CONFIG_TYPE_GROUP); - if(group != NULL) + if(group != NULL) settings = config_setting_add(group, "themePath", CONFIG_TYPE_STRING); - if(settings != NULL) + if(settings != NULL) config_setting_set_string(settings, themePath); } diff --git a/common/theme.h b/common/theme.h index 9ccecd6..2cc48b0 100644 --- a/common/theme.h +++ b/common/theme.h @@ -6,6 +6,7 @@ typedef struct { color_t textColor; + color_t attentionTextColor; color_t frontWaveColor; color_t middleWaveColor; color_t backWaveColor;