diff --git a/data/gui/dialogs/custom_camera_settings.stkgui b/data/gui/dialogs/custom_camera_settings.stkgui index 63c5a02d6..dba6d062c 100644 --- a/data/gui/dialogs/custom_camera_settings.stkgui +++ b/data/gui/dialogs/custom_camera_settings.stkgui @@ -55,6 +55,15 @@ +
+ +
+
+
+ +
diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index d42bdd535..dc558064e 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -958,6 +958,11 @@ namespace UserConfigParams &m_camera_normal, "if true, use smoothing (forward-up-angle become relative to speed) when pointing forward")); + PARAM_PREFIX FloatUserConfigParam m_camera_backward_distance + PARAM_DEFAULT( FloatUserConfigParam(2.0, "backward-distance", + &m_camera_normal, + "Distance between kart and camera (reverse)")); + PARAM_PREFIX FloatUserConfigParam m_camera_backward_up_angle PARAM_DEFAULT( FloatUserConfigParam(5, "backward-up-angle", &m_camera_normal, @@ -998,6 +1003,11 @@ namespace UserConfigParams &m_standard_camera_settings, "if true, use smoothing (forward-up-angle become relative to speed) when pointing forward")); + PARAM_PREFIX FloatUserConfigParam m_standard_camera_backward_distance + PARAM_DEFAULT( FloatUserConfigParam(2.0, "backward-distance", + &m_standard_camera_settings, + "Distance between kart and camera (reverse)")); + PARAM_PREFIX FloatUserConfigParam m_standard_camera_backward_up_angle PARAM_DEFAULT( FloatUserConfigParam(5, "backward-up-angle", &m_standard_camera_settings, @@ -1034,6 +1044,11 @@ namespace UserConfigParams &m_drone_camera_settings, "if true, use smoothing (forward-up-angle become relative to speed) when pointing forward")); + PARAM_PREFIX FloatUserConfigParam m_drone_camera_backward_distance + PARAM_DEFAULT( FloatUserConfigParam(2.0, "backward-distance", + &m_drone_camera_settings, + "Distance between kart and camera (reverse)")); + PARAM_PREFIX FloatUserConfigParam m_drone_camera_backward_up_angle PARAM_DEFAULT( FloatUserConfigParam(10, "backward-up-angle", &m_drone_camera_settings, @@ -1070,6 +1085,11 @@ namespace UserConfigParams &m_saved_camera_settings, "if true, use smoothing (forward-up-angle become relative to speed) when pointing forward")); + PARAM_PREFIX FloatUserConfigParam m_saved_camera_backward_distance + PARAM_DEFAULT( FloatUserConfigParam(2.0, "backward-distance", + &m_saved_camera_settings, + "Distance between kart and camera (reverse)")); + PARAM_PREFIX FloatUserConfigParam m_saved_camera_backward_up_angle PARAM_DEFAULT( FloatUserConfigParam(5, "backward-up-angle", &m_saved_camera_settings, diff --git a/src/graphics/camera_normal.cpp b/src/graphics/camera_normal.cpp index 81284b63c..68b32410a 100644 --- a/src/graphics/camera_normal.cpp +++ b/src/graphics/camera_normal.cpp @@ -223,7 +223,7 @@ void CameraNormal::getCameraSettings(float *above_kart, float *cam_angle, *above_kart = 0.75f; *cam_angle = UserConfigParams::m_camera_backward_up_angle * DEGREE_TO_RAD; *sideway = 0; - *distance = 2.0f*m_distance; + *distance = UserConfigParams::m_camera_backward_distance; *smoothing = false; *cam_roll_angle = 0.0f; if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE) diff --git a/src/guiengine/widgets/spinner_widget.cpp b/src/guiengine/widgets/spinner_widget.cpp index 9d92b3d89..26c184dd3 100644 --- a/src/guiengine/widgets/spinner_widget.cpp +++ b/src/guiengine/widgets/spinner_widget.cpp @@ -104,7 +104,7 @@ SpinnerWidget::SpinnerWidget(const bool gauge) : Widget(WTYPE_SPINNER) } // ----------------------------------------------------------------------------- -void SpinnerWidget::setRange(int min, int max, float step) +void SpinnerWidget::setRange(float min, float max, float step) { clearLabels(); setStep(step); diff --git a/src/guiengine/widgets/spinner_widget.hpp b/src/guiengine/widgets/spinner_widget.hpp index 2649aad15..7b71cd2e7 100644 --- a/src/guiengine/widgets/spinner_widget.hpp +++ b/src/guiengine/widgets/spinner_widget.hpp @@ -266,7 +266,7 @@ namespace GUIEngine const core::stringw& getCustomText() const { return m_custom_text; } /* Set a spinner with numeric values min <= i <= max, with a precision of defined by step */ - void setRange(int min, int max, float step); + void setRange(float min, float max, float step); void setRange(int min, int max) { setRange(min, max, 1.0); } void onPressed(int x, int y); diff --git a/src/states_screens/dialogs/custom_camera_settings.cpp b/src/states_screens/dialogs/custom_camera_settings.cpp index 41a59b9f2..b2256cb77 100644 --- a/src/states_screens/dialogs/custom_camera_settings.cpp +++ b/src/states_screens/dialogs/custom_camera_settings.cpp @@ -58,15 +58,17 @@ void CustomCameraSettingsDialog::beforeAddingWidgets() { #ifndef SERVER_ONLY getWidget("fov")->setRange(75, 115); - getWidget("camera_distance")->setRange(0 , 20, 0.1); - getWidget("camera_angle")->setRange(0 , 45); - getWidget("backward_camera_angle")->setRange(0 , 45); + getWidget("camera_distance")->setRange(0.05f, 20, 0.05f); + getWidget("camera_angle")->setRange(0, 80); + getWidget("backward_camera_distance")->setRange(0.05f, 20, 0.05f); + getWidget("backward_camera_angle")->setRange(0, 80); if (UserConfigParams::m_camera_present == 1) // Standard camera { getWidget("camera_name")->setText(_("Standard"), false); getWidget("fov")->setValue(UserConfigParams::m_standard_camera_fov); getWidget("camera_distance")->setFloatValue(UserConfigParams::m_standard_camera_distance); getWidget("camera_angle")->setValue(UserConfigParams::m_standard_camera_forward_up_angle); + getWidget("backward_camera_distance")->setFloatValue(UserConfigParams::m_standard_camera_backward_distance); getWidget("backward_camera_angle")->setValue(UserConfigParams::m_standard_camera_backward_up_angle); getWidget("camera_smoothing")->setState(UserConfigParams::m_standard_camera_forward_smoothing); getWidget("use_soccer_camera")->setState(UserConfigParams::m_standard_reverse_look_use_soccer_cam); @@ -74,6 +76,7 @@ void CustomCameraSettingsDialog::beforeAddingWidgets() getWidget("fov")->setActive(false); getWidget("camera_distance")->setActive(false); getWidget("camera_angle")->setActive(false); + getWidget("backward_camera_distance")->setActive(false); getWidget("backward_camera_angle")->setActive(false); } else if (UserConfigParams::m_camera_present == 2) // Drone chase camera @@ -82,6 +85,7 @@ void CustomCameraSettingsDialog::beforeAddingWidgets() getWidget("fov")->setValue(UserConfigParams::m_drone_camera_fov); getWidget("camera_distance")->setFloatValue(UserConfigParams::m_drone_camera_distance); getWidget("camera_angle")->setValue(UserConfigParams::m_drone_camera_forward_up_angle); + getWidget("backward_camera_distance")->setFloatValue(UserConfigParams::m_drone_camera_backward_distance); getWidget("backward_camera_angle")->setValue(UserConfigParams::m_drone_camera_backward_up_angle); getWidget("camera_smoothing")->setState(UserConfigParams::m_drone_camera_forward_smoothing); getWidget("use_soccer_camera")->setState(UserConfigParams::m_drone_reverse_look_use_soccer_cam); @@ -89,6 +93,7 @@ void CustomCameraSettingsDialog::beforeAddingWidgets() getWidget("fov")->setActive(false); getWidget("camera_distance")->setActive(false); getWidget("camera_angle")->setActive(false); + getWidget("backward_camera_distance")->setActive(false); getWidget("backward_camera_angle")->setActive(false); } else // Custom camera @@ -98,6 +103,7 @@ void CustomCameraSettingsDialog::beforeAddingWidgets() getWidget("camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_distance); getWidget("camera_angle")->setValue(UserConfigParams::m_saved_camera_forward_up_angle); getWidget("camera_smoothing")->setState(UserConfigParams::m_saved_camera_forward_smoothing); + getWidget("backward_camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_backward_distance); getWidget("backward_camera_angle")->setValue(UserConfigParams::m_saved_camera_backward_up_angle); getWidget("use_soccer_camera")->setState(UserConfigParams::m_saved_reverse_look_use_soccer_cam); } @@ -129,11 +135,13 @@ GUIEngine::EventPropagation CustomCameraSettingsDialog::processEvent(const std:: UserConfigParams::m_camera_fov = getWidget("fov")->getValue(); UserConfigParams::m_camera_distance = getWidget("camera_distance")->getFloatValue(); UserConfigParams::m_camera_forward_up_angle = getWidget("camera_angle")->getValue(); + UserConfigParams::m_camera_backward_distance = getWidget("backward_camera_distance")->getFloatValue(); UserConfigParams::m_camera_backward_up_angle = getWidget("backward_camera_angle")->getValue(); UserConfigParams::m_saved_camera_fov = UserConfigParams::m_camera_fov; UserConfigParams::m_saved_camera_distance = UserConfigParams::m_camera_distance; UserConfigParams::m_saved_camera_forward_up_angle = UserConfigParams::m_camera_forward_up_angle; UserConfigParams::m_saved_camera_forward_smoothing = UserConfigParams::m_camera_forward_smoothing; + UserConfigParams::m_saved_camera_backward_distance = UserConfigParams::m_camera_backward_distance; UserConfigParams::m_saved_camera_backward_up_angle = UserConfigParams::m_camera_backward_up_angle; UserConfigParams::m_saved_reverse_look_use_soccer_cam = UserConfigParams::m_reverse_look_use_soccer_cam; } @@ -159,6 +167,7 @@ GUIEngine::EventPropagation CustomCameraSettingsDialog::processEvent(const std:: getWidget("camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_distance); getWidget("camera_angle")->setValue(UserConfigParams::m_saved_camera_forward_up_angle); getWidget("camera_smoothing")->setState(UserConfigParams::m_saved_camera_forward_smoothing); + getWidget("backward_camera_distance")->setFloatValue(UserConfigParams::m_saved_camera_backward_distance); getWidget("backward_camera_angle")->setValue(UserConfigParams::m_saved_camera_backward_up_angle); getWidget("use_soccer_camera")->setState(UserConfigParams::m_saved_reverse_look_use_soccer_cam); } diff --git a/src/states_screens/options/options_screen_ui.cpp b/src/states_screens/options/options_screen_ui.cpp index f11543dd6..5039ebc39 100644 --- a/src/states_screens/options/options_screen_ui.cpp +++ b/src/states_screens/options/options_screen_ui.cpp @@ -520,6 +520,7 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con UserConfigParams::m_camera_distance = UserConfigParams::m_standard_camera_distance; UserConfigParams::m_camera_forward_up_angle = UserConfigParams::m_standard_camera_forward_up_angle; UserConfigParams::m_camera_forward_smoothing = UserConfigParams::m_standard_camera_forward_smoothing; + UserConfigParams::m_camera_backward_distance = UserConfigParams::m_standard_camera_backward_distance; UserConfigParams::m_camera_backward_up_angle = UserConfigParams::m_standard_camera_backward_up_angle; UserConfigParams::m_reverse_look_use_soccer_cam = UserConfigParams::m_standard_reverse_look_use_soccer_cam; } @@ -529,6 +530,7 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con UserConfigParams::m_camera_distance = UserConfigParams::m_drone_camera_distance; UserConfigParams::m_camera_forward_up_angle = UserConfigParams::m_drone_camera_forward_up_angle; UserConfigParams::m_camera_forward_smoothing = UserConfigParams::m_drone_camera_forward_smoothing; + UserConfigParams::m_camera_backward_distance = UserConfigParams::m_drone_camera_backward_distance; UserConfigParams::m_camera_backward_up_angle = UserConfigParams::m_drone_camera_backward_up_angle; UserConfigParams::m_reverse_look_use_soccer_cam = UserConfigParams::m_drone_reverse_look_use_soccer_cam; } @@ -538,6 +540,7 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con UserConfigParams::m_camera_distance = UserConfigParams::m_saved_camera_distance; UserConfigParams::m_camera_forward_up_angle = UserConfigParams::m_saved_camera_forward_up_angle; UserConfigParams::m_camera_forward_smoothing = UserConfigParams::m_saved_camera_forward_smoothing; + UserConfigParams::m_camera_backward_distance = UserConfigParams::m_saved_camera_backward_distance; UserConfigParams::m_camera_backward_up_angle = UserConfigParams::m_saved_camera_backward_up_angle; UserConfigParams::m_reverse_look_use_soccer_cam = UserConfigParams::m_saved_reverse_look_use_soccer_cam; } diff --git a/src/states_screens/options/options_screen_ui.hpp b/src/states_screens/options/options_screen_ui.hpp index 78a81b044..ac9b754cd 100644 --- a/src/states_screens/options/options_screen_ui.hpp +++ b/src/states_screens/options/options_screen_ui.hpp @@ -26,17 +26,6 @@ namespace GUIEngine { class Widget; } -struct CameraPreset -{ - int fov; - float distance; - float angle; - bool smoothing; - float backward_angle; -}; - -struct Input; - /** * \brief Graphics options screen * \ingroup states_screens @@ -54,8 +43,6 @@ class OptionsScreenUI : public GUIEngine::Screen, public GUIEngine::ScreenSingle OptionsScreenUI(); bool m_inited; - std::vector m_camera_presets; - std::map m_skins; void updateCamera();