Make every free cam option always available again

This commit is contained in:
Agent X 2024-05-30 17:44:22 -04:00
parent f8b5f2a9f6
commit 800f2422f9
1 changed files with 9 additions and 36 deletions

View File

@ -7,34 +7,8 @@
#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, ENABLE_FREE_CAMERA);
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, ENABLE_FREE_CAMERA);
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], ENABLE_FREE_CAMERA);
}
}
void djui_panel_camera_create(struct DjuiBase* caller) {
@ -42,16 +16,15 @@ 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_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_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_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back);
}