Add default zoom setting

This commit is contained in:
def 2015-01-03 03:13:21 +01:00
parent 592ab36c7e
commit 0ed314eef9
3 changed files with 33 additions and 8 deletions

View file

@ -17,16 +17,23 @@
CCamera::CCamera()
{
m_Zoom = 1.0f;
m_CamType = CAMTYPE_UNDEFINED;
m_Zoom = 1.0;
}
void CCamera::OnRender()
{
CServerInfo Info;
Client()->GetServerInfo(&Info);
if(!(m_pClient->m_Snap.m_SpecInfo.m_Active || IsRace(&Info) || Client()->State() == IClient::STATE_DEMOPLAYBACK))
m_Zoom = 1.0f;
{
m_Zoom = 1.0;
}
else if(m_Zoom == 1.0 && g_Config.m_ClDefaultZoom != 10)
{
OnReset();
}
// update camera center
if(m_pClient->m_Snap.m_SpecInfo.m_Active && !m_pClient->m_Snap.m_SpecInfo.m_UsePosition)
@ -77,12 +84,22 @@ void CCamera::OnConsoleInit()
Console()->Register("zoom", "", CFGFLAG_CLIENT, ConZoomReset, this, "Zoom reset");
}
const float ZoomStep = 0.866025f;
void CCamera::OnReset()
{
m_Zoom = 1.0f;
for (int i = g_Config.m_ClDefaultZoom; i < 10; i++)
{
m_Zoom *= 1/ZoomStep;
}
for (int i = g_Config.m_ClDefaultZoom; i > 10; i--)
{
m_Zoom *= ZoomStep;
}
}
const float ZoomStep = 0.866025f;
void CCamera::ConZoomPlus(IConsole::IResult *pResult, void *pUserData)
{
CCamera *pSelf = (CCamera *)pUserData;
@ -104,5 +121,5 @@ void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData)
CCamera *pSelf = (CCamera *)pUserData;
CServerInfo Info;
pSelf->Client()->GetServerInfo(&Info);
((CCamera *)pUserData)->m_Zoom = 1.0f;
((CCamera *)pUserData)->OnReset();
}

View file

@ -1670,7 +1670,7 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
Left.HSplitTop(20.0f, &Button, &Left);
Button.VSplitMid(&LeftLeft, &Button);
Button.VSplitLeft(60.0f, &Label, &Button);
Button.VSplitLeft(50.0f, &Label, &Button);
Button.HMargin(2.0f, &Button);
UI()->DoLabelScaled(&Label, Localize("Alpha"), 14.0f, -1);
g_Config.m_ClShowOthersAlpha = (int)(DoScrollbarH(&g_Config.m_ClShowOthersAlpha, &Button, g_Config.m_ClShowOthersAlpha /100.0f)*100.0f);
@ -1687,6 +1687,15 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
g_Config.m_ClShowQuads ^= 1;
}
Right.HSplitTop(20.0f, &Label, &Right);
Label.VSplitLeft(130.0f, &Label, &Button);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Default zoom"), g_Config.m_ClDefaultZoom);
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
//Right.HSplitTop(20.0f, &Button, 0);
Button.HMargin(2.0f, &Button);
g_Config.m_ClDefaultZoom= static_cast<int>(DoScrollbarH(&g_Config.m_ClDefaultZoom, &Button, g_Config.m_ClDefaultZoom/20.0f)*20.0f+0.1f);
Right.HSplitTop(20.0f, &Button, &Right);
if(DoButton_CheckBox(&g_Config.m_ClAntiPing, Localize("AntiPing"), g_Config.m_ClAntiPing, &Button))
{
@ -1730,9 +1739,6 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
g_Config.m_ClShowDirection ^= 1;
}
Right.HSplitTop(20.0f, &Button, &Right);
// Empty space here
CUIRect aRects[2];
Left.HSplitTop(5.0f, &Button, &Left);
Right.HSplitTop(5.0f, &Button, &Right);

View file

@ -66,6 +66,8 @@ MACRO_CONFIG_STR(ClLanguagefile, cl_languagefile, 255, "", CFGFLAG_CLIENT|CFGFLA
MACRO_CONFIG_INT(ClShowNewSkins, cl_show_new_skins, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show new skins ingame")
MACRO_CONFIG_INT(ClShowCustomSkins, cl_show_custom_skins, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show custom skins ingame")
MACRO_CONFIG_INT(ClDefaultZoom, cl_default_zoom, 10, 0, 20, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Default zoom level (10 default, min 0, max 20)")
MACRO_CONFIG_INT(PlayerUseCustomColor, player_use_custom_color, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toggles usage of custom colors")
MACRO_CONFIG_INT(PlayerColorBody, player_color_body, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player body color")
MACRO_CONFIG_INT(PlayerColorFeet, player_color_feet, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player feet color")