made requested changes by yellows8
This commit is contained in:
parent
26acfddb38
commit
3bc32177a5
@ -153,8 +153,8 @@ void DrawPixel(uint32_t x, uint32_t y, color_t clr);
|
||||
void DrawText(u32 font, uint32_t x, uint32_t y, color_t clr, const char* text);
|
||||
void DrawTextTruncate(u32 font, uint32_t x, uint32_t y, color_t clr, const char* text, uint32_t max_width, const char* end_text);
|
||||
void GetTextDimensions(u32 font, const char* text, uint32_t* width_out, uint32_t* height_out);
|
||||
uint32_t getXCoordinate(u32 font,uint32_t rX, const char* text,const char align);
|
||||
uint32_t getYCoordinate(u32 font,uint32_t rY, const char* text,const char align);
|
||||
uint32_t getTextXCoordinate(u32 font, uint32_t rX, const char* text, const char align);
|
||||
uint32_t getTextYCoordinate(u32 font, uint32_t rY, const char* text, const char align);
|
||||
|
||||
bool fontInitialize(void);
|
||||
void fontExit();
|
||||
|
@ -377,46 +377,48 @@ void fontExit()
|
||||
}
|
||||
|
||||
/*Automatically gives you the desired x-coordinate
|
||||
*based on the string length and desired alignmenr
|
||||
*based on the string length and desired alignment
|
||||
*rY=reference point... where to align around
|
||||
*align='t','b','c' translates too (top,bottom,center)
|
||||
*align='t','b','c' translates to (top,bottom,center)
|
||||
*'t' aligned, top of text aligns with rY,
|
||||
*you get the rest....
|
||||
*/
|
||||
uint32_t getYCoordinate(u32 font,uint32_t rY,const char* text, const char align){
|
||||
uint32_t getTextYCoordinate(u32 font, uint32_t rY, const char* text, const char align){
|
||||
uint32_t height_o,width;
|
||||
GetTextDimensions(font,text,&width,&height_o);
|
||||
uint32_t height = (uint32_t)height_o;
|
||||
uint32_t fC = (rY-height);
|
||||
|
||||
switch(align){
|
||||
case 't':
|
||||
default:
|
||||
return rY;
|
||||
case 'c':
|
||||
return (rY+(height/2U));
|
||||
return (rY+(height>>1));//>>1 is a bitwise shift for dividing by 2
|
||||
case 'b':
|
||||
if(fC<=0U) return 0U;
|
||||
if(fC<=0) return 0;
|
||||
else return fC;
|
||||
}
|
||||
}
|
||||
|
||||
/*Automatically gives you the desired x-coordinate
|
||||
*based on the string length and desired alignmenr
|
||||
*based on the string length and desired alignment
|
||||
*rX=reference point... where to align around
|
||||
*text=string you want to display
|
||||
*align='r','l','c' translates too (right,left,center)
|
||||
*align='r','l','c' translates to (right,left,center)
|
||||
*'r' aligned, rX location = end of string, you get the rest...
|
||||
*/
|
||||
uint32_t getXCoordinate(u32 font,uint32_t rX, const char* text ,const char align){
|
||||
uint32_t getTextXCoordinate(u32 font, uint32_t rX, const char* text, const char align){
|
||||
uint32_t height,width_o;
|
||||
GetTextDimensions(font,text,&width_o,&height);
|
||||
uint32_t fC = (rX-width_o);
|
||||
|
||||
switch(align){
|
||||
case 'r':
|
||||
if(fC<0U) return 0U;
|
||||
if(fC<0) return 0;
|
||||
else return fC;
|
||||
case 'c':
|
||||
return (rX+(width_o/2U));
|
||||
return (rX+(width_o>>1));//>>1 is a bitwise shift for dividing by 2
|
||||
case 'l':
|
||||
default:
|
||||
return rX;
|
||||
|
@ -294,6 +294,7 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
|
||||
/*if (shortcut)
|
||||
shortcutFree(&sc);*/
|
||||
}
|
||||
|
||||
if (me->type == ENTRY_TYPE_THEME) {
|
||||
config_t cfg = {0};
|
||||
config_init(&cfg);
|
||||
|
@ -181,7 +181,7 @@ int themeMenuScan(const char* target) {
|
||||
|
||||
strncpy(me->path, tmp_path, sizeof(me->path)-1);
|
||||
me->path[sizeof(me->path)-1] = 0;
|
||||
if (menuEntryLoad(me,dp->d_name, shortcut))
|
||||
if (menuEntryLoad(me, dp->d_name, shortcut))
|
||||
menuAddEntry(me);
|
||||
else
|
||||
menuDeleteEntry(me);
|
||||
|
@ -74,7 +74,7 @@ void launchApplyThemeTask(menuEntry_s* arg) {
|
||||
return;
|
||||
}
|
||||
config_destroy(&cfg);
|
||||
themeStartup(globalPreset);
|
||||
themeStartup(themeGlobalPreset);
|
||||
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
|
||||
}
|
||||
else if (me->type == ENTRY_TYPE_THEME){
|
||||
smallimg = theme_icon_small;
|
||||
if(globalPreset == THEME_PRESET_DARK)
|
||||
if(themeGlobalPreset == THEME_PRESET_DARK)
|
||||
largeimg = theme_icon_dark_bin;
|
||||
else largeimg = theme_icon_light_bin;
|
||||
}
|
||||
@ -307,6 +307,10 @@ void menuStartup() {
|
||||
|
||||
folder_icon_small = downscaleImg(folder_icon_bin, 256, 256, 140, 140, IMAGE_MODE_RGB24);
|
||||
invalid_icon_small = downscaleImg(invalid_icon_bin, 256, 256, 140, 140, IMAGE_MODE_RGB24);
|
||||
if(themeGlobalPreset == 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");
|
||||
}
|
||||
@ -319,13 +323,6 @@ void themeMenuStartup() {
|
||||
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) {
|
||||
@ -499,7 +496,7 @@ void menuLoop() {
|
||||
|
||||
if(active_entry != NULL) {
|
||||
if (active_entry->type == ENTRY_TYPE_THEME) {
|
||||
int getX = getXCoordinate(interuiregular18, 1180, textGetString(StrId_Actions_Theme_Menu), 'r');
|
||||
int getX = getTextXCoordinate(interuiregular18, 1180, textGetString(StrId_Actions_Theme_Menu), 'r');
|
||||
DrawText(interuiregular18, getX, 0 + 47, themeCurrent.textColor, textGetString(StrId_Actions_Theme_Menu));
|
||||
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));
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "hbmenu_logo_light_bin.h"
|
||||
#include "hbmenu_logo_dark_bin.h"
|
||||
|
||||
theme_t themeCurrent;
|
||||
|
||||
bool colorFromSetting(config_setting_t *rgba, color_t *col) {
|
||||
if(rgba == NULL)
|
||||
return false;
|
||||
@ -14,7 +16,7 @@ bool colorFromSetting(config_setting_t *rgba, color_t *col) {
|
||||
}
|
||||
|
||||
void themeStartup(ThemePreset preset) {
|
||||
globalPreset = preset;
|
||||
themeGlobalPreset = preset;
|
||||
theme_t themeLight = (theme_t) {
|
||||
.textColor = MakeColor(0, 0, 0, 255),
|
||||
.frontWaveColor = MakeColor(100, 212, 250, 255),
|
||||
@ -67,6 +69,7 @@ void themeStartup(ThemePreset preset) {
|
||||
int waveBlending;
|
||||
const char *AText, *BText;
|
||||
bool good_cfg = config_read_file(&cfg, tmp_path);
|
||||
|
||||
switch (preset) {
|
||||
case THEME_PRESET_LIGHT:
|
||||
default:
|
||||
@ -81,6 +84,7 @@ void themeStartup(ThemePreset preset) {
|
||||
theme = config_lookup(&cfg, "darkTheme");
|
||||
break;
|
||||
}
|
||||
|
||||
if (good_cfg) {
|
||||
if (theme != NULL) {
|
||||
if (!colorFromSetting(config_setting_lookup(theme, "textColor"), &text))
|
||||
|
@ -30,8 +30,8 @@ typedef enum
|
||||
|
||||
bool colorFromSetting(config_setting_t *rgba, color_t *col);
|
||||
|
||||
void themeStartup(ThemePreset preset);
|
||||
extern void themeStartup(ThemePreset preset);
|
||||
|
||||
theme_t themeCurrent;
|
||||
extern theme_t themeCurrent;
|
||||
|
||||
ThemePreset globalPreset;
|
||||
ThemePreset themeGlobalPreset;
|
||||
|
@ -40,6 +40,7 @@ int main(int argc, char **argv)
|
||||
|
||||
rc = plInitialize();
|
||||
if (R_FAILED(rc)) fatalSimple(-6);
|
||||
|
||||
themeStartup((ThemePreset)theme);
|
||||
textInit();
|
||||
menuStartup();
|
||||
|
Loading…
Reference in New Issue
Block a user