From 563196048dad41878221c5c7d74e165e1482d8ad Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sun, 19 May 2024 15:08:24 -0400 Subject: [PATCH] Make camera options disable if no first person or override --- src/pc/djui/djui_panel_camera.c | 10 ++++++--- src/pc/lua/utils/smlua_misc_utils.c | 33 ++++++++++++----------------- src/pc/lua/utils/smlua_misc_utils.h | 7 ++++++ 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/pc/djui/djui_panel_camera.c b/src/pc/djui/djui_panel_camera.c index 4310e408..23d462c9 100644 --- a/src/pc/djui/djui_panel_camera.c +++ b/src/pc/djui/djui_panel_camera.c @@ -4,15 +4,19 @@ #include "pc/utils/misc.h" #include "pc/configfile.h" #include "game/bettercamera.h" +#include "game/first_person_cam.h" +#include "pc/lua/utils/smlua_misc_utils.h" #define FREE_CAMERA_OPTIONS 9 +#define ENABLE_FREE_CAMERA configEnableCamera || gFirstPersonCamera.enabled || (gOverrideEnableCamera.override && gOverrideEnableCamera.value) + 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); + djui_base_set_enabled(&checkbox->base, ENABLE_FREE_CAMERA); sFreeCameraOptions[sIndex] = &checkbox->base; sIndex++; return checkbox; @@ -20,7 +24,7 @@ static struct DjuiCheckbox* djui_linked_checkbox_create(struct DjuiBase* parent, 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); + djui_base_set_enabled(&slider->base, ENABLE_FREE_CAMERA); sFreeCameraOptions[sIndex] = &slider->base; sIndex++; return slider; @@ -29,7 +33,7 @@ static struct DjuiSlider* djui_linked_slider_create(struct DjuiBase* parent, con 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); + djui_base_set_enabled(sFreeCameraOptions[i], ENABLE_FREE_CAMERA); } } diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 4fc7dfc1..a51d2c48 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -247,21 +247,16 @@ void hud_set_flash(s8 value) { /// -struct CameraOverride { - unsigned int value; - bool override; -}; - -struct CameraOverride sOverrideCameraXSens = { 0 }; -struct CameraOverride sOverrideCameraYSens = { 0 }; -struct CameraOverride sOverrideCameraAggr = { 0 }; -struct CameraOverride sOverrideCameraPan = { 0 }; -struct CameraOverride sOverrideCameraDegrade = { 0 }; -struct CameraOverride sOverrideCameraInvertX = { 0 }; -struct CameraOverride sOverrideCameraInvertY = { 0 }; -struct CameraOverride sOverrideEnableCamera = { 0 }; -struct CameraOverride sOverrideCameraAnalog = { 0 }; -struct CameraOverride sOverrideCameraMouse = { 0 }; +static struct CameraOverride sOverrideCameraXSens = { 0 }; +static struct CameraOverride sOverrideCameraYSens = { 0 }; +static struct CameraOverride sOverrideCameraAggr = { 0 }; +static struct CameraOverride sOverrideCameraPan = { 0 }; +static struct CameraOverride sOverrideCameraDegrade = { 0 }; +static struct CameraOverride sOverrideCameraInvertX = { 0 }; +static struct CameraOverride sOverrideCameraInvertY = { 0 }; +struct CameraOverride gOverrideEnableCamera = { 0 }; +static struct CameraOverride sOverrideCameraAnalog = { 0 }; +static struct CameraOverride sOverrideCameraMouse = { 0 }; void camera_reset_overrides(void) { sOverrideCameraXSens.override = false; @@ -271,7 +266,7 @@ void camera_reset_overrides(void) { sOverrideCameraDegrade.override = false; sOverrideCameraInvertX.override = false; sOverrideCameraInvertY.override = false; - sOverrideEnableCamera.override = false; + gOverrideEnableCamera.override = false; sOverrideCameraAnalog.override = false; sOverrideCameraMouse.override = false; } @@ -305,7 +300,7 @@ void camera_romhack_allow_dpad_usage(u8 allow) { } bool camera_config_is_free_cam_enabled(void) { - return sOverrideEnableCamera.override ? sOverrideEnableCamera.value : configEnableCamera; + return gOverrideEnableCamera.override ? gOverrideEnableCamera.value : configEnableCamera; } bool camera_config_is_analog_cam_enabled(void) { @@ -345,8 +340,8 @@ u32 camera_config_get_deceleration(void) { } void camera_config_enable_free_cam(bool enable) { - sOverrideEnableCamera.value = enable; - sOverrideEnableCamera.override = true; + gOverrideEnableCamera.value = enable; + gOverrideEnableCamera.override = true; newcam_init_settings(); } diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index fc90d79c..d8a93aa8 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -38,6 +38,13 @@ struct DateTime { s32 second; }; +struct CameraOverride { + unsigned int value; + bool override; +}; + +extern struct CameraOverride gOverrideEnableCamera; + u32 get_network_area_timer(void); s32* get_temp_s32_pointer(s32 initialValue);