mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add dynamic camera console toggle feature
This commit is contained in:
parent
33c0420edf
commit
7c41cb1afe
|
@ -85,6 +85,7 @@ void CCamera::OnConsoleInit()
|
||||||
Console()->Register("zoom+", "", CFGFLAG_CLIENT, ConZoomPlus, this, "Zoom increase");
|
Console()->Register("zoom+", "", CFGFLAG_CLIENT, ConZoomPlus, this, "Zoom increase");
|
||||||
Console()->Register("zoom-", "", CFGFLAG_CLIENT, ConZoomMinus, this, "Zoom decrease");
|
Console()->Register("zoom-", "", CFGFLAG_CLIENT, ConZoomMinus, this, "Zoom decrease");
|
||||||
Console()->Register("zoom", "", CFGFLAG_CLIENT, ConZoomReset, this, "Zoom reset");
|
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;
|
const float ZoomStep = 0.866025f;
|
||||||
|
@ -126,3 +127,24 @@ void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData)
|
||||||
pSelf->Client()->GetServerInfo(&Info);
|
pSelf->Client()->GetServerInfo(&Info);
|
||||||
((CCamera *)pUserData)->OnReset();
|
((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();
|
||||||
|
}
|
||||||
|
|
|
@ -30,10 +30,13 @@ public:
|
||||||
|
|
||||||
virtual void OnConsoleInit();
|
virtual void OnConsoleInit();
|
||||||
virtual void OnReset();
|
virtual void OnReset();
|
||||||
|
|
||||||
|
static void ToggleDynamic();
|
||||||
private:
|
private:
|
||||||
static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData);
|
static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData);
|
static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConZoomReset(IConsole::IResult *pResult, void *pUserData);
|
static void ConZoomReset(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
static void ConToggleDynamic(IConsole::IResult *pResult, void *pUserData);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <game/localization.h>
|
#include <game/localization.h>
|
||||||
|
|
||||||
#include "binds.h"
|
#include "binds.h"
|
||||||
|
#include "camera.h"
|
||||||
#include "countryflags.h"
|
#include "countryflags.h"
|
||||||
#include "menus.h"
|
#include "menus.h"
|
||||||
#include "skins.h"
|
#include "skins.h"
|
||||||
|
@ -74,18 +75,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
||||||
static int s_DynamicCameraButton = 0;
|
static int s_DynamicCameraButton = 0;
|
||||||
if(DoButton_CheckBox(&s_DynamicCameraButton, Localize("Dynamic Camera"), g_Config.m_ClMouseDeadzone != 0, &Button))
|
if(DoButton_CheckBox(&s_DynamicCameraButton, Localize("Dynamic Camera"), g_Config.m_ClMouseDeadzone != 0, &Button))
|
||||||
{
|
{
|
||||||
if(g_Config.m_ClMouseDeadzone)
|
CCamera::ToggleDynamic();
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// weapon pickup
|
// weapon pickup
|
||||||
|
|
|
@ -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, "")
|
MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 800, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||||
#endif
|
#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(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, "")
|
MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue