| 184 | //--------------------------------------------------------------------------- |
| 185 | |
| 186 | static void AutomapControl(const DVector2& cangvect) |
| 187 | { |
| 188 | static double nonsharedtimer; |
| 189 | double ms = (double)screen->FrameTime; |
| 190 | double interval; |
| 191 | |
| 192 | if (nonsharedtimer > 0 || ms < nonsharedtimer) |
| 193 | { |
| 194 | interval = ms - nonsharedtimer; |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | interval = 0; |
| 199 | } |
| 200 | nonsharedtimer = ms; |
| 201 | |
| 202 | if (System_WantGuiCapture()) |
| 203 | return; |
| 204 | |
| 205 | if (automapMode != am_off) |
| 206 | { |
| 207 | if (am_zoomdir > 0) |
| 208 | { |
| 209 | gZoom = gZoom * am_zoomdir; |
| 210 | } |
| 211 | else if (am_zoomdir < 0) |
| 212 | { |
| 213 | gZoom = gZoom / -am_zoomdir; |
| 214 | } |
| 215 | am_zoomdir = 0; |
| 216 | |
| 217 | double j = interval * (35. / 65536.) / gZoom; |
| 218 | gZoom += (buttonMap.ButtonDown(gamefunc_Enlarge_Screen) - buttonMap.ButtonDown(gamefunc_Shrink_Screen)) * j * max(gZoom, 0.25); |
| 219 | gZoom = clamp(gZoom, 0.05, 2.); |
| 220 | |
| 221 | if (!am_followplayer) |
| 222 | { |
| 223 | const double zoomspeed = j * 512.; |
| 224 | const auto panhorz = buttonMap.ButtonDown(gamefunc_AM_PanRight) - buttonMap.ButtonDown(gamefunc_AM_PanLeft); |
| 225 | const auto panvert = buttonMap.ButtonDown(gamefunc_AM_PanUp) - buttonMap.ButtonDown(gamefunc_AM_PanDown); |
| 226 | |
| 227 | if (min_bounds.X == INT_MAX) CalcMapBounds(); |
| 228 | |
| 229 | follow = clamp(follow + DVector2(panvert, panhorz).Rotated(cangvect.X, cangvect.Y) * zoomspeed, min_bounds, max_bounds); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | //--------------------------------------------------------------------------- |
| 235 | // |
no test coverage detected