mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Editor: Add feature to zoom to the current mouse position
This commit is contained in:
parent
b34e455e4c
commit
90617421eb
|
@ -4074,10 +4074,18 @@ void CEditor::Render()
|
|||
if(m_Dialog == DIALOG_NONE && UI()->MouseInside(&View))
|
||||
{
|
||||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP))
|
||||
{
|
||||
m_ZoomLevel -= 20;
|
||||
if(g_Config.m_EdZoomTarget)
|
||||
ZoomMouseTarget((float)m_ZoomLevel/(m_ZoomLevel+20));
|
||||
}
|
||||
|
||||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
|
||||
{
|
||||
m_ZoomLevel += 20;
|
||||
if(g_Config.m_EdZoomTarget)
|
||||
ZoomMouseTarget((float)m_ZoomLevel/(m_ZoomLevel-20));
|
||||
}
|
||||
}
|
||||
m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000);
|
||||
m_WorldZoom = m_ZoomLevel/100.0f;
|
||||
|
@ -4233,6 +4241,16 @@ int CEditor::GetLineDistance()
|
|||
return LineDistance;
|
||||
}
|
||||
|
||||
void CEditor::ZoomMouseTarget(float ZoomFactor)
|
||||
{
|
||||
// zoom to the current mouse position
|
||||
float mx = UI()->MouseWorldX();
|
||||
float my = UI()->MouseWorldY();
|
||||
|
||||
m_EditorOffsetX += (mx-m_EditorOffsetX) * (1-ZoomFactor);
|
||||
m_EditorOffsetY += (my-m_EditorOffsetY) * (1-ZoomFactor);
|
||||
}
|
||||
|
||||
void CEditorMap::DeleteEnvelope(int Index)
|
||||
{
|
||||
if(Index < 0 || Index >= m_lEnvelopes.size())
|
||||
|
|
|
@ -837,6 +837,7 @@ public:
|
|||
}
|
||||
|
||||
int GetLineDistance();
|
||||
void ZoomMouseTarget(float ZoomFactor);
|
||||
};
|
||||
|
||||
// make sure to inline this function
|
||||
|
|
|
@ -28,6 +28,7 @@ MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 800, 0, 0, CFGFLAG_C
|
|||
|
||||
MACRO_CONFIG_INT(ClCustomizeSkin, cl_customize_skin, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
|
||||
MACRO_CONFIG_INT(EdZoomTarget, ed_zoom_target, 1, 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(ClFlow, cl_flow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
|
|
Loading…
Reference in a new issue