mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 14:03:26 +02:00
add menu example in playerground module
This commit is contained in:
@@ -48,6 +48,8 @@ void LuaInterface::registerFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getSize", &UIWidget::getSize);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setSize", &UIWidget::resize);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getPosition", &UIWidget::getPosition);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getX", &UIWidget::getX);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getY", &UIWidget::getY);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("moveTo", &UIWidget::moveTo);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("moveChildToIndex", &UIWidget::moveChildToIndex);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getParent", &UIWidget::getParent);
|
||||
@@ -59,6 +61,7 @@ void LuaInterface::registerFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getOpacity", &UIWidget::getOpacity);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setOpacity", &UIWidget::setOpacity);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setStyle", &UIWidget::setStyle);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("applyStyle", &UIWidget::applyStyle);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getStyle", &UIWidget::getStyle);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getMarginTop", &UIWidget::getMarginTop);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("setMarginTop", &UIWidget::setMarginTop);
|
||||
|
@@ -252,6 +252,29 @@ void push_luavalue(const OTMLNodePtr& node)
|
||||
g_lua.pushNil();
|
||||
}
|
||||
|
||||
bool luavalue_cast(int index, OTMLNodePtr& node)
|
||||
{
|
||||
node = OTMLNode::create();
|
||||
node->setUnique(true);
|
||||
if(g_lua.isTable(index)) {
|
||||
g_lua.pushNil();
|
||||
while(g_lua.next(index < 0 ? index-1 : index)) {
|
||||
std::string cnodeName = g_lua.toString(-2);
|
||||
if(g_lua.isTable()) {
|
||||
OTMLNodePtr cnode;
|
||||
if(luavalue_cast(-1, node)) {
|
||||
cnode->setTag(cnodeName);
|
||||
node->addChild(cnode);
|
||||
}
|
||||
} else
|
||||
node->writeAt(cnodeName, g_lua.toString());
|
||||
g_lua.pop();
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// object ptr
|
||||
bool luavalue_cast(int index, LuaObjectPtr& obj) {
|
||||
if(g_lua.isUserdata(index)) {
|
||||
|
@@ -70,6 +70,7 @@ bool luavalue_cast(int index, Size& size);
|
||||
|
||||
// otml nodes
|
||||
void push_luavalue(const OTMLNodePtr& node);
|
||||
bool luavalue_cast(int index, OTMLNodePtr& node);
|
||||
|
||||
// enum
|
||||
template<class T>
|
||||
|
Reference in New Issue
Block a user