Applied #189
* There was a bug in OTML saving hotkeys per player because of the way they are storing children and not a straight value. Perhaps you want to look at it ed. Note: Your hotkeys will reset in this revision.
This commit is contained in:
parent
adba4b0da9
commit
914b4bd5f3
|
@ -84,33 +84,43 @@ function terminate()
|
||||||
end
|
end
|
||||||
|
|
||||||
function load()
|
function load()
|
||||||
local hotkeySettings = g_settings.getNode('HotkeysManager')
|
local hotkeySettings = g_settings.getNode('HotkeysManager') or {}
|
||||||
|
if hotkeySettings then
|
||||||
|
local playerHotkeySettings = hotkeySettings[g_game.getLocalPlayer():getName()]
|
||||||
|
|
||||||
local hasCombos = false
|
local hasCombos = false
|
||||||
if hotkeySettings ~= nil then
|
if playerHotkeySettings ~= nil then
|
||||||
for i, v in pairs(hotkeySettings) do
|
for k, setting in pairs(playerHotkeySettings) do
|
||||||
addKeyCombo(nil, v.keyCombo, v)
|
addKeyCombo(nil, setting.keyCombo, setting)
|
||||||
hasCombos = true
|
hasCombos = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- add default F keys combos
|
-- add default F keys combos
|
||||||
if not hasCombos then
|
if not hasCombos then
|
||||||
for i=1,12 do
|
for i=1,12 do
|
||||||
addKeyCombo(nil, 'F' .. i)
|
addKeyCombo(nil, 'F' .. i)
|
||||||
end
|
end
|
||||||
|
for i=1,4 do
|
||||||
|
addKeyCombo(nil, 'Shift+F' .. i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function save()
|
function save()
|
||||||
local hotkeySettings = {}
|
local char = g_game.getLocalPlayer():getName()
|
||||||
|
local hotkeySettings = g_settings.getNode('HotkeysManager') or {}
|
||||||
|
hotkeySettings[char] = {}
|
||||||
for i=1, currentHotkeysList:getChildCount() do
|
for i=1, currentHotkeysList:getChildCount() do
|
||||||
local child = currentHotkeysList:getChildByIndex(i)
|
local child = currentHotkeysList:getChildByIndex(i)
|
||||||
table.insert(hotkeySettings, {keyCombo = child.keyCombo,
|
table.insert(hotkeySettings[char], {
|
||||||
|
keyCombo = child.keyCombo,
|
||||||
autoSend = child.autoSend,
|
autoSend = child.autoSend,
|
||||||
itemId = child.itemId,
|
itemId = child.itemId,
|
||||||
useType = child.useType,
|
useType = child.useType,
|
||||||
value = child.value})
|
value = child.value
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
g_settings.setNode('HotkeysManager', hotkeySettings)
|
g_settings.setNode('HotkeysManager', hotkeySettings)
|
||||||
|
|
|
@ -38,7 +38,7 @@ std::string OTMLEmitter::emitNode(const OTMLNodePtr& node, int currentDepth)
|
||||||
ss << node->tag();
|
ss << node->tag();
|
||||||
|
|
||||||
// add ':' to if the node is unique or has value
|
// add ':' to if the node is unique or has value
|
||||||
if(node->hasValue() || node->isUnique() || node->isNull())
|
if(node->hasValue() || node->isUnique() || node->isNull() || node->hasChildren())
|
||||||
ss << ":";
|
ss << ":";
|
||||||
} else
|
} else
|
||||||
ss << "-";
|
ss << "-";
|
||||||
|
|
Loading…
Reference in New Issue