diff --git a/components/lua_ui/text.cpp b/components/lua_ui/text.cpp index 241af981b0..571bdaf403 100644 --- a/components/lua_ui/text.cpp +++ b/components/lua_ui/text.cpp @@ -3,10 +3,13 @@ namespace LuaUi { + LuaText::LuaText() + : mAutoSized(true) + {} + void LuaText::initialize() { WidgetExtension::initialize(); - mAutoSized = true; } bool LuaText::setPropertyRaw(std::string_view name, sol::object value) diff --git a/components/lua_ui/text.hpp b/components/lua_ui/text.hpp index 08de275d23..90a3fc563c 100644 --- a/components/lua_ui/text.hpp +++ b/components/lua_ui/text.hpp @@ -12,6 +12,7 @@ namespace LuaUi MYGUI_RTTI_DERIVED(LuaText) public: + LuaText(); virtual void initialize() override; private: diff --git a/components/lua_ui/textedit.hpp b/components/lua_ui/textedit.hpp index 7d3291692c..3eb5b471c3 100644 --- a/components/lua_ui/textedit.hpp +++ b/components/lua_ui/textedit.hpp @@ -11,8 +11,8 @@ namespace LuaUi { MYGUI_RTTI_DERIVED(LuaTextEdit) - protected: - bool setPropertyRaw(std::string_view name, sol::object value) override; + protected: + bool setPropertyRaw(std::string_view name, sol::object value) override; }; } diff --git a/components/lua_ui/widget.cpp b/components/lua_ui/widget.cpp index 5cbf1f318d..3ce07273f8 100644 --- a/components/lua_ui/widget.cpp +++ b/components/lua_ui/widget.cpp @@ -8,6 +8,13 @@ namespace LuaUi { + WidgetExtension::WidgetExtension() + : mForcedCoord() + , mAbsoluteCoord() + , mRelativeCoord() + , mAnchor() + {} + void WidgetExtension::triggerEvent(std::string_view name, const sol::object& argument = sol::nil) const { auto it = mCallbacks.find(name); @@ -27,11 +34,6 @@ namespace LuaUi void WidgetExtension::initialize() { - mAbsoluteCoord = MyGUI::IntCoord(); - mRelativeCoord = MyGUI::FloatCoord(); - mAnchor = MyGUI::FloatSize(); - mForcedCoord = MyGUI::IntCoord(); - // \todo might be more efficient to only register these if there are Lua callbacks mWidget->eventKeyButtonPressed += MyGUI::newDelegate(this, &WidgetExtension::keyPress); mWidget->eventKeyButtonReleased += MyGUI::newDelegate(this, &WidgetExtension::keyRelease); diff --git a/components/lua_ui/widget.hpp b/components/lua_ui/widget.hpp index fe1ad46716..48b169572f 100644 --- a/components/lua_ui/widget.hpp +++ b/components/lua_ui/widget.hpp @@ -19,6 +19,7 @@ namespace LuaUi class WidgetExtension { public: + WidgetExtension(); // must be called after creating the underlying MyGUI::Widget void create(lua_State* lua, MyGUI::Widget* self); // must be called after before destroying the underlying MyGUI::Widget @@ -42,7 +43,6 @@ namespace LuaUi void updateCoord(); protected: - ~WidgetExtension() {} sol::table makeTable() const; sol::object keyEvent(MyGUI::KeyCode) const; sol::object mouseEvent(int left, int top, MyGUI::MouseButton button) const; diff --git a/components/lua_ui/window.cpp b/components/lua_ui/window.cpp index 874ccb9fa4..b7bb426a63 100644 --- a/components/lua_ui/window.cpp +++ b/components/lua_ui/window.cpp @@ -4,6 +4,12 @@ namespace LuaUi { + LuaWindow::LuaWindow() + : mCaption() + , mPreviousMouse() + , mChangeScale() + {} + void LuaWindow::initialize() { WidgetExtension::initialize(); diff --git a/components/lua_ui/window.hpp b/components/lua_ui/window.hpp index d92bf8dcbf..c04b0a6055 100644 --- a/components/lua_ui/window.hpp +++ b/components/lua_ui/window.hpp @@ -13,6 +13,9 @@ namespace LuaUi { MYGUI_RTTI_DERIVED(LuaWindow) + public: + LuaWindow(); + private: // \todo replace with LuaText when skins are properly implemented MyGUI::TextBox* mCaption;