mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-17 10:10:23 +00:00
Merge branch 'lua_ui_data' into 'master'
Add a data field to Lua UI layouts See merge request OpenMW/openmw!1429
This commit is contained in:
commit
e2c896e4ce
@ -46,6 +46,11 @@ namespace LuaUi
|
||||
}
|
||||
}
|
||||
|
||||
void setLayout(LuaUi::WidgetExtension* ext, const sol::table& layout)
|
||||
{
|
||||
ext->setLayout(layout);
|
||||
}
|
||||
|
||||
LuaUi::WidgetExtension* createWidget(const sol::table& layout, LuaUi::WidgetExtension* parent)
|
||||
{
|
||||
std::string type = widgetType(layout);
|
||||
@ -72,6 +77,7 @@ namespace LuaUi
|
||||
|
||||
setEventCallbacks(ext, layout);
|
||||
setProperties(ext, layout);
|
||||
setLayout(ext, layout);
|
||||
|
||||
Content cont = content(layout);
|
||||
for (size_t i = 0; i < cont.size(); i++)
|
||||
@ -90,6 +96,7 @@ namespace LuaUi
|
||||
{
|
||||
setEventCallbacks(ext, layout);
|
||||
setProperties(ext, layout);
|
||||
setLayout(ext, layout);
|
||||
|
||||
Content newContent = content(layout);
|
||||
|
||||
|
@ -13,13 +13,16 @@ namespace LuaUi
|
||||
, mAbsoluteCoord()
|
||||
, mRelativeCoord()
|
||||
, mAnchor()
|
||||
, mLua{ nullptr }
|
||||
, mWidget{ nullptr }
|
||||
, mLayout{ sol::nil }
|
||||
{}
|
||||
|
||||
void WidgetExtension::triggerEvent(std::string_view name, const sol::object& argument = sol::nil) const
|
||||
{
|
||||
auto it = mCallbacks.find(name);
|
||||
if (it != mCallbacks.end())
|
||||
it->second(argument);
|
||||
it->second(argument, mLayout);
|
||||
}
|
||||
|
||||
void WidgetExtension::create(lua_State* lua, MyGUI::Widget* self)
|
||||
|
@ -43,6 +43,8 @@ namespace LuaUi
|
||||
void setForcedCoord(const MyGUI::IntCoord& offset);
|
||||
void updateCoord();
|
||||
|
||||
void setLayout(const sol::table& layout) { mLayout = layout; }
|
||||
|
||||
protected:
|
||||
sol::table makeTable() const;
|
||||
sol::object keyEvent(MyGUI::KeyCode) const;
|
||||
@ -67,11 +69,12 @@ namespace LuaUi
|
||||
|
||||
private:
|
||||
// use lua_State* instead of sol::state_view because MyGUI requires a default constructor
|
||||
lua_State* mLua;
|
||||
lua_State* mLua;
|
||||
MyGUI::Widget* mWidget;
|
||||
|
||||
std::vector<WidgetExtension*> mContent;
|
||||
std::map<std::string, LuaUtil::Callback, std::less<>> mCallbacks;
|
||||
sol::table mLayout;
|
||||
|
||||
void updateChildrenCoord(MyGUI::Widget*);
|
||||
|
||||
|
@ -46,6 +46,14 @@ A container holding all the widget's children. It has a few important difference
|
||||
|
||||
.. TODO: Talk about skins/templates here when they are ready
|
||||
|
||||
Events
|
||||
------
|
||||
|
||||
| A table mapping event names to `openmw.async.callback` s.
|
||||
| When an event triggers, the callback is called with two arguments:
|
||||
an event-specific value, and that widget's layout table.
|
||||
| See the Widget type pages for information on what events exist, and which first argument they pass.
|
||||
|
||||
Widget types
|
||||
------------
|
||||
|
||||
|
@ -41,7 +41,7 @@ Events
|
||||
:widths: 20 20 60
|
||||
|
||||
* - name
|
||||
- type
|
||||
- first argument type
|
||||
- description
|
||||
* - keyPress
|
||||
- `KeyboardEvent <../openmw_input.html##(KeyboardEvent)>`_
|
||||
|
Loading…
Reference in New Issue
Block a user