From 5fb1ff4d21028b5bbc8f8c22f50940c2883e1c4b Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 8 Mar 2025 10:20:55 +0100 Subject: [PATCH] a system to limit the framerate if not currently showing an animated screen --- control.cpp | 16 ++++++++++++---- graph.cpp | 3 +++ screenshot.cpp | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/control.cpp b/control.cpp index bcd67b35..94554bfb 100644 --- a/control.cpp +++ b/control.cpp @@ -395,6 +395,7 @@ EX ld camera_speed = 1; EX ld camera_rot_speed = 1; EX void full_forward_camera(ld t) { + if(t) currently_scrolling = true; if(anyshiftclick) zoom_or_fov(exp(-t/10.)); else if(GDIM == 3) { @@ -409,6 +410,7 @@ EX void full_cstrafe_camera(int dir, ld t) { shift_view(ctangent(dir, t * camera_speed)); didsomething = true; playermoved = false; + if(t) currently_scrolling = true; } } @@ -424,6 +426,7 @@ EX ld third_person_rotation = 0; EX void full_rotate_camera(int dir, ld val) { if(!val) return; + currently_scrolling = true; if(rug::rug_control() && lshiftclick) { val *= camera_rot_speed; hyperpoint h; @@ -478,6 +481,7 @@ EX void full_rotate_camera(int dir, ld val) { } EX void full_rotate_view(ld h, ld v) { + if(v) currently_scrolling = true; if(history::on && !rug::rug_control()) models::rotation = spin(h * camera_rot_speed) * models::rotation; else { @@ -491,8 +495,8 @@ EX void full_rotate_view(ld h, ld v) { EX void handlePanning(int sym, int uni) { if(mousepan && dual::split([=] { handlePanning(sym, uni); })) return; if(GDIM == 3) { - if(sym == PSEUDOKEY_WHEELUP) shift_view(ztangent(-0.05*shiftmul) * camera_speed), didsomething = true, playermoved = false; - if(sym == PSEUDOKEY_WHEELDOWN) shift_view(ztangent(0.05*shiftmul) * camera_speed), didsomething = true, playermoved = false; + if(sym == PSEUDOKEY_WHEELUP) shift_view(ztangent(-0.05*shiftmul) * camera_speed), didsomething = true, playermoved = false, currently_scrolling = true; + if(sym == PSEUDOKEY_WHEELDOWN) shift_view(ztangent(0.05*shiftmul) * camera_speed), didsomething = true, playermoved = false, currently_scrolling = true; } #if CAP_RUG @@ -519,7 +523,7 @@ EX void handlePanning(int sym, int uni) { if(sym == PSEUDOKEY_WHEELUP && GDIM == 2) { ld jx = (mousex - current_display->xcenter - .0) / current_display->radius / 10; ld jy = (mousey - current_display->ycenter - .0) / current_display->radius / 10; - playermoved = false; + playermoved = false; currently_scrolling = true; rotate_view(gpushxto0(hpxy(jx * camera_speed, jy * camera_speed))); sym = 1; } @@ -776,6 +780,10 @@ EX bool mouseaiming(bool shmupon) { EX purehookset hooks_control; +EX bool stillscreen; + +EX bool currently_scrolling; + EX void mainloopiter() { GLWRAP; DEBB(DF_GRAPH, ("main loop\n")); @@ -803,7 +811,7 @@ EX void mainloopiter() { timetowait = lastframe + 1000 / cframelimit - ticks; cframelimit = vid.framelimit; - if(outoffocus && cframelimit > 10) cframelimit = 10; + if(stillscreen && cframelimit > 10) cframelimit = 10; bool normal = cmode & sm::NORMAL; diff --git a/graph.cpp b/graph.cpp index 599aa771..ede3c600 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5816,6 +5816,7 @@ EX string menu_format = ""; EX void gamescreen() { if(cmode & sm::NOSCR) { + stillscreen = true; emptyscreen(); return; } @@ -5837,6 +5838,8 @@ EX void gamescreen() { return; } + stillscreen = false; + auto gx = vid.xres; auto gy = vid.yres; diff --git a/screenshot.cpp b/screenshot.cpp index 02f703f3..19ccc731 100644 --- a/screenshot.cpp +++ b/screenshot.cpp @@ -1803,7 +1803,7 @@ EX bool any_animation() { } EX bool any_on() { - return any_animation() || history::includeHistory; + return any_animation() || history::includeHistory || currently_scrolling; } EX bool center_music() {