Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented a theme switcher feature #62

Merged
merged 64 commits into from Sep 29, 2018
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ed5c670
Implemented hbmenu Theme Switcher! Final changes will now be cosmetic
NightlyFox Sep 19, 2018
afe968f
Merge branch 'master' of https://github.com/switchbrew/nx-hbmenu
NightlyFox Sep 19, 2018
93ee023
saw a potential bug, where i was changing the size of something a whi…
NightlyFox Sep 19, 2018
2f887cc
added some minor touch ups to the Theme Switcher Menu
NightlyFox Sep 19, 2018
bd23932
got rid of TODO comments that are no longer needed, different impleme…
NightlyFox Sep 19, 2018
35a3c64
added proper deallocation in places of the code for pointers that i a…
NightlyFox Sep 19, 2018
8e2a79c
added two new theming attributes, borderColor, borderTextcolor, allow…
NightlyFox Sep 20, 2018
981a60a
Added themeExit to pc main.cpp
NightlyFox Sep 21, 2018
4369cbf
not sure how the highlight multiplier got removed, but i added it back
NightlyFox Sep 21, 2018
df53f5f
added config_destroy() after done applying theme.
NightlyFox Sep 21, 2018
af0278b
removed *bin.h files
NightlyFox Sep 21, 2018
c877b65
reverted make file
NightlyFox Sep 21, 2018
59ba53d
remmoved (old) files and got rid of extra whitespace
NightlyFox Sep 21, 2018
9c8c395
removed the free from the menu-entry file and put it in the function …
NightlyFox Sep 21, 2018
42df5cf
fixed bug that would take user from netloader screen to theme switche…
NightlyFox Sep 21, 2018
2f1e6ad
got rid of void* cast when freeing, got rid of comments asking questi…
NightlyFox Sep 22, 2018
22c2c5b
restored newline at eof of main.c
NightlyFox Sep 22, 2018
907b594
fixed indention
NightlyFox Sep 22, 2018
12761b1
got rid of stray whitespace, replaced with newline
NightlyFox Sep 22, 2018
7dbc5b2
got rid of void* in menu-list, didnt save the file last time
NightlyFox Sep 22, 2018
4d488b4
got rid of code modifying display name of theme config files, changed…
NightlyFox Sep 23, 2018
b0c5a82
user no longer needs to restart the application
NightlyFox Sep 23, 2018
2880429
added spaces to areas in code to have coding conformity
NightlyFox Sep 23, 2018
ea1d7dc
missed this extra newline
NightlyFox Sep 23, 2018
0f95009
added theme info to config file, users can now add theme author, and …
NightlyFox Sep 23, 2018
d79d501
cleaned up code with themeInfo config, now looks a lot better
NightlyFox Sep 23, 2018
350fbda
got rid of booleans, initialized pointers with default values
NightlyFox Sep 23, 2018
a9921cb
changed settings.cfg name back to theme.cfg name, but left it in the …
NightlyFox Sep 23, 2018
c542b19
added declaration of functions to get rid of implicit warnings
NightlyFox Sep 23, 2018
2a2128c
tested building on mac osx, added to .gitignore and make clean for fi…
NightlyFox Sep 23, 2018
3abb799
fixed spaces
NightlyFox Sep 23, 2018
f7d1f7a
added git ignore changes
NightlyFox Sep 24, 2018
59f2e4d
fixed aligment and added a newline after temp_path within launchApply…
NightlyFox Sep 24, 2018
f89e331
got rid of redundent code in menu-entry.c file
NightlyFox Sep 24, 2018
26acfdd
out newline before tmp_path in menu.c
NightlyFox Sep 24, 2018
3bc3217
made requested changes by yellows8
NightlyFox Sep 24, 2018
b928153
updated language for theme menu
NightlyFox Sep 24, 2018
1afb097
fixed capitalization of functions to match others
NightlyFox Sep 24, 2018
8f20c9a
made suggested changes
NightlyFox Sep 24, 2018
03503d8
updated changes
NightlyFox Sep 24, 2018
ce5470d
added GetThemePathConfig function
NightlyFox Sep 26, 2018
e60156c
Merge branch 'master' of https://github.com/NightlyFox/nx-hbmenu
NightlyFox Sep 26, 2018
5621fb4
NOT STABLE: attempting to write functions that copy themePath to and …
NightlyFox Sep 26, 2018
58f5a78
added removeDriveFromPath Function
NightlyFox Sep 26, 2018
3e7618a
added newline
NightlyFox Sep 26, 2018
63e71a4
NO IDEA WHY I REVERTED
NightlyFox Sep 26, 2018
19ea89c
newline to font.c at eof
NightlyFox Sep 26, 2018
1d9ef3b
added functions to create/modify settings config for hbmenu theme
NightlyFox Sep 26, 2018
624fbed
added check for empty themePath, added check for existing settings co…
NightlyFox Sep 28, 2018
cd8698c
added null checks to theme.c, removed and added newline in language.c
NightlyFox Sep 28, 2018
1c15605
i swear if this adds two newlines!
NightlyFox Sep 28, 2018
a776768
added newline
NightlyFox Sep 28, 2018
56f495f
final changed to make and gitignore file
NightlyFox Sep 28, 2018
3c548f6
changed hbmenuConfig to settings
NightlyFox Sep 28, 2018
a5279c8
passed in size
NightlyFox Sep 28, 2018
3b40097
made some final changes, cleaned up code
NightlyFox Sep 28, 2018
0cfaa79
added Default theme entry that will always insert itself at the front…
NightlyFox Sep 28, 2018
8f01f59
added correct punctuation to the end of StrId_ThemeNotApplied languages
NightlyFox Sep 28, 2018
dab82dc
added code for + and - button, using - button for theme menu now, cor…
NightlyFox Sep 29, 2018
253ef7c
took repeated code out of if/else statements
NightlyFox Sep 29, 2018
de42849
added correct unicode for switch characters + and - for light theme
NightlyFox Sep 29, 2018
3c4f483
commented out prompt to press - button to open theme menu
NightlyFox Sep 29, 2018
c6716a0
got rid of newline
NightlyFox Sep 29, 2018
096b283
got rid of extra newline before themeMenuScan
NightlyFox Sep 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile.pc
Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions common/language.c
Expand Up @@ -310,6 +310,24 @@ const char* const g_strings[StrId_Max][16] =
STR_TW("確認"),
},

[StrId_Actions_Apply] =
{
STR_EN("Apply"),
STR_ES("Aplicar"),
STR_JP("適用"),
STR_KO("대다"),
STR_TW("应用"),
},


NightlyFox marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

[StrId_Actions_Theme_Menu] =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StrId_ThemeMenu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
STR_EN("Theme Switcher V1.0"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theme Menu, & update below strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

STR_ES("Versión 1,0 del cambiador de tema"),
STR_JP("テーマスイッチャー版1.0"),
STR_KO("테마 스위처 에디션 1.0"),
STR_TW("主题切换器版本1。0"),
},
/*[StrId_Reboot] =
NightlyFox marked this conversation as resolved.
Show resolved Hide resolved
{
STR_EN(
Expand Down
3 changes: 3 additions & 0 deletions common/language.h
Expand Up @@ -21,6 +21,7 @@ typedef enum
StrId_Actions_Launch,
StrId_Actions_Open,
StrId_Actions_Back,
StrId_Actions_Apply,

StrId_MsgBox_OK,

Expand All @@ -42,6 +43,8 @@ typedef enum
StrId_NetLoaderActive,
StrId_NetLoaderTransferring,

StrId_Actions_Theme_Menu,

StrId_Max,
} StrId;

Expand Down
9 changes: 8 additions & 1 deletion common/menu-entry.c
Expand Up @@ -137,6 +137,7 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {

tempbuf[PATH_MAX] = 0;
strcpy(me->name, name);

if (me->type == ENTRY_TYPE_FOLDER)
{
//Check for <dirpath>/<dirname>.nro
Expand Down Expand Up @@ -182,7 +183,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");

Expand Down Expand Up @@ -293,6 +294,12 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
/*if (shortcut)
shortcutFree(&sc);*/
}
if (me->type == ENTRY_TYPE_THEME){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

") {"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


//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;
}
Expand Down
50 changes: 50 additions & 0 deletions common/menu-list.c
Expand Up @@ -150,3 +150,53 @@ int menuScan(const char* target) {
return 0;
}


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code using config_setting_lookup_string was wrong. In theme.h theme_t can you change buttonAText/buttonBText to char {name}[32];, and update code setting those fields to use this? strncpy({dest}, {input}, sizeof({dest})-1);

got it, fixed! no longer useds calloc :), got rid of themeExit functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got rid of the extra newline

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still has an extra newline here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually yeah remove it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping^

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of this line and the next line + remove the funcs which would then be unused, and just use d_name for the name.

A different name could be specified in the .cfg file, perhaps load it in menuEntryLoad.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was going to add a feature to put a theme name within the config file in the future, and this was going to be a fallback so that if they didnt the filename wouldnt look so ugly with the underscores and extension attached too it... but if you dont want it there ill remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

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)-1);
me->path[sizeof(me->path)-1] = 0;
if (menuEntryLoad(me,(const char*)name, shortcut))
menuAddEntry(me);
else
menuDeleteEntry(me);
free((void*)name);//This was allocated by calloc and copied over by strcpy
NightlyFox marked this conversation as resolved.
Show resolved Hide resolved
}

closedir(dir);
menuSort();
// Swap the menu and clear the previous menu
s_curMenu = !s_curMenu;
menuClear();
return 0;
}
82 changes: 74 additions & 8 deletions common/menu.c
Expand Up @@ -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];

Expand All @@ -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);
}
Expand All @@ -27,6 +31,7 @@ static enum
HBMENU_NETLOADER_ACTIVE,
HBMENU_NETLOADER_ERROR,
HBMENU_NETLOADER_SUCCESS,
HBMENU_THEME_MENU,
} hbmenu_state = HBMENU_DEFAULT;

void launchMenuNetloaderTask() {
Expand All @@ -39,11 +44,41 @@ void launchMenuBackTask()
if(hbmenu_state == HBMENU_NETLOADER_ACTIVE) {
netloader_deactivate();
hbmenu_state = HBMENU_DEFAULT;
} else {
}else if(hbmenu_state == HBMENU_THEME_MENU){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces missing

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};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix alignment + insert newline here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#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;
config_destroy(&cfg);
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) {
Expand Down Expand Up @@ -72,6 +107,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;
Expand All @@ -87,7 +123,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {

int border_start_x, border_end_x;
int border_start_y, border_end_y;
color_t border_color = MakeColor(255, 255, 255, 255);
color_t border_color = MakeColor(themeCurrent.borderColor.r, themeCurrent.borderColor.g, themeCurrent.borderColor.b, 255);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MakeColor with a color_t is redundant, same with below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are correct... changed.


int shadow_start_y, shadow_y;
int shadow_inset;
Expand Down Expand Up @@ -166,7 +202,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {

for (y=start_y; y<end_y; y++) {
for (x=start_x; x<end_x; x+=4) {
Draw4PixelsRaw(x, y, MakeColor(255, 255, 255, 255));
Draw4PixelsRaw(x, y, MakeColor(themeCurrent.borderColor.r, themeCurrent.borderColor.g, themeCurrent.borderColor.b, 255));//add to theme
}
}

Expand All @@ -178,6 +214,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;
Expand Down Expand Up @@ -205,8 +247,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
}
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added it back

DrawTextTruncate(interuiregular14, start_x + 4, start_y + 4 + 18, MakeColor(64, 64, 64, 255), me->name, 140 - 32, "...");
DrawTextTruncate(interuiregular14, start_x + 4, start_y + 4 + 18, MakeColor(themeCurrent.borderTextColor.r, themeCurrent.borderTextColor.g, themeCurrent.borderTextColor.b, 255), me->name, 140 - 32, "...");//Add to theme

if (is_active) {
start_x = 1280 - 790;
Expand Down Expand Up @@ -271,6 +312,23 @@ void menuStartup() {
//menuCreateMsgBox(780, 300, "This is a test");
}

void themeMenuStartup() {
if(hbmenu_state != HBMENU_DEFAULT) 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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this would work on hardware...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pc-build that is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, i used the directory_seperators so that it would though


themeMenuScan(tmp_path);
if(globalPreset == THEME_PRESET_DARK)
theme_icon_small = downscaleImg(theme_icon_dark_bin, 256, 256, 140, 140, IMAGE_MODE_RGB24);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this into menuStartup, it should only be initialized once (themeMenuStartup can be called multiple times).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

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);
}
Expand Down Expand Up @@ -441,12 +499,20 @@ void menuLoop() {
}

if(active_entry != NULL) {
if (active_entry->type != ENTRY_TYPE_FOLDER) {
if(active_entry->type == ENTRY_TYPE_THEME){
Copy link
Collaborator

@yellows8 yellows8 Sep 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use spaces like the ENTRY_TYPE_FOLDER line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

int getX = getXCoordinate(interuiregular18,1180,textGetString(StrId_Actions_Theme_Menu),'r');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces after ','.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

DrawText(interuiregular18, getX , 0 + 47, themeCurrent.textColor, textGetString(StrId_Actions_Theme_Menu));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra space after getX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

//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));
Expand All @@ -457,4 +523,4 @@ void menuLoop() {
}

menuDrawMsgBox();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

18 changes: 18 additions & 0 deletions common/menu.h
Expand Up @@ -19,6 +19,7 @@ typedef enum
{
ENTRY_TYPE_FILE,
ENTRY_TYPE_FOLDER,
ENTRY_TYPE_THEME,
} MenuEntryType;

typedef struct menuEntry_s_tag menuEntry_s;
Expand Down Expand Up @@ -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();
Expand All @@ -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;/*Get copy of the head of the char* to return, otherwise it will return copy->null */
for (p = str; p <= (str+strlen(str)) && *p != '.'; p++){
NightlyFox marked this conversation as resolved.
Show resolved Hide resolved
*copy = *p;
copy++;
}
return (char*)copyHead;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast is superfluous.

}

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;
}