#include "godmode.h" #include "draw.h" #include "hid.h" #include "fs.h" #define COLOR_TOP_BAR ((GetWritePermissions() == 0) ? COLOR_WHITE : (GetWritePermissions() == 1) ? COLOR_BRIGHTGREEN : (GetWritePermissions() == 2) ? COLOR_BRIGHTYELLOW : COLOR_BRIGHTRED) #define COLOR_SIDE_BAR COLOR_DARKGREY #define COLOR_MARKED COLOR_TINTEDYELLOW #define COLOR_FILE COLOR_TINTEDGREEN #define COLOR_DIR COLOR_TINTEDBLUE #define COLOR_ROOT COLOR_GREY void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* clipboard, bool switched) { const u32 info_start = 18; static u32 state_prev = 0xFFFFFFFF; u32 state_curr = ((*curr_path) ? (1<<0) : 0) | ((clipboard->n_entries) ? (1<<1) : 0) | ((switched) ? (1<<2) : 0) | (GetWritePermissions()<<3); char bytestr0[32]; char bytestr1[32]; char tempstr[64]; if (state_prev != state_curr) { ClearScreenF(true, false, COLOR_STD_BG); state_prev = state_curr; } // top bar - current path & free/total storage DrawRectangleF(true, 0, 0, SCREEN_WIDTH_TOP, 12, COLOR_TOP_BAR); if (strncmp(curr_path, "", 256) != 0) { TruncateString(tempstr, curr_path, 30, 8); DrawStringF(true, 2, 2, COLOR_STD_BG, COLOR_TOP_BAR, tempstr); DrawStringF(true, 30 * 8 + 4, 2, 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(true, 30 * 8 + 4, 2, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", tempstr); } else { DrawStringF(true, 2, 2, COLOR_STD_BG, COLOR_TOP_BAR, "[root]"); DrawStringF(true, 30 * 8 + 6, 2, COLOR_STD_BG, COLOR_TOP_BAR, "%19.19s", "GodMode9"); } // left top - current file info DrawStringF(true, 2, info_start, COLOR_STD_FONT, COLOR_STD_BG, "[CURRENT]"); ResizeString(tempstr, curr_entry->name, 20, 8, false); u32 color_current = (curr_entry->marked) ? COLOR_MARKED : (curr_entry->type == T_FAT_ROOT) ? COLOR_ROOT : (curr_entry->type == T_FAT_DIR) ? COLOR_DIR : COLOR_FILE; DrawStringF(true, 4, info_start + 12, color_current, COLOR_STD_BG, "%s", tempstr); if (curr_entry->type == T_FAT_DIR) { ResizeString(tempstr, "(dir)", 20, 8, false); } else { FormatBytes(bytestr0, curr_entry->size); ResizeString(tempstr, bytestr0, 20, 8, false); } DrawStringF(true, 4, info_start + 12 + 10, color_current, COLOR_STD_BG, tempstr); // right top - clipboard DrawStringF(true, SCREEN_WIDTH_TOP - (20*8), info_start, COLOR_STD_FONT, COLOR_STD_BG, "%20s", (clipboard->n_entries) ? "[CLIPBOARD]" : ""); for (u32 c = 0; c < 10; c++) { ResizeString(tempstr, (clipboard->n_entries > c) ? clipboard->entry[c].name : "", 20, 8, true); DrawStringF(true, SCREEN_WIDTH_TOP - (20*8) - 4, info_start + 12 + (c*10), (clipboard->entry[c].type == T_FAT_FILE) ? COLOR_FILE : COLOR_DIR, COLOR_STD_BG, tempstr); } *tempstr = '\0'; if (clipboard->n_entries > 10) snprintf(tempstr, 60, "+ %lu more", clipboard->n_entries - 10); DrawStringF(true, SCREEN_WIDTH_TOP - (20*8) - 4, info_start + 12 + (10*10), COLOR_DARKGREY, COLOR_STD_BG, "%20s", tempstr); // bottom: inctruction block char instr[256]; snprintf(instr, 256, "%s%s%s%s%s%s", "GodMode 9 v0.0.4\n", // generic start part (*curr_path && !switched) ? " (hold) - Switch commands\n (+<\x18\x19\x1A\x1B>) - Mark entries\n" : (*curr_path && switched) ? " (rel.) - Switch commands\n - Make a Screenshot\n" : " - Make a Screenshot\n", (!(*curr_path)) ? "" : (!switched) ? " - DELETE file(s)\n - ADD file(s) to clipboard\n" : " - RENAME file\n - CREATE directory\n", (*curr_path) ? "" : (GetWritePermissions() <= 1) ? " - Unlock EmuNAND writing\n - Unlock SysNAND writing\n" : (GetWritePermissions() == 2) ? " - Relock EmuNAND writing\n - Unlock SysNAND writing\n" : " - Relock EmuNAND writing\n - Relock SysNAND writing\n", (clipboard->n_entries) ? "