| 193 | } |
| 194 | |
| 195 | WidgetExtension* createWidget(const sol::table& layout, bool isRoot, uint64_t depth) |
| 196 | { |
| 197 | static auto widgetTypeMap = widgetTypeToName(); |
| 198 | std::string type = widgetType(layout); |
| 199 | if (widgetTypeMap.find(type) == widgetTypeMap.end()) |
| 200 | throw std::logic_error(std::string("Invalid widget type ") += type); |
| 201 | |
| 202 | std::string name = layout.get_or(LayoutKeys::name, std::string()); |
| 203 | MyGUI::Widget* widget |
| 204 | = MyGUI::Gui::getInstancePtr()->createWidgetT(type, {}, {}, MyGUI::Align::Default, {}, name); |
| 205 | |
| 206 | WidgetExtension* ext = dynamic_cast<WidgetExtension*>(widget); |
| 207 | if (!ext) |
| 208 | throw std::runtime_error("Invalid widget!"); |
| 209 | ext->initialize(layout.lua_state(), widget, isRoot); |
| 210 | |
| 211 | updateWidget(ext, layout, depth); |
| 212 | return ext; |
| 213 | } |
| 214 | |
| 215 | void updateWidget(WidgetExtension* ext, const sol::table& layout, uint64_t depth) |
| 216 | { |
no test coverage detected