mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18636) -Codechange: make TextEffect::duration a value in ticks instead of ticks * 8
This commit is contained in:
parent
e6d6704f32
commit
9cefcdab82
|
@ -722,7 +722,7 @@ void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
|
||||||
msg = STR_INCOME_FLOAT_INCOME;
|
msg = STR_INCOME_FLOAT_INCOME;
|
||||||
}
|
}
|
||||||
SetDParam(0, cost);
|
SetDParam(0, cost);
|
||||||
AddTextEffect(msg, pt.x, pt.y, 0x250, TE_RISING);
|
AddTextEffect(msg, pt.x, pt.y, DAY_TICKS, TE_RISING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
|
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
|
||||||
|
@ -730,7 +730,7 @@ void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
|
||||||
Point pt = RemapCoords(x, y, z);
|
Point pt = RemapCoords(x, y, z);
|
||||||
|
|
||||||
SetDParam(0, cost);
|
SetDParam(0, cost);
|
||||||
AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING);
|
AddTextEffect(STR_FEEDER, pt.x, pt.y, DAY_TICKS, TE_RISING);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
|
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
|
||||||
|
@ -740,7 +740,7 @@ TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID str
|
||||||
assert(string != STR_NULL);
|
assert(string != STR_NULL);
|
||||||
|
|
||||||
SetDParam(0, percent);
|
SetDParam(0, percent);
|
||||||
return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC);
|
return AddTextEffect(string, pt.x, pt.y, 0, TE_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
|
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
/** Container for all information about a text effect */
|
/** Container for all information about a text effect */
|
||||||
struct TextEffect : public ViewportSign{
|
struct TextEffect : public ViewportSign{
|
||||||
StringID string_id; ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid
|
|
||||||
uint16 duration; ///< How long the text effect should stay
|
|
||||||
uint64 params_1; ///< DParam parameter
|
uint64 params_1; ///< DParam parameter
|
||||||
|
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
|
TextEffectMode mode; ///< Type of text effect
|
||||||
|
|
||||||
/** Reset the text effect */
|
/** Reset the text effect */
|
||||||
|
@ -40,7 +40,7 @@ struct TextEffect : public ViewportSign{
|
||||||
static SmallVector<struct TextEffect, 32> _text_effects; ///< Text effects are stored there
|
static SmallVector<struct TextEffect, 32> _text_effects; ///< Text effects are stored there
|
||||||
|
|
||||||
/* Text Effects */
|
/* Text Effects */
|
||||||
TextEffectID AddTextEffect(StringID msg, int center, int y, uint16 duration, TextEffectMode mode)
|
TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode)
|
||||||
{
|
{
|
||||||
if (_game_mode == GM_MENU) return INVALID_TE_ID;
|
if (_game_mode == GM_MENU) return INVALID_TE_ID;
|
||||||
|
|
||||||
|
@ -80,25 +80,21 @@ void RemoveTextEffect(TextEffectID te_id)
|
||||||
_text_effects[te_id].Reset();
|
_text_effects[te_id].Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MoveTextEffect(TextEffect *te)
|
|
||||||
{
|
|
||||||
/* Never expire for duration of 0xFFFF */
|
|
||||||
if (te->duration == 0xFFFF) return;
|
|
||||||
if (te->duration < 8) {
|
|
||||||
te->Reset();
|
|
||||||
} else {
|
|
||||||
te->duration -= 8;
|
|
||||||
te->MarkDirty();
|
|
||||||
te->top--;
|
|
||||||
te->MarkDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MoveAllTextEffects()
|
void MoveAllTextEffects()
|
||||||
{
|
{
|
||||||
const TextEffect *end = _text_effects.End();
|
const TextEffect *end = _text_effects.End();
|
||||||
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
|
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
|
||||||
if (te->string_id != INVALID_STRING_ID && te->mode == TE_RISING) MoveTextEffect(te);
|
if (te->string_id == INVALID_STRING_ID) continue;
|
||||||
|
if (te->mode != TE_RISING) continue;
|
||||||
|
|
||||||
|
if (te->duration-- == 0) {
|
||||||
|
te->Reset();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
te->MarkDirty();
|
||||||
|
te->top--;
|
||||||
|
te->MarkDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ enum TextEffectMode {
|
||||||
typedef uint16 TextEffectID;
|
typedef uint16 TextEffectID;
|
||||||
|
|
||||||
void MoveAllTextEffects();
|
void MoveAllTextEffects();
|
||||||
TextEffectID AddTextEffect(StringID msg, int x, int y, uint16 duration, TextEffectMode mode);
|
TextEffectID AddTextEffect(StringID msg, int x, int y, uint8 duration, TextEffectMode mode);
|
||||||
void InitTextEffects();
|
void InitTextEffects();
|
||||||
void DrawTextEffects(DrawPixelInfo *dpi);
|
void DrawTextEffects(DrawPixelInfo *dpi);
|
||||||
void UpdateTextEffect(TextEffectID effect_id, StringID msg);
|
void UpdateTextEffect(TextEffectID effect_id, StringID msg);
|
||||||
|
|
Loading…
Reference in New Issue