Files
@ r28356:5479dee3539c
Branch filter:
Location: cpp/openttd-patchpack/source/src/texteff.cpp - annotation
r28356:5479dee3539c
4.2 KiB
text/x-c
Fix: [CI] patch in SHF_COMPRESSED symbol for our Linux Generic binaries (#11651)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6422:5983361e241a r5584:545d748cc681 r6998:9587370cd6e8 r7849:cfd99cb69695 r8114:866ed489ed98 r8225:491804378826 r8270:c2ec53375c9d r27089:0c098eaacf35 r27089:0c098eaacf35 r27089:0c098eaacf35 r5584:545d748cc681 r21383:942c32fb8b0e r21383:942c32fb8b0e r14049:815b288b8078 r14503:957285aedfbf r27684:ef2ec2354566 r14049:815b288b8078 r27737:728d55b97775 r14049:815b288b8078 r14049:815b288b8078 r14049:815b288b8078 r14049:815b288b8078 r14049:815b288b8078 r14049:815b288b8078 r14049:815b288b8078 r14049:815b288b8078 r14049:815b288b8078 r6248:b940b09d7ab8 r5584:545d748cc681 r23538:8df50944b27a r5584:545d748cc681 r7545:2cbf405181b3 r27737:728d55b97775 r5584:545d748cc681 r6998:9587370cd6e8 r5584:545d748cc681 r27876:9b3ff9b7e8ff r27878:15d820d4fa04 r27878:15d820d4fa04 r27878:15d820d4fa04 r27878:15d820d4fa04 r27878:15d820d4fa04 r5584:545d748cc681 r27876:9b3ff9b7e8ff r6998:9587370cd6e8 r6998:9587370cd6e8 r23532:dc91fcd293f5 r23532:dc91fcd293f5 r27684:ef2ec2354566 r23532:dc91fcd293f5 r5584:545d748cc681 r14049:815b288b8078 r23532:dc91fcd293f5 r23532:dc91fcd293f5 r6998:9587370cd6e8 r27876:9b3ff9b7e8ff r6998:9587370cd6e8 r6998:9587370cd6e8 r6998:9587370cd6e8 r6998:9587370cd6e8 r6998:9587370cd6e8 r27877:ce72b7742e5a r27877:ce72b7742e5a r27877:ce72b7742e5a r27877:ce72b7742e5a r6998:9587370cd6e8 r27877:ce72b7742e5a r25359:9796f7058da8 r25359:9796f7058da8 r25359:9796f7058da8 r25359:9796f7058da8 r25359:9796f7058da8 r25371:bdce16c583e0 r27684:ef2ec2354566 r25359:9796f7058da8 r25359:9796f7058da8 r6998:9587370cd6e8 r6998:9587370cd6e8 r6998:9587370cd6e8 r6998:9587370cd6e8 r14078:b9c563f3b6ef r5584:545d748cc681 r5584:545d748cc681 r27089:0c098eaacf35 r27089:0c098eaacf35 r27089:0c098eaacf35 r23127:a13182a294c6 r23536:ce42deb0b32d r23536:ce42deb0b32d r23536:ce42deb0b32d r14079:4360508cef5f r23536:ce42deb0b32d r23536:ce42deb0b32d r14079:4360508cef5f r14079:4360508cef5f r14079:4360508cef5f r23536:ce42deb0b32d r23536:ce42deb0b32d r23536:ce42deb0b32d r23536:ce42deb0b32d r5584:545d748cc681 r27089:0c098eaacf35 r5584:545d748cc681 r6247:96e840dbefcc r5584:545d748cc681 r23522:1fb564b1efa6 r23522:1fb564b1efa6 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r5584:545d748cc681 r14049:815b288b8078 r18462:a1ba75a7f741 r27824:c503500c92b2 r23536:ce42deb0b32d r23536:ce42deb0b32d r27824:c503500c92b2 r27684:ef2ec2354566 r27634:055c9bd809d0 r14049:815b288b8078 r5584:545d748cc681 r5584:545d748cc681 | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file texteff.cpp Handling of text effects. */
#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"
/** Container for all information about a text effect */
struct TextEffect : public ViewportSign {
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_t duration; ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING)
TextEffectMode mode; ///< Type of text effect
/** Reset the text effect */
void Reset()
{
this->MarkDirty();
this->width_normal = 0;
this->string_id = INVALID_STRING_ID;
}
};
static std::vector<struct TextEffect> _text_effects; ///< Text effects are stored there
/* Text Effects */
TextEffectID AddTextEffect(StringID msg, int center, int y, uint8_t duration, TextEffectMode mode)
{
if (_game_mode == GM_MENU) return INVALID_TE_ID;
auto it = std::find_if(std::begin(_text_effects), std::end(_text_effects), [](const TextEffect &te) { return te.string_id == INVALID_STRING_ID; });
if (it == std::end(_text_effects)) {
/* _text_effects.size() is the maximum ID + 1 that has been allocated. We should not allocate INVALID_TE_ID or beyond. */
if (_text_effects.size() >= INVALID_TE_ID) return INVALID_TE_ID;
it = _text_effects.emplace(std::end(_text_effects));
}
TextEffect &te = *it;
/* Start defining this object */
te.string_id = msg;
te.duration = duration;
CopyOutDParam(te.params, 2);
te.mode = mode;
/* Make sure we only dirty the new area */
te.width_normal = 0;
te.UpdatePosition(center, y, msg);
return static_cast<TextEffectID>(it - std::begin(_text_effects));
}
void UpdateTextEffect(TextEffectID te_id, StringID msg)
{
/* Update details */
TextEffect &te = _text_effects[te_id];
if (msg == te.string_id && !HaveDParamChanged(te.params)) return;
te.string_id = msg;
CopyOutDParam(te.params, 2);
te.UpdatePosition(te.center, te.top, te.string_id, te.string_id - 1);
}
void UpdateAllTextEffectVirtCoords()
{
for (auto &te : _text_effects) {
if (te.string_id == INVALID_STRING_ID) continue;
CopyInDParam(te.params);
te.UpdatePosition(te.center, te.top, te.string_id, te.string_id - 1);
}
}
void RemoveTextEffect(TextEffectID te_id)
{
_text_effects[te_id].Reset();
}
/** Slowly move text effects upwards. */
IntervalTimer<TimerWindow> move_all_text_effects_interval = {std::chrono::milliseconds(30), [](uint count) {
if (_pause_mode && _game_mode != GM_EDITOR && _settings_game.construction.command_pause_level <= CMDPL_NO_CONSTRUCTION) return;
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_OUT_8X);
te.duration -= count;
te.top -= count * ZOOM_LVL_BASE;
te.MarkDirty(ZOOM_LVL_OUT_8X);
}
}};
void InitTextEffects()
{
_text_effects.clear();
_text_effects.shrink_to_fit();
}
void DrawTextEffects(DrawPixelInfo *dpi)
{
/* Don't draw the text effects when zoomed out a lot */
if (dpi->zoom > ZOOM_LVL_OUT_8X) return;
if (IsTransparencySet(TO_TEXT)) return;
for (TextEffect &te : _text_effects) {
if (te.string_id == INVALID_STRING_ID) continue;
if (te.mode == TE_RISING || _settings_client.gui.loading_indicators) {
CopyInDParam(te.params);
ViewportAddString(dpi, ZOOM_LVL_OUT_8X, &te, te.string_id, te.string_id - 1, STR_NULL);
}
}
}
|