mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
new scripting functionality
* dofiles functions to run all scripts inside a directory * new style option ! that evaluates its value from a lua code
This commit is contained in:
@@ -461,6 +461,20 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
|
||||
|
||||
m_loadingStyle = true;
|
||||
try {
|
||||
// translate ! style tags
|
||||
for(const OTMLNodePtr& node : styleNode->children()) {
|
||||
if(node->tag()[0] == '!') {
|
||||
std::string tag = node->tag().substr(1);
|
||||
std::string code = Fw::formatString("tostring(%s)", node->value().c_str());
|
||||
std::string origin = "@" + node->source() + "[" + node->tag() + "]";
|
||||
g_lua.evaluateExpression(code, origin);
|
||||
std::string value = g_lua.popString();
|
||||
|
||||
node->setTag(tag);
|
||||
node->setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
onStyleApply(styleNode->tag(), styleNode);
|
||||
callLuaField("onStyleApply", styleNode->tag(), styleNode);
|
||||
|
||||
@@ -471,7 +485,6 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
|
||||
focus();
|
||||
}
|
||||
m_firstOnStyle = false;
|
||||
|
||||
} catch(Exception& e) {
|
||||
logError("Failed to apply style to widget '", m_id, "' style: ", e.what());
|
||||
}
|
||||
|
Reference in New Issue
Block a user