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:
Eduardo Bart
2012-04-26 12:11:03 -03:00
parent 243bd3a930
commit fae2cc6481
5 changed files with 44 additions and 28 deletions

View File

@@ -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());
}