Manual iris control
This commit is contained in:
28
display.lua
28
display.lua
@ -48,6 +48,26 @@ function display.drawDisconnectButton()
|
|||||||
term.redirect(oldterm)
|
term.redirect(oldterm)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function display.drawIrisButtons()
|
||||||
|
if not config.irisEnabled then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local oldterm = term.redirect(mon)
|
||||||
|
|
||||||
|
-- Open iris button (green)
|
||||||
|
paintutils.drawFilledBox(2, 17, 9, 19, colors.green)
|
||||||
|
mon.setCursorPos(3, 18)
|
||||||
|
mon.write("OPEN")
|
||||||
|
|
||||||
|
-- Close iris button (red)
|
||||||
|
paintutils.drawFilledBox(11, 17, 18, 19, colors.red)
|
||||||
|
mon.setCursorPos(12, 18)
|
||||||
|
mon.write("CLOSE")
|
||||||
|
|
||||||
|
term.redirect(oldterm)
|
||||||
|
end
|
||||||
|
|
||||||
function display.drawIrisStatus()
|
function display.drawIrisStatus()
|
||||||
mon.setCursorPos(1, 19)
|
mon.setCursorPos(1, 19)
|
||||||
mon.setBackgroundColor(colors.black)
|
mon.setBackgroundColor(colors.black)
|
||||||
@ -118,6 +138,7 @@ function display.screenWrite(list, fcount, fy)
|
|||||||
paintutils.drawFilledBox(23, 17, 28, 19, colors.red)
|
paintutils.drawFilledBox(23, 17, 28, 19, colors.red)
|
||||||
mon.setCursorPos(24, 18)
|
mon.setCursorPos(24, 18)
|
||||||
mon.write("Back")
|
mon.write("Back")
|
||||||
|
display.drawIrisButtons()
|
||||||
term.redirect(oldterm)
|
term.redirect(oldterm)
|
||||||
|
|
||||||
return fcount, fy
|
return fcount, fy
|
||||||
@ -157,6 +178,7 @@ function display.selectionTabs()
|
|||||||
mon.setCursorPos(24, 18)
|
mon.setCursorPos(24, 18)
|
||||||
mon.write("Back")
|
mon.write("Back")
|
||||||
|
|
||||||
|
display.drawIrisButtons()
|
||||||
display.drawIrisStatus()
|
display.drawIrisStatus()
|
||||||
term.redirect(oldterm)
|
term.redirect(oldterm)
|
||||||
end
|
end
|
||||||
@ -194,6 +216,9 @@ function display.showIncoming(addressName, addressString, allowed, reason)
|
|||||||
mon.setCursorPos(1, 7)
|
mon.setCursorPos(1, 7)
|
||||||
mon.write(addressString)
|
mon.write(addressString)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
display.drawIrisButtons()
|
||||||
|
display.drawIrisStatus()
|
||||||
end
|
end
|
||||||
|
|
||||||
function display.showEntity(entityType, entityName, allowed)
|
function display.showEntity(entityType, entityName, allowed)
|
||||||
@ -253,6 +278,7 @@ function display.showConnected(destName, destAddr)
|
|||||||
paintutils.drawFilledBox(20, 17, 28, 19, colors.red)
|
paintutils.drawFilledBox(20, 17, 28, 19, colors.red)
|
||||||
mon.setCursorPos(21, 18)
|
mon.setCursorPos(21, 18)
|
||||||
mon.write("CLOSE")
|
mon.write("CLOSE")
|
||||||
|
display.drawIrisButtons()
|
||||||
term.redirect(oldterm)
|
term.redirect(oldterm)
|
||||||
|
|
||||||
display.drawIrisStatus()
|
display.drawIrisStatus()
|
||||||
@ -265,6 +291,7 @@ function display.showMainMenu()
|
|||||||
mon.setCursorPos(9, 1)
|
mon.setCursorPos(9, 1)
|
||||||
mon.setBackgroundColor(colors.red)
|
mon.setBackgroundColor(colors.red)
|
||||||
mon.write("press to start")
|
mon.write("press to start")
|
||||||
|
display.drawIrisButtons()
|
||||||
display.drawIrisStatus()
|
display.drawIrisStatus()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -313,6 +340,7 @@ function display.showPasswordPrompt()
|
|||||||
mon.setCursorPos(18, 17)
|
mon.setCursorPos(18, 17)
|
||||||
mon.write("OK")
|
mon.write("OK")
|
||||||
|
|
||||||
|
display.drawIrisButtons()
|
||||||
term.redirect(oldterm)
|
term.redirect(oldterm)
|
||||||
display.drawIrisStatus()
|
display.drawIrisStatus()
|
||||||
end
|
end
|
||||||
|
|||||||
38
handlers.lua
38
handlers.lua
@ -97,6 +97,40 @@ function handlers.handlePasswordInput()
|
|||||||
return password
|
return password
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---------------------------------------------
|
||||||
|
-- IRIS BUTTON HANDLER
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
function handlers.handleIrisButtons(eventType, side, x, y)
|
||||||
|
-- Only process if not entering password (password handler has higher priority)
|
||||||
|
if state.enteringPassword then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Only process if iris is enabled
|
||||||
|
if not config.irisEnabled then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if clicking iris buttons (bottom-left area)
|
||||||
|
if y >= 17 and y <= 19 then
|
||||||
|
-- Open button (2-9)
|
||||||
|
if x >= 2 and x <= 9 then
|
||||||
|
utils.openIris()
|
||||||
|
display.drawIrisStatus()
|
||||||
|
return "iris_opened"
|
||||||
|
end
|
||||||
|
-- Close button (11-18)
|
||||||
|
if x >= 11 and x <= 18 then
|
||||||
|
utils.closeIris()
|
||||||
|
display.drawIrisStatus()
|
||||||
|
return "iris_closed"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil -- Not an iris button click
|
||||||
|
end
|
||||||
|
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
-- DISCONNECT BUTTON HANDLER
|
-- DISCONNECT BUTTON HANDLER
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
@ -169,6 +203,7 @@ end
|
|||||||
|
|
||||||
function handlers.handleMessage(eventType, side, message)
|
function handlers.handleMessage(eventType, side, message)
|
||||||
state.lastReceivedMessage = message
|
state.lastReceivedMessage = message
|
||||||
|
utils.debug("Message Received: " .. message)
|
||||||
return "message_received"
|
return "message_received"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -200,8 +235,9 @@ function handlers.setupConnectionHandlers()
|
|||||||
-- Clear any existing handlers
|
-- Clear any existing handlers
|
||||||
events.clearHandlers()
|
events.clearHandlers()
|
||||||
-- Register all handlers with their priorities
|
-- Register all handlers with their priorities
|
||||||
|
events.registerHandler("monitor_touch", handlers.handleIrisButtons, events.PRIORITY.DISCONNECT_BUTTON) -- Same priority as disconnect
|
||||||
events.registerHandler("monitor_touch", handlers.handleDisconnectButton, events.PRIORITY.DISCONNECT_BUTTON)
|
events.registerHandler("monitor_touch", handlers.handleDisconnectButton, events.PRIORITY.DISCONNECT_BUTTON)
|
||||||
events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates
|
events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates
|
||||||
events.registerHandler("stargate_incoming_wormhole", handlers.handleActivation, events.PRIORITY.ACTIVATION)
|
events.registerHandler("stargate_incoming_wormhole", handlers.handleActivation, events.PRIORITY.ACTIVATION)
|
||||||
events.registerHandler("stargate_reconstructing_entity", handlers.handleEntityRead, events.PRIORITY.ENTITY_READ)
|
events.registerHandler("stargate_reconstructing_entity", handlers.handleEntityRead, events.PRIORITY.ENTITY_READ)
|
||||||
events.registerHandler("stargate_disconnected", handlers.handleDisconnect, events.PRIORITY.DISCONNECT_CHECK)
|
events.registerHandler("stargate_disconnected", handlers.handleDisconnect, events.PRIORITY.DISCONNECT_CHECK)
|
||||||
|
|||||||
Reference in New Issue
Block a user