mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
Allow switching screens via a #define
... #define SWITCH_SCREENS (in common.h?) to enabled this
This commit is contained in:
parent
761a3a7a91
commit
893f98b343
@ -48,6 +48,8 @@
|
||||
#define QLZ_SPLASH sm9_splash_baby_qlz
|
||||
#endif
|
||||
|
||||
// define this to switch top / bottom screen
|
||||
// #define SWITCH_SCREENS
|
||||
|
||||
// GodMode9 version
|
||||
#define VERSION "1.1.3"
|
||||
|
@ -25,10 +25,10 @@ void ClearScreen(u8* screen, int color)
|
||||
}
|
||||
}
|
||||
|
||||
void ClearScreenF(bool clear_top, bool clear_bottom, int color)
|
||||
void ClearScreenF(bool clear_main, bool clear_alt, int color)
|
||||
{
|
||||
if (clear_top) ClearScreen(TOP_SCREEN, color);
|
||||
if (clear_bottom) ClearScreen(BOT_SCREEN, color);
|
||||
if (clear_main) ClearScreen(MAIN_SCREEN, color);
|
||||
if (clear_alt) ClearScreen(ALT_SCREEN, color);
|
||||
}
|
||||
|
||||
void DrawRectangle(u8* screen, int x, int y, int width, int height, int color)
|
||||
@ -128,7 +128,7 @@ u32 GetDrawStringWidth(const char* str) {
|
||||
void WordWrapString(char* str, int llen) {
|
||||
char* last_brk = str - 1;
|
||||
char* last_spc = str - 1;
|
||||
if (!llen) llen = (SCREEN_WIDTH_TOP / FONT_WIDTH);
|
||||
if (!llen) llen = (SCREEN_WIDTH_MAIN / FONT_WIDTH);
|
||||
for (char* str_ptr = str;; str_ptr++) {
|
||||
if (!*str_ptr || (*str_ptr == ' ')) { // on space or string_end
|
||||
if (str_ptr - last_brk > llen) { // if maximum line lenght is exceeded
|
||||
@ -208,11 +208,11 @@ void ShowString(const char *format, ...)
|
||||
|
||||
str_width = GetDrawStringWidth(str);
|
||||
str_height = GetDrawStringHeight(str);
|
||||
x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
|
||||
x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2;
|
||||
y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2;
|
||||
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
DrawStringF(TOP_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawStringF(MAIN_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
} else ClearScreenF(true, false, COLOR_STD_BG);
|
||||
}
|
||||
|
||||
@ -234,13 +234,13 @@ void ShowIconString(u8* icon, int w, int h, const char *format, ...)
|
||||
str_width = GetDrawStringWidth(str);
|
||||
str_height = GetDrawStringHeight(str);
|
||||
tot_height = h + icon_offset + str_height;
|
||||
x_str = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
|
||||
x_str = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2;
|
||||
y_str = (str_height >= SCREEN_HEIGHT) ? 0 : h + icon_offset + (SCREEN_HEIGHT - tot_height) / 2;
|
||||
x_bmp = (w >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - w) / 2;
|
||||
x_bmp = (w >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - w) / 2;
|
||||
y_bmp = (tot_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - tot_height) / 2;
|
||||
|
||||
DrawBitmap(TOP_SCREEN, x_bmp, y_bmp, w, h, icon);
|
||||
DrawStringF(TOP_SCREEN, x_str, y_str, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawBitmap(MAIN_SCREEN, x_bmp, y_bmp, w, h, icon);
|
||||
DrawStringF(MAIN_SCREEN, x_str, y_str, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
}
|
||||
|
||||
bool ShowPrompt(bool ask, const char *format, ...)
|
||||
@ -258,12 +258,12 @@ bool ShowPrompt(bool ask, const char *format, ...)
|
||||
str_width = GetDrawStringWidth(str);
|
||||
str_height = GetDrawStringHeight(str) + (2 * 10);
|
||||
if (str_width < 18 * FONT_WIDTH) str_width = 18 * FONT_WIDTH;
|
||||
x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
|
||||
x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2;
|
||||
y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2;
|
||||
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
DrawStringF(TOP_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawStringF(TOP_SCREEN, x, y + str_height - (1*10), COLOR_STD_FONT, COLOR_STD_BG, (ask) ? "(<A> yes, <B> no)" : "(<A> to continue)");
|
||||
DrawStringF(MAIN_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawStringF(MAIN_SCREEN, x, y + str_height - (1*10), COLOR_STD_FONT, COLOR_STD_BG, (ask) ? "(<A> yes, <B> no)" : "(<A> to continue)");
|
||||
|
||||
while (true) {
|
||||
u32 pad_state = InputWait();
|
||||
@ -320,7 +320,7 @@ bool ShowUnlockSequence(u32 seqlvl, const char *format, ...) {
|
||||
str_width = GetDrawStringWidth(str);
|
||||
str_height = GetDrawStringHeight(str) + (4*10);
|
||||
if (str_width < 24 * FONT_WIDTH) str_width = 24 * FONT_WIDTH;
|
||||
x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
|
||||
x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2;
|
||||
y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2;
|
||||
|
||||
if (seqlvl >= 6) { // special handling
|
||||
@ -331,12 +331,12 @@ bool ShowUnlockSequence(u32 seqlvl, const char *format, ...) {
|
||||
}
|
||||
|
||||
ClearScreenF(true, false, color_bg);
|
||||
DrawStringF(TOP_SCREEN, x, y, color_font, color_bg, str);
|
||||
DrawStringF(TOP_SCREEN, x, y + str_height - 28, color_font, color_bg, "To proceed, enter this:");
|
||||
DrawStringF(MAIN_SCREEN, x, y, color_font, color_bg, str);
|
||||
DrawStringF(MAIN_SCREEN, x, y + str_height - 28, color_font, color_bg, "To proceed, enter this:");
|
||||
|
||||
while (true) {
|
||||
for (u32 n = 0; n < len; n++) {
|
||||
DrawStringF(TOP_SCREEN, x + (n*4*8), y + str_height - 18,
|
||||
DrawStringF(MAIN_SCREEN, x + (n*4*8), y + str_height - 18,
|
||||
(lvl > n) ? color_on : color_off, color_bg, "<%c>", seqsymbols[seqlvl][n]);
|
||||
}
|
||||
if (lvl == len)
|
||||
@ -374,16 +374,16 @@ u32 ShowSelectPrompt(u32 n, const char** options, const char *format, ...) {
|
||||
str_width = GetDrawStringWidth(str);
|
||||
str_height = GetDrawStringHeight(str) + (n * 12) + (3 * 10);
|
||||
if (str_width < 24 * FONT_WIDTH) str_width = 24 * FONT_WIDTH;
|
||||
x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
|
||||
x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2;
|
||||
y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2;
|
||||
yopt = y + GetDrawStringHeight(str) + 8;
|
||||
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
DrawStringF(TOP_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawStringF(TOP_SCREEN, x, yopt + (n*12) + 10, COLOR_STD_FONT, COLOR_STD_BG, "(<A> select, <B> cancel)");
|
||||
DrawStringF(MAIN_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawStringF(MAIN_SCREEN, x, yopt + (n*12) + 10, COLOR_STD_FONT, COLOR_STD_BG, "(<A> select, <B> cancel)");
|
||||
while (true) {
|
||||
for (u32 i = 0; i < n; i++) {
|
||||
DrawStringF(TOP_SCREEN, x, yopt + (12*i), (sel == i) ? COLOR_STD_FONT : COLOR_LIGHTGREY, COLOR_STD_BG, "%2.2s %s",
|
||||
DrawStringF(MAIN_SCREEN, x, yopt + (12*i), (sel == i) ? COLOR_STD_FONT : COLOR_LIGHTGREY, COLOR_STD_BG, "%2.2s %s",
|
||||
(sel == i) ? "->" : "", options[i]);
|
||||
}
|
||||
u32 pad_state = InputWait();
|
||||
@ -422,12 +422,12 @@ bool ShowInputPrompt(char* inputstr, u32 max_size, u32 resize, const char* alpha
|
||||
str_width = GetDrawStringWidth(str);
|
||||
str_height = GetDrawStringHeight(str) + (8*10);
|
||||
if (str_width < (24 * FONT_WIDTH)) str_width = 24 * FONT_WIDTH;
|
||||
x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
|
||||
x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2;
|
||||
y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2;
|
||||
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
DrawStringF(TOP_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawStringF(TOP_SCREEN, x + 8, y + str_height - 38, COLOR_STD_FONT, COLOR_STD_BG, "R - (\x18\x19) fast scroll\nL - clear data%s", resize ? "\nX - remove char\nY - insert char" : "");
|
||||
DrawStringF(MAIN_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
|
||||
DrawStringF(MAIN_SCREEN, x + 8, y + str_height - 38, COLOR_STD_FONT, COLOR_STD_BG, "R - (\x18\x19) fast scroll\nL - clear data%s", resize ? "\nX - remove char\nY - insert char" : "");
|
||||
|
||||
int cursor_a = -1;
|
||||
u32 cursor_s = 0;
|
||||
@ -439,7 +439,7 @@ bool ShowInputPrompt(char* inputstr, u32 max_size, u32 resize, const char* alpha
|
||||
if (cursor_s < scroll) scroll = cursor_s;
|
||||
else if (cursor_s - scroll >= input_shown) scroll = cursor_s - input_shown + 1;
|
||||
while (scroll && (inputstr_size - scroll < input_shown)) scroll--;
|
||||
DrawStringF(TOP_SCREEN, x, y + str_height - 68, COLOR_STD_FONT, COLOR_STD_BG, "%c%-*.*s%c%-*.*s\n%-*.*s^%-*.*s",
|
||||
DrawStringF(MAIN_SCREEN, x, y + str_height - 68, COLOR_STD_FONT, COLOR_STD_BG, "%c%-*.*s%c%-*.*s\n%-*.*s^%-*.*s",
|
||||
(scroll) ? '<' : '|',
|
||||
(inputstr_size > input_shown) ? input_shown : inputstr_size,
|
||||
(inputstr_size > input_shown) ? input_shown : inputstr_size,
|
||||
@ -601,7 +601,7 @@ bool ShowProgress(u64 current, u64 total, const char* opstr)
|
||||
static u32 last_prog_width = 0;
|
||||
const u32 bar_width = 240;
|
||||
const u32 bar_height = 12;
|
||||
const u32 bar_pos_x = (SCREEN_WIDTH_TOP - bar_width) / 2;
|
||||
const u32 bar_pos_x = (SCREEN_WIDTH_MAIN - bar_width) / 2;
|
||||
const u32 bar_pos_y = (SCREEN_HEIGHT / 2) - bar_height - 2 - 10;
|
||||
const u32 text_pos_y = bar_pos_y + bar_height + 2;
|
||||
u32 prog_width = ((total > 0) && (current <= total)) ? (current * (bar_width-4)) / total : 0;
|
||||
@ -622,22 +622,22 @@ bool ShowProgress(u64 current, u64 total, const char* opstr)
|
||||
|
||||
if (!current || last_prog_width > prog_width) {
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
DrawRectangle(TOP_SCREEN, bar_pos_x, bar_pos_y, bar_width, bar_height, COLOR_STD_FONT);
|
||||
DrawRectangle(TOP_SCREEN, bar_pos_x + 1, bar_pos_y + 1, bar_width - 2, bar_height - 2, COLOR_STD_BG);
|
||||
DrawRectangle(MAIN_SCREEN, bar_pos_x, bar_pos_y, bar_width, bar_height, COLOR_STD_FONT);
|
||||
DrawRectangle(MAIN_SCREEN, bar_pos_x + 1, bar_pos_y + 1, bar_width - 2, bar_height - 2, COLOR_STD_BG);
|
||||
}
|
||||
DrawRectangle(TOP_SCREEN, bar_pos_x + 2, bar_pos_y + 2, prog_width, bar_height - 4, COLOR_STD_FONT);
|
||||
DrawRectangle(MAIN_SCREEN, bar_pos_x + 2, bar_pos_y + 2, prog_width, bar_height - 4, COLOR_STD_FONT);
|
||||
|
||||
TruncateString(progstr, opstr, (bar_width / FONT_WIDTH_EXT) - 7, 8);
|
||||
snprintf(tempstr, 64, "%s (%lu%%)", progstr, prog_percent);
|
||||
ResizeString(progstr, tempstr, bar_width / FONT_WIDTH_EXT, 8, false);
|
||||
DrawString(TOP_SCREEN, progstr, bar_pos_x, text_pos_y, COLOR_STD_FONT, COLOR_STD_BG);
|
||||
DrawString(MAIN_SCREEN, progstr, bar_pos_x, text_pos_y, COLOR_STD_FONT, COLOR_STD_BG);
|
||||
if (sec_elapsed >= 1) {
|
||||
snprintf(tempstr, 16, "ETA %02llum%02llus", sec_remain / 60, sec_remain % 60);
|
||||
ResizeString(progstr, tempstr, 16, 8, true);
|
||||
DrawString(TOP_SCREEN, progstr, bar_pos_x + bar_width - 1 - (FONT_WIDTH_EXT * 16),
|
||||
DrawString(MAIN_SCREEN, progstr, bar_pos_x + bar_width - 1 - (FONT_WIDTH_EXT * 16),
|
||||
bar_pos_y - 10 - 1, COLOR_STD_FONT, COLOR_STD_BG);
|
||||
}
|
||||
DrawString(TOP_SCREEN, "(hold B to cancel)", bar_pos_x + 2, text_pos_y + 14, COLOR_STD_FONT, COLOR_STD_BG);
|
||||
DrawString(MAIN_SCREEN, "(hold B to cancel)", bar_pos_x + 2, text_pos_y + 14, COLOR_STD_FONT, COLOR_STD_BG);
|
||||
|
||||
last_prog_width = prog_width;
|
||||
|
||||
|
@ -55,8 +55,20 @@
|
||||
#define TOP_SCREEN (u8*)(*(u32*)0x23FFFE00)
|
||||
#define BOT_SCREEN (u8*)(*(u32*)0x23FFFE08)
|
||||
|
||||
#ifndef SWITCH_SCREENS
|
||||
#define MAIN_SCREEN TOP_SCREEN
|
||||
#define ALT_SCREEN BOT_SCREEN
|
||||
#define SCREEN_WIDTH_MAIN SCREEN_WIDTH_TOP
|
||||
#define SCREEN_WIDTH_ALT SCREEN_WIDTH_BOT
|
||||
#else
|
||||
#define MAIN_SCREEN BOT_SCREEN
|
||||
#define ALT_SCREEN TOP_SCREEN
|
||||
#define SCREEN_WIDTH_MAIN SCREEN_WIDTH_BOT
|
||||
#define SCREEN_WIDTH_ALT SCREEN_WIDTH_TOP
|
||||
#endif
|
||||
|
||||
void ClearScreen(unsigned char *screen, int color);
|
||||
void ClearScreenF(bool clear_top, bool clear_bottom, int color);
|
||||
void ClearScreenF(bool clear_main, bool clear_alt, int color);
|
||||
void DrawRectangle(u8* screen, int x, int y, int width, int height, int color);
|
||||
void DrawBitmap(u8* screen, int x, int y, int w, int h, u8* bitmap);
|
||||
|
||||
|
@ -49,9 +49,11 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
const u32 n_cb_show = 8;
|
||||
const u32 bartxt_start = (FONT_HEIGHT_EXT == 10) ? 1 : 2;
|
||||
const u32 bartxt_x = 2;
|
||||
const u32 bartxt_rx = SCREEN_WIDTH_TOP - (19*FONT_WIDTH_EXT) - bartxt_x;
|
||||
const u32 bartxt_rx = SCREEN_WIDTH_MAIN - (19*FONT_WIDTH_EXT) - bartxt_x;
|
||||
const u32 info_start = 18;
|
||||
const u32 instr_x = (SCREEN_WIDTH_TOP - (36*FONT_WIDTH_EXT)) / 2;
|
||||
const u32 instr_x = (SCREEN_WIDTH_MAIN - (36*FONT_WIDTH_EXT)) / 2;
|
||||
const u32 len_path = SCREEN_WIDTH_MAIN - ((SCREEN_WIDTH_MAIN >= 400) ? 160 : 120);
|
||||
const u32 len_info = (SCREEN_WIDTH_MAIN - ((SCREEN_WIDTH_MAIN >= 400) ? 80 : 40)) / 2;
|
||||
char tempstr[64];
|
||||
|
||||
static u32 state_prev = 0xFFFFFFFF;
|
||||
@ -69,33 +71,33 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
}
|
||||
|
||||
// top bar - current path & free/total storage
|
||||
DrawRectangle(TOP_SCREEN, 0, 0, SCREEN_WIDTH_TOP, 12, COLOR_TOP_BAR);
|
||||
DrawRectangle(MAIN_SCREEN, 0, 0, SCREEN_WIDTH_MAIN, 12, COLOR_TOP_BAR);
|
||||
if (strncmp(curr_path, "", 256) != 0) {
|
||||
char bytestr0[32];
|
||||
char bytestr1[32];
|
||||
TruncateString(tempstr, curr_path, 240 / FONT_WIDTH_EXT, 8);
|
||||
DrawStringF(TOP_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, tempstr);
|
||||
DrawStringF(TOP_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", "LOADING...");
|
||||
TruncateString(tempstr, curr_path, len_path / FONT_WIDTH_EXT, 8);
|
||||
DrawStringF(MAIN_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, tempstr);
|
||||
DrawStringF(MAIN_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", "LOADING...");
|
||||
FormatBytes(bytestr0, GetFreeSpace(curr_path));
|
||||
FormatBytes(bytestr1, GetTotalSpace(curr_path));
|
||||
snprintf(tempstr, 64, "%s/%s", bytestr0, bytestr1);
|
||||
DrawStringF(TOP_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", tempstr);
|
||||
DrawStringF(MAIN_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", tempstr);
|
||||
} else {
|
||||
DrawStringF(TOP_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "[root]");
|
||||
DrawStringF(TOP_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", FLAVOR);
|
||||
DrawStringF(MAIN_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "[root]");
|
||||
DrawStringF(MAIN_SCREEN, bartxt_rx, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", FLAVOR);
|
||||
}
|
||||
|
||||
// left top - current file info
|
||||
if (curr_pane) snprintf(tempstr, 63, "PANE #%lu", curr_pane);
|
||||
else snprintf(tempstr, 63, "CURRENT");
|
||||
DrawStringF(TOP_SCREEN, 2, info_start, COLOR_STD_FONT, COLOR_STD_BG, "[%s]", tempstr);
|
||||
DrawStringF(MAIN_SCREEN, 2, info_start, COLOR_STD_FONT, COLOR_STD_BG, "[%s]", tempstr);
|
||||
// file / entry name
|
||||
ResizeString(tempstr, curr_entry->name, 160 / FONT_WIDTH_EXT, 8, false);
|
||||
ResizeString(tempstr, curr_entry->name, len_info / FONT_WIDTH_EXT, 8, false);
|
||||
u32 color_current = COLOR_ENTRY(curr_entry);
|
||||
DrawStringF(TOP_SCREEN, 4, info_start + 12, color_current, COLOR_STD_BG, "%s", tempstr);
|
||||
DrawStringF(MAIN_SCREEN, 4, info_start + 12, color_current, COLOR_STD_BG, "%s", tempstr);
|
||||
// size (in Byte) or type desc
|
||||
if (curr_entry->type == T_DIR) {
|
||||
ResizeString(tempstr, "(dir)", 160 / FONT_WIDTH_EXT, 8, false);
|
||||
ResizeString(tempstr, "(dir)", len_info / FONT_WIDTH_EXT, 8, false);
|
||||
} else if (curr_entry->type == T_DOTDOT) {
|
||||
snprintf(tempstr, 21, "%20s", "");
|
||||
} else if (curr_entry->type == T_ROOT) {
|
||||
@ -107,39 +109,39 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
(drvtype & DRV_XORPAD) ? "XORpad" : (drvtype & DRV_MEMORY) ? "Memory" : (drvtype & DRV_ALIAS) ? "Alias" :
|
||||
(drvtype & DRV_CART) ? "Gamecart" : (drvtype & DRV_SEARCH) ? "Search" : ""),
|
||||
((drvtype & DRV_FAT) ? " FAT" : (drvtype & DRV_VIRTUAL) ? " Virtual" : ""));
|
||||
ResizeString(tempstr, drvstr, 160 / FONT_WIDTH_EXT, 8, false);
|
||||
ResizeString(tempstr, drvstr, len_info / FONT_WIDTH_EXT, 8, false);
|
||||
} else {
|
||||
char numstr[32];
|
||||
char bytestr[32];
|
||||
FormatNumber(numstr, curr_entry->size);
|
||||
snprintf(bytestr, 31, "%s Byte", numstr);
|
||||
ResizeString(tempstr, bytestr, 160 / FONT_WIDTH_EXT, 8, false);
|
||||
ResizeString(tempstr, bytestr, len_info / FONT_WIDTH_EXT, 8, false);
|
||||
}
|
||||
DrawStringF(TOP_SCREEN, 4, info_start + 12 + 10, color_current, COLOR_STD_BG, tempstr);
|
||||
DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10, color_current, COLOR_STD_BG, tempstr);
|
||||
// path of file (if in search results)
|
||||
if ((DriveType(curr_path) & DRV_SEARCH) && strrchr(curr_entry->path, '/')) {
|
||||
char dirstr[256];
|
||||
strncpy(dirstr, curr_entry->path, 256);
|
||||
*(strrchr(dirstr, '/')+1) = '\0';
|
||||
ResizeString(tempstr, dirstr, 160 / FONT_WIDTH_EXT, 8, false);
|
||||
DrawStringF(TOP_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, tempstr);
|
||||
ResizeString(tempstr, dirstr, len_info / FONT_WIDTH_EXT, 8, false);
|
||||
DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, tempstr);
|
||||
} else {
|
||||
ResizeString(tempstr, "", 160 / FONT_WIDTH_EXT, 8, false);
|
||||
DrawStringF(TOP_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, tempstr);
|
||||
ResizeString(tempstr, "", len_info / FONT_WIDTH_EXT, 8, false);
|
||||
DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, tempstr);
|
||||
}
|
||||
|
||||
// right top - clipboard
|
||||
DrawStringF(TOP_SCREEN, SCREEN_WIDTH_TOP - 160, info_start, COLOR_STD_FONT, COLOR_STD_BG, "%*s", 160 / FONT_WIDTH_EXT,
|
||||
(clipboard->n_entries) ? "[CLIPBOARD]" : "");
|
||||
DrawStringF(MAIN_SCREEN, SCREEN_WIDTH_MAIN - len_info, info_start, COLOR_STD_FONT, COLOR_STD_BG, "%*s",
|
||||
len_info / FONT_WIDTH_EXT, (clipboard->n_entries) ? "[CLIPBOARD]" : "");
|
||||
for (u32 c = 0; c < n_cb_show; c++) {
|
||||
u32 color_cb = COLOR_ENTRY(&(clipboard->entry[c]));
|
||||
ResizeString(tempstr, (clipboard->n_entries > c) ? clipboard->entry[c].name : "", 160 / FONT_WIDTH_EXT, 8, true);
|
||||
DrawStringF(TOP_SCREEN, SCREEN_WIDTH_TOP - 160 - 4, info_start + 12 + (c*10), color_cb, COLOR_STD_BG, tempstr);
|
||||
ResizeString(tempstr, (clipboard->n_entries > c) ? clipboard->entry[c].name : "", len_info / FONT_WIDTH_EXT, 8, true);
|
||||
DrawStringF(MAIN_SCREEN, SCREEN_WIDTH_MAIN - len_info - 4, info_start + 12 + (c*10), color_cb, COLOR_STD_BG, tempstr);
|
||||
}
|
||||
*tempstr = '\0';
|
||||
if (clipboard->n_entries > n_cb_show) snprintf(tempstr, 60, "+ %lu more", clipboard->n_entries - n_cb_show);
|
||||
DrawStringF(TOP_SCREEN, SCREEN_WIDTH_TOP - 160 - 4, info_start + 12 + (n_cb_show*10), COLOR_DARKGREY, COLOR_STD_BG, "%*s",
|
||||
160 / FONT_WIDTH_EXT, tempstr);
|
||||
DrawStringF(MAIN_SCREEN, SCREEN_WIDTH_MAIN - len_info - 4, info_start + 12 + (n_cb_show*10), COLOR_DARKGREY, COLOR_STD_BG,
|
||||
"%*s", len_info / FONT_WIDTH_EXT, tempstr);
|
||||
|
||||
// bottom: inctruction block
|
||||
char instr[512];
|
||||
@ -155,11 +157,11 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
|
||||
"R+\x1B\x1A - Switch to prev/next pane\n",
|
||||
(clipboard->n_entries) ? "SELECT - Clear Clipboard\n" : "SELECT - Restore Clipboard\n", // only if clipboard is full
|
||||
"START - Reboot / [+R] Poweroff\nHOME button for HOME menu"); // generic end part
|
||||
DrawStringF(TOP_SCREEN, instr_x, SCREEN_HEIGHT - 4 - GetDrawStringHeight(instr), COLOR_STD_FONT, COLOR_STD_BG, instr);
|
||||
DrawStringF(MAIN_SCREEN, instr_x, SCREEN_HEIGHT - 4 - GetDrawStringHeight(instr), COLOR_STD_FONT, COLOR_STD_BG, instr);
|
||||
}
|
||||
|
||||
void DrawDirContents(DirStruct* contents, u32 cursor, u32* scroll) {
|
||||
const int str_width = (SCREEN_WIDTH_BOT-3) / FONT_WIDTH_EXT;
|
||||
const int str_width = (SCREEN_WIDTH_ALT-3) / FONT_WIDTH_EXT;
|
||||
const u32 bar_height_min = 32;
|
||||
const u32 bar_width = 2;
|
||||
const u32 start_y = 2;
|
||||
@ -187,7 +189,7 @@ void DrawDirContents(DirStruct* contents, u32 cursor, u32* scroll) {
|
||||
snprintf(tempstr, str_width + 1, "%s%10.10s", namestr,
|
||||
(curr_entry->type == T_DIR) ? "(dir)" : (curr_entry->type == T_DOTDOT) ? "(..)" : bytestr);
|
||||
} else snprintf(tempstr, str_width + 1, "%-*.*s", str_width, str_width, "");
|
||||
DrawStringF(BOT_SCREEN, pos_x, pos_y, color_font, COLOR_STD_BG, tempstr);
|
||||
DrawStringF(ALT_SCREEN, pos_x, pos_y, color_font, COLOR_STD_BG, tempstr);
|
||||
pos_y += stp_y;
|
||||
}
|
||||
|
||||
@ -196,10 +198,10 @@ void DrawDirContents(DirStruct* contents, u32 cursor, u32* scroll) {
|
||||
if (bar_height < bar_height_min) bar_height = bar_height_min;
|
||||
u32 bar_pos = ((u64) *scroll * (SCREEN_HEIGHT - bar_height)) / (contents->n_entries - lines);
|
||||
|
||||
DrawRectangle(BOT_SCREEN, SCREEN_WIDTH_BOT - bar_width, 0, bar_width, bar_pos, COLOR_STD_BG);
|
||||
DrawRectangle(BOT_SCREEN, SCREEN_WIDTH_BOT - bar_width, bar_pos + bar_height, bar_width, SCREEN_WIDTH_BOT - (bar_pos + bar_height), COLOR_STD_BG);
|
||||
DrawRectangle(BOT_SCREEN, SCREEN_WIDTH_BOT - bar_width, bar_pos, bar_width, bar_height, COLOR_SIDE_BAR);
|
||||
} else DrawRectangle(BOT_SCREEN, SCREEN_WIDTH_BOT - bar_width, 0, bar_width, SCREEN_HEIGHT, COLOR_STD_BG);
|
||||
DrawRectangle(ALT_SCREEN, SCREEN_WIDTH_ALT - bar_width, 0, bar_width, bar_pos, COLOR_STD_BG);
|
||||
DrawRectangle(ALT_SCREEN, SCREEN_WIDTH_ALT - bar_width, bar_pos + bar_height, bar_width, SCREEN_WIDTH_ALT - (bar_pos + bar_height), COLOR_STD_BG);
|
||||
DrawRectangle(ALT_SCREEN, SCREEN_WIDTH_ALT - bar_width, bar_pos, bar_width, bar_height, COLOR_SIDE_BAR);
|
||||
} else DrawRectangle(ALT_SCREEN, SCREEN_WIDTH_ALT - bar_width, 0, bar_width, SCREEN_HEIGHT, COLOR_STD_BG);
|
||||
}
|
||||
|
||||
u32 SdFormatMenu(void) {
|
||||
@ -290,11 +292,15 @@ u32 HexViewer(const char* path) {
|
||||
int cursor = 0;
|
||||
|
||||
static bool show_instr = true;
|
||||
static const char* instr = "Hexeditor Controls:\n \n\x18\x19\x1A\x1B(+R) - Scroll\nR+Y - Switch view\nX - Search / goto...\nA - Enter edit mode\nA+\x18\x19\x1A\x1B - Edit value\nB - Exit\n";
|
||||
if (show_instr) { // show one time instructions
|
||||
ShowPrompt(false, "Hexeditor Controls:\n \n\x18\x19\x1A\x1B(+R) - Scroll\nR+Y - Switch view\nX - Search / goto...\nA - Enter edit mode\nA+\x18\x19\x1A\x1B - Edit value\nB - Exit\n");
|
||||
ShowPrompt(false, instr);
|
||||
show_instr = false;
|
||||
}
|
||||
|
||||
#ifdef SWITCH_SCREENS
|
||||
ShowString(instr);
|
||||
#endif
|
||||
memcpy(bottom_cpy, BOT_SCREEN, (SCREEN_HEIGHT * SCREEN_WIDTH_BOT * 3));
|
||||
|
||||
while (true) {
|
||||
@ -361,8 +367,9 @@ u32 HexViewer(const char* path) {
|
||||
rows = (dual_screen ? 2 : 1) * SCREEN_HEIGHT / (FONT_HEIGHT_EXT + (2*vpad));
|
||||
total_shown = rows * cols;
|
||||
last_mode = mode;
|
||||
ClearScreenF(true, dual_screen, COLOR_STD_BG);
|
||||
if (!dual_screen) memcpy(BOT_SCREEN, bottom_cpy, (SCREEN_HEIGHT * SCREEN_WIDTH_BOT * 3));
|
||||
ClearScreen(TOP_SCREEN, COLOR_STD_BG);
|
||||
if (dual_screen) ClearScreen(BOT_SCREEN, COLOR_STD_BG);
|
||||
else memcpy(BOT_SCREEN, bottom_cpy, (SCREEN_HEIGHT * SCREEN_WIDTH_BOT * 3));
|
||||
}
|
||||
// fix offset (if required)
|
||||
if (offset % cols) offset -= (offset % cols); // fix offset (align to cols)
|
||||
@ -445,7 +452,7 @@ u32 HexViewer(const char* path) {
|
||||
u8 data[64] = { 0 };
|
||||
FileGetData(path, data, found_size, found_offset);
|
||||
found_offset = FileFindData(path, data, found_size, found_offset + 1);
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
ClearScreen(TOP_SCREEN, COLOR_STD_BG);
|
||||
if (found_offset == (u32) -1) {
|
||||
ShowPrompt(false, "Not found!");
|
||||
found_size = 0;
|
||||
@ -464,7 +471,7 @@ u32 HexViewer(const char* path) {
|
||||
if (ShowStringPrompt(string, 64 + 1, "Enter search string below.\n(R+X to repeat search)", (unsigned int) offset)) {
|
||||
found_size = strnlen(string, 64);
|
||||
found_offset = FileFindData(path, (u8*) string, found_size, offset);
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
ClearScreen(TOP_SCREEN, COLOR_STD_BG);
|
||||
if (found_offset == (u32) -1) {
|
||||
ShowPrompt(false, "Not found!");
|
||||
found_size = 0;
|
||||
@ -477,7 +484,7 @@ u32 HexViewer(const char* path) {
|
||||
if (ShowDataPrompt(data, &size, "Enter search data below.\n(R+X to repeat search)", (unsigned int) offset)) {
|
||||
found_size = size;
|
||||
found_offset = FileFindData(path, data, size, offset);
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
ClearScreen(TOP_SCREEN, COLOR_STD_BG);
|
||||
if (found_offset == (u32) -1) {
|
||||
ShowPrompt(false, "Not found!");
|
||||
found_size = 0;
|
||||
@ -536,8 +543,12 @@ u32 HexViewer(const char* path) {
|
||||
}
|
||||
}
|
||||
|
||||
ClearScreenF(true, false, COLOR_STD_BG);
|
||||
ClearScreen(TOP_SCREEN, COLOR_STD_BG);
|
||||
#ifndef SWITCH_SCREENS
|
||||
memcpy(BOT_SCREEN, bottom_cpy, (SCREEN_HEIGHT * SCREEN_WIDTH_BOT * 3));
|
||||
#else
|
||||
ClearScreen(BOT_SCREEN, COLOR_STD_BG);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user