17 #ifndef HEADER_SUPERTUX_OBJECT_TEXT_OBJECT_HPP 18 #define HEADER_SUPERTUX_OBJECT_TEXT_OBJECT_HPP 20 #include "supertux/game_object.hpp" 22 #include "math/anchor_point.hpp" 23 #include "video/color.hpp" 24 #include "video/drawing_context.hpp" 25 #include "video/font_ptr.hpp" 40 static Color default_color;
43 static void register_class(ssq::VM& vm);
49 static std::string class_name() {
return "textobject"; }
50 virtual std::string get_class_name()
const override {
return class_name(); }
51 virtual std::string get_exposed_class_name()
const override {
return "TextObject"; }
52 static std::string display_name() {
return _(
"Text"); }
56 virtual const std::string get_icon_path()
const override {
return "images/engine/editor/textarray.png"; }
59 virtual void update(
float dt_sec)
override;
67 void set_text(
const std::string& text);
73 void set_font(
const std::string& fontname);
118 void set_pos(
float x,
float y);
129 #ifdef DOXYGEN_SCRIPTING 135 float get_pos_x()
const;
141 float get_pos_y()
const;
200 void set_text_color(
float red,
float green,
float blue,
float alpha);
212 void set_pos(
const Vector& pos) { m_pos = pos; }
213 const Vector& get_pos()
const {
return m_pos; }
221 std::string m_wrapped_text;
222 float m_fade_progress;
234 AnchorPoint m_anchor;
235 Vector m_anchor_offset;
242 Color m_front_fill_color;
243 Color m_back_fill_color;
void set_visible(bool visible)
Definition: text_object.cpp:138
void set_front_fill_color(float red, float green, float blue, float alpha)
Sets the front fill color of the text.
Definition: text_object.cpp:205
void set_roundness(float roundness)
Definition: text_object.cpp:223
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: text_object.hpp:60
void set_font(const std::string &fontname)
Sets the font of the text to be displayed.
Definition: text_object.cpp:62
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: text_object.hpp:54
void fade_out(float fadetime)
Fades out the specified text for the next ""fadetime"" seconds.
Definition: text_object.cpp:130
void set_wrap_width(float width)
Definition: text_object.cpp:199
void set_pos(float x, float y)
Sets the offset of the text, relative to the anchor point.
Definition: text_object.cpp:157
void grow_in(float fadetime)
Grows in the specified text for the next ""fadetime"" seconds.
Definition: text_object.cpp:102
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it's state.
Definition: text_object.cpp:269
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user's locale.
Definition: text_object.hpp:53
A text object intended for scripts that want to tell a story.
Definition: text_object.hpp:38
void set_centered(bool centered)
Definition: text_object.cpp:151
void set_text_color(float red, float green, float blue, float alpha)
Sets the text color.
Definition: text_object.cpp:217
void set_anchor_point(int anchor)
Sets the anchor point of the text.
Definition: text_object.cpp:175
float get_x() const
Returns the X offset of the text, relative to the anchor point.
Definition: text_object.cpp:163
void grow_out(float fadetime)
Grows out the specified text for the next ""fadetime"" seconds.
Definition: text_object.cpp:112
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
int get_anchor_point() const
Returns the current anchor point of the text (one of the ""ANCHOR_*"" constants; see ${SRG_REF_Anchor...
Definition: text_object.cpp:181
void set_text(const std::string &text)
Sets the text string to be displayed.
Definition: text_object.cpp:95
float get_wrap_width() const
Definition: text_object.cpp:193
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
void fade_in(float fadetime)
Fades in the specified text for the next ""fadetime"" seconds.
Definition: text_object.cpp:120
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
float get_y() const
Returns the Y offset of the text, relative to the anchor point.
Definition: text_object.cpp:169
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: text_object.cpp:229
Definition: reader_mapping.hpp:32
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
void set_anchor_offset(float x, float y)
Sets the anchor offset of the text.
Definition: text_object.cpp:187
void set_back_fill_color(float red, float green, float blue, float alpha)
Sets the back fill color of the text.
Definition: text_object.cpp:211