Moved path init code from menuStartup() into new func menuStartupPath(), which now creates the config dirs if needed. Added menuGetRootBasePath(), which is now used for config paths and pc-build fonts. Changed some funcs from () to (void). Fixed broken button handling in pc_main for theme-menu. This fixes pc-build support for config/theme-menu.
This commit is contained in:
parent
6e11672e20
commit
e01ca3150e
@ -59,9 +59,10 @@ typedef union {
|
||||
#include "theme.h"
|
||||
#include "message-box.h"
|
||||
|
||||
void menuStartup();
|
||||
void themeMenuStartup();
|
||||
void menuLoop();
|
||||
void menuStartupPath(void);
|
||||
void menuStartup(void);
|
||||
void themeMenuStartup(void);
|
||||
void menuLoop(void);
|
||||
|
||||
static inline uint8_t BlendColor(uint32_t src, uint32_t dst, uint8_t alpha)
|
||||
{
|
||||
|
@ -349,7 +349,7 @@ bool fontInitialize(void)
|
||||
|
||||
for (i=0; i<FONT_FACES_MAX; i++) {
|
||||
memset(fontpath, 0, sizeof(fontpath));
|
||||
snprintf(fontpath, sizeof(fontpath)-1, "fonts%s%u.ttf", DIRECTORY_SEPARATOR, i);
|
||||
snprintf(fontpath, sizeof(fontpath)-1, "%s%sfonts%s%u.ttf", menuGetRootBasePath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, i);
|
||||
|
||||
ret = FT_New_Face( s_font_library,
|
||||
fontpath,
|
||||
|
@ -7,13 +7,18 @@
|
||||
#include "theme_icon_dark_bin.h"
|
||||
#include "theme_icon_light_bin.h"
|
||||
|
||||
char rootPathBase[PATH_MAX];
|
||||
char rootPath[PATH_MAX+8];
|
||||
void computeFrontGradient(color_t baseColor, int height);
|
||||
|
||||
char *menuGetRootPath() {
|
||||
char *menuGetRootPath(void) {
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
char *menuGetRootBasePath(void) {
|
||||
return rootPathBase;
|
||||
}
|
||||
|
||||
void launchMenuEntryTask(menuEntry_s* arg) {
|
||||
menuEntry_s* me = arg;
|
||||
if (me->type == ENTRY_TYPE_FOLDER)
|
||||
@ -286,15 +291,15 @@ void computeFrontGradient(color_t baseColor, int height) {
|
||||
}
|
||||
}
|
||||
|
||||
void menuStartup() {
|
||||
char tmp_path[PATH_MAX];
|
||||
void menuStartupPath(void) {
|
||||
char tmp_path[PATH_MAX+25];
|
||||
|
||||
#ifdef __SWITCH__
|
||||
strcpy(tmp_path,"sdmc:");
|
||||
strncpy(rootPathBase, "sdmc:", sizeof(rootPathBase)-1);
|
||||
#else
|
||||
getcwd(tmp_path, PATH_MAX);
|
||||
getcwd(rootPathBase, sizeof(rootPathBase));
|
||||
#endif
|
||||
snprintf(rootPath, sizeof(rootPath)-1, "%s%s%s", tmp_path, DIRECTORY_SEPARATOR, "switch");
|
||||
snprintf(rootPath, sizeof(rootPath)-1, "%s%s%s", rootPathBase, DIRECTORY_SEPARATOR, "switch");
|
||||
|
||||
struct stat st = {0};
|
||||
|
||||
@ -302,6 +307,20 @@ void menuStartup() {
|
||||
mkdir(rootPath, 0755);
|
||||
}
|
||||
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s/config/nx-hbmenu/themes", rootPathBase);
|
||||
if (stat(tmp_path, &st) == -1) {
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s/config", rootPathBase);
|
||||
mkdir(tmp_path, 0755);
|
||||
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s/config/nx-hbmenu", rootPathBase);
|
||||
mkdir(tmp_path, 0755);
|
||||
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s/config/nx-hbmenu/themes", rootPathBase);
|
||||
mkdir(tmp_path, 0755);
|
||||
}
|
||||
}
|
||||
|
||||
void menuStartup(void) {
|
||||
menuScan(rootPath);
|
||||
|
||||
folder_icon_small = downscaleImg(folder_icon_bin, 256, 256, 140, 140, IMAGE_MODE_RGB24);
|
||||
@ -314,12 +333,12 @@ void menuStartup() {
|
||||
//menuCreateMsgBox(780, 300, "This is a test");
|
||||
}
|
||||
|
||||
void themeMenuStartup() {
|
||||
void themeMenuStartup(void) {
|
||||
if(hbmenu_state != HBMENU_DEFAULT) return;
|
||||
hbmenu_state = HBMENU_THEME_MENU;
|
||||
char tmp_path[PATH_MAX];
|
||||
char tmp_path[PATH_MAX+25];
|
||||
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s%s%s%s%s%s",DIRECTORY_SEPARATOR, "config", DIRECTORY_SEPARATOR, "nx-hbmenu" , DIRECTORY_SEPARATOR, "themes");
|
||||
snprintf(tmp_path, sizeof(tmp_path)-1, "%s%s%s%s%s%s%s", rootPathBase, DIRECTORY_SEPARATOR, "config", DIRECTORY_SEPARATOR, "nx-hbmenu" , DIRECTORY_SEPARATOR, "themes");
|
||||
|
||||
themeMenuScan(tmp_path);
|
||||
}
|
||||
@ -406,7 +425,7 @@ void drawBackBtn(menu_s* menu, bool emptyDir) {
|
||||
}
|
||||
}
|
||||
|
||||
void menuLoop() {
|
||||
void menuLoop(void) {
|
||||
menuEntry_s* me;
|
||||
menu_s* menu = menuGetCurrent();
|
||||
int i;
|
||||
|
@ -91,7 +91,8 @@ void launchMenuEntryTask(menuEntry_s* arg);
|
||||
void launchApplyThemeTask(menuEntry_s* arg);
|
||||
void launchMenuBackTask();
|
||||
void launchMenuNetloaderTask();
|
||||
char *menuGetRootPath();
|
||||
char *menuGetRootPath(void);
|
||||
char *menuGetRootBasePath(void);
|
||||
|
||||
void menuHandleAButton(void);
|
||||
|
||||
|
@ -144,16 +144,11 @@ void GetThemePathFromConfig(char* themePath, size_t size) {
|
||||
const char* tmpThemePath = "";
|
||||
config_t cfg = {0};
|
||||
config_setting_t *settings = NULL;
|
||||
char tmp_path[PATH_MAX] = {0};
|
||||
char tmp_path_theme[PATH_MAX] = {0};
|
||||
char tmp_path[PATH_MAX+1] = {0};
|
||||
char tmp_path_theme[PATH_MAX+1] = {0};
|
||||
|
||||
#ifdef __SWITCH__
|
||||
tmp_path[0] = '/';
|
||||
tmp_path_theme[0] = '/';
|
||||
#endif
|
||||
|
||||
strncat(tmp_path, "config/nx-hbmenu/settings.cfg", sizeof(tmp_path)-2);
|
||||
strncat(tmp_path_theme, "config/nx-hbmenu/themes/", sizeof(tmp_path_theme)-2);
|
||||
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) {
|
||||
@ -183,7 +178,7 @@ void SetThemePathToConfig(const char* themePath) {
|
||||
settingPath[0] = '/';
|
||||
#endif
|
||||
|
||||
strncat(settingPath, "config/nx-hbmenu/settings.cfg", sizeof(settingPath)-2);
|
||||
snprintf(settingPath, sizeof(settingPath)-1, "%s/config/nx-hbmenu/settings.cfg", menuGetRootBasePath());
|
||||
bool good_cfg = config_read_file(&cfg, settingPath);
|
||||
|
||||
if(good_cfg) {
|
||||
|
@ -41,6 +41,8 @@ int main(int argc, char **argv)
|
||||
rc = plInitialize();
|
||||
if (R_FAILED(rc)) fatalSimple(-6);
|
||||
|
||||
menuStartupPath();
|
||||
|
||||
themeStartup((ThemePreset)theme);
|
||||
textInit();
|
||||
menuStartup();
|
||||
|
@ -15,9 +15,10 @@ int main()
|
||||
sf::RenderWindow window(sf::VideoMode(1280, 720), "Test");
|
||||
window.setFramerateLimit(60);
|
||||
|
||||
menuStartupPath();
|
||||
themeStartup(THEME_PRESET_LIGHT);
|
||||
textInit();
|
||||
fontInitialize();//Must be called before menuStartup() due to cwd.
|
||||
fontInitialize();
|
||||
menuStartup();
|
||||
|
||||
while (window.isOpen())
|
||||
@ -111,6 +112,7 @@ extern "C" bool menuUpdate(void) {
|
||||
esc_state = new_esc_state;
|
||||
return_state = new_return_state;
|
||||
y_state = new_y_state;
|
||||
t_state = new_t_state;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user