mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
Ability to setup a default font
This commit is contained in:
parent
03d1255aaa
commit
9a227b92bf
@ -67,6 +67,7 @@
|
||||
#define FTYPE_SCRIPT(tp) (tp&(TXT_SCRIPT))
|
||||
#define FTYPE_FONT(tp) (tp&(FONT_PBM))
|
||||
#define FTYPE_GFX(tp) (tp&(GFX_PNG))
|
||||
#define FTYPE_SETABLE(tp) (tp&(FONT_PBM))
|
||||
#define FTYPE_BOOTABLE(tp) (tp&(SYS_FIRM))
|
||||
#define FTYPE_INSTALLABLE(tp) (tp&(SYS_FIRM))
|
||||
#define FTYPE_AGBSAVE(tp) (tp&(SYS_AGBSAVE))
|
||||
|
@ -48,6 +48,51 @@ size_t LoadSupportFile(const char* fname, void* buffer, size_t max_len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SaveSupportFile(const char* fname, void* buffer, size_t len)
|
||||
{
|
||||
const char* base_paths[] = { SUPPORT_FILE_PATHS };
|
||||
int idx = -1;
|
||||
|
||||
// check for existing support file path
|
||||
for (u32 i = 0; (idx < 0) && (i < countof(base_paths)); i++) {
|
||||
if (fvx_stat(base_paths[i], NULL) == FR_OK)
|
||||
idx = i;
|
||||
}
|
||||
|
||||
// create path if required
|
||||
for (u32 i = 0; (idx < 0) && (i < countof(base_paths)); i++) {
|
||||
if (fvx_rmkdir(base_paths[i]) == FR_OK)
|
||||
idx = i;
|
||||
}
|
||||
|
||||
// write support file
|
||||
if (idx >= 0) {
|
||||
char path[256];
|
||||
snprintf(path, 256, "%s/%s", base_paths[idx], fname);
|
||||
fvx_unlink(path);
|
||||
if (fvx_qwrite(path, buffer, 0, len, NULL) == FR_OK)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SetAsSupportFile(const char* fname, const char* source)
|
||||
{
|
||||
u32 len = fvx_qsize(source);
|
||||
if (!len) return false;
|
||||
|
||||
void* buffer = malloc(len);
|
||||
if (!buffer) return false;
|
||||
|
||||
bool res = false;
|
||||
if (fvx_qread(source, buffer, 0, len, NULL) == FR_OK)
|
||||
res = SaveSupportFile(fname, buffer, len);
|
||||
free(buffer);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GetSupportDir(char* path, const char* dname)
|
||||
{
|
||||
const char* base_paths[] = { SUPPORT_DIR_PATHS };
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
bool CheckSupportFile(const char* fname);
|
||||
size_t LoadSupportFile(const char* fname, void* buffer, size_t max_len);
|
||||
bool SaveSupportFile(const char* fname, void* buffer, size_t len);
|
||||
bool SetAsSupportFile(const char* fname, const char* source);
|
||||
|
||||
bool CheckSupportDir(const char* fpath);
|
||||
bool FileSelectorSupport(char* result, const char* text, const char* dname, const char* pattern);
|
||||
|
@ -1044,6 +1044,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
|
||||
bool scriptable = (FTYPE_SCRIPT(filetype));
|
||||
bool fontable = (FTYPE_FONT(filetype));
|
||||
bool viewable = (FTYPE_GFX(filetype));
|
||||
bool setable = (FTYPE_SETABLE(filetype));
|
||||
bool bootable = (FTYPE_BOOTABLE(filetype));
|
||||
bool installable = (FTYPE_INSTALLABLE(filetype));
|
||||
bool agbexportable = (FTYPE_AGBSAVE(filetype) && (drvtype & DRV_VIRTUAL) && (drvtype & DRV_SYSNAND));
|
||||
@ -1109,7 +1110,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
|
||||
(filetype & BIN_LEGKEY) ? "Build " KEYDB_NAME :
|
||||
(filetype & BIN_NCCHNFO)? "NCCHinfo options..." :
|
||||
(filetype & TXT_SCRIPT) ? "Execute GM9 script" :
|
||||
(filetype & FONT_PBM) ? "Set as active font" :
|
||||
(filetype & FONT_PBM) ? "Font options..." :
|
||||
(filetype & GFX_PNG) ? "View PNG file" :
|
||||
(filetype & HDR_NAND) ? "Rebuild NCSD header" :
|
||||
(filetype & NOIMG_NAND) ? "Rebuild NCSD header" : "???";
|
||||
@ -1259,6 +1260,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
|
||||
int view = (viewable) ? ++n_opt : -1;
|
||||
int agbexport = (agbexportable) ? ++n_opt : -1;
|
||||
int agbimport = (agbimportable) ? ++n_opt : -1;
|
||||
int setup = (setable) ? ++n_opt : -1;
|
||||
if (mount > 0) optionstr[mount-1] = (filetype & GAME_TMD) ? "Mount CXI/NDS to drive" : "Mount image to drive";
|
||||
if (restore > 0) optionstr[restore-1] = "Restore SysNAND (safe)";
|
||||
if (ebackup > 0) optionstr[ebackup-1] = "Update embedded backup";
|
||||
@ -1290,6 +1292,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
|
||||
if (font > 0) optionstr[font-1] = "Set as active font";
|
||||
if (agbexport > 0) optionstr[agbexport-1] = "Dump GBA VC save";
|
||||
if (agbimport > 0) optionstr[agbimport-1] = "Inject GBA VC save";
|
||||
if (setup > 0) optionstr[setup-1] = "Set as default";
|
||||
|
||||
// auto select when there is only one option
|
||||
user_select = (n_opt <= 1) ? n_opt : (int) ShowSelectPrompt(n_opt, optionstr, (n_marked > 1) ?
|
||||
@ -1831,6 +1834,13 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (user_select == setup) { // set as default (font)
|
||||
if (filetype & FONT_PBM) {
|
||||
if (SetAsSupportFile("font.pbm", file_path))
|
||||
ShowPrompt(false, "%s\nFont will be active on next boot", pathstr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return FileHandlerMenu(current_path, cursor, scroll, pane);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user