- animated menus without frame rate cap

The frame rate cap is only deactivated if there's actual animations running so that leaving the game in the menu won't make the engine run at high frame rates.
Fixes #288.
This commit is contained in:
Christoph Oelckers 2020-08-31 19:56:13 +02:00
parent 54d65bfcfc
commit 923833ccec
4 changed files with 17 additions and 3 deletions

View File

@ -331,9 +331,7 @@ void TryRunTics (void)
// If paused, do not eat more CPU time than we need, because it
// will all be wasted anyway.
if (pauseext)
r_NoInterpolate = true;
bool doWait = cl_capfps || r_NoInterpolate;
bool doWait = cl_capfps || pauseext || (r_NoInterpolate && !M_IsAnimated());
// get real tics
if (doWait)

View File

@ -94,6 +94,7 @@ void DImageScrollerMenu::Init(DMenu* parent, FImageScrollerDescriptor* desc)
mCurrent = newImageScreen(&mDesc->mItems[0]);
mCurrent->canAnimate = canAnimate;
isAnimated = true;
}
bool DImageScrollerMenu::MenuEvent(int mkey, bool fromcontroller)

View File

@ -1026,6 +1026,16 @@ void M_EnableMenu (bool on)
}
bool M_IsAnimated()
{
if (ConsoleState == c_down) return false;
if (!CurrentMenu) return false;
if (CurrentMenu->IsAnimated()) return true;
if(transition.previous) return true;
return false;
}
//=============================================================================
//
// [RH] Most menus can now be accessed directly

View File

@ -325,6 +325,7 @@ public:
DVector2 origin = { 0,0 };
int scriptID = INT_MAX;
bool canAnimate = false;
bool isAnimated = false; // set to true when uncapped frame rate is needed.
DMenu(DMenu *parent = NULL);
virtual ~DMenu() = default;
@ -339,6 +340,7 @@ public:
virtual void Close();
virtual bool MouseEvent(int type, int x, int y);
virtual void Destroy() {}
bool IsAnimated() const { return isAnimated; }
bool MouseEventBack(int type, int x, int y);
void SetCapture();
void ReleaseCapture();
@ -836,4 +838,7 @@ public:
extern FSavegameManager savegameManager;
extern DMenu* CurrentMenu;
bool M_IsAnimated();
#endif