diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index 937757b2a..a0b358f88 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -85,6 +85,7 @@ void CCamera::OnConsoleInit() Console()->Register("zoom+", "", CFGFLAG_CLIENT, ConZoomPlus, this, "Zoom increase"); Console()->Register("zoom-", "", CFGFLAG_CLIENT, ConZoomMinus, this, "Zoom decrease"); Console()->Register("zoom", "", CFGFLAG_CLIENT, ConZoomReset, this, "Zoom reset"); + Console()->Register("toggle_dynamic_camera", "", CFGFLAG_CLIENT, ConToggleDynamic, this, "Turn dynamic camera on/off"); } const float ZoomStep = 0.866025f; @@ -126,3 +127,24 @@ void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData) pSelf->Client()->GetServerInfo(&Info); ((CCamera *)pUserData)->OnReset(); } + +void CCamera::ToggleDynamic() +{ + if(g_Config.m_ClMouseDeadzone) + { + g_Config.m_ClMouseFollowfactor = 0; + g_Config.m_ClMouseMaxDistance = 400; + g_Config.m_ClMouseDeadzone = 0; + } + else + { + g_Config.m_ClMouseFollowfactor = g_Config.m_DynCamFollowFactor; + g_Config.m_ClMouseMaxDistance = g_Config.m_DynCamMaxDistance; + g_Config.m_ClMouseDeadzone = g_Config.m_DynCamDeadZone; + } +} + +void CCamera::ConToggleDynamic(IConsole::IResult *pResult, void *pUserData) +{ + ToggleDynamic(); +} diff --git a/src/game/client/components/camera.h b/src/game/client/components/camera.h index e7733a846..703a1ff01 100644 --- a/src/game/client/components/camera.h +++ b/src/game/client/components/camera.h @@ -30,10 +30,13 @@ public: virtual void OnConsoleInit(); virtual void OnReset(); + + static void ToggleDynamic(); private: static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData); static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData); static void ConZoomReset(IConsole::IResult *pResult, void *pUserData); + static void ConToggleDynamic(IConsole::IResult *pResult, void *pUserData); }; #endif diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 0fa31d663..5bacaaa24 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -24,6 +24,7 @@ #include #include "binds.h" +#include "camera.h" #include "countryflags.h" #include "menus.h" #include "skins.h" @@ -74,18 +75,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) static int s_DynamicCameraButton = 0; if(DoButton_CheckBox(&s_DynamicCameraButton, Localize("Dynamic Camera"), g_Config.m_ClMouseDeadzone != 0, &Button)) { - if(g_Config.m_ClMouseDeadzone) - { - g_Config.m_ClMouseFollowfactor = 0; - g_Config.m_ClMouseMaxDistance = 400; - g_Config.m_ClMouseDeadzone = 0; - } - else - { - g_Config.m_ClMouseFollowfactor = 60; - g_Config.m_ClMouseMaxDistance = 1000; - g_Config.m_ClMouseDeadzone = 300; - } + CCamera::ToggleDynamic(); } // weapon pickup diff --git a/src/game/variables.h b/src/game/variables.h index e908a43eb..60b88fd5e 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -49,6 +49,10 @@ MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 400, 0, 0, CFGFLAG_C MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 800, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "") #endif +MACRO_CONFIG_INT(DynCamMaxDistance, cl_dyn_cam_max_distance, 1000, 0, 2000, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Maximal dynamic camera distance") +MACRO_CONFIG_INT(DynCamDeadZone, cl_dyn_cam_dead_zone, 300, 1, 1300, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Dynamic camera dead zone") +MACRO_CONFIG_INT(DynCamFollowFactor, cl_dyn_cam_follow_factor, 60, 0, 200, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Dynamic camera follow factor") + MACRO_CONFIG_INT(EdZoomTarget, ed_zoom_target, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Zoom to the current mouse target") MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")