From 38bc85e32912b3c1e1d79d70a2910a0b9333ad85 Mon Sep 17 00:00:00 2001 From: PeachyPeach <72323920+PeachyPeachSM64@users.noreply.github.com> Date: Mon, 19 Sep 2022 02:29:05 +0200 Subject: [PATCH] Main menu: separate Rom Hacks from regular mods (#190) --- src/pc/djui/djui_panel_host.c | 10 +++++++++- src/pc/djui/djui_panel_host_mods.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/pc/djui/djui_panel_host.c b/src/pc/djui/djui_panel_host.c index f6b3e049b..a638bc6dc 100644 --- a/src/pc/djui/djui_panel_host.c +++ b/src/pc/djui/djui_panel_host.c @@ -60,7 +60,7 @@ static void djui_panel_host_do_host(struct DjuiBase* caller) { } void djui_panel_host_create(struct DjuiBase* caller) { - f32 bodyHeight = 32 * 3 + 64 * 3 + 16 * 5; + f32 bodyHeight = 32 * 4 + 64 * 4 + 16 * 5; struct DjuiBase* defaultBase = NULL; struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\H\\#1be700\\O\\#00b3ff\\S\\#ffef00\\T"); @@ -130,6 +130,14 @@ void djui_panel_host_create(struct DjuiBase* caller) { djui_base_set_size(&button2->base, 1.0f, 64); djui_base_set_alignment(&button2->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); djui_interactable_hook_click(&button2->base, djui_panel_host_mods_create); + button2->base.tag = 0; + + struct DjuiButton* button3 = djui_button_create(&body->base, "Rom-Hacks"); + djui_base_set_size_type(&button3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&button3->base, 1.0f, 64); + djui_base_set_alignment(&button3->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); + djui_interactable_hook_click(&button3->base, djui_panel_host_mods_create); + button3->base.tag = 1; struct DjuiRect* rect3 = djui_rect_create(&body->base); djui_base_set_size_type(&rect3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); diff --git a/src/pc/djui/djui_panel_host_mods.c b/src/pc/djui/djui_panel_host_mods.c index 09d49d086..df1564dcc 100644 --- a/src/pc/djui/djui_panel_host_mods.c +++ b/src/pc/djui/djui_panel_host_mods.c @@ -64,13 +64,13 @@ static void djui_mod_checkbox_on_value_change(UNUSED struct DjuiBase* base) { u16 index = 0; struct DjuiBaseChild* node = sModLayout->base.child; while (node != NULL) { + index = node->base->tag; if (index >= gLocalMods.entryCount) { break; } struct Mod* mod = gLocalMods.entries[index]; djui_base_set_enabled(node->base, mod->selectable); // iterate - index++; node = node->next; } } @@ -87,11 +87,15 @@ static void djui_panel_host_mods_destroy(struct DjuiBase* base) { void djui_panel_host_mods_create(struct DjuiBase* caller) { f32 bodyHeight = (416) + 64 * 1 + 16 * 1; + bool isRomHacks = (caller->tag == 1); mods_update_selectable(); struct DjuiBase* defaultBase = NULL; - struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\M\\#1be700\\O\\#00b3ff\\D\\#ffef00\\S"); + struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, isRomHacks ? + "\\#ff0800\\R\\#1be700\\O\\#00b3ff\\M \\#ffef00\\H\\#ff0800\\A\\#1be700\\C\\#00b3ff\\K\\#ffef00\\S" : + "\\#ff0800\\M\\#1be700\\O\\#00b3ff\\D\\#ffef00\\S" + ); struct DjuiFlowLayout* body = (struct DjuiFlowLayout*)djui_three_panel_get_body(panel); { struct DjuiPaginated* paginated = djui_paginated_create(&body->base, 8); @@ -99,6 +103,9 @@ void djui_panel_host_mods_create(struct DjuiBase* caller) { struct DjuiBase* layoutBase = &paginated->layout->base; for (int i = 0; i < gLocalMods.entryCount; i++) { struct Mod* mod = gLocalMods.entries[i]; + if (isRomHacks != (mod->incompatible && strstr(mod->incompatible, "romhack"))) { + continue; + } struct DjuiCheckbox* checkbox = djui_checkbox_create(layoutBase, mod->name, &mod->enabled); checkbox->base.tag = i; djui_base_set_size_type(&checkbox->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);