From 403a90e82b6aadede1db1a90fe6e30de0511ef8a Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 10 Mar 2022 18:16:12 -0800 Subject: [PATCH] Added dynos model packs to djui interface --- data/dynos.cpp.h | 3 +++ data/dynos_coop.c.h | 5 ++++ data/dynos_coop_c.cpp | 22 +++++++++++++++++ data/dynos_gfx_init.cpp | 7 ++++++ data/dynos_gfx_update.cpp | 13 ++++++---- data/dynos_opt.cpp | 2 +- src/pc/djui/djui.h | 1 + src/pc/djui/djui_base.h | 1 + src/pc/djui/djui_panel_display.c | 7 +++++- src/pc/djui/djui_panel_dynos.c | 42 ++++++++++++++++++++++++++++++++ src/pc/djui/djui_panel_dynos.h | 4 +++ 11 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 src/pc/djui/djui_panel_dynos.c create mode 100644 src/pc/djui/djui_panel_dynos.h diff --git a/data/dynos.cpp.h b/data/dynos.cpp.h index 22d079a7..a1076895 100644 --- a/data/dynos.cpp.h +++ b/data/dynos.cpp.h @@ -637,6 +637,9 @@ u8 *DynOS_Gfx_TextureConvertToRGBA32(const u8 *aData, u64 aLength, s32 aFormat, bool DynOS_Gfx_ImportTexture(void **aOutput, void *aPtr, s32 aTile, void *aGfxRApi, void **aHashMap, void *aPool, u32 *aPoolPos, u32 aPoolSize); Array &DynOS_Gfx_GetActorList(); Array &DynOS_Gfx_GetPacks(); +#ifdef COOP +Array &DynOS_Gfx_GetPacksEnabled(); +#endif Array DynOS_Gfx_Init(); void DynOS_Gfx_Update(); void DynOS_Gfx_SwapAnimations(void *aPtr); diff --git a/data/dynos_coop.c.h b/data/dynos_coop.c.h index 0f5c569c..1d1f59b4 100644 --- a/data/dynos_coop.c.h +++ b/data/dynos_coop.c.h @@ -5,6 +5,11 @@ bool dynos_warp_to_level(s32 aLevel, s32 aArea, s32 aAct); +int dynos_packs_get_count(void); +const char* dynos_packs_get(s32 index); +bool dynos_packs_get_enabled(s32 index); +void dynos_packs_set_enabled(s32 index, bool value); + #endif #endif #endif diff --git a/data/dynos_coop_c.cpp b/data/dynos_coop_c.cpp index 5efd8055..259cb2c0 100644 --- a/data/dynos_coop_c.cpp +++ b/data/dynos_coop_c.cpp @@ -1,10 +1,32 @@ #ifdef COOP #include "dynos.cpp.h" + extern "C" { bool dynos_warp_to_level(s32 aLevel, s32 aArea, s32 aAct) { return DynOS_Warp_ToLevel(aLevel, aArea, aAct); } +// -- dynos packs -- // + +#define DYNOS_PACK_PATH_SPLIT_LEN 12 + +int dynos_packs_get_count(void) { + return DynOS_Gfx_GetPacks().Count(); +} + +const char* dynos_packs_get(s32 index) { + std::string path = DynOS_Gfx_GetPacks()[index]->mPath; + return path.substr(path.find(DYNOS_PACKS_FOLDER) + DYNOS_PACK_PATH_SPLIT_LEN).c_str(); +} + +bool dynos_packs_get_enabled(s32 index) { + return DynOS_Gfx_GetPacksEnabled()[index]; +} + +void dynos_packs_set_enabled(s32 index, bool value) { + DynOS_Gfx_GetPacksEnabled()[index] = value; +} + } #endif diff --git a/data/dynos_gfx_init.cpp b/data/dynos_gfx_init.cpp index 5c0ea536..0bf93ebc 100644 --- a/data/dynos_gfx_init.cpp +++ b/data/dynos_gfx_init.cpp @@ -10,6 +10,13 @@ Array &DynOS_Gfx_GetPacks() { return sPacks; } +#ifdef COOP +Array &DynOS_Gfx_GetPacksEnabled() { + static Array sPacksEnabled; + return sPacksEnabled; +} +#endif + Array DynOS_Gfx_Init() { // Alloc and init the actors gfx list diff --git a/data/dynos_gfx_update.cpp b/data/dynos_gfx_update.cpp index ae9c1bee..9116ebe9 100644 --- a/data/dynos_gfx_update.cpp +++ b/data/dynos_gfx_update.cpp @@ -103,16 +103,19 @@ void DynOS_Gfx_Update() { if (gObjectLists) { // Check packs +#ifdef COOP + Array &_Enabled = DynOS_Gfx_GetPacksEnabled(); + const Array &pDynosPacks = DynOS_Gfx_GetPacks(); + while (_Enabled.Count() < pDynosPacks.Count()) { + _Enabled.Add(true); + } +#else Array _Enabled; const Array &pDynosPacks = DynOS_Gfx_GetPacks(); for (s32 i = 0; i != pDynosPacks.Count(); ++i) { -#ifdef COOP - // TODO: needs to be adjusted from djui - _Enabled.Add(true); -#else _Enabled.Add(DynOS_Opt_GetValue(String("dynos_pack_%d", i))); -#endif } +#endif // Loop through all object lists for (s32 list : { OBJ_LIST_PLAYER, OBJ_LIST_DESTRUCTIVE, OBJ_LIST_GENACTOR, OBJ_LIST_PUSHABLE, OBJ_LIST_LEVEL, OBJ_LIST_DEFAULT, OBJ_LIST_SURFACE, OBJ_LIST_POLELIKE, OBJ_LIST_UNIMPORTANT }) { diff --git a/data/dynos_opt.cpp b/data/dynos_opt.cpp index 364dc1bd..1cf12c45 100644 --- a/data/dynos_opt.cpp +++ b/data/dynos_opt.cpp @@ -643,10 +643,10 @@ void DynOS_Opt_Init() { // Model loader DynOS_Opt_CreateModelPacksSubMenu(); -#endif // Init config DynOS_Opt_LoadConfig(sDynosMenu); +#endif } // diff --git a/src/pc/djui/djui.h b/src/pc/djui/djui.h index d58fd428..4c30d064 100644 --- a/src/pc/djui/djui.h +++ b/src/pc/djui/djui.h @@ -53,6 +53,7 @@ #include "djui_panel_controls_n64.h" #include "djui_panel_controls_extra.h" #include "djui_panel_display.h" +#include "djui_panel_dynos.h" #include "djui_panel_sound.h" #include "djui_panel_confirm.h" #include "djui_panel_cheats.h" diff --git a/src/pc/djui/djui_base.h b/src/pc/djui/djui_base.h index 197f5923..f38bea04 100644 --- a/src/pc/djui/djui_base.h +++ b/src/pc/djui/djui_base.h @@ -42,6 +42,7 @@ struct DjuiBase { bool addChildrenToHead; bool abandonAfterChildRenderFail; s32 tag; + bool bTag; void (*get_cursor_hover_location)(struct DjuiBase*, f32* x, f32* y); void (*on_child_render)(struct DjuiBase*, struct DjuiBase*); void (*on_render_pre)(struct DjuiBase*, bool*); diff --git a/src/pc/djui/djui_panel_display.c b/src/pc/djui/djui_panel_display.c index 6650f8e9..51247b95 100644 --- a/src/pc/djui/djui_panel_display.c +++ b/src/pc/djui/djui_panel_display.c @@ -7,7 +7,7 @@ static void djui_panel_display_apply(UNUSED struct DjuiBase* caller) { } void djui_panel_display_create(struct DjuiBase* caller) { - f32 bodyHeight = 32 * 7 + 64 * 1 + 16 * 6; + f32 bodyHeight = 32 * 7 + 64 * 2 + 16 * 7; struct DjuiBase* defaultBase = NULL; struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\D\\#1be700\\I\\#00b3ff\\S\\#ffef00\\P\\#ff0800\\L\\#1be700\\A\\#00b3ff\\Y"); @@ -44,6 +44,11 @@ void djui_panel_display_create(struct DjuiBase* caller) { djui_base_set_size_type(&selectionbox3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&selectionbox3->base, 1.0f, 32); + struct DjuiButton* button5 = djui_button_create(&body->base, "DynOS Model Packs"); + djui_base_set_size_type(&button5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&button5->base, 1.0f, 64); + djui_interactable_hook_click(&button5->base, djui_panel_dynos_create); + struct DjuiButton* button6 = djui_button_create(&body->base, "Back"); djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&button6->base, 1.0f, 64); diff --git a/src/pc/djui/djui_panel_dynos.c b/src/pc/djui/djui_panel_dynos.c new file mode 100644 index 00000000..9a70d7b2 --- /dev/null +++ b/src/pc/djui/djui_panel_dynos.c @@ -0,0 +1,42 @@ +#include "djui.h" +#include "src/pc/utils/misc.h" +#include "src/pc/configfile.h" +#include "data/dynos_coop.c.h" + +static void djui_panel_dynos_apply(struct DjuiBase* caller) { + dynos_packs_set_enabled(caller->tag, caller->bTag); +} + +void djui_panel_dynos_create(struct DjuiBase* caller) { + int packCount = dynos_packs_get_count(); + f32 bodyHeight = 32 * (packCount) + 64 * 1 + 16 * (packCount + 1); + + struct DjuiBase* defaultBase = NULL; + struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\D\\#1be700\\Y\\#00b3ff\\N\\#ffef00\\O\\#ff0800\\S"); + struct DjuiFlowLayout* body = (struct DjuiFlowLayout*)djui_three_panel_get_body(panel); + + { + for (int i = 0; i < packCount; i++) { + bool tmp = dynos_packs_get_enabled(i); + const char* pack = dynos_packs_get(i); + + struct DjuiCheckbox* checkbox1 = djui_checkbox_create(&body->base, pack, &tmp); + checkbox1->base.tag = i; + checkbox1->base.bTag = tmp; + checkbox1->value = &checkbox1->base.bTag; + + djui_base_set_size_type(&checkbox1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&checkbox1->base, 1.0f, 32); + djui_interactable_hook_value_change(&checkbox1->base, djui_panel_dynos_apply); + if (i == 0) { defaultBase = &checkbox1->base; } + } + + struct DjuiButton* button6 = djui_button_create(&body->base, "Back"); + djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&button6->base, 1.0f, 64); + djui_button_set_style(button6, 1); + djui_interactable_hook_click(&button6->base, djui_panel_menu_back); + } + + djui_panel_add(caller, &panel->base, defaultBase); +} diff --git a/src/pc/djui/djui_panel_dynos.h b/src/pc/djui/djui_panel_dynos.h new file mode 100644 index 00000000..9b2797b4 --- /dev/null +++ b/src/pc/djui/djui_panel_dynos.h @@ -0,0 +1,4 @@ +#pragma once +#include "djui.h" + +void djui_panel_dynos_create(struct DjuiBase* caller);