Text Effects */
| 40 | |
| 41 | /* Text Effects */ |
| 42 | TextEffectID AddTextEffect(EncodedString &&msg, int center, int y, uint8_t duration, TextEffectMode mode) |
| 43 | { |
| 44 | if (_game_mode == GM_MENU) return INVALID_TE_ID; |
| 45 | |
| 46 | auto it = std::ranges::find_if(_text_effects, [](const TextEffect &te) { return !te.IsValid(); }); |
| 47 | if (it == std::end(_text_effects)) { |
| 48 | /* _text_effects.size() is the maximum ID + 1 that has been allocated. We should not allocate INVALID_TE_ID or beyond. */ |
| 49 | if (_text_effects.size() >= INVALID_TE_ID) return INVALID_TE_ID; |
| 50 | it = _text_effects.emplace(std::end(_text_effects)); |
| 51 | } |
| 52 | |
| 53 | TextEffect &te = *it; |
| 54 | |
| 55 | /* Start defining this object */ |
| 56 | te.msg = std::move(msg); |
| 57 | te.duration = duration; |
| 58 | te.mode = mode; |
| 59 | |
| 60 | /* Make sure we only dirty the new area */ |
| 61 | te.width_normal = 0; |
| 62 | te.UpdatePosition(center, y, te.msg.GetDecodedString()); |
| 63 | |
| 64 | return static_cast<TextEffectID>(it - std::begin(_text_effects)); |
| 65 | } |
| 66 | |
| 67 | void UpdateTextEffect(TextEffectID te_id, EncodedString &&msg) |
| 68 | { |
no test coverage detected