Allow zooming to levels. Close #3923

This commit is contained in:
Learath2 2021-07-10 15:53:23 +02:00
parent 4a13ba2536
commit 1a6de7caf8
2 changed files with 5 additions and 4 deletions

View file

@ -183,7 +183,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", "?i", CFGFLAG_CLIENT, ConZoom, this, "Change zoom");
Console()->Register("set_view", "i[x]i[y]", CFGFLAG_CLIENT, ConSetView, this, "Set camera position to x and y in the map"); Console()->Register("set_view", "i[x]i[y]", CFGFLAG_CLIENT, ConSetView, this, "Set camera position to x and y in the map");
} }
@ -209,9 +209,10 @@ void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData)
pSelf->ScaleZoom(1 / ZoomStep); pSelf->ScaleZoom(1 / ZoomStep);
} }
} }
void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData) void CCamera::ConZoom(IConsole::IResult *pResult, void *pUserData)
{ {
((CCamera *)pUserData)->ChangeZoom(pow(ZoomStep, g_Config.m_ClDefaultZoom - 10)); int TargetLevel = pResult->NumArguments() ? clamp(pResult->GetInteger(0), 0, 20) : g_Config.m_ClDefaultZoom;
((CCamera *)pUserData)->ChangeZoom(pow(ZoomStep, TargetLevel - 10));
} }
void CCamera::ConSetView(IConsole::IResult *pResult, void *pUserData) void CCamera::ConSetView(IConsole::IResult *pResult, void *pUserData)
{ {

View file

@ -50,7 +50,7 @@ public:
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 ConZoom(IConsole::IResult *pResult, void *pUserData);
static void ConSetView(IConsole::IResult *pResult, void *pUserData); static void ConSetView(IConsole::IResult *pResult, void *pUserData);
vec2 m_ForceFreeviewPos; vec2 m_ForceFreeviewPos;