feat: Revamp dashboard layout for improved vertical display and enhanced statistics visibility

This commit is contained in:
MayaTheShy
2026-02-16 01:48:43 -05:00
parent 611609d404
commit 1610ade7b7

View File

@@ -89,109 +89,153 @@ local function drawDashboard()
monitor.setBackgroundColor(colors.black)
monitor.clear()
-- Header
drawBox(1, 1, w, 3, colors.blue)
centerText(2, "=== TURTLE NETWORK BRIDGE ===", colors.white, colors.blue)
-- Header (larger for vertical display)
drawBox(1, 1, w, 4, colors.blue)
centerText(2, "╔════════════════════════════════════════════════╗", colors.white, colors.blue)
centerText(3, "║ TURTLE NETWORK BRIDGE CONTROL CENTER ║", colors.white, colors.blue)
centerText(4, "╚════════════════════════════════════════════════╝", colors.white, colors.blue)
monitor.setCursorPos(2, 2)
monitor.setTextColor(colors.lime)
monitor.setBackgroundColor(colors.blue)
monitor.write("\7 ONLINE")
monitor.setCursorPos(w - 15, 2)
monitor.setTextColor(colors.lightBlue)
monitor.write("Server: ACTIVE")
-- Stats box
local startY = 4
drawBox(2, startY, 30, 8, colors.gray)
drawBox(3, startY + 1, 28, 6, colors.black)
-- Stats box (left side, taller)
local statsY = 6
drawBox(2, statsY, 50, 20, colors.gray)
drawBox(3, statsY + 1, 48, 18, colors.black)
monitor.setTextColor(colors.yellow)
monitor.setBackgroundColor(colors.black)
monitor.setCursorPos(4, startY + 1)
monitor.write("SYSTEM STATISTICS")
monitor.setCursorPos(4, statsY + 1)
monitor.write("╔═══ SYSTEM STATISTICS ═══╗")
local statY = statsY + 3
-- Messages
monitor.setTextColor(colors.lightGray)
monitor.setCursorPos(4, startY + 3)
monitor.setCursorPos(5, statY)
monitor.write("Messages Received:")
monitor.setTextColor(colors.white)
monitor.setCursorPos(23, startY + 3)
monitor.setCursorPos(38, statY)
monitor.write(tostring(stats.messagesReceived))
statY = statY + 2
-- Commands
monitor.setTextColor(colors.lightGray)
monitor.setCursorPos(4, startY + 4)
monitor.setCursorPos(5, statY)
monitor.write("Commands Sent:")
monitor.setTextColor(colors.lime)
monitor.setCursorPos(23, startY + 4)
monitor.setCursorPos(38, statY)
monitor.write(tostring(stats.commandsSent))
statY = statY + 2
-- Server Updates
monitor.setTextColor(colors.lightGray)
monitor.setCursorPos(4, startY + 5)
monitor.setCursorPos(5, statY)
monitor.write("Server Updates:")
monitor.setTextColor(colors.lightBlue)
monitor.setCursorPos(23, startY + 5)
monitor.setCursorPos(38, statY)
monitor.write(tostring(stats.serverUpdates))
statY = statY + 2
-- Errors
monitor.setTextColor(colors.lightGray)
monitor.setCursorPos(4, startY + 6)
monitor.setCursorPos(5, statY)
monitor.write("Errors:")
monitor.setTextColor(stats.errors > 0 and colors.red or colors.lime)
monitor.setCursorPos(38, statY)
monitor.write(tostring(stats.errors))
statY = statY + 2
-- Uptime
monitor.setTextColor(colors.lightGray)
monitor.setCursorPos(5, statY)
monitor.write("Uptime:")
monitor.setTextColor(colors.white)
monitor.setCursorPos(23, startY + 6)
monitor.setCursorPos(38, statY)
monitor.write(formatTime(os.epoch("utc") - stats.startTime))
statY = statY + 3
-- Turtle list
local startX = 34
local boxWidth = w - startX - 1
drawBox(startX, startY, boxWidth, 8, colors.gray)
drawBox(startX + 1, startY + 1, boxWidth - 2, 6, colors.black)
-- Connection info
monitor.setTextColor(colors.gray)
monitor.setCursorPos(5, statY)
monitor.write("Server: " .. SERVER_URL:sub(8))
statY = statY + 1
monitor.setCursorPos(5, statY)
monitor.write("Channels: " .. STATUS_CHANNEL .. "/" .. COMMAND_CHANNEL)
-- Turtle list (right side, much taller)
local turtleX = 54
local turtleWidth = w - turtleX - 1
drawBox(turtleX, statsY, turtleWidth, 20, colors.gray)
drawBox(turtleX + 1, statsY + 1, turtleWidth - 2, 18, colors.black)
monitor.setTextColor(colors.yellow)
monitor.setCursorPos(startX + 2, startY + 1)
monitor.write("ACTIVE TURTLES")
monitor.setCursorPos(turtleX + 2, statsY + 1)
monitor.write("╔═══ ACTIVE TURTLES ═══╗")
local y = startY + 3
local turtleY = statsY + 3
local count = 0
for id, turtle in pairs(turtles) do
if count >= 4 then break end
if count >= 15 then break end -- Show up to 15 turtles
local statusColor = getStatusColor(turtle)
monitor.setCursorPos(startX + 2, y)
monitor.setCursorPos(turtleX + 2, turtleY)
monitor.setTextColor(statusColor)
monitor.write("\7")
monitor.setTextColor(colors.white)
monitor.write(" Turtle #" .. id)
monitor.write(string.format(" T#%-2d", id))
monitor.setCursorPos(startX + 16, y)
monitor.setCursorPos(turtleX + 12, turtleY)
monitor.setTextColor(colors.lightGray)
if turtle.state then
monitor.write(turtle.state:upper())
local state = turtle.state:upper()
if #state > 10 then state = state:sub(1, 10) end
monitor.write(state)
else
monitor.write("UNKNOWN")
end
y = y + 1
-- Show position if available
if turtle.position then
turtleY = turtleY + 1
monitor.setCursorPos(turtleX + 4, turtleY)
monitor.setTextColor(colors.gray)
monitor.write(string.format("X:%d Y:%d Z:%d",
turtle.position.x or 0,
turtle.position.y or 0,
turtle.position.z or 0))
end
turtleY = turtleY + 2
count = count + 1
end
if count == 0 then
monitor.setCursorPos(startX + 2, startY + 4)
monitor.setCursorPos(turtleX + 2, statsY + 5)
monitor.setTextColor(colors.gray)
monitor.write("No turtles detected")
monitor.setCursorPos(turtleX + 2, statsY + 6)
monitor.write("Waiting for signals...")
end
-- Activity log
local logY = 13
-- Activity log (bottom section, MUCH taller for vertical display)
local logY = 28
drawBox(2, logY, w - 2, h - logY - 1, colors.gray)
drawBox(3, logY + 1, w - 4, h - logY - 3, colors.black)
monitor.setTextColor(colors.yellow)
monitor.setCursorPos(4, logY + 1)
monitor.write("ACTIVITY LOG")
monitor.write("╔═══ ACTIVITY LOG ═══╗")
-- Calculate how many log lines we can show (huge vertical space!)
local maxLines = h - logY - 4
local maxLines = h - logY - 3
for i = 1, math.min(#activityLog, maxLines) do
local entry = activityLog[i]
monitor.setCursorPos(4, logY + 2 + i - 1)
monitor.setCursorPos(4, logY + 2 + i)
monitor.setBackgroundColor(colors.black)
monitor.setTextColor(colors.gray)
@@ -199,14 +243,20 @@ local function drawDashboard()
monitor.write("[" .. time .. "] ")
monitor.setTextColor(entry.color)
monitor.write(entry.text)
-- Truncate long messages to fit width
local maxTextWidth = w - 18
local text = entry.text
if #text > maxTextWidth then
text = text:sub(1, maxTextWidth - 3) .. "..."
end
monitor.write(text)
end
-- Footer
monitor.setBackgroundColor(colors.gray)
monitor.setCursorPos(1, h)
monitor.clearLine()
centerText(h, "Server: " .. SERVER_URL:sub(8), colors.white, colors.gray)
centerText(h, "Ctrl+T to terminate | Monitoring " .. STATUS_CHANNEL .. " & " .. COMMAND_CHANNEL, colors.white, colors.gray)
end
local function addLog(text, color)