From 8209554f692ec9cf3607230147131e956e71c012 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sun, 12 May 2024 09:51:17 -0400 Subject: [PATCH] Disable freecam options if freecam is off --- src/pc/djui/djui_panel_camera.c | 45 +++++++++++++++++++++++++-------- src/pc/djui/djui_panel_menu.c | 2 +- src/pc/djui/djui_slider.c | 4 +++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/pc/djui/djui_panel_camera.c b/src/pc/djui/djui_panel_camera.c index bf8a03d2c..4310e408c 100644 --- a/src/pc/djui/djui_panel_camera.c +++ b/src/pc/djui/djui_panel_camera.c @@ -5,8 +5,32 @@ #include "pc/configfile.h" #include "game/bettercamera.h" -void djui_panel_camera_value_changed(UNUSED struct DjuiBase* caller) { +#define FREE_CAMERA_OPTIONS 9 + +static struct DjuiBase* sFreeCameraOptions[FREE_CAMERA_OPTIONS] = { 0 }; +static u8 sIndex = 0; + +static struct DjuiCheckbox* djui_linked_checkbox_create(struct DjuiBase* parent, const char* message, bool* value, void (*on_value_change)(struct DjuiBase*)) { + struct DjuiCheckbox* checkbox = djui_checkbox_create(parent, message, value, on_value_change); + djui_base_set_enabled(&checkbox->base, configEnableCamera); + sFreeCameraOptions[sIndex] = &checkbox->base; + sIndex++; + return checkbox; +} + +static struct DjuiSlider* djui_linked_slider_create(struct DjuiBase* parent, const char* message, unsigned int* value, unsigned int min, unsigned int max, void (*on_value_change)(struct DjuiBase*)) { + struct DjuiSlider* slider = djui_slider_create(parent, message, value, min, max, on_value_change); + djui_base_set_enabled(&slider->base, configEnableCamera); + sFreeCameraOptions[sIndex] = &slider->base; + sIndex++; + return slider; +} + +static void djui_panel_camera_value_changed(UNUSED struct DjuiBase* caller) { newcam_init_settings(); + for (s32 i = 0; i < FREE_CAMERA_OPTIONS; i++) { + djui_base_set_enabled(sFreeCameraOptions[i], configEnableCamera); + } } void djui_panel_camera_create(struct DjuiBase* caller) { @@ -14,15 +38,16 @@ void djui_panel_camera_create(struct DjuiBase* caller) { struct DjuiBase* body = djui_three_panel_get_body(panel); { djui_checkbox_create(body, DLANG(CAMERA, FREE_CAMERA), &configEnableCamera, djui_panel_camera_value_changed); - djui_checkbox_create(body, DLANG(CAMERA, ANALOG_CAMERA), &configCameraAnalog, djui_panel_camera_value_changed); - djui_checkbox_create(body, DLANG(CAMERA, MOUSE_LOOK), &configCameraMouse, djui_panel_camera_value_changed); - djui_checkbox_create(body, DLANG(CAMERA, INVERT_X), &configCameraInvertX, djui_panel_camera_value_changed); - djui_checkbox_create(body, DLANG(CAMERA, INVERT_Y), &configCameraInvertY, djui_panel_camera_value_changed); - djui_slider_create(body, DLANG(CAMERA, X_SENSITIVITY), &configCameraXSens, 1, 100, djui_panel_camera_value_changed); - djui_slider_create(body, DLANG(CAMERA, Y_SENSITIVITY), &configCameraYSens, 1, 100, djui_panel_camera_value_changed); - djui_slider_create(body, DLANG(CAMERA, AGGRESSION), &configCameraAggr, 0, 100, djui_panel_camera_value_changed); - djui_slider_create(body, DLANG(CAMERA, PAN_LEVEL), &configCameraPan, 0, 100, djui_panel_camera_value_changed); - djui_slider_create(body, DLANG(CAMERA, DECELERATION), &configCameraDegrade, 0, 100, djui_panel_camera_value_changed); + djui_linked_checkbox_create(body, DLANG(CAMERA, ANALOG_CAMERA), &configCameraAnalog, djui_panel_camera_value_changed); + djui_linked_checkbox_create(body, DLANG(CAMERA, MOUSE_LOOK), &configCameraMouse, djui_panel_camera_value_changed); + djui_linked_checkbox_create(body, DLANG(CAMERA, INVERT_X), &configCameraInvertX, djui_panel_camera_value_changed); + djui_linked_checkbox_create(body, DLANG(CAMERA, INVERT_Y), &configCameraInvertY, djui_panel_camera_value_changed); + djui_linked_slider_create(body, DLANG(CAMERA, X_SENSITIVITY), &configCameraXSens, 1, 100, djui_panel_camera_value_changed); + djui_linked_slider_create(body, DLANG(CAMERA, Y_SENSITIVITY), &configCameraYSens, 1, 100, djui_panel_camera_value_changed); + djui_linked_slider_create(body, DLANG(CAMERA, AGGRESSION), &configCameraAggr, 0, 100, djui_panel_camera_value_changed); + djui_linked_slider_create(body, DLANG(CAMERA, PAN_LEVEL), &configCameraPan, 0, 100, djui_panel_camera_value_changed); + djui_linked_slider_create(body, DLANG(CAMERA, DECELERATION), &configCameraDegrade, 0, 100, djui_panel_camera_value_changed); + sIndex = 0; djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); } diff --git a/src/pc/djui/djui_panel_menu.c b/src/pc/djui/djui_panel_menu.c index b7e938e00..03c417915 100644 --- a/src/pc/djui/djui_panel_menu.c +++ b/src/pc/djui/djui_panel_menu.c @@ -7,7 +7,7 @@ #define RAINBOW_TEXT_LEN 255 char* sRainbowColors[] = { - "\\#ff5050\\", + "\\#ff4040\\", "\\#50e750\\", "\\#50b3ff\\", "\\#ffef50\\", diff --git a/src/pc/djui/djui_slider.c b/src/pc/djui/djui_slider.c index 7a67339d7..3dd72069b 100644 --- a/src/pc/djui/djui_slider.c +++ b/src/pc/djui/djui_slider.c @@ -6,6 +6,10 @@ static void djui_slider_update_style(struct DjuiBase* base) { bool activeRegion = (gCursorX >= x); if (!slider->base.enabled) { + djui_base_set_border_color(&slider->rect->base, 93, 93, 93, 255); + djui_base_set_color(&slider->rect->base, 0, 0, 0, 0); + djui_base_set_color(&slider->text->base, 100, 100, 100, 255); + djui_base_set_color(&slider->rectValue->base, 100, 100, 100, 255); } else if (gInteractableFocus == base) { djui_base_set_border_color(&slider->rect->base, 20, 170, 255, 255); djui_base_set_color(&slider->rect->base, 255, 255, 255, 32);