Skip to content

Commit

Permalink
Add logic to update the standard camera settings when upgrading
Browse files Browse the repository at this point in the history
Because the defaults in the code get written into config.xml,use a special parameter to ensure that the standard camera settings are updated for people switching from an older 1.x version.
  • Loading branch information
Alayan-stk-2 committed Jan 30, 2025
1 parent e898ba1 commit 017b7bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/config/user_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,10 @@ namespace UserConfigParams
"The current used camera. 0=Custom; 1=Standard; 2=Drone chase") );

// ---- Standard camera settings
PARAM_PREFIX BoolUserConfigParam m_camera_updated_one_five
PARAM_DEFAULT( BoolUserConfigParam(false, "camera-updated-one-five",
"Used to update the standard camera values for users upgrading to 1.5") );

PARAM_PREFIX GroupUserConfigParam m_standard_camera_settings
PARAM_DEFAULT( GroupUserConfigParam(
"standard-camera-settings",
Expand Down
16 changes: 16 additions & 0 deletions src/graphics/camera/camera_normal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ void CameraNormal::getCameraSettings(float *above_kart, float *cam_angle,
float *sideway, float *distance,
bool *smoothing, float *cam_roll_angle)
{
// Update the standard camera for users updating to 1.5
if(!UserConfigParams::m_camera_updated_one_five)
{
UserConfigParams::m_standard_camera_fov.revertToDefaults();
UserConfigParams::m_standard_camera_distance.revertToDefaults();
UserConfigParams::m_standard_camera_forward_up_angle.revertToDefaults();
if (UserConfigParams::m_camera_present == 1) // Currently using a standard camera
{
UserConfigParams::m_camera_fov.revertToDefaults();
UserConfigParams::m_camera_distance.revertToDefaults();
UserConfigParams::m_camera_forward_up_angle.revertToDefaults();
m_distance = UserConfigParams::m_camera_distance;
}
UserConfigParams::m_camera_updated_one_five = true;
}

switch(getMode())
{
case CM_NORMAL:
Expand Down

0 comments on commit 017b7bc

Please sign in to comment.