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