shipannunciator.lua

--- Display for general shipboard use. Mimics a 16x52 DOS-esque terminal, because I like the aesthetic.
--@classmod ShipAnnunciator

ShipAnnunciator = {}










----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
--- Initialisation methods.
-- For creating and Initialising ShipAnnunciator object.
-- @section Initialisation



----------------------------------------------
--- Creates a new instance of the ShipAnnunciator class.
-- @treturn table A new instance of the ShipAnnunciator class.
-- @usage annunc = ShipAnnunciator:new()
function ShipAnnunciator:new()

    ShipAnnunciator.__index = ShipAnnunciator
    local self = setmetatable({}, ShipAnnunciator)

    --------------------

    self.container = Geyser.Label:new({ name = self._instanceName..".container", x = elementX, y = elementY, width = 395, height = 256 } )
    self.container:setStyleSheet([[background-color: #222222;]])

    --------------------

    self.rowingLabel = Geyser.Label:new({ name = self._instanceName..".rowingLabel", x = 0, y = 0, width = 132, height = 64 }, self.container )
    self.rowingLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\rowing.png]] )
    self.rowingLabel:setStyleSheet([[background-color: #00000000;]])

    self.sailsLabel = Geyser.Label:new({ name = self._instanceName..".sailsLabel", x = 132, y = 0, width = 131, height = 64 }, self.container )
    self.sailsLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\sails.png]] )
    self.sailsLabel:setStyleSheet([[background-color: #00000000;]])

    self.anchorLabel = Geyser.Label:new({ name = self._instanceName..".anchorLabel", x = 263, y = 0, width = 132, height = 64 }, self.container )
    self.anchorLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\anchor.png]] )
    self.anchorLabel:setStyleSheet([[background-color: #00000000;]])

    self.gangplankLabel = Geyser.Label:new({ name = self._instanceName..".gangplankLabel", x = 263, y = 64, width = 132, height = 64 }, self.container )
    self.gangplankLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\gangplank.png]] )
    self.gangplankLabel:setStyleSheet([[background-color: #00000000;]])

    self.apLabel = Geyser.Label:new({ name = self._instanceName..".apLabel", x = 0, y = 128, width = 132, height = 64 }, self.container )
    self.apLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\ap_on.png]] )
    self.apLabel:setStyleSheet([[background-color: #00000000;]])

    self.windboostLabel = Geyser.Label:new({ name = self._instanceName..".windboostLabel", x = 0, y = 64, width = 132, height = 64 }, self.container )
    self.windboostLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\windboost.png]] )
    self.windboostLabel:setStyleSheet([[background-color: #00000000;]])

    self.shieldLabel = Geyser.Label:new({ name = self._instanceName..".shieldLabel", x = 132, y = 64, width = 131, height = 64 }, self.container )
    self.shieldLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\shield.png]] )
    self.shieldLabel:setStyleSheet([[background-color: #00000000;]])

    self.insDriftLabel = Geyser.Label:new({ name = self._instanceName..".insDriftLabel", x = 0, y = 192, width = 132, height = 64 }, self.container )
    self.insDriftLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\ins_drift.png]] )
    self.insDriftLabel:setStyleSheet([[background-color: #00000000;]])

    self.grappledLabel = Geyser.Label:new({ name = self._instanceName..".grappledLabel", x = 132, y = 128, width = 131, height = 64 }, self.container )
    self.grappledLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\grappled.png]] )
    self.grappledLabel:setStyleSheet([[background-color: #00000000;]])

    self.leakDetectLabel = Geyser.Label:new({ name = self._instanceName..".leakDetectLabel", x = 263, y = 128, width = 132, height = 64 }, self.container )
    self.leakDetectLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\leak.png]] )
    self.leakDetectLabel:setStyleSheet([[background-color: #00000000;]])

    self.fireLabel = Geyser.Label:new({ name = self._instanceName..".fireLabel", x = 132, y = 192, width = 131, height = 64 }, self.container )
    self.fireLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\fire.png]] )
    self.fireLabel:setStyleSheet([[background-color: #00000000;]])

    self.abandonShipLabel = Geyser.Label:new({ name = self._instanceName..".abandonShipLabel", x = 263, y = 192, width = 132, height = 64 }, self.container )
    self.abandonShipLabel:setBackgroundImage( cloudDir .. [[GUI\images\sailing\abandon_ship.png]] )
    self.abandonShipLabel:setStyleSheet([[background-color: #00000000;]])

    --------------------

    self.container:show()
    self.rowingLabel:hide()
    self.sailsLabel:hide()
    self.anchorLabel:hide()
    self.gangplankLabel:hide()
    self.apLabel:hide()
    self.windboostLabel:hide()
    self.shieldLabel:hide()
    self.insDriftLabel:hide()
    self.grappledLabel:hide()
    self.leakDetectLabel:hide()
    self.fireLabel:hide()
    self.abandonShipLabel:hide()

    --------------------

    return self

end



----------------------------------------------
--- Toggles element visibility via boolean input.
-- @tparam table element The element to hide/show.
-- @tparam bool showElement Show if true, hide if false.
-- @usage annunc = ShipAnnunciator:new()
function ShipAnnunciator:setVisible(element, showElement)

    if showElement then
        element:show()
    else
        element:hide()
    end

end







function ShipAnnunciator:updateAnnunciator()

    -- Row 1
    ------------------------------------------------------------------
    -- ROWING
    self.setVisible( self.rowingLabel, self.isRowing() )
    -- SAILING
    self.setVisible( self.sailingLabel, (self.sailSetting() > 0))
    -- ANCHOR
    self.setVisible( self.anchorLabel, (not self.isAnchorRaised()) )

    -- Row 2
    ------------------------------------------------------------------
    -- WINDBOOST
    self:setVisible( self.windboostLabel, ship.windboost )
    -- SHIELD
    self:setVisible( self.shieldLabel, ship.shield )
    -- GANGPLANK
    self:setVisible( self.gangplankLabel, ship.windboost )

    -- Row 3
    ------------------------------------------------------------------
    -- A/P ON
    self:setVisible( self.apLabel, ship.autopilotEnabled)
    -- GRAPPLED
        -- INOP
    -- LEAK DETECT
        -- INOP

    -- Row 4
    ------------------------------------------------------------------
    -- INS DRIFT
    if uacs.easting >= 0 and uacs.southing >= 0 and uacs.error >= 5 then
        shipAnnunciator.insDriftLabel:show()
    else
        shipAnnunciator.insDriftLabel:hide()
    end
    -- FIRE
    self:setVisible( self.fireLabel, ship.fire )
    -- ABANDON SHIP
    self:setVisible( self.abandonShipLabel, ship.abandonShip )

end
generated by LDoc 1.4.3 Last updated 2021-01-24 20:08:44