mirror of https://github.com/OpenTTD/OpenTTD.git
Change: Animate text effects by real time instead of game ticks.
This commit is contained in:
parent
ead9c9eab5
commit
59fe4f28c8
|
@ -1495,8 +1495,6 @@ void GameLoop()
|
||||||
|
|
||||||
if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
|
if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
|
||||||
|
|
||||||
if (!_pause_mode || _game_mode == GM_EDITOR || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects();
|
|
||||||
|
|
||||||
InputLoop();
|
InputLoop();
|
||||||
|
|
||||||
SoundDriver::GetInstance()->MainLoop();
|
SoundDriver::GetInstance()->MainLoop();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "core/smallvec_type.hpp"
|
#include "core/smallvec_type.hpp"
|
||||||
#include "viewport_func.h"
|
#include "viewport_func.h"
|
||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
|
#include "window_func.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
@ -82,20 +83,25 @@ void RemoveTextEffect(TextEffectID te_id)
|
||||||
_text_effects[te_id].Reset();
|
_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();
|
const TextEffect *end = _text_effects.End();
|
||||||
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
|
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
|
||||||
if (te->string_id == INVALID_STRING_ID) continue;
|
if (te->string_id == INVALID_STRING_ID) continue;
|
||||||
if (te->mode != TE_RISING) continue;
|
if (te->mode != TE_RISING) continue;
|
||||||
|
|
||||||
if (te->duration-- == 0) {
|
if (te->duration < count) {
|
||||||
te->Reset();
|
te->Reset();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
te->MarkDirty(ZOOM_LVL_OUT_8X);
|
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);
|
te->MarkDirty(ZOOM_LVL_OUT_8X);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ enum TextEffectMode {
|
||||||
|
|
||||||
typedef uint16 TextEffectID;
|
typedef uint16 TextEffectID;
|
||||||
|
|
||||||
void MoveAllTextEffects();
|
void MoveAllTextEffects(uint delta_ms);
|
||||||
TextEffectID AddTextEffect(StringID msg, int x, int y, uint8 duration, TextEffectMode mode);
|
TextEffectID AddTextEffect(StringID msg, int x, int y, uint8 duration, TextEffectMode mode);
|
||||||
void InitTextEffects();
|
void InitTextEffects();
|
||||||
void DrawTextEffects(DrawPixelInfo *dpi);
|
void DrawTextEffects(DrawPixelInfo *dpi);
|
||||||
|
|
|
@ -3126,6 +3126,8 @@ void UpdateWindows()
|
||||||
_window_highlight_colour = !_window_highlight_colour;
|
_window_highlight_colour = !_window_highlight_colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_pause_mode || _game_mode == GM_EDITOR || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects(delta_ms);
|
||||||
|
|
||||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||||
w->ProcessScheduledInvalidations();
|
w->ProcessScheduledInvalidations();
|
||||||
w->ProcessHighlightedInvalidations();
|
w->ProcessHighlightedInvalidations();
|
||||||
|
|
Loading…
Reference in New Issue