From 50743fbff7c59c4f6413d004ca27ef87b9b5c0a9 Mon Sep 17 00:00:00 2001 From: Vankata453 <78196474+Vankata453@users.noreply.github.com> Date: Sun, 7 Jan 2024 12:28:59 +0200 Subject: [PATCH] Instantiable `Text` and `TextArray` objects (#2722) `TextObject` and `TextArrayObject` can now be instantiated from scripting. This allows for more possibilities in scripting texts. The former `Text` and `TextArray` instances, which are always added to a `Sector`, have been retained to allow for compatibility. The default `Text` object is used by `TextArea` triggers. Additionally, a function to get/set the text wrap width of a `Text` or `TextArray` text object is added. --- src/object/text_array_object.cpp | 17 +- src/object/text_array_object.hpp | 10 +- src/object/text_object.cpp | 5 +- src/object/text_object.hpp | 14 +- .../{text_array.cpp => text_array_object.cpp} | 94 ++-- .../{text_array.hpp => text_array_object.hpp} | 21 +- src/scripting/{text.cpp => text_object.cpp} | 57 +- src/scripting/{text.hpp => text_object.hpp} | 28 +- src/scripting/wrapper.cpp | 526 ++++++++++++------ src/scripting/wrapper.hpp | 8 +- src/scripting/wrapper.interface.hpp | 4 +- src/supertux/game_object_factory.cpp | 3 - src/supertux/sector.cpp | 4 +- src/supertux/sector.hpp | 4 + src/trigger/text_area.cpp | 4 +- 15 files changed, 524 insertions(+), 275 deletions(-) rename src/scripting/{text_array.cpp => text_array_object.cpp} (67%) rename src/scripting/{text_array.hpp => text_array_object.hpp} (82%) rename src/scripting/{text.cpp => text_object.cpp} (65%) rename src/scripting/{text.hpp => text_object.hpp} (82%) diff --git a/src/object/text_array_object.cpp b/src/object/text_array_object.cpp index 2590aee3577..87bda134ff6 100644 --- a/src/object/text_array_object.cpp +++ b/src/object/text_array_object.cpp @@ -18,7 +18,7 @@ #include "control/input_manager.hpp" TextArrayObject::TextArrayObject(const std::string& name) : - ExposedObject(this), + ExposedObject(this), m_isDone(false), m_isAuto(false), m_keepVisible(false), @@ -32,21 +32,6 @@ TextArrayObject::TextArrayObject(const std::string& name) : m_name = name; } -TextArrayObject::TextArrayObject(const ReaderMapping& reader) : - GameObject(reader), - ExposedObject(this), - m_isDone(false), - m_isAuto(false), - m_keepVisible(false), - m_fadeTransition(true), - m_fadetime(1.0), - m_texts(), - m_curTextIndex(0), - m_lastTextIndex(0), - m_waiting() -{ -} - void TextArrayObject::clear() { diff --git a/src/object/text_array_object.hpp b/src/object/text_array_object.hpp index cbd7f881bdd..141184e2e27 100644 --- a/src/object/text_array_object.hpp +++ b/src/object/text_array_object.hpp @@ -20,11 +20,10 @@ #include #include "squirrel/exposed_object.hpp" -#include "scripting/text_array.hpp" - #include "supertux/game_object.hpp" -#include "supertux/timer.hpp" +#include "scripting/text_array_object.hpp" +#include "supertux/timer.hpp" #include "object/text_object.hpp" #include "object/text_array_item.hpp" @@ -32,18 +31,15 @@ typedef size_t ta_index; /** A text array object intended for narration */ class TextArrayObject final : public GameObject, - public ExposedObject + public ExposedObject { public: TextArrayObject(const std::string& name = ""); - TextArrayObject(const ReaderMapping& reader); - ~TextArrayObject() override = default; virtual void draw(DrawingContext& context) override; virtual void update(float dt_sec) override; - virtual bool is_singleton() const override { return true; } virtual bool is_saveable() const override { return false; } static std::string class_name() { return "text-array"; } diff --git a/src/object/text_object.cpp b/src/object/text_object.cpp index d7e79b56667..adf285292da 100644 --- a/src/object/text_object.cpp +++ b/src/object/text_object.cpp @@ -26,7 +26,7 @@ TextObject::TextObject(const std::string& name) : GameObject(name), - ExposedObject(this), + ExposedObject(this), m_font(Resources::normal_font), m_text(), m_wrapped_text(), @@ -37,6 +37,7 @@ TextObject::TextObject(const std::string& name) : m_anchor(ANCHOR_MIDDLE), m_anchor_offset(0, 0), m_pos(0, 0), + m_wrap_width(500.f), m_front_fill_color(0.6f, 0.7f, 0.8f, 0.5f), m_back_fill_color(0.2f, 0.3f, 0.4f, 0.8f), m_text_color(1.f, 1.f, 1.f, 1.f), @@ -95,7 +96,7 @@ TextObject::wrap_text() do { std::string overflow; - m_wrapped_text += m_font->wrap_to_width(rest, 500, &overflow); + m_wrapped_text += m_font->wrap_to_width(rest, m_wrap_width, &overflow); if (!overflow.empty()) { m_wrapped_text += "\n"; } diff --git a/src/object/text_object.hpp b/src/object/text_object.hpp index 13c41d059e6..1b5a9c06747 100644 --- a/src/object/text_object.hpp +++ b/src/object/text_object.hpp @@ -17,10 +17,11 @@ #ifndef HEADER_SUPERTUX_OBJECT_TEXT_OBJECT_HPP #define HEADER_SUPERTUX_OBJECT_TEXT_OBJECT_HPP -#include "math/anchor_point.hpp" -#include "scripting/text.hpp" #include "squirrel/exposed_object.hpp" #include "supertux/game_object.hpp" + +#include "math/anchor_point.hpp" +#include "scripting/text_object.hpp" #include "video/color.hpp" #include "video/drawing_context.hpp" #include "video/font_ptr.hpp" @@ -30,12 +31,11 @@ class ReaderMapping; /** A text object intended for scripts that want to tell a story */ class TextObject final : public GameObject, - public ExposedObject + public ExposedObject { static Color default_color; public: - TextObject(const ReaderMapping& reader); TextObject(const std::string& name = ""); ~TextObject() override; @@ -48,10 +48,8 @@ class TextObject final : public GameObject, virtual void draw(DrawingContext& context) override; virtual void update(float dt_sec) override; - virtual bool is_singleton() const override { return true; } virtual bool is_saveable() const override { return false; } - void set_text(const std::string& text); void set_font(const std::string& name); void grow_in(float fadetime); @@ -70,6 +68,9 @@ class TextObject final : public GameObject, AnchorPoint get_anchor_point() const { return m_anchor; } void set_anchor_offset(const Vector& offset) { m_anchor_offset = offset; } + float get_wrap_width() const { return m_wrap_width; } + void set_wrap_width(float width) { m_wrap_width = width; } + void set_pos(const Vector& pos) { m_pos = pos; } const Vector& get_pos() const { return m_pos; } @@ -87,6 +88,7 @@ class TextObject final : public GameObject, AnchorPoint m_anchor; Vector m_anchor_offset; Vector m_pos; + float m_wrap_width; Color m_front_fill_color; Color m_back_fill_color; Color m_text_color; diff --git a/src/scripting/text_array.cpp b/src/scripting/text_array_object.cpp similarity index 67% rename from src/scripting/text_array.cpp rename to src/scripting/text_array_object.cpp index ce5a90bc6c2..23b88aa37b6 100644 --- a/src/scripting/text_array.cpp +++ b/src/scripting/text_array_object.cpp @@ -14,85 +14,91 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "scripting/text_array.hpp" -#include "object/text_array_object.hpp" +#include "scripting/text_array_object.hpp" +#include "object/text_array_object.hpp" #include "object/text_object.hpp" +#include "supertux/sector.hpp" namespace scripting { +TextArrayObject::TextArrayObject() : + GameObject(get_sector().add<::TextArrayObject>()) +{ +} + void -TextArray::add_text_duration(const std::string& text, float duration) +TextArrayObject::add_text_duration(const std::string& text, float duration) { SCRIPT_GUARD_VOID; object.add_text(text, duration); } void -TextArray::add_text(const std::string& text) +TextArrayObject::add_text(const std::string& text) { SCRIPT_GUARD_VOID; object.add_text(text); } void -TextArray::clear() +TextArrayObject::clear() { SCRIPT_GUARD_VOID; object.clear(); } void -TextArray::set_fade_transition(bool fade_transition) +TextArrayObject::set_fade_transition(bool fade_transition) { SCRIPT_GUARD_VOID; object.set_fade_transition(fade_transition); } void -TextArray::set_fade_time(float fadetime) +TextArrayObject::set_fade_time(float fadetime) { SCRIPT_GUARD_VOID; object.set_fade_time(fadetime); } void -TextArray::set_text_index(int index) +TextArrayObject::set_text_index(int index) { SCRIPT_GUARD_VOID; object.set_text_index(index); } void -TextArray::next_text() +TextArrayObject::next_text() { SCRIPT_GUARD_VOID; object.next_text(); } void -TextArray::prev_text() +TextArrayObject::prev_text() { SCRIPT_GUARD_VOID; object.prev_text(); } void -TextArray::set_keep_visible(bool keep_visible) +TextArrayObject::set_keep_visible(bool keep_visible) { SCRIPT_GUARD_VOID; object.set_keep_visible(keep_visible); } void -TextArray::set_done(bool done) +TextArrayObject::set_done(bool done) { SCRIPT_GUARD_VOID; object.set_done(done); } void -TextArray::set_auto(bool is_auto) +TextArrayObject::set_auto(bool is_auto) { SCRIPT_GUARD_VOID; object.set_auto(is_auto); @@ -101,7 +107,7 @@ TextArray::set_auto(bool is_auto) /////////// text api void -TextArray::set_text(const std::string& text) +TextArrayObject::set_text(const std::string& text) { SCRIPT_GUARD_VOID; @@ -114,7 +120,7 @@ TextArray::set_text(const std::string& text) } void -TextArray::set_font(const std::string& fontname) +TextArrayObject::set_font(const std::string& fontname) { SCRIPT_GUARD_VOID; @@ -124,7 +130,7 @@ TextArray::set_font(const std::string& fontname) } void -TextArray::fade_in(float fadetime) +TextArrayObject::fade_in(float fadetime) { SCRIPT_GUARD_VOID; @@ -134,7 +140,7 @@ TextArray::fade_in(float fadetime) } void -TextArray::fade_out(float fadetime) +TextArrayObject::fade_out(float fadetime) { SCRIPT_GUARD_VOID; @@ -144,7 +150,7 @@ TextArray::fade_out(float fadetime) } void -TextArray::grow_in(float fadetime) +TextArrayObject::grow_in(float fadetime) { SCRIPT_GUARD_VOID; @@ -154,7 +160,7 @@ TextArray::grow_in(float fadetime) } void -TextArray::grow_out(float fadetime) +TextArrayObject::grow_out(float fadetime) { SCRIPT_GUARD_VOID; @@ -164,7 +170,7 @@ TextArray::grow_out(float fadetime) } void -TextArray::set_visible(bool visible) +TextArrayObject::set_visible(bool visible) { SCRIPT_GUARD_VOID; @@ -174,7 +180,7 @@ TextArray::set_visible(bool visible) } void -TextArray::set_centered(bool centered) +TextArrayObject::set_centered(bool centered) { SCRIPT_GUARD_VOID; @@ -184,7 +190,7 @@ TextArray::set_centered(bool centered) } void -TextArray::set_pos(float x, float y) +TextArrayObject::set_pos(float x, float y) { SCRIPT_GUARD_VOID; @@ -194,33 +200,33 @@ TextArray::set_pos(float x, float y) } float -TextArray::get_pos_x() const +TextArrayObject::get_pos_x() const { SCRIPT_GUARD_DEFAULT; if (auto* textItem = object.get_current_text_item()) { return textItem->text_object.get_pos().x; } else { - log_warning << "TextArray position is not set. Assuming (0,0)" << std::endl; + log_warning << "TextArrayObject position is not set. Assuming (0,0)" << std::endl; return 0; } } float -TextArray::get_pos_y() const +TextArrayObject::get_pos_y() const { SCRIPT_GUARD_DEFAULT; if (auto* textItem = object.get_current_text_item()) { return textItem->text_object.get_pos().y; } else { - log_warning << "TextArray position is not set. Assuming (0,0)" << std::endl; + log_warning << "TextArrayObject position is not set. Assuming (0,0)" << std::endl; return 0; } } void -TextArray::set_anchor_point(int anchor) +TextArrayObject::set_anchor_point(int anchor) { SCRIPT_GUARD_VOID; @@ -230,7 +236,7 @@ TextArray::set_anchor_point(int anchor) } int -TextArray::get_anchor_point() const +TextArrayObject::get_anchor_point() const { SCRIPT_GUARD_DEFAULT; @@ -242,7 +248,7 @@ TextArray::get_anchor_point() const } void -TextArray::set_anchor_offset(float x, float y) +TextArrayObject::set_anchor_offset(float x, float y) { SCRIPT_GUARD_VOID; @@ -251,8 +257,30 @@ TextArray::set_anchor_offset(float x, float y) } } +float +TextArrayObject::get_wrap_width() const +{ + SCRIPT_GUARD_DEFAULT; + + if (auto* textItem = object.get_current_text_item()) { + return textItem->text_object.get_wrap_width(); + } else { + return 0; + } +} + +void +TextArrayObject::set_wrap_width(float width) +{ + SCRIPT_GUARD_VOID; + + if (auto* textItem = object.get_current_text_item()) { + textItem->text_object.set_wrap_width(width); + } +} + void -TextArray::set_front_fill_color(float red, float green, float blue, float alpha) +TextArrayObject::set_front_fill_color(float red, float green, float blue, float alpha) { SCRIPT_GUARD_VOID; if (auto* textItem = object.get_current_text_item()) { @@ -261,7 +289,7 @@ TextArray::set_front_fill_color(float red, float green, float blue, float alpha) } void -TextArray::set_back_fill_color(float red, float green, float blue, float alpha) +TextArrayObject::set_back_fill_color(float red, float green, float blue, float alpha) { SCRIPT_GUARD_VOID; if (auto* textItem = object.get_current_text_item()) { @@ -270,7 +298,7 @@ TextArray::set_back_fill_color(float red, float green, float blue, float alpha) } void -TextArray::set_text_color(float red, float green, float blue, float alpha) +TextArrayObject::set_text_color(float red, float green, float blue, float alpha) { SCRIPT_GUARD_VOID; if (auto* textItem = object.get_current_text_item()) { @@ -279,7 +307,7 @@ TextArray::set_text_color(float red, float green, float blue, float alpha) } void -TextArray::set_roundness(float roundness) +TextArrayObject::set_roundness(float roundness) { SCRIPT_GUARD_VOID; if (auto* textItem = object.get_current_text_item()) { diff --git a/src/scripting/text_array.hpp b/src/scripting/text_array_object.hpp similarity index 82% rename from src/scripting/text_array.hpp rename to src/scripting/text_array_object.hpp index 4786a762671..880254f0077 100644 --- a/src/scripting/text_array.hpp +++ b/src/scripting/text_array_object.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef HEADER_SUPERTUX_SCRIPTING_TEXT_ARRAY_HPP -#define HEADER_SUPERTUX_SCRIPTING_TEXT_ARRAY_HPP +#ifndef HEADER_SUPERTUX_SCRIPTING_TEXT_ARRAY_OBJECT_HPP +#define HEADER_SUPERTUX_SCRIPTING_TEXT_ARRAY_OBJECT_HPP #ifndef SCRIPTING_API #include @@ -29,13 +29,14 @@ class TextArrayObject; namespace scripting { /** - * @summary A ""TextArrayObject"" that was given a name can be controlled by scripts. + * @summary A ""TextArrayObject"" that was given a name (or manually instantiated) can be controlled by scripts. Supports all functions of ${SRG_REF_Text}, applying them to the current text item.${SRG_NEWPARAGRAPH} Intended for scripts with narration. - * @instances A ""TextArrayObject"" is instantiated by placing a definition inside a level. - It can then be accessed by its name from a script or via ""sector.name"" from the console. + * @instances A ""TextArrayObject"" instance is already provided in sectors under ""sector.TextArray"".${SRG_NEWPARAGRAPH} + A ""TextArrayObject"" can also be created in a script or from the console. Constructor:${SRG_NEWPARAGRAPH} + """""" <- TextArrayObject()"""""" */ -class TextArray final +class TextArrayObject final #ifndef SCRIPTING_API : public GameObject<::TextArrayObject> #endif @@ -45,11 +46,13 @@ class TextArray final using GameObject::GameObject; private: - TextArray(const TextArray&) = delete; - TextArray& operator=(const TextArray&) = delete; + TextArrayObject(const TextArrayObject&) = delete; + TextArrayObject& operator=(const TextArrayObject&) = delete; #endif public: + TextArrayObject(); + /* * The text array api. * @see: text_array_object.hpp @@ -127,6 +130,8 @@ class TextArray final void set_anchor_point(int anchor); int get_anchor_point() const; void set_anchor_offset(float x, float y); + float get_wrap_width() const; + void set_wrap_width(float width); void set_front_fill_color(float red, float green, float blue, float alpha); void set_back_fill_color(float red, float green, float blue, float alpha); void set_text_color(float red, float green, float blue, float alpha); diff --git a/src/scripting/text.cpp b/src/scripting/text_object.cpp similarity index 65% rename from src/scripting/text.cpp rename to src/scripting/text_object.cpp index c0ee408d370..4639710dd42 100644 --- a/src/scripting/text.cpp +++ b/src/scripting/text_object.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "scripting/text.hpp" +#include "scripting/text_object.hpp" #include "object/text_object.hpp" #include "supertux/sector.hpp" @@ -22,127 +22,146 @@ namespace scripting { +TextObject::TextObject() : + GameObject(get_sector().add<::TextObject>()) +{ +} + void -Text::set_text(const std::string& text) +TextObject::set_text(const std::string& text) { SCRIPT_GUARD_VOID; object.set_text(text); } void -Text::set_font(const std::string& fontname) +TextObject::set_font(const std::string& fontname) { SCRIPT_GUARD_VOID; object.set_font(fontname); } void -Text::fade_in(float fadetime) +TextObject::fade_in(float fadetime) { SCRIPT_GUARD_VOID; object.fade_in(fadetime); } void -Text::fade_out(float fadetime) +TextObject::fade_out(float fadetime) { SCRIPT_GUARD_VOID; object.fade_out(fadetime); } void -Text::grow_in(float fadetime) +TextObject::grow_in(float fadetime) { SCRIPT_GUARD_VOID; object.grow_in(fadetime); } void -Text::grow_out(float fadetime) +TextObject::grow_out(float fadetime) { SCRIPT_GUARD_VOID; object.grow_out(fadetime); } void -Text::set_visible(bool visible) +TextObject::set_visible(bool visible) { SCRIPT_GUARD_VOID; object.set_visible(visible); } void -Text::set_centered(bool centered) +TextObject::set_centered(bool centered) { SCRIPT_GUARD_VOID; object.set_centered(centered); } void -Text::set_pos(float x, float y) +TextObject::set_pos(float x, float y) { SCRIPT_GUARD_VOID; object.set_pos(Vector(x, y)); } float -Text::get_pos_x() const +TextObject::get_pos_x() const { SCRIPT_GUARD_DEFAULT; return object.get_pos().x; } float -Text::get_pos_y() const +TextObject::get_pos_y() const { SCRIPT_GUARD_DEFAULT; return object.get_pos().y; } void -Text::set_anchor_point(int anchor) +TextObject::set_anchor_point(int anchor) { SCRIPT_GUARD_VOID; object.set_anchor_point(static_cast(anchor)); } int -Text::get_anchor_point() const +TextObject::get_anchor_point() const { SCRIPT_GUARD_DEFAULT; return static_cast(object.get_anchor_point()); } void -Text::set_anchor_offset(float x, float y) +TextObject::set_anchor_offset(float x, float y) { SCRIPT_GUARD_VOID; object.set_anchor_offset(Vector(x, y)); } +float +TextObject::get_wrap_width() const +{ + SCRIPT_GUARD_DEFAULT; + return object.get_wrap_width(); +} + +void +TextObject::set_wrap_width(float width) +{ + SCRIPT_GUARD_VOID; + object.set_wrap_width(width); +} + void -Text::set_front_fill_color(float red, float green, float blue, float alpha) +TextObject::set_front_fill_color(float red, float green, float blue, float alpha) { SCRIPT_GUARD_VOID; object.set_front_fill_color(Color(red, green, blue, alpha)); } void -Text::set_back_fill_color(float red, float green, float blue, float alpha) +TextObject::set_back_fill_color(float red, float green, float blue, float alpha) { SCRIPT_GUARD_VOID; object.set_back_fill_color(Color(red, green, blue, alpha)); } void -Text::set_text_color(float red, float green, float blue, float alpha) +TextObject::set_text_color(float red, float green, float blue, float alpha) { SCRIPT_GUARD_VOID; object.set_text_color(Color(red, green, blue, alpha)); } void -Text::set_roundness(float roundness) +TextObject::set_roundness(float roundness) { SCRIPT_GUARD_VOID; object.set_roundness(roundness); diff --git a/src/scripting/text.hpp b/src/scripting/text_object.hpp similarity index 82% rename from src/scripting/text.hpp rename to src/scripting/text_object.hpp index 4fa7312b4b4..2c80c05f8d6 100644 --- a/src/scripting/text.hpp +++ b/src/scripting/text_object.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef HEADER_SUPERTUX_SCRIPTING_TEXT_HPP -#define HEADER_SUPERTUX_SCRIPTING_TEXT_HPP +#ifndef HEADER_SUPERTUX_SCRIPTING_TEXT_OBJECT_HPP +#define HEADER_SUPERTUX_SCRIPTING_TEXT_OBJECT_HPP #ifndef SCRIPTING_API #include @@ -27,11 +27,12 @@ class TextObject; namespace scripting { /** - * @summary A ""TextObject"" that was given a name can be controlled by scripts. - * @instances A ""TextObject"" is instantiated by placing a definition inside a level. - It can then be accessed by its name from a script or via ""sector.name"" from the console. + * @summary A ""TextObject"" that was given a name (or manually instantiated) can be controlled by scripts. + * @instances A ""TextObject"" instance is already provided in sectors under ""sector.Text"".${SRG_NEWPARAGRAPH} + A ""TextObject"" can also be created in a script or from the console. Constructor:${SRG_NEWPARAGRAPH} + """""" <- TextObject()"""""" */ -class Text final +class TextObject final #ifndef SCRIPTING_API : public GameObject<::TextObject> #endif @@ -41,11 +42,13 @@ class Text final using GameObject::GameObject; private: - Text(const Text&) = delete; - Text& operator=(const Text&) = delete; + TextObject(const TextObject&) = delete; + TextObject& operator=(const TextObject&) = delete; #endif public: + TextObject(); + /** * Sets the text string to be displayed. * @param string $text @@ -115,6 +118,15 @@ class Text final * @param float $y */ void set_anchor_offset(float x, float y); + /** + * Gets the text wrap width of the text. + */ + float get_wrap_width() const; + /** + * Sets the text wrap width of the text. + * @param float $width + */ + void set_wrap_width(float width); /** * Sets the front fill color of the text. * @param float $red diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index 7f50cf09b13..281a3b78a3d 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -9137,21 +9137,44 @@ static SQInteger Spotlight_ease_color_rgba_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_release_hook(SQUserPointer ptr, SQInteger ) +static SQInteger TextObject_release_hook(SQUserPointer ptr, SQInteger ) { - scripting::Text* _this = reinterpret_cast (ptr); + scripting::TextObject* _this = reinterpret_cast (ptr); delete _this; return 0; } -static SQInteger Text_set_text_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_constructor_wrapper(HSQUIRRELVM vm) +{ + + try { + auto _this = new scripting::TextObject(); + if(SQ_FAILED(sq_setinstanceup(vm, 1, _this))) { + sq_throwerror(vm, _SC("Couldn't setup instance of 'TextObject' class")); + return SQ_ERROR; + } + sq_setreleasehook(vm, 1, TextObject_release_hook); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'constructor'")); + return SQ_ERROR; + } + +} + +static SQInteger TextObject_set_text_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_text' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); const SQChar* arg0; if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { @@ -9174,14 +9197,14 @@ static SQInteger Text_set_text_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_font_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_font_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_font' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); const SQChar* arg0; if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { @@ -9204,14 +9227,14 @@ static SQInteger Text_set_font_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_fade_in_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_fade_in_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'fade_in' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9234,14 +9257,14 @@ static SQInteger Text_fade_in_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_fade_out_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_fade_out_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'fade_out' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9264,14 +9287,14 @@ static SQInteger Text_fade_out_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_grow_in_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_grow_in_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'grow_in' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9294,14 +9317,14 @@ static SQInteger Text_grow_in_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_grow_out_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_grow_out_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'grow_out' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9324,14 +9347,14 @@ static SQInteger Text_grow_out_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_visible_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_visible_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_visible' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -9354,14 +9377,14 @@ static SQInteger Text_set_visible_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_centered_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_centered_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_centered' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -9384,14 +9407,14 @@ static SQInteger Text_set_centered_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_pos_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_pos_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_pos' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9419,14 +9442,14 @@ static SQInteger Text_set_pos_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_get_pos_x_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_get_pos_x_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'get_pos_x' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); try { @@ -9445,14 +9468,14 @@ static SQInteger Text_get_pos_x_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_get_pos_y_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_get_pos_y_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'get_pos_y' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); try { @@ -9471,14 +9494,14 @@ static SQInteger Text_get_pos_y_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_anchor_point_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_anchor_point_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_anchor_point' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQInteger arg0; if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { @@ -9501,14 +9524,14 @@ static SQInteger Text_set_anchor_point_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_get_anchor_point_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_get_anchor_point_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'get_anchor_point' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); try { @@ -9527,14 +9550,14 @@ static SQInteger Text_get_anchor_point_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_anchor_offset_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_anchor_offset_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_anchor_offset' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9562,14 +9585,70 @@ static SQInteger Text_set_anchor_offset_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_front_fill_color_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_get_wrap_width_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { + sq_throwerror(vm, _SC("'get_wrap_width' called without instance")); + return SQ_ERROR; + } + scripting::TextObject* _this = reinterpret_cast (data); + + + try { + float return_value = _this->get_wrap_width(); + + sq_pushfloat(vm, return_value); + return 1; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'get_wrap_width'")); + return SQ_ERROR; + } + +} + +static SQInteger TextObject_set_wrap_width_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { + sq_throwerror(vm, _SC("'set_wrap_width' called without instance")); + return SQ_ERROR; + } + scripting::TextObject* _this = reinterpret_cast (data); + + SQFloat arg0; + if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { + sq_throwerror(vm, _SC("Argument 1 not a float")); + return SQ_ERROR; + } + + try { + _this->set_wrap_width(arg0); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'set_wrap_width'")); + return SQ_ERROR; + } + +} + +static SQInteger TextObject_set_front_fill_color_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_front_fill_color' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9607,14 +9686,14 @@ static SQInteger Text_set_front_fill_color_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_back_fill_color_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_back_fill_color_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_back_fill_color' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9652,14 +9731,14 @@ static SQInteger Text_set_back_fill_color_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_text_color_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_text_color_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_text_color' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9697,14 +9776,14 @@ static SQInteger Text_set_text_color_wrapper(HSQUIRRELVM vm) } -static SQInteger Text_set_roundness_wrapper(HSQUIRRELVM vm) +static SQInteger TextObject_set_roundness_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_roundness' called without instance")); return SQ_ERROR; } - scripting::Text* _this = reinterpret_cast (data); + scripting::TextObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9727,21 +9806,44 @@ static SQInteger Text_set_roundness_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_release_hook(SQUserPointer ptr, SQInteger ) +static SQInteger TextArrayObject_release_hook(SQUserPointer ptr, SQInteger ) { - scripting::TextArray* _this = reinterpret_cast (ptr); + scripting::TextArrayObject* _this = reinterpret_cast (ptr); delete _this; return 0; } -static SQInteger TextArray_clear_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_constructor_wrapper(HSQUIRRELVM vm) +{ + + try { + auto _this = new scripting::TextArrayObject(); + if(SQ_FAILED(sq_setinstanceup(vm, 1, _this))) { + sq_throwerror(vm, _SC("Couldn't setup instance of 'TextArrayObject' class")); + return SQ_ERROR; + } + sq_setreleasehook(vm, 1, TextArrayObject_release_hook); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'constructor'")); + return SQ_ERROR; + } + +} + +static SQInteger TextArrayObject_clear_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'clear' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); try { @@ -9759,14 +9861,14 @@ static SQInteger TextArray_clear_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_add_text_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_add_text_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'add_text' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); const SQChar* arg0; if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { @@ -9789,14 +9891,14 @@ static SQInteger TextArray_add_text_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_add_text_duration_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_add_text_duration_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'add_text_duration' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); const SQChar* arg0; if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { @@ -9824,14 +9926,14 @@ static SQInteger TextArray_add_text_duration_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_text_index_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_text_index_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_text_index' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQInteger arg0; if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { @@ -9854,14 +9956,14 @@ static SQInteger TextArray_set_text_index_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_keep_visible_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_keep_visible_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_keep_visible' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -9884,14 +9986,14 @@ static SQInteger TextArray_set_keep_visible_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_fade_transition_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_fade_transition_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_fade_transition' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -9914,14 +10016,14 @@ static SQInteger TextArray_set_fade_transition_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_fade_time_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_fade_time_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_fade_time' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -9944,14 +10046,14 @@ static SQInteger TextArray_set_fade_time_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_done_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_done_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_done' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -9974,14 +10076,14 @@ static SQInteger TextArray_set_done_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_auto_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_auto_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_auto' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -10004,14 +10106,14 @@ static SQInteger TextArray_set_auto_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_next_text_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_next_text_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'next_text' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); try { @@ -10029,14 +10131,14 @@ static SQInteger TextArray_next_text_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_prev_text_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_prev_text_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'prev_text' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); try { @@ -10054,14 +10156,14 @@ static SQInteger TextArray_prev_text_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_text_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_text_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_text' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); const SQChar* arg0; if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { @@ -10084,14 +10186,14 @@ static SQInteger TextArray_set_text_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_font_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_font_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_font' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); const SQChar* arg0; if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { @@ -10114,14 +10216,14 @@ static SQInteger TextArray_set_font_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_fade_in_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_fade_in_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'fade_in' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10144,14 +10246,14 @@ static SQInteger TextArray_fade_in_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_fade_out_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_fade_out_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'fade_out' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10174,14 +10276,14 @@ static SQInteger TextArray_fade_out_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_grow_in_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_grow_in_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'grow_in' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10204,14 +10306,14 @@ static SQInteger TextArray_grow_in_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_grow_out_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_grow_out_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'grow_out' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10234,14 +10336,14 @@ static SQInteger TextArray_grow_out_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_visible_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_visible_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_visible' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -10264,14 +10366,14 @@ static SQInteger TextArray_set_visible_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_centered_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_centered_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_centered' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQBool arg0; if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { @@ -10294,14 +10396,14 @@ static SQInteger TextArray_set_centered_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_pos_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_pos_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_pos' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10329,14 +10431,14 @@ static SQInteger TextArray_set_pos_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_get_pos_x_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_get_pos_x_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'get_pos_x' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); try { @@ -10355,14 +10457,14 @@ static SQInteger TextArray_get_pos_x_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_get_pos_y_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_get_pos_y_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'get_pos_y' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); try { @@ -10381,14 +10483,14 @@ static SQInteger TextArray_get_pos_y_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_anchor_point_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_anchor_point_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_anchor_point' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQInteger arg0; if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { @@ -10411,14 +10513,14 @@ static SQInteger TextArray_set_anchor_point_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_get_anchor_point_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_get_anchor_point_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'get_anchor_point' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); try { @@ -10437,14 +10539,14 @@ static SQInteger TextArray_get_anchor_point_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_anchor_offset_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_anchor_offset_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_anchor_offset' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10472,14 +10574,70 @@ static SQInteger TextArray_set_anchor_offset_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_front_fill_color_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_get_wrap_width_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { + sq_throwerror(vm, _SC("'get_wrap_width' called without instance")); + return SQ_ERROR; + } + scripting::TextArrayObject* _this = reinterpret_cast (data); + + + try { + float return_value = _this->get_wrap_width(); + + sq_pushfloat(vm, return_value); + return 1; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'get_wrap_width'")); + return SQ_ERROR; + } + +} + +static SQInteger TextArrayObject_set_wrap_width_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { + sq_throwerror(vm, _SC("'set_wrap_width' called without instance")); + return SQ_ERROR; + } + scripting::TextArrayObject* _this = reinterpret_cast (data); + + SQFloat arg0; + if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { + sq_throwerror(vm, _SC("Argument 1 not a float")); + return SQ_ERROR; + } + + try { + _this->set_wrap_width(arg0); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'set_wrap_width'")); + return SQ_ERROR; + } + +} + +static SQInteger TextArrayObject_set_front_fill_color_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_front_fill_color' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10517,14 +10675,14 @@ static SQInteger TextArray_set_front_fill_color_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_back_fill_color_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_back_fill_color_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_back_fill_color' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10562,14 +10720,14 @@ static SQInteger TextArray_set_back_fill_color_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_text_color_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_text_color_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_text_color' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -10607,14 +10765,14 @@ static SQInteger TextArray_set_text_color_wrapper(HSQUIRRELVM vm) } -static SQInteger TextArray_set_roundness_wrapper(HSQUIRRELVM vm) +static SQInteger TextArrayObject_set_roundness_wrapper(HSQUIRRELVM vm) { SQUserPointer data; if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, nullptr, SQTrue)) || !data) { sq_throwerror(vm, _SC("'set_roundness' called without instance")); return SQ_ERROR; } - scripting::TextArray* _this = reinterpret_cast (data); + scripting::TextArrayObject* _this = reinterpret_cast (data); SQFloat arg0; if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { @@ -13634,53 +13792,53 @@ void create_squirrel_instance(HSQUIRRELVM v, scripting::Spotlight* object, bool sq_remove(v, -2); // remove root table } -void create_squirrel_instance(HSQUIRRELVM v, scripting::Text* object, bool setup_releasehook) +void create_squirrel_instance(HSQUIRRELVM v, scripting::TextObject* object, bool setup_releasehook) { using namespace wrapper; sq_pushroottable(v); - sq_pushstring(v, "Text", -1); + sq_pushstring(v, "TextObject", -1); if(SQ_FAILED(sq_get(v, -2))) { std::ostringstream msg; - msg << "Couldn't resolved squirrel type 'Text'"; + msg << "Couldn't resolved squirrel type 'TextObject'"; throw SquirrelError(v, msg.str()); } if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { std::ostringstream msg; - msg << "Couldn't setup squirrel instance for object of type 'Text'"; + msg << "Couldn't setup squirrel instance for object of type 'TextObject'"; throw SquirrelError(v, msg.str()); } sq_remove(v, -2); // remove object name if(setup_releasehook) { - sq_setreleasehook(v, -1, Text_release_hook); + sq_setreleasehook(v, -1, TextObject_release_hook); } sq_remove(v, -2); // remove root table } -void create_squirrel_instance(HSQUIRRELVM v, scripting::TextArray* object, bool setup_releasehook) +void create_squirrel_instance(HSQUIRRELVM v, scripting::TextArrayObject* object, bool setup_releasehook) { using namespace wrapper; sq_pushroottable(v); - sq_pushstring(v, "TextArray", -1); + sq_pushstring(v, "TextArrayObject", -1); if(SQ_FAILED(sq_get(v, -2))) { std::ostringstream msg; - msg << "Couldn't resolved squirrel type 'TextArray'"; + msg << "Couldn't resolved squirrel type 'TextArrayObject'"; throw SquirrelError(v, msg.str()); } if(SQ_FAILED(sq_createinstance(v, -1)) || SQ_FAILED(sq_setinstanceup(v, -1, object))) { std::ostringstream msg; - msg << "Couldn't setup squirrel instance for object of type 'TextArray'"; + msg << "Couldn't setup squirrel instance for object of type 'TextArrayObject'"; throw SquirrelError(v, msg.str()); } sq_remove(v, -2); // remove object name if(setup_releasehook) { - sq_setreleasehook(v, -1, TextArray_release_hook); + sq_setreleasehook(v, -1, TextArrayObject_release_hook); } sq_remove(v, -2); // remove root table @@ -16690,355 +16848,397 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register class 'Spotlight'"); } - // Register class Text - sq_pushstring(v, "Text", -1); + // Register class TextObject + sq_pushstring(v, "TextObject", -1); if(sq_newclass(v, SQFalse) < 0) { std::ostringstream msg; - msg << "Couldn't create new class 'Text'"; + msg << "Couldn't create new class 'TextObject'"; throw SquirrelError(v, msg.str()); } + sq_pushstring(v, "constructor", -1); + sq_newclosure(v, &TextObject_constructor_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'constructor'"); + } + sq_pushstring(v, "set_text", -1); - sq_newclosure(v, &Text_set_text_wrapper, 0); + sq_newclosure(v, &TextObject_set_text_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_text'"); } sq_pushstring(v, "set_font", -1); - sq_newclosure(v, &Text_set_font_wrapper, 0); + sq_newclosure(v, &TextObject_set_font_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_font'"); } sq_pushstring(v, "fade_in", -1); - sq_newclosure(v, &Text_fade_in_wrapper, 0); + sq_newclosure(v, &TextObject_fade_in_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'fade_in'"); } sq_pushstring(v, "fade_out", -1); - sq_newclosure(v, &Text_fade_out_wrapper, 0); + sq_newclosure(v, &TextObject_fade_out_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'fade_out'"); } sq_pushstring(v, "grow_in", -1); - sq_newclosure(v, &Text_grow_in_wrapper, 0); + sq_newclosure(v, &TextObject_grow_in_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'grow_in'"); } sq_pushstring(v, "grow_out", -1); - sq_newclosure(v, &Text_grow_out_wrapper, 0); + sq_newclosure(v, &TextObject_grow_out_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'grow_out'"); } sq_pushstring(v, "set_visible", -1); - sq_newclosure(v, &Text_set_visible_wrapper, 0); + sq_newclosure(v, &TextObject_set_visible_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_visible'"); } sq_pushstring(v, "set_centered", -1); - sq_newclosure(v, &Text_set_centered_wrapper, 0); + sq_newclosure(v, &TextObject_set_centered_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_centered'"); } sq_pushstring(v, "set_pos", -1); - sq_newclosure(v, &Text_set_pos_wrapper, 0); + sq_newclosure(v, &TextObject_set_pos_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_pos'"); } sq_pushstring(v, "get_pos_x", -1); - sq_newclosure(v, &Text_get_pos_x_wrapper, 0); + sq_newclosure(v, &TextObject_get_pos_x_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'get_pos_x'"); } sq_pushstring(v, "get_pos_y", -1); - sq_newclosure(v, &Text_get_pos_y_wrapper, 0); + sq_newclosure(v, &TextObject_get_pos_y_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'get_pos_y'"); } sq_pushstring(v, "set_anchor_point", -1); - sq_newclosure(v, &Text_set_anchor_point_wrapper, 0); + sq_newclosure(v, &TextObject_set_anchor_point_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_anchor_point'"); } sq_pushstring(v, "get_anchor_point", -1); - sq_newclosure(v, &Text_get_anchor_point_wrapper, 0); + sq_newclosure(v, &TextObject_get_anchor_point_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'get_anchor_point'"); } sq_pushstring(v, "set_anchor_offset", -1); - sq_newclosure(v, &Text_set_anchor_offset_wrapper, 0); + sq_newclosure(v, &TextObject_set_anchor_offset_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_anchor_offset'"); } + sq_pushstring(v, "get_wrap_width", -1); + sq_newclosure(v, &TextObject_get_wrap_width_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'get_wrap_width'"); + } + + sq_pushstring(v, "set_wrap_width", -1); + sq_newclosure(v, &TextObject_set_wrap_width_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'set_wrap_width'"); + } + sq_pushstring(v, "set_front_fill_color", -1); - sq_newclosure(v, &Text_set_front_fill_color_wrapper, 0); + sq_newclosure(v, &TextObject_set_front_fill_color_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_front_fill_color'"); } sq_pushstring(v, "set_back_fill_color", -1); - sq_newclosure(v, &Text_set_back_fill_color_wrapper, 0); + sq_newclosure(v, &TextObject_set_back_fill_color_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_back_fill_color'"); } sq_pushstring(v, "set_text_color", -1); - sq_newclosure(v, &Text_set_text_color_wrapper, 0); + sq_newclosure(v, &TextObject_set_text_color_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_text_color'"); } sq_pushstring(v, "set_roundness", -1); - sq_newclosure(v, &Text_set_roundness_wrapper, 0); + sq_newclosure(v, &TextObject_set_roundness_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_roundness'"); } if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register class 'Text'"); + throw SquirrelError(v, "Couldn't register class 'TextObject'"); } - // Register class TextArray - sq_pushstring(v, "TextArray", -1); + // Register class TextArrayObject + sq_pushstring(v, "TextArrayObject", -1); if(sq_newclass(v, SQFalse) < 0) { std::ostringstream msg; - msg << "Couldn't create new class 'TextArray'"; + msg << "Couldn't create new class 'TextArrayObject'"; throw SquirrelError(v, msg.str()); } + sq_pushstring(v, "constructor", -1); + sq_newclosure(v, &TextArrayObject_constructor_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'constructor'"); + } + sq_pushstring(v, "clear", -1); - sq_newclosure(v, &TextArray_clear_wrapper, 0); + sq_newclosure(v, &TextArrayObject_clear_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'clear'"); } sq_pushstring(v, "add_text", -1); - sq_newclosure(v, &TextArray_add_text_wrapper, 0); + sq_newclosure(v, &TextArrayObject_add_text_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'add_text'"); } sq_pushstring(v, "add_text_duration", -1); - sq_newclosure(v, &TextArray_add_text_duration_wrapper, 0); + sq_newclosure(v, &TextArrayObject_add_text_duration_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".sb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'add_text_duration'"); } sq_pushstring(v, "set_text_index", -1); - sq_newclosure(v, &TextArray_set_text_index_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_text_index_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_text_index'"); } sq_pushstring(v, "set_keep_visible", -1); - sq_newclosure(v, &TextArray_set_keep_visible_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_keep_visible_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_keep_visible'"); } sq_pushstring(v, "set_fade_transition", -1); - sq_newclosure(v, &TextArray_set_fade_transition_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_fade_transition_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_fade_transition'"); } sq_pushstring(v, "set_fade_time", -1); - sq_newclosure(v, &TextArray_set_fade_time_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_fade_time_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_fade_time'"); } sq_pushstring(v, "set_done", -1); - sq_newclosure(v, &TextArray_set_done_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_done_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_done'"); } sq_pushstring(v, "set_auto", -1); - sq_newclosure(v, &TextArray_set_auto_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_auto_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_auto'"); } sq_pushstring(v, "next_text", -1); - sq_newclosure(v, &TextArray_next_text_wrapper, 0); + sq_newclosure(v, &TextArrayObject_next_text_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'next_text'"); } sq_pushstring(v, "prev_text", -1); - sq_newclosure(v, &TextArray_prev_text_wrapper, 0); + sq_newclosure(v, &TextArrayObject_prev_text_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'prev_text'"); } sq_pushstring(v, "set_text", -1); - sq_newclosure(v, &TextArray_set_text_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_text_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_text'"); } sq_pushstring(v, "set_font", -1); - sq_newclosure(v, &TextArray_set_font_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_font_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_font'"); } sq_pushstring(v, "fade_in", -1); - sq_newclosure(v, &TextArray_fade_in_wrapper, 0); + sq_newclosure(v, &TextArrayObject_fade_in_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'fade_in'"); } sq_pushstring(v, "fade_out", -1); - sq_newclosure(v, &TextArray_fade_out_wrapper, 0); + sq_newclosure(v, &TextArrayObject_fade_out_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'fade_out'"); } sq_pushstring(v, "grow_in", -1); - sq_newclosure(v, &TextArray_grow_in_wrapper, 0); + sq_newclosure(v, &TextArrayObject_grow_in_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'grow_in'"); } sq_pushstring(v, "grow_out", -1); - sq_newclosure(v, &TextArray_grow_out_wrapper, 0); + sq_newclosure(v, &TextArrayObject_grow_out_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'grow_out'"); } sq_pushstring(v, "set_visible", -1); - sq_newclosure(v, &TextArray_set_visible_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_visible_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_visible'"); } sq_pushstring(v, "set_centered", -1); - sq_newclosure(v, &TextArray_set_centered_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_centered_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_centered'"); } sq_pushstring(v, "set_pos", -1); - sq_newclosure(v, &TextArray_set_pos_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_pos_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_pos'"); } sq_pushstring(v, "get_pos_x", -1); - sq_newclosure(v, &TextArray_get_pos_x_wrapper, 0); + sq_newclosure(v, &TextArrayObject_get_pos_x_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'get_pos_x'"); } sq_pushstring(v, "get_pos_y", -1); - sq_newclosure(v, &TextArray_get_pos_y_wrapper, 0); + sq_newclosure(v, &TextArrayObject_get_pos_y_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'get_pos_y'"); } sq_pushstring(v, "set_anchor_point", -1); - sq_newclosure(v, &TextArray_set_anchor_point_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_anchor_point_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_anchor_point'"); } sq_pushstring(v, "get_anchor_point", -1); - sq_newclosure(v, &TextArray_get_anchor_point_wrapper, 0); + sq_newclosure(v, &TextArrayObject_get_anchor_point_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'get_anchor_point'"); } sq_pushstring(v, "set_anchor_offset", -1); - sq_newclosure(v, &TextArray_set_anchor_offset_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_anchor_offset_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_anchor_offset'"); } + sq_pushstring(v, "get_wrap_width", -1); + sq_newclosure(v, &TextArrayObject_get_wrap_width_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'get_wrap_width'"); + } + + sq_pushstring(v, "set_wrap_width", -1); + sq_newclosure(v, &TextArrayObject_set_wrap_width_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'set_wrap_width'"); + } + sq_pushstring(v, "set_front_fill_color", -1); - sq_newclosure(v, &TextArray_set_front_fill_color_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_front_fill_color_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_front_fill_color'"); } sq_pushstring(v, "set_back_fill_color", -1); - sq_newclosure(v, &TextArray_set_back_fill_color_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_back_fill_color_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_back_fill_color'"); } sq_pushstring(v, "set_text_color", -1); - sq_newclosure(v, &TextArray_set_text_color_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_text_color_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_text_color'"); } sq_pushstring(v, "set_roundness", -1); - sq_newclosure(v, &TextArray_set_roundness_wrapper, 0); + sq_newclosure(v, &TextArrayObject_set_roundness_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register function 'set_roundness'"); } if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register class 'TextArray'"); + throw SquirrelError(v, "Couldn't register class 'TextArrayObject'"); } // Register class Thunderstorm diff --git a/src/scripting/wrapper.hpp b/src/scripting/wrapper.hpp index 7cfad2044ad..bb8a329977a 100644 --- a/src/scripting/wrapper.hpp +++ b/src/scripting/wrapper.hpp @@ -62,10 +62,10 @@ class SoundObject; void create_squirrel_instance(HSQUIRRELVM v, scripting::SoundObject* object, bool setup_releasehook = false); class Spotlight; void create_squirrel_instance(HSQUIRRELVM v, scripting::Spotlight* object, bool setup_releasehook = false); -class Text; -void create_squirrel_instance(HSQUIRRELVM v, scripting::Text* object, bool setup_releasehook = false); -class TextArray; -void create_squirrel_instance(HSQUIRRELVM v, scripting::TextArray* object, bool setup_releasehook = false); +class TextObject; +void create_squirrel_instance(HSQUIRRELVM v, scripting::TextObject* object, bool setup_releasehook = false); +class TextArrayObject; +void create_squirrel_instance(HSQUIRRELVM v, scripting::TextArrayObject* object, bool setup_releasehook = false); class Thunderstorm; void create_squirrel_instance(HSQUIRRELVM v, scripting::Thunderstorm* object, bool setup_releasehook = false); class TileMap; diff --git a/src/scripting/wrapper.interface.hpp b/src/scripting/wrapper.interface.hpp index 7b3ee4deeb3..4d73317027e 100644 --- a/src/scripting/wrapper.interface.hpp +++ b/src/scripting/wrapper.interface.hpp @@ -27,8 +27,8 @@ #include "scripting/sector.hpp" #include "scripting/sound_object.hpp" #include "scripting/spotlight.hpp" -#include "scripting/text.hpp" -#include "scripting/text_array.hpp" +#include "scripting/text_object.hpp" +#include "scripting/text_array_object.hpp" #include "scripting/thunderstorm.hpp" #include "scripting/tilemap.hpp" #include "scripting/torch.hpp" diff --git a/src/supertux/game_object_factory.cpp b/src/supertux/game_object_factory.cpp index cabc900e4ed..b88e65934bc 100644 --- a/src/supertux/game_object_factory.cpp +++ b/src/supertux/game_object_factory.cpp @@ -120,8 +120,6 @@ #include "object/sound_object.hpp" #include "object/spawnpoint.hpp" #include "object/spotlight.hpp" -#include "object/text_array_object.hpp" -#include "object/text_object.hpp" #include "object/textscroller.hpp" #include "object/thunderstorm.hpp" #include "object/tilemap.hpp" @@ -282,7 +280,6 @@ GameObjectFactory::init_factories() add_factory("particles-snow"); add_factory("spotlight"); add_factory("textscroller"); - add_factory("text-array"); add_factory("thunderstorm"); add_factory("torch"); add_factory("trampoline", OBJ_PARAM_PORTABLE | OBJ_PARAM_DISPENSABLE); diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index c5104bea501..b30676bef79 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -66,10 +66,10 @@ Sector::Sector(Level& parent) : m_fully_constructed(false), m_foremost_layer(), m_gravity(10.0f), - m_collision_system(new CollisionSystem(*this)) + m_collision_system(new CollisionSystem(*this)), + m_text_object(add("Text")) { add("Effect"); - add("Text"); add("TextArray"); SoundManager::current()->preload("sounds/shoot.wav"); diff --git a/src/supertux/sector.hpp b/src/supertux/sector.hpp index 6df95d15252..8591283fa90 100644 --- a/src/supertux/sector.hpp +++ b/src/supertux/sector.hpp @@ -44,6 +44,7 @@ class Player; class ReaderMapping; class Rectf; class Size; +class TextObject; class TileMap; class Writer; @@ -147,6 +148,7 @@ class Sector final : public Base::Sector Camera& get_camera() const; std::vector get_players() const; DisplayEffect& get_effect() const; + TextObject& get_text_object() const { return m_text_object; } private: uint32_t collision_tile_attributes(const Rectf& dest, const Vector& mov) const; @@ -170,6 +172,8 @@ class Sector final : public Base::Sector std::unique_ptr m_collision_system; + TextObject& m_text_object; + private: Sector(const Sector&) = delete; Sector& operator=(const Sector&) = delete; diff --git a/src/trigger/text_area.cpp b/src/trigger/text_area.cpp index de904bc3dd4..7b3cf996fbd 100644 --- a/src/trigger/text_area.cpp +++ b/src/trigger/text_area.cpp @@ -71,7 +71,7 @@ TextArea::event(Player& player, EventType type) return; } - TextObject& text_object = Sector::get().get_singleton_by_type(); + TextObject& text_object = Sector::get().get_text_object(); m_current_text = 0; m_status = Status::FADING_IN; @@ -95,7 +95,7 @@ TextArea::update(float dt_sec) if (m_timer.check()) { - TextObject& text_object = Sector::get().get_singleton_by_type(); + TextObject& text_object = Sector::get().get_text_object(); switch(m_status) {