Theme fix + main changes
This commit is contained in:
@@ -222,7 +222,7 @@ local keyEvents = {
|
||||
}
|
||||
|
||||
local function updateEvent(event, ...)
|
||||
if(event=="terminate")then basalt.stop() end
|
||||
if(event=="terminate")then basalt.stop() return end
|
||||
if lazyElementsEventHandler(event, ...) then return end
|
||||
|
||||
if(mouseEvents[event])then
|
||||
@@ -272,6 +272,7 @@ end
|
||||
--- @vararg any The event to run with
|
||||
function basalt.update(...)
|
||||
local f = function(...)
|
||||
basalt.isRunning = true
|
||||
updateEvent(...)
|
||||
renderFrames()
|
||||
end
|
||||
@@ -280,6 +281,7 @@ function basalt.update(...)
|
||||
errorManager.header = "Basalt Runtime Error"
|
||||
errorManager.error(err)
|
||||
end
|
||||
basalt.isRunning = false
|
||||
end
|
||||
|
||||
--- Stops the Basalt runtime
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
local errorManager = require("errorManager")
|
||||
local defaultTheme = {
|
||||
default = {
|
||||
background = colors.lightGray,
|
||||
@@ -160,7 +161,21 @@ function BaseElement:applyTheme()
|
||||
local styles = self:getTheme()
|
||||
if(styles ~= nil) then
|
||||
for prop, value in pairs(styles) do
|
||||
self.set(prop, value)
|
||||
local config = self._properties[prop]
|
||||
if(config)then
|
||||
if((config.type)=="color")then
|
||||
if(type(value)=="string")then
|
||||
if(colors[value])then
|
||||
value = colors[value]
|
||||
else
|
||||
errorManager.error("Invalid color '" .. value .. "' for property '" .. prop .. "' in theme for " .. self._values.type)
|
||||
end
|
||||
end
|
||||
end
|
||||
self.set(prop, value)
|
||||
else
|
||||
errorManager.error("Invalid property '" .. prop .. "' in theme for " .. self._values.type)
|
||||
end
|
||||
end
|
||||
end
|
||||
return self
|
||||
@@ -205,6 +220,11 @@ function ThemeAPI.loadTheme(path)
|
||||
local content = file.readAll()
|
||||
file.close()
|
||||
themes.default = textutils.unserializeJSON(content)
|
||||
if not themes.default then
|
||||
errorManager.error("Failed to load theme from " .. path)
|
||||
end
|
||||
else
|
||||
errorManager.error("Could not open theme file: " .. path)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user