- Fixed createFrame bug
- Added custom XML/Attributes
This commit is contained in:
@@ -98,6 +98,10 @@ end
|
|||||||
function basalt.createFrame()
|
function basalt.createFrame()
|
||||||
local frame = basalt.create("BaseFrame")
|
local frame = basalt.create("BaseFrame")
|
||||||
frame:postInit()
|
frame:postInit()
|
||||||
|
if(main==nil)then
|
||||||
|
main = tostring(term.current())
|
||||||
|
basalt.setActiveFrame(frame, true)
|
||||||
|
end
|
||||||
return frame
|
return frame
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ local XMLParser = {
|
|||||||
end
|
end
|
||||||
i = j + 1
|
i = j + 1
|
||||||
end
|
end
|
||||||
local text = string.sub(xmlText, i);
|
|
||||||
if #stack > 1 then
|
if #stack > 1 then
|
||||||
error("XMLParser: unclosed " .. stack[#stack].tag)
|
error("XMLParser: unclosed " .. stack[#stack].tag)
|
||||||
end
|
end
|
||||||
@@ -170,6 +169,10 @@ end
|
|||||||
|
|
||||||
local BaseElement = {}
|
local BaseElement = {}
|
||||||
|
|
||||||
|
function BaseElement.setup(element)
|
||||||
|
element.defineProperty(element, "customXML", {default = {attributes={},children={}}, type = "table"})
|
||||||
|
end
|
||||||
|
|
||||||
--- Generates this element from XML nodes
|
--- Generates this element from XML nodes
|
||||||
--- @shortDescription Generates this element from XML nodes
|
--- @shortDescription Generates this element from XML nodes
|
||||||
--- @param self BaseElement The element to generate from XML nodes
|
--- @param self BaseElement The element to generate from XML nodes
|
||||||
@@ -196,7 +199,8 @@ function BaseElement:fromXML(node, scope)
|
|||||||
errorManager.error("XMLParser: property '" .. k .. "' not found in element '" .. self:getType() .. "'")
|
errorManager.error("XMLParser: property '" .. k .. "' not found in element '" .. self:getType() .. "'")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
errorManager.error("XMLParser: property '" .. k .. "' not found in element '" .. self:getType() .. "'")
|
local customXML = self.get("customXML")
|
||||||
|
customXML.attributes[k] = convertValue(v, scope)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -229,6 +233,10 @@ function BaseElement:fromXML(node, scope)
|
|||||||
else
|
else
|
||||||
self[child.tag](self)
|
self[child.tag](self)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
local customXML = self.get("customXML")
|
||||||
|
child.value = convertValue(child.value, scope)
|
||||||
|
customXML.children[child.tag] = child
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -241,7 +249,7 @@ local Container = {}
|
|||||||
--- Loads an XML string and parses it into the element
|
--- Loads an XML string and parses it into the element
|
||||||
--- @shortDescription Loads an XML string and parses it into the element
|
--- @shortDescription Loads an XML string and parses it into the element
|
||||||
--- @param self Container The element to load the XML into
|
--- @param self Container The element to load the XML into
|
||||||
--- @param nodes string The XML string to load
|
--- @param content string The XML string to load
|
||||||
--- @param scope table The scope to use
|
--- @param scope table The scope to use
|
||||||
--- @return Container self The element instance
|
--- @return Container self The element instance
|
||||||
function Container:loadXML(content, scope)
|
function Container:loadXML(content, scope)
|
||||||
|
|||||||
Reference in New Issue
Block a user