fixes in Settings/g_configs
This commit is contained in:
parent
98ef0e4574
commit
34f9ecb6c8
|
@ -173,6 +173,11 @@ end
|
|||
|
||||
function Terminal.executeCommand(command)
|
||||
if command == nil or #command == 0 then return end
|
||||
|
||||
logLocked = true
|
||||
Logger.log(LogInfo, '>> ' .. command)
|
||||
logLocked = false
|
||||
|
||||
-- detect and convert commands with simple syntax
|
||||
local realCommand
|
||||
if commandEnv[command] then
|
||||
|
|
|
@ -2,7 +2,7 @@ Settings = {}
|
|||
|
||||
Settings.exists = g_configs.exists
|
||||
Settings.setNode = g_configs.setNode
|
||||
Settings.mergeNode = g_configs.mergeNode
|
||||
Settings.addNode = g_configs.addNode
|
||||
Settings.getNode = g_configs.getNode
|
||||
Settings.remove = g_configs.remove
|
||||
Settings.setList = g_configs.setList
|
||||
|
|
|
@ -123,6 +123,7 @@ void ConfigManager::addNode(const std::string& key, const OTMLNodePtr& node)
|
|||
{
|
||||
OTMLNodePtr clone = node->clone();
|
||||
node->setTag(key);
|
||||
node->setUnique(true);
|
||||
m_confsDoc->addChild(node);
|
||||
}
|
||||
|
||||
|
|
|
@ -243,14 +243,13 @@ void push_otml_subnode_luavalue(const OTMLNodePtr& node)
|
|||
void push_luavalue(const OTMLNodePtr& node)
|
||||
{
|
||||
g_lua.newTable();
|
||||
int currentIndex = 1;
|
||||
for(const OTMLNodePtr& cnode : node->children()) {
|
||||
if(cnode->isUnique()) {
|
||||
push_otml_subnode_luavalue(cnode);
|
||||
if(!g_lua.isNil()) {
|
||||
if(cnode->isUnique()) {
|
||||
g_lua.setField(cnode->tag());
|
||||
} else
|
||||
g_lua.pop();
|
||||
}
|
||||
g_lua.rawSeti(currentIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,15 +260,28 @@ bool luavalue_cast(int index, OTMLNodePtr& node)
|
|||
if(g_lua.isTable(index)) {
|
||||
g_lua.pushNil();
|
||||
while(g_lua.next(index < 0 ? index-1 : index)) {
|
||||
std::string cnodeName = g_lua.toString(-2);
|
||||
bool listItem = false;
|
||||
std::string cnodeName;
|
||||
if(g_lua.isNumber(-2))
|
||||
listItem = true;
|
||||
else
|
||||
cnodeName = g_lua.toString(-2);
|
||||
if(g_lua.isTable()) {
|
||||
OTMLNodePtr cnode;
|
||||
if(luavalue_cast(-1, cnode)) {
|
||||
if(listItem)
|
||||
node->setUnique(false);
|
||||
else
|
||||
cnode->setTag(cnodeName);
|
||||
node->addChild(cnode);
|
||||
}
|
||||
} else
|
||||
node->writeAt(cnodeName, g_lua.toString());
|
||||
} else {
|
||||
std::string value = g_lua.toString();
|
||||
if(listItem)
|
||||
node->writeIn(value);
|
||||
else
|
||||
node->writeAt(cnodeName, value);
|
||||
}
|
||||
g_lua.pop();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -147,6 +147,7 @@ void OTMLNode::write(const T& v) {
|
|||
template<typename T>
|
||||
void OTMLNode::writeAt(const std::string& childTag, const T& v) {
|
||||
OTMLNodePtr child = OTMLNode::create(childTag);
|
||||
child->setUnique(true);
|
||||
child->write<T>(v);
|
||||
addChild(child);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue