Merge pull request #55 from cinaera/pr_smooth_line

Editor: Add feature to zoom to mouse position
This commit is contained in:
Dennis Felsing 2014-10-08 15:03:49 +02:00
commit 1999b8faa4
3 changed files with 35 additions and 3 deletions

View file

@ -4028,12 +4028,22 @@ void CEditor::Render()
}
if(m_Dialog == DIALOG_NONE && UI()->MouseInside(&View))
{
// Determines in which direction to zoom.
int Zoom = 0;
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP))
m_ZoomLevel -= 20;
Zoom--;
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
m_ZoomLevel += 20;
Zoom++;
if(Zoom != 0)
{
float OldLevel = m_ZoomLevel;
m_ZoomLevel = clamp(m_ZoomLevel + Zoom * 20, 50, 2000);
if(g_Config.m_EdZoomTarget)
ZoomMouseTarget((float)m_ZoomLevel / OldLevel);
}
}
m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000);
m_WorldZoom = m_ZoomLevel/100.0f;
float Brightness = 0.25f;
@ -4229,6 +4239,26 @@ int CEditor::GetLineDistance()
return LineDistance;
}
void CEditor::ZoomMouseTarget(float ZoomFactor)
{
// zoom to the current mouse position
// get absolute mouse position
float aPoints[4];
RenderTools()->MapscreenToWorld(
m_WorldOffsetX, m_WorldOffsetY,
1.0f, 1.0f, 0.0f, 0.0f, Graphics()->ScreenAspect(), m_WorldZoom, aPoints);
float WorldWidth = aPoints[2]-aPoints[0];
float WorldHeight = aPoints[3]-aPoints[1];
float Mwx = aPoints[0] + WorldWidth * (UI()->MouseX()/UI()->Screen()->w);
float Mwy = aPoints[1] + WorldHeight * (UI()->MouseY()/UI()->Screen()->h);
// adjust camera
m_WorldOffsetX += (Mwx-m_WorldOffsetX) * (1-ZoomFactor);
m_WorldOffsetY += (Mwy-m_WorldOffsetY) * (1-ZoomFactor);
}
void CEditorMap::DeleteEnvelope(int Index)
{
if(Index < 0 || Index >= m_lEnvelopes.size())

View file

@ -913,6 +913,7 @@ public:
}
int GetLineDistance();
void ZoomMouseTarget(float ZoomFactor);
// DDRace

View file

@ -48,6 +48,7 @@ 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(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(ClFlow, cl_flow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")