- 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 // If paused, do not eat more CPU time than we need, because it
// will all be wasted anyway. // will all be wasted anyway.
if (pauseext) bool doWait = cl_capfps || pauseext || (r_NoInterpolate && !M_IsAnimated());
r_NoInterpolate = true;
bool doWait = cl_capfps || r_NoInterpolate;
// get real tics // get real tics
if (doWait) if (doWait)

View File

@ -94,6 +94,7 @@ void DImageScrollerMenu::Init(DMenu* parent, FImageScrollerDescriptor* desc)
mCurrent = newImageScreen(&mDesc->mItems[0]); mCurrent = newImageScreen(&mDesc->mItems[0]);
mCurrent->canAnimate = canAnimate; mCurrent->canAnimate = canAnimate;
isAnimated = true;
} }
bool DImageScrollerMenu::MenuEvent(int mkey, bool fromcontroller) 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 // [RH] Most menus can now be accessed directly

View File

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