From 8b7c34d7d4ae76424011133c84cb402335c546af Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 25 Jun 2023 06:27:33 +0200 Subject: [PATCH] Codechange: use string parameter backps for the text effects --- src/texteff.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/texteff.cpp b/src/texteff.cpp index e974160974..ae1e796880 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -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 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); } }