Make DJUI Mod Menu element names visually refresh

This commit is contained in:
Agent X 2024-06-02 17:51:02 -04:00
parent c4893b1f8a
commit 3f6da68615
3 changed files with 22 additions and 7 deletions

View file

@ -15,10 +15,25 @@ static char* to_uppercase(char* str) {
return buffer; return buffer;
} }
// generic void djui_panel_mod_menu_mod_button(struct DjuiBase* caller) {
void djui_panel_mod_menu_mod_element(struct DjuiBase* caller) {
struct LuaHookedModMenuElement* hooked = &gHookedModMenuElements[caller->tag]; struct LuaHookedModMenuElement* hooked = &gHookedModMenuElements[caller->tag];
smlua_call_mod_menu_element_hook(hooked, caller->tag); smlua_call_mod_menu_element_hook(hooked, caller->tag);
struct DjuiButton* button = (struct DjuiButton*)caller;
djui_text_set_text(button->text, hooked->name);
}
void djui_panel_mod_menu_mod_checkbox(struct DjuiBase* caller) {
struct LuaHookedModMenuElement* hooked = &gHookedModMenuElements[caller->tag];
smlua_call_mod_menu_element_hook(hooked, caller->tag);
struct DjuiCheckbox* checkbox = (struct DjuiCheckbox*)caller;
djui_text_set_text(checkbox->text, hooked->name);
}
void djui_panel_mod_menu_mod_slider(struct DjuiBase* caller) {
struct LuaHookedModMenuElement* hooked = &gHookedModMenuElements[caller->tag];
smlua_call_mod_menu_element_hook(hooked, caller->tag);
struct DjuiSlider* slider = (struct DjuiSlider*)caller;
djui_text_set_text(slider->text, hooked->name);
} }
static void djui_panel_mod_menu_mod_inputbox(struct DjuiBase* caller) { static void djui_panel_mod_menu_mod_inputbox(struct DjuiBase* caller) {
@ -32,15 +47,15 @@ static void djui_panel_mod_menu_mod_create_element(struct DjuiBase* parent, int
struct LuaHookedModMenuElement* hooked = &gHookedModMenuElements[i]; struct LuaHookedModMenuElement* hooked = &gHookedModMenuElements[i];
switch (hooked->element) { switch (hooked->element) {
case MOD_MENU_ELEMENT_BUTTON: case MOD_MENU_ELEMENT_BUTTON:
struct DjuiButton* button = djui_button_create(parent, hooked->name, DJUI_BUTTON_STYLE_NORMAL, djui_panel_mod_menu_mod_element); struct DjuiButton* button = djui_button_create(parent, hooked->name, DJUI_BUTTON_STYLE_NORMAL, djui_panel_mod_menu_mod_button);
button->base.tag = i; button->base.tag = i;
break; break;
case MOD_MENU_ELEMENT_CHECKBOX: case MOD_MENU_ELEMENT_CHECKBOX:
struct DjuiCheckbox* checkbox = djui_checkbox_create(parent, hooked->name, &hooked->boolValue, djui_panel_mod_menu_mod_element); struct DjuiCheckbox* checkbox = djui_checkbox_create(parent, hooked->name, &hooked->boolValue, djui_panel_mod_menu_mod_checkbox);
checkbox->base.tag = i; checkbox->base.tag = i;
break; break;
case MOD_MENU_ELEMENT_SLIDER: case MOD_MENU_ELEMENT_SLIDER:
struct DjuiSlider* slider = djui_slider_create(parent, hooked->name, &hooked->uintValue, hooked->sliderMin, hooked->sliderMax, djui_panel_mod_menu_mod_element); struct DjuiSlider* slider = djui_slider_create(parent, hooked->name, &hooked->uintValue, hooked->sliderMin, hooked->sliderMax, djui_panel_mod_menu_mod_slider);
slider->base.tag = i; slider->base.tag = i;
break; break;
case MOD_MENU_ELEMENT_INPUTBOX: case MOD_MENU_ELEMENT_INPUTBOX:

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "djui.h" #include "djui.h"
void djui_panel_mod_menu_mod_element(struct DjuiBase* caller); void djui_panel_mod_menu_mod_button(struct DjuiBase* caller);
void djui_panel_mod_menu_mod_create(struct DjuiBase* caller); void djui_panel_mod_menu_mod_create(struct DjuiBase* caller);
void djui_panel_mod_menu_create(struct DjuiBase* caller); void djui_panel_mod_menu_create(struct DjuiBase* caller);

View file

@ -79,7 +79,7 @@ void djui_panel_pause_create(struct DjuiBase* caller) {
} else { } else {
snprintf(buffer, 256, "%s", hooked->mod->name); snprintf(buffer, 256, "%s", hooked->mod->name);
} }
struct DjuiButton* button = djui_button_create(body, buffer, DJUI_BUTTON_STYLE_NORMAL, djui_panel_mod_menu_mod_element); struct DjuiButton* button = djui_button_create(body, buffer, DJUI_BUTTON_STYLE_NORMAL, djui_panel_mod_menu_mod_button);
button->base.tag = 0; button->base.tag = 0;
} else if (gHookedModMenuElementsCount > 0) { } else if (gHookedModMenuElementsCount > 0) {
djui_button_create(body, DLANG(PAUSE, MOD_MENU), DJUI_BUTTON_STYLE_NORMAL, djui_panel_mod_menu_create); djui_button_create(body, DLANG(PAUSE, MOD_MENU), DJUI_BUTTON_STYLE_NORMAL, djui_panel_mod_menu_create);