local graphics = require("graphics") Panel = {x = 1, y = 1, w = 8, h=1, title="New Panel", bColor=0xaaaaaa, fColor=0xffffff} Panel.__index = Panel function Panel:new(x,y,w,h,title,showStatusLight,bColor,fColor) local self = {} setmetatable(self, Panel) self.x = math.floor(x) self.y = math.floor(y) self.w = math.floor(w) self.h = math.floor(h) self.title = title self.bColor = bColor self.fColor = fColor self.visible = true self.showStatusLight = showStatusLight self.status = false return self end function Panel:setStatus(bool) self.status = bool end function Panel:draw() if not self.visible then return end local gpu = graphics.gpu gpu.setBackground(self.bColor) gpu.setForeground(self.fColor) gpu.fill(self.x,self.y,self.w,self.h," ") -- outline gpu.fill(self.x,self.y,1,self.h, "║") gpu.fill(self.x,self.y,self.w,1, "═") gpu.fill(self.x,self.h+self.y,self.w,1,"═") gpu.fill(self.w+self.x,self.y,1,self.h,"║") if self.showStatusLight then gpu.set(self.x+3,self.y,"[") gpu.set(self.x+5,self.y,"]") if self.status then gpu.setForeground(0x00ff00) else gpu.setForeground(0xff0000) end gpu.set(self.x+4, self.y, "■") end gpu.setForeground(self.fColor) -- outline corners gpu.set(self.x,self.y,"╔") gpu.set(self.w+self.x,self.h+self.y,"╝") gpu.set(self.w+self.x,self.y,"╗") gpu.set(self.x,self.h+self.y,"╚") local title = " " .. self.title .. " " -- title bar local magic = math.floor(self.w/2) - math.floor(#self.title / 2) gpu.set(magic-1, self.y, "╡") gpu.set(magic+title:len(), self.y, "╞") gpu.setBackground(0xaaaaaa) gpu.setForeground(0x000000) gpu.set(magic, self.y, title) end return Panel