OpenTTD Source 20250312-master-gcdcc6b491d
texteff.cpp File Reference

Handling of text effects. More...

#include "stdafx.h"
#include "texteff.hpp"
#include "transparency.h"
#include "strings_func.h"
#include "viewport_func.h"
#include "settings_type.h"
#include "command_type.h"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  TextEffect
 Container for all information about a text effect. More...
 

Functions

TextEffectID AddTextEffect (EncodedString &&msg, int center, int y, uint8_t duration, TextEffectMode mode)
 
void UpdateTextEffect (TextEffectID te_id, EncodedString &&msg)
 
void UpdateAllTextEffectVirtCoords ()
 
void RemoveTextEffect (TextEffectID te_id)
 
void InitTextEffects ()
 
void DrawTextEffects (DrawPixelInfo *dpi)
 

Variables

static std::vector< TextEffect_text_effects
 Text effects are stored there.
 
IntervalTimer< TimerWindowmove_all_text_effects_interval
 Slowly move text effects upwards.
 

Detailed Description

Handling of text effects.

Definition in file texteff.cpp.

Function Documentation

◆ AddTextEffect()

TextEffectID AddTextEffect ( EncodedString &&  msg,
int  center,
int  y,
uint8_t  duration,
TextEffectMode  mode 
)

Definition at line 42 of file texteff.cpp.

◆ DrawTextEffects()

void DrawTextEffects ( DrawPixelInfo dpi)

Definition at line 117 of file texteff.cpp.

◆ InitTextEffects()

void InitTextEffects ( )

Definition at line 111 of file texteff.cpp.

◆ RemoveTextEffect()

void RemoveTextEffect ( TextEffectID  te_id)

Definition at line 86 of file texteff.cpp.

◆ UpdateAllTextEffectVirtCoords()

void UpdateAllTextEffectVirtCoords ( )

Definition at line 77 of file texteff.cpp.

◆ UpdateTextEffect()

void UpdateTextEffect ( TextEffectID  te_id,
EncodedString &&  msg 
)

Definition at line 67 of file texteff.cpp.

Variable Documentation

◆ _text_effects

std::vector<TextEffect> _text_effects
static

Text effects are stored there.

Definition at line 39 of file texteff.cpp.

◆ move_all_text_effects_interval

IntervalTimer<TimerWindow> move_all_text_effects_interval
Initial value:
= {std::chrono::milliseconds(30), [](uint count) {
if (_pause_mode.Any() && _game_mode != GM_EDITOR && _settings_game.construction.command_pause_level <= CMDPL_NO_CONSTRUCTION) return;
for (TextEffect &te : _text_effects) {
if (!te.IsValid()) continue;
if (te.mode != TE_RISING) continue;
if (te.duration < count) {
te.Reset();
continue;
}
te.MarkDirty(ZOOM_LVL_TEXT_EFFECT);
te.duration -= count;
te.top -= count * ZOOM_BASE;
te.MarkDirty(ZOOM_LVL_TEXT_EFFECT);
}
}}
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
@ CMDPL_NO_CONSTRUCTION
No construction actions may be executed.
PauseModes _pause_mode
The current pause mode.
Definition gfx.cpp:50
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:58
uint8_t command_pause_level
level/amount of commands that can't be executed while paused
ConstructionSettings construction
construction of things in-game
Container for all information about a text effect.
Definition texteff.cpp:23
static std::vector< TextEffect > _text_effects
Text effects are stored there.
Definition texteff.cpp:39
@ TE_RISING
Make the text effect slowly go upwards.
Definition texteff.hpp:22
@ ZOOM_LVL_TEXT_EFFECT
All zoom levels above this will not show text effects.
Definition zoom_type.h:39

Slowly move text effects upwards.

Definition at line 92 of file texteff.cpp.