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