Implemented hbmenu Theme Switcher! Final changes will now be cosmetic
This commit is contained in:
parent
8909142fb4
commit
ed5c670419
@ -78,6 +78,15 @@ build_pc/hbmenu_logo_dark.bin.o : data/hbmenu_logo_dark.bin
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
build_pc/hbmenu_logo_light.bin.o : data/theme_icon_light.bin
|
||||
mkdir -p $(dir $@)
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
build_pc/hbmenu_logo_dark.bin.o : data/theme_icon_dark.bin
|
||||
mkdir -p $(dir $@)
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
|
||||
clean:
|
||||
|
@ -72,7 +72,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_JP("自作アプリ"),
|
||||
STR_PT("Aplicação Homebrew"),
|
||||
STR_NL("Homebrew toepassing"),
|
||||
STR_KO("Homebrew 애플리케이션"),
|
||||
STR_KO("홈브류 애플리케이션"),
|
||||
STR_RU("приложение хомебреw"),
|
||||
STR_ZH("自制应用程序"),
|
||||
STR_TW("自製程式"),
|
||||
@ -104,7 +104,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_JP("入出力エラー"),
|
||||
STR_PT("Erro de E/S"),
|
||||
STR_NL("I/O Fout"),
|
||||
STR_KO("읽기/쓰기 오류"),
|
||||
STR_KO("입출력 오류"),
|
||||
STR_RU("I/O-ошибка"),
|
||||
STR_ZH("读写出错"),
|
||||
STR_TW("讀寫錯誤"),
|
||||
@ -120,7 +120,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_JP("ファイルを開くことができませんでした:\n%s"),
|
||||
STR_PT("Não foi possível abrir o ficheiro:\n%s"),
|
||||
STR_NL("Kan bestand niet openen:\n%s"),
|
||||
STR_KO("다음 파일을 열지 못했습니다:\n%s"),
|
||||
STR_KO("파일을 열 수 없습니다:\n%s"),
|
||||
STR_RU("Не могу открыть файл:\n%s"),
|
||||
STR_ZH("无法打开文件:\n%s"),
|
||||
STR_TW("開啓檔案失敗:\n%s"),
|
||||
@ -190,8 +190,8 @@ const char* const g_strings[StrId_Max][16] =
|
||||
"en de toepassingen bevat."
|
||||
),
|
||||
STR_KO(
|
||||
"SD 카드에 애플리케이션이 없습니다.\n"
|
||||
"SD 카드의 루트에 /switch 폴더가 있고\n"
|
||||
"SD 카드에서 애플리케이션을 찾을 수 없습니다.\n"
|
||||
"SD 카드 최상위에 /switch 폴더가 있고\n"
|
||||
"애플리케이션을 포함하는지 확인해 주십시오."
|
||||
),
|
||||
STR_RU(
|
||||
@ -215,8 +215,9 @@ const char* const g_strings[StrId_Max][16] =
|
||||
{
|
||||
STR_EN("The last application returned an error:"),
|
||||
STR_ES("La última aplicación devolvió un error:"),
|
||||
STR_FR("La dernière application a retourné une erreur:"),
|
||||
STR_JP("直前に実行したアプリでエラーが発生しました:"),
|
||||
STR_KO("최근 애플리케이션에서 다음 오류가 발생했습니다:"),
|
||||
STR_KO("최근 애플리케이션에서 오류가 발생했습니다:"),
|
||||
STR_TW("程式執行時發生錯誤:"),
|
||||
},
|
||||
|
||||
@ -308,6 +309,14 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_KO("확인"),
|
||||
STR_TW("確認"),
|
||||
},
|
||||
[StrId_Actions_Apply] =
|
||||
{
|
||||
STR_EN("Apply"),
|
||||
STR_ES("Aplicar"),
|
||||
STR_JP("適用"),
|
||||
STR_KO("대다"),
|
||||
STR_TW("應用"),
|
||||
},
|
||||
|
||||
/*[StrId_Reboot] =
|
||||
{
|
||||
@ -361,7 +370,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
" \xEE\x80\x81 Annuleren"
|
||||
),
|
||||
STR_KO(
|
||||
"\xEE\x81\xB3홈 으로 돌아갈 수 없습니다.\n"
|
||||
"\xEE\x81\xB3HOME 으로 돌아갈 수 없습니다.\n"
|
||||
"콘솔을 재부팅할 것 입니다.\n\n"
|
||||
" \xEE\x80\x80 재부팅\n"
|
||||
" \xEE\x80\x81 취소"
|
||||
@ -472,7 +481,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_JP("タイトルセレクタ"),
|
||||
STR_PT("Selector de Títulos"),
|
||||
STR_NL("Titel selector"),
|
||||
STR_KO("제목 선택기"),
|
||||
STR_KO("타이틀 선택기"),
|
||||
STR_RU("Селектор заголовков"),
|
||||
STR_ZH("应用启动器"),
|
||||
STR_TW("自製程式啓動器"),
|
||||
@ -491,7 +500,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_JP("タイトルメタデータを読み取ることができませんでした。\n%08lX%08lX@%d"),
|
||||
STR_PT("Erro a ler os metadados do título.\n%08lX%08lX@%d"),
|
||||
STR_NL("Fout bij het lezen van titel metadata.\n%08lX%08lX@%d"),
|
||||
STR_KO("제목 메타데이터를 읽는데 실패하였습니다.\n%08lX%08lX@%d"),
|
||||
STR_KO("타이틀 메타데이터를 읽는데 실패하였습니다.\n%08lX%08lX@%d"),
|
||||
STR_RU("Ошибка чтения метаданных заголовка\n.%08lX%08lX@%d"),
|
||||
STR_ZH("读取软件相关信息时发生错误:\n%08lX%08lX@%d"),
|
||||
STR_TW("讀取軟體相關數據時發生錯誤:\n%08lX%08lX@%d"),
|
||||
@ -507,7 +516,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_JP("タイトルが見つかりませんでした。"),
|
||||
STR_PT("Nenhum título foi encontrado."),
|
||||
STR_NL("Geen titels gevonden."),
|
||||
STR_KO("제목을 감지하지 못하였습니다."),
|
||||
STR_KO("타이틀을 찾을 수 없습니다."),
|
||||
STR_RU("Заголовки не обнаружены"),
|
||||
STR_ZH("主机内找不到任何软件。"),
|
||||
STR_TW("主機内找不到任何軟體。"),
|
||||
@ -556,7 +565,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
" \xEE\x80\x81 Annuleren"
|
||||
),
|
||||
STR_KO(
|
||||
"대상 제목을 선택해 주십시오.\n\n"
|
||||
"대상 타이틀을 선택해 주십시오.\n\n"
|
||||
" \xEE\x80\x80 선택\n"
|
||||
" \xEE\x80\x81 취소"
|
||||
),
|
||||
@ -620,7 +629,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
"Gebruik een andere exploit."
|
||||
),
|
||||
STR_KO(
|
||||
"이 Homebrew 익스플로잇은 해당 제목에서 애플리케이션을\n"
|
||||
"이 홈브류 익스플로잇은 해당 타이틀에서 애플리케이션을\n"
|
||||
"실행하는 것을 지원하지 않습니다.\n"
|
||||
"다른 익스플로잇을 사용해 주십시오."
|
||||
),
|
||||
@ -677,7 +686,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
),
|
||||
STR_KO(
|
||||
"해당 애플리케이션은 시스템에 설치되지 않은\n"
|
||||
"제목을 요구합니다."
|
||||
"타이틀을 요구합니다."
|
||||
),
|
||||
STR_RU(
|
||||
"Для приложения требуется зависимость,\n"
|
||||
@ -735,7 +744,7 @@ const char* const g_strings[StrId_Max][16] =
|
||||
STR_JP("エラーが発生しました。\n技術的な詳細:[%s:%d]"),
|
||||
STR_PT("Ocorreu um erro.\nDetalhes técnicos: [%s:%d]"),
|
||||
STR_NL("Er is een fout opgetreden\nTechnische details: [%s:%d]"),
|
||||
STR_KO("오류가 발생했습니다.\n기술적 상세: [%s:%d]"),
|
||||
STR_KO("오류가 발생했습니다.\n기술적인 세부사항: [%s:%d]"),
|
||||
STR_RU("Произошла ошибка.\nТехнические подробности: [%s:%d]"),
|
||||
STR_ZH("发生错误。\n详细错误信息:[%s:%d]"),
|
||||
STR_TW("發生錯誤。\n詳細錯誤資訊:[%s:%d]"),
|
||||
@ -744,9 +753,10 @@ const char* const g_strings[StrId_Max][16] =
|
||||
[StrId_NetLoaderOffline] =
|
||||
{
|
||||
STR_EN("Offline, waiting for network…\n\n\n \xEE\x80\x81 Cancel"),
|
||||
STR_FR("Hors-ligne, en attente d'une connection...\n\n\n \xEE\x80\x81 Annuler"),
|
||||
STR_IT("Disconnesso, in attesa della connessione…\n\n\n \xEE\x80\x81 Annullare"),
|
||||
STR_JP("オフラインです。ネットワーク接続を待っています…\n\n\n \xEE\x80\x81 キャンセル"),
|
||||
STR_KO("오프라인임, 네트워크 대기중…\n\n\n \xEE\x80\x81 취소")
|
||||
STR_KO("연결 끊김, 네트워크 기다리는 중…\n\n\n \xEE\x80\x81 취소")
|
||||
STR_ZH("无法连接网络,等待网络连接…\n\n\n \xEE\x80\x81 取消"),
|
||||
STR_TW("當前離線,等待網路連線…\n\n\n \xEE\x80\x81 取消"),
|
||||
},
|
||||
|
@ -21,6 +21,7 @@ typedef enum
|
||||
StrId_Actions_Launch,
|
||||
StrId_Actions_Open,
|
||||
StrId_Actions_Back,
|
||||
StrId_Actions_Apply,
|
||||
|
||||
StrId_MsgBox_OK,
|
||||
|
||||
|
@ -182,7 +182,7 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
|
||||
|
||||
if (me->type == ENTRY_TYPE_FILE)
|
||||
{
|
||||
strcpy(me->name, name);
|
||||
//strcpy(me->name, name);//This is already done before both if statements
|
||||
strcpy(me->author, textGetString(StrId_DefaultPublisher));
|
||||
strcpy(me->version, "1.0.0");
|
||||
|
||||
@ -293,6 +293,13 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
|
||||
/*if (shortcut)
|
||||
shortcutFree(&sc);*/
|
||||
}
|
||||
if (me->type == ENTRY_TYPE_THEME){
|
||||
|
||||
//Todo load in the data about the theme?
|
||||
//Add a theme name property to each one?
|
||||
//Ability to load the theme as you hover over?
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -150,3 +150,52 @@ int menuScan(const char* target) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int themeMenuScan(const char* target) {
|
||||
menuClear();
|
||||
if (chdir(target) < 0) return 1;
|
||||
if (getcwd(s_menu[!s_curMenu].dirname, PATH_MAX+1) == NULL)
|
||||
return 1;
|
||||
DIR* dir;
|
||||
struct dirent* dp;
|
||||
char tmp_path[PATH_MAX+1];
|
||||
dir = opendir(s_menu[!s_curMenu].dirname);
|
||||
if (!dir) return 2;
|
||||
|
||||
while ((dp = readdir(dir)))
|
||||
{
|
||||
menuEntry_s* me = NULL;
|
||||
|
||||
bool shortcut = false;
|
||||
if (dp->d_name[0]=='.')
|
||||
continue;
|
||||
|
||||
memset(tmp_path, 0, sizeof(tmp_path));
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s/%s", s_menu[!s_curMenu].dirname, dp->d_name);
|
||||
|
||||
const char* ext = getExtension(dp->d_name);
|
||||
char* name = removeExtension(dp->d_name);
|
||||
replaceCharacter(name,'_',' ');
|
||||
if(strcmp(dp->d_name,"theme.cfg")==0)//This theme is already the currently applied theme, dont load it
|
||||
continue;
|
||||
if (strcasecmp(ext, ".cfg")==0)
|
||||
me = menuCreateEntry(ENTRY_TYPE_THEME);
|
||||
|
||||
if (!me)
|
||||
continue;
|
||||
|
||||
strncpy(me->path, tmp_path, sizeof(me->path)-5);//-(1 + 4 for the file extension size)
|
||||
me->path[sizeof(me->path)-1] = 0;
|
||||
if (menuEntryLoad(me,(const char*)name, shortcut))
|
||||
menuAddEntry(me);
|
||||
else
|
||||
menuDeleteEntry(me);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
menuSort();
|
||||
// Swap the menu and clear the previous menu
|
||||
s_curMenu = !s_curMenu;
|
||||
menuClear();
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "invalid_icon_bin.h"
|
||||
#include "folder_icon_bin.h"
|
||||
#include "theme_icon_dark_bin.h"
|
||||
#include "theme_icon_light_bin.h"
|
||||
|
||||
char rootPath[PATH_MAX+8];
|
||||
|
||||
@ -17,6 +19,8 @@ void launchMenuEntryTask(menuEntry_s* arg)
|
||||
if (me->type == ENTRY_TYPE_FOLDER)
|
||||
menuScan(me->path);
|
||||
//changeDirTask(me->path);
|
||||
else if(me->type == ENTRY_TYPE_THEME)
|
||||
launchApplyThemeTask(me);
|
||||
else
|
||||
launchMenuEntry(me);
|
||||
}
|
||||
@ -27,6 +31,7 @@ static enum
|
||||
HBMENU_NETLOADER_ACTIVE,
|
||||
HBMENU_NETLOADER_ERROR,
|
||||
HBMENU_NETLOADER_SUCCESS,
|
||||
HBMENU_THEME_MENU,
|
||||
} hbmenu_state = HBMENU_DEFAULT;
|
||||
|
||||
void launchMenuNetloaderTask() {
|
||||
@ -39,11 +44,40 @@ void launchMenuBackTask()
|
||||
if(hbmenu_state == HBMENU_NETLOADER_ACTIVE) {
|
||||
netloader_deactivate();
|
||||
hbmenu_state = HBMENU_DEFAULT;
|
||||
} else {
|
||||
}else if(hbmenu_state == HBMENU_THEME_MENU){
|
||||
hbmenu_state = HBMENU_DEFAULT;
|
||||
menuScan(rootPath);
|
||||
}
|
||||
else {
|
||||
menuScan("..");
|
||||
}
|
||||
|
||||
}
|
||||
bool appliedTheme=false;
|
||||
void launchApplyThemeTask(menuEntry_s* arg){
|
||||
if(appliedTheme){
|
||||
menuCreateMsgBox(780, 300, "A new theme was already applied...\nYou must restart hbmenu before applying a different one");
|
||||
return;
|
||||
}
|
||||
config_t cfg = {0};
|
||||
config_init(&cfg);
|
||||
if(!config_read_file(&cfg, arg->path)){
|
||||
menuCreateMsgBox(780, 300, "Something went wrong, and the theme could not be loaded!");
|
||||
return;
|
||||
}
|
||||
char tmp_path[PATH_MAX] = {0};
|
||||
#ifdef __SWITCH__
|
||||
tmp_path[0] = '/';
|
||||
#endif
|
||||
|
||||
strncat(tmp_path, "config/nx-hbmenu/themes/theme.cfg", sizeof(tmp_path)-2);
|
||||
if(!config_write_file(&cfg, tmp_path)){
|
||||
menuCreateMsgBox(780, 300, "Something went wrong, and the theme could not be applied!");
|
||||
return;
|
||||
}
|
||||
appliedTheme=true;
|
||||
menuCreateMsgBox(780, 300, "Theme Applied! Restart hbmenu to see the changes");
|
||||
}
|
||||
|
||||
//Draws an RGB888 or RGBA8888 image.
|
||||
static void drawImage(int x, int y, int width, int height, const uint8_t *image, ImageMode mode) {
|
||||
@ -72,6 +106,7 @@ static void drawImage(int x, int y, int width, int height, const uint8_t *image,
|
||||
|
||||
uint8_t *folder_icon_small;
|
||||
uint8_t *invalid_icon_small;
|
||||
uint8_t *theme_icon_small;
|
||||
|
||||
static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
|
||||
int x, y;
|
||||
@ -178,6 +213,12 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
|
||||
smallimg = folder_icon_small;
|
||||
largeimg = folder_icon_bin;
|
||||
}
|
||||
else if (me->type == ENTRY_TYPE_THEME){
|
||||
smallimg = theme_icon_small;
|
||||
if(globalPreset == THEME_PRESET_DARK)
|
||||
largeimg = theme_icon_dark_bin;
|
||||
else largeimg = theme_icon_light_bin;
|
||||
}
|
||||
else {
|
||||
smallimg = invalid_icon_small;
|
||||
largeimg = invalid_icon_bin;
|
||||
@ -271,6 +312,23 @@ void menuStartup() {
|
||||
//menuCreateMsgBox(780, 300, "This is a test");
|
||||
}
|
||||
|
||||
void themeMenuStartup() {
|
||||
if(hbmenu_state==HBMENU_THEME_MENU) return;
|
||||
hbmenu_state = HBMENU_THEME_MENU;
|
||||
char tmp_path[PATH_MAX];
|
||||
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s%s%s%s%s%s",DIRECTORY_SEPARATOR, "config", DIRECTORY_SEPARATOR, "nx-hbmenu" , DIRECTORY_SEPARATOR, "themes");
|
||||
|
||||
themeMenuScan(tmp_path);
|
||||
if(globalPreset == THEME_PRESET_DARK)
|
||||
theme_icon_small = downscaleImg(theme_icon_dark_bin, 256, 256, 140, 140, IMAGE_MODE_RGB24);
|
||||
else
|
||||
theme_icon_small = downscaleImg(theme_icon_light_bin, 256, 256, 140, 140, IMAGE_MODE_RGB24);
|
||||
|
||||
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
||||
//menuCreateMsgBox(780, 300, "This is a test");
|
||||
}
|
||||
|
||||
color_t waveBlendAdd(color_t a, color_t b, float alpha) {
|
||||
return MakeColor(a.r+(b.r*alpha), a.g+b.g*alpha, a.b + b.b*alpha, 255);
|
||||
}
|
||||
@ -441,12 +499,18 @@ void menuLoop() {
|
||||
}
|
||||
|
||||
if(active_entry != NULL) {
|
||||
if (active_entry->type != ENTRY_TYPE_FOLDER) {
|
||||
if(active_entry->type == ENTRY_TYPE_THEME){
|
||||
DrawText(fontscale7, 1280 - 126 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, themeCurrent.buttonAText);
|
||||
DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, textGetString(StrId_Actions_Apply));
|
||||
}
|
||||
else if (active_entry->type != ENTRY_TYPE_FOLDER) {
|
||||
//TODO: add minus button
|
||||
//drawImage(1280 - 126 - 30 - 32, 720 - 48, 32, 32, themeCurrent.buttonAImage, IMAGE_MODE_RGBA32);
|
||||
DrawText(fontscale7, 1280 - 126 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, themeCurrent.buttonAText);//Display the 'A' button from SharedFont.
|
||||
DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, textGetString(StrId_Actions_Launch));
|
||||
}
|
||||
else {
|
||||
else{
|
||||
//TODO: add minus button
|
||||
//drawImage(1280 - 126 - 30 - 32, 720 - 48, 32, 32, themeCurrent.buttonAImage, IMAGE_MODE_RGBA32);
|
||||
DrawText(fontscale7, 1280 - 126 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, themeCurrent.buttonAText);
|
||||
DrawText(interuiregular18, 1280 - 90 - 30 - 32, 720 - 47 + 24, themeCurrent.textColor, textGetString(StrId_Actions_Open));
|
||||
|
@ -19,6 +19,7 @@ typedef enum
|
||||
{
|
||||
ENTRY_TYPE_FILE,
|
||||
ENTRY_TYPE_FOLDER,
|
||||
ENTRY_TYPE_THEME,
|
||||
} MenuEntryType;
|
||||
|
||||
typedef struct menuEntry_s_tag menuEntry_s;
|
||||
@ -86,6 +87,7 @@ menu_s* menuGetCurrent(void);
|
||||
int menuScan(const char* target);
|
||||
|
||||
void launchMenuEntryTask(menuEntry_s* arg);
|
||||
void launchApplyThemeTask(menuEntry_s* arg);
|
||||
void launchMenuBackTask();
|
||||
void launchMenuNetloaderTask();
|
||||
char *menuGetRootPath();
|
||||
@ -109,3 +111,19 @@ static inline char* getSlash(const char* str)
|
||||
return (char*)p;
|
||||
}
|
||||
|
||||
static inline char* removeExtension(const char* str){
|
||||
const char* p;
|
||||
char* copy = calloc(strlen(str)+1,sizeof(char));
|
||||
char *copyHead = copy;
|
||||
for (p = str; p <= (str+strlen(str)) && *p != '.'; p++){
|
||||
*copy = *p;
|
||||
copy++;
|
||||
}
|
||||
return (char*)copyHead;
|
||||
}
|
||||
|
||||
static inline void replaceCharacter(char* str, char orig, char repl){
|
||||
char* p;
|
||||
for (p = str; p <= (str+strlen(str)); p++) if(*p==orig) *p=repl;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,20 @@ bool colorFromSetting(config_setting_t *rgba, color_t *col) {
|
||||
}
|
||||
|
||||
void themeStartup(ThemePreset preset) {
|
||||
globalPreset = preset;
|
||||
char* buttonAText = calloc(7,sizeof(char));
|
||||
char* buttonBText = calloc(7,sizeof(char));
|
||||
switch (preset) {
|
||||
case THEME_PRESET_LIGHT:
|
||||
default:
|
||||
strcpy(buttonAText, "\uE0E0");
|
||||
strcpy(buttonBText, "\uE0E1");
|
||||
break;
|
||||
case THEME_PRESET_DARK:
|
||||
strcpy(buttonAText, "\uE0A0");
|
||||
strcpy(buttonBText, "\uE0A1");
|
||||
break;
|
||||
}
|
||||
theme_t themeLight = (theme_t) {
|
||||
.textColor = MakeColor(0, 0, 0, 255),
|
||||
.frontWaveColor = MakeColor(100, 212, 250, 255),
|
||||
@ -23,8 +37,8 @@ void themeStartup(ThemePreset preset) {
|
||||
.highlightColor = MakeColor(91, 237, 224, 255),
|
||||
.separatorColor = MakeColor(219, 218, 219, 255),
|
||||
.enableWaveBlending = 0,
|
||||
.buttonAText = "\uE0E0",
|
||||
.buttonBText = "\uE0E1",
|
||||
.buttonAText = buttonAText,
|
||||
.buttonBText = buttonBText,
|
||||
//.buttonAImage = button_a_light_bin,
|
||||
//.buttonBImage = button_b_light_bin,
|
||||
.hbmenuLogoImage = hbmenu_logo_light_bin
|
||||
@ -39,8 +53,8 @@ void themeStartup(ThemePreset preset) {
|
||||
.highlightColor = MakeColor(91, 237, 224, 255),
|
||||
.separatorColor = MakeColor(219, 218, 219, 255),
|
||||
.enableWaveBlending = 0,
|
||||
.buttonAText = "\uE0A0",
|
||||
.buttonBText = "\uE0A1",
|
||||
.buttonAText = buttonAText,
|
||||
.buttonBText = buttonBText,
|
||||
//.buttonAImage = button_a_dark_bin,
|
||||
//.buttonBImage = button_b_dark_bin,
|
||||
.hbmenuLogoImage = hbmenu_logo_dark_bin
|
||||
@ -62,19 +76,31 @@ void themeStartup(ThemePreset preset) {
|
||||
int waveBlending;
|
||||
const char *AText, *BText;
|
||||
bool good_cfg = config_read_file(&cfg, tmp_path);
|
||||
|
||||
struct stat buffer;
|
||||
if(!good_cfg){
|
||||
config_t tmp = {0};
|
||||
cfg = tmp;//clear the config
|
||||
}
|
||||
switch (preset) {
|
||||
case THEME_PRESET_LIGHT:
|
||||
default:
|
||||
themeDefault = &themeLight;
|
||||
if (good_cfg)
|
||||
theme = config_lookup(&cfg, "lightTheme");
|
||||
else{
|
||||
if(stat(tmp_path,&buffer)==0);
|
||||
//TODO: theme.cfg file does not exist or is corrupted/misconfigured! overwrite with default theme.
|
||||
}
|
||||
break;
|
||||
|
||||
case THEME_PRESET_DARK:
|
||||
themeDefault = &themeDark;
|
||||
if (good_cfg)
|
||||
theme = config_lookup(&cfg, "darkTheme");
|
||||
else{
|
||||
if(stat(tmp_path,&buffer)==0);
|
||||
//TODO: theme.cfg file does not exist or is corrupted/misconfigured! overwrite with default theme.
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -32,3 +32,5 @@ bool colorFromSetting(config_setting_t *rgba, color_t *col);
|
||||
void themeStartup(ThemePreset preset);
|
||||
|
||||
theme_t themeCurrent;
|
||||
|
||||
ThemePreset globalPreset;
|
||||
|
1
data/theme_icon_dark.bin
Normal file
1
data/theme_icon_dark.bin
Normal file
File diff suppressed because one or more lines are too long
1
data/theme_icon_light.bin
Normal file
1
data/theme_icon_light.bin
Normal file
File diff suppressed because one or more lines are too long
1
data/unused/theme_icon_dark.bin(old)
Normal file
1
data/unused/theme_icon_dark.bin(old)
Normal file
File diff suppressed because one or more lines are too long
1
data/unused/theme_icon_light.bin(old)
Normal file
1
data/unused/theme_icon_light.bin(old)
Normal file
File diff suppressed because one or more lines are too long
3
folder_icon_bin.h
Normal file
3
folder_icon_bin.h
Normal file
@ -0,0 +1,3 @@
|
||||
extern const u8 folder_icon_bin_end[];
|
||||
extern const u8 folder_icon_bin[];
|
||||
extern const u32 folder_icon_bin_size;
|
3
hbmenu_logo_bin.h
Normal file
3
hbmenu_logo_bin.h
Normal file
@ -0,0 +1,3 @@
|
||||
extern const u8 hbmenu_logo_light_bin_end[];
|
||||
extern const u8 hbmenu_logo_light_bin[];
|
||||
extern const u32 hbmenu_logo_light_bin_size;
|
3
invalid_icon_bin.h
Normal file
3
invalid_icon_bin.h
Normal file
@ -0,0 +1,3 @@
|
||||
extern const u8 invalid_icon_bin_end[];
|
||||
extern const u8 invalid_icon_bin[];
|
||||
extern const u32 invalid_icon_bin_size;
|
@ -18,6 +18,8 @@ void audio_initialize(void);
|
||||
void audio_exit(void);
|
||||
#endif
|
||||
|
||||
char* getSavedTheme();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Result lastret=0;
|
||||
@ -33,6 +35,7 @@ int main(int argc, char **argv)
|
||||
appletSetScreenShotPermission(1);
|
||||
|
||||
ColorSetId theme;
|
||||
|
||||
rc = setsysInitialize();
|
||||
if (R_FAILED(rc)) fatalSimple(-5);
|
||||
|
||||
@ -40,7 +43,7 @@ int main(int argc, char **argv)
|
||||
|
||||
rc = plInitialize();
|
||||
if (R_FAILED(rc)) fatalSimple(-6);
|
||||
|
||||
//char* savedThemeName = getSavedTheme();
|
||||
themeStartup((ThemePreset)theme);
|
||||
textInit();
|
||||
menuStartup();
|
||||
@ -135,6 +138,9 @@ bool menuUpdate(void) {
|
||||
{
|
||||
launchMenuBackTask();
|
||||
}
|
||||
else if(down & KEY_MINUS){
|
||||
themeMenuStartup();
|
||||
}
|
||||
else if (down & KEY_PLUS)
|
||||
{
|
||||
exitflag = 1;
|
||||
@ -160,3 +166,23 @@ bool menuUpdate(void) {
|
||||
|
||||
return exitflag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char* getSavedTheme(){
|
||||
char tmp_path[PATH_MAX];
|
||||
#ifdef __SWITCH__
|
||||
strcpy(tmp_path,"sdmc:");
|
||||
#else
|
||||
getcwd(tmp_path, PATH_MAX);
|
||||
#endif
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s%s%s%s%s%s%s", DIRECTORY_SEPARATOR, "config", DIRECTORY_SEPARATOR, "nx-hbmenu" , DIRECTORY_SEPARATOR, "themes", DIRECTORY_SEPARATOR, "theme.saved");
|
||||
FILE* f;
|
||||
if((f= fopen(tmp_path, "rb"))==NULL) return NULL; //return null if FAILED TO OPEN FILE
|
||||
char* buffer;
|
||||
buffer = calloc(1, PATH_MAX+1) ;//calloc already contains zeros
|
||||
if( 1!=fread(buffer,PATH_MAX, 1, f) ) return NULL;// return null if FAILED TO READ
|
||||
fclose(f);
|
||||
return buffer;
|
||||
|
||||
}
|
@ -66,6 +66,8 @@ extern "C" bool menuUpdate(void) {
|
||||
int new_return_state = sf::Keyboard::isKeyPressed(sf::Keyboard::Return);
|
||||
static int y_state = 0;
|
||||
int new_y_state = sf::Keyboard::isKeyPressed(sf::Keyboard::Y);
|
||||
static int t_state = 0;
|
||||
int new_t_state = sf::Keyboard::isKeyPressed(sf::Keyboard::T);
|
||||
|
||||
if(!new_y_state && y_state)
|
||||
{
|
||||
@ -77,6 +79,9 @@ extern "C" bool menuUpdate(void) {
|
||||
{
|
||||
launchMenuBackTask();
|
||||
}
|
||||
else if(!new_t_state && t_state){
|
||||
themeMenuStartup();
|
||||
}
|
||||
else if (!new_return_state && return_state)
|
||||
{
|
||||
if (menuIsMsgBoxOpen()) {
|
||||
|
BIN
resources/theme_icon_dark.png
Normal file
BIN
resources/theme_icon_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/theme_icon_light.png
Normal file
BIN
resources/theme_icon_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
3
theme_icon_dark_bin.h
Normal file
3
theme_icon_dark_bin.h
Normal file
@ -0,0 +1,3 @@
|
||||
extern const u8 theme_icon_dark_bin_end[];
|
||||
extern const u8 theme_icon_dark_bin[];
|
||||
extern const u32 theme_icon_dark_bin_size;
|
3
theme_icon_light_bin.h
Normal file
3
theme_icon_light_bin.h
Normal file
@ -0,0 +1,3 @@
|
||||
extern const u8 theme_icon_light_bin_end[];
|
||||
extern const u8 theme_icon_light_bin[];
|
||||
extern const u32 theme_icon_light_bin_size;
|
Loading…
Reference in New Issue
Block a user