fixed messages lost when changing state with auto pause enabled (fixes #944)

This commit is contained in:
Thomas Jentzsch 2022-12-17 11:03:48 +01:00
parent 31cc0884db
commit d1073fc51f
1 changed files with 11 additions and 6 deletions

View File

@ -59,6 +59,8 @@
#include "TimeMachine.hxx"
#endif
static constexpr int MESSAGE_TIME = 120; // display message for 2 seconds
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::FrameBuffer(OSystem& osystem)
: myOSystem{osystem}
@ -387,7 +389,7 @@ void FrameBuffer::update(UpdateMode mode)
// Show a pause message immediately and then every 7 seconds
const bool shade = myOSystem.settings().getBool("pausedim");
if(myPausedCount-- <= 0)
if(myMsg.counter < MESSAGE_TIME && myPausedCount-- <= 0)
{
myPausedCount = static_cast<uInt32>(7 * myOSystem.frameRate());
showTextMessage("Paused", MessagePosition::MiddleCenter);
@ -620,9 +622,9 @@ void FrameBuffer::createMessage(string_view message, MessagePosition position,
const int VBORDER = fontHeight / 4;
// Show message for 2 seconds
myMsg.counter = std::min(static_cast<uInt32>(myOSystem.frameRate()) * 2, 120U);
myMsg.counter = std::min(static_cast<Int32>(myOSystem.frameRate()) * 2, MESSAGE_TIME);
if(myMsg.counter == 0)
myMsg.counter = 120;
myMsg.counter = MESSAGE_TIME;
// Precompute the message coordinates
myMsg.text = message;
@ -1009,9 +1011,12 @@ void FrameBuffer::setUIPalette()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::stateChanged(EventHandlerState state)
{
// Prevent removing state change messages
if(myMsg.counter < MESSAGE_TIME - 1)
{
// Make sure any onscreen messages are removed
hideMessage();
}
update(); // update immediately
}