OpenTTD Source 20241224-master-gf74b0cf984
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 (StringID msg, int center, int y, uint8_t duration, TextEffectMode mode)
 
void UpdateTextEffect (TextEffectID te_id, StringID msg)
 
void UpdateAllTextEffectVirtCoords ()
 
void RemoveTextEffect (TextEffectID te_id)
 
void InitTextEffects ()
 
void DrawTextEffects (DrawPixelInfo *dpi)
 

Variables

static std::vector< struct 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 ( StringID  msg,
int  center,
int  y,
uint8_t  duration,
TextEffectMode  mode 
)

Definition at line 41 of file texteff.cpp.

◆ DrawTextEffects()

void DrawTextEffects ( DrawPixelInfo dpi)

Definition at line 118 of file texteff.cpp.

◆ InitTextEffects()

void InitTextEffects ( )

Definition at line 112 of file texteff.cpp.

◆ RemoveTextEffect()

void RemoveTextEffect ( TextEffectID  te_id)

Definition at line 87 of file texteff.cpp.

◆ UpdateAllTextEffectVirtCoords()

void UpdateAllTextEffectVirtCoords ( )

Definition at line 78 of file texteff.cpp.

◆ UpdateTextEffect()

void UpdateTextEffect ( TextEffectID  te_id,
StringID  msg 
)

Definition at line 67 of file texteff.cpp.

Variable Documentation

◆ _text_effects

std::vector<struct TextEffect> _text_effects
static

Text effects are stored there.

Definition at line 38 of file texteff.cpp.

◆ move_all_text_effects_interval

IntervalTimer<TimerWindow> move_all_text_effects_interval
Initial value:
= {std::chrono::milliseconds(30), [](uint count) {
for (TextEffect &te : _text_effects) {
if (te.string_id == INVALID_STRING_ID) 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);
}
}}
@ CMDPL_NO_CONSTRUCTION
No construction actions may be executed.
PauseMode _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:57
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
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< struct TextEffect > _text_effects
Text effects are stored there.
Definition texteff.cpp:38
@ TE_RISING
Make the text effect slowly go upwards.
Definition texteff.hpp:21
@ 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 93 of file texteff.cpp.