summaryrefslogtreecommitdiff
path: root/src/error_gui.cpp
diff options
context:
space:
mode:
authorglx22 <glx@openttd.org>2021-01-07 00:53:10 +0100
committerPatric Stout <github@truebrain.nl>2021-01-10 14:07:17 +0100
commit1fb4ed8eef558d13ef6f72253652ce65611e0c4b (patch)
tree3ffde98a9b1c38350dc57c37a656e253c64d69c7 /src/error_gui.cpp
parentc0d7949d7c798285cc289bb9c76b4b155256456c (diff)
downloadopenttd-1fb4ed8eef558d13ef6f72253652ce65611e0c4b.tar.xz
Fix: Use realtime for error message and console backlog timeouts
Diffstat (limited to 'src/error_gui.cpp')
-rw-r--r--src/error_gui.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/error_gui.cpp b/src/error_gui.cpp
index f9d88a199..c8594e34a 100644
--- a/src/error_gui.cpp
+++ b/src/error_gui.cpp
@@ -71,7 +71,7 @@ static WindowDesc _errmsg_face_desc(
* @param data The data to copy.
*/
ErrorMessageData::ErrorMessageData(const ErrorMessageData &data) :
- duration(data.duration), textref_stack_grffile(data.textref_stack_grffile), textref_stack_size(data.textref_stack_size),
+ display_timer(data.display_timer), textref_stack_grffile(data.textref_stack_grffile), textref_stack_size(data.textref_stack_size),
summary_msg(data.summary_msg), detailed_msg(data.detailed_msg), position(data.position), face(data.face)
{
memcpy(this->textref_stack, data.textref_stack, sizeof(this->textref_stack));
@@ -103,7 +103,6 @@ ErrorMessageData::~ErrorMessageData()
* @param textref_stack Values to put on the #TextRefStack.
*/
ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack) :
- duration(duration),
textref_stack_grffile(textref_stack_grffile),
textref_stack_size(textref_stack_size),
summary_msg(summary_msg),
@@ -119,6 +118,8 @@ ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg,
if (textref_stack_size > 0) MemCpyT(this->textref_stack, textref_stack, textref_stack_size);
assert(summary_msg != INVALID_STRING_ID);
+
+ this->display_timer.SetInterval(duration * 3000);
}
/**
@@ -297,16 +298,14 @@ public:
void OnMouseLoop() override
{
/* Disallow closing the window too easily, if timeout is disabled */
- if (_right_button_down && this->duration != 0) delete this;
+ if (_right_button_down && !this->display_timer.HasElapsed()) delete this;
}
- void OnHundredthTick() override
+ void OnRealtimeTick(uint delta_ms) override
{
- /* Timeout enabled? */
- if (this->duration != 0) {
- this->duration--;
- if (this->duration == 0) delete this;
- }
+ if (this->display_timer.CountElapsed(delta_ms) == 0) return;
+
+ delete this;
}
~ErrmsgWindow()
@@ -321,7 +320,7 @@ public:
*/
bool IsCritical()
{
- return this->duration == 0;
+ return this->display_timer.HasElapsed();
}
};