bezel.lua
Bezel = {
["top"] = Geyser.Label:new({ name = "Bezel.top", x = 0, y = 0, width = 0, height = 0 }),
["left"] = Geyser.Label:new({ name = "Bezel.left", x = 0, y = 0, width = 0, height = 0 }),
["right"] = Geyser.Label:new({ name = "Bezel.right", x = 0, y = 0, width = 0, height = 0 }),
["bottom"] = Geyser.Label:new({ name = "Bezel.bottom", x = 0, y = 0, width = 0, height = 0 }),
["displayed"] = "none"
}
function Bezel.set(_imageSet)
local setConfig = Bezel.parseSettings(_imageSet)
setBorderSizes( setConfig.border_top, setConfig.border_right, setConfig.border_bottom, setConfig.border_left )
Bezel.top = Geyser.Label:new({ name = "Bezel.top", x = setConfig.label_top.x, y = setConfig.label_top.y, width = setConfig.label_top.width, height = setConfig.label_top.height })
Bezel.left = Geyser.Label:new({ name = "Bezel.left", x = setConfig.label_left.x, y = setConfig.label_left.y, width = setConfig.label_left.width, height = setConfig.label_left.height })
Bezel.right = Geyser.Label:new({ name = "Bezel.right", x = setConfig.label_right.x, y = setConfig.label_right.y, width = setConfig.label_right.width, height = setConfig.label_right.height })
Bezel.bottom = Geyser.Label:new({ name = "Bezel.bottom", x = setConfig.label_bottom.x, y = setConfig.label_bottom.y, width = setConfig.label_bottom.width, height = setConfig.label_bottom.height })
Bezel.top:setStyleSheet( [[background-color: #00000000;]] )
Bezel.left:setStyleSheet( [[background-color: #00000000;]] )
Bezel.right:setStyleSheet( [[background-color: #00000000;]] )
Bezel.bottom:setStyleSheet( [[background-color: #00000000;]] )
Bezel.top:setBackgroundImage( cloudDir..[[GUI\images\]].._imageSet..[[\top.png]] )
Bezel.left:setBackgroundImage( cloudDir..[[GUI\images\]].._imageSet..[[\left.png]] )
Bezel.right:setBackgroundImage( cloudDir..[[GUI\images\]].._imageSet..[[\right.png]] )
Bezel.bottom:setBackgroundImage( cloudDir..[[GUI\images\]].._imageSet..[[\bottom.png]] )
Bezel.top:lower()
Bezel.left:lower()
Bezel.right:lower()
Bezel.bottom:lower()
Bezel.displayed = _imageSet
raiseEvent("bezel set", _imageSet)
end
function Bezel.parseSettings(_imageSet)
local _dimFilePath = cloudDir..[[GUI\images\]].._imageSet..[[\dim.list]]
local _dimIterator = io.lines(cloudDir..[[GUI\images\]].._imageSet..[[\dim.list]])
local _dimTable = {}
local _fileReadTable = {}
for _fileLine in io.lines(cloudDir.."GUI/images/".._imageSet.."/dim.list") do
table.insert(_fileReadTable,_fileLine)
end
local _fileReadTableClean = table.deepcopy(_fileReadTable)
for i,v in ipairs(_fileReadTableClean) do
_fileReadTableClean[i] = string.gsub(v,"#.*$","") _fileReadTableClean[i] = string.trim( _fileReadTableClean[i]) end
for i,v in ipairs(_fileReadTableClean) do
if string.find( string.lower(v), "^border" ) then
local _type, _size = string.match( string.lower(v), "^(border_%w+)%s+(-?%d+)%s*$" )
if _type then
_dimTable[string.lower(_type)] = tonumber(_size)
else
error("Malformed border definition at line ".. i .." in "..cloudDir.."GUI/images/".._imageSet.."/dim.list - \"".._fileReadTableClean[i].."\"")
end
elseif string.find( string.lower(v), "^label" ) then
local _type, _x, _y, _w, _h = string.match( string.lower(v), "^(label_%w+)%s+(-?%d+)%s+(-?%d+)%s+(-?%d+)%s+(-?%d+)%s*$" )
if _type then
_dimTable[string.lower(_type)] = {
["x"] = tonumber(_x),
["y"] = tonumber(_y),
["width"] = tonumber(_w),
["height"] = tonumber(_h),
}
else
error("Malformed label definition at line ".. i .." in "..cloudDir.."GUI/images/".._imageSet.."/dim.list - \"".._fileReadTableClean[i].."\"")
end
elseif v ~= "" then
error("Malformed definition at line ".. i .." in "..cloudDir.."GUI/images/".._imageSet.."/dim.list - \"".._fileReadTableClean[i].."\"")
end
end
return _dimTable
end