summaryrefslogtreecommitdiff
path: root/src/texteff.cpp
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2018-05-11 17:52:06 +0100
committerPeterN <peter@fuzzle.org>2019-01-11 11:56:21 +0000
commit59fe4f28c8f0bf47e7af40095dc6fba145188930 (patch)
treec8007886b450f167b31804315b4011284ec11201 /src/texteff.cpp
parentead9c9eab5d206cb13eb169e392e1291e767efaf (diff)
downloadopenttd-59fe4f28c8f0bf47e7af40095dc6fba145188930.tar.xz
Change: Animate text effects by real time instead of game ticks.
Diffstat (limited to 'src/texteff.cpp')
-rw-r--r--src/texteff.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/texteff.cpp b/src/texteff.cpp
index cdb8b8ce6..0f79f51c1 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -16,6 +16,7 @@
#include "core/smallvec_type.hpp"
#include "viewport_func.h"
#include "settings_type.h"
+#include "window_func.h"
#include "safeguards.h"
@@ -82,20 +83,25 @@ void RemoveTextEffect(TextEffectID te_id)
_text_effects[te_id].Reset();
}
-void MoveAllTextEffects()
+void MoveAllTextEffects(uint delta_ms)
{
+ static uint texteffecttimer = 0;
+ uint count = CountIntervalElapsed(texteffecttimer, delta_ms, MILLISECONDS_PER_TICK);
+ if (count == 0) return;
+
const TextEffect *end = _text_effects.End();
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
if (te->string_id == INVALID_STRING_ID) continue;
if (te->mode != TE_RISING) continue;
- if (te->duration-- == 0) {
+ if (te->duration < count) {
te->Reset();
continue;
}
te->MarkDirty(ZOOM_LVL_OUT_8X);
- te->top -= ZOOM_LVL_BASE;
+ te->duration -= count;
+ te->top -= count * ZOOM_LVL_BASE;
te->MarkDirty(ZOOM_LVL_OUT_8X);
}
}