Etterna 0.74.4
Loading...
Searching...
No Matches
BitmapText.h
1#ifndef BITMAP_TEXT_H
2#define BITMAP_TEXT_H
3
4#include "Actor.h"
5
6class RageTexture;
7class Font;
10class BitmapText : public Actor
11{
12 public:
13 BitmapText();
14 BitmapText(const BitmapText& cpy);
15 auto operator=(const BitmapText& cpy) -> BitmapText&;
16 ~BitmapText() override;
17
18 void LoadFromNode(const XNode* pNode) override;
19 [[nodiscard]] auto Copy() const -> BitmapText* override;
20
22 {
23 // We'd be better off not adding strokes to things we can't control
24 // themewise (ScreenDebugOverlay for example). -Midiman
26 : m_stroke_color(RageColor(0, 0, 0, 0))
27 {
28 }
29 static void MakeWeightedAverage(BMT_TweenState& out,
30 BMT_TweenState const& from,
31 BMT_TweenState const& to,
32 float between);
33 auto operator==(BMT_TweenState const& other) const -> bool;
34 auto operator!=(BMT_TweenState const& other) const -> bool
35 {
36 return !operator==(other);
37 }
38 void SetStrokeColor(RageColor const& c) { m_stroke_color = c; }
39 [[nodiscard]] auto GetStrokeColor() const -> RageColor const&
40 {
41 return m_stroke_color;
42 }
43
44 private:
45 RageColor m_stroke_color;
46 };
47
48 auto BMT_DestTweenState() -> BMT_TweenState&
49 {
50 if (BMT_Tweens.empty()) {
51 return BMT_current;
52 }
53
54 return BMT_Tweens.back();
55 }
56
57 [[nodiscard]] auto BMT_DestTweenState() const -> BMT_TweenState const&
58 {
59 return const_cast<BitmapText*>(this)->BMT_DestTweenState();
60 }
61
62 void SetCurrentTweenStart() override;
63 void EraseHeadTween() override;
64 void UpdatePercentThroughTween(float between) override;
65 void BeginTweening(float time, ITween* interp) override;
66 // This function exists because the compiler tried to connect a call of
67 // "BeginTweening(1.2f)" to the function above. -Kyz
68 virtual void BeginTweening(float time, TweenType tt = TWEEN_LINEAR) override
69 {
70 Actor::BeginTweening(time, tt);
71 }
72 void StopTweening() override;
73 void FinishTweening() override;
74
75 auto LoadFromFont(const std::string& sFontName) -> bool;
76 auto LoadFromTextureAndChars(const std::string& sTexturePath,
77 const std::string& sChars) -> bool;
78 virtual void SetText(const std::string& sText,
79 const std::string& sAlternateText = "",
80 int iWrapWidthPixels = -1);
81 void SetVertSpacing(int iSpacing);
82 void SetMaxWidth(float fMaxWidth);
83 void SetMaxHeight(float fMaxHeight);
84 void SetMaxDimUseZoom(bool use);
85 void SetWrapWidthPixels(int iWrapWidthPixels);
86 void CropLineToWidth(size_t l, int width);
87 void CropToWidth(int width);
88
89 [[nodiscard]] auto EarlyAbortDraw() const -> bool override;
90 void DrawPrimitives() override;
91
92 void SetUppercase(bool b);
93 void SetRainbowScroll(bool b) { m_bRainbowScroll = b; }
94 void SetJitter(bool b) { m_bJitter = b; }
95 void SetDistortion(float f);
96 void UnSetDistortion();
97 void set_mult_attrs_with_diffuse(bool m);
98 [[nodiscard]] auto get_mult_attrs_with_diffuse() const -> bool;
99
100 void SetHorizAlign(float f) override;
101
102 void SetStrokeColor(const RageColor& c)
103 {
104 BMT_DestTweenState().SetStrokeColor(c);
105 }
106 auto GetStrokeColor() -> RageColor const&
107 {
108 return BMT_DestTweenState().GetStrokeColor();
109 }
110 void SetCurrStrokeColor(const RageColor& c)
111 {
112 BMT_current.SetStrokeColor(c);
113 }
114 auto GetCurrStrokeColor() -> RageColor const&
115 {
116 return BMT_current.GetStrokeColor();
117 }
118
119 void SetTextGlowMode(TextGlowMode tgm) { m_TextGlowMode = tgm; }
120
121 void GetLines(std::vector<std::wstring>& wTextLines) const
122 {
123 wTextLines = m_wTextLines;
124 }
125
126 [[nodiscard]] auto GetLines() const -> const std::vector<std::wstring>&
127 {
128 return m_wTextLines;
129 }
130
131 [[nodiscard]] auto GetText() const -> std::string { return m_sText; }
132 // Return true if the string 's' will use an alternate string, if available.
133 [[nodiscard]] auto StringWillUseAlternate(
134 const std::string& sText,
135 const std::string& sAlternateText) const -> bool;
136
138 {
139 int length{ -1 };
140 RageColor diffuse[NUM_DIFFUSE_COLORS];
141 RageColor glow;
142
143 void FromStack(lua_State* L, int iPos);
144 };
145
146 [[nodiscard]] auto GetDefaultAttribute() const -> Attribute;
147 void AddAttribute(size_t iPos, const Attribute& attr);
148 void ClearAttributes();
149
150 // Commands
151 void PushSelf(lua_State* L) override;
152
153 std::vector<RageSpriteVertex> m_aVertices;
154
155 protected:
156 Font* m_pFont;
157 bool m_bUppercase;
158 std::string m_sText;
159 std::vector<std::wstring> m_wTextLines;
160 std::vector<int> m_iLineWidths; // in source pixels
161 int m_iWrapWidthPixels; // -1 = no wrap
162 float m_fMaxWidth; // 0 = no max
163 float m_fMaxHeight; // 0 = no max
164 bool m_MaxDimensionUsesZoom;
165 bool m_bRainbowScroll;
166 bool m_bJitter;
167 bool m_bUsingDistortion;
168 bool m_mult_attrs_with_diffuse;
169 float m_fDistortion;
170 int m_iVertSpacing;
171
172 std::vector<FontPageTextures*> m_vpFontPageTextures;
173 std::map<size_t, Attribute> m_mAttributes;
174 bool m_bHasGlowAttribute;
175
176 TextGlowMode m_TextGlowMode;
177
178 // recalculate the items in SetText()
179 void BuildChars();
180 void DrawChars(bool bUseStrokeTexture);
181 void UpdateBaseZoom();
182
183 private:
184 void SetTextInternal();
185 std::vector<BMT_TweenState> BMT_Tweens;
186 BMT_TweenState BMT_current;
187 BMT_TweenState BMT_start;
188};
189
190// With the addition of Attributes to BitmapText, this class may very well be
191// redundant. (Leave it in for now, though.) -aj
193{
194 public:
195 [[nodiscard]] auto Copy() const -> ColorBitmapText* override;
196 void SetText(const std::string& sText,
197 const std::string& sAlternateText = "",
198 int iWrapWidthPixels = -1) override;
199 void ResetText();
200 void DrawPrimitives() override;
201 int lines = 0;
202 void SetMaxLines(int iNumLines, int iDirection, unsigned int& scroll);
203 void SetMaxLines(int iLines, bool bCutBottom = true); // if bCutBottom =
204 // false then, it will
205 // crop the top
206 void SimpleAddLine(const std::string& sAddition, int iWidthPixels);
207 void SetMaxLines(int iNumLines, int iDirection);
208 void PushSelf(lua_State* L) override;
209
210 protected:
212 {
213 RageColor c; // Color to change to
214 int l{}; // Change Location
215 };
216 std::vector<ColorChange> m_vColors;
217};
218
219#endif
Base class for all objects that appear on the screen.
Definition Actor.h:77
An actor that holds a Font and draws text to the screen.
Definition BitmapText.h:11
auto EarlyAbortDraw() const -> bool override
Allow the Actor to be aborted early.
Definition BitmapText.cpp:754
void DrawPrimitives() override
Draw the primitives of the Actor.
Definition BitmapText.cpp:762
Definition BitmapText.h:193
Definition Font.h:139
The interface for simple interpolation.
Definition Tween.h:29
Definition RageTexture.h:14
Definition XmlFile.h:95
Definition BitmapText.h:138
Definition BitmapText.h:22
Definition BitmapText.h:212
The textures used by the font.
Definition Font.h:15
Definition RageTypes.h:332
Definition RageTypes.h:557