Revised instructions, more cosmetics

This commit is contained in:
d0k3 2016-03-01 17:13:13 +01:00
parent bf19767a82
commit dbc7015d2a
2 changed files with 21 additions and 26 deletions

View File

@ -181,11 +181,11 @@ bool ShowPrompt(bool ask, const char *format, ...)
str_width = GetDrawStringWidth(str); str_width = GetDrawStringWidth(str);
str_height = GetDrawStringHeight(str) + (2 * 10); str_height = GetDrawStringHeight(str) + (2 * 10);
x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2; x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - (str_height+20)) / 2; y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2;
ClearScreenF(true, false, COLOR_STD_BG); ClearScreenF(true, false, COLOR_STD_BG);
DrawStringF(true, x, y, COLOR_STD_FONT, COLOR_STD_BG, str); DrawStringF(true, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
DrawStringF(true, x, y + str_height, COLOR_STD_FONT, COLOR_STD_BG, (ask) ? "(<A> yes, <B> no)" : "(<A> to continue)"); DrawStringF(true, x, y + str_height - (1*10), COLOR_STD_FONT, COLOR_STD_BG, (ask) ? "(<A> yes, <B> no)" : "(<A> to continue)");
while (true) { while (true) {
u32 pad_state = InputWait(); u32 pad_state = InputWait();
@ -226,17 +226,17 @@ bool ShowUnlockSequence(u32 seqlvl, const char *format, ...) {
va_end(va); va_end(va);
str_width = GetDrawStringWidth(str); str_width = GetDrawStringWidth(str);
str_height = GetDrawStringHeight(str) + (2 * 10); str_height = GetDrawStringHeight(str) + (3*10);
x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2; x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2;
y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - (str_height + 30)) / 2; y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - (str_height)) / 2;
ClearScreenF(true, false, COLOR_STD_BG); ClearScreenF(true, false, COLOR_STD_BG);
DrawStringF(true, x, y, COLOR_STD_FONT, COLOR_STD_BG, str); DrawStringF(true, x, y, COLOR_STD_FONT, COLOR_STD_BG, str);
DrawStringF(true, x, y + str_height, COLOR_STD_FONT, COLOR_STD_BG, "To proceed, enter this:"); DrawStringF(true, x, y + str_height - (2*10), COLOR_STD_FONT, COLOR_STD_BG, "To proceed, enter this:");
while (true) { while (true) {
for (u32 n = 0; n < len; n++) { for (u32 n = 0; n < len; n++) {
DrawStringF(true, x + (n*4*8), y + str_height + 10, DrawStringF(true, x + (n*4*8), y + str_height - (1*10),
(lvl > n) ? seqcolors[seqlvl] : COLOR_GREY, COLOR_STD_BG, "<%c>", seqsymbols[seqlvl][n]); (lvl > n) ? seqcolors[seqlvl] : COLOR_GREY, COLOR_STD_BG, "<%c>", seqsymbols[seqlvl][n]);
} }
if (lvl == len) if (lvl == len)

View File

@ -3,22 +3,21 @@
#include "hid.h" #include "hid.h"
#include "fs.h" #include "fs.h"
#define COLOR_TOP_BAR ((GetWritePermissions() == 0) ? COLOR_WHITE : (GetWritePermissions() == 1) ? COLOR_BRIGHTGREEN : (GetWritePermissions() == 2) ? COLOR_BRIGHTYELLOW : COLOR_BRIGHTRED) #define COLOR_TOP_BAR ((GetWritePermissions() == 0) ? COLOR_WHITE : (GetWritePermissions() == 1) ? COLOR_BRIGHTGREEN : (GetWritePermissions() == 2) ? COLOR_BRIGHTYELLOW : COLOR_RED)
#define COLOR_SIDE_BAR COLOR_DARKGREY #define COLOR_SIDE_BAR COLOR_DARKGREY
#define COLOR_MARKED COLOR_TINTEDYELLOW #define COLOR_MARKED COLOR_TINTEDYELLOW
#define COLOR_FILE COLOR_TINTEDGREEN #define COLOR_FILE COLOR_TINTEDGREEN
#define COLOR_DIR COLOR_TINTEDBLUE #define COLOR_DIR COLOR_TINTEDBLUE
#define COLOR_ROOT COLOR_GREY #define COLOR_ROOT COLOR_GREY
void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* clipboard, bool switched) { void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* clipboard) {
const u32 info_start = 18; const u32 info_start = 18;
static u32 state_prev = 0xFFFFFFFF; static u32 state_prev = 0xFFFFFFFF;
u32 state_curr = u32 state_curr =
((*curr_path) ? (1<<0) : 0) | ((*curr_path) ? (1<<0) : 0) |
((clipboard->n_entries) ? (1<<1) : 0) | ((clipboard->n_entries) ? (1<<1) : 0) |
((switched) ? (1<<2) : 0) | (GetWritePermissions()<<2);
(GetWritePermissions()<<3);
char bytestr0[32]; char bytestr0[32];
char bytestr1[32]; char bytestr1[32];
@ -70,21 +69,15 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
// bottom: inctruction block // bottom: inctruction block
char instr[256]; char instr[256];
snprintf(instr, 256, "%s%s%s%s%s%s", snprintf(instr, 256, "%s%s%s%s",
"GodMode 9 v0.0.4\n", // generic start part "GodMode9 File Explorer v0.0.4\n", // generic start part
(*curr_path && !switched) ? "<R> (hold) - Switch commands\n<L> (+<\x18\x19\x1A\x1B>) - Mark entries\n" : (*curr_path) ? "L - MARK files (use with \x18\x19\x1A\x1B)\nX - DELETE / [+R] RENAME file(s)\nY - COPY file(s) / [+R] CREATE dir\n" :
(*curr_path && switched) ? "<R> (rel.) - Switch commands\n<L> - Make a Screenshot\n" : (GetWritePermissions() <= 1) ? "X - Unlock EmuNAND writing\nY - Unlock SysNAND writing\n" :
"<R+L> - Make a Screenshot\n", (GetWritePermissions() == 2) ? "X - Relock EmuNAND writing\nY - Unlock SysNAND writing\n" :
(!(*curr_path)) ? "" : "X - Relock EmuNAND writing\nY - Relock SysNAND writing\n",
(!switched) ? "<X> - DELETE file(s)\n<Y> - ADD file(s) to clipboard\n" : (clipboard->n_entries) ? "SELECT - Clear Clipboard\n" : "", // only if clipboard is full
"<X> - RENAME file\n<Y> - CREATE directory\n", "R+L - Make a SCREENSHOT\nSTART - Reboot / [+\x1B] Poweroff"); // generic end part
(*curr_path) ? "" : DrawStringF(true, (SCREEN_WIDTH_TOP - GetDrawStringWidth(instr)) / 2, SCREEN_HEIGHT - 4 - GetDrawStringHeight(instr), COLOR_STD_FONT, COLOR_STD_BG, instr);
(GetWritePermissions() <= 1) ? "<X> - Unlock EmuNAND writing\n<Y> - Unlock SysNAND writing\n" :
(GetWritePermissions() == 2) ? "<X> - Relock EmuNAND writing\n<Y> - Unlock SysNAND writing\n" :
"<X> - Relock EmuNAND writing\n<Y> - Relock SysNAND writing\n",
(clipboard->n_entries) ? "<SELECT> - Clear Clipboard\n" : "", // only if clipboard is full
"<START/+\x1B> - Reboot/Poweroff"); // generic end part
DrawStringF(true, (SCREEN_WIDTH_TOP - GetDrawStringWidth(instr)) / 2, SCREEN_HEIGHT - 2 - GetDrawStringHeight(instr), COLOR_STD_FONT, COLOR_STD_BG, instr);
} }
void DrawDirContents(DirStruct* contents, u32 cursor) { void DrawDirContents(DirStruct* contents, u32 cursor) {
@ -151,7 +144,7 @@ u32 GodMode() {
GetDirContents(current_dir, ""); GetDirContents(current_dir, "");
clipboard->n_entries = 0; clipboard->n_entries = 0;
while (true) { // this is the main loop while (true) { // this is the main loop
DrawUserInterface(current_path, &(current_dir->entry[cursor]), clipboard, switched); DrawUserInterface(current_path, &(current_dir->entry[cursor]), clipboard);
DrawDirContents(current_dir, cursor); DrawDirContents(current_dir, cursor);
u32 pad_state = InputWait(); u32 pad_state = InputWait();
switched = (pad_state & BUTTON_R1); switched = (pad_state & BUTTON_R1);
@ -182,8 +175,10 @@ u32 GodMode() {
cursor = (cursor >= quick_stp) ? cursor - quick_stp : 0; cursor = (cursor >= quick_stp) ? cursor - quick_stp : 0;
} else if (pad_state & BUTTON_RIGHT) { // mark all entries } else if (pad_state & BUTTON_RIGHT) { // mark all entries
for (u32 c = 0; c < current_dir->n_entries; c++) current_dir->entry[c].marked = 1; for (u32 c = 0; c < current_dir->n_entries; c++) current_dir->entry[c].marked = 1;
mark_setting = 1;
} else if (pad_state & BUTTON_LEFT) { // unmark all entries } else if (pad_state & BUTTON_LEFT) { // unmark all entries
for (u32 c = 0; c < current_dir->n_entries; c++) current_dir->entry[c].marked = 0; for (u32 c = 0; c < current_dir->n_entries; c++) current_dir->entry[c].marked = 0;
mark_setting = 0;
} else if (switched && (pad_state & BUTTON_L1)) { // switched L -> screenshot } else if (switched && (pad_state & BUTTON_L1)) { // switched L -> screenshot
CreateScreenshot(); CreateScreenshot();
ClearScreenF(true, true, COLOR_STD_BG); ClearScreenF(true, true, COLOR_STD_BG);