MCPcopy Create free account
hub / github.com/ddnet/ddnet / ZoomMouseTarget

Method ZoomMouseTarget

src/game/editor/map_view.cpp:128–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128void CMapView::ZoomMouseTarget(float ZoomFactor)
129{
130 // zoom to the current mouse position
131 // get absolute mouse position
132 float aPoints[4];
133 Graphics()->MapScreenToWorld(
134 GetWorldOffset().x, GetWorldOffset().y,
135 100.0f, 100.0f, 100.0f, 0.0f, 0.0f, Graphics()->ScreenAspect(), m_WorldZoom, aPoints);
136
137 float WorldWidth = aPoints[2] - aPoints[0];
138 float WorldHeight = aPoints[3] - aPoints[1];
139
140 float MouseWorldX = aPoints[0] + WorldWidth * (Ui()->MouseX() / Ui()->Screen()->w);
141 float MouseWorldY = aPoints[1] + WorldHeight * (Ui()->MouseY() / Ui()->Screen()->h);
142
143 // adjust camera
144 OffsetWorld((vec2(MouseWorldX, MouseWorldY) - GetWorldOffset()) * (1.0f - ZoomFactor));
145}
146
147void CMapView::UpdateZoom()
148{

Callers

nothing calls this directly

Calls 7

GraphicsFunction · 0.85
UiFunction · 0.85
MapScreenToWorldMethod · 0.80
ScreenAspectMethod · 0.80
MouseXMethod · 0.80
ScreenMethod · 0.80
MouseYMethod · 0.80

Tested by

no test coverage detected