divided everything

This commit is contained in:
2025-12-28 23:51:01 -05:00
parent 39fe8bdc6c
commit 91c7cc2113
8 changed files with 1711 additions and 13 deletions

222
display.lua Normal file
View File

@ -0,0 +1,222 @@
--[[
Display Functions
Handles all monitor/screen drawing operations
]]
local display = {}
-- Will be set by startup.lua
local mon
local config
local addresses
local utils
-- State variables
local buttonXY = {}
local computerAddresses = {}
local computerNames = {}
local x, y = 0, 0
function display.init(monitor, cfg, addr, utilsModule)
mon = monitor
config = cfg
addresses = addr
utils = utilsModule
end
function display.getButtonData()
return buttonXY, computerAddresses, computerNames
end
function display.clearButtonData()
buttonXY = {}
computerAddresses = {}
computerNames = {}
end
---------------------------------------------
-- DRAWING FUNCTIONS
---------------------------------------------
function display.drawIrisStatus()
mon.setCursorPos(1, 19)
mon.setBackgroundColor(colors.black)
local irisState = utils.getIrisState()
if irisState == "OPEN" then
mon.setTextColor(colors.green)
elseif irisState == "CLOSED" then
mon.setTextColor(colors.red)
else
mon.setTextColor(colors.gray)
end
mon.write("IRIS: " .. irisState .. " ")
mon.setTextColor(colors.white)
if irisState == "MOVING" then
sleep(0.1)
display.drawIrisStatus()
end
end
function display.screenWrite(list, fcount, fy)
for i = 1, #list do
local x1, x2 = 0, 0
if fcount == 0 then
x = 2
fcount = 1
elseif fcount == 1 then
x = 11
fcount = 2
else
x = 20
fcount = 0
fy = fy + 2
end
mon.setCursorPos(x, fy)
mon.write(list[i][1])
x1 = x
x2 = x + 7
table.insert(buttonXY, { x1, x2, fy })
table.insert(computerNames, list[i][1])
table.insert(computerAddresses, list[i][2])
end
local oldterm = term.redirect(mon)
paintutils.drawFilledBox(23, 17, 28, 19, colors.red)
mon.setCursorPos(24, 18)
mon.write("Back")
term.redirect(oldterm)
return fcount, fy
end
function display.selectionTabs()
mon.setBackgroundColor(colors.black)
mon.clear()
local oldterm = term.redirect(mon)
if #addresses.MainGates ~= 0 then
paintutils.drawFilledBox(2, 2, 13, 6, colors.purple)
mon.setCursorPos(4, 4)
mon.setBackgroundColor(colors.purple)
mon.write("Main Gates")
end
if #addresses.playerGates ~= 0 then
paintutils.drawFilledBox(16, 2, 27, 6, colors.green)
mon.setCursorPos(18, 4)
mon.setBackgroundColor(colors.green)
mon.write("Player")
mon.setCursorPos(18, 5)
mon.write("Base gates")
end
if (#addresses.hazardGates ~= 0) and (config.canAccessHazardGates == true) then
paintutils.drawFilledBox(2, 8, 13, 12, colors.red)
mon.setCursorPos(4, 9)
mon.setBackgroundColor(colors.red)
mon.write("Hazard")
mon.setCursorPos(4, 11)
mon.write("gates")
end
paintutils.drawFilledBox(23, 17, 28, 19, colors.red)
mon.setCursorPos(24, 18)
mon.write("Back")
display.drawIrisStatus()
term.redirect(oldterm)
end
function display.showIncoming(addressString, allowed, reason)
mon.setBackgroundColor(colors.black)
mon.clear()
if allowed then
mon.setBackgroundColor(colors.green)
mon.setTextScale(1)
mon.setCursorPos(1, 2)
mon.write("INCOMING - AUTHORIZED")
else
mon.setBackgroundColor(colors.red)
mon.setTextScale(1)
mon.setCursorPos(1, 2)
mon.write("INCOMING - UNAUTHORIZED")
mon.setCursorPos(1, 4)
mon.write(reason)
end
mon.setCursorPos(1, 6)
mon.setBackgroundColor(colors.black)
mon.write("Address:\n" .. addressString)
end
function display.showEntity(entityType, entityName, allowed)
mon.setTextScale(1)
mon.setCursorPos(1, 10)
mon.write("Type: " .. entityType)
mon.setCursorPos(1, 12)
mon.write("Name: " .. entityName)
if not allowed then
mon.setCursorPos(1, 14)
mon.setTextColor(colors.red)
mon.write("IRIS IMPACT!")
mon.setTextColor(colors.white)
end
end
function display.showDialing(chevron, symbol, gateType)
mon.setBackgroundColor(colors.black)
mon.clear()
mon.setBackgroundColor(colors.red)
mon.setTextScale(2)
mon.setCursorPos(2, 3)
mon.write("DIALING GATE")
mon.setCursorPos(4, 5)
mon.write("CHEVERON")
mon.setCursorPos(7, 7)
mon.setBackgroundColor(colors.black)
mon.write(chevron)
mon.setBackgroundColor(colors.red)
if symbol ~= 0 then
mon.setCursorPos(4, 9)
mon.write("ENGAGED")
else
mon.setCursorPos(5, 9)
mon.setBackgroundColor(colors.green)
mon.write("LOCKED")
end
end
function display.showConnected(destName, destAddr)
mon.setBackgroundColor(colors.green)
mon.clear()
mon.setTextScale(1)
mon.setCursorPos(6, 5)
mon.write(destName)
mon.setCursorPos(3, 10)
for i = 1, #destAddr do
mon.write(destAddr[i])
mon.write(" ")
end
display.drawIrisStatus()
end
function display.showMainMenu()
mon.setTextScale(1)
mon.setBackgroundColor(colors.black)
mon.clear()
mon.setCursorPos(9, 1)
mon.setBackgroundColor(colors.red)
mon.write("press to start")
display.drawIrisStatus()
end
return display