mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
Codechange: use string parameter backps for the text effects
This commit is contained in:
parent
7ed90a859f
commit
8b7c34d7d4
@ -21,8 +21,7 @@
|
||||
|
||||
/** Container for all information about a text effect */
|
||||
struct TextEffect : public ViewportSign {
|
||||
uint64 params_1; ///< DParam parameter
|
||||
uint64 params_2; ///< second DParam parameter
|
||||
std::vector<StringParameterBackup> params; ///< Backup of string parameters
|
||||
StringID string_id; ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid
|
||||
uint8 duration; ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING)
|
||||
TextEffectMode mode; ///< Type of text effect
|
||||
@ -54,8 +53,7 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text
|
||||
/* Start defining this object */
|
||||
te.string_id = msg;
|
||||
te.duration = duration;
|
||||
te.params_1 = GetDParam(0);
|
||||
te.params_2 = GetDParam(1);
|
||||
CopyOutDParam(te.params, 2);
|
||||
te.mode = mode;
|
||||
|
||||
/* Make sure we only dirty the new area */
|
||||
@ -69,10 +67,9 @@ void UpdateTextEffect(TextEffectID te_id, StringID msg)
|
||||
{
|
||||
/* Update details */
|
||||
TextEffect *te = _text_effects.data() + te_id;
|
||||
if (msg == te->string_id && GetDParam(0) == te->params_1) return;
|
||||
if (msg == te->string_id && !HaveDParamChanged(te->params)) return;
|
||||
te->string_id = msg;
|
||||
te->params_1 = GetDParam(0);
|
||||
te->params_2 = GetDParam(1);
|
||||
CopyOutDParam(te->params, 2);
|
||||
|
||||
te->UpdatePosition(te->center, te->top, te->string_id, te->string_id - 1);
|
||||
}
|
||||
@ -81,8 +78,7 @@ void UpdateAllTextEffectVirtCoords()
|
||||
{
|
||||
for (auto &te : _text_effects) {
|
||||
if (te.string_id == INVALID_STRING_ID) continue;
|
||||
SetDParam(0, te.params_1);
|
||||
SetDParam(1, te.params_2);
|
||||
CopyInDParam(te.params);
|
||||
te.UpdatePosition(te.center, te.top, te.string_id, te.string_id - 1);
|
||||
}
|
||||
}
|
||||
@ -126,8 +122,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
|
||||
for (TextEffect &te : _text_effects) {
|
||||
if (te.string_id == INVALID_STRING_ID) continue;
|
||||
if (te.mode == TE_RISING || (_settings_client.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) {
|
||||
SetDParam(0, te.params_1);
|
||||
SetDParam(1, te.params_2);
|
||||
CopyInDParam(te.params);
|
||||
ViewportAddString(dpi, ZOOM_LVL_OUT_8X, &te, te.string_id, te.string_id - 1, STR_NULL);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user