XML added attribute version for states

This commit is contained in:
Robert Jelic
2025-10-30 08:14:06 +01:00
parent bf8c6d695c
commit c2621bbafa

View File

@@ -273,7 +273,18 @@ function BaseElement:fromXML(node, scope)
if child.children then if child.children then
for _, stateChild in ipairs(child.children) do for _, stateChild in ipairs(child.children) do
local propName = stateChild.tag local propName = stateChild.tag
local value = convertValue(stateChild.value, scope) local value
if stateChild.attributes and stateChild.attributes.value then
value = convertValue(stateChild.attributes.value, scope)
elseif stateChild.value then
value = convertValue(stateChild.value, scope)
else
log.warn("XMLParser: State property '" .. propName .. "' has no value")
value = nil
end
if value ~= nil then
local capitalizedName = propName:sub(1,1):upper() .. propName:sub(2) local capitalizedName = propName:sub(1,1):upper() .. propName:sub(2)
local methodName = "set"..capitalizedName.."State" local methodName = "set"..capitalizedName.."State"
@@ -284,6 +295,7 @@ function BaseElement:fromXML(node, scope)
end end
end end
end end
end
elseif(self._properties[child.tag])then elseif(self._properties[child.tag])then
if(self._properties[child.tag].type == "table")then if(self._properties[child.tag].type == "table")then
self.set(child.tag, createTableFromNode(child, scope)) self.set(child.tag, createTableFromNode(child, scope))