mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-22 18:06:40 +00:00
[Menu] Add captions and seperators
Additionally, skip selection of them to retain flow and maintain auto scroll.
This commit is contained in:
parent
03729bddd5
commit
997e250c43
3 changed files with 64 additions and 13 deletions
22
ipl/main.c
22
ipl/main.c
|
@ -1231,9 +1231,13 @@ void about()
|
|||
|
||||
ment_t ment_cinfo[] = {
|
||||
MDEF_BACK(),
|
||||
MDEF_CHGLINE(),
|
||||
MDEF_CAPTION("---- SoC Info ----", 0xFFE6B90A),
|
||||
MDEF_HANDLER("Print fuse info", print_fuseinfo),
|
||||
MDEF_HANDLER("Print kfuse info", print_kfuseinfo),
|
||||
MDEF_HANDLER("Print TSEC keys", print_tsec_key),
|
||||
MDEF_CHGLINE(),
|
||||
MDEF_CAPTION("-- Storage Info --", 0xFFE6B90A),
|
||||
MDEF_HANDLER("Print eMMC info", print_mmc_info),
|
||||
MDEF_HANDLER("Print SD Card info", print_sdcard_info),
|
||||
MDEF_END()
|
||||
|
@ -1244,6 +1248,7 @@ menu_t menu_cinfo = {
|
|||
};
|
||||
|
||||
ment_t ment_autorcm[] = {
|
||||
MDEF_CAPTION("WARNING: This corrupts your BOOT0 partition!", 0xFF00FFE6),
|
||||
MDEF_BACK(),
|
||||
MDEF_BACK(),
|
||||
MDEF_BACK(),
|
||||
|
@ -1263,11 +1268,19 @@ menu_t menu_autorcm = {
|
|||
|
||||
ment_t ment_tools[] = {
|
||||
MDEF_BACK(),
|
||||
MDEF_CHGLINE(),
|
||||
MDEF_CAPTION("------ Full --------", 0xFFE6B90A),
|
||||
MDEF_HANDLER("Dump RAW eMMC", dump_emmc_rawnand),
|
||||
MDEF_HANDLER("Dump eMMC BOOT", dump_emmc_boot),
|
||||
MDEF_CHGLINE(),
|
||||
MDEF_CAPTION("-- GP Partitions --", 0xFFE6B90A),
|
||||
MDEF_HANDLER("Dump eMMC SYS", dump_emmc_system),
|
||||
MDEF_HANDLER("Dump eMMC USER", dump_emmc_user),
|
||||
MDEF_HANDLER("Dump eMMC BOOT", dump_emmc_boot),
|
||||
MDEF_CHGLINE(),
|
||||
MDEF_CAPTION("------ Misc -------", 0xFFE6B90A),
|
||||
MDEF_HANDLER("Dump package1", dump_package1),
|
||||
MDEF_CHGLINE(),
|
||||
MDEF_CAPTION("---- Dangerous ----", 0xFF0000FF),
|
||||
MDEF_MENU("AutoRCM", &menu_autorcm),
|
||||
MDEF_END()
|
||||
};
|
||||
|
@ -1279,11 +1292,14 @@ menu_t menu_tools = {
|
|||
|
||||
ment_t ment_top[] = {
|
||||
MDEF_HANDLER("Launch firmware", launch_firmware),
|
||||
MDEF_CAPTION("---------------", 0xFF444444),
|
||||
MDEF_MENU("Tools", &menu_tools),
|
||||
MDEF_MENU("Console info", &menu_cinfo),
|
||||
MDEF_HANDLER("Reboot (normal)", reboot_normal),
|
||||
MDEF_HANDLER("Reboot (rcm)", reboot_rcm),
|
||||
MDEF_CAPTION("---------------", 0xFF444444),
|
||||
MDEF_HANDLER("Reboot (Normal)", reboot_normal),
|
||||
MDEF_HANDLER("Reboot (RCM)", reboot_rcm),
|
||||
MDEF_HANDLER("Power off", power_off),
|
||||
MDEF_CAPTION("---------------", 0xFF444444),
|
||||
MDEF_HANDLER("About", about),
|
||||
MDEF_END()
|
||||
};
|
||||
|
|
36
ipl/tui.c
36
ipl/tui.c
|
@ -41,6 +41,7 @@ void tui_pbar(gfx_con_t *con, int x, int y, u32 val)
|
|||
void *tui_do_menu(gfx_con_t *con, menu_t *menu)
|
||||
{
|
||||
int idx = 0, cnt;
|
||||
int prev_idx = 0;
|
||||
|
||||
gfx_clear(con->gfx_ctxt, 0xFF1B1B1B);
|
||||
|
||||
|
@ -50,6 +51,31 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
|
|||
gfx_con_setpos(con, menu->x, menu->y);
|
||||
gfx_printf(con, "[%s]\n\n", menu->caption);
|
||||
|
||||
// Skip caption or seperator lines selection
|
||||
while (menu->ents[idx].type == MENT_CAPTION ||
|
||||
menu->ents[idx].type == MENT_CHGLINE)
|
||||
{
|
||||
if (prev_idx <= idx || (!idx && prev_idx == cnt - 1))
|
||||
{
|
||||
idx++;
|
||||
if (idx > (cnt - 1))
|
||||
{
|
||||
idx = 0;
|
||||
prev_idx = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
idx--;
|
||||
if (idx < 0)
|
||||
{
|
||||
idx = cnt - 1;
|
||||
prev_idx = cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
prev_idx = idx;
|
||||
|
||||
// Draw the menu
|
||||
for (cnt = 0; menu->ents[cnt].type != MENT_END; cnt++)
|
||||
{
|
||||
|
@ -57,11 +83,13 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
|
|||
gfx_con_setcol(con, 0xFF1B1B1B, 1, 0xFFCCCCCC);
|
||||
else
|
||||
gfx_con_setcol(con, 0xFFCCCCCC, 1, 0xFF1B1B1B);
|
||||
con->x += 8;
|
||||
gfx_printf(con, "%s", menu->ents[cnt].caption);
|
||||
if (cnt != idx && menu->ents[cnt].type == MENT_CAPTION)
|
||||
gfx_printf(con, "%k %s", menu->ents[cnt].color, menu->ents[cnt].caption);
|
||||
else
|
||||
gfx_printf(con, " %s", menu->ents[cnt].caption);
|
||||
if(menu->ents[cnt].type == MENT_MENU)
|
||||
gfx_printf(con, "%k...", 0xFFEE9900);
|
||||
gfx_putc(con, '\n');
|
||||
gfx_printf(con, " \n");
|
||||
}
|
||||
gfx_con_setcol(con, 0xFFCCCCCC, 1, 0xFF1B1B1B);
|
||||
gfx_putc(con, '\n');
|
||||
|
@ -93,6 +121,8 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
|
|||
case MENT_BACK:
|
||||
return NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
gfx_clear(con->gfx_ctxt, 0xFF1B1B1B);
|
||||
}
|
||||
|
|
19
ipl/tui.h
19
ipl/tui.h
|
@ -20,16 +20,19 @@
|
|||
#include "types.h"
|
||||
#include "gfx.h"
|
||||
|
||||
#define MENT_END 0
|
||||
#define MENT_END 0
|
||||
#define MENT_HANDLER 1
|
||||
#define MENT_MENU 2
|
||||
#define MENT_CHOICE 3
|
||||
#define MENT_BACK 4
|
||||
#define MENT_MENU 2
|
||||
#define MENT_CHOICE 3
|
||||
#define MENT_BACK 4
|
||||
#define MENT_CAPTION 5
|
||||
#define MENT_CHGLINE 6
|
||||
|
||||
typedef struct _ment_t
|
||||
{
|
||||
u32 type;
|
||||
const char *caption;
|
||||
u32 color;
|
||||
void *data;
|
||||
union
|
||||
{
|
||||
|
@ -47,10 +50,12 @@ typedef struct _menu_t
|
|||
} menu_t;
|
||||
|
||||
#define MDEF_END() {MENT_END}
|
||||
#define MDEF_HANDLER(caption, _handler) { MENT_HANDLER, caption, NULL, { .handler = _handler } }
|
||||
#define MDEF_HANDLER_EX(caption, data, _handler) { MENT_HANDLER, caption, data, { .handler = _handler } }
|
||||
#define MDEF_MENU(caption, _menu) { MENT_MENU, caption, NULL, { .menu = _menu } }
|
||||
#define MDEF_HANDLER(caption, _handler) { MENT_HANDLER, caption, 0, NULL, { .handler = _handler } }
|
||||
#define MDEF_HANDLER_EX(caption, data, _handler) { MENT_HANDLER, caption, 0, data, { .handler = _handler } }
|
||||
#define MDEF_MENU(caption, _menu) { MENT_MENU, caption, 0, NULL, { .menu = _menu } }
|
||||
#define MDEF_BACK() { MENT_BACK, "Back" }
|
||||
#define MDEF_CAPTION(caption, color) { MENT_CAPTION, caption, color }
|
||||
#define MDEF_CHGLINE() {MENT_CHGLINE}
|
||||
|
||||
void tui_pbar(gfx_con_t *con, int x, int y, u32 val);
|
||||
void *tui_do_menu(gfx_con_t *con, menu_t *menu);
|
||||
|
|
Loading…
Reference in a new issue