shiplcdbox.lua
ShipLCDBox = {}
ShipLCDBox.update = function()
end
function ShipLCDBox:new(_instanceName, _elementX, _elementY, _inputText, _backingText, _fontSize, _fontColour)
cloudDir = cloudDir or [[D:\Achaea\]]
self.__index = ShipLCDBox
local self = setmetatable({}, ShipLCDBox)
self._instanceName = _instanceName
self._fontSize = _fontSize or 30
self._fontName = "DSEG7 Classic Mini-Bold Italic"
self._padding = 4
self._fontColour = _fontColour or "HotPink"
registerAnonymousEventHandler( "ship prompt processed", self._instanceName..":update")
self._LCD_CSS = CSSMan.new([[
background-color: #00000000;
border-style: solid;
border-color: white;
border-width: 0px;
border-radius: 0px;
margin: 0px;
qproperty-alignment: 'AlignHCenter | AlignVCenter';
font-family: "]]..self._fontName..[[", sans-serif;
]])
self._LCD_off_CSS = CSSMan.new([[
background-color: #00000000;
border-style: solid;
border-color: white;
border-width: 0px;
border-radius: 0px;
margin: 0px;
qproperty-alignment: 'AlignHCenter | AlignVCenter';
font-family: "]]..self._fontName..[[", sans-serif;
color: #333333;
]])
self._updateHandler = self._updateHandler or registerAnonymousEventHandler("svo done with prompt", self._instanceName..":update")
_charW,_charH = calcFontSize(self._fontSize, self._fontName)
_elementWidth = (math.max( string.len(_inputText), string.len(_backingText) )*_charW) + (self._padding*2)
_elementHeight = _charH + (self._padding*2)
self._container = Geyser.Label:new({ name = self._instanceName.."._container", x = _elementX, y = _elementY, width = _elementWidth, height = _elementHeight })
self._labelForegroundText = Geyser.Label:new({ name = self._instanceName.."._labelForegroundText", x = 0, y = 0, width = "100%", height = "100%", color = "#007700" }, self._container )
self._labelBackgroundText = Geyser.Label:new({ name = self._instanceName.."._labelBackgroundText", x = 0, y = 0, width = "100%", height = "100%", color = "#007700" }, self._container )
self._container:setStyleSheet( [[background-color: #00000000;]] )
self._labelForegroundText:setStyleSheet(self._LCD_CSS:getCSS())
self._labelBackgroundText:setStyleSheet(self._LCD_off_CSS:getCSS())
self._labelForegroundText:echo( tostring( _inputText ), self._fontColour, "r"..tostring(self._fontSize) )
self._labelBackgroundText:echo( tostring(_backingText), "#333333", "r"..tostring(self._fontSize) )
self._container:raiseAll()
self._labelBackgroundText:raise()
self._labelForegroundText:raise()
return self
end
function ShipLCDBox:setVisible(_visible)
if _visible then
self._container:show()
else
self._container:hide()
end
end
function ShipLCDBox:build(_positionTable, _type)
self.hull = ShipLCDBox:new(self._instanceName..".hull", 846, 808, "42", "88", 36, "green")
self.sails = ShipLCDBox:new(self._instanceName..".sails", 846, 923, "42", "88", 36, "green")
self.speed = ShipLCDBox:new(self._instanceName..".speed", 330, 941, "42", "88", 28, "cyan" )
self.wind = ShipLCDBox:new(self._instanceName..".wind", 24, 941, "42", "88", 28, "cyan" )
end