LiteRGSS 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/LiteRGSS/Bitmap.cpp +316 -0
- data/ext/LiteRGSS/Bitmap.h +24 -0
- data/ext/LiteRGSS/BlendMode.cpp +202 -0
- data/ext/LiteRGSS/BlendMode.h +20 -0
- data/ext/LiteRGSS/CBitmap_Element.cpp +50 -0
- data/ext/LiteRGSS/CBitmap_Element.h +17 -0
- data/ext/LiteRGSS/CDrawable_Element.cpp +38 -0
- data/ext/LiteRGSS/CDrawable_Element.h +30 -0
- data/ext/LiteRGSS/CRect_Element.h +15 -0
- data/ext/LiteRGSS/CShaderSprite_Element.cpp +17 -0
- data/ext/LiteRGSS/CShaderSprite_Element.h +17 -0
- data/ext/LiteRGSS/CSprite_Element.cpp +15 -0
- data/ext/LiteRGSS/CSprite_Element.h +36 -0
- data/ext/LiteRGSS/CText_Element.cpp +12 -0
- data/ext/LiteRGSS/CText_Element.h +29 -0
- data/ext/LiteRGSS/CTone_Element.h +17 -0
- data/ext/LiteRGSS/CViewport_Element.cpp +224 -0
- data/ext/LiteRGSS/CViewport_Element.h +57 -0
- data/ext/LiteRGSS/Color.cpp +200 -0
- data/ext/LiteRGSS/Color.h +22 -0
- data/ext/LiteRGSS/Fonts.cpp +126 -0
- data/ext/LiteRGSS/Fonts.h +20 -0
- data/ext/LiteRGSS/Graphics.cpp +314 -0
- data/ext/LiteRGSS/Graphics.h +31 -0
- data/ext/LiteRGSS/Graphics.local.cpp +365 -0
- data/ext/LiteRGSS/Graphics.local.h +37 -0
- data/ext/LiteRGSS/Image.cpp +460 -0
- data/ext/LiteRGSS/Image.h +32 -0
- data/ext/LiteRGSS/Input.cpp +664 -0
- data/ext/LiteRGSS/Input.h +38 -0
- data/ext/LiteRGSS/LiteRGSS.cpp +34 -0
- data/ext/LiteRGSS/LiteRGSS.h +113 -0
- data/ext/LiteRGSS/Rect.cpp +324 -0
- data/ext/LiteRGSS/Rect.h +24 -0
- data/ext/LiteRGSS/Shader.cpp +279 -0
- data/ext/LiteRGSS/Shader.h +13 -0
- data/ext/LiteRGSS/ShaderSprite.cpp +78 -0
- data/ext/LiteRGSS/ShaderSprite.h +8 -0
- data/ext/LiteRGSS/Sprite.cpp +495 -0
- data/ext/LiteRGSS/Sprite.h +43 -0
- data/ext/LiteRGSS/Table.cpp +228 -0
- data/ext/LiteRGSS/Table.h +29 -0
- data/ext/LiteRGSS/Table32.cpp +228 -0
- data/ext/LiteRGSS/Table32.h +29 -0
- data/ext/LiteRGSS/Text.cpp +574 -0
- data/ext/LiteRGSS/Text.h +52 -0
- data/ext/LiteRGSS/Texture.hpp +735 -0
- data/ext/LiteRGSS/Tone.cpp +228 -0
- data/ext/LiteRGSS/Tone.h +22 -0
- data/ext/LiteRGSS/Viewport.cpp +491 -0
- data/ext/LiteRGSS/Viewport.h +33 -0
- data/ext/LiteRGSS/Yuki.cpp +29 -0
- data/ext/LiteRGSS/Yuki.h +8 -0
- data/ext/LiteRGSS/Yuki_Gif.cpp +218 -0
- data/ext/LiteRGSS/Yuki_Gif.h +25 -0
- data/ext/LiteRGSS/extconf.rb +8 -0
- data/ext/LiteRGSS/libnsgif.c +1169 -0
- data/ext/LiteRGSS/libnsgif.h +183 -0
- data/ext/LiteRGSS/libnsgif.hpp +184 -0
- data/ext/LiteRGSS/lodepng.cpp +6245 -0
- data/ext/LiteRGSS/lodepng.h +1769 -0
- data/ext/LiteRGSS/lzw.c +377 -0
- data/ext/LiteRGSS/lzw.h +105 -0
- data/ext/LiteRGSS/sf_Text2.cpp +690 -0
- data/ext/LiteRGSS/sf_Text2.hpp +549 -0
- data/ext/LiteRGSS/utils/log.h +21 -0
- metadata +112 -0
@@ -0,0 +1,549 @@
|
|
1
|
+
////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// SFML - Simple and Fast Multimedia Library
|
4
|
+
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
|
5
|
+
//
|
6
|
+
// This software is provided 'as-is', without any express or implied warranty.
|
7
|
+
// In no event will the authors be held liable for any damages arising from the use of this software.
|
8
|
+
//
|
9
|
+
// Permission is granted to anyone to use this software for any purpose,
|
10
|
+
// including commercial applications, and to alter it and redistribute it freely,
|
11
|
+
// subject to the following restrictions:
|
12
|
+
//
|
13
|
+
// 1. The origin of this software must not be misrepresented;
|
14
|
+
// you must not claim that you wrote the original software.
|
15
|
+
// If you use this software in a product, an acknowledgment
|
16
|
+
// in the product documentation would be appreciated but is not required.
|
17
|
+
//
|
18
|
+
// 2. Altered source versions must be plainly marked as such,
|
19
|
+
// and must not be misrepresented as being the original software.
|
20
|
+
//
|
21
|
+
// 3. This notice may not be removed or altered from any source distribution.
|
22
|
+
//
|
23
|
+
////////////////////////////////////////////////////////////
|
24
|
+
|
25
|
+
#ifndef SFML_TEXT2_HPP
|
26
|
+
#define SFML_TEXT2_HPP
|
27
|
+
|
28
|
+
////////////////////////////////////////////////////////////
|
29
|
+
// Headers
|
30
|
+
////////////////////////////////////////////////////////////
|
31
|
+
#include <SFML/Graphics/Export.hpp>
|
32
|
+
#include <SFML/Graphics/Drawable.hpp>
|
33
|
+
#include <SFML/Graphics/Transformable.hpp>
|
34
|
+
#include <SFML/Graphics/Font.hpp>
|
35
|
+
#include <SFML/Graphics/Rect.hpp>
|
36
|
+
#include <SFML/Graphics/VertexArray.hpp>
|
37
|
+
#include <SFML/System/String.hpp>
|
38
|
+
#include <string>
|
39
|
+
#include <vector>
|
40
|
+
|
41
|
+
|
42
|
+
namespace sf
|
43
|
+
{
|
44
|
+
////////////////////////////////////////////////////////////
|
45
|
+
/// \brief Graphical text that can be drawn to a render target
|
46
|
+
///
|
47
|
+
////////////////////////////////////////////////////////////
|
48
|
+
class Text2 : public Drawable, public Transformable
|
49
|
+
{
|
50
|
+
public:
|
51
|
+
|
52
|
+
////////////////////////////////////////////////////////////
|
53
|
+
/// \brief Enumeration of the string drawing styles
|
54
|
+
///
|
55
|
+
////////////////////////////////////////////////////////////
|
56
|
+
enum Style
|
57
|
+
{
|
58
|
+
Regular = 0, ///< Regular characters, no style
|
59
|
+
Bold = 1 << 0, ///< Bold characters
|
60
|
+
Italic = 1 << 1, ///< Italic characters
|
61
|
+
Underlined = 1 << 2, ///< Underlined characters
|
62
|
+
StrikeThrough = 1 << 3 ///< Strike through characters
|
63
|
+
};
|
64
|
+
|
65
|
+
////////////////////////////////////////////////////////////
|
66
|
+
/// \brief Default constructor
|
67
|
+
///
|
68
|
+
/// Creates an empty text.
|
69
|
+
///
|
70
|
+
////////////////////////////////////////////////////////////
|
71
|
+
Text2();
|
72
|
+
|
73
|
+
////////////////////////////////////////////////////////////
|
74
|
+
/// \brief Construct the text from a string, font and size
|
75
|
+
///
|
76
|
+
/// Note that if the used font is a bitmap font, it is not
|
77
|
+
/// scalable, thus not all requested sizes will be available
|
78
|
+
/// to use. This needs to be taken into consideration when
|
79
|
+
/// setting the character size. If you need to display text
|
80
|
+
/// of a certain size, make sure the corresponding bitmap
|
81
|
+
/// font that supports that size is used.
|
82
|
+
///
|
83
|
+
/// \param string Text assigned to the string
|
84
|
+
/// \param font Font used to draw the string
|
85
|
+
/// \param characterSize Base size of characters, in pixels
|
86
|
+
///
|
87
|
+
////////////////////////////////////////////////////////////
|
88
|
+
Text2(const String& string, const Font& font, unsigned int characterSize = 30);
|
89
|
+
|
90
|
+
////////////////////////////////////////////////////////////
|
91
|
+
/// \brief Set the text's string
|
92
|
+
///
|
93
|
+
/// The \a string argument is a sf::String, which can
|
94
|
+
/// automatically be constructed from standard string types.
|
95
|
+
/// So, the following calls are all valid:
|
96
|
+
/// \code
|
97
|
+
/// text.setString("hello");
|
98
|
+
/// text.setString(L"hello");
|
99
|
+
/// text.setString(std::string("hello"));
|
100
|
+
/// text.setString(std::wstring(L"hello"));
|
101
|
+
/// \endcode
|
102
|
+
/// A text's string is empty by default.
|
103
|
+
///
|
104
|
+
/// \param string New string
|
105
|
+
///
|
106
|
+
/// \see getString
|
107
|
+
///
|
108
|
+
////////////////////////////////////////////////////////////
|
109
|
+
void setString(const String& string);
|
110
|
+
|
111
|
+
////////////////////////////////////////////////////////////
|
112
|
+
/// \brief Set the text's font
|
113
|
+
///
|
114
|
+
/// The \a font argument refers to a font that must
|
115
|
+
/// exist as long as the text uses it. Indeed, the text
|
116
|
+
/// doesn't store its own copy of the font, but rather keeps
|
117
|
+
/// a pointer to the one that you passed to this function.
|
118
|
+
/// If the font is destroyed and the text tries to
|
119
|
+
/// use it, the behavior is undefined.
|
120
|
+
///
|
121
|
+
/// \param font New font
|
122
|
+
///
|
123
|
+
/// \see getFont
|
124
|
+
///
|
125
|
+
////////////////////////////////////////////////////////////
|
126
|
+
void setFont(const Font& font);
|
127
|
+
|
128
|
+
////////////////////////////////////////////////////////////
|
129
|
+
/// \brief Set the character size
|
130
|
+
///
|
131
|
+
/// The default size is 30.
|
132
|
+
///
|
133
|
+
/// Note that if the used font is a bitmap font, it is not
|
134
|
+
/// scalable, thus not all requested sizes will be available
|
135
|
+
/// to use. This needs to be taken into consideration when
|
136
|
+
/// setting the character size. If you need to display text
|
137
|
+
/// of a certain size, make sure the corresponding bitmap
|
138
|
+
/// font that supports that size is used.
|
139
|
+
///
|
140
|
+
/// \param size New character size, in pixels
|
141
|
+
///
|
142
|
+
/// \see getCharacterSize
|
143
|
+
///
|
144
|
+
////////////////////////////////////////////////////////////
|
145
|
+
void setCharacterSize(unsigned int size);
|
146
|
+
|
147
|
+
////////////////////////////////////////////////////////////
|
148
|
+
/// \brief Set the line spacing factor
|
149
|
+
///
|
150
|
+
/// The default spacing between lines is defined by the font.
|
151
|
+
/// This method enables you to set a factor for the spacing
|
152
|
+
/// between lines. By default the line spacing factor is 1.
|
153
|
+
///
|
154
|
+
/// \param spacingFactor New line spacing factor
|
155
|
+
///
|
156
|
+
/// \see getLineSpacing
|
157
|
+
///
|
158
|
+
////////////////////////////////////////////////////////////
|
159
|
+
void setLineSpacing(float spacingFactor);
|
160
|
+
|
161
|
+
////////////////////////////////////////////////////////////
|
162
|
+
/// \brief Set the letter spacing factor
|
163
|
+
///
|
164
|
+
/// The default spacing between letters is defined by the font.
|
165
|
+
/// This factor doesn't directly apply to the existing
|
166
|
+
/// spacing between each character, it rather adds a fixed
|
167
|
+
/// space between them which is calculated from the font
|
168
|
+
/// metrics and the character size.
|
169
|
+
/// Note that factors below 1 (including negative numbers) bring
|
170
|
+
/// characters closer to each other.
|
171
|
+
/// By default the letter spacing factor is 1.
|
172
|
+
///
|
173
|
+
/// \param spacingFactor New letter spacing factor
|
174
|
+
///
|
175
|
+
/// \see getLetterSpacing
|
176
|
+
///
|
177
|
+
////////////////////////////////////////////////////////////
|
178
|
+
void setLetterSpacing(float spacingFactor);
|
179
|
+
|
180
|
+
////////////////////////////////////////////////////////////
|
181
|
+
/// \brief Set the text's style
|
182
|
+
///
|
183
|
+
/// You can pass a combination of one or more styles, for
|
184
|
+
/// example sf::Text::Bold | sf::Text::Italic.
|
185
|
+
/// The default style is sf::Text::Regular.
|
186
|
+
///
|
187
|
+
/// \param style New style
|
188
|
+
///
|
189
|
+
/// \see getStyle
|
190
|
+
///
|
191
|
+
////////////////////////////////////////////////////////////
|
192
|
+
void setStyle(Uint32 style);
|
193
|
+
|
194
|
+
////////////////////////////////////////////////////////////
|
195
|
+
/// \brief Set the fill color of the text
|
196
|
+
///
|
197
|
+
/// By default, the text's fill color is opaque white.
|
198
|
+
/// Setting the fill color to a transparent color with an outline
|
199
|
+
/// will cause the outline to be displayed in the fill area of the text.
|
200
|
+
///
|
201
|
+
/// \param color New fill color of the text
|
202
|
+
///
|
203
|
+
/// \see getFillColor
|
204
|
+
///
|
205
|
+
/// \deprecated There is now fill and outline colors instead
|
206
|
+
/// of a single global color.
|
207
|
+
/// Use setFillColor() or setOutlineColor() instead.
|
208
|
+
///
|
209
|
+
////////////////////////////////////////////////////////////
|
210
|
+
SFML_DEPRECATED void setColor(const Color& color);
|
211
|
+
|
212
|
+
////////////////////////////////////////////////////////////
|
213
|
+
/// \brief Set the fill color of the text
|
214
|
+
///
|
215
|
+
/// By default, the text's fill color is opaque white.
|
216
|
+
/// Setting the fill color to a transparent color with an outline
|
217
|
+
/// will cause the outline to be displayed in the fill area of the text.
|
218
|
+
///
|
219
|
+
/// \param color New fill color of the text
|
220
|
+
///
|
221
|
+
/// \see getFillColor
|
222
|
+
///
|
223
|
+
////////////////////////////////////////////////////////////
|
224
|
+
void setFillColor(const Color& color);
|
225
|
+
|
226
|
+
////////////////////////////////////////////////////////////
|
227
|
+
/// \brief Set the outline color of the text
|
228
|
+
///
|
229
|
+
/// By default, the text's outline color is opaque black.
|
230
|
+
///
|
231
|
+
/// \param color New outline color of the text
|
232
|
+
///
|
233
|
+
/// \see getOutlineColor
|
234
|
+
///
|
235
|
+
////////////////////////////////////////////////////////////
|
236
|
+
void setOutlineColor(const Color& color);
|
237
|
+
|
238
|
+
////////////////////////////////////////////////////////////
|
239
|
+
/// \brief Set the thickness of the text's outline
|
240
|
+
///
|
241
|
+
/// By default, the outline thickness is 0.
|
242
|
+
///
|
243
|
+
/// Be aware that using a negative value for the outline
|
244
|
+
/// thickness will cause distorted rendering.
|
245
|
+
///
|
246
|
+
/// \param thickness New outline thickness, in pixels
|
247
|
+
///
|
248
|
+
/// \see getOutlineThickness
|
249
|
+
///
|
250
|
+
////////////////////////////////////////////////////////////
|
251
|
+
void setOutlineThickness(float thickness);
|
252
|
+
|
253
|
+
////////////////////////////////////////////////////////////
|
254
|
+
/// \brief Get the text's string
|
255
|
+
///
|
256
|
+
/// The returned string is a sf::String, which can automatically
|
257
|
+
/// be converted to standard string types. So, the following
|
258
|
+
/// lines of code are all valid:
|
259
|
+
/// \code
|
260
|
+
/// sf::String s1 = text.getString();
|
261
|
+
/// std::string s2 = text.getString();
|
262
|
+
/// std::wstring s3 = text.getString();
|
263
|
+
/// \endcode
|
264
|
+
///
|
265
|
+
/// \return Text's string
|
266
|
+
///
|
267
|
+
/// \see setString
|
268
|
+
///
|
269
|
+
////////////////////////////////////////////////////////////
|
270
|
+
const String& getString() const;
|
271
|
+
|
272
|
+
////////////////////////////////////////////////////////////
|
273
|
+
/// \brief Get the text's font
|
274
|
+
///
|
275
|
+
/// If the text has no font attached, a NULL pointer is returned.
|
276
|
+
/// The returned pointer is const, which means that you
|
277
|
+
/// cannot modify the font when you get it from this function.
|
278
|
+
///
|
279
|
+
/// \return Pointer to the text's font
|
280
|
+
///
|
281
|
+
/// \see setFont
|
282
|
+
///
|
283
|
+
////////////////////////////////////////////////////////////
|
284
|
+
const Font* getFont() const;
|
285
|
+
|
286
|
+
////////////////////////////////////////////////////////////
|
287
|
+
/// \brief Get the character size
|
288
|
+
///
|
289
|
+
/// \return Size of the characters, in pixels
|
290
|
+
///
|
291
|
+
/// \see setCharacterSize
|
292
|
+
///
|
293
|
+
////////////////////////////////////////////////////////////
|
294
|
+
unsigned int getCharacterSize() const;
|
295
|
+
|
296
|
+
////////////////////////////////////////////////////////////
|
297
|
+
/// \brief Get the size of the letter spacing factor
|
298
|
+
///
|
299
|
+
/// \return Size of the letter spacing factor
|
300
|
+
///
|
301
|
+
/// \see setLetterSpacing
|
302
|
+
///
|
303
|
+
////////////////////////////////////////////////////////////
|
304
|
+
float getLetterSpacing() const;
|
305
|
+
|
306
|
+
////////////////////////////////////////////////////////////
|
307
|
+
/// \brief Get the size of the line spacing factor
|
308
|
+
///
|
309
|
+
/// \return Size of the line spacing factor
|
310
|
+
///
|
311
|
+
/// \see setLineSpacing
|
312
|
+
///
|
313
|
+
////////////////////////////////////////////////////////////
|
314
|
+
float getLineSpacing() const;
|
315
|
+
|
316
|
+
////////////////////////////////////////////////////////////
|
317
|
+
/// \brief Get the text's style
|
318
|
+
///
|
319
|
+
/// \return Text's style
|
320
|
+
///
|
321
|
+
/// \see setStyle
|
322
|
+
///
|
323
|
+
////////////////////////////////////////////////////////////
|
324
|
+
Uint32 getStyle() const;
|
325
|
+
|
326
|
+
////////////////////////////////////////////////////////////
|
327
|
+
/// \brief Get the fill color of the text
|
328
|
+
///
|
329
|
+
/// \return Fill color of the text
|
330
|
+
///
|
331
|
+
/// \see setFillColor
|
332
|
+
///
|
333
|
+
/// \deprecated There is now fill and outline colors instead
|
334
|
+
/// of a single global color.
|
335
|
+
/// Use getFillColor() or getOutlineColor() instead.
|
336
|
+
///
|
337
|
+
////////////////////////////////////////////////////////////
|
338
|
+
SFML_DEPRECATED const Color& getColor() const;
|
339
|
+
|
340
|
+
////////////////////////////////////////////////////////////
|
341
|
+
/// \brief Get the fill color of the text
|
342
|
+
///
|
343
|
+
/// \return Fill color of the text
|
344
|
+
///
|
345
|
+
/// \see setFillColor
|
346
|
+
///
|
347
|
+
////////////////////////////////////////////////////////////
|
348
|
+
const Color& getFillColor() const;
|
349
|
+
|
350
|
+
////////////////////////////////////////////////////////////
|
351
|
+
/// \brief Get the outline color of the text
|
352
|
+
///
|
353
|
+
/// \return Outline color of the text
|
354
|
+
///
|
355
|
+
/// \see setOutlineColor
|
356
|
+
///
|
357
|
+
////////////////////////////////////////////////////////////
|
358
|
+
const Color& getOutlineColor() const;
|
359
|
+
|
360
|
+
////////////////////////////////////////////////////////////
|
361
|
+
/// \brief Get the outline thickness of the text
|
362
|
+
///
|
363
|
+
/// \return Outline thickness of the text, in pixels
|
364
|
+
///
|
365
|
+
/// \see setOutlineThickness
|
366
|
+
///
|
367
|
+
////////////////////////////////////////////////////////////
|
368
|
+
float getOutlineThickness() const;
|
369
|
+
|
370
|
+
////////////////////////////////////////////////////////////
|
371
|
+
/// \brief Return the position of the \a index-th character
|
372
|
+
///
|
373
|
+
/// This function computes the visual position of a character
|
374
|
+
/// from its index in the string. The returned position is
|
375
|
+
/// in global coordinates (translation, rotation, scale and
|
376
|
+
/// origin are applied).
|
377
|
+
/// If \a index is out of range, the position of the end of
|
378
|
+
/// the string is returned.
|
379
|
+
///
|
380
|
+
/// \param index Index of the character
|
381
|
+
///
|
382
|
+
/// \return Position of the character
|
383
|
+
///
|
384
|
+
////////////////////////////////////////////////////////////
|
385
|
+
Vector2f findCharacterPos(std::size_t index) const;
|
386
|
+
|
387
|
+
////////////////////////////////////////////////////////////
|
388
|
+
/// \brief Get the local bounding rectangle of the entity
|
389
|
+
///
|
390
|
+
/// The returned rectangle is in local coordinates, which means
|
391
|
+
/// that it ignores the transformations (translation, rotation,
|
392
|
+
/// scale, ...) that are applied to the entity.
|
393
|
+
/// In other words, this function returns the bounds of the
|
394
|
+
/// entity in the entity's coordinate system.
|
395
|
+
///
|
396
|
+
/// \return Local bounding rectangle of the entity
|
397
|
+
///
|
398
|
+
////////////////////////////////////////////////////////////
|
399
|
+
FloatRect getLocalBounds() const;
|
400
|
+
|
401
|
+
////////////////////////////////////////////////////////////
|
402
|
+
/// \brief Get the global bounding rectangle of the entity
|
403
|
+
///
|
404
|
+
/// The returned rectangle is in global coordinates, which means
|
405
|
+
/// that it takes into account the transformations (translation,
|
406
|
+
/// rotation, scale, ...) that are applied to the entity.
|
407
|
+
/// In other words, this function returns the bounds of the
|
408
|
+
/// text in the global 2D world's coordinate system.
|
409
|
+
///
|
410
|
+
/// \return Global bounding rectangle of the entity
|
411
|
+
///
|
412
|
+
////////////////////////////////////////////////////////////
|
413
|
+
FloatRect getGlobalBounds() const;
|
414
|
+
//<< YuriADD
|
415
|
+
|
416
|
+
|
417
|
+
virtual void setDrawShadow(bool drawshadow)
|
418
|
+
{
|
419
|
+
m_geometryNeedUpdate = true;
|
420
|
+
m_DrawShadow = drawshadow;
|
421
|
+
};
|
422
|
+
|
423
|
+
virtual bool getDrawShadow()
|
424
|
+
{
|
425
|
+
return m_DrawShadow;
|
426
|
+
};
|
427
|
+
|
428
|
+
virtual void setNumCharToDraw(Uint32 num)
|
429
|
+
{
|
430
|
+
m_geometryNeedUpdate = true;
|
431
|
+
m_numberCharsToDraw = num;
|
432
|
+
};
|
433
|
+
|
434
|
+
virtual Uint32 getNumCharToDraw() const
|
435
|
+
{
|
436
|
+
return m_numberCharsToDraw;
|
437
|
+
};
|
438
|
+
|
439
|
+
virtual void setLineHeight(float height)
|
440
|
+
{
|
441
|
+
m_lineHeight = height;
|
442
|
+
}
|
443
|
+
|
444
|
+
virtual Uint32 getTextWidth(const String& string) const;
|
445
|
+
//>> YuriAdd
|
446
|
+
private:
|
447
|
+
|
448
|
+
////////////////////////////////////////////////////////////
|
449
|
+
/// \brief Draw the text to a render target
|
450
|
+
///
|
451
|
+
/// \param target Render target to draw to
|
452
|
+
/// \param states Current render states
|
453
|
+
///
|
454
|
+
////////////////////////////////////////////////////////////
|
455
|
+
virtual void draw(RenderTarget& target, RenderStates states) const;
|
456
|
+
|
457
|
+
////////////////////////////////////////////////////////////
|
458
|
+
/// \brief Make sure the text's geometry is updated
|
459
|
+
///
|
460
|
+
/// All the attributes related to rendering are cached, such
|
461
|
+
/// that the geometry is only updated when necessary.
|
462
|
+
///
|
463
|
+
////////////////////////////////////////////////////////////
|
464
|
+
void ensureGeometryUpdate() const;
|
465
|
+
|
466
|
+
////////////////////////////////////////////////////////////
|
467
|
+
// Member data
|
468
|
+
////////////////////////////////////////////////////////////
|
469
|
+
String m_string; ///< String to display
|
470
|
+
const Font* m_font; ///< Font used to display the string
|
471
|
+
unsigned int m_characterSize; ///< Base size of characters, in pixels
|
472
|
+
float m_letterSpacingFactor; ///< Spacing factor between letters
|
473
|
+
float m_lineSpacingFactor; ///< Spacing factor between lines
|
474
|
+
Uint32 m_style; ///< Text style (see Style enum)
|
475
|
+
Color m_fillColor; ///< Text fill color
|
476
|
+
Color m_outlineColor; ///< Text outline color
|
477
|
+
float m_outlineThickness; ///< Thickness of the text's outline
|
478
|
+
mutable VertexArray m_vertices; ///< Vertex array containing the fill geometry
|
479
|
+
mutable VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry
|
480
|
+
mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
|
481
|
+
mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?
|
482
|
+
mutable Uint64 m_fontTextureId; ///< The font texture id
|
483
|
+
//<< YuriAdd
|
484
|
+
bool m_DrawShadow;
|
485
|
+
Uint32 m_numberCharsToDraw;
|
486
|
+
float m_lineHeight;
|
487
|
+
//>> YuriAdd
|
488
|
+
friend class Texture;
|
489
|
+
};
|
490
|
+
} // namespace sf
|
491
|
+
|
492
|
+
|
493
|
+
#endif // SFML_TEXT2_HPP
|
494
|
+
|
495
|
+
|
496
|
+
////////////////////////////////////////////////////////////
|
497
|
+
/// \class sf::Text
|
498
|
+
/// \ingroup graphics
|
499
|
+
///
|
500
|
+
/// sf::Text is a drawable class that allows to easily display
|
501
|
+
/// some text with custom style and color on a render target.
|
502
|
+
///
|
503
|
+
/// It inherits all the functions from sf::Transformable:
|
504
|
+
/// position, rotation, scale, origin. It also adds text-specific
|
505
|
+
/// properties such as the font to use, the character size,
|
506
|
+
/// the font style (bold, italic, underlined and strike through), the
|
507
|
+
/// text color, the outline thickness, the outline color, the character
|
508
|
+
/// spacing, the line spacing and the text to display of course.
|
509
|
+
/// It also provides convenience functions to calculate the
|
510
|
+
/// graphical size of the text, or to get the global position
|
511
|
+
/// of a given character.
|
512
|
+
///
|
513
|
+
/// sf::Text works in combination with the sf::Font class, which
|
514
|
+
/// loads and provides the glyphs (visual characters) of a given font.
|
515
|
+
///
|
516
|
+
/// The separation of sf::Font and sf::Text allows more flexibility
|
517
|
+
/// and better performances: indeed a sf::Font is a heavy resource,
|
518
|
+
/// and any operation on it is slow (often too slow for real-time
|
519
|
+
/// applications). On the other side, a sf::Text is a lightweight
|
520
|
+
/// object which can combine the glyphs data and metrics of a sf::Font
|
521
|
+
/// to display any text on a render target.
|
522
|
+
///
|
523
|
+
/// It is important to note that the sf::Text instance doesn't
|
524
|
+
/// copy the font that it uses, it only keeps a reference to it.
|
525
|
+
/// Thus, a sf::Font must not be destructed while it is
|
526
|
+
/// used by a sf::Text (i.e. never write a function that
|
527
|
+
/// uses a local sf::Font instance for creating a text).
|
528
|
+
///
|
529
|
+
/// See also the note on coordinates and undistorted rendering in sf::Transformable.
|
530
|
+
///
|
531
|
+
/// Usage example:
|
532
|
+
/// \code
|
533
|
+
/// // Declare and load a font
|
534
|
+
/// sf::Font font;
|
535
|
+
/// font.loadFromFile("arial.ttf");
|
536
|
+
///
|
537
|
+
/// // Create a text
|
538
|
+
/// sf::Text text("hello", font);
|
539
|
+
/// text.setCharacterSize(30);
|
540
|
+
/// text.setStyle(sf::Text::Bold);
|
541
|
+
/// text.setFillColor(sf::Color::Red);
|
542
|
+
///
|
543
|
+
/// // Draw it
|
544
|
+
/// window.draw(text);
|
545
|
+
/// \endcode
|
546
|
+
///
|
547
|
+
/// \see sf::Font, sf::Transformable
|
548
|
+
///
|
549
|
+
////////////////////////////////////////////////////////////
|