diff --git a/basalt-source.lua b/basalt-source.lua index 6907e65..639d753 100644 --- a/basalt-source.lua +++ b/basalt-source.lua @@ -1,7 +1,12 @@ local basalt = { debugger = true, version = 1 } -local activeFrame +local keyActive = {} +local focusedObject local frames = {} -local keyActive = {} +local activeFrame + +local mainFrame +local monFrames = {} + local parentTerminal = term.current() local sub = string.sub @@ -606,11 +611,6 @@ end local function Object(name) -- Base object local objectType = "Object" -- not changeable - --[[ - local horizontalAnchor = "left" - local verticalAnchor = "top" - local ignYOffset = false - local ignXOffset = false ]] local value local zIndex = 1 local hanchor = "left" @@ -799,11 +799,8 @@ local function Object(name) getAbsolutePosition = function(self, x, y) -- relative position to absolute position - if (x == nil) then - x = self.x - end - if (y == nil) then - y = self.y + if (x == nil) or (y == nil) then + x, y = self:getAnchorPosition() end if (self.parent ~= nil) then @@ -828,24 +825,32 @@ local function Object(name) y = self.parent.height - y - self.height + 2 end local xO, yO = self:getOffset() - if (ignOffset or ignOff) then - return x, y + if not(ignOffset or ignOff) then + return x+xO, y+yO end - return x + xO, y + yO + return x, y end; getOffset = function(self) - if (self.parent ~= nil) and (ignOffset == false) then + if (self.parent ~= nil) then return self.parent:getFrameOffset() end return 0, 0 end; ignoreOffset = function(self, ignore) - ignOffset = ignore or true + ignOffset = ignore + if(ignore==nil)then ignOffset = true end return self end; + getBaseFrame = function(self) + if(self.parent~=nil)then + return self.parent:getBaseFrame() + end + return self + end; + setAnchor = function(self, ...) for _, value in pairs(table.pack(...)) do if (value == "right") or (value == "left") then @@ -874,13 +879,24 @@ local function Object(name) return self end; - onEvent = function(self, func) - self:registerEvent("custom_event_handler", func) + onClickUp = function(self, func) + self:registerEvent("mouse_up", func) return self end; - onClickUp = function(self, func) - self:registerEvent("mouse_up", func) + + onScroll = function(self, func) + self:registerEvent("mouse_scroll", func) + return self + end; + + onDrag = function(self, func) + self:registerEvent("mouse_drag", func) + return self + end; + + onEvent = function(self, func) + self:registerEvent("custom_event_handler", func) return self end; @@ -935,7 +951,7 @@ local function Object(name) return eventSystem:sendEvent(event, self, ...) end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local objX, objY = self:getAbsolutePosition(self:getAnchorPosition()) if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (isVisible) then if (self.parent ~= nil) then @@ -1148,8 +1164,8 @@ local function Checkbox(name) return objectType end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then if (self:getValue() ~= true) and (self:getValue() ~= false) then self:setValue(false) @@ -1283,7 +1299,7 @@ local function Dropdown(name) return self end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) if (isOpened) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then @@ -1318,7 +1334,7 @@ local function Dropdown(name) end self:setVisualChanged() end - if (base.mouseClickHandler(self, event, button, x, y)) then + if (base.mouseHandler(self, event, button, x, y)) then isOpened = true else isOpened = false @@ -1739,8 +1755,8 @@ local function Input(name) end end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then if (event == "mouse_click") and (button == 1) then end @@ -1984,7 +2000,7 @@ local function List(name) return self end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (obx <= x) and (obx + self.width > x) and (oby <= y) and (oby + self.height > y) and (self:isVisible()) then if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then @@ -2177,8 +2193,8 @@ local function Menubar(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if(base.mouseClickHandler(self, event, button, x, y))then + mouseHandler = function(self, event, button, x, y) + if(base.mouseHandler(self, event, button, x, y))then local objX, objY = self:getAbsolutePosition(self:getAnchorPosition()) if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then if (self.parent ~= nil) then @@ -2809,15 +2825,15 @@ local function Program(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then if (curProcess == nil) then return false end if not (curProcess:isDead()) then if not (paused) then local absX, absY = self:getAbsolutePosition(self:getAnchorPosition(nil, nil, true)) - curProcess:resume(event, button, x - absX + 1, y - absY + 1) + curProcess:resume(event, button, x - (absX - 1), y - (absY - 1)) end end return true @@ -3098,7 +3114,7 @@ local function Radio(name) return self end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then if (#list > 0) then @@ -3204,8 +3220,8 @@ local function Scrollbar(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then if (barType == "horizontal") then @@ -3333,8 +3349,8 @@ local function Slider(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then if (barType == "horizontal") then @@ -3438,8 +3454,8 @@ local function Switch(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if ((event == "mouse_click") and (button == 1))or(event=="monitor_touch") then self:setValue(not self:getValue()) @@ -3714,8 +3730,8 @@ local function Textfield(name) end end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local anchx, anchy = self:getAnchorPosition() if (event == "mouse_click")or(event=="monitor_touch") then @@ -3732,7 +3748,7 @@ local function Textfield(name) end end if (self.parent ~= nil) then - self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) + self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor) end end end @@ -3750,7 +3766,7 @@ local function Textfield(name) end end if (self.parent ~= nil) then - self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) + self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor) end end end @@ -3767,7 +3783,7 @@ local function Textfield(name) if (self.parent ~= nil) then if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then - self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) + self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor) else self.parent:setCursor(false) end @@ -3956,11 +3972,12 @@ local function Frame(name, parent) local objects = {} local objZIndex = {} local object = {} - local focusedObject local termObject = parentTerminal - local monitors = {} + local monSide = "" local isMonitor = false + local monitorAttached = false + local dragOffset = 0 base:setZIndex(10) @@ -4048,16 +4065,13 @@ local function Frame(name, parent) end; setFocusedObject = function(self, obj) - for _, index in pairs(objZIndex) do - for _, value in pairs(objects[index]) do - if (value == obj) then - if (focusedObject ~= nil) then - focusedObject:loseFocusHandler() - end - focusedObject = obj - focusedObject:getFocusHandler() - end - end + if (focusedObject ~= nil) then + focusedObject:loseFocusHandler() + focusedObject = nil + end + if(obj~=nil)then + focusedObject = obj + obj:getFocusHandler() end return self end; @@ -4068,7 +4082,7 @@ local function Frame(name, parent) return self end; - getFrameOffset = function(self) + getFrameOffset = function(self) -- internal return xOffset, yOffset end; @@ -4084,25 +4098,22 @@ local function Frame(name, parent) return focusedObject end; - show = function(self) - base:show() - if (self.parent == nil)and not(isMonitor) then - activeFrame = self - end - return self - end; - setCursor = function(self, _blink, _xCursor, _yCursor, color) - local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - cursorBlink = _blink or false - if (_xCursor ~= nil) then - xCursor = obx + _xCursor - 1 + if(self.parent~=nil)then + local obx, oby = self:getAnchorPosition() + self.parent:setCursor(_blink or false, (_xCursor or 0)+obx-1, (_yCursor or 0)+oby-1, color or cursorColor) + else + local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) + cursorBlink = _blink or false + if (_xCursor ~= nil) then + xCursor = obx + _xCursor - 1 + end + if (_yCursor ~= nil) then + yCursor = oby + _yCursor - 1 + end + cursorColor = color or cursorColor + self:setVisualChanged() end - if (_yCursor ~= nil) then - yCursor = oby + _yCursor - 1 - end - cursorColor = color or cursorColor - self:setVisualChanged() return self end; @@ -4112,30 +4123,36 @@ local function Frame(name, parent) return self; end; - - addMonitor = function(self, mon) - local screen = peripheral.wrap(mon) - monitors[mon] = {monitor=mon, frame=basalt.createFrame(self:getName().."_monitor_"..mon)} - monitors[mon].frame:setDisplay(screen):setFrameAsMonitor() - monitors[mon].frame:setSize(screen:getSize()) - return monitors[mon].frame - end; - - setMonitorScale = function(self, scale, fullSize) -- 1,2,3,4,5,6,7,8,9,10 - if(isMonitor)then - termObject.setTextScale(scale*0.5) - if(fullSize)then - self:setSize(termObject:getSize()) + show = function(self) + base.show(self) + if(self.parent==nil)then + activeFrame = self; + if(isMonitor)then + monFrames[monSide] = self; + else + mainFrame = self; end end - return self, isMonitor + return self; end; - setFrameAsMonitor = function(self, isMon) - isMonitor = isMon - if(isMon==nil)then isMonitor = true end + hide = function (self) + base.hide(self) + if(self.parent==nil)then + if(activeFrame == self)then activeFrame = nil end + if(isMonitor)then + if(monFrames[monSide] == self)then + monFrames[monSide] = nil; + end + else + if(mainFrame == self)then + mainFrame = nil; + end + end + end return self end; + showBar = function(self, showIt) self.barActive = showIt or not self.barActive @@ -4157,14 +4174,23 @@ local function Frame(name, parent) return self end; - setDisplay = function(self, drawTerm) - termObject = drawTerm + setMonitor = function(self, side) + if(side~=nil)or(side~=false)then + if(peripheral.getType(side)=="monitor")then + termObject = peripheral.wrap(side) + monitorAttached = true + end + isMonitor = true + else + termObject = parentTerminal + isMonitor = false + if(monFrames[monSide]==self)then + monFrames[monSide] = nil + end + end drawHelper = basaltDrawHelper(termObject) - return self - end; - - getDisplay = function(self) - return termObject + monSide = side or nil + return self; end; getVisualChanged = function(self) @@ -4195,10 +4221,14 @@ local function Frame(name, parent) keyHandler = function(self, event, key) if (focusedObject ~= nil) then - if (focusedObject.keyHandler ~= nil) then - if (focusedObject:keyHandler(event, key)) then - return true + if(focusedObject~=self)then + if (focusedObject.keyHandler ~= nil) then + if (focusedObject:keyHandler(event, key)) then + return true + end end + else + base.keyHandler(self, event, key) end end return false @@ -4228,6 +4258,18 @@ local function Frame(name, parent) end end end + if(isMonitor)then + if(event == "peripheral")and(p1==monSide)then + if(peripheral.getType(monSide)=="monitor")then + monitorAttached = true + termObject = peripheral.wrap(monSide) + drawHelper = basaltDrawHelper(termObject) + end + end + if(event == "peripheral_detach")and(p1==monSide)then + monitorAttached = false + end + end if (event == "terminate") then termObject.clear() termObject.setCursorPos(1, 1) @@ -4235,7 +4277,7 @@ local function Frame(name, parent) end end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local xO, yO = self:getOffset() xO = xO < 0 and math.abs(xO) or -xO yO = yO < 0 and math.abs(yO) or -yO @@ -4246,7 +4288,7 @@ local function Frame(name, parent) if (self.parent ~= nil) then parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition()) end - self:setPosition(x + self.xToRem - (parentX - 1) + xO, y - (parentY - 1) + yO) + self:setPosition(x + dragOffset - (parentX - 1) + xO, y - (parentY - 1) + yO) end if (event == "mouse_up") then self.drag = false @@ -4254,32 +4296,25 @@ local function Frame(name, parent) return true end - if (base.mouseClickHandler(self, event, button, x, y)) then + if (base.mouseHandler(self, event, button, x, y)) then local fx, fy = self:getAbsolutePosition(self:getAnchorPosition()) - if(event~="monitor_touch") or (isMonitor)then + fx = fx + xOffset;fy = fy + yOffset; for _, index in pairs(objZIndex) do if (objects[index] ~= nil) then for _, value in rpairs(objects[index]) do - if (value.mouseClickHandler ~= nil) then - if (value:mouseClickHandler(event, button, x + xO, y + yO)) then + if (value.mouseHandler ~= nil) then + if (value:mouseHandler(event, button, x, y)) then return true end end end end end - elseif not(isMonitor)then - for _,v in pairs(monitors)do - if(button==v.monitor)then - v.frame:mouseClickHandler(event, button, x, y) - end - end - end if (self.isMoveable) then if (x >= fx) and (x <= fx + self.width - 1) and (y == fy) and (event == "mouse_click") then self.drag = true - self.xToRem = fx - x + dragOffset = fx - x end end if (focusedObject ~= nil) then @@ -4295,7 +4330,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:setText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1)) else drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1)) end @@ -4306,7 +4342,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setBG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:setBG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1)) else drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1)) end @@ -4317,7 +4354,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setFG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:setFG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1)) else drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1)) end @@ -4328,7 +4366,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:writeText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:writeText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol) else drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol) end @@ -4340,7 +4379,8 @@ local function Frame(name, parent) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) if (self.parent ~= nil) then - self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, bgCol) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, bgCol) else drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, bgCol) end @@ -4351,7 +4391,8 @@ local function Frame(name, parent) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) if (self.parent ~= nil) then - self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, symbol:sub(1, 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, symbol:sub(1, 1)) else drawHelper.drawTextBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, symbol:sub(1, 1)) end @@ -4362,16 +4403,15 @@ local function Frame(name, parent) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) if (self.parent ~= nil) then - self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, fgCol) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, fgCol) else drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgCol) end end; draw = function(self) - for _,v in pairs(monitors)do - v.frame:draw() - end + if(isMonitor)and not(monitorAttached)then return false end; if (self:getVisualChanged()) then if (base.draw(self)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) @@ -4418,11 +4458,9 @@ local function Frame(name, parent) end end; - drawUpdate = function (self) + drawUpdate = function(self) + if(isMonitor)and not(monitorAttached)then return false end; drawHelper.update() - for k,v in pairs(monitors)do - v.frame:drawUpdate() - end end; addObject = function(self, obj) @@ -4542,24 +4580,41 @@ local function Frame(name, parent) end; } setmetatable(object, base) - if (parent == nil) then - table.insert(frames, object) - end return object end +local function drawFrames() + mainFrame:draw() + mainFrame:drawUpdate() + for _,v in pairs(monFrames)do + v:draw() + v:drawUpdate() + end +end + local updaterActive = false local function basaltUpdateEvent(event, p1, p2, p3, p4) - if (event == "mouse_click") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "mouse_drag") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "mouse_up") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "mouse_scroll") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "monitor_touch") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "key") or (event == "char") then + if(mainFrame~=nil)then + if (event == "mouse_click") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "mouse_drag") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "mouse_up") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "mouse_scroll") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "monitor_touch") then + if(monFrames[p1]~=nil)then + monFrames[p1]:mouseHandler(event, p1, p2, p3, p4) + activeFrame = monFrames[p1] + end + end + end + + if(event == "key") or (event == "char") then activeFrame:keyHandler(event, p1) activeFrame:backgroundKeyHandler(event, p1) end @@ -4572,20 +4627,18 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4) keyActive[p1] = false end - for _, value in pairs(frames) do - value:eventHandler(event, p1, p2, p3, p4) + for _, v in pairs(frames) do + v:eventHandler(event, p1, p2, p3, p4) end if (updaterActive) then - activeFrame:draw() - activeFrame:drawUpdate() + drawFrames() end end function basalt.autoUpdate(isActive) - parentTerminal.clear() - updaterActive = isActive or true - activeFrame:draw() - activeFrame:drawUpdate() + updaterActive = isActive + if(isActive==nil)then updaterActive = true end + drawFrames() while updaterActive do local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later basaltUpdateEvent(event, p1, p2, p3, p4) @@ -4596,8 +4649,7 @@ function basalt.update(event, p1, p2, p3, p4) if (event ~= nil) then basaltUpdateEvent(event, p1, p2, p3, p4) else - activeFrame:draw() - activeFrame:drawUpdate() + drawFrames() end end @@ -4631,32 +4683,34 @@ function basalt.setActiveFrame(frame) end function basalt.createFrame(name) - return Frame(name) + for _, v in pairs(frames) do + if (v.name == name) then + return nil + end + end + local newFrame = Frame(name) + table.insert(frames, newFrame) + return newFrame end function basalt.removeFrame(name) - for key, value in pairs(frames) do - if (value.name == name) then - frames[key] = nil - return true - end - end - return false + frames[name] = nil end + if (basalt.debugger) then basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray) basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show() basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show() - basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = activeFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show() + basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = mainFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):ignoreOffset():setZIndex(20):show() end if (basalt.debugger) then function basalt.debug(...) local args = { ... } - if (activeFrame.name ~= "basaltDebuggingFrame") then - if (activeFrame ~= basalt.debugLabel.frame) then - basalt.debugLabel:setParent(activeFrame) + if (mainFrame.name ~= "basaltDebuggingFrame") then + if (mainFrame ~= basalt.debugFrame) then + basalt.debugLabel:setParent(mainFrame) end end local str = "" diff --git a/basalt.lua b/basalt.lua index 4be3003..f0fdb86 100644 --- a/basalt.lua +++ b/basalt.lua @@ -1 +1 @@ -local a={debugger=true,version=1}local b;local c={}local d={}local e=term.current()local f=string.sub;local g={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local h={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local i={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{[[000110000110110000110010101000000010000000100101]],[[000000110110000000000010101000000010000000100101]],[[000000000000000000000000000000000000000000000000]],[[100010110100000010000110110000010100000100000110]],[[000000110000000010110110000110000000000000110000]],[[000000000000000000000000000000000000000000000000]],[[000000110110000010000000100000100000000000000010]],[[000000000110110100010000000010000000000000000100]],[[000000000000000000000000000000000000000000000000]],[[010000000000100110000000000000000000000110010000]],[[000000000000000000000000000010000000010110000000]],[[000000000000000000000000000000000000000000000000]],[[011110110000000100100010110000000100000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110000110110000000000000000000010100100010000000]],[[000010000000000000110110000000000100010010000000]],[[000000000000000000000000000000000000000000000000]],[[010110010110100110110110010000000100000110110110]],[[000000000000000000000110000000000110000000000000]],[[000000000000000000000000000000000000000000000000]],[[010100010110110000000000000000110000000010000000]],[[110110000000000000110000110110100000000010000000]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[100100100100100100100100100100100100100100100100]],[[000000110100110110000010000011110000000000011000]],[[000000000100000000000010000011000110000000001000]],[[000000000000000000000000000000000000000000000000]],[[010000100100000000000000000100000000010010110000]],[[000000000000000000000000000000110110110110110000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110000000110110110110110110110110]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000110110000110010000000000000000010010]],[[000010000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110110110110000000000000]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110000000000000000010000]],[[000000000000000000000000100000000000000110000110]],[[000000000000000000000000000000000000000000000000]]}}local j={}local k={}do local l=0;local m=#i[1]local n=#i[1][1]for o=1,m,3 do for p=1,n,3 do local q=string.char(l)local r={}r[1]=i[1][o]:sub(p,p+2)r[2]=i[1][o+1]:sub(p,p+2)r[3]=i[1][o+2]:sub(p,p+2)local s={}s[1]=i[2][o]:sub(p,p+2)s[2]=i[2][o+1]:sub(p,p+2)s[3]=i[2][o+2]:sub(p,p+2)k[q]={r,s}l=l+1 end end;j[1]=k end;local function t(u,v)local w={["0"]="1",["1"]="0"}if u<=#j then return true end;for x=#j+1,u do local y={}local z=j[x-1]for l=0,255 do local q=string.char(l)local r={}local s={}local A=z[q][1]local B=z[q][2]for o=1,#A do local C,D,E,F,G,H={},{},{},{},{},{}for p=1,#A[1]do local I=k[A[o]:sub(p,p)][1]table.insert(C,I[1])table.insert(D,I[2])table.insert(E,I[3])local J=k[A[o]:sub(p,p)][2]if B[o]:sub(p,p)=="1"then table.insert(F,J[1]:gsub("[01]",w))table.insert(G,J[2]:gsub("[01]",w))table.insert(H,J[3]:gsub("[01]",w))else table.insert(F,J[1])table.insert(G,J[2])table.insert(H,J[3])end end;table.insert(r,table.concat(C))table.insert(r,table.concat(D))table.insert(r,table.concat(E))table.insert(s,table.concat(F))table.insert(s,table.concat(G))table.insert(s,table.concat(H))end;y[q]={r,s}if v then v="Font"..x.."Yeld"..l;os.queueEvent(v)os.pullEvent(v)end end;j[x]=y end;return true end;local function K(L,M,N,O,P)if not type(M)=="string"then error("Not a String",3)end;local Q=type(N)=="string"and N:sub(1,1)or g[N]or error("Wrong Front Color",3)local R=type(O)=="string"and O:sub(1,1)or g[O]or error("Wrong Back Color",3)if j[L]==nil then t(3,false)end;local S=j[L]or error("Wrong font size selected",3)if M==""then return{{""},{""},{""}}end;local T={}for o in M:gmatch('.')do table.insert(T,o)end;local U={}local m=#S[T[1]][1]for V=1,m do local W={}for o=1,#T do W[o]=S[T[o]]and S[T[o]][1][V]or""end;U[V]=table.concat(W)end;local X={}local Y={}local Z={["0"]=Q,["1"]=R}local _={["0"]=R,["1"]=Q}for V=1,m do local a0={}local a1={}for o=1,#T do local a2=S[T[o]]and S[T[o]][2][V]or""a0[o]=a2:gsub("[01]",P and{["0"]=N:sub(o,o),["1"]=O:sub(o,o)}or Z)a1[o]=a2:gsub("[01]",P and{["0"]=O:sub(o,o),["1"]=N:sub(o,o)}or _)end;X[V]=table.concat(a0)Y[V]=table.concat(a1)end;return{U,X,Y}end;local function a3(a4)local a5=a4;local a6,m=a5.getSize()local a7={}local a8={}local a9={}local aa={}local ab={}local ac={}local ad;local ae={}local function af()ad=(" "):rep(a6)for ag=0,15 do local ah=2^ag;local ai=g[ah]ae[ah]=ai:rep(a6)end end;af()local function aj()local ak=ad;local al=ae[colors.white]local am=ae[colors.black]for an=1,m do a7[an]=f(a7[an]==nil and ak or a7[an]..ak:sub(1,a6-a7[an]:len()),1,a6)a9[an]=f(a9[an]==nil and al or a9[an]..al:sub(1,a6-a9[an]:len()),1,a6)a8[an]=f(a8[an]==nil and am or a8[an]..am:sub(1,a6-a8[an]:len()),1,a6)end end;aj()local function ao(ap,aq,ar)if aq>=1 and aq<=m then if ap+ar:len()>0 and ap<=a6 then local as=a7[aq]local at;local au=ap+#ar-1;if ap<1 then local av=1-ap+1;local aw=a6-ap+1;ar=f(ar,av,aw)elseif au>a6 then local aw=a6-ap+1;ar=f(ar,1,aw)end;if ap>1 then local aw=ap-1;at=f(as,1,aw)..ar else at=ar end;if au=1 and aq<=m then if ap+ay:len()>0 and ap<=a6 then local as=a8[aq]local at;local au=ap+#ay-1;if ap<1 then ay=f(ay,1-ap+1,a6-ap+1)elseif au>a6 then ay=f(ay,1,a6-ap+1)end;if ap>1 then at=f(as,1,ap-1)..ay else at=ay end;if au=1 and aq<=m then if ap+ay:len()>0 and ap<=a6 then local as=a9[aq]local at;local au=ap+#ay-1;if ap<1 then local av=1-ap+1;local aw=a6-ap+1;ay=f(ay,av,aw)elseif au>a6 then local aw=a6-ap+1;ay=f(ay,1,aw)end;if ap>1 then local aw=ap-1;at=f(as,1,aw)..ay else at=ay end;if au1 then while#bg>2 do table.sort(bg,function(bq,br)return bq[2]>br[2]end)local bs,bt=bf(bg),#bg;local bu,bv=bg[bt][1],bg[bs][1]for o=1,6 do if bk[o]==bu then bk[o]=bv;bg[bs][2]=bg[bs][2]+1 end end;bg[bt]=nil end;local bw=128;for o=1,#bk-1 do if bk[o]~=bk[6]then bw=bw+2^(o-1)end end;return string.char(bw),bc[bg[1][1]==bk[6]and bg[2][1]or bg[1][1]],bc[bk[6]]else return"\128",bc[bk[1]],bc[bk[1]]end end;local bx,a6,m,aB={{},{},{}},0,#b7+#b7%3,b8 or colors.black;for o=1,#b7 do if#b7[o]>a6 then a6=#b7[o]end end;for aq=0,m-1,3 do local by,bz,bA,bB={},{},{},1;for ap=0,a6-1,2 do local bk,bl={},{}for bC=1,3 do for bD=1,2 do bk[#bk+1]=b7[aq+bC]and b7[aq+bC][ap+bD]and(b7[aq+bC][ap+bD]==0 and aB or b7[aq+bC][ap+bD])or aB;bl[bk[#bk]]=bl[bk[#bk]]and bl[bk[#bk]]+1 or 1 end end;by[bB],bz[bB],bA[bB]=bj(bk,bl)bB=bB+1 end;bx[1][#bx[1]+1],bx[2][#bx[2]+1],bx[3][#bx[3]+1]=table.concat(by),table.concat(bz),table.concat(bA)end;bx.width,bx.height=#bx[1][1],#bx[1]return bx end;local function bE(bF)local bG="Object"local aP;local bH=1;local bI="left"local bJ="top"local bK=false;local bL=false;local bM=true;local bN=aI()local bO={x=1,y=1,width=1,height=1,bgColor=colors.black,fgColor=colors.white,name=bF or"Object",parent=nil,show=function(self)bL=true;bM=true;return self end,hide=function(self)bL=false;bM=true;return self end,isVisible=function(self)return bL end,setFocus=function(self)if self.parent~=nil then self.parent:setFocusedObject(self)end;return self end,setZIndex=function(self,aK)bH=aK;if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end;return self end,getZIndex=function(self)return bH end,getType=function(self)return bG end,getName=function(self)return self.name end,remove=function(self)if self.parent~=nil then self.parent:removeObject(self)end;return self end,setParent=function(self,bP)if bP.getType~=nil and bP:getType()=="Frame"then self:remove()bP:addObject(self)if self.draw then self:show()end end;return self end,setValue=function(self,bQ)if aP~=bQ then aP=bQ;bM=true;self:valueChangedHandler()end;return self end,getValue=function(self)return aP end,getVisualChanged=function(self)return bM end,setVisualChanged=function(self,bR)bM=bR or true;if bR==nil then bM=true end;return self end,getEventSystem=function(self)return bN end,getParent=function(self)return self.parent end,setPosition=function(self,bS,bT,bU)if bU then self.x,self.y=math.floor(self.x+bS),math.floor(self.y+bT)else self.x,self.y=math.floor(bS),math.floor(bT)end;bM=true;return self end,getPosition=function(self)return self.x,self.y end,getVisibility=function(self)return bL end,setVisibility=function(self,bV)bL=bV or not bL;bM=true;return self end,setSize=function(self,a6,m)self.width,self.height=a6,m;bM=true;return self end,getHeight=function(self)return self.height end,getWidth=function(self)return self.width end,getSize=function(self)return self.width,self.height end,setBackground=function(self,bW)self.bgColor=bW;bM=true;return self end,getBackground=function(self)return self.bgColor end,setForeground=function(self,bW)self.fgColor=bW;bM=true;return self end,getForeground=function(self)return self.fgColor end,draw=function(self)if bL then return true end;return false end,getAbsolutePosition=function(self,ap,aq)if ap==nil then ap=self.x end;if aq==nil then aq=self.y end;if self.parent~=nil then local bX,bY=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())ap=bX+ap-1;aq=bY+aq-1 end;return ap,aq end,getAnchorPosition=function(self,ap,aq,bZ)if ap==nil then ap=self.x end;if aq==nil then aq=self.y end;if bI=="right"then ap=self.parent.width-ap-self.width+2 end;if bJ=="bottom"then aq=self.parent.height-aq-self.height+2 end;local b_,c0=self:getOffset()if bK or bZ then return ap,aq end;return ap+b_,aq+c0 end,getOffset=function(self)if self.parent~=nil and bK==false then return self.parent:getFrameOffset()end;return 0,0 end,ignoreOffset=function(self,c1)bK=c1 or true;return self end,setAnchor=function(self,...)for aO,aP in pairs(table.pack(...))do if aP=="right"or aP=="left"then bI=aP end;if aP=="top"or aP=="bottom"then bJ=aP end end;bM=true;return self end,getAnchor=function(self)return bI,bJ end,onChange=function(self,aN)self:registerEvent("value_changed",aN)return self end,onClick=function(self,aN)self:registerEvent("mouse_click",aN)self:registerEvent("monitor_touch",aN)return self end,onEvent=function(self,aN)self:registerEvent("custom_event_handler",aN)return self end,onClickUp=function(self,aN)self:registerEvent("mouse_up",aN)return self end,onKey=function(self,aN)self:registerEvent("key",aN)self:registerEvent("char",aN)return self end,onKeyUp=function(self,aN)self:registerEvent("key_up",aN)return self end,onBackgroundKey=function(self,aN)self:registerEvent("background_key",aN)self:registerEvent("background_char",aN)return self end,onBackgroundKeyUp=function(self,aN)self:registerEvent("background_key_up",aN)return self end,isFocused=function(self)if self.parent~=nil then return self.parent:getFocusedObject()==self end;return false end,onGetFocus=function(self,aN)self:registerEvent("get_focus",aN)return self end,onLoseFocus=function(self,aN)self:registerEvent("lose_focus",aN)return self end,registerEvent=function(self,aL,aN)return bN:registerEvent(aL,aN)end,removeEvent=function(self,aL,aK)return bN:removeEvent(aL,aK)end,sendEvent=function(self,aL,...)return bN:sendEvent(aL,self,...)end,mouseClickHandler=function(self,aL,c2,ap,aq)local c3,c4=self:getAbsolutePosition(self:getAnchorPosition())if c3<=ap and c3+self.width>ap and c4<=aq and c4+self.height>aq and bL then if self.parent~=nil then self.parent:setFocusedObject(self)end;bN:sendEvent(aL,self,aL,c2,ap,aq)return true end;return false end,keyHandler=function(self,aL,bp)if self:isFocused()then bN:sendEvent(aL,self,aL,bp)return true end;return false end,backgroundKeyHandler=function(self,aL,bp)bN:sendEvent("background_"..aL,self,aL,bp)end,valueChangedHandler=function(self)bN:sendEvent("value_changed",self)end,eventHandler=function(self,aL,c5,c6,c7,c8)bN:sendEvent("custom_event_handler",self,aL,c5,c6,c7,c8)end,getFocusHandler=function(self)bN:sendEvent("get_focus",self)end,loseFocusHandler=function(self)bN:sendEvent("lose_focus",self)end}bO.__index=bO;return bO end;local function c9(bF)local bO={}local bG="Animation"local ca;local cb={}local aK=1;local cc=0;local cd;local function ce()if cb[aK]~=nil then cb[aK].f(bO,aK)end;aK=aK+1;if cb[aK]~=nil then if cb[aK].t>0 then ca=os.startTimer(cb[aK].t)else ce()end end end;bO={name=bF,getType=function(self)return bG end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,aN,cf)cd=aN;table.insert(cb,{f=aN,t=cf or cc})return self end,wait=function(self,cf)cc=cf;return self end,rep=function(self,cg)for ap=1,cg do table.insert(cb,{f=cd,t=cc})end;return self end,clear=function(self)cb={}cd=nil;cc=0;aK=1;return self end,play=function(self)aK=1;if cb[aK]~=nil then if cb[aK].t>0 then ca=os.startTimer(cb[aK].t)else ce()end end;return self end,cancel=function(self)os.cancelTimer(ca)return self end,eventHandler=function(self,aL,ch)if aL=="timer"and ch==ca then if cb[aK]~=nil then ce()end end end}bO.__index=bO;return bO end;local function ci(bF)local cj=bE(bF)local bG="Button"cj:setValue("Button")cj:setZIndex(5)cj.width=8;cj.bgColor=h.ButtonBG;cj.fgColor=h.ButtonFG;local ck="center"local cl="center"local bO={getType=function(self)return bG end,setHorizontalAlign=function(self,cm)ck=cm end,setVerticalAlign=function(self,cm)cl=cm end,setText=function(self,ar)cj:setValue(ar)return self end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,cl)self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)self.parent:drawTextBox(cn,co,self.width,self.height," ")for ag=1,self.height do if ag==cp then self.parent:setText(cn,co+ag-1,aZ(self:getValue(),self.width,ck))end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cq(bF)local cj=bE(bF)local bG="Checkbox"cj:setZIndex(5)cj:setValue(false)cj.width=1;cj.height=1;cj.bgColor=h.CheckboxBG;cj.fgColor=h.CheckboxFG;local bO={symbol="\42",getType=function(self)return bG end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,"center")self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)for ag=1,self.height do if ag==cp then if self:getValue()==true then self.parent:writeText(cn,co+ag-1,aZ(self.symbol,self.width,"center"),self.bgColor,self.fgColor)else self.parent:writeText(cn,co+ag-1,aZ(" ",self.width,"center"),self.bgColor,self.fgColor)end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cr(bF)local cj=bE(bF)local bG="Dropdown"cj.width=12;cj.height=1;cj.bgColor=h.dropdownBG;cj.fgColor=h.dropdownFG;cj:setZIndex(6)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local cv=true;local cw="left"local cx=0;local cy=16;local cz=6;local cA="\16"local cB="\31"local cC=false;local bO={getType=function(self)return bG end,setIndexOffset=function(self,cD)cx=cD;return self end,getIndexOffset=function(self)return cx end,addItem=function(self,ar,aB,aC,...)table.insert(cs,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,getAll=function(self)return cs end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getItemIndex=function(self)local cE=self:getValue()for bp,aP in pairs(cs)do if aP==cE then return bp end end end,clear=function(self)cs={}self:setValue({})return self end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,cF)ct=aB or self.bgColor;cu=aC or self.fgColor;cv=cF;return self end,setDropdownSize=function(self,a6,m)cy,cz=a6,m;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cC then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then if#cs>0 then for ag=1,cz do if cs[ag+cx]~=nil then if cn<=ap and cn+cy>ap and co+ag==aq then self:setValue(cs[ag+cx])return true end end end end end;if aL=="mouse_scroll"then cx=cx+c2;if cx<0 then cx=0 end;if c2==1 then if#cs>cz then if cx>#cs-cz then cx=#cs-cz end else cx=cs-1 end end;return true end;self:setVisualChanged()end;if cj.mouseClickHandler(self,aL,c2,ap,aq)then cC=true else cC=false end end,draw=function(self)if cj.draw(self)then local cn,co=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)local cG=self:getValue()local ar=aZ(cG~=nil and cG.text or"",self.width,cw):sub(1,self.width-1)..(cC and cB or cA)self.parent:writeText(cn,co,ar,self.bgColor,self.fgColor)if cC then for ag=1,cz do if cs[ag+cx]~=nil then if cs[ag+cx]==cG then if cv then self.parent:writeText(cn,co+ag,aZ(cs[ag+cx].text,cy,cw),ct,cu)else self.parent:writeText(cn,co+ag,aZ(cs[ag+cx].text,cy,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end else self.parent:writeText(cn,co+ag,aZ(cs[ag+cx].text,cy,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cH(bF)local cj=bE(bF)local bG="Image"cj:setZIndex(2)local cI;local cJ;local cK=false;local function b6()local b9={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local ba,bb,bc={},{},{}for o=0,15 do bb[2^o]=o end;do local bd="0123456789abcdef"for o=1,16 do ba[bd:sub(o,o)]=o-1;ba[o-1]=bd:sub(o,o)bc[bd:sub(o,o)]=2^(o-1)bc[2^(o-1)]=bd:sub(o,o)local be=b9[o-1]for o=1,#be do be[o]=2^be[o]end end end;local function bf(bg)local bh=b9[bb[bg[#bg][1]]]for p=1,#bh do local bi=bh[p]for o=1,#bg-1 do if bg[o][1]==bi then return o end end end;return 1 end;local function bj(bk,bl)if not bl then local bm={}bl={}for o=1,6 do local bn=bk[o]local bo=bl[bn]bl[bn],bm[o]=bo and bo+1 or 1,bn end;bk=bm end;local bg={}for bp,aP in pairs(bl)do bg[#bg+1]={bp,aP}end;if#bg>1 then while#bg>2 do table.sort(bg,function(bq,br)return bq[2]>br[2]end)local bs,bt=bf(bg),#bg;local bu,bv=bg[bt][1],bg[bs][1]for o=1,6 do if bk[o]==bu then bk[o]=bv;bg[bs][2]=bg[bs][2]+1 end end;bg[bt]=nil end;local bw=128;for o=1,#bk-1 do if bk[o]~=bk[6]then bw=bw+2^(o-1)end end;return string.char(bw),bc[bg[1][1]==bk[6]and bg[2][1]or bg[1][1]],bc[bk[6]]else return"\128",bc[bk[1]],bc[bk[1]]end end;local bx,a6,m,aB={{},{},{}},0,#cI+#cI%3,cj.bgColor or colors.black;for o=1,#cI do if#cI[o]>a6 then a6=#cI[o]end end;for aq=0,m-1,3 do local by,bz,bA,bB={},{},{},1;for ap=0,a6-1,2 do local bk,bl={},{}for bC=1,3 do for bD=1,2 do bk[#bk+1]=cI[aq+bC]and cI[aq+bC][ap+bD]and(cI[aq+bC][ap+bD]==0 and aB or cI[aq+bC][ap+bD])or aB;bl[bk[#bk]]=bl[bk[#bk]]and bl[bk[#bk]]+1 or 1 end end;by[bB],bz[bB],bA[bB]=bj(bk,bl)bB=bB+1 end;bx[1][#bx[1]+1],bx[2][#bx[2]+1],bx[3][#bx[3]+1]=table.concat(by),table.concat(bz),table.concat(bA)end;bx.width,bx.height=#bx[1][1],#bx[1]cJ=bx end;local bO={getType=function(self)return bG end,loadImage=function(self,aT)cI=paintutils.loadImage(aT)cK=false;return self end,loadBlittleImage=function(self,aT)cK=true;return self end,shrink=function(self)b6()cK=true;return self end,draw=function(self)if cj.draw(self)then if self.parent~=nil then if cI~=nil then local cn,co=self:getAnchorPosition()if cK then local b5,cL,cM=cJ[1],cJ[2],cJ[3]for o=1,cJ.height do local cN=b5[o]if type(cN)=="string"then self.parent:setText(cn,co+o-1,cN)self.parent:setFG(cn,co+o-1,cL[o])self.parent:setBG(cn,co+o-1,cM[o])elseif type(cN)=="table"then self.parent:setText(cn,co+o-1,cN[2])self.parent:setFG(cn,co+o-1,cL[o])self.parent:setBG(cn,co+o-1,cM[o])end end else for bT=1,math.min(#cI,self.height)do local cO=cI[bT]for bS=1,math.min(#cO,self.width)do if cO[bS]>0 then self.parent:drawBackgroundBox(cn+bS-1,co+bT-1,1,1,cO[bS])end end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cP(bF)local cj=bE(bF)local bG="Input"local cQ="text"local cR=0;cj:setZIndex(5)cj:setValue("")cj.width=10;cj.height=1;cj.bgColor=h.InputBG;cj.fgColor=h.InputFG;local cS=1;local cT=1;local cU=""local cV;local cW;local cX=cU;local cY=false;local bO={getType=function(self)return bG end,setInputType=function(self,cZ)if cZ=="password"or cZ=="number"or cZ=="text"then cQ=cZ end;return self end,setDefaultText=function(self,ar,c_,d0)cU=ar;cV=d0 or cV;cW=c_ or cW;if self:isFocused()then cX=""else cX=cU end;return self end,getInputType=function(self)return cQ end,setValue=function(self,cG)cj.setValue(self,tostring(cG))if not cY then cS=tostring(cG):len()+1 end;return self end,getValue=function(self)local cG=cj.getValue(self)return cQ=="number"and tonumber(cG)or cG end,setInputLimit=function(self,d1)cR=tonumber(d1)or cR;return self end,getInputLimit=function(self)return cR end,getFocusHandler=function(self)cj.getFocusHandler(self)if self.parent~=nil then local cn,co=self:getAnchorPosition()cX=""if self.parent~=nil then self.parent:setCursor(true,cn+cS-cT,co,self.fgColor)end end end,loseFocusHandler=function(self)cj.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)cX=cU end end,keyHandler=function(self,aL,bp)if cj.keyHandler(self,aL,bp)then cY=true;if aL=="key"then if bp==keys.backspace then local ar=tostring(cj.getValue())if cS>1 then self:setValue(ar:sub(1,cS-2)..ar:sub(cS,ar:len()))if cS>1 then cS=cS-1 end;if cT>1 then if cSd2 then cS=d2+1 end;if cS<1 then cS=1 end;if cS=self.width+cT then cT=cS-self.width+1 end;if cT<1 then cT=1 end end;if bp==keys.left then cS=cS-1;if cS>=1 then if cS=self.width+cT then cT=cS end end;if cS<1 then cS=1 end;if cT<1 then cT=1 end end end;if aL=="char"then local ar=cj.getValue()if ar:len()=self.width+cT then cT=cT+1 end end end;local cn,co=self:getAnchorPosition()local cG=tostring(cj.getValue())local d4=(cS<=cG:len()and cS-1 or cG:len())-(cT-1)if d4>self.x+self.width-1 then d4=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,cn+d4,co,self.fgColor)end;cY=false end end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then if aL=="mouse_click"and c2==1 then end;return true end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,"center")self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)for ag=1,self.height do if ag==cp then local cG=tostring(cj.getValue())local d0=self.bgColor;local c_=self.fgColor;local ar;if cG:len()<=0 then ar=cX;d0=cV or d0;c_=cW or c_ end;ar=cX;if cG~=""then ar=cG end;ar=ar:sub(cT,self.width+cT-1)local d5=self.width-ar:len()if d5<0 then d5=0 end;if cQ=="password"and cG~=""then ar=string.rep("*",ar:len())end;ar=ar..string.rep(" ",d5)self.parent:writeText(cn,co+ag-1,ar,d0,c_)end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function d6(bF)local cj=bE(bF)local bG="Label"cj:setZIndex(3)cj.fgColor=colors.white;cj.bgcolor=colors.black;local d7=true;cj:setValue("")local ck="left"local cl="top"local d8=0;local bO={getType=function(self)return bG end,setText=function(self,ar)ar=tostring(ar)cj:setValue(ar)if d7 then self.width=ar:len()end;return self end,setTextAlign=function(self,d9,da)ck=d9 or ck;cl=da or cl;self:setVisualChanged()return self end,setFontSize=function(self,u)if u>0 and u<=4 then d8=u-1 or 0 end;return self end,getFontSize=function(self)return d8+1 end,setSize=function(self,a6,m)cj.setSize(self,a6,m)d7=false;self:setVisualChanged()return self end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,cl)self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)self.parent:drawTextBox(cn,co,self.width,self.height," ")if d8==0 then for ag=1,self.height do if ag==cp then self.parent:writeText(cn,co+ag-1,aZ(self:getValue(),self.width,ck),self.bgColor,self.fgColor)end end else local db=K(d8,self:getValue(),self.fgColor,self.bgColor)if d7 then self.height=#db[1]-1;self.width=#db[1][1]end;for ag=1,self.height do if ag==cp then local dc,dd=self.parent:getSize()local de,df=#db[1][1],#db[1]cn=cn or math.floor((dc-de)/2)+1;co=co or math.floor((dd-df)/2)+1;for o=1,df do self.parent:setFG(cn,co+o+ag-2,aZ(db[2][o],self.width,ck))self.parent:setBG(cn,co+o+ag-2,aZ(db[3][o],self.width,ck,g[self.bgColor]))self.parent:setText(cn,co+o+ag-2,aZ(db[1][o],self.width,ck))end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function dg(bF)local cj=bE(bF)local bG="List"cj.width=16;cj.height=6;cj.bgColor=h.listBG;cj.fgColor=h.listFG;cj:setZIndex(5)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local cv=true;local cw="left"local cx=0;local dh=true;local bO={getType=function(self)return bG end,addItem=function(self,ar,aB,aC,...)table.insert(cs,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})if#cs==1 then self:setValue(cs[1])end;return self end,setIndexOffset=function(self,cD)cx=cD;return self end,getIndexOffset=function(self)return cx end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getAll=function(self)return cs end,getItemIndex=function(self)local cE=self:getValue()for bp,aP in pairs(cs)do if aP==cE then return bp end end end,clear=function(self)cs={}self:setValue({})return self end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,cF)ct=aB or self.bgColor;cu=aC or self.fgColor;cv=cF;return self end,setScrollable=function(self,di)dh=di;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if cn<=ap and cn+self.width>ap and co<=aq and co+self.height>aq and self:isVisible()then if(aL=="mouse_click"or aL=="mouse_drag")and c2==1 or aL=="monitor_touch"then if#cs>0 then for ag=1,self.height do if cs[ag+cx]~=nil then if cn<=ap and cn+self.width>ap and co+ag-1==aq then self:setValue(cs[ag+cx])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,ap,aq,cs[ag+cx])end end end end end;if aL=="mouse_scroll"and dh then cx=cx+c2;if cx<0 then cx=0 end;if c2>=1 then if#cs>self.height then if cx>#cs-self.height then cx=#cs-self.height end;if cx>=#cs then cx=#cs-1 end else cx=cx-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)for ag=1,self.height do if cs[ag+cx]~=nil then if cs[ag+cx]==self:getValue()then if cv then self.parent:writeText(cn,co+ag-1,aZ(cs[ag+cx].text,self.width,cw),ct,cu)else self.parent:writeText(cn,co+ag-1,aZ(cs[ag+cx].text,self.width,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end else self.parent:writeText(cn,co+ag-1,aZ(cs[ag+cx].text,self.width,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function dj(bF)local cj=bE(bF)local bG="Menubar"local bO={}cj.width=30;cj.height=1;cj.bgColor=colors.gray;cj.fgColor=colors.lightGray;cj:setZIndex(5)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local cv=true;local cw="left"local dk=0;local d5=1;local dh=false;local function dl()local dm=0;local bS=0;for ag=1,#cs do if bS+cs[ag].text:len()+d5*2>bO.width then if bSdm then dk=dm end;return self end,getPositionOffset=function(self)return dk end,setScrollable=function(self,di)dh=di;if di==nil then dh=true end;return self end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,cF)ct=aB or self.bgColor;cu=aC or self.fgColor;cv=cF;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local c3,c4=self:getAbsolutePosition(self:getAnchorPosition())if c3<=ap and c3+self.width>ap and c4<=aq and c4+self.height>aq and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if aL=="mouse_click"or aL=="monitor_touch"then local bS=0;for ag=1,#cs do if cs[ag]~=nil then if c3+bS<=ap+dk and c3+bS+cs[ag].text:len()+d5*2>ap+dk and c4==aq then self:setValue(cs[ag])self:getEventSystem():sendEvent(aL,self,aL,0,ap,aq,cs[ag])end;bS=bS+cs[ag].text:len()+d5*2 end end end;if aL=="mouse_scroll"and dh then dk=dk+c2;if dk<0 then dk=0 end;local dm=dl()if dk>dm then dk=dm end end;self:setVisualChanged(true)return true end end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)local ar=""local dp=""local dq=""for aO,dr in pairs(cs)do local ds=(" "):rep(d5)..dr.text..(" "):rep(d5)ar=ar..ds;if dr==self:getValue()then dp=dp..g[ct or dr.bgCol or self.bgColor]:rep(ds:len())dq=dq..g[cu or dr.FgCol or self.fgColor]:rep(ds:len())else dp=dp..g[dr.bgCol or self.bgColor]:rep(ds:len())dq=dq..g[dr.FgCol or self.fgColor]:rep(ds:len())end end;self.parent:setText(cn,co,ar:sub(dk+1,self.width+dk))self.parent:setBG(cn,co,dp:sub(dk+1,self.width+dk))self.parent:setFG(cn,co,dq:sub(dk+1,self.width+dk))end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function dt(bF)local cj=bE(bF)local bG="Pane"local bO={getType=function(self)return bG end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.bgColor)end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function du(bF)local cj=bE(bF)local bG="Program"cj:setZIndex(5)local bO;local function dv(ap,aq,a6,m)local dw,dx=1,1;local b8,dy=colors.black,colors.white;local dz=false;local dA=false;local a7={}local a8={}local a9={}local dB={}local ad;local ae={}for o=0,15 do local dC=2^o;dB[dC]={e.getPaletteColour(dC)}end;local function af()ad=(" "):rep(a6)for ag=0,15 do local ah=2^ag;local ai=g[ah]ae[ah]=ai:rep(a6)end end;local function aj()af()local ak=ad;local al=ae[colors.white]local am=ae[colors.black]for ag=1,m do a7[ag]=f(a7[ag]==nil and ak or a7[ag]..ak:sub(1,a6-a7[ag]:len()),1,a6)a9[ag]=f(a9[ag]==nil and al or a9[ag]..al:sub(1,a6-a9[ag]:len()),1,a6)a8[ag]=f(a8[ag]==nil and am or a8[ag]..am:sub(1,a6-a8[ag]:len()),1,a6)end end;aj()local function dD()if dw>=1 and dx>=1 and dw<=a6 and dx<=m then else end end;local function dE(dF,dG,dH)local dI=dw;local au=dI+#dF-1;if dx>=1 and dx<=m then if dI<=a6 and au>=1 then if dI==1 and au==a6 then a7[dx]=dF;a9[dx]=dG;a8[dx]=dH else local dJ,dK,dL;if dI<1 then local dM=1-dI+1;local dN=a6-dI+1;dJ=f(dF,dM,dN)dK=f(dG,dM,dN)dL=f(dH,dM,dN)elseif au>a6 then local dN=a6-dI+1;dJ=f(dF,1,dN)dK=f(dG,1,dN)dL=f(dH,1,dN)else dJ=dF;dK=dG;dL=dH end;local dO=a7[dx]local dP=a9[dx]local dQ=a8[dx]local dR,dS,dT;if dI>1 then local dU=dI-1;dR=f(dO,1,dU)..dJ;dS=f(dP,1,dU)..dK;dT=f(dQ,1,dU)..dL else dR=dJ;dS=dK;dT=dL end;if au=1 and aq<=m then a7[eg]=a7[aq]a8[eg]=a8[aq]a9[eg]=a9[aq]else a7[eg]=ed;a9[eg]=ee;a8[eg]=ef end end end;if dA then dD()end end,isColor=function()return e.isColor()end,isColour=function()return e.isColor()end,write=function(ar)ar=tostring(ar)if dA then dE(ar,g[dy]:rep(ar:len()),g[b8]:rep(ar:len()))end end,clearLine=function()if dA then ao(1,dx,(" "):rep(a6))ax(1,dx,g[b8]:rep(a6))az(1,dx,g[dy]:rep(a6))end;if dA then dD()end end,clear=function()for ag=1,m do ao(1,ag,(" "):rep(a6))ax(1,ag,g[b8]:rep(a6))az(1,ag,g[dy]:rep(a6))end;if dA then dD()end end,blit=function(ar,eh,ei)if type(ar)~="string"then error("bad argument #1 (expected string, got "..type(ar)..")",2)end;if type(eh)~="string"then error("bad argument #2 (expected string, got "..type(eh)..")",2)end;if type(ei)~="string"then error("bad argument #3 (expected string, got "..type(ei)..")",2)end;if#eh~=#ar or#ei~=#ar then error("Arguments must be the same length",2)end;if dA then dE(ar,eh,ei)end end}return e8 end;cj.width=30;cj.height=12;local ej=dv(1,1,cj.width,cj.height)local ek;local el=false;local em={}bO={getType=function(self)return bG end,show=function(self)cj.show(self)ej.setBackgroundColor(self.bgColor)ej.setTextColor(self.fgColor)ej.basalt_setVisible(true)return self end,hide=function(self)cj.hide(self)ej.basalt_setVisible(false)return self end,setPosition=function(self,ap,aq,bU)cj.setPosition(self,ap,aq,bU)ej.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return ej end,getBasaltProcess=function()return ek end,setSize=function(self,a6,m)cj.setSize(self,a6,m)ej.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if ek~=nil then return ek:getStatus()end;return"inactive"end,execute=function(self,aT,...)ek=aR:new(aT,ej,...)ej.setBackgroundColor(colors.black)ej.setTextColor(colors.white)ej.clear()ej.setCursorPos(1,1)ek:resume()el=false;return self end,stop=function(self)if ek~=nil then if not ek:isDead()then ek:resume("terminate")if ek:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,en)el=en or not el;if ek~=nil then if not ek:isDead()then if not el then self:injectEvents(em)em={}end end end;return self end,isPaused=function(self)return el end,injectEvent=function(self,aL,c5,c6,c7,c8,eo)if ek~=nil then if not ek:isDead()then if el==false or eo then ek:resume(aL,c5,c6,c7,c8)else table.insert(em,{event=aL,args={c5,c6,c7,c8}})end end end;return self end,getQueuedEvents=function(self)return em end,updateQueuedEvents=function(self,aJ)em=aJ or em;return self end,injectEvents=function(self,aJ)if ek~=nil then if not ek:isDead()then for aO,aP in pairs(aJ)do ek:resume(aP.event,table.unpack(aP.args))end end end;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then if ek==nil then return false end;if not ek:isDead()then if not el then local ep,eq=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))ek:resume(aL,c2,ap-ep+1,aq-eq+1)end end;return true end end,keyHandler=function(self,aL,bp)cj.keyHandler(self,aL,bp)if self:isFocused()then if ek==nil then return false end;if not ek:isDead()then if not el then if self.draw then ek:resume(aL,bp)end end end end end,getFocusHandler=function(self)cj.getFocusHandler(self)if ek~=nil then if not ek:isDead()then if not el then if self.parent~=nil then local er,es=ej.getCursorPos()local cn,co=self:getAnchorPosition()if self.parent~=nil then if cn+er-1>=1 and cn+er-1<=cn+self.width-1 and es+co-1>=1 and es+co-1<=co+self.height-1 then self.parent:setCursor(ej.getCursorBlink(),cn+er-1,es+co-1,ej.getTextColor())end end end end end end end,loseFocusHandler=function(self)cj.loseFocusHandler(self)if ek~=nil then if not ek:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,aL,c5,c6,c7,c8)if ek==nil then return end;if not ek:isDead()then if not el then if aL~="mouse_click"and aL~="monitor_touch"and aL~="mouse_up"and aL~="mouse_scroll"and aL~="mouse_drag"and aL~="key_up"and aL~="key"and aL~="char"and aL~="terminate"then ek:resume(aL,c5,c6,c7,c8)end;if self:isFocused()then local cn,co=self:getAnchorPosition()local er,es=ej.getCursorPos()if self.parent~=nil then if cn+er-1>=1 and cn+er-1<=cn+self.width-1 and es+co-1>=1 and es+co-1<=co+self.height-1 then self.parent:setCursor(ej.getCursorBlink(),cn+er-1,es+co-1,ej.getTextColor())end end;if aL=="terminate"and self:isFocused()then self:stop()end end else if aL~="mouse_click"and aL~="monitor_touch"and aL~="mouse_up"and aL~="mouse_scroll"and aL~="mouse_drag"and aL~="key_up"and aL~="key"and aL~="char"and aL~="terminate"then table.insert(em,{event=aL,args={c5,c6,c7,c8}})end end end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()ej.basalt_reposition(cn,co)self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)ej.basalt_update()end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function et(bF)local cj=bE(bF)local bG="Progressbar"local eu=0;cj:setZIndex(5)cj:setValue(false)cj.width=25;cj.height=1;cj.bgColor=h.CheckboxBG;cj.fgColor=h.CheckboxFG;local ev=colors.black;local ew=""local ex=colors.white;local ey=""local ez=0;local bO={getType=function(self)return bG end,setDirection=function(self,eA)ez=eA;return self end,setProgressBar=function(self,bW,aD,eB)ev=bW or ev;ew=aD or ew;ex=eB or ex;return self end,setBackgroundSymbol=function(self,aD)ey=aD:sub(1,1)return self end,setProgress=function(self,aP)if aP>=0 and aP<=100 and eu~=aP then eu=aP;self:setValue(eu)if eu==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return eu end,onProgressDone=function(self,x)self:registerEvent("progress_done",x)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)self.parent:drawTextBox(cn,co,self.width,self.height,ey)if ez==1 then self.parent:drawBackgroundBox(cn,co,self.width,self.height/100*eu,ev)self.parent:drawForegroundBox(cn,co,self.width,self.height/100*eu,ex)self.parent:drawTextBox(cn,co,self.width,self.height/100*eu,ew)elseif ez==2 then self.parent:drawBackgroundBox(cn,co+math.ceil(self.height-self.height/100*eu),self.width,self.height/100*eu,ev)self.parent:drawForegroundBox(cn,co+math.ceil(self.height-self.height/100*eu),self.width,self.height/100*eu,ex)self.parent:drawTextBox(cn,co+math.ceil(self.height-self.height/100*eu),self.width,self.height/100*eu,ew)elseif ez==3 then self.parent:drawBackgroundBox(cn+math.ceil(self.width-self.width/100*eu),co,self.width/100*eu,self.height,ev)self.parent:drawForegroundBox(cn+math.ceil(self.width-self.width/100*eu),co,self.width/100*eu,self.height,ex)self.parent:drawTextBox(cn+math.ceil(self.width-self.width/100*eu),co,self.width/100*eu,self.height,ew)else self.parent:drawBackgroundBox(cn,co,self.width/100*eu,self.height,ev)self.parent:drawForegroundBox(cn,co,self.width/100*eu,self.height,ex)self.parent:drawTextBox(cn,co,self.width/100*eu,self.height,ew)end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eC(bF)local cj=bE(bF)local bG="Radio"cj.width=8;cj.bgColor=h.listBG;cj.fgColor=h.listFG;cj:setZIndex(5)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local eD=cj.bgColor;local eE=cj.fgColor;local cv=true;local aD="\7"local cw="left"local bO={getType=function(self)return bG end,addItem=function(self,ar,ap,aq,aB,aC,...)table.insert(cs,{x=ap or 1,y=aq or 1,text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})if#cs==1 then self:setValue(cs[1])end;return self end,getAll=function(self)return cs end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getItemIndex=function(self)local cE=self:getValue()for bp,aP in pairs(cs)do if aP==cE then return bp end end end,clear=function(self)cs={}self:setValue({})return self end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,ap,aq,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{x=ap or 1,y=aq or 1,text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,eF,eG,cF)ct=aB or ct;cu=aC or cu;eD=eF or eD;eE=eG or eE;cv=cF;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then if#cs>0 then for aO,aP in pairs(cs)do if cn+aP.x-1<=ap and cn+aP.x-1+aP.text:len()+2>=ap and co+aP.y-1==aq then self:setValue(aP)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()for aO,aP in pairs(cs)do if aP==self:getValue()then if cw=="left"then self.parent:writeText(aP.x+cn-1,aP.y+co-1,aD,eD,eE)self.parent:writeText(aP.x+2+cn-1,aP.y+co-1,aP.text,ct,cu)end else self.parent:drawBackgroundBox(aP.x+cn-1,aP.y+co-1,1,1,self.bgColor)self.parent:writeText(aP.x+2+cn-1,aP.y+co-1,aP.text,aP.bgCol,aP.fgCol)end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eH(bF)local cj=bE(bF)local bG="Scrollbar"cj.width=1;cj.height=8;cj.bgColor=colors.lightGray;cj.fgColor=colors.gray;cj:setValue(1)cj:setZIndex(2)local eI="vertical"local aD=" "local eJ=colors.black;local eK="\127"local eL=cj.height;local aK=1;local eM=1;local bO={getType=function(self)return bG end,setSymbol=function(self,eN)aD=eN:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,u)eM=tonumber(u)or 1;if eI=="vertical"then self:setValue(aK-1*eL/(self.height-(eM-1))-eL/(self.height-(eM-1)))elseif eI=="horizontal"then self:setValue(aK-1*eL/(self.width-(eM-1))-eL/(self.width-(eM-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,cG)eL=cG;return self end,setBackgroundSymbol=function(self,eO)eK=string.sub(eO,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eP)eJ=eP;self:setVisualChanged()return self end,setBarType=function(self,eQ)eI=eQ:lower()return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if(aL=="mouse_click"or aL=="mouse_drag")and c2==1 or aL=="monitor_touch"then if eI=="horizontal"then for eR=0,self.width do if cn+eR==ap and co<=aq and co+self.height>aq then aK=math.min(eR+1,self.width-(eM-1))self:setValue(eL/self.width*aK)self:setVisualChanged()end end end;if eI=="vertical"then for eR=0,self.height do if co+eR==aq and cn<=ap and cn+self.width>ap then aK=math.min(eR+1,self.height-(eM-1))self:setValue(eL/self.height*aK)self:setVisualChanged()end end end end;if aL=="mouse_scroll"then aK=aK+c2;if aK<1 then aK=1 end;aK=math.min(aK,(eI=="vertical"and self.height or self.width)-(eM-1))self:setValue(eL/(eI=="vertical"and self.height or self.width)*aK)end;return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()if eI=="horizontal"then self.parent:writeText(cn,co,eK:rep(aK-1),self.bgColor,self.fgColor)self.parent:writeText(cn+aK-1,co,aD:rep(eM),eJ,eJ)self.parent:writeText(cn+aK+eM-1,co,eK:rep(self.width-(aK+eM-1)),self.bgColor,self.fgColor)end;if eI=="vertical"then for ag=0,self.height-1 do if aK==ag+1 then for eS=0,math.min(eM-1,self.height)do self.parent:writeText(cn,co+ag+eS,aD,eJ,eJ)end else if ag+1aK-1+eM then self.parent:writeText(cn,co+ag,eK,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eT(bF)local cj=bE(bF)local bG="Slider"cj.width=8;cj.height=1;cj.bgColor=colors.lightGray;cj.fgColor=colors.gray;cj:setValue(1)local eI="horizontal"local aD=" "local eJ=colors.black;local eK="\140"local eL=cj.width;local aK=1;local eM=1;local bO={getType=function(self)return bG end,setSymbol=function(self,eN)aD=eN:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,u)eM=tonumber(u)or 1;if eI=="vertical"then self:setValue(aK-1*eL/(self.height-(eM-1))-eL/(self.height-(eM-1)))elseif eI=="horizontal"then self:setValue(aK-1*eL/(self.width-(eM-1))-eL/(self.width-(eM-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,cG)eL=cG;return self end,setBackgroundSymbol=function(self,eO)eK=string.sub(eO,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eP)eJ=eP;self:setVisualChanged()return self end,setBarType=function(self,eQ)eI=eQ:lower()return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if(aL=="mouse_click"or aL=="mouse_drag")and c2==1 or aL=="monitor_touch"then if eI=="horizontal"then for eR=0,self.width do if cn+eR==ap and co<=aq and co+self.height>aq then aK=math.min(eR+1,self.width-(eM-1))self:setValue(eL/self.width*aK)self:setVisualChanged()end end end;if eI=="vertical"then for eR=0,self.height do if co+eR==aq and cn<=ap and cn+self.width>ap then aK=math.min(eR+1,self.height-(eM-1))self:setValue(eL/self.height*aK)self:setVisualChanged()end end end end;if aL=="mouse_scroll"then aK=aK+c2;if aK<1 then aK=1 end;aK=math.min(aK,(eI=="vertical"and self.height or self.width)-(eM-1))self:setValue(eL/(eI=="vertical"and self.height or self.width)*aK)end;return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()if eI=="horizontal"then self.parent:writeText(cn,co,eK:rep(aK-1),self.bgColor,self.fgColor)self.parent:writeText(cn+aK-1,co,aD:rep(eM),eJ,eJ)self.parent:writeText(cn+aK+eM-1,co,eK:rep(self.width-(aK+eM-1)),self.bgColor,self.fgColor)end;if eI=="vertical"then for ag=0,self.height-1 do if aK==ag+1 then for eS=0,math.min(eM-1,self.height)do self.parent:writeText(cn,co+ag+eS,aD,eJ,eJ)end else if ag+1aK-1+eM then self.parent:writeText(cn,co+ag,eK,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eU(bF)local cj=bE(bF)local bG="Switch"cj.width=2;cj.height=1;cj.bgColor=colors.lightGray;cj.fgColor=colors.gray;cj:setValue(false)cj:setZIndex(5)local eK=colors.black;local eV=colors.red;local eW=colors.green;local bO={getType=function(self)return bG end,setSymbolColor=function(self,eJ)eK=eJ;self:setVisualChanged()return self end,setActiveBackground=function(self,ei)eW=ei;self:setVisualChanged()return self end,setInactiveBackground=function(self,ei)eV=ei;self:setVisualChanged()return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then self:setValue(not self:getValue())end;return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)if self:getValue()then self.parent:drawBackgroundBox(cn,co,1,self.height,eW)self.parent:drawBackgroundBox(cn+1,co,1,self.height,eK)else self.parent:drawBackgroundBox(cn,co,1,self.height,eK)self.parent:drawBackgroundBox(cn+1,co,1,self.height,eV)end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eX(bF)local cj=bE(bF)local bG="Textfield"local eY,cT,cS,eZ=1,1,1,1;local e_={""}local f0={[colors.purple]={"break"}}cj.width=20;cj.height=8;cj.bgColor=h.textfieldBG;cj.fgColor=h.textfieldFG;cj:setZIndex(5)local bO={getType=function(self)return bG end,getLines=function(self)return e_ end,getLine=function(self,aK)return e_[aK]or""end,editLine=function(self,aK,ar)e_[aK]=ar or e_[aK]return self end,addLine=function(self,ar,aK)if aK~=nil then table.insert(e_,aK,ar)else table.insert(e_,ar)end;return self end,addKeyword=function(self,f1,bW)end,removeLine=function(self,aK)table.remove(e_,aK or#e_)if#e_<=0 then table.insert(e_,"")end;return self end,getTextCursor=function(self)return cS,eZ end,getFocusHandler=function(self)cj.getFocusHandler(self)if self.parent~=nil then local cn,co=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,cn+cS-cT,co+eZ-eY,self.fgColor)end end end,loseFocusHandler=function(self)cj.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,aL,bp)if cj.keyHandler(self,aL,bp)then local cn,co=self:getAnchorPosition()if aL=="key"then if bp==keys.backspace then if e_[eZ]==""then if eZ>1 then table.remove(e_,eZ)cS=e_[eZ-1]:len()+1;cT=cS-self.width+1;if cT<1 then cT=1 end;eZ=eZ-1 end elseif cS<=1 then if eZ>1 then cS=e_[eZ-1]:len()+1;cT=cS-self.width+1;if cT<1 then cT=1 end;e_[eZ-1]=e_[eZ-1]..e_[eZ]table.remove(e_,eZ)eZ=eZ-1 end else e_[eZ]=e_[eZ]:sub(1,cS-2)..e_[eZ]:sub(cS,e_[eZ]:len())if cS>1 then cS=cS-1 end;if cT>1 then if cSe_[eZ]:len()then if e_[eZ+1]~=nil then e_[eZ]=e_[eZ]..e_[eZ+1]table.remove(e_,eZ+1)end else e_[eZ]=e_[eZ]:sub(1,cS-1)..e_[eZ]:sub(cS+1,e_[eZ]:len())end end;if bp==keys.enter then table.insert(e_,eZ+1,e_[eZ]:sub(cS,e_[eZ]:len()))e_[eZ]=e_[eZ]:sub(1,cS-1)eZ=eZ+1;cS=1;cT=1;if eZ-eY>=self.height then eY=eY+1 end;self:setValue("")end;if bp==keys.up then if eZ>1 then eZ=eZ-1;if cS>e_[eZ]:len()+1 then cS=e_[eZ]:len()+1 end;if cT>1 then if cS1 then if eZe_[eZ]:len()+1 then cS=e_[eZ]:len()+1 end;if eZ>=eY+self.height then eY=eY+1 end end end;if bp==keys.right then cS=cS+1;if eZ<#e_ then if cS>e_[eZ]:len()+1 then cS=1;eZ=eZ+1 end elseif cS>e_[eZ]:len()then cS=e_[eZ]:len()+1 end;if cS<1 then cS=1 end;if cS=self.width+cT then cT=cS-self.width+1 end;if cT<1 then cT=1 end end;if bp==keys.left then cS=cS-1;if cS>=1 then if cS=self.width+cT then cT=cS end end;if eZ>1 then if cS<1 then eZ=eZ-1;cS=e_[eZ]:len()+1;cT=cS-self.width+1 end end;if cS<1 then cS=1 end;if cT<1 then cT=1 end end end;if aL=="char"then e_[eZ]=e_[eZ]:sub(1,cS-1)..bp..e_[eZ]:sub(cS,e_[eZ]:len())cS=cS+1;if cS>=self.width+cT then cT=cT+1 end;self:setValue("")end;local d4=(cS<=e_[eZ]:len()and cS-1 or e_[eZ]:len())-(cT-1)if d4>self.x+self.width-1 then d4=self.x+self.width-1 end;local f2=eZ-eYe_[eZ]:len()then cS=e_[eZ]:len()+1 end;if cSe_[eZ]:len()then cS=e_[eZ]:len()+1 end;if cS#e_-(self.height-1)then eY=#e_-(self.height-1)end;if eY<1 then eY=1 end;if self.parent~=nil then if cn+cS-cT>=cn and cn+cS-cT<=cn+self.width and(co+eZ-eY>=co and co+eZ-eY<=co+self.height)then self.parent:setCursor(true,f3+cS-cT,f4+eZ-eY)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)for ag=1,self.height do local ar=""if e_[ag+eY-1]~=nil then ar=e_[ag+eY-1]end;ar=ar:sub(cT,self.width+cT-1)local d5=self.width-ar:len()if d5<0 then d5=0 end;ar=ar..string.rep(" ",d5)self.parent:setText(cn,co+ag-1,ar)end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function f5(bF)local bO;local bG="Thread"local aN;local f6;local f7=false;bO={name=bF,getType=function(self)return bG end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,x)if x==nil then error("Function provided to thread is nil")end;aN=x;f6=coroutine.create(aN)f7=true;local aX,aY=coroutine.resume(f6)if not aX then if aY~="Terminated"then error("Thread Error Occurred - "..aY)end end;return self end,getStatus=function(self,x)if f6~=nil then return coroutine.status(f6)end;return nil end,stop=function(self,x)f7=false;return self end,eventHandler=function(self,aL,c5,c6,c7)if f7 then if coroutine.status(f6)~="dead"then local aX,aY=coroutine.resume(f6,aL,c5,c6,c7)if not aX then if aY~="Terminated"then error("Thread Error Occurred - "..aY)end end else f7=false end end end}bO.__index=bO;return bO end;local function f8(bF)local bG="Timer"local f9=0;local fa=0;local fb=0;local ca;local bN=aI()local fc=false;local bO={name=bF,getType=function(self)return bG end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,fd,fe)f9=fd or 0;fa=fe or 1;return self end,start=function(self)if fc then os.cancelTimer(ca)end;fb=fa;ca=os.startTimer(f9)fc=true;return self end,isActive=function(self)return fc end,cancel=function(self)if ca~=nil then os.cancelTimer(ca)end;fc=false;return self end,onCall=function(self,aN)bN:registerEvent("timed_event",aN)return self end,eventHandler=function(self,aL,ch)if aL=="timer"and ch==ca and fc then bN:sendEvent("timed_event",self)if fb>=1 then fb=fb-1;if fb>=1 then ca=os.startTimer(f9)end elseif fb==-1 then ca=os.startTimer(f9)end end end}bO.__index=bO;return bO end;local function ff(bF,fg)local cj=bE(bF)local bG="Frame"local fh={}local fi={}local bO={}local fj;local fk=e;local fl={}local fm=false;cj:setZIndex(10)local aA=a3(fk)local dz=false;local dw=1;local dx=1;local fn=colors.white;local fo,cx=0,0;if fg~=nil then cj.parent=fg;cj.width,cj.height=fg:getSize()cj.bgColor=h.FrameBG;cj.fgColor=h.FrameFG else cj.width,cj.height=fk.getSize()cj.bgColor=h.basaltBG;cj.fgColor=h.basaltFG end;local function fp(bF)for aO,aP in pairs(fh)do for aO,br in pairs(aP)do if br.name==bF then return aP end end end end;local function fq(fr)local bH=fr:getZIndex()if fp(fr.name)~=nil then return nil end;if fh[bH]==nil then for ap=1,#fi+1 do if fi[ap]~=nil then if bH==fi[ap]then break end;if bH>fi[ap]then table.insert(fi,ap,bH)break end else table.insert(fi,bH)end end;if#fi<=0 then table.insert(fi,bH)end;fh[bH]={}end;fr.parent=bO;table.insert(fh[bH],fr)return fr end;local function fs(fr)for bq,br in pairs(fh)do for bp,aP in pairs(br)do if aP==fr then table.remove(fh[bq],bp)return true end end end;return false end;bO={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return bG end,setFocusedObject=function(self,fr)for aO,aK in pairs(fi)do for aO,aP in pairs(fh[aK])do if aP==fr then if fj~=nil then fj:loseFocusHandler()end;fj=fr;fj:getFocusHandler()end end end;return self end,setOffset=function(self,b_,c0)fo=b_~=nil and math.floor(b_<0 and math.abs(b_)or-b_)or fo;cx=c0~=nil and math.floor(c0<0 and math.abs(c0)or-c0)or cx;return self end,getFrameOffset=function(self)return fo,cx end,removeFocusedObject=function(self)if fj~=nil then fj:loseFocusHandler()end;fj=nil;return self end,getFocusedObject=function(self)return fj end,show=function(self)cj:show()if self.parent==nil and not fm then b=self end;return self end,setCursor=function(self,ft,fu,fv,bW)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())dz=ft or false;if fu~=nil then dw=cn+fu-1 end;if fv~=nil then dx=co+fv-1 end;fn=bW or fn;self:setVisualChanged()return self end,setMoveable=function(self,fw)self.isMoveable=fw or not self.isMoveable;self:setVisualChanged()return self end,addMonitor=function(self,fx)local fy=peripheral.wrap(fx)fl[fx]={monitor=fx,frame=a.createFrame(self:getName().."_monitor_"..fx)}fl[fx].frame:setDisplay(fy):setFrameAsMonitor()fl[fx].frame:setSize(fy:getSize())return fl[fx].frame end,setMonitorScale=function(self,fz,fA)if fm then fk.setTextScale(fz*0.5)if fA then self:setSize(fk:getSize())end end;return self,fm end,setFrameAsMonitor=function(self,fB)fm=fB;if fB==nil then fm=true end;return self end,showBar=function(self,fC)self.barActive=fC or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,ar,aB,aC)self.barText=ar or""self.barBackground=aB or self.barBackground;self.barTextcolor=aC or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,cw)self.barTextAlign=cw or"left"self:setVisualChanged()return self end,setDisplay=function(self,a4)fk=a4;aA=a3(fk)return self end,getDisplay=function(self)return fk end,getVisualChanged=function(self)local fD=cj.getVisualChanged(self)for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.getVisualChanged~=nil and aP:getVisualChanged()then fD=true end end end end;return fD end,loseFocusHandler=function(self)cj.loseFocusHandler(self)end,getFocusHandler=function(self)cj.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,aL,bp)if fj~=nil then if fj.keyHandler~=nil then if fj:keyHandler(aL,bp)then return true end end end;return false end,backgroundKeyHandler=function(self,aL,bp)cj.backgroundKeyHandler(self,aL,bp)for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.backgroundKeyHandler~=nil then aP:backgroundKeyHandler(aL,bp)end end end end end,eventHandler=function(self,aL,c5,c6,c7,c8)cj.eventHandler(self,aL,c5,c6,c7,c8)for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.eventHandler~=nil then aP:eventHandler(aL,c5,c6,c7,c8)end end end end;if aL=="terminate"then fk.clear()fk.setCursorPos(1,1)a.stop()end end,mouseClickHandler=function(self,aL,c2,ap,aq)local b_,c0=self:getOffset()b_=b_<0 and math.abs(b_)or-b_;c0=c0<0 and math.abs(c0)or-c0;if self.drag then if aL=="mouse_drag"then local fE=1;local fF=1;if self.parent~=nil then fE,fF=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(ap+self.xToRem-(fE-1)+b_,aq-(fF-1)+c0)end;if aL=="mouse_up"then self.drag=false end;return true end;if cj.mouseClickHandler(self,aL,c2,ap,aq)then local bX,bY=self:getAbsolutePosition(self:getAnchorPosition())if aL~="monitor_touch"or fm then for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in b4(fh[aK])do if aP.mouseClickHandler~=nil then if aP:mouseClickHandler(aL,c2,ap+b_,aq+c0)then return true end end end end end elseif not fm then for aO,dr in pairs(fl)do if c2==dr.monitor then dr.frame:mouseClickHandler(aL,c2,ap,aq)end end end;if self.isMoveable then if ap>=bX and ap<=bX+self.width-1 and aq==bY and aL=="mouse_click"then self.drag=true;self.xToRem=bX-ap end end;if fj~=nil then fj:loseFocusHandler()fj=nil end;return true end;return false end,setText=function(self,ap,aq,ar)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:setText(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(ar,math.max(1-ap+1,1),self.width-ap+1))else aA.setText(math.max(ap+cn-1,cn),co+aq-1,f(ar,math.max(1-ap+1,1),self.width-ap+1))end end end,setBG=function(self,ap,aq,aB)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:setBG(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(aB,math.max(1-ap+1,1),self.width-ap+1))else aA.setBG(math.max(ap+cn-1,cn),co+aq-1,f(aB,math.max(1-ap+1,1),self.width-ap+1))end end end,setFG=function(self,ap,aq,aC)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:setFG(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(aC,math.max(1-ap+1,1),self.width-ap+1))else aA.setFG(math.max(ap+cn-1,cn),co+aq-1,f(aC,math.max(1-ap+1,1),self.width-ap+1))end end end,writeText=function(self,ap,aq,ar,aB,aC)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:writeText(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(ar,math.max(1-ap+1,1),self.width-ap+1),aB,aC)else aA.writeText(math.max(ap+cn-1,cn),co+aq-1,f(ar,math.max(1-ap+1,1),self.width-ap+1),aB,aC)end end end,drawBackgroundBox=function(self,ap,aq,a6,m,aB)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())m=aq<1 and(m+aq>self.height and self.height or m+aq-1)or(m+aq>self.height and self.height-aq+1 or m)a6=ap<1 and(a6+ap>self.width and self.width or a6+ap-1)or(a6+ap>self.width and self.width-ap+1 or a6)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(ap+cn-1,cn)-(self.parent.x-1),math.max(aq+co-1,co)-(self.parent.y-1),a6,m,aB)else aA.drawBackgroundBox(math.max(ap+cn-1,cn),math.max(aq+co-1,co),a6,m,aB)end end,drawTextBox=function(self,ap,aq,a6,m,aD)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())m=aq<1 and(m+aq>self.height and self.height or m+aq-1)or(m+aq>self.height and self.height-aq+1 or m)a6=ap<1 and(a6+ap>self.width and self.width or a6+ap-1)or(a6+ap>self.width and self.width-ap+1 or a6)if self.parent~=nil then self.parent:drawTextBox(math.max(ap+cn-1,cn)-(self.parent.x-1),math.max(aq+co-1,co)-(self.parent.y-1),a6,m,aD:sub(1,1))else aA.drawTextBox(math.max(ap+cn-1,cn),math.max(aq+co-1,co),a6,m,aD:sub(1,1))end end,drawForegroundBox=function(self,ap,aq,a6,m,aC)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())m=aq<1 and(m+aq>self.height and self.height or m+aq-1)or(m+aq>self.height and self.height-aq+1 or m)a6=ap<1 and(a6+ap>self.width and self.width or a6+ap-1)or(a6+ap>self.width and self.width-ap+1 or a6)if self.parent~=nil then self.parent:drawForegroundBox(math.max(ap+cn-1,cn)-(self.parent.x-1),math.max(aq+co-1,co)-(self.parent.y-1),a6,m,aC)else aA.drawForegroundBox(math.max(ap+cn-1,cn),math.max(aq+co-1,co),a6,m,aC)end end,draw=function(self)for aO,dr in pairs(fl)do dr.frame:draw()end;if self:getVisualChanged()then if cj.draw(self)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())local f3,f4=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(f3,f4,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(f3,f4,self.width,self.height,self.fgColor)self.parent:drawTextBox(f3,f4,self.width,self.height," ")else aA.drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)aA.drawForegroundBox(cn,co,self.width,self.height,self.fgColor)aA.drawTextBox(cn,co,self.width,self.height," ")end;fk.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(f3,f4,aZ(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)else aA.writeText(cn,co,aZ(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aO,aK in b4(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.draw~=nil then aP:draw()end end end end;if dz then fk.setTextColor(fn)fk.setCursorPos(dw,dx)if self.parent~=nil then fk.setCursorBlink(self:isFocused())else fk.setCursorBlink(dz)end end;self:setVisualChanged(false)end end end,drawUpdate=function(self)aA.update()for fG,dr in pairs(fl)do dr.frame:drawUpdate()end end,addObject=function(self,fr)return fq(fr)end,removeObject=function(self,fr)return fs(fr)end,getObject=function(self,fr)return fp(fr)end,addButton=function(self,bF)local fr=ci(bF)fr.name=bF;return fq(fr)end,addLabel=function(self,bF)local fr=d6(bF)fr.bgColor=self.bgColor;fr.fgColor=self.fgColor;return fq(fr)end,addCheckbox=function(self,bF)local fr=cq(bF)return fq(fr)end,addInput=function(self,bF)local fr=cP(bF)return fq(fr)end,addProgram=function(self,bF)local fr=du(bF)return fq(fr)end,addTextfield=function(self,bF)local fr=eX(bF)return fq(fr)end,addList=function(self,bF)local fr=dg(bF)fr.name=nam;return fq(fr)end,addDropdown=function(self,bF)local fr=cr(bF)return fq(fr)end,addRadio=function(self,bF)local fr=eC(bF)return fq(fr)end,addTimer=function(self,bF)local fr=f8(bF)return fq(fr)end,addAnimation=function(self,bF)local fr=c9(bF)return fq(fr)end,addSlider=function(self,bF)local fr=eT(bF)return fq(fr)end,addScrollbar=function(self,bF)local fr=eH(bF)return fq(fr)end,addMenubar=function(self,bF)local fr=dj(bF)return fq(fr)end,addThread=function(self,bF)local fr=f5(bF)return fq(fr)end,addPane=function(self,bF)local fr=dt(bF)return fq(fr)end,addImage=function(self,bF)local fr=cH(bF)return fq(fr)end,addProgressbar=function(self,bF)local fr=et(bF)return fq(fr)end,addSwitch=function(self,bF)local fr=eU(bF)return fq(fr)end,addFrame=function(self,bF)local fr=ff(bF,self)return fq(fr)end}setmetatable(bO,cj)if fg==nil then table.insert(c,bO)end;return bO end;local fH=false;local function fI(aL,c5,c6,c7,c8)if aL=="mouse_click"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="mouse_drag"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="mouse_up"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="mouse_scroll"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="monitor_touch"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="key"or aL=="char"then b:keyHandler(aL,c5)b:backgroundKeyHandler(aL,c5)end;if aL=="key"then d[c5]=true end;if aL=="key_up"then d[c5]=false end;for aO,aP in pairs(c)do aP:eventHandler(aL,c5,c6,c7,c8)end;if fH then b:draw()b:drawUpdate()end end;function a.autoUpdate(f7)e.clear()fH=f7 or true;b:draw()b:drawUpdate()while fH do local aL,c5,c6,c7,c8=os.pullEventRaw()fI(aL,c5,c6,c7,c8)end end;function a.update(aL,c5,c6,c7,c8)if aL~=nil then fI(aL,c5,c6,c7,c8)else b:draw()b:drawUpdate()end end;function a.stop()fH=false end;function a.isKeyDown(bp)if d[bp]==nil then return false end;return d[bp]end;function a.getFrame(bF)for aO,aP in pairs(c)do if aP.name==bF then return aP end end end;function a.getActiveFrame()return b end;function a.setActiveFrame(bP)if bP:getType()=="Frame"then b=bP;return true end;return false end;function a.createFrame(bF)return ff(bF)end;function a.removeFrame(bF)for bp,aP in pairs(c)do if aP.name==bF then c[bp]=nil;return true end end;return false end;if a.debugger then a.debugFrame=a.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)a.debugList=a.debugFrame:addList("debugList"):setSize(a.debugFrame.width-2,a.debugFrame.height-3):setPosition(2,3):setScrollable(true):show()a.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()a.oldFrame:show()end):setBackground(colors.red):show()a.debugLabel=a.debugFrame:addLabel("debugLabel"):onClick(function()a.oldFrame=b;a.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if a.debugger then function a.debug(...)local aV={...}if b.name~="basaltDebuggingFrame"then if b~=a.debugLabel.frame then a.debugLabel:setParent(b)end end;local fJ=""for bp,aP in pairs(aV)do fJ=fJ..tostring(aP)..(#aV~=bp and", "or"")end;a.debugLabel:setText("[Debug] "..fJ)a.debugList:addItem(fJ)if a.debugList:getItemCount()>50 then a.debugList:removeItem(1)end;a.debugList:setValue(a.debugList:getItem(a.debugList:getItemCount()))if a.debugList.getItemCount()>a.debugList:getHeight()then a.debugList:setIndexOffset(a.debugList:getItemCount()-a.debugList:getHeight())end;a.debugLabel:show()end end;return a \ No newline at end of file +local a={debugger=true,version=1}local b={}local c;local d={}local e;local f;local g={}local h=term.current()local i=string.sub;local j={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local k={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local l={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{[[000110000110110000110010101000000010000000100101]],[[000000110110000000000010101000000010000000100101]],[[000000000000000000000000000000000000000000000000]],[[100010110100000010000110110000010100000100000110]],[[000000110000000010110110000110000000000000110000]],[[000000000000000000000000000000000000000000000000]],[[000000110110000010000000100000100000000000000010]],[[000000000110110100010000000010000000000000000100]],[[000000000000000000000000000000000000000000000000]],[[010000000000100110000000000000000000000110010000]],[[000000000000000000000000000010000000010110000000]],[[000000000000000000000000000000000000000000000000]],[[011110110000000100100010110000000100000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110000110110000000000000000000010100100010000000]],[[000010000000000000110110000000000100010010000000]],[[000000000000000000000000000000000000000000000000]],[[010110010110100110110110010000000100000110110110]],[[000000000000000000000110000000000110000000000000]],[[000000000000000000000000000000000000000000000000]],[[010100010110110000000000000000110000000010000000]],[[110110000000000000110000110110100000000010000000]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[100100100100100100100100100100100100100100100100]],[[000000110100110110000010000011110000000000011000]],[[000000000100000000000010000011000110000000001000]],[[000000000000000000000000000000000000000000000000]],[[010000100100000000000000000100000000010010110000]],[[000000000000000000000000000000110110110110110000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110000000110110110110110110110110]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000110110000110010000000000000000010010]],[[000010000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110110110110000000000000]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110000000000000000010000]],[[000000000000000000000000100000000000000110000110]],[[000000000000000000000000000000000000000000000000]]}}local m={}local n={}do local o=0;local p=#l[1]local q=#l[1][1]for r=1,p,3 do for s=1,q,3 do local t=string.char(o)local u={}u[1]=l[1][r]:sub(s,s+2)u[2]=l[1][r+1]:sub(s,s+2)u[3]=l[1][r+2]:sub(s,s+2)local v={}v[1]=l[2][r]:sub(s,s+2)v[2]=l[2][r+1]:sub(s,s+2)v[3]=l[2][r+2]:sub(s,s+2)n[t]={u,v}o=o+1 end end;m[1]=n end;local function w(x,y)local z={["0"]="1",["1"]="0"}if x<=#m then return true end;for A=#m+1,x do local B={}local C=m[A-1]for o=0,255 do local t=string.char(o)local u={}local v={}local D=C[t][1]local E=C[t][2]for r=1,#D do local F,G,H,I,J,K={},{},{},{},{},{}for s=1,#D[1]do local L=n[D[r]:sub(s,s)][1]table.insert(F,L[1])table.insert(G,L[2])table.insert(H,L[3])local M=n[D[r]:sub(s,s)][2]if E[r]:sub(s,s)=="1"then table.insert(I,M[1]:gsub("[01]",z))table.insert(J,M[2]:gsub("[01]",z))table.insert(K,M[3]:gsub("[01]",z))else table.insert(I,M[1])table.insert(J,M[2])table.insert(K,M[3])end end;table.insert(u,table.concat(F))table.insert(u,table.concat(G))table.insert(u,table.concat(H))table.insert(v,table.concat(I))table.insert(v,table.concat(J))table.insert(v,table.concat(K))end;B[t]={u,v}if y then y="Font"..A.."Yeld"..o;os.queueEvent(y)os.pullEvent(y)end end;m[A]=B end;return true end;local function N(O,P,Q,R,S)if not type(P)=="string"then error("Not a String",3)end;local T=type(Q)=="string"and Q:sub(1,1)or j[Q]or error("Wrong Front Color",3)local U=type(R)=="string"and R:sub(1,1)or j[R]or error("Wrong Back Color",3)if m[O]==nil then w(3,false)end;local V=m[O]or error("Wrong font size selected",3)if P==""then return{{""},{""},{""}}end;local W={}for r in P:gmatch('.')do table.insert(W,r)end;local X={}local p=#V[W[1]][1]for Y=1,p do local Z={}for r=1,#W do Z[r]=V[W[r]]and V[W[r]][1][Y]or""end;X[Y]=table.concat(Z)end;local _={}local a0={}local a1={["0"]=T,["1"]=U}local a2={["0"]=U,["1"]=T}for Y=1,p do local a3={}local a4={}for r=1,#W do local a5=V[W[r]]and V[W[r]][2][Y]or""a3[r]=a5:gsub("[01]",S and{["0"]=Q:sub(r,r),["1"]=R:sub(r,r)}or a1)a4[r]=a5:gsub("[01]",S and{["0"]=R:sub(r,r),["1"]=Q:sub(r,r)}or a2)end;_[Y]=table.concat(a3)a0[Y]=table.concat(a4)end;return{X,_,a0}end;local function a6(a7)local a8=a7;local a9,p=a8.getSize()local aa={}local ab={}local ac={}local ad={}local ae={}local af={}local ag;local ah={}local function ai()ag=(" "):rep(a9)for aj=0,15 do local ak=2^aj;local al=j[ak]ah[ak]=al:rep(a9)end end;ai()local function am()local an=ag;local ao=ah[colors.white]local ap=ah[colors.black]for aq=1,p do aa[aq]=i(aa[aq]==nil and an or aa[aq]..an:sub(1,a9-aa[aq]:len()),1,a9)ac[aq]=i(ac[aq]==nil and ao or ac[aq]..ao:sub(1,a9-ac[aq]:len()),1,a9)ab[aq]=i(ab[aq]==nil and ap or ab[aq]..ap:sub(1,a9-ab[aq]:len()),1,a9)end end;am()local function ar(as,at,au)if at>=1 and at<=p then if as+au:len()>0 and as<=a9 then local av=aa[at]local aw;local ax=as+#au-1;if as<1 then local ay=1-as+1;local az=a9-as+1;au=i(au,ay,az)elseif ax>a9 then local az=a9-as+1;au=i(au,1,az)end;if as>1 then local az=as-1;aw=i(av,1,az)..au else aw=au end;if ax=1 and at<=p then if as+aB:len()>0 and as<=a9 then local av=ab[at]local aw;local ax=as+#aB-1;if as<1 then aB=i(aB,1-as+1,a9-as+1)elseif ax>a9 then aB=i(aB,1,a9-as+1)end;if as>1 then aw=i(av,1,as-1)..aB else aw=aB end;if ax=1 and at<=p then if as+aB:len()>0 and as<=a9 then local av=ac[at]local aw;local ax=as+#aB-1;if as<1 then local ay=1-as+1;local az=a9-as+1;aB=i(aB,ay,az)elseif ax>a9 then local az=a9-as+1;aB=i(aB,1,az)end;if as>1 then local az=as-1;aw=i(av,1,az)..aB else aw=aB end;if ax1 then while#bj>2 do table.sort(bj,function(bt,bu)return bt[2]>bu[2]end)local bv,bw=bi(bj),#bj;local bx,by=bj[bw][1],bj[bv][1]for r=1,6 do if bn[r]==bx then bn[r]=by;bj[bv][2]=bj[bv][2]+1 end end;bj[bw]=nil end;local bz=128;for r=1,#bn-1 do if bn[r]~=bn[6]then bz=bz+2^(r-1)end end;return string.char(bz),bf[bj[1][1]==bn[6]and bj[2][1]or bj[1][1]],bf[bn[6]]else return"\128",bf[bn[1]],bf[bn[1]]end end;local bA,a9,p,aE={{},{},{}},0,#ba+#ba%3,bb or colors.black;for r=1,#ba do if#ba[r]>a9 then a9=#ba[r]end end;for at=0,p-1,3 do local bB,bC,bD,bE={},{},{},1;for as=0,a9-1,2 do local bn,bo={},{}for bF=1,3 do for bG=1,2 do bn[#bn+1]=ba[at+bF]and ba[at+bF][as+bG]and(ba[at+bF][as+bG]==0 and aE or ba[at+bF][as+bG])or aE;bo[bn[#bn]]=bo[bn[#bn]]and bo[bn[#bn]]+1 or 1 end end;bB[bE],bC[bE],bD[bE]=bm(bn,bo)bE=bE+1 end;bA[1][#bA[1]+1],bA[2][#bA[2]+1],bA[3][#bA[3]+1]=table.concat(bB),table.concat(bC),table.concat(bD)end;bA.width,bA.height=#bA[1][1],#bA[1]return bA end;local function bH(bI)local bJ="Object"local aS;local bK=1;local bL="left"local bM="top"local bN=false;local bO=false;local bP=true;local bQ=aL()local bR={x=1,y=1,width=1,height=1,bgColor=colors.black,fgColor=colors.white,name=bI or"Object",parent=nil,show=function(self)bO=true;bP=true;return self end,hide=function(self)bO=false;bP=true;return self end,isVisible=function(self)return bO end,setFocus=function(self)if self.parent~=nil then self.parent:setFocusedObject(self)end;return self end,setZIndex=function(self,aN)bK=aN;if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end;return self end,getZIndex=function(self)return bK end,getType=function(self)return bJ end,getName=function(self)return self.name end,remove=function(self)if self.parent~=nil then self.parent:removeObject(self)end;return self end,setParent=function(self,bS)if bS.getType~=nil and bS:getType()=="Frame"then self:remove()bS:addObject(self)if self.draw then self:show()end end;return self end,setValue=function(self,bT)if aS~=bT then aS=bT;bP=true;self:valueChangedHandler()end;return self end,getValue=function(self)return aS end,getVisualChanged=function(self)return bP end,setVisualChanged=function(self,bU)bP=bU or true;if bU==nil then bP=true end;return self end,getEventSystem=function(self)return bQ end,getParent=function(self)return self.parent end,setPosition=function(self,bV,bW,bX)if bX then self.x,self.y=math.floor(self.x+bV),math.floor(self.y+bW)else self.x,self.y=math.floor(bV),math.floor(bW)end;bP=true;return self end,getPosition=function(self)return self.x,self.y end,getVisibility=function(self)return bO end,setVisibility=function(self,bY)bO=bY or not bO;bP=true;return self end,setSize=function(self,a9,p)self.width,self.height=a9,p;bP=true;return self end,getHeight=function(self)return self.height end,getWidth=function(self)return self.width end,getSize=function(self)return self.width,self.height end,setBackground=function(self,bZ)self.bgColor=bZ;bP=true;return self end,getBackground=function(self)return self.bgColor end,setForeground=function(self,bZ)self.fgColor=bZ;bP=true;return self end,getForeground=function(self)return self.fgColor end,draw=function(self)if bO then return true end;return false end,getAbsolutePosition=function(self,as,at)if as==nil or at==nil then as,at=self:getAnchorPosition()end;if self.parent~=nil then local b_,c0=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())as=b_+as-1;at=c0+at-1 end;return as,at end,getAnchorPosition=function(self,as,at,c1)if as==nil then as=self.x end;if at==nil then at=self.y end;if bL=="right"then as=self.parent.width-as-self.width+2 end;if bM=="bottom"then at=self.parent.height-at-self.height+2 end;local c2,c3=self:getOffset()if not(bN or c1)then return as+c2,at+c3 end;return as,at end,getOffset=function(self)if self.parent~=nil then return self.parent:getFrameOffset()end;return 0,0 end,ignoreOffset=function(self,c4)bN=c4;if c4==nil then bN=true end;return self end,getBaseFrame=function(self)if self.parent~=nil then return self.parent:getBaseFrame()end;return self end,setAnchor=function(self,...)for aR,aS in pairs(table.pack(...))do if aS=="right"or aS=="left"then bL=aS end;if aS=="top"or aS=="bottom"then bM=aS end end;bP=true;return self end,getAnchor=function(self)return bL,bM end,onChange=function(self,aQ)self:registerEvent("value_changed",aQ)return self end,onClick=function(self,aQ)self:registerEvent("mouse_click",aQ)self:registerEvent("monitor_touch",aQ)return self end,onClickUp=function(self,aQ)self:registerEvent("mouse_up",aQ)return self end,onScroll=function(self,aQ)self:registerEvent("mouse_scroll",aQ)return self end,onDrag=function(self,aQ)self:registerEvent("mouse_drag",aQ)return self end,onEvent=function(self,aQ)self:registerEvent("custom_event_handler",aQ)return self end,onKey=function(self,aQ)self:registerEvent("key",aQ)self:registerEvent("char",aQ)return self end,onKeyUp=function(self,aQ)self:registerEvent("key_up",aQ)return self end,onBackgroundKey=function(self,aQ)self:registerEvent("background_key",aQ)self:registerEvent("background_char",aQ)return self end,onBackgroundKeyUp=function(self,aQ)self:registerEvent("background_key_up",aQ)return self end,isFocused=function(self)if self.parent~=nil then return self.parent:getFocusedObject()==self end;return false end,onGetFocus=function(self,aQ)self:registerEvent("get_focus",aQ)return self end,onLoseFocus=function(self,aQ)self:registerEvent("lose_focus",aQ)return self end,registerEvent=function(self,aO,aQ)return bQ:registerEvent(aO,aQ)end,removeEvent=function(self,aO,aN)return bQ:removeEvent(aO,aN)end,sendEvent=function(self,aO,...)return bQ:sendEvent(aO,self,...)end,mouseHandler=function(self,aO,c5,as,at)local c6,c7=self:getAbsolutePosition(self:getAnchorPosition())if c6<=as and c6+self.width>as and c7<=at and c7+self.height>at and bO then if self.parent~=nil then self.parent:setFocusedObject(self)end;bQ:sendEvent(aO,self,aO,c5,as,at)return true end;return false end,keyHandler=function(self,aO,bs)if self:isFocused()then bQ:sendEvent(aO,self,aO,bs)return true end;return false end,backgroundKeyHandler=function(self,aO,bs)bQ:sendEvent("background_"..aO,self,aO,bs)end,valueChangedHandler=function(self)bQ:sendEvent("value_changed",self)end,eventHandler=function(self,aO,c8,c9,ca,cb)bQ:sendEvent("custom_event_handler",self,aO,c8,c9,ca,cb)end,getFocusHandler=function(self)bQ:sendEvent("get_focus",self)end,loseFocusHandler=function(self)bQ:sendEvent("lose_focus",self)end}bR.__index=bR;return bR end;local function cc(bI)local bR={}local bJ="Animation"local cd;local ce={}local aN=1;local cf=0;local cg;local function ch()if ce[aN]~=nil then ce[aN].f(bR,aN)end;aN=aN+1;if ce[aN]~=nil then if ce[aN].t>0 then cd=os.startTimer(ce[aN].t)else ch()end end end;bR={name=bI,getType=function(self)return bJ end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,aQ,ci)cg=aQ;table.insert(ce,{f=aQ,t=ci or cf})return self end,wait=function(self,ci)cf=ci;return self end,rep=function(self,cj)for as=1,cj do table.insert(ce,{f=cg,t=cf})end;return self end,clear=function(self)ce={}cg=nil;cf=0;aN=1;return self end,play=function(self)aN=1;if ce[aN]~=nil then if ce[aN].t>0 then cd=os.startTimer(ce[aN].t)else ch()end end;return self end,cancel=function(self)os.cancelTimer(cd)return self end,eventHandler=function(self,aO,ck)if aO=="timer"and ck==cd then if ce[aN]~=nil then ch()end end end}bR.__index=bR;return bR end;local function cl(bI)local cm=bH(bI)local bJ="Button"cm:setValue("Button")cm:setZIndex(5)cm.width=8;cm.bgColor=k.ButtonBG;cm.fgColor=k.ButtonFG;local cn="center"local co="center"local bR={getType=function(self)return bJ end,setHorizontalAlign=function(self,cp)cn=cp end,setVerticalAlign=function(self,cp)co=cp end,setText=function(self,au)cm:setValue(au)return self end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()local cs=b5(self.height,co)self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cq,cr,self.width,self.height,self.fgColor)self.parent:drawTextBox(cq,cr,self.width,self.height," ")for aj=1,self.height do if aj==cs then self.parent:setText(cq,cr+aj-1,b1(self:getValue(),self.width,cn))end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function ct(bI)local cm=bH(bI)local bJ="Checkbox"cm:setZIndex(5)cm:setValue(false)cm.width=1;cm.height=1;cm.bgColor=k.CheckboxBG;cm.fgColor=k.CheckboxFG;local bR={symbol="\42",getType=function(self)return bJ end,mouseHandler=function(self,aO,c5,as,at)if cm.mouseHandler(self,aO,c5,as,at)then if aO=="mouse_click"and c5==1 or aO=="monitor_touch"then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()local cs=b5(self.height,"center")self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)for aj=1,self.height do if aj==cs then if self:getValue()==true then self.parent:writeText(cq,cr+aj-1,b1(self.symbol,self.width,"center"),self.bgColor,self.fgColor)else self.parent:writeText(cq,cr+aj-1,b1(" ",self.width,"center"),self.bgColor,self.fgColor)end end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function cu(bI)local cm=bH(bI)local bJ="Dropdown"cm.width=12;cm.height=1;cm.bgColor=k.dropdownBG;cm.fgColor=k.dropdownFG;cm:setZIndex(6)local cv={}local cw=k.selectionBG;local cx=k.selectionFG;local cy=true;local cz="left"local cA=0;local cB=16;local cC=6;local cD="\16"local cE="\31"local cF=false;local bR={getType=function(self)return bJ end,setIndexOffset=function(self,cG)cA=cG;return self end,getIndexOffset=function(self)return cA end,addItem=function(self,au,aE,aF,...)table.insert(cv,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,getAll=function(self)return cv end,removeItem=function(self,aN)table.remove(cv,aN)return self end,getItem=function(self,aN)return cv[aN]end,getItemIndex=function(self)local cH=self:getValue()for bs,aS in pairs(cv)do if aS==cH then return bs end end end,clear=function(self)cv={}self:setValue({})return self end,getItemCount=function(self)return#cv end,editItem=function(self,aN,au,aE,aF,...)table.remove(cv,aN)table.insert(cv,aN,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cv[aN]or{})return self end,setSelectedItem=function(self,aE,aF,cI)cw=aE or self.bgColor;cx=aF or self.fgColor;cy=cI;return self end,setDropdownSize=function(self,a9,p)cB,cC=a9,p;return self end,mouseHandler=function(self,aO,c5,as,at)if cF then local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if aO=="mouse_click"and c5==1 or aO=="monitor_touch"then if#cv>0 then for aj=1,cC do if cv[aj+cA]~=nil then if cq<=as and cq+cB>as and cr+aj==at then self:setValue(cv[aj+cA])return true end end end end end;if aO=="mouse_scroll"then cA=cA+c5;if cA<0 then cA=0 end;if c5==1 then if#cv>cC then if cA>#cv-cC then cA=#cv-cC end else cA=cv-1 end end;return true end;self:setVisualChanged()end;if cm.mouseHandler(self,aO,c5,as,at)then cF=true else cF=false end end,draw=function(self)if cm.draw(self)then local cq,cr=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)local cJ=self:getValue()local au=b1(cJ~=nil and cJ.text or"",self.width,cz):sub(1,self.width-1)..(cF and cE or cD)self.parent:writeText(cq,cr,au,self.bgColor,self.fgColor)if cF then for aj=1,cC do if cv[aj+cA]~=nil then if cv[aj+cA]==cJ then if cy then self.parent:writeText(cq,cr+aj,b1(cv[aj+cA].text,cB,cz),cw,cx)else self.parent:writeText(cq,cr+aj,b1(cv[aj+cA].text,cB,cz),cv[aj+cA].bgCol,cv[aj+cA].fgCol)end else self.parent:writeText(cq,cr+aj,b1(cv[aj+cA].text,cB,cz),cv[aj+cA].bgCol,cv[aj+cA].fgCol)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function cK(bI)local cm=bH(bI)local bJ="Image"cm:setZIndex(2)local cL;local cM;local cN=false;local function b9()local bc={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local bd,be,bf={},{},{}for r=0,15 do be[2^r]=r end;do local bg="0123456789abcdef"for r=1,16 do bd[bg:sub(r,r)]=r-1;bd[r-1]=bg:sub(r,r)bf[bg:sub(r,r)]=2^(r-1)bf[2^(r-1)]=bg:sub(r,r)local bh=bc[r-1]for r=1,#bh do bh[r]=2^bh[r]end end end;local function bi(bj)local bk=bc[be[bj[#bj][1]]]for s=1,#bk do local bl=bk[s]for r=1,#bj-1 do if bj[r][1]==bl then return r end end end;return 1 end;local function bm(bn,bo)if not bo then local bp={}bo={}for r=1,6 do local bq=bn[r]local br=bo[bq]bo[bq],bp[r]=br and br+1 or 1,bq end;bn=bp end;local bj={}for bs,aS in pairs(bo)do bj[#bj+1]={bs,aS}end;if#bj>1 then while#bj>2 do table.sort(bj,function(bt,bu)return bt[2]>bu[2]end)local bv,bw=bi(bj),#bj;local bx,by=bj[bw][1],bj[bv][1]for r=1,6 do if bn[r]==bx then bn[r]=by;bj[bv][2]=bj[bv][2]+1 end end;bj[bw]=nil end;local bz=128;for r=1,#bn-1 do if bn[r]~=bn[6]then bz=bz+2^(r-1)end end;return string.char(bz),bf[bj[1][1]==bn[6]and bj[2][1]or bj[1][1]],bf[bn[6]]else return"\128",bf[bn[1]],bf[bn[1]]end end;local bA,a9,p,aE={{},{},{}},0,#cL+#cL%3,cm.bgColor or colors.black;for r=1,#cL do if#cL[r]>a9 then a9=#cL[r]end end;for at=0,p-1,3 do local bB,bC,bD,bE={},{},{},1;for as=0,a9-1,2 do local bn,bo={},{}for bF=1,3 do for bG=1,2 do bn[#bn+1]=cL[at+bF]and cL[at+bF][as+bG]and(cL[at+bF][as+bG]==0 and aE or cL[at+bF][as+bG])or aE;bo[bn[#bn]]=bo[bn[#bn]]and bo[bn[#bn]]+1 or 1 end end;bB[bE],bC[bE],bD[bE]=bm(bn,bo)bE=bE+1 end;bA[1][#bA[1]+1],bA[2][#bA[2]+1],bA[3][#bA[3]+1]=table.concat(bB),table.concat(bC),table.concat(bD)end;bA.width,bA.height=#bA[1][1],#bA[1]cM=bA end;local bR={getType=function(self)return bJ end,loadImage=function(self,aW)cL=paintutils.loadImage(aW)cN=false;return self end,loadBlittleImage=function(self,aW)cN=true;return self end,shrink=function(self)b9()cN=true;return self end,draw=function(self)if cm.draw(self)then if self.parent~=nil then if cL~=nil then local cq,cr=self:getAnchorPosition()if cN then local b8,cO,cP=cM[1],cM[2],cM[3]for r=1,cM.height do local cQ=b8[r]if type(cQ)=="string"then self.parent:setText(cq,cr+r-1,cQ)self.parent:setFG(cq,cr+r-1,cO[r])self.parent:setBG(cq,cr+r-1,cP[r])elseif type(cQ)=="table"then self.parent:setText(cq,cr+r-1,cQ[2])self.parent:setFG(cq,cr+r-1,cO[r])self.parent:setBG(cq,cr+r-1,cP[r])end end else for bW=1,math.min(#cL,self.height)do local cR=cL[bW]for bV=1,math.min(#cR,self.width)do if cR[bV]>0 then self.parent:drawBackgroundBox(cq+bV-1,cr+bW-1,1,1,cR[bV])end end end end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function cS(bI)local cm=bH(bI)local bJ="Input"local cT="text"local cU=0;cm:setZIndex(5)cm:setValue("")cm.width=10;cm.height=1;cm.bgColor=k.InputBG;cm.fgColor=k.InputFG;local cV=1;local cW=1;local cX=""local cY;local cZ;local c_=cX;local d0=false;local bR={getType=function(self)return bJ end,setInputType=function(self,d1)if d1=="password"or d1=="number"or d1=="text"then cT=d1 end;return self end,setDefaultText=function(self,au,d2,d3)cX=au;cY=d3 or cY;cZ=d2 or cZ;if self:isFocused()then c_=""else c_=cX end;return self end,getInputType=function(self)return cT end,setValue=function(self,cJ)cm.setValue(self,tostring(cJ))if not d0 then cV=tostring(cJ):len()+1 end;return self end,getValue=function(self)local cJ=cm.getValue(self)return cT=="number"and tonumber(cJ)or cJ end,setInputLimit=function(self,d4)cU=tonumber(d4)or cU;return self end,getInputLimit=function(self)return cU end,getFocusHandler=function(self)cm.getFocusHandler(self)if self.parent~=nil then local cq,cr=self:getAnchorPosition()c_=""if self.parent~=nil then self.parent:setCursor(true,cq+cV-cW,cr,self.fgColor)end end end,loseFocusHandler=function(self)cm.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)c_=cX end end,keyHandler=function(self,aO,bs)if cm.keyHandler(self,aO,bs)then d0=true;if aO=="key"then if bs==keys.backspace then local au=tostring(cm.getValue())if cV>1 then self:setValue(au:sub(1,cV-2)..au:sub(cV,au:len()))if cV>1 then cV=cV-1 end;if cW>1 then if cVd5 then cV=d5+1 end;if cV<1 then cV=1 end;if cV=self.width+cW then cW=cV-self.width+1 end;if cW<1 then cW=1 end end;if bs==keys.left then cV=cV-1;if cV>=1 then if cV=self.width+cW then cW=cV end end;if cV<1 then cV=1 end;if cW<1 then cW=1 end end end;if aO=="char"then local au=cm.getValue()if au:len()=self.width+cW then cW=cW+1 end end end;local cq,cr=self:getAnchorPosition()local cJ=tostring(cm.getValue())local d7=(cV<=cJ:len()and cV-1 or cJ:len())-(cW-1)if d7>self.x+self.width-1 then d7=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,cq+d7,cr,self.fgColor)end;d0=false end end,mouseHandler=function(self,aO,c5,as,at)if cm.mouseHandler(self,aO,c5,as,at)then if aO=="mouse_click"and c5==1 then end;return true end;return false end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()local cs=b5(self.height,"center")self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)for aj=1,self.height do if aj==cs then local cJ=tostring(cm.getValue())local d3=self.bgColor;local d2=self.fgColor;local au;if cJ:len()<=0 then au=c_;d3=cY or d3;d2=cZ or d2 end;au=c_;if cJ~=""then au=cJ end;au=au:sub(cW,self.width+cW-1)local d8=self.width-au:len()if d8<0 then d8=0 end;if cT=="password"and cJ~=""then au=string.rep("*",au:len())end;au=au..string.rep(" ",d8)self.parent:writeText(cq,cr+aj-1,au,d3,d2)end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function d9(bI)local cm=bH(bI)local bJ="Label"cm:setZIndex(3)cm.fgColor=colors.white;cm.bgcolor=colors.black;local da=true;cm:setValue("")local cn="left"local co="top"local db=0;local bR={getType=function(self)return bJ end,setText=function(self,au)au=tostring(au)cm:setValue(au)if da then self.width=au:len()end;return self end,setTextAlign=function(self,dc,dd)cn=dc or cn;co=dd or co;self:setVisualChanged()return self end,setFontSize=function(self,x)if x>0 and x<=4 then db=x-1 or 0 end;return self end,getFontSize=function(self)return db+1 end,setSize=function(self,a9,p)cm.setSize(self,a9,p)da=false;self:setVisualChanged()return self end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()local cs=b5(self.height,co)self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cq,cr,self.width,self.height,self.fgColor)self.parent:drawTextBox(cq,cr,self.width,self.height," ")if db==0 then for aj=1,self.height do if aj==cs then self.parent:writeText(cq,cr+aj-1,b1(self:getValue(),self.width,cn),self.bgColor,self.fgColor)end end else local de=N(db,self:getValue(),self.fgColor,self.bgColor)if da then self.height=#de[1]-1;self.width=#de[1][1]end;for aj=1,self.height do if aj==cs then local df,dg=self.parent:getSize()local dh,di=#de[1][1],#de[1]cq=cq or math.floor((df-dh)/2)+1;cr=cr or math.floor((dg-di)/2)+1;for r=1,di do self.parent:setFG(cq,cr+r+aj-2,b1(de[2][r],self.width,cn))self.parent:setBG(cq,cr+r+aj-2,b1(de[3][r],self.width,cn,j[self.bgColor]))self.parent:setText(cq,cr+r+aj-2,b1(de[1][r],self.width,cn))end end end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function dj(bI)local cm=bH(bI)local bJ="List"cm.width=16;cm.height=6;cm.bgColor=k.listBG;cm.fgColor=k.listFG;cm:setZIndex(5)local cv={}local cw=k.selectionBG;local cx=k.selectionFG;local cy=true;local cz="left"local cA=0;local dk=true;local bR={getType=function(self)return bJ end,addItem=function(self,au,aE,aF,...)table.insert(cv,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})if#cv==1 then self:setValue(cv[1])end;return self end,setIndexOffset=function(self,cG)cA=cG;return self end,getIndexOffset=function(self)return cA end,removeItem=function(self,aN)table.remove(cv,aN)return self end,getItem=function(self,aN)return cv[aN]end,getAll=function(self)return cv end,getItemIndex=function(self)local cH=self:getValue()for bs,aS in pairs(cv)do if aS==cH then return bs end end end,clear=function(self)cv={}self:setValue({})return self end,getItemCount=function(self)return#cv end,editItem=function(self,aN,au,aE,aF,...)table.remove(cv,aN)table.insert(cv,aN,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cv[aN]or{})return self end,setSelectedItem=function(self,aE,aF,cI)cw=aE or self.bgColor;cx=aF or self.fgColor;cy=cI;return self end,setScrollable=function(self,dl)dk=dl;return self end,mouseHandler=function(self,aO,c5,as,at)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if cq<=as and cq+self.width>as and cr<=at and cr+self.height>at and self:isVisible()then if(aO=="mouse_click"or aO=="mouse_drag")and c5==1 or aO=="monitor_touch"then if#cv>0 then for aj=1,self.height do if cv[aj+cA]~=nil then if cq<=as and cq+self.width>as and cr+aj-1==at then self:setValue(cv[aj+cA])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,as,at,cv[aj+cA])end end end end end;if aO=="mouse_scroll"and dk then cA=cA+c5;if cA<0 then cA=0 end;if c5>=1 then if#cv>self.height then if cA>#cv-self.height then cA=#cv-self.height end;if cA>=#cv then cA=#cv-1 end else cA=cA-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)for aj=1,self.height do if cv[aj+cA]~=nil then if cv[aj+cA]==self:getValue()then if cy then self.parent:writeText(cq,cr+aj-1,b1(cv[aj+cA].text,self.width,cz),cw,cx)else self.parent:writeText(cq,cr+aj-1,b1(cv[aj+cA].text,self.width,cz),cv[aj+cA].bgCol,cv[aj+cA].fgCol)end else self.parent:writeText(cq,cr+aj-1,b1(cv[aj+cA].text,self.width,cz),cv[aj+cA].bgCol,cv[aj+cA].fgCol)end end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function dm(bI)local cm=bH(bI)local bJ="Menubar"local bR={}cm.width=30;cm.height=1;cm.bgColor=colors.gray;cm.fgColor=colors.lightGray;cm:setZIndex(5)local cv={}local cw=k.selectionBG;local cx=k.selectionFG;local cy=true;local cz="left"local dn=0;local d8=1;local dk=false;local function dp()local dq=0;local bV=0;for aj=1,#cv do if bV+cv[aj].text:len()+d8*2>bR.width then if bVdq then dn=dq end;return self end,getPositionOffset=function(self)return dn end,setScrollable=function(self,dl)dk=dl;if dl==nil then dk=true end;return self end,removeItem=function(self,aN)table.remove(cv,aN)return self end,getItem=function(self,aN)return cv[aN]end,getItemCount=function(self)return#cv end,editItem=function(self,aN,au,aE,aF,...)table.remove(cv,aN)table.insert(cv,aN,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cv[aN]or{})return self end,setSelectedItem=function(self,aE,aF,cI)cw=aE or self.bgColor;cx=aF or self.fgColor;cy=cI;return self end,mouseHandler=function(self,aO,c5,as,at)if cm.mouseHandler(self,aO,c5,as,at)then local c6,c7=self:getAbsolutePosition(self:getAnchorPosition())if c6<=as and c6+self.width>as and c7<=at and c7+self.height>at and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if aO=="mouse_click"or aO=="monitor_touch"then local bV=0;for aj=1,#cv do if cv[aj]~=nil then if c6+bV<=as+dn and c6+bV+cv[aj].text:len()+d8*2>as+dn and c7==at then self:setValue(cv[aj])self:getEventSystem():sendEvent(aO,self,aO,0,as,at,cv[aj])end;bV=bV+cv[aj].text:len()+d8*2 end end end;if aO=="mouse_scroll"and dk then dn=dn+c5;if dn<0 then dn=0 end;local dq=dp()if dn>dq then dn=dq end end;self:setVisualChanged(true)return true end end;return false end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)local au=""local ds=""local dt=""for aR,du in pairs(cv)do local dv=(" "):rep(d8)..du.text..(" "):rep(d8)au=au..dv;if du==self:getValue()then ds=ds..j[cw or du.bgCol or self.bgColor]:rep(dv:len())dt=dt..j[cx or du.FgCol or self.fgColor]:rep(dv:len())else ds=ds..j[du.bgCol or self.bgColor]:rep(dv:len())dt=dt..j[du.FgCol or self.fgColor]:rep(dv:len())end end;self.parent:setText(cq,cr,au:sub(dn+1,self.width+dn))self.parent:setBG(cq,cr,ds:sub(dn+1,self.width+dn))self.parent:setFG(cq,cr,dt:sub(dn+1,self.width+dn))end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function dw(bI)local cm=bH(bI)local bJ="Pane"local bR={getType=function(self)return bJ end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cq,cr,self.width,self.height,self.bgColor)end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function dx(bI)local cm=bH(bI)local bJ="Program"cm:setZIndex(5)local bR;local function dy(as,at,a9,p)local dz,dA=1,1;local bb,dB=colors.black,colors.white;local dC=false;local dD=false;local aa={}local ab={}local ac={}local dE={}local ag;local ah={}for r=0,15 do local dF=2^r;dE[dF]={h.getPaletteColour(dF)}end;local function ai()ag=(" "):rep(a9)for aj=0,15 do local ak=2^aj;local al=j[ak]ah[ak]=al:rep(a9)end end;local function am()ai()local an=ag;local ao=ah[colors.white]local ap=ah[colors.black]for aj=1,p do aa[aj]=i(aa[aj]==nil and an or aa[aj]..an:sub(1,a9-aa[aj]:len()),1,a9)ac[aj]=i(ac[aj]==nil and ao or ac[aj]..ao:sub(1,a9-ac[aj]:len()),1,a9)ab[aj]=i(ab[aj]==nil and ap or ab[aj]..ap:sub(1,a9-ab[aj]:len()),1,a9)end end;am()local function dG()if dz>=1 and dA>=1 and dz<=a9 and dA<=p then else end end;local function dH(dI,dJ,dK)local dL=dz;local ax=dL+#dI-1;if dA>=1 and dA<=p then if dL<=a9 and ax>=1 then if dL==1 and ax==a9 then aa[dA]=dI;ac[dA]=dJ;ab[dA]=dK else local dM,dN,dO;if dL<1 then local dP=1-dL+1;local dQ=a9-dL+1;dM=i(dI,dP,dQ)dN=i(dJ,dP,dQ)dO=i(dK,dP,dQ)elseif ax>a9 then local dQ=a9-dL+1;dM=i(dI,1,dQ)dN=i(dJ,1,dQ)dO=i(dK,1,dQ)else dM=dI;dN=dJ;dO=dK end;local dR=aa[dA]local dS=ac[dA]local dT=ab[dA]local dU,dV,dW;if dL>1 then local dX=dL-1;dU=i(dR,1,dX)..dM;dV=i(dS,1,dX)..dN;dW=i(dT,1,dX)..dO else dU=dM;dV=dN;dW=dO end;if ax=1 and at<=p then aa[ej]=aa[at]ab[ej]=ab[at]ac[ej]=ac[at]else aa[ej]=eg;ac[ej]=eh;ab[ej]=ei end end end;if dD then dG()end end,isColor=function()return h.isColor()end,isColour=function()return h.isColor()end,write=function(au)au=tostring(au)if dD then dH(au,j[dB]:rep(au:len()),j[bb]:rep(au:len()))end end,clearLine=function()if dD then ar(1,dA,(" "):rep(a9))aA(1,dA,j[bb]:rep(a9))aC(1,dA,j[dB]:rep(a9))end;if dD then dG()end end,clear=function()for aj=1,p do ar(1,aj,(" "):rep(a9))aA(1,aj,j[bb]:rep(a9))aC(1,aj,j[dB]:rep(a9))end;if dD then dG()end end,blit=function(au,ek,el)if type(au)~="string"then error("bad argument #1 (expected string, got "..type(au)..")",2)end;if type(ek)~="string"then error("bad argument #2 (expected string, got "..type(ek)..")",2)end;if type(el)~="string"then error("bad argument #3 (expected string, got "..type(el)..")",2)end;if#ek~=#au or#el~=#au then error("Arguments must be the same length",2)end;if dD then dH(au,ek,el)end end}return eb end;cm.width=30;cm.height=12;local em=dy(1,1,cm.width,cm.height)local en;local eo=false;local ep={}bR={getType=function(self)return bJ end,show=function(self)cm.show(self)em.setBackgroundColor(self.bgColor)em.setTextColor(self.fgColor)em.basalt_setVisible(true)return self end,hide=function(self)cm.hide(self)em.basalt_setVisible(false)return self end,setPosition=function(self,as,at,bX)cm.setPosition(self,as,at,bX)em.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return em end,getBasaltProcess=function()return en end,setSize=function(self,a9,p)cm.setSize(self,a9,p)em.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if en~=nil then return en:getStatus()end;return"inactive"end,execute=function(self,aW,...)en=aU:new(aW,em,...)em.setBackgroundColor(colors.black)em.setTextColor(colors.white)em.clear()em.setCursorPos(1,1)en:resume()eo=false;return self end,stop=function(self)if en~=nil then if not en:isDead()then en:resume("terminate")if en:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,eq)eo=eq or not eo;if en~=nil then if not en:isDead()then if not eo then self:injectEvents(ep)ep={}end end end;return self end,isPaused=function(self)return eo end,injectEvent=function(self,aO,c8,c9,ca,cb,er)if en~=nil then if not en:isDead()then if eo==false or er then en:resume(aO,c8,c9,ca,cb)else table.insert(ep,{event=aO,args={c8,c9,ca,cb}})end end end;return self end,getQueuedEvents=function(self)return ep end,updateQueuedEvents=function(self,aM)ep=aM or ep;return self end,injectEvents=function(self,aM)if en~=nil then if not en:isDead()then for aR,aS in pairs(aM)do en:resume(aS.event,table.unpack(aS.args))end end end;return self end,mouseHandler=function(self,aO,c5,as,at)if cm.mouseHandler(self,aO,c5,as,at)then if en==nil then return false end;if not en:isDead()then if not eo then local es,et=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))en:resume(aO,c5,as-(es-1),at-(et-1))end end;return true end end,keyHandler=function(self,aO,bs)cm.keyHandler(self,aO,bs)if self:isFocused()then if en==nil then return false end;if not en:isDead()then if not eo then if self.draw then en:resume(aO,bs)end end end end end,getFocusHandler=function(self)cm.getFocusHandler(self)if en~=nil then if not en:isDead()then if not eo then if self.parent~=nil then local eu,ev=em.getCursorPos()local cq,cr=self:getAnchorPosition()if self.parent~=nil then if cq+eu-1>=1 and cq+eu-1<=cq+self.width-1 and ev+cr-1>=1 and ev+cr-1<=cr+self.height-1 then self.parent:setCursor(em.getCursorBlink(),cq+eu-1,ev+cr-1,em.getTextColor())end end end end end end end,loseFocusHandler=function(self)cm.loseFocusHandler(self)if en~=nil then if not en:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,aO,c8,c9,ca,cb)if en==nil then return end;if not en:isDead()then if not eo then if aO~="mouse_click"and aO~="monitor_touch"and aO~="mouse_up"and aO~="mouse_scroll"and aO~="mouse_drag"and aO~="key_up"and aO~="key"and aO~="char"and aO~="terminate"then en:resume(aO,c8,c9,ca,cb)end;if self:isFocused()then local cq,cr=self:getAnchorPosition()local eu,ev=em.getCursorPos()if self.parent~=nil then if cq+eu-1>=1 and cq+eu-1<=cq+self.width-1 and ev+cr-1>=1 and ev+cr-1<=cr+self.height-1 then self.parent:setCursor(em.getCursorBlink(),cq+eu-1,ev+cr-1,em.getTextColor())end end;if aO=="terminate"and self:isFocused()then self:stop()end end else if aO~="mouse_click"and aO~="monitor_touch"and aO~="mouse_up"and aO~="mouse_scroll"and aO~="mouse_drag"and aO~="key_up"and aO~="key"and aO~="char"and aO~="terminate"then table.insert(ep,{event=aO,args={c8,c9,ca,cb}})end end end end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()em.basalt_reposition(cq,cr)self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)em.basalt_update()end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function ew(bI)local cm=bH(bI)local bJ="Progressbar"local ex=0;cm:setZIndex(5)cm:setValue(false)cm.width=25;cm.height=1;cm.bgColor=k.CheckboxBG;cm.fgColor=k.CheckboxFG;local ey=colors.black;local ez=""local eA=colors.white;local eB=""local eC=0;local bR={getType=function(self)return bJ end,setDirection=function(self,eD)eC=eD;return self end,setProgressBar=function(self,bZ,aG,eE)ey=bZ or ey;ez=aG or ez;eA=eE or eA;return self end,setBackgroundSymbol=function(self,aG)eB=aG:sub(1,1)return self end,setProgress=function(self,aS)if aS>=0 and aS<=100 and ex~=aS then ex=aS;self:setValue(ex)if ex==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return ex end,onProgressDone=function(self,A)self:registerEvent("progress_done",A)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cq,cr,self.width,self.height,self.fgColor)self.parent:drawTextBox(cq,cr,self.width,self.height,eB)if eC==1 then self.parent:drawBackgroundBox(cq,cr,self.width,self.height/100*ex,ey)self.parent:drawForegroundBox(cq,cr,self.width,self.height/100*ex,eA)self.parent:drawTextBox(cq,cr,self.width,self.height/100*ex,ez)elseif eC==2 then self.parent:drawBackgroundBox(cq,cr+math.ceil(self.height-self.height/100*ex),self.width,self.height/100*ex,ey)self.parent:drawForegroundBox(cq,cr+math.ceil(self.height-self.height/100*ex),self.width,self.height/100*ex,eA)self.parent:drawTextBox(cq,cr+math.ceil(self.height-self.height/100*ex),self.width,self.height/100*ex,ez)elseif eC==3 then self.parent:drawBackgroundBox(cq+math.ceil(self.width-self.width/100*ex),cr,self.width/100*ex,self.height,ey)self.parent:drawForegroundBox(cq+math.ceil(self.width-self.width/100*ex),cr,self.width/100*ex,self.height,eA)self.parent:drawTextBox(cq+math.ceil(self.width-self.width/100*ex),cr,self.width/100*ex,self.height,ez)else self.parent:drawBackgroundBox(cq,cr,self.width/100*ex,self.height,ey)self.parent:drawForegroundBox(cq,cr,self.width/100*ex,self.height,eA)self.parent:drawTextBox(cq,cr,self.width/100*ex,self.height,ez)end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function eF(bI)local cm=bH(bI)local bJ="Radio"cm.width=8;cm.bgColor=k.listBG;cm.fgColor=k.listFG;cm:setZIndex(5)local cv={}local cw=k.selectionBG;local cx=k.selectionFG;local eG=cm.bgColor;local eH=cm.fgColor;local cy=true;local aG="\7"local cz="left"local bR={getType=function(self)return bJ end,addItem=function(self,au,as,at,aE,aF,...)table.insert(cv,{x=as or 1,y=at or 1,text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})if#cv==1 then self:setValue(cv[1])end;return self end,getAll=function(self)return cv end,removeItem=function(self,aN)table.remove(cv,aN)return self end,getItem=function(self,aN)return cv[aN]end,getItemIndex=function(self)local cH=self:getValue()for bs,aS in pairs(cv)do if aS==cH then return bs end end end,clear=function(self)cv={}self:setValue({})return self end,getItemCount=function(self)return#cv end,editItem=function(self,aN,au,as,at,aE,aF,...)table.remove(cv,aN)table.insert(cv,aN,{x=as or 1,y=at or 1,text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cv[aN]or{})return self end,setSelectedItem=function(self,aE,aF,eI,eJ,cI)cw=aE or cw;cx=aF or cx;eG=eI or eG;eH=eJ or eH;cy=cI;return self end,mouseHandler=function(self,aO,c5,as,at)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if aO=="mouse_click"and c5==1 or aO=="monitor_touch"then if#cv>0 then for aR,aS in pairs(cv)do if cq+aS.x-1<=as and cq+aS.x-1+aS.text:len()+2>=as and cr+aS.y-1==at then self:setValue(aS)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end;return false end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()for aR,aS in pairs(cv)do if aS==self:getValue()then if cz=="left"then self.parent:writeText(aS.x+cq-1,aS.y+cr-1,aG,eG,eH)self.parent:writeText(aS.x+2+cq-1,aS.y+cr-1,aS.text,cw,cx)end else self.parent:drawBackgroundBox(aS.x+cq-1,aS.y+cr-1,1,1,self.bgColor)self.parent:writeText(aS.x+2+cq-1,aS.y+cr-1,aS.text,aS.bgCol,aS.fgCol)end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function eK(bI)local cm=bH(bI)local bJ="Scrollbar"cm.width=1;cm.height=8;cm.bgColor=colors.lightGray;cm.fgColor=colors.gray;cm:setValue(1)cm:setZIndex(2)local eL="vertical"local aG=" "local eM=colors.black;local eN="\127"local eO=cm.height;local aN=1;local eP=1;local bR={getType=function(self)return bJ end,setSymbol=function(self,eQ)aG=eQ:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,x)eP=tonumber(x)or 1;if eL=="vertical"then self:setValue(aN-1*eO/(self.height-(eP-1))-eO/(self.height-(eP-1)))elseif eL=="horizontal"then self:setValue(aN-1*eO/(self.width-(eP-1))-eO/(self.width-(eP-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,cJ)eO=cJ;return self end,setBackgroundSymbol=function(self,eR)eN=string.sub(eR,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eS)eM=eS;self:setVisualChanged()return self end,setBarType=function(self,eT)eL=eT:lower()return self end,mouseHandler=function(self,aO,c5,as,at)if cm.mouseHandler(self,aO,c5,as,at)then local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if(aO=="mouse_click"or aO=="mouse_drag")and c5==1 or aO=="monitor_touch"then if eL=="horizontal"then for eU=0,self.width do if cq+eU==as and cr<=at and cr+self.height>at then aN=math.min(eU+1,self.width-(eP-1))self:setValue(eO/self.width*aN)self:setVisualChanged()end end end;if eL=="vertical"then for eU=0,self.height do if cr+eU==at and cq<=as and cq+self.width>as then aN=math.min(eU+1,self.height-(eP-1))self:setValue(eO/self.height*aN)self:setVisualChanged()end end end end;if aO=="mouse_scroll"then aN=aN+c5;if aN<1 then aN=1 end;aN=math.min(aN,(eL=="vertical"and self.height or self.width)-(eP-1))self:setValue(eO/(eL=="vertical"and self.height or self.width)*aN)end;return true end end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()if eL=="horizontal"then self.parent:writeText(cq,cr,eN:rep(aN-1),self.bgColor,self.fgColor)self.parent:writeText(cq+aN-1,cr,aG:rep(eP),eM,eM)self.parent:writeText(cq+aN+eP-1,cr,eN:rep(self.width-(aN+eP-1)),self.bgColor,self.fgColor)end;if eL=="vertical"then for aj=0,self.height-1 do if aN==aj+1 then for eV=0,math.min(eP-1,self.height)do self.parent:writeText(cq,cr+aj+eV,aG,eM,eM)end else if aj+1aN-1+eP then self.parent:writeText(cq,cr+aj,eN,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function eW(bI)local cm=bH(bI)local bJ="Slider"cm.width=8;cm.height=1;cm.bgColor=colors.lightGray;cm.fgColor=colors.gray;cm:setValue(1)local eL="horizontal"local aG=" "local eM=colors.black;local eN="\140"local eO=cm.width;local aN=1;local eP=1;local bR={getType=function(self)return bJ end,setSymbol=function(self,eQ)aG=eQ:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,x)eP=tonumber(x)or 1;if eL=="vertical"then self:setValue(aN-1*eO/(self.height-(eP-1))-eO/(self.height-(eP-1)))elseif eL=="horizontal"then self:setValue(aN-1*eO/(self.width-(eP-1))-eO/(self.width-(eP-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,cJ)eO=cJ;return self end,setBackgroundSymbol=function(self,eR)eN=string.sub(eR,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eS)eM=eS;self:setVisualChanged()return self end,setBarType=function(self,eT)eL=eT:lower()return self end,mouseHandler=function(self,aO,c5,as,at)if cm.mouseHandler(self,aO,c5,as,at)then local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if(aO=="mouse_click"or aO=="mouse_drag")and c5==1 or aO=="monitor_touch"then if eL=="horizontal"then for eU=0,self.width do if cq+eU==as and cr<=at and cr+self.height>at then aN=math.min(eU+1,self.width-(eP-1))self:setValue(eO/self.width*aN)self:setVisualChanged()end end end;if eL=="vertical"then for eU=0,self.height do if cr+eU==at and cq<=as and cq+self.width>as then aN=math.min(eU+1,self.height-(eP-1))self:setValue(eO/self.height*aN)self:setVisualChanged()end end end end;if aO=="mouse_scroll"then aN=aN+c5;if aN<1 then aN=1 end;aN=math.min(aN,(eL=="vertical"and self.height or self.width)-(eP-1))self:setValue(eO/(eL=="vertical"and self.height or self.width)*aN)end;return true end end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()if eL=="horizontal"then self.parent:writeText(cq,cr,eN:rep(aN-1),self.bgColor,self.fgColor)self.parent:writeText(cq+aN-1,cr,aG:rep(eP),eM,eM)self.parent:writeText(cq+aN+eP-1,cr,eN:rep(self.width-(aN+eP-1)),self.bgColor,self.fgColor)end;if eL=="vertical"then for aj=0,self.height-1 do if aN==aj+1 then for eV=0,math.min(eP-1,self.height)do self.parent:writeText(cq,cr+aj+eV,aG,eM,eM)end else if aj+1aN-1+eP then self.parent:writeText(cq,cr+aj,eN,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function eX(bI)local cm=bH(bI)local bJ="Switch"cm.width=2;cm.height=1;cm.bgColor=colors.lightGray;cm.fgColor=colors.gray;cm:setValue(false)cm:setZIndex(5)local eN=colors.black;local eY=colors.red;local eZ=colors.green;local bR={getType=function(self)return bJ end,setSymbolColor=function(self,eM)eN=eM;self:setVisualChanged()return self end,setActiveBackground=function(self,el)eZ=el;self:setVisualChanged()return self end,setInactiveBackground=function(self,el)eY=el;self:setVisualChanged()return self end,mouseHandler=function(self,aO,c5,as,at)if cm.mouseHandler(self,aO,c5,as,at)then local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if aO=="mouse_click"and c5==1 or aO=="monitor_touch"then self:setValue(not self:getValue())end;return true end end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)if self:getValue()then self.parent:drawBackgroundBox(cq,cr,1,self.height,eZ)self.parent:drawBackgroundBox(cq+1,cr,1,self.height,eN)else self.parent:drawBackgroundBox(cq,cr,1,self.height,eN)self.parent:drawBackgroundBox(cq+1,cr,1,self.height,eY)end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function e_(bI)local cm=bH(bI)local bJ="Textfield"local f0,cW,cV,f1=1,1,1,1;local f2={""}local f3={[colors.purple]={"break"}}cm.width=20;cm.height=8;cm.bgColor=k.textfieldBG;cm.fgColor=k.textfieldFG;cm:setZIndex(5)local bR={getType=function(self)return bJ end,getLines=function(self)return f2 end,getLine=function(self,aN)return f2[aN]or""end,editLine=function(self,aN,au)f2[aN]=au or f2[aN]return self end,addLine=function(self,au,aN)if aN~=nil then table.insert(f2,aN,au)else table.insert(f2,au)end;return self end,addKeyword=function(self,f4,bZ)end,removeLine=function(self,aN)table.remove(f2,aN or#f2)if#f2<=0 then table.insert(f2,"")end;return self end,getTextCursor=function(self)return cV,f1 end,getFocusHandler=function(self)cm.getFocusHandler(self)if self.parent~=nil then local cq,cr=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,cq+cV-cW,cr+f1-f0,self.fgColor)end end end,loseFocusHandler=function(self)cm.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,aO,bs)if cm.keyHandler(self,aO,bs)then local cq,cr=self:getAnchorPosition()if aO=="key"then if bs==keys.backspace then if f2[f1]==""then if f1>1 then table.remove(f2,f1)cV=f2[f1-1]:len()+1;cW=cV-self.width+1;if cW<1 then cW=1 end;f1=f1-1 end elseif cV<=1 then if f1>1 then cV=f2[f1-1]:len()+1;cW=cV-self.width+1;if cW<1 then cW=1 end;f2[f1-1]=f2[f1-1]..f2[f1]table.remove(f2,f1)f1=f1-1 end else f2[f1]=f2[f1]:sub(1,cV-2)..f2[f1]:sub(cV,f2[f1]:len())if cV>1 then cV=cV-1 end;if cW>1 then if cVf2[f1]:len()then if f2[f1+1]~=nil then f2[f1]=f2[f1]..f2[f1+1]table.remove(f2,f1+1)end else f2[f1]=f2[f1]:sub(1,cV-1)..f2[f1]:sub(cV+1,f2[f1]:len())end end;if bs==keys.enter then table.insert(f2,f1+1,f2[f1]:sub(cV,f2[f1]:len()))f2[f1]=f2[f1]:sub(1,cV-1)f1=f1+1;cV=1;cW=1;if f1-f0>=self.height then f0=f0+1 end;self:setValue("")end;if bs==keys.up then if f1>1 then f1=f1-1;if cV>f2[f1]:len()+1 then cV=f2[f1]:len()+1 end;if cW>1 then if cV1 then if f1f2[f1]:len()+1 then cV=f2[f1]:len()+1 end;if f1>=f0+self.height then f0=f0+1 end end end;if bs==keys.right then cV=cV+1;if f1<#f2 then if cV>f2[f1]:len()+1 then cV=1;f1=f1+1 end elseif cV>f2[f1]:len()then cV=f2[f1]:len()+1 end;if cV<1 then cV=1 end;if cV=self.width+cW then cW=cV-self.width+1 end;if cW<1 then cW=1 end end;if bs==keys.left then cV=cV-1;if cV>=1 then if cV=self.width+cW then cW=cV end end;if f1>1 then if cV<1 then f1=f1-1;cV=f2[f1]:len()+1;cW=cV-self.width+1 end end;if cV<1 then cV=1 end;if cW<1 then cW=1 end end end;if aO=="char"then f2[f1]=f2[f1]:sub(1,cV-1)..bs..f2[f1]:sub(cV,f2[f1]:len())cV=cV+1;if cV>=self.width+cW then cW=cW+1 end;self:setValue("")end;local d7=(cV<=f2[f1]:len()and cV-1 or f2[f1]:len())-(cW-1)if d7>self.x+self.width-1 then d7=self.x+self.width-1 end;local f5=f1-f0f2[f1]:len()then cV=f2[f1]:len()+1 end;if cVf2[f1]:len()then cV=f2[f1]:len()+1 end;if cV#f2-(self.height-1)then f0=#f2-(self.height-1)end;if f0<1 then f0=1 end;if self.parent~=nil then if cq+cV-cW>=cq and cq+cV-cW<=cq+self.width and(cr+f1-f0>=cr and cr+f1-f0<=cr+self.height)then self.parent:setCursor(true,f6+cV-cW,f7+f1-f0,self.fgColor)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if cm.draw(self)then if self.parent~=nil then local cq,cr=self:getAnchorPosition()self.parent:drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cq,cr,self.width,self.height,self.fgColor)for aj=1,self.height do local au=""if f2[aj+f0-1]~=nil then au=f2[aj+f0-1]end;au=au:sub(cW,self.width+cW-1)local d8=self.width-au:len()if d8<0 then d8=0 end;au=au..string.rep(" ",d8)self.parent:setText(cq,cr+aj-1,au)end end;self:setVisualChanged(false)end end}return setmetatable(bR,cm)end;local function f8(bI)local bR;local bJ="Thread"local aQ;local f9;local fa=false;bR={name=bI,getType=function(self)return bJ end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,A)if A==nil then error("Function provided to thread is nil")end;aQ=A;f9=coroutine.create(aQ)fa=true;local a_,b0=coroutine.resume(f9)if not a_ then if b0~="Terminated"then error("Thread Error Occurred - "..b0)end end;return self end,getStatus=function(self,A)if f9~=nil then return coroutine.status(f9)end;return nil end,stop=function(self,A)fa=false;return self end,eventHandler=function(self,aO,c8,c9,ca)if fa then if coroutine.status(f9)~="dead"then local a_,b0=coroutine.resume(f9,aO,c8,c9,ca)if not a_ then if b0~="Terminated"then error("Thread Error Occurred - "..b0)end end else fa=false end end end}bR.__index=bR;return bR end;local function fb(bI)local bJ="Timer"local fc=0;local fd=0;local fe=0;local cd;local bQ=aL()local ff=false;local bR={name=bI,getType=function(self)return bJ end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,fg,fh)fc=fg or 0;fd=fh or 1;return self end,start=function(self)if ff then os.cancelTimer(cd)end;fe=fd;cd=os.startTimer(fc)ff=true;return self end,isActive=function(self)return ff end,cancel=function(self)if cd~=nil then os.cancelTimer(cd)end;ff=false;return self end,onCall=function(self,aQ)bQ:registerEvent("timed_event",aQ)return self end,eventHandler=function(self,aO,ck)if aO=="timer"and ck==cd and ff then bQ:sendEvent("timed_event",self)if fe>=1 then fe=fe-1;if fe>=1 then cd=os.startTimer(fc)end elseif fe==-1 then cd=os.startTimer(fc)end end end}bR.__index=bR;return bR end;local function fi(bI,fj)local cm=bH(bI)local bJ="Frame"local fk={}local fl={}local bR={}local fm=h;local fn=""local fo=false;local fp=false;local fq=0;cm:setZIndex(10)local aD=a6(fm)local dC=false;local dz=1;local dA=1;local fr=colors.white;local fs,cA=0,0;if fj~=nil then cm.parent=fj;cm.width,cm.height=fj:getSize()cm.bgColor=k.FrameBG;cm.fgColor=k.FrameFG else cm.width,cm.height=fm.getSize()cm.bgColor=k.basaltBG;cm.fgColor=k.basaltFG end;local function ft(bI)for aR,aS in pairs(fk)do for aR,bu in pairs(aS)do if bu.name==bI then return aS end end end end;local function fu(fv)local bK=fv:getZIndex()if ft(fv.name)~=nil then return nil end;if fk[bK]==nil then for as=1,#fl+1 do if fl[as]~=nil then if bK==fl[as]then break end;if bK>fl[as]then table.insert(fl,as,bK)break end else table.insert(fl,bK)end end;if#fl<=0 then table.insert(fl,bK)end;fk[bK]={}end;fv.parent=bR;table.insert(fk[bK],fv)return fv end;local function fw(fv)for bt,bu in pairs(fk)do for bs,aS in pairs(bu)do if aS==fv then table.remove(fk[bt],bs)return true end end end;return false end;bR={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return bJ end,setFocusedObject=function(self,fv)if c~=nil then c:loseFocusHandler()c=nil end;if fv~=nil then c=fv;fv:getFocusHandler()end;return self end,setOffset=function(self,c2,c3)fs=c2~=nil and math.floor(c2<0 and math.abs(c2)or-c2)or fs;cA=c3~=nil and math.floor(c3<0 and math.abs(c3)or-c3)or cA;return self end,getFrameOffset=function(self)return fs,cA end,removeFocusedObject=function(self)if c~=nil then c:loseFocusHandler()end;c=nil;return self end,getFocusedObject=function(self)return c end,setCursor=function(self,fx,fy,fz,bZ)if self.parent~=nil then local cq,cr=self:getAnchorPosition()self.parent:setCursor(fx or false,(fy or 0)+cq-1,(fz or 0)+cr-1,bZ or fr)else local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())dC=fx or false;if fy~=nil then dz=cq+fy-1 end;if fz~=nil then dA=cr+fz-1 end;fr=bZ or fr;self:setVisualChanged()end;return self end,setMoveable=function(self,fA)self.isMoveable=fA or not self.isMoveable;self:setVisualChanged()return self end,show=function(self)cm.show(self)if self.parent==nil then e=self;if fo then g[fn]=self else f=self end end;return self end,hide=function(self)cm.hide(self)if self.parent==nil then if e==self then e=nil end;if fo then if g[fn]==self then g[fn]=nil end else if f==self then f=nil end end end;return self end,showBar=function(self,fB)self.barActive=fB or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,au,aE,aF)self.barText=au or""self.barBackground=aE or self.barBackground;self.barTextcolor=aF or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,cz)self.barTextAlign=cz or"left"self:setVisualChanged()return self end,setMonitor=function(self,fC)if fC~=nil or fC~=false then if peripheral.getType(fC)=="monitor"then fm=peripheral.wrap(fC)fp=true end;fo=true else fm=h;fo=false;if g[fn]==self then g[fn]=nil end end;aD=a6(fm)fn=fC or nil;return self end,getVisualChanged=function(self)local fD=cm.getVisualChanged(self)for aR,aN in pairs(fl)do if fk[aN]~=nil then for aR,aS in pairs(fk[aN])do if aS.getVisualChanged~=nil and aS:getVisualChanged()then fD=true end end end end;return fD end,loseFocusHandler=function(self)cm.loseFocusHandler(self)end,getFocusHandler=function(self)cm.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,aO,bs)if c~=nil then if c~=self then if c.keyHandler~=nil then if c:keyHandler(aO,bs)then return true end end else cm.keyHandler(self,aO,bs)end end;return false end,backgroundKeyHandler=function(self,aO,bs)cm.backgroundKeyHandler(self,aO,bs)for aR,aN in pairs(fl)do if fk[aN]~=nil then for aR,aS in pairs(fk[aN])do if aS.backgroundKeyHandler~=nil then aS:backgroundKeyHandler(aO,bs)end end end end end,eventHandler=function(self,aO,c8,c9,ca,cb)cm.eventHandler(self,aO,c8,c9,ca,cb)for aR,aN in pairs(fl)do if fk[aN]~=nil then for aR,aS in pairs(fk[aN])do if aS.eventHandler~=nil then aS:eventHandler(aO,c8,c9,ca,cb)end end end end;if fo then if aO=="peripheral"and c8==fn then if peripheral.getType(fn)=="monitor"then fp=true;fm=peripheral.wrap(fn)aD=a6(fm)end end;if aO=="peripheral_detach"and c8==fn then fp=false end end;if aO=="terminate"then fm.clear()fm.setCursorPos(1,1)a.stop()end end,mouseHandler=function(self,aO,c5,as,at)local c2,c3=self:getOffset()c2=c2<0 and math.abs(c2)or-c2;c3=c3<0 and math.abs(c3)or-c3;if self.drag then if aO=="mouse_drag"then local fE=1;local fF=1;if self.parent~=nil then fE,fF=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(as+fq-(fE-1)+c2,at-(fF-1)+c3)end;if aO=="mouse_up"then self.drag=false end;return true end;if cm.mouseHandler(self,aO,c5,as,at)then local b_,c0=self:getAbsolutePosition(self:getAnchorPosition())b_=b_+fs;c0=c0+cA;for aR,aN in pairs(fl)do if fk[aN]~=nil then for aR,aS in b7(fk[aN])do if aS.mouseHandler~=nil then if aS:mouseHandler(aO,c5,as,at)then return true end end end end end;if self.isMoveable then if as>=b_ and as<=b_+self.width-1 and at==c0 and aO=="mouse_click"then self.drag=true;fq=b_-as end end;if c~=nil then c:loseFocusHandler()c=nil end;return true end;return false end,setText=function(self,as,at,au)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fE,fF=self.parent:getAnchorPosition()self.parent:setText(math.max(as+cq-1,cq)-(fE-1),cr+at-1-(fF-1),i(au,math.max(1-as+1,1),self.width-as+1))else aD.setText(math.max(as+cq-1,cq),cr+at-1,i(au,math.max(1-as+1,1),self.width-as+1))end end end,setBG=function(self,as,at,aE)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fE,fF=self.parent:getAnchorPosition()self.parent:setBG(math.max(as+cq-1,cq)-(fE-1),cr+at-1-(fF-1),i(aE,math.max(1-as+1,1),self.width-as+1))else aD.setBG(math.max(as+cq-1,cq),cr+at-1,i(aE,math.max(1-as+1,1),self.width-as+1))end end end,setFG=function(self,as,at,aF)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fE,fF=self.parent:getAnchorPosition()self.parent:setFG(math.max(as+cq-1,cq)-(fE-1),cr+at-1-(fF-1),i(aF,math.max(1-as+1,1),self.width-as+1))else aD.setFG(math.max(as+cq-1,cq),cr+at-1,i(aF,math.max(1-as+1,1),self.width-as+1))end end end,writeText=function(self,as,at,au,aE,aF)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fE,fF=self.parent:getAnchorPosition()self.parent:writeText(math.max(as+cq-1,cq)-(fE-1),cr+at-1-(fF-1),i(au,math.max(1-as+1,1),self.width-as+1),aE,aF)else aD.writeText(math.max(as+cq-1,cq),cr+at-1,i(au,math.max(1-as+1,1),self.width-as+1),aE,aF)end end end,drawBackgroundBox=function(self,as,at,a9,p,aE)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())p=at<1 and(p+at>self.height and self.height or p+at-1)or(p+at>self.height and self.height-at+1 or p)a9=as<1 and(a9+as>self.width and self.width or a9+as-1)or(a9+as>self.width and self.width-as+1 or a9)if self.parent~=nil then local fE,fF=self.parent:getAnchorPosition()self.parent:drawBackgroundBox(math.max(as+cq-1,cq)-(fE-1),math.max(at+cr-1,cr)-(fF-1),a9,p,aE)else aD.drawBackgroundBox(math.max(as+cq-1,cq),math.max(at+cr-1,cr),a9,p,aE)end end,drawTextBox=function(self,as,at,a9,p,aG)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())p=at<1 and(p+at>self.height and self.height or p+at-1)or(p+at>self.height and self.height-at+1 or p)a9=as<1 and(a9+as>self.width and self.width or a9+as-1)or(a9+as>self.width and self.width-as+1 or a9)if self.parent~=nil then local fE,fF=self.parent:getAnchorPosition()self.parent:drawTextBox(math.max(as+cq-1,cq)-(fE-1),math.max(at+cr-1,cr)-(fF-1),a9,p,aG:sub(1,1))else aD.drawTextBox(math.max(as+cq-1,cq),math.max(at+cr-1,cr),a9,p,aG:sub(1,1))end end,drawForegroundBox=function(self,as,at,a9,p,aF)local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())p=at<1 and(p+at>self.height and self.height or p+at-1)or(p+at>self.height and self.height-at+1 or p)a9=as<1 and(a9+as>self.width and self.width or a9+as-1)or(a9+as>self.width and self.width-as+1 or a9)if self.parent~=nil then local fE,fF=self.parent:getAnchorPosition()self.parent:drawForegroundBox(math.max(as+cq-1,cq)-(fE-1),math.max(at+cr-1,cr)-(fF-1),a9,p,aF)else aD.drawForegroundBox(math.max(as+cq-1,cq),math.max(at+cr-1,cr),a9,p,aF)end end,draw=function(self)if fo and not fp then return false end;if self:getVisualChanged()then if cm.draw(self)then local cq,cr=self:getAbsolutePosition(self:getAnchorPosition())local f6,f7=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(f6,f7,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(f6,f7,self.width,self.height,self.fgColor)self.parent:drawTextBox(f6,f7,self.width,self.height," ")else aD.drawBackgroundBox(cq,cr,self.width,self.height,self.bgColor)aD.drawForegroundBox(cq,cr,self.width,self.height,self.fgColor)aD.drawTextBox(cq,cr,self.width,self.height," ")end;fm.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(f6,f7,b1(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)else aD.writeText(cq,cr,b1(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aR,aN in b7(fl)do if fk[aN]~=nil then for aR,aS in pairs(fk[aN])do if aS.draw~=nil then aS:draw()end end end end;if dC then fm.setTextColor(fr)fm.setCursorPos(dz,dA)if self.parent~=nil then fm.setCursorBlink(self:isFocused())else fm.setCursorBlink(dC)end end;self:setVisualChanged(false)end end end,drawUpdate=function(self)if fo and not fp then return false end;aD.update()end,addObject=function(self,fv)return fu(fv)end,removeObject=function(self,fv)return fw(fv)end,getObject=function(self,fv)return ft(fv)end,addButton=function(self,bI)local fv=cl(bI)fv.name=bI;return fu(fv)end,addLabel=function(self,bI)local fv=d9(bI)fv.bgColor=self.bgColor;fv.fgColor=self.fgColor;return fu(fv)end,addCheckbox=function(self,bI)local fv=ct(bI)return fu(fv)end,addInput=function(self,bI)local fv=cS(bI)return fu(fv)end,addProgram=function(self,bI)local fv=dx(bI)return fu(fv)end,addTextfield=function(self,bI)local fv=e_(bI)return fu(fv)end,addList=function(self,bI)local fv=dj(bI)fv.name=nam;return fu(fv)end,addDropdown=function(self,bI)local fv=cu(bI)return fu(fv)end,addRadio=function(self,bI)local fv=eF(bI)return fu(fv)end,addTimer=function(self,bI)local fv=fb(bI)return fu(fv)end,addAnimation=function(self,bI)local fv=cc(bI)return fu(fv)end,addSlider=function(self,bI)local fv=eW(bI)return fu(fv)end,addScrollbar=function(self,bI)local fv=eK(bI)return fu(fv)end,addMenubar=function(self,bI)local fv=dm(bI)return fu(fv)end,addThread=function(self,bI)local fv=f8(bI)return fu(fv)end,addPane=function(self,bI)local fv=dw(bI)return fu(fv)end,addImage=function(self,bI)local fv=cK(bI)return fu(fv)end,addProgressbar=function(self,bI)local fv=ew(bI)return fu(fv)end,addSwitch=function(self,bI)local fv=eX(bI)return fu(fv)end,addFrame=function(self,bI)local fv=fi(bI,self)return fu(fv)end}setmetatable(bR,cm)return bR end;local function fG()f:draw()f:drawUpdate()for aR,du in pairs(g)do du:draw()du:drawUpdate()end end;local fH=false;local function fI(aO,c8,c9,ca,cb)if f~=nil then if aO=="mouse_click"then f:mouseHandler(aO,c8,c9,ca,cb)e=f elseif aO=="mouse_drag"then f:mouseHandler(aO,c8,c9,ca,cb)e=f elseif aO=="mouse_up"then f:mouseHandler(aO,c8,c9,ca,cb)e=f elseif aO=="mouse_scroll"then f:mouseHandler(aO,c8,c9,ca,cb)e=f elseif aO=="monitor_touch"then if g[c8]~=nil then g[c8]:mouseHandler(aO,c8,c9,ca,cb)e=g[c8]end end end;if aO=="key"or aO=="char"then e:keyHandler(aO,c8)e:backgroundKeyHandler(aO,c8)end;if aO=="key"then b[c8]=true end;if aO=="key_up"then b[c8]=false end;for aR,du in pairs(d)do du:eventHandler(aO,c8,c9,ca,cb)end;if fH then fG()end end;function a.autoUpdate(fa)fH=fa;if fa==nil then fH=true end;fG()while fH do local aO,c8,c9,ca,cb=os.pullEventRaw()fI(aO,c8,c9,ca,cb)end end;function a.update(aO,c8,c9,ca,cb)if aO~=nil then fI(aO,c8,c9,ca,cb)else fG()end end;function a.stop()fH=false end;function a.isKeyDown(bs)if b[bs]==nil then return false end;return b[bs]end;function a.getFrame(bI)for aR,aS in pairs(d)do if aS.name==bI then return aS end end end;function a.getActiveFrame()return e end;function a.setActiveFrame(bS)if bS:getType()=="Frame"then e=bS;return true end;return false end;function a.createFrame(bI)for aR,du in pairs(d)do if du.name==bI then return nil end end;local fJ=fi(bI)table.insert(d,fJ)return fJ end;function a.removeFrame(bI)d[bI]=nil end;if a.debugger then a.debugFrame=a.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)a.debugList=a.debugFrame:addList("debugList"):setSize(a.debugFrame.width-2,a.debugFrame.height-3):setPosition(2,3):setScrollable(true):show()a.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()a.oldFrame:show()end):setBackground(colors.red):show()a.debugLabel=a.debugFrame:addLabel("debugLabel"):onClick(function()a.oldFrame=f;a.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):ignoreOffset():setZIndex(20):show()end;if a.debugger then function a.debug(...)local aY={...}if f.name~="basaltDebuggingFrame"then if f~=a.debugFrame then a.debugLabel:setParent(f)end end;local fK=""for bs,aS in pairs(aY)do fK=fK..tostring(aS)..(#aY~=bs and", "or"")end;a.debugLabel:setText("[Debug] "..fK)a.debugList:addItem(fK)if a.debugList:getItemCount()>50 then a.debugList:removeItem(1)end;a.debugList:setValue(a.debugList:getItem(a.debugList:getItemCount()))if a.debugList.getItemCount()>a.debugList:getHeight()then a.debugList:setIndexOffset(a.debugList:getItemCount()-a.debugList:getHeight())end;a.debugLabel:show()end end;return a \ No newline at end of file diff --git a/oldVersions/v1.1/basalt.lua b/oldVersions/v1.1/basalt.lua new file mode 100644 index 0000000..4be3003 --- /dev/null +++ b/oldVersions/v1.1/basalt.lua @@ -0,0 +1 @@ +local a={debugger=true,version=1}local b;local c={}local d={}local e=term.current()local f=string.sub;local g={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local h={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local i={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{[[000110000110110000110010101000000010000000100101]],[[000000110110000000000010101000000010000000100101]],[[000000000000000000000000000000000000000000000000]],[[100010110100000010000110110000010100000100000110]],[[000000110000000010110110000110000000000000110000]],[[000000000000000000000000000000000000000000000000]],[[000000110110000010000000100000100000000000000010]],[[000000000110110100010000000010000000000000000100]],[[000000000000000000000000000000000000000000000000]],[[010000000000100110000000000000000000000110010000]],[[000000000000000000000000000010000000010110000000]],[[000000000000000000000000000000000000000000000000]],[[011110110000000100100010110000000100000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110000110110000000000000000000010100100010000000]],[[000010000000000000110110000000000100010010000000]],[[000000000000000000000000000000000000000000000000]],[[010110010110100110110110010000000100000110110110]],[[000000000000000000000110000000000110000000000000]],[[000000000000000000000000000000000000000000000000]],[[010100010110110000000000000000110000000010000000]],[[110110000000000000110000110110100000000010000000]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[100100100100100100100100100100100100100100100100]],[[000000110100110110000010000011110000000000011000]],[[000000000100000000000010000011000110000000001000]],[[000000000000000000000000000000000000000000000000]],[[010000100100000000000000000100000000010010110000]],[[000000000000000000000000000000110110110110110000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110000000110110110110110110110110]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000110110000110010000000000000000010010]],[[000010000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110110110110000000000000]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110000000000000000010000]],[[000000000000000000000000100000000000000110000110]],[[000000000000000000000000000000000000000000000000]]}}local j={}local k={}do local l=0;local m=#i[1]local n=#i[1][1]for o=1,m,3 do for p=1,n,3 do local q=string.char(l)local r={}r[1]=i[1][o]:sub(p,p+2)r[2]=i[1][o+1]:sub(p,p+2)r[3]=i[1][o+2]:sub(p,p+2)local s={}s[1]=i[2][o]:sub(p,p+2)s[2]=i[2][o+1]:sub(p,p+2)s[3]=i[2][o+2]:sub(p,p+2)k[q]={r,s}l=l+1 end end;j[1]=k end;local function t(u,v)local w={["0"]="1",["1"]="0"}if u<=#j then return true end;for x=#j+1,u do local y={}local z=j[x-1]for l=0,255 do local q=string.char(l)local r={}local s={}local A=z[q][1]local B=z[q][2]for o=1,#A do local C,D,E,F,G,H={},{},{},{},{},{}for p=1,#A[1]do local I=k[A[o]:sub(p,p)][1]table.insert(C,I[1])table.insert(D,I[2])table.insert(E,I[3])local J=k[A[o]:sub(p,p)][2]if B[o]:sub(p,p)=="1"then table.insert(F,J[1]:gsub("[01]",w))table.insert(G,J[2]:gsub("[01]",w))table.insert(H,J[3]:gsub("[01]",w))else table.insert(F,J[1])table.insert(G,J[2])table.insert(H,J[3])end end;table.insert(r,table.concat(C))table.insert(r,table.concat(D))table.insert(r,table.concat(E))table.insert(s,table.concat(F))table.insert(s,table.concat(G))table.insert(s,table.concat(H))end;y[q]={r,s}if v then v="Font"..x.."Yeld"..l;os.queueEvent(v)os.pullEvent(v)end end;j[x]=y end;return true end;local function K(L,M,N,O,P)if not type(M)=="string"then error("Not a String",3)end;local Q=type(N)=="string"and N:sub(1,1)or g[N]or error("Wrong Front Color",3)local R=type(O)=="string"and O:sub(1,1)or g[O]or error("Wrong Back Color",3)if j[L]==nil then t(3,false)end;local S=j[L]or error("Wrong font size selected",3)if M==""then return{{""},{""},{""}}end;local T={}for o in M:gmatch('.')do table.insert(T,o)end;local U={}local m=#S[T[1]][1]for V=1,m do local W={}for o=1,#T do W[o]=S[T[o]]and S[T[o]][1][V]or""end;U[V]=table.concat(W)end;local X={}local Y={}local Z={["0"]=Q,["1"]=R}local _={["0"]=R,["1"]=Q}for V=1,m do local a0={}local a1={}for o=1,#T do local a2=S[T[o]]and S[T[o]][2][V]or""a0[o]=a2:gsub("[01]",P and{["0"]=N:sub(o,o),["1"]=O:sub(o,o)}or Z)a1[o]=a2:gsub("[01]",P and{["0"]=O:sub(o,o),["1"]=N:sub(o,o)}or _)end;X[V]=table.concat(a0)Y[V]=table.concat(a1)end;return{U,X,Y}end;local function a3(a4)local a5=a4;local a6,m=a5.getSize()local a7={}local a8={}local a9={}local aa={}local ab={}local ac={}local ad;local ae={}local function af()ad=(" "):rep(a6)for ag=0,15 do local ah=2^ag;local ai=g[ah]ae[ah]=ai:rep(a6)end end;af()local function aj()local ak=ad;local al=ae[colors.white]local am=ae[colors.black]for an=1,m do a7[an]=f(a7[an]==nil and ak or a7[an]..ak:sub(1,a6-a7[an]:len()),1,a6)a9[an]=f(a9[an]==nil and al or a9[an]..al:sub(1,a6-a9[an]:len()),1,a6)a8[an]=f(a8[an]==nil and am or a8[an]..am:sub(1,a6-a8[an]:len()),1,a6)end end;aj()local function ao(ap,aq,ar)if aq>=1 and aq<=m then if ap+ar:len()>0 and ap<=a6 then local as=a7[aq]local at;local au=ap+#ar-1;if ap<1 then local av=1-ap+1;local aw=a6-ap+1;ar=f(ar,av,aw)elseif au>a6 then local aw=a6-ap+1;ar=f(ar,1,aw)end;if ap>1 then local aw=ap-1;at=f(as,1,aw)..ar else at=ar end;if au=1 and aq<=m then if ap+ay:len()>0 and ap<=a6 then local as=a8[aq]local at;local au=ap+#ay-1;if ap<1 then ay=f(ay,1-ap+1,a6-ap+1)elseif au>a6 then ay=f(ay,1,a6-ap+1)end;if ap>1 then at=f(as,1,ap-1)..ay else at=ay end;if au=1 and aq<=m then if ap+ay:len()>0 and ap<=a6 then local as=a9[aq]local at;local au=ap+#ay-1;if ap<1 then local av=1-ap+1;local aw=a6-ap+1;ay=f(ay,av,aw)elseif au>a6 then local aw=a6-ap+1;ay=f(ay,1,aw)end;if ap>1 then local aw=ap-1;at=f(as,1,aw)..ay else at=ay end;if au1 then while#bg>2 do table.sort(bg,function(bq,br)return bq[2]>br[2]end)local bs,bt=bf(bg),#bg;local bu,bv=bg[bt][1],bg[bs][1]for o=1,6 do if bk[o]==bu then bk[o]=bv;bg[bs][2]=bg[bs][2]+1 end end;bg[bt]=nil end;local bw=128;for o=1,#bk-1 do if bk[o]~=bk[6]then bw=bw+2^(o-1)end end;return string.char(bw),bc[bg[1][1]==bk[6]and bg[2][1]or bg[1][1]],bc[bk[6]]else return"\128",bc[bk[1]],bc[bk[1]]end end;local bx,a6,m,aB={{},{},{}},0,#b7+#b7%3,b8 or colors.black;for o=1,#b7 do if#b7[o]>a6 then a6=#b7[o]end end;for aq=0,m-1,3 do local by,bz,bA,bB={},{},{},1;for ap=0,a6-1,2 do local bk,bl={},{}for bC=1,3 do for bD=1,2 do bk[#bk+1]=b7[aq+bC]and b7[aq+bC][ap+bD]and(b7[aq+bC][ap+bD]==0 and aB or b7[aq+bC][ap+bD])or aB;bl[bk[#bk]]=bl[bk[#bk]]and bl[bk[#bk]]+1 or 1 end end;by[bB],bz[bB],bA[bB]=bj(bk,bl)bB=bB+1 end;bx[1][#bx[1]+1],bx[2][#bx[2]+1],bx[3][#bx[3]+1]=table.concat(by),table.concat(bz),table.concat(bA)end;bx.width,bx.height=#bx[1][1],#bx[1]return bx end;local function bE(bF)local bG="Object"local aP;local bH=1;local bI="left"local bJ="top"local bK=false;local bL=false;local bM=true;local bN=aI()local bO={x=1,y=1,width=1,height=1,bgColor=colors.black,fgColor=colors.white,name=bF or"Object",parent=nil,show=function(self)bL=true;bM=true;return self end,hide=function(self)bL=false;bM=true;return self end,isVisible=function(self)return bL end,setFocus=function(self)if self.parent~=nil then self.parent:setFocusedObject(self)end;return self end,setZIndex=function(self,aK)bH=aK;if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end;return self end,getZIndex=function(self)return bH end,getType=function(self)return bG end,getName=function(self)return self.name end,remove=function(self)if self.parent~=nil then self.parent:removeObject(self)end;return self end,setParent=function(self,bP)if bP.getType~=nil and bP:getType()=="Frame"then self:remove()bP:addObject(self)if self.draw then self:show()end end;return self end,setValue=function(self,bQ)if aP~=bQ then aP=bQ;bM=true;self:valueChangedHandler()end;return self end,getValue=function(self)return aP end,getVisualChanged=function(self)return bM end,setVisualChanged=function(self,bR)bM=bR or true;if bR==nil then bM=true end;return self end,getEventSystem=function(self)return bN end,getParent=function(self)return self.parent end,setPosition=function(self,bS,bT,bU)if bU then self.x,self.y=math.floor(self.x+bS),math.floor(self.y+bT)else self.x,self.y=math.floor(bS),math.floor(bT)end;bM=true;return self end,getPosition=function(self)return self.x,self.y end,getVisibility=function(self)return bL end,setVisibility=function(self,bV)bL=bV or not bL;bM=true;return self end,setSize=function(self,a6,m)self.width,self.height=a6,m;bM=true;return self end,getHeight=function(self)return self.height end,getWidth=function(self)return self.width end,getSize=function(self)return self.width,self.height end,setBackground=function(self,bW)self.bgColor=bW;bM=true;return self end,getBackground=function(self)return self.bgColor end,setForeground=function(self,bW)self.fgColor=bW;bM=true;return self end,getForeground=function(self)return self.fgColor end,draw=function(self)if bL then return true end;return false end,getAbsolutePosition=function(self,ap,aq)if ap==nil then ap=self.x end;if aq==nil then aq=self.y end;if self.parent~=nil then local bX,bY=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())ap=bX+ap-1;aq=bY+aq-1 end;return ap,aq end,getAnchorPosition=function(self,ap,aq,bZ)if ap==nil then ap=self.x end;if aq==nil then aq=self.y end;if bI=="right"then ap=self.parent.width-ap-self.width+2 end;if bJ=="bottom"then aq=self.parent.height-aq-self.height+2 end;local b_,c0=self:getOffset()if bK or bZ then return ap,aq end;return ap+b_,aq+c0 end,getOffset=function(self)if self.parent~=nil and bK==false then return self.parent:getFrameOffset()end;return 0,0 end,ignoreOffset=function(self,c1)bK=c1 or true;return self end,setAnchor=function(self,...)for aO,aP in pairs(table.pack(...))do if aP=="right"or aP=="left"then bI=aP end;if aP=="top"or aP=="bottom"then bJ=aP end end;bM=true;return self end,getAnchor=function(self)return bI,bJ end,onChange=function(self,aN)self:registerEvent("value_changed",aN)return self end,onClick=function(self,aN)self:registerEvent("mouse_click",aN)self:registerEvent("monitor_touch",aN)return self end,onEvent=function(self,aN)self:registerEvent("custom_event_handler",aN)return self end,onClickUp=function(self,aN)self:registerEvent("mouse_up",aN)return self end,onKey=function(self,aN)self:registerEvent("key",aN)self:registerEvent("char",aN)return self end,onKeyUp=function(self,aN)self:registerEvent("key_up",aN)return self end,onBackgroundKey=function(self,aN)self:registerEvent("background_key",aN)self:registerEvent("background_char",aN)return self end,onBackgroundKeyUp=function(self,aN)self:registerEvent("background_key_up",aN)return self end,isFocused=function(self)if self.parent~=nil then return self.parent:getFocusedObject()==self end;return false end,onGetFocus=function(self,aN)self:registerEvent("get_focus",aN)return self end,onLoseFocus=function(self,aN)self:registerEvent("lose_focus",aN)return self end,registerEvent=function(self,aL,aN)return bN:registerEvent(aL,aN)end,removeEvent=function(self,aL,aK)return bN:removeEvent(aL,aK)end,sendEvent=function(self,aL,...)return bN:sendEvent(aL,self,...)end,mouseClickHandler=function(self,aL,c2,ap,aq)local c3,c4=self:getAbsolutePosition(self:getAnchorPosition())if c3<=ap and c3+self.width>ap and c4<=aq and c4+self.height>aq and bL then if self.parent~=nil then self.parent:setFocusedObject(self)end;bN:sendEvent(aL,self,aL,c2,ap,aq)return true end;return false end,keyHandler=function(self,aL,bp)if self:isFocused()then bN:sendEvent(aL,self,aL,bp)return true end;return false end,backgroundKeyHandler=function(self,aL,bp)bN:sendEvent("background_"..aL,self,aL,bp)end,valueChangedHandler=function(self)bN:sendEvent("value_changed",self)end,eventHandler=function(self,aL,c5,c6,c7,c8)bN:sendEvent("custom_event_handler",self,aL,c5,c6,c7,c8)end,getFocusHandler=function(self)bN:sendEvent("get_focus",self)end,loseFocusHandler=function(self)bN:sendEvent("lose_focus",self)end}bO.__index=bO;return bO end;local function c9(bF)local bO={}local bG="Animation"local ca;local cb={}local aK=1;local cc=0;local cd;local function ce()if cb[aK]~=nil then cb[aK].f(bO,aK)end;aK=aK+1;if cb[aK]~=nil then if cb[aK].t>0 then ca=os.startTimer(cb[aK].t)else ce()end end end;bO={name=bF,getType=function(self)return bG end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,aN,cf)cd=aN;table.insert(cb,{f=aN,t=cf or cc})return self end,wait=function(self,cf)cc=cf;return self end,rep=function(self,cg)for ap=1,cg do table.insert(cb,{f=cd,t=cc})end;return self end,clear=function(self)cb={}cd=nil;cc=0;aK=1;return self end,play=function(self)aK=1;if cb[aK]~=nil then if cb[aK].t>0 then ca=os.startTimer(cb[aK].t)else ce()end end;return self end,cancel=function(self)os.cancelTimer(ca)return self end,eventHandler=function(self,aL,ch)if aL=="timer"and ch==ca then if cb[aK]~=nil then ce()end end end}bO.__index=bO;return bO end;local function ci(bF)local cj=bE(bF)local bG="Button"cj:setValue("Button")cj:setZIndex(5)cj.width=8;cj.bgColor=h.ButtonBG;cj.fgColor=h.ButtonFG;local ck="center"local cl="center"local bO={getType=function(self)return bG end,setHorizontalAlign=function(self,cm)ck=cm end,setVerticalAlign=function(self,cm)cl=cm end,setText=function(self,ar)cj:setValue(ar)return self end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,cl)self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)self.parent:drawTextBox(cn,co,self.width,self.height," ")for ag=1,self.height do if ag==cp then self.parent:setText(cn,co+ag-1,aZ(self:getValue(),self.width,ck))end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cq(bF)local cj=bE(bF)local bG="Checkbox"cj:setZIndex(5)cj:setValue(false)cj.width=1;cj.height=1;cj.bgColor=h.CheckboxBG;cj.fgColor=h.CheckboxFG;local bO={symbol="\42",getType=function(self)return bG end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,"center")self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)for ag=1,self.height do if ag==cp then if self:getValue()==true then self.parent:writeText(cn,co+ag-1,aZ(self.symbol,self.width,"center"),self.bgColor,self.fgColor)else self.parent:writeText(cn,co+ag-1,aZ(" ",self.width,"center"),self.bgColor,self.fgColor)end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cr(bF)local cj=bE(bF)local bG="Dropdown"cj.width=12;cj.height=1;cj.bgColor=h.dropdownBG;cj.fgColor=h.dropdownFG;cj:setZIndex(6)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local cv=true;local cw="left"local cx=0;local cy=16;local cz=6;local cA="\16"local cB="\31"local cC=false;local bO={getType=function(self)return bG end,setIndexOffset=function(self,cD)cx=cD;return self end,getIndexOffset=function(self)return cx end,addItem=function(self,ar,aB,aC,...)table.insert(cs,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,getAll=function(self)return cs end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getItemIndex=function(self)local cE=self:getValue()for bp,aP in pairs(cs)do if aP==cE then return bp end end end,clear=function(self)cs={}self:setValue({})return self end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,cF)ct=aB or self.bgColor;cu=aC or self.fgColor;cv=cF;return self end,setDropdownSize=function(self,a6,m)cy,cz=a6,m;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cC then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then if#cs>0 then for ag=1,cz do if cs[ag+cx]~=nil then if cn<=ap and cn+cy>ap and co+ag==aq then self:setValue(cs[ag+cx])return true end end end end end;if aL=="mouse_scroll"then cx=cx+c2;if cx<0 then cx=0 end;if c2==1 then if#cs>cz then if cx>#cs-cz then cx=#cs-cz end else cx=cs-1 end end;return true end;self:setVisualChanged()end;if cj.mouseClickHandler(self,aL,c2,ap,aq)then cC=true else cC=false end end,draw=function(self)if cj.draw(self)then local cn,co=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)local cG=self:getValue()local ar=aZ(cG~=nil and cG.text or"",self.width,cw):sub(1,self.width-1)..(cC and cB or cA)self.parent:writeText(cn,co,ar,self.bgColor,self.fgColor)if cC then for ag=1,cz do if cs[ag+cx]~=nil then if cs[ag+cx]==cG then if cv then self.parent:writeText(cn,co+ag,aZ(cs[ag+cx].text,cy,cw),ct,cu)else self.parent:writeText(cn,co+ag,aZ(cs[ag+cx].text,cy,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end else self.parent:writeText(cn,co+ag,aZ(cs[ag+cx].text,cy,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cH(bF)local cj=bE(bF)local bG="Image"cj:setZIndex(2)local cI;local cJ;local cK=false;local function b6()local b9={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local ba,bb,bc={},{},{}for o=0,15 do bb[2^o]=o end;do local bd="0123456789abcdef"for o=1,16 do ba[bd:sub(o,o)]=o-1;ba[o-1]=bd:sub(o,o)bc[bd:sub(o,o)]=2^(o-1)bc[2^(o-1)]=bd:sub(o,o)local be=b9[o-1]for o=1,#be do be[o]=2^be[o]end end end;local function bf(bg)local bh=b9[bb[bg[#bg][1]]]for p=1,#bh do local bi=bh[p]for o=1,#bg-1 do if bg[o][1]==bi then return o end end end;return 1 end;local function bj(bk,bl)if not bl then local bm={}bl={}for o=1,6 do local bn=bk[o]local bo=bl[bn]bl[bn],bm[o]=bo and bo+1 or 1,bn end;bk=bm end;local bg={}for bp,aP in pairs(bl)do bg[#bg+1]={bp,aP}end;if#bg>1 then while#bg>2 do table.sort(bg,function(bq,br)return bq[2]>br[2]end)local bs,bt=bf(bg),#bg;local bu,bv=bg[bt][1],bg[bs][1]for o=1,6 do if bk[o]==bu then bk[o]=bv;bg[bs][2]=bg[bs][2]+1 end end;bg[bt]=nil end;local bw=128;for o=1,#bk-1 do if bk[o]~=bk[6]then bw=bw+2^(o-1)end end;return string.char(bw),bc[bg[1][1]==bk[6]and bg[2][1]or bg[1][1]],bc[bk[6]]else return"\128",bc[bk[1]],bc[bk[1]]end end;local bx,a6,m,aB={{},{},{}},0,#cI+#cI%3,cj.bgColor or colors.black;for o=1,#cI do if#cI[o]>a6 then a6=#cI[o]end end;for aq=0,m-1,3 do local by,bz,bA,bB={},{},{},1;for ap=0,a6-1,2 do local bk,bl={},{}for bC=1,3 do for bD=1,2 do bk[#bk+1]=cI[aq+bC]and cI[aq+bC][ap+bD]and(cI[aq+bC][ap+bD]==0 and aB or cI[aq+bC][ap+bD])or aB;bl[bk[#bk]]=bl[bk[#bk]]and bl[bk[#bk]]+1 or 1 end end;by[bB],bz[bB],bA[bB]=bj(bk,bl)bB=bB+1 end;bx[1][#bx[1]+1],bx[2][#bx[2]+1],bx[3][#bx[3]+1]=table.concat(by),table.concat(bz),table.concat(bA)end;bx.width,bx.height=#bx[1][1],#bx[1]cJ=bx end;local bO={getType=function(self)return bG end,loadImage=function(self,aT)cI=paintutils.loadImage(aT)cK=false;return self end,loadBlittleImage=function(self,aT)cK=true;return self end,shrink=function(self)b6()cK=true;return self end,draw=function(self)if cj.draw(self)then if self.parent~=nil then if cI~=nil then local cn,co=self:getAnchorPosition()if cK then local b5,cL,cM=cJ[1],cJ[2],cJ[3]for o=1,cJ.height do local cN=b5[o]if type(cN)=="string"then self.parent:setText(cn,co+o-1,cN)self.parent:setFG(cn,co+o-1,cL[o])self.parent:setBG(cn,co+o-1,cM[o])elseif type(cN)=="table"then self.parent:setText(cn,co+o-1,cN[2])self.parent:setFG(cn,co+o-1,cL[o])self.parent:setBG(cn,co+o-1,cM[o])end end else for bT=1,math.min(#cI,self.height)do local cO=cI[bT]for bS=1,math.min(#cO,self.width)do if cO[bS]>0 then self.parent:drawBackgroundBox(cn+bS-1,co+bT-1,1,1,cO[bS])end end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function cP(bF)local cj=bE(bF)local bG="Input"local cQ="text"local cR=0;cj:setZIndex(5)cj:setValue("")cj.width=10;cj.height=1;cj.bgColor=h.InputBG;cj.fgColor=h.InputFG;local cS=1;local cT=1;local cU=""local cV;local cW;local cX=cU;local cY=false;local bO={getType=function(self)return bG end,setInputType=function(self,cZ)if cZ=="password"or cZ=="number"or cZ=="text"then cQ=cZ end;return self end,setDefaultText=function(self,ar,c_,d0)cU=ar;cV=d0 or cV;cW=c_ or cW;if self:isFocused()then cX=""else cX=cU end;return self end,getInputType=function(self)return cQ end,setValue=function(self,cG)cj.setValue(self,tostring(cG))if not cY then cS=tostring(cG):len()+1 end;return self end,getValue=function(self)local cG=cj.getValue(self)return cQ=="number"and tonumber(cG)or cG end,setInputLimit=function(self,d1)cR=tonumber(d1)or cR;return self end,getInputLimit=function(self)return cR end,getFocusHandler=function(self)cj.getFocusHandler(self)if self.parent~=nil then local cn,co=self:getAnchorPosition()cX=""if self.parent~=nil then self.parent:setCursor(true,cn+cS-cT,co,self.fgColor)end end end,loseFocusHandler=function(self)cj.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)cX=cU end end,keyHandler=function(self,aL,bp)if cj.keyHandler(self,aL,bp)then cY=true;if aL=="key"then if bp==keys.backspace then local ar=tostring(cj.getValue())if cS>1 then self:setValue(ar:sub(1,cS-2)..ar:sub(cS,ar:len()))if cS>1 then cS=cS-1 end;if cT>1 then if cSd2 then cS=d2+1 end;if cS<1 then cS=1 end;if cS=self.width+cT then cT=cS-self.width+1 end;if cT<1 then cT=1 end end;if bp==keys.left then cS=cS-1;if cS>=1 then if cS=self.width+cT then cT=cS end end;if cS<1 then cS=1 end;if cT<1 then cT=1 end end end;if aL=="char"then local ar=cj.getValue()if ar:len()=self.width+cT then cT=cT+1 end end end;local cn,co=self:getAnchorPosition()local cG=tostring(cj.getValue())local d4=(cS<=cG:len()and cS-1 or cG:len())-(cT-1)if d4>self.x+self.width-1 then d4=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,cn+d4,co,self.fgColor)end;cY=false end end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then if aL=="mouse_click"and c2==1 then end;return true end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,"center")self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)for ag=1,self.height do if ag==cp then local cG=tostring(cj.getValue())local d0=self.bgColor;local c_=self.fgColor;local ar;if cG:len()<=0 then ar=cX;d0=cV or d0;c_=cW or c_ end;ar=cX;if cG~=""then ar=cG end;ar=ar:sub(cT,self.width+cT-1)local d5=self.width-ar:len()if d5<0 then d5=0 end;if cQ=="password"and cG~=""then ar=string.rep("*",ar:len())end;ar=ar..string.rep(" ",d5)self.parent:writeText(cn,co+ag-1,ar,d0,c_)end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function d6(bF)local cj=bE(bF)local bG="Label"cj:setZIndex(3)cj.fgColor=colors.white;cj.bgcolor=colors.black;local d7=true;cj:setValue("")local ck="left"local cl="top"local d8=0;local bO={getType=function(self)return bG end,setText=function(self,ar)ar=tostring(ar)cj:setValue(ar)if d7 then self.width=ar:len()end;return self end,setTextAlign=function(self,d9,da)ck=d9 or ck;cl=da or cl;self:setVisualChanged()return self end,setFontSize=function(self,u)if u>0 and u<=4 then d8=u-1 or 0 end;return self end,getFontSize=function(self)return d8+1 end,setSize=function(self,a6,m)cj.setSize(self,a6,m)d7=false;self:setVisualChanged()return self end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()local cp=b2(self.height,cl)self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)self.parent:drawTextBox(cn,co,self.width,self.height," ")if d8==0 then for ag=1,self.height do if ag==cp then self.parent:writeText(cn,co+ag-1,aZ(self:getValue(),self.width,ck),self.bgColor,self.fgColor)end end else local db=K(d8,self:getValue(),self.fgColor,self.bgColor)if d7 then self.height=#db[1]-1;self.width=#db[1][1]end;for ag=1,self.height do if ag==cp then local dc,dd=self.parent:getSize()local de,df=#db[1][1],#db[1]cn=cn or math.floor((dc-de)/2)+1;co=co or math.floor((dd-df)/2)+1;for o=1,df do self.parent:setFG(cn,co+o+ag-2,aZ(db[2][o],self.width,ck))self.parent:setBG(cn,co+o+ag-2,aZ(db[3][o],self.width,ck,g[self.bgColor]))self.parent:setText(cn,co+o+ag-2,aZ(db[1][o],self.width,ck))end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function dg(bF)local cj=bE(bF)local bG="List"cj.width=16;cj.height=6;cj.bgColor=h.listBG;cj.fgColor=h.listFG;cj:setZIndex(5)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local cv=true;local cw="left"local cx=0;local dh=true;local bO={getType=function(self)return bG end,addItem=function(self,ar,aB,aC,...)table.insert(cs,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})if#cs==1 then self:setValue(cs[1])end;return self end,setIndexOffset=function(self,cD)cx=cD;return self end,getIndexOffset=function(self)return cx end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getAll=function(self)return cs end,getItemIndex=function(self)local cE=self:getValue()for bp,aP in pairs(cs)do if aP==cE then return bp end end end,clear=function(self)cs={}self:setValue({})return self end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,cF)ct=aB or self.bgColor;cu=aC or self.fgColor;cv=cF;return self end,setScrollable=function(self,di)dh=di;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if cn<=ap and cn+self.width>ap and co<=aq and co+self.height>aq and self:isVisible()then if(aL=="mouse_click"or aL=="mouse_drag")and c2==1 or aL=="monitor_touch"then if#cs>0 then for ag=1,self.height do if cs[ag+cx]~=nil then if cn<=ap and cn+self.width>ap and co+ag-1==aq then self:setValue(cs[ag+cx])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,ap,aq,cs[ag+cx])end end end end end;if aL=="mouse_scroll"and dh then cx=cx+c2;if cx<0 then cx=0 end;if c2>=1 then if#cs>self.height then if cx>#cs-self.height then cx=#cs-self.height end;if cx>=#cs then cx=#cs-1 end else cx=cx-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)for ag=1,self.height do if cs[ag+cx]~=nil then if cs[ag+cx]==self:getValue()then if cv then self.parent:writeText(cn,co+ag-1,aZ(cs[ag+cx].text,self.width,cw),ct,cu)else self.parent:writeText(cn,co+ag-1,aZ(cs[ag+cx].text,self.width,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end else self.parent:writeText(cn,co+ag-1,aZ(cs[ag+cx].text,self.width,cw),cs[ag+cx].bgCol,cs[ag+cx].fgCol)end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function dj(bF)local cj=bE(bF)local bG="Menubar"local bO={}cj.width=30;cj.height=1;cj.bgColor=colors.gray;cj.fgColor=colors.lightGray;cj:setZIndex(5)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local cv=true;local cw="left"local dk=0;local d5=1;local dh=false;local function dl()local dm=0;local bS=0;for ag=1,#cs do if bS+cs[ag].text:len()+d5*2>bO.width then if bSdm then dk=dm end;return self end,getPositionOffset=function(self)return dk end,setScrollable=function(self,di)dh=di;if di==nil then dh=true end;return self end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,cF)ct=aB or self.bgColor;cu=aC or self.fgColor;cv=cF;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local c3,c4=self:getAbsolutePosition(self:getAnchorPosition())if c3<=ap and c3+self.width>ap and c4<=aq and c4+self.height>aq and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if aL=="mouse_click"or aL=="monitor_touch"then local bS=0;for ag=1,#cs do if cs[ag]~=nil then if c3+bS<=ap+dk and c3+bS+cs[ag].text:len()+d5*2>ap+dk and c4==aq then self:setValue(cs[ag])self:getEventSystem():sendEvent(aL,self,aL,0,ap,aq,cs[ag])end;bS=bS+cs[ag].text:len()+d5*2 end end end;if aL=="mouse_scroll"and dh then dk=dk+c2;if dk<0 then dk=0 end;local dm=dl()if dk>dm then dk=dm end end;self:setVisualChanged(true)return true end end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)local ar=""local dp=""local dq=""for aO,dr in pairs(cs)do local ds=(" "):rep(d5)..dr.text..(" "):rep(d5)ar=ar..ds;if dr==self:getValue()then dp=dp..g[ct or dr.bgCol or self.bgColor]:rep(ds:len())dq=dq..g[cu or dr.FgCol or self.fgColor]:rep(ds:len())else dp=dp..g[dr.bgCol or self.bgColor]:rep(ds:len())dq=dq..g[dr.FgCol or self.fgColor]:rep(ds:len())end end;self.parent:setText(cn,co,ar:sub(dk+1,self.width+dk))self.parent:setBG(cn,co,dp:sub(dk+1,self.width+dk))self.parent:setFG(cn,co,dq:sub(dk+1,self.width+dk))end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function dt(bF)local cj=bE(bF)local bG="Pane"local bO={getType=function(self)return bG end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.bgColor)end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function du(bF)local cj=bE(bF)local bG="Program"cj:setZIndex(5)local bO;local function dv(ap,aq,a6,m)local dw,dx=1,1;local b8,dy=colors.black,colors.white;local dz=false;local dA=false;local a7={}local a8={}local a9={}local dB={}local ad;local ae={}for o=0,15 do local dC=2^o;dB[dC]={e.getPaletteColour(dC)}end;local function af()ad=(" "):rep(a6)for ag=0,15 do local ah=2^ag;local ai=g[ah]ae[ah]=ai:rep(a6)end end;local function aj()af()local ak=ad;local al=ae[colors.white]local am=ae[colors.black]for ag=1,m do a7[ag]=f(a7[ag]==nil and ak or a7[ag]..ak:sub(1,a6-a7[ag]:len()),1,a6)a9[ag]=f(a9[ag]==nil and al or a9[ag]..al:sub(1,a6-a9[ag]:len()),1,a6)a8[ag]=f(a8[ag]==nil and am or a8[ag]..am:sub(1,a6-a8[ag]:len()),1,a6)end end;aj()local function dD()if dw>=1 and dx>=1 and dw<=a6 and dx<=m then else end end;local function dE(dF,dG,dH)local dI=dw;local au=dI+#dF-1;if dx>=1 and dx<=m then if dI<=a6 and au>=1 then if dI==1 and au==a6 then a7[dx]=dF;a9[dx]=dG;a8[dx]=dH else local dJ,dK,dL;if dI<1 then local dM=1-dI+1;local dN=a6-dI+1;dJ=f(dF,dM,dN)dK=f(dG,dM,dN)dL=f(dH,dM,dN)elseif au>a6 then local dN=a6-dI+1;dJ=f(dF,1,dN)dK=f(dG,1,dN)dL=f(dH,1,dN)else dJ=dF;dK=dG;dL=dH end;local dO=a7[dx]local dP=a9[dx]local dQ=a8[dx]local dR,dS,dT;if dI>1 then local dU=dI-1;dR=f(dO,1,dU)..dJ;dS=f(dP,1,dU)..dK;dT=f(dQ,1,dU)..dL else dR=dJ;dS=dK;dT=dL end;if au=1 and aq<=m then a7[eg]=a7[aq]a8[eg]=a8[aq]a9[eg]=a9[aq]else a7[eg]=ed;a9[eg]=ee;a8[eg]=ef end end end;if dA then dD()end end,isColor=function()return e.isColor()end,isColour=function()return e.isColor()end,write=function(ar)ar=tostring(ar)if dA then dE(ar,g[dy]:rep(ar:len()),g[b8]:rep(ar:len()))end end,clearLine=function()if dA then ao(1,dx,(" "):rep(a6))ax(1,dx,g[b8]:rep(a6))az(1,dx,g[dy]:rep(a6))end;if dA then dD()end end,clear=function()for ag=1,m do ao(1,ag,(" "):rep(a6))ax(1,ag,g[b8]:rep(a6))az(1,ag,g[dy]:rep(a6))end;if dA then dD()end end,blit=function(ar,eh,ei)if type(ar)~="string"then error("bad argument #1 (expected string, got "..type(ar)..")",2)end;if type(eh)~="string"then error("bad argument #2 (expected string, got "..type(eh)..")",2)end;if type(ei)~="string"then error("bad argument #3 (expected string, got "..type(ei)..")",2)end;if#eh~=#ar or#ei~=#ar then error("Arguments must be the same length",2)end;if dA then dE(ar,eh,ei)end end}return e8 end;cj.width=30;cj.height=12;local ej=dv(1,1,cj.width,cj.height)local ek;local el=false;local em={}bO={getType=function(self)return bG end,show=function(self)cj.show(self)ej.setBackgroundColor(self.bgColor)ej.setTextColor(self.fgColor)ej.basalt_setVisible(true)return self end,hide=function(self)cj.hide(self)ej.basalt_setVisible(false)return self end,setPosition=function(self,ap,aq,bU)cj.setPosition(self,ap,aq,bU)ej.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return ej end,getBasaltProcess=function()return ek end,setSize=function(self,a6,m)cj.setSize(self,a6,m)ej.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if ek~=nil then return ek:getStatus()end;return"inactive"end,execute=function(self,aT,...)ek=aR:new(aT,ej,...)ej.setBackgroundColor(colors.black)ej.setTextColor(colors.white)ej.clear()ej.setCursorPos(1,1)ek:resume()el=false;return self end,stop=function(self)if ek~=nil then if not ek:isDead()then ek:resume("terminate")if ek:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,en)el=en or not el;if ek~=nil then if not ek:isDead()then if not el then self:injectEvents(em)em={}end end end;return self end,isPaused=function(self)return el end,injectEvent=function(self,aL,c5,c6,c7,c8,eo)if ek~=nil then if not ek:isDead()then if el==false or eo then ek:resume(aL,c5,c6,c7,c8)else table.insert(em,{event=aL,args={c5,c6,c7,c8}})end end end;return self end,getQueuedEvents=function(self)return em end,updateQueuedEvents=function(self,aJ)em=aJ or em;return self end,injectEvents=function(self,aJ)if ek~=nil then if not ek:isDead()then for aO,aP in pairs(aJ)do ek:resume(aP.event,table.unpack(aP.args))end end end;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then if ek==nil then return false end;if not ek:isDead()then if not el then local ep,eq=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))ek:resume(aL,c2,ap-ep+1,aq-eq+1)end end;return true end end,keyHandler=function(self,aL,bp)cj.keyHandler(self,aL,bp)if self:isFocused()then if ek==nil then return false end;if not ek:isDead()then if not el then if self.draw then ek:resume(aL,bp)end end end end end,getFocusHandler=function(self)cj.getFocusHandler(self)if ek~=nil then if not ek:isDead()then if not el then if self.parent~=nil then local er,es=ej.getCursorPos()local cn,co=self:getAnchorPosition()if self.parent~=nil then if cn+er-1>=1 and cn+er-1<=cn+self.width-1 and es+co-1>=1 and es+co-1<=co+self.height-1 then self.parent:setCursor(ej.getCursorBlink(),cn+er-1,es+co-1,ej.getTextColor())end end end end end end end,loseFocusHandler=function(self)cj.loseFocusHandler(self)if ek~=nil then if not ek:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,aL,c5,c6,c7,c8)if ek==nil then return end;if not ek:isDead()then if not el then if aL~="mouse_click"and aL~="monitor_touch"and aL~="mouse_up"and aL~="mouse_scroll"and aL~="mouse_drag"and aL~="key_up"and aL~="key"and aL~="char"and aL~="terminate"then ek:resume(aL,c5,c6,c7,c8)end;if self:isFocused()then local cn,co=self:getAnchorPosition()local er,es=ej.getCursorPos()if self.parent~=nil then if cn+er-1>=1 and cn+er-1<=cn+self.width-1 and es+co-1>=1 and es+co-1<=co+self.height-1 then self.parent:setCursor(ej.getCursorBlink(),cn+er-1,es+co-1,ej.getTextColor())end end;if aL=="terminate"and self:isFocused()then self:stop()end end else if aL~="mouse_click"and aL~="monitor_touch"and aL~="mouse_up"and aL~="mouse_scroll"and aL~="mouse_drag"and aL~="key_up"and aL~="key"and aL~="char"and aL~="terminate"then table.insert(em,{event=aL,args={c5,c6,c7,c8}})end end end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()ej.basalt_reposition(cn,co)self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)ej.basalt_update()end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function et(bF)local cj=bE(bF)local bG="Progressbar"local eu=0;cj:setZIndex(5)cj:setValue(false)cj.width=25;cj.height=1;cj.bgColor=h.CheckboxBG;cj.fgColor=h.CheckboxFG;local ev=colors.black;local ew=""local ex=colors.white;local ey=""local ez=0;local bO={getType=function(self)return bG end,setDirection=function(self,eA)ez=eA;return self end,setProgressBar=function(self,bW,aD,eB)ev=bW or ev;ew=aD or ew;ex=eB or ex;return self end,setBackgroundSymbol=function(self,aD)ey=aD:sub(1,1)return self end,setProgress=function(self,aP)if aP>=0 and aP<=100 and eu~=aP then eu=aP;self:setValue(eu)if eu==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return eu end,onProgressDone=function(self,x)self:registerEvent("progress_done",x)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)self.parent:drawTextBox(cn,co,self.width,self.height,ey)if ez==1 then self.parent:drawBackgroundBox(cn,co,self.width,self.height/100*eu,ev)self.parent:drawForegroundBox(cn,co,self.width,self.height/100*eu,ex)self.parent:drawTextBox(cn,co,self.width,self.height/100*eu,ew)elseif ez==2 then self.parent:drawBackgroundBox(cn,co+math.ceil(self.height-self.height/100*eu),self.width,self.height/100*eu,ev)self.parent:drawForegroundBox(cn,co+math.ceil(self.height-self.height/100*eu),self.width,self.height/100*eu,ex)self.parent:drawTextBox(cn,co+math.ceil(self.height-self.height/100*eu),self.width,self.height/100*eu,ew)elseif ez==3 then self.parent:drawBackgroundBox(cn+math.ceil(self.width-self.width/100*eu),co,self.width/100*eu,self.height,ev)self.parent:drawForegroundBox(cn+math.ceil(self.width-self.width/100*eu),co,self.width/100*eu,self.height,ex)self.parent:drawTextBox(cn+math.ceil(self.width-self.width/100*eu),co,self.width/100*eu,self.height,ew)else self.parent:drawBackgroundBox(cn,co,self.width/100*eu,self.height,ev)self.parent:drawForegroundBox(cn,co,self.width/100*eu,self.height,ex)self.parent:drawTextBox(cn,co,self.width/100*eu,self.height,ew)end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eC(bF)local cj=bE(bF)local bG="Radio"cj.width=8;cj.bgColor=h.listBG;cj.fgColor=h.listFG;cj:setZIndex(5)local cs={}local ct=h.selectionBG;local cu=h.selectionFG;local eD=cj.bgColor;local eE=cj.fgColor;local cv=true;local aD="\7"local cw="left"local bO={getType=function(self)return bG end,addItem=function(self,ar,ap,aq,aB,aC,...)table.insert(cs,{x=ap or 1,y=aq or 1,text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})if#cs==1 then self:setValue(cs[1])end;return self end,getAll=function(self)return cs end,removeItem=function(self,aK)table.remove(cs,aK)return self end,getItem=function(self,aK)return cs[aK]end,getItemIndex=function(self)local cE=self:getValue()for bp,aP in pairs(cs)do if aP==cE then return bp end end end,clear=function(self)cs={}self:setValue({})return self end,getItemCount=function(self)return#cs end,editItem=function(self,aK,ar,ap,aq,aB,aC,...)table.remove(cs,aK)table.insert(cs,aK,{x=ap or 1,y=aq or 1,text=ar,bgCol=aB or self.bgColor,fgCol=aC or self.fgColor,args={...}})return self end,selectItem=function(self,aK)self:setValue(cs[aK]or{})return self end,setSelectedItem=function(self,aB,aC,eF,eG,cF)ct=aB or ct;cu=aC or cu;eD=eF or eD;eE=eG or eE;cv=cF;return self end,mouseClickHandler=function(self,aL,c2,ap,aq)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then if#cs>0 then for aO,aP in pairs(cs)do if cn+aP.x-1<=ap and cn+aP.x-1+aP.text:len()+2>=ap and co+aP.y-1==aq then self:setValue(aP)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end;return false end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()for aO,aP in pairs(cs)do if aP==self:getValue()then if cw=="left"then self.parent:writeText(aP.x+cn-1,aP.y+co-1,aD,eD,eE)self.parent:writeText(aP.x+2+cn-1,aP.y+co-1,aP.text,ct,cu)end else self.parent:drawBackgroundBox(aP.x+cn-1,aP.y+co-1,1,1,self.bgColor)self.parent:writeText(aP.x+2+cn-1,aP.y+co-1,aP.text,aP.bgCol,aP.fgCol)end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eH(bF)local cj=bE(bF)local bG="Scrollbar"cj.width=1;cj.height=8;cj.bgColor=colors.lightGray;cj.fgColor=colors.gray;cj:setValue(1)cj:setZIndex(2)local eI="vertical"local aD=" "local eJ=colors.black;local eK="\127"local eL=cj.height;local aK=1;local eM=1;local bO={getType=function(self)return bG end,setSymbol=function(self,eN)aD=eN:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,u)eM=tonumber(u)or 1;if eI=="vertical"then self:setValue(aK-1*eL/(self.height-(eM-1))-eL/(self.height-(eM-1)))elseif eI=="horizontal"then self:setValue(aK-1*eL/(self.width-(eM-1))-eL/(self.width-(eM-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,cG)eL=cG;return self end,setBackgroundSymbol=function(self,eO)eK=string.sub(eO,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eP)eJ=eP;self:setVisualChanged()return self end,setBarType=function(self,eQ)eI=eQ:lower()return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if(aL=="mouse_click"or aL=="mouse_drag")and c2==1 or aL=="monitor_touch"then if eI=="horizontal"then for eR=0,self.width do if cn+eR==ap and co<=aq and co+self.height>aq then aK=math.min(eR+1,self.width-(eM-1))self:setValue(eL/self.width*aK)self:setVisualChanged()end end end;if eI=="vertical"then for eR=0,self.height do if co+eR==aq and cn<=ap and cn+self.width>ap then aK=math.min(eR+1,self.height-(eM-1))self:setValue(eL/self.height*aK)self:setVisualChanged()end end end end;if aL=="mouse_scroll"then aK=aK+c2;if aK<1 then aK=1 end;aK=math.min(aK,(eI=="vertical"and self.height or self.width)-(eM-1))self:setValue(eL/(eI=="vertical"and self.height or self.width)*aK)end;return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()if eI=="horizontal"then self.parent:writeText(cn,co,eK:rep(aK-1),self.bgColor,self.fgColor)self.parent:writeText(cn+aK-1,co,aD:rep(eM),eJ,eJ)self.parent:writeText(cn+aK+eM-1,co,eK:rep(self.width-(aK+eM-1)),self.bgColor,self.fgColor)end;if eI=="vertical"then for ag=0,self.height-1 do if aK==ag+1 then for eS=0,math.min(eM-1,self.height)do self.parent:writeText(cn,co+ag+eS,aD,eJ,eJ)end else if ag+1aK-1+eM then self.parent:writeText(cn,co+ag,eK,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eT(bF)local cj=bE(bF)local bG="Slider"cj.width=8;cj.height=1;cj.bgColor=colors.lightGray;cj.fgColor=colors.gray;cj:setValue(1)local eI="horizontal"local aD=" "local eJ=colors.black;local eK="\140"local eL=cj.width;local aK=1;local eM=1;local bO={getType=function(self)return bG end,setSymbol=function(self,eN)aD=eN:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,u)eM=tonumber(u)or 1;if eI=="vertical"then self:setValue(aK-1*eL/(self.height-(eM-1))-eL/(self.height-(eM-1)))elseif eI=="horizontal"then self:setValue(aK-1*eL/(self.width-(eM-1))-eL/(self.width-(eM-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,cG)eL=cG;return self end,setBackgroundSymbol=function(self,eO)eK=string.sub(eO,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eP)eJ=eP;self:setVisualChanged()return self end,setBarType=function(self,eQ)eI=eQ:lower()return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if(aL=="mouse_click"or aL=="mouse_drag")and c2==1 or aL=="monitor_touch"then if eI=="horizontal"then for eR=0,self.width do if cn+eR==ap and co<=aq and co+self.height>aq then aK=math.min(eR+1,self.width-(eM-1))self:setValue(eL/self.width*aK)self:setVisualChanged()end end end;if eI=="vertical"then for eR=0,self.height do if co+eR==aq and cn<=ap and cn+self.width>ap then aK=math.min(eR+1,self.height-(eM-1))self:setValue(eL/self.height*aK)self:setVisualChanged()end end end end;if aL=="mouse_scroll"then aK=aK+c2;if aK<1 then aK=1 end;aK=math.min(aK,(eI=="vertical"and self.height or self.width)-(eM-1))self:setValue(eL/(eI=="vertical"and self.height or self.width)*aK)end;return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()if eI=="horizontal"then self.parent:writeText(cn,co,eK:rep(aK-1),self.bgColor,self.fgColor)self.parent:writeText(cn+aK-1,co,aD:rep(eM),eJ,eJ)self.parent:writeText(cn+aK+eM-1,co,eK:rep(self.width-(aK+eM-1)),self.bgColor,self.fgColor)end;if eI=="vertical"then for ag=0,self.height-1 do if aK==ag+1 then for eS=0,math.min(eM-1,self.height)do self.parent:writeText(cn,co+ag+eS,aD,eJ,eJ)end else if ag+1aK-1+eM then self.parent:writeText(cn,co+ag,eK,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eU(bF)local cj=bE(bF)local bG="Switch"cj.width=2;cj.height=1;cj.bgColor=colors.lightGray;cj.fgColor=colors.gray;cj:setValue(false)cj:setZIndex(5)local eK=colors.black;local eV=colors.red;local eW=colors.green;local bO={getType=function(self)return bG end,setSymbolColor=function(self,eJ)eK=eJ;self:setVisualChanged()return self end,setActiveBackground=function(self,ei)eW=ei;self:setVisualChanged()return self end,setInactiveBackground=function(self,ei)eV=ei;self:setVisualChanged()return self end,mouseClickHandler=function(self,aL,c2,ap,aq)if cj.mouseClickHandler(self,aL,c2,ap,aq)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aL=="mouse_click"and c2==1 or aL=="monitor_touch"then self:setValue(not self:getValue())end;return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)if self:getValue()then self.parent:drawBackgroundBox(cn,co,1,self.height,eW)self.parent:drawBackgroundBox(cn+1,co,1,self.height,eK)else self.parent:drawBackgroundBox(cn,co,1,self.height,eK)self.parent:drawBackgroundBox(cn+1,co,1,self.height,eV)end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function eX(bF)local cj=bE(bF)local bG="Textfield"local eY,cT,cS,eZ=1,1,1,1;local e_={""}local f0={[colors.purple]={"break"}}cj.width=20;cj.height=8;cj.bgColor=h.textfieldBG;cj.fgColor=h.textfieldFG;cj:setZIndex(5)local bO={getType=function(self)return bG end,getLines=function(self)return e_ end,getLine=function(self,aK)return e_[aK]or""end,editLine=function(self,aK,ar)e_[aK]=ar or e_[aK]return self end,addLine=function(self,ar,aK)if aK~=nil then table.insert(e_,aK,ar)else table.insert(e_,ar)end;return self end,addKeyword=function(self,f1,bW)end,removeLine=function(self,aK)table.remove(e_,aK or#e_)if#e_<=0 then table.insert(e_,"")end;return self end,getTextCursor=function(self)return cS,eZ end,getFocusHandler=function(self)cj.getFocusHandler(self)if self.parent~=nil then local cn,co=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,cn+cS-cT,co+eZ-eY,self.fgColor)end end end,loseFocusHandler=function(self)cj.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,aL,bp)if cj.keyHandler(self,aL,bp)then local cn,co=self:getAnchorPosition()if aL=="key"then if bp==keys.backspace then if e_[eZ]==""then if eZ>1 then table.remove(e_,eZ)cS=e_[eZ-1]:len()+1;cT=cS-self.width+1;if cT<1 then cT=1 end;eZ=eZ-1 end elseif cS<=1 then if eZ>1 then cS=e_[eZ-1]:len()+1;cT=cS-self.width+1;if cT<1 then cT=1 end;e_[eZ-1]=e_[eZ-1]..e_[eZ]table.remove(e_,eZ)eZ=eZ-1 end else e_[eZ]=e_[eZ]:sub(1,cS-2)..e_[eZ]:sub(cS,e_[eZ]:len())if cS>1 then cS=cS-1 end;if cT>1 then if cSe_[eZ]:len()then if e_[eZ+1]~=nil then e_[eZ]=e_[eZ]..e_[eZ+1]table.remove(e_,eZ+1)end else e_[eZ]=e_[eZ]:sub(1,cS-1)..e_[eZ]:sub(cS+1,e_[eZ]:len())end end;if bp==keys.enter then table.insert(e_,eZ+1,e_[eZ]:sub(cS,e_[eZ]:len()))e_[eZ]=e_[eZ]:sub(1,cS-1)eZ=eZ+1;cS=1;cT=1;if eZ-eY>=self.height then eY=eY+1 end;self:setValue("")end;if bp==keys.up then if eZ>1 then eZ=eZ-1;if cS>e_[eZ]:len()+1 then cS=e_[eZ]:len()+1 end;if cT>1 then if cS1 then if eZe_[eZ]:len()+1 then cS=e_[eZ]:len()+1 end;if eZ>=eY+self.height then eY=eY+1 end end end;if bp==keys.right then cS=cS+1;if eZ<#e_ then if cS>e_[eZ]:len()+1 then cS=1;eZ=eZ+1 end elseif cS>e_[eZ]:len()then cS=e_[eZ]:len()+1 end;if cS<1 then cS=1 end;if cS=self.width+cT then cT=cS-self.width+1 end;if cT<1 then cT=1 end end;if bp==keys.left then cS=cS-1;if cS>=1 then if cS=self.width+cT then cT=cS end end;if eZ>1 then if cS<1 then eZ=eZ-1;cS=e_[eZ]:len()+1;cT=cS-self.width+1 end end;if cS<1 then cS=1 end;if cT<1 then cT=1 end end end;if aL=="char"then e_[eZ]=e_[eZ]:sub(1,cS-1)..bp..e_[eZ]:sub(cS,e_[eZ]:len())cS=cS+1;if cS>=self.width+cT then cT=cT+1 end;self:setValue("")end;local d4=(cS<=e_[eZ]:len()and cS-1 or e_[eZ]:len())-(cT-1)if d4>self.x+self.width-1 then d4=self.x+self.width-1 end;local f2=eZ-eYe_[eZ]:len()then cS=e_[eZ]:len()+1 end;if cSe_[eZ]:len()then cS=e_[eZ]:len()+1 end;if cS#e_-(self.height-1)then eY=#e_-(self.height-1)end;if eY<1 then eY=1 end;if self.parent~=nil then if cn+cS-cT>=cn and cn+cS-cT<=cn+self.width and(co+eZ-eY>=co and co+eZ-eY<=co+self.height)then self.parent:setCursor(true,f3+cS-cT,f4+eZ-eY)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if cj.draw(self)then if self.parent~=nil then local cn,co=self:getAnchorPosition()self.parent:drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cn,co,self.width,self.height,self.fgColor)for ag=1,self.height do local ar=""if e_[ag+eY-1]~=nil then ar=e_[ag+eY-1]end;ar=ar:sub(cT,self.width+cT-1)local d5=self.width-ar:len()if d5<0 then d5=0 end;ar=ar..string.rep(" ",d5)self.parent:setText(cn,co+ag-1,ar)end end;self:setVisualChanged(false)end end}return setmetatable(bO,cj)end;local function f5(bF)local bO;local bG="Thread"local aN;local f6;local f7=false;bO={name=bF,getType=function(self)return bG end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,x)if x==nil then error("Function provided to thread is nil")end;aN=x;f6=coroutine.create(aN)f7=true;local aX,aY=coroutine.resume(f6)if not aX then if aY~="Terminated"then error("Thread Error Occurred - "..aY)end end;return self end,getStatus=function(self,x)if f6~=nil then return coroutine.status(f6)end;return nil end,stop=function(self,x)f7=false;return self end,eventHandler=function(self,aL,c5,c6,c7)if f7 then if coroutine.status(f6)~="dead"then local aX,aY=coroutine.resume(f6,aL,c5,c6,c7)if not aX then if aY~="Terminated"then error("Thread Error Occurred - "..aY)end end else f7=false end end end}bO.__index=bO;return bO end;local function f8(bF)local bG="Timer"local f9=0;local fa=0;local fb=0;local ca;local bN=aI()local fc=false;local bO={name=bF,getType=function(self)return bG end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,fd,fe)f9=fd or 0;fa=fe or 1;return self end,start=function(self)if fc then os.cancelTimer(ca)end;fb=fa;ca=os.startTimer(f9)fc=true;return self end,isActive=function(self)return fc end,cancel=function(self)if ca~=nil then os.cancelTimer(ca)end;fc=false;return self end,onCall=function(self,aN)bN:registerEvent("timed_event",aN)return self end,eventHandler=function(self,aL,ch)if aL=="timer"and ch==ca and fc then bN:sendEvent("timed_event",self)if fb>=1 then fb=fb-1;if fb>=1 then ca=os.startTimer(f9)end elseif fb==-1 then ca=os.startTimer(f9)end end end}bO.__index=bO;return bO end;local function ff(bF,fg)local cj=bE(bF)local bG="Frame"local fh={}local fi={}local bO={}local fj;local fk=e;local fl={}local fm=false;cj:setZIndex(10)local aA=a3(fk)local dz=false;local dw=1;local dx=1;local fn=colors.white;local fo,cx=0,0;if fg~=nil then cj.parent=fg;cj.width,cj.height=fg:getSize()cj.bgColor=h.FrameBG;cj.fgColor=h.FrameFG else cj.width,cj.height=fk.getSize()cj.bgColor=h.basaltBG;cj.fgColor=h.basaltFG end;local function fp(bF)for aO,aP in pairs(fh)do for aO,br in pairs(aP)do if br.name==bF then return aP end end end end;local function fq(fr)local bH=fr:getZIndex()if fp(fr.name)~=nil then return nil end;if fh[bH]==nil then for ap=1,#fi+1 do if fi[ap]~=nil then if bH==fi[ap]then break end;if bH>fi[ap]then table.insert(fi,ap,bH)break end else table.insert(fi,bH)end end;if#fi<=0 then table.insert(fi,bH)end;fh[bH]={}end;fr.parent=bO;table.insert(fh[bH],fr)return fr end;local function fs(fr)for bq,br in pairs(fh)do for bp,aP in pairs(br)do if aP==fr then table.remove(fh[bq],bp)return true end end end;return false end;bO={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return bG end,setFocusedObject=function(self,fr)for aO,aK in pairs(fi)do for aO,aP in pairs(fh[aK])do if aP==fr then if fj~=nil then fj:loseFocusHandler()end;fj=fr;fj:getFocusHandler()end end end;return self end,setOffset=function(self,b_,c0)fo=b_~=nil and math.floor(b_<0 and math.abs(b_)or-b_)or fo;cx=c0~=nil and math.floor(c0<0 and math.abs(c0)or-c0)or cx;return self end,getFrameOffset=function(self)return fo,cx end,removeFocusedObject=function(self)if fj~=nil then fj:loseFocusHandler()end;fj=nil;return self end,getFocusedObject=function(self)return fj end,show=function(self)cj:show()if self.parent==nil and not fm then b=self end;return self end,setCursor=function(self,ft,fu,fv,bW)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())dz=ft or false;if fu~=nil then dw=cn+fu-1 end;if fv~=nil then dx=co+fv-1 end;fn=bW or fn;self:setVisualChanged()return self end,setMoveable=function(self,fw)self.isMoveable=fw or not self.isMoveable;self:setVisualChanged()return self end,addMonitor=function(self,fx)local fy=peripheral.wrap(fx)fl[fx]={monitor=fx,frame=a.createFrame(self:getName().."_monitor_"..fx)}fl[fx].frame:setDisplay(fy):setFrameAsMonitor()fl[fx].frame:setSize(fy:getSize())return fl[fx].frame end,setMonitorScale=function(self,fz,fA)if fm then fk.setTextScale(fz*0.5)if fA then self:setSize(fk:getSize())end end;return self,fm end,setFrameAsMonitor=function(self,fB)fm=fB;if fB==nil then fm=true end;return self end,showBar=function(self,fC)self.barActive=fC or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,ar,aB,aC)self.barText=ar or""self.barBackground=aB or self.barBackground;self.barTextcolor=aC or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,cw)self.barTextAlign=cw or"left"self:setVisualChanged()return self end,setDisplay=function(self,a4)fk=a4;aA=a3(fk)return self end,getDisplay=function(self)return fk end,getVisualChanged=function(self)local fD=cj.getVisualChanged(self)for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.getVisualChanged~=nil and aP:getVisualChanged()then fD=true end end end end;return fD end,loseFocusHandler=function(self)cj.loseFocusHandler(self)end,getFocusHandler=function(self)cj.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,aL,bp)if fj~=nil then if fj.keyHandler~=nil then if fj:keyHandler(aL,bp)then return true end end end;return false end,backgroundKeyHandler=function(self,aL,bp)cj.backgroundKeyHandler(self,aL,bp)for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.backgroundKeyHandler~=nil then aP:backgroundKeyHandler(aL,bp)end end end end end,eventHandler=function(self,aL,c5,c6,c7,c8)cj.eventHandler(self,aL,c5,c6,c7,c8)for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.eventHandler~=nil then aP:eventHandler(aL,c5,c6,c7,c8)end end end end;if aL=="terminate"then fk.clear()fk.setCursorPos(1,1)a.stop()end end,mouseClickHandler=function(self,aL,c2,ap,aq)local b_,c0=self:getOffset()b_=b_<0 and math.abs(b_)or-b_;c0=c0<0 and math.abs(c0)or-c0;if self.drag then if aL=="mouse_drag"then local fE=1;local fF=1;if self.parent~=nil then fE,fF=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(ap+self.xToRem-(fE-1)+b_,aq-(fF-1)+c0)end;if aL=="mouse_up"then self.drag=false end;return true end;if cj.mouseClickHandler(self,aL,c2,ap,aq)then local bX,bY=self:getAbsolutePosition(self:getAnchorPosition())if aL~="monitor_touch"or fm then for aO,aK in pairs(fi)do if fh[aK]~=nil then for aO,aP in b4(fh[aK])do if aP.mouseClickHandler~=nil then if aP:mouseClickHandler(aL,c2,ap+b_,aq+c0)then return true end end end end end elseif not fm then for aO,dr in pairs(fl)do if c2==dr.monitor then dr.frame:mouseClickHandler(aL,c2,ap,aq)end end end;if self.isMoveable then if ap>=bX and ap<=bX+self.width-1 and aq==bY and aL=="mouse_click"then self.drag=true;self.xToRem=bX-ap end end;if fj~=nil then fj:loseFocusHandler()fj=nil end;return true end;return false end,setText=function(self,ap,aq,ar)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:setText(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(ar,math.max(1-ap+1,1),self.width-ap+1))else aA.setText(math.max(ap+cn-1,cn),co+aq-1,f(ar,math.max(1-ap+1,1),self.width-ap+1))end end end,setBG=function(self,ap,aq,aB)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:setBG(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(aB,math.max(1-ap+1,1),self.width-ap+1))else aA.setBG(math.max(ap+cn-1,cn),co+aq-1,f(aB,math.max(1-ap+1,1),self.width-ap+1))end end end,setFG=function(self,ap,aq,aC)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:setFG(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(aC,math.max(1-ap+1,1),self.width-ap+1))else aA.setFG(math.max(ap+cn-1,cn),co+aq-1,f(aC,math.max(1-ap+1,1),self.width-ap+1))end end end,writeText=function(self,ap,aq,ar,aB,aC)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())if aq>=1 and aq<=self.height then if self.parent~=nil then self.parent:writeText(math.max(ap+cn-1,cn)-(self.parent.x-1),co+aq-1-(self.parent.y-1),f(ar,math.max(1-ap+1,1),self.width-ap+1),aB,aC)else aA.writeText(math.max(ap+cn-1,cn),co+aq-1,f(ar,math.max(1-ap+1,1),self.width-ap+1),aB,aC)end end end,drawBackgroundBox=function(self,ap,aq,a6,m,aB)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())m=aq<1 and(m+aq>self.height and self.height or m+aq-1)or(m+aq>self.height and self.height-aq+1 or m)a6=ap<1 and(a6+ap>self.width and self.width or a6+ap-1)or(a6+ap>self.width and self.width-ap+1 or a6)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(ap+cn-1,cn)-(self.parent.x-1),math.max(aq+co-1,co)-(self.parent.y-1),a6,m,aB)else aA.drawBackgroundBox(math.max(ap+cn-1,cn),math.max(aq+co-1,co),a6,m,aB)end end,drawTextBox=function(self,ap,aq,a6,m,aD)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())m=aq<1 and(m+aq>self.height and self.height or m+aq-1)or(m+aq>self.height and self.height-aq+1 or m)a6=ap<1 and(a6+ap>self.width and self.width or a6+ap-1)or(a6+ap>self.width and self.width-ap+1 or a6)if self.parent~=nil then self.parent:drawTextBox(math.max(ap+cn-1,cn)-(self.parent.x-1),math.max(aq+co-1,co)-(self.parent.y-1),a6,m,aD:sub(1,1))else aA.drawTextBox(math.max(ap+cn-1,cn),math.max(aq+co-1,co),a6,m,aD:sub(1,1))end end,drawForegroundBox=function(self,ap,aq,a6,m,aC)local cn,co=self:getAbsolutePosition(self:getAnchorPosition())m=aq<1 and(m+aq>self.height and self.height or m+aq-1)or(m+aq>self.height and self.height-aq+1 or m)a6=ap<1 and(a6+ap>self.width and self.width or a6+ap-1)or(a6+ap>self.width and self.width-ap+1 or a6)if self.parent~=nil then self.parent:drawForegroundBox(math.max(ap+cn-1,cn)-(self.parent.x-1),math.max(aq+co-1,co)-(self.parent.y-1),a6,m,aC)else aA.drawForegroundBox(math.max(ap+cn-1,cn),math.max(aq+co-1,co),a6,m,aC)end end,draw=function(self)for aO,dr in pairs(fl)do dr.frame:draw()end;if self:getVisualChanged()then if cj.draw(self)then local cn,co=self:getAbsolutePosition(self:getAnchorPosition())local f3,f4=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(f3,f4,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(f3,f4,self.width,self.height,self.fgColor)self.parent:drawTextBox(f3,f4,self.width,self.height," ")else aA.drawBackgroundBox(cn,co,self.width,self.height,self.bgColor)aA.drawForegroundBox(cn,co,self.width,self.height,self.fgColor)aA.drawTextBox(cn,co,self.width,self.height," ")end;fk.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(f3,f4,aZ(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)else aA.writeText(cn,co,aZ(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aO,aK in b4(fi)do if fh[aK]~=nil then for aO,aP in pairs(fh[aK])do if aP.draw~=nil then aP:draw()end end end end;if dz then fk.setTextColor(fn)fk.setCursorPos(dw,dx)if self.parent~=nil then fk.setCursorBlink(self:isFocused())else fk.setCursorBlink(dz)end end;self:setVisualChanged(false)end end end,drawUpdate=function(self)aA.update()for fG,dr in pairs(fl)do dr.frame:drawUpdate()end end,addObject=function(self,fr)return fq(fr)end,removeObject=function(self,fr)return fs(fr)end,getObject=function(self,fr)return fp(fr)end,addButton=function(self,bF)local fr=ci(bF)fr.name=bF;return fq(fr)end,addLabel=function(self,bF)local fr=d6(bF)fr.bgColor=self.bgColor;fr.fgColor=self.fgColor;return fq(fr)end,addCheckbox=function(self,bF)local fr=cq(bF)return fq(fr)end,addInput=function(self,bF)local fr=cP(bF)return fq(fr)end,addProgram=function(self,bF)local fr=du(bF)return fq(fr)end,addTextfield=function(self,bF)local fr=eX(bF)return fq(fr)end,addList=function(self,bF)local fr=dg(bF)fr.name=nam;return fq(fr)end,addDropdown=function(self,bF)local fr=cr(bF)return fq(fr)end,addRadio=function(self,bF)local fr=eC(bF)return fq(fr)end,addTimer=function(self,bF)local fr=f8(bF)return fq(fr)end,addAnimation=function(self,bF)local fr=c9(bF)return fq(fr)end,addSlider=function(self,bF)local fr=eT(bF)return fq(fr)end,addScrollbar=function(self,bF)local fr=eH(bF)return fq(fr)end,addMenubar=function(self,bF)local fr=dj(bF)return fq(fr)end,addThread=function(self,bF)local fr=f5(bF)return fq(fr)end,addPane=function(self,bF)local fr=dt(bF)return fq(fr)end,addImage=function(self,bF)local fr=cH(bF)return fq(fr)end,addProgressbar=function(self,bF)local fr=et(bF)return fq(fr)end,addSwitch=function(self,bF)local fr=eU(bF)return fq(fr)end,addFrame=function(self,bF)local fr=ff(bF,self)return fq(fr)end}setmetatable(bO,cj)if fg==nil then table.insert(c,bO)end;return bO end;local fH=false;local function fI(aL,c5,c6,c7,c8)if aL=="mouse_click"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="mouse_drag"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="mouse_up"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="mouse_scroll"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="monitor_touch"then b:mouseClickHandler(aL,c5,c6,c7,c8)elseif aL=="key"or aL=="char"then b:keyHandler(aL,c5)b:backgroundKeyHandler(aL,c5)end;if aL=="key"then d[c5]=true end;if aL=="key_up"then d[c5]=false end;for aO,aP in pairs(c)do aP:eventHandler(aL,c5,c6,c7,c8)end;if fH then b:draw()b:drawUpdate()end end;function a.autoUpdate(f7)e.clear()fH=f7 or true;b:draw()b:drawUpdate()while fH do local aL,c5,c6,c7,c8=os.pullEventRaw()fI(aL,c5,c6,c7,c8)end end;function a.update(aL,c5,c6,c7,c8)if aL~=nil then fI(aL,c5,c6,c7,c8)else b:draw()b:drawUpdate()end end;function a.stop()fH=false end;function a.isKeyDown(bp)if d[bp]==nil then return false end;return d[bp]end;function a.getFrame(bF)for aO,aP in pairs(c)do if aP.name==bF then return aP end end end;function a.getActiveFrame()return b end;function a.setActiveFrame(bP)if bP:getType()=="Frame"then b=bP;return true end;return false end;function a.createFrame(bF)return ff(bF)end;function a.removeFrame(bF)for bp,aP in pairs(c)do if aP.name==bF then c[bp]=nil;return true end end;return false end;if a.debugger then a.debugFrame=a.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)a.debugList=a.debugFrame:addList("debugList"):setSize(a.debugFrame.width-2,a.debugFrame.height-3):setPosition(2,3):setScrollable(true):show()a.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()a.oldFrame:show()end):setBackground(colors.red):show()a.debugLabel=a.debugFrame:addLabel("debugLabel"):onClick(function()a.oldFrame=b;a.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if a.debugger then function a.debug(...)local aV={...}if b.name~="basaltDebuggingFrame"then if b~=a.debugLabel.frame then a.debugLabel:setParent(b)end end;local fJ=""for bp,aP in pairs(aV)do fJ=fJ..tostring(aP)..(#aV~=bp and", "or"")end;a.debugLabel:setText("[Debug] "..fJ)a.debugList:addItem(fJ)if a.debugList:getItemCount()>50 then a.debugList:removeItem(1)end;a.debugList:setValue(a.debugList:getItem(a.debugList:getItemCount()))if a.debugList.getItemCount()>a.debugList:getHeight()then a.debugList:setIndexOffset(a.debugList:getItemCount()-a.debugList:getHeight())end;a.debugLabel:show()end end;return a \ No newline at end of file diff --git a/source/project/Frame.lua b/source/project/Frame.lua index 4a9bead..fc0151c 100644 --- a/source/project/Frame.lua +++ b/source/project/Frame.lua @@ -5,11 +5,12 @@ local function Frame(name, parent) local objects = {} local objZIndex = {} local object = {} - local focusedObject local termObject = parentTerminal - local monitors = {} + local monSide = "" local isMonitor = false + local monitorAttached = false + local dragOffset = 0 base:setZIndex(10) @@ -97,16 +98,13 @@ local function Frame(name, parent) end; setFocusedObject = function(self, obj) - for _, index in pairs(objZIndex) do - for _, value in pairs(objects[index]) do - if (value == obj) then - if (focusedObject ~= nil) then - focusedObject:loseFocusHandler() - end - focusedObject = obj - focusedObject:getFocusHandler() - end - end + if (focusedObject ~= nil) then + focusedObject:loseFocusHandler() + focusedObject = nil + end + if(obj~=nil)then + focusedObject = obj + obj:getFocusHandler() end return self end; @@ -117,7 +115,7 @@ local function Frame(name, parent) return self end; - getFrameOffset = function(self) + getFrameOffset = function(self) -- internal return xOffset, yOffset end; @@ -133,25 +131,22 @@ local function Frame(name, parent) return focusedObject end; - show = function(self) - base:show() - if (self.parent == nil)and not(isMonitor) then - activeFrame = self - end - return self - end; - setCursor = function(self, _blink, _xCursor, _yCursor, color) - local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - cursorBlink = _blink or false - if (_xCursor ~= nil) then - xCursor = obx + _xCursor - 1 + if(self.parent~=nil)then + local obx, oby = self:getAnchorPosition() + self.parent:setCursor(_blink or false, (_xCursor or 0)+obx-1, (_yCursor or 0)+oby-1, color or cursorColor) + else + local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) + cursorBlink = _blink or false + if (_xCursor ~= nil) then + xCursor = obx + _xCursor - 1 + end + if (_yCursor ~= nil) then + yCursor = oby + _yCursor - 1 + end + cursorColor = color or cursorColor + self:setVisualChanged() end - if (_yCursor ~= nil) then - yCursor = oby + _yCursor - 1 - end - cursorColor = color or cursorColor - self:setVisualChanged() return self end; @@ -161,30 +156,36 @@ local function Frame(name, parent) return self; end; - - addMonitor = function(self, mon) - local screen = peripheral.wrap(mon) - monitors[mon] = {monitor=mon, frame=basalt.createFrame(self:getName().."_monitor_"..mon)} - monitors[mon].frame:setDisplay(screen):setFrameAsMonitor() - monitors[mon].frame:setSize(screen:getSize()) - return monitors[mon].frame - end; - - setMonitorScale = function(self, scale, fullSize) -- 1,2,3,4,5,6,7,8,9,10 - if(isMonitor)then - termObject.setTextScale(scale*0.5) - if(fullSize)then - self:setSize(termObject:getSize()) + show = function(self) + base.show(self) + if(self.parent==nil)then + activeFrame = self; + if(isMonitor)then + monFrames[monSide] = self; + else + mainFrame = self; end end - return self, isMonitor + return self; end; - setFrameAsMonitor = function(self, isMon) - isMonitor = isMon - if(isMon==nil)then isMonitor = true end + hide = function (self) + base.hide(self) + if(self.parent==nil)then + if(activeFrame == self)then activeFrame = nil end + if(isMonitor)then + if(monFrames[monSide] == self)then + monFrames[monSide] = nil; + end + else + if(mainFrame == self)then + mainFrame = nil; + end + end + end return self end; + showBar = function(self, showIt) self.barActive = showIt or not self.barActive @@ -206,14 +207,23 @@ local function Frame(name, parent) return self end; - setDisplay = function(self, drawTerm) - termObject = drawTerm + setMonitor = function(self, side) + if(side~=nil)or(side~=false)then + if(peripheral.getType(side)=="monitor")then + termObject = peripheral.wrap(side) + monitorAttached = true + end + isMonitor = true + else + termObject = parentTerminal + isMonitor = false + if(monFrames[monSide]==self)then + monFrames[monSide] = nil + end + end drawHelper = basaltDrawHelper(termObject) - return self - end; - - getDisplay = function(self) - return termObject + monSide = side or nil + return self; end; getVisualChanged = function(self) @@ -244,10 +254,14 @@ local function Frame(name, parent) keyHandler = function(self, event, key) if (focusedObject ~= nil) then - if (focusedObject.keyHandler ~= nil) then - if (focusedObject:keyHandler(event, key)) then - return true + if(focusedObject~=self)then + if (focusedObject.keyHandler ~= nil) then + if (focusedObject:keyHandler(event, key)) then + return true + end end + else + base.keyHandler(self, event, key) end end return false @@ -277,6 +291,18 @@ local function Frame(name, parent) end end end + if(isMonitor)then + if(event == "peripheral")and(p1==monSide)then + if(peripheral.getType(monSide)=="monitor")then + monitorAttached = true + termObject = peripheral.wrap(monSide) + drawHelper = basaltDrawHelper(termObject) + end + end + if(event == "peripheral_detach")and(p1==monSide)then + monitorAttached = false + end + end if (event == "terminate") then termObject.clear() termObject.setCursorPos(1, 1) @@ -284,7 +310,7 @@ local function Frame(name, parent) end end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local xO, yO = self:getOffset() xO = xO < 0 and math.abs(xO) or -xO yO = yO < 0 and math.abs(yO) or -yO @@ -295,7 +321,7 @@ local function Frame(name, parent) if (self.parent ~= nil) then parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition()) end - self:setPosition(x + self.xToRem - (parentX - 1) + xO, y - (parentY - 1) + yO) + self:setPosition(x + dragOffset - (parentX - 1) + xO, y - (parentY - 1) + yO) end if (event == "mouse_up") then self.drag = false @@ -303,32 +329,25 @@ local function Frame(name, parent) return true end - if (base.mouseClickHandler(self, event, button, x, y)) then + if (base.mouseHandler(self, event, button, x, y)) then local fx, fy = self:getAbsolutePosition(self:getAnchorPosition()) - if(event~="monitor_touch") or (isMonitor)then + fx = fx + xOffset;fy = fy + yOffset; for _, index in pairs(objZIndex) do if (objects[index] ~= nil) then for _, value in rpairs(objects[index]) do - if (value.mouseClickHandler ~= nil) then - if (value:mouseClickHandler(event, button, x + xO, y + yO)) then + if (value.mouseHandler ~= nil) then + if (value:mouseHandler(event, button, x, y)) then return true end end end end end - elseif not(isMonitor)then - for _,v in pairs(monitors)do - if(button==v.monitor)then - v.frame:mouseClickHandler(event, button, x, y) - end - end - end if (self.isMoveable) then if (x >= fx) and (x <= fx + self.width - 1) and (y == fy) and (event == "mouse_click") then self.drag = true - self.xToRem = fx - x + dragOffset = fx - x end end if (focusedObject ~= nil) then @@ -344,7 +363,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:setText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1)) else drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1)) end @@ -355,7 +375,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setBG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:setBG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1)) else drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1)) end @@ -366,7 +387,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setFG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:setFG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1)) else drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1)) end @@ -377,7 +399,8 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:writeText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:writeText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol) else drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol) end @@ -389,7 +412,8 @@ local function Frame(name, parent) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) if (self.parent ~= nil) then - self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, bgCol) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, bgCol) else drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, bgCol) end @@ -400,7 +424,8 @@ local function Frame(name, parent) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) if (self.parent ~= nil) then - self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, symbol:sub(1, 1)) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, symbol:sub(1, 1)) else drawHelper.drawTextBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, symbol:sub(1, 1)) end @@ -411,16 +436,15 @@ local function Frame(name, parent) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) if (self.parent ~= nil) then - self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, fgCol) + local parentX, parentY = self.parent:getAnchorPosition() + self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, fgCol) else drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgCol) end end; draw = function(self) - for _,v in pairs(monitors)do - v.frame:draw() - end + if(isMonitor)and not(monitorAttached)then return false end; if (self:getVisualChanged()) then if (base.draw(self)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) @@ -467,11 +491,9 @@ local function Frame(name, parent) end end; - drawUpdate = function (self) + drawUpdate = function(self) + if(isMonitor)and not(monitorAttached)then return false end; drawHelper.update() - for k,v in pairs(monitors)do - v.frame:drawUpdate() - end end; addObject = function(self, obj) @@ -591,8 +613,5 @@ local function Frame(name, parent) end; } setmetatable(object, base) - if (parent == nil) then - table.insert(frames, object) - end return object end \ No newline at end of file diff --git a/source/project/Object.lua b/source/project/Object.lua index f469949..a72094e 100644 --- a/source/project/Object.lua +++ b/source/project/Object.lua @@ -1,11 +1,6 @@ local function Object(name) -- Base object local objectType = "Object" -- not changeable - --[[ - local horizontalAnchor = "left" - local verticalAnchor = "top" - local ignYOffset = false - local ignXOffset = false ]] local value local zIndex = 1 local hanchor = "left" @@ -194,11 +189,8 @@ local function Object(name) getAbsolutePosition = function(self, x, y) -- relative position to absolute position - if (x == nil) then - x = self.x - end - if (y == nil) then - y = self.y + if (x == nil) or (y == nil) then + x, y = self:getAnchorPosition() end if (self.parent ~= nil) then @@ -223,24 +215,32 @@ local function Object(name) y = self.parent.height - y - self.height + 2 end local xO, yO = self:getOffset() - if (ignOffset or ignOff) then - return x, y + if not(ignOffset or ignOff) then + return x+xO, y+yO end - return x + xO, y + yO + return x, y end; getOffset = function(self) - if (self.parent ~= nil) and (ignOffset == false) then + if (self.parent ~= nil) then return self.parent:getFrameOffset() end return 0, 0 end; ignoreOffset = function(self, ignore) - ignOffset = ignore or true + ignOffset = ignore + if(ignore==nil)then ignOffset = true end return self end; + getBaseFrame = function(self) + if(self.parent~=nil)then + return self.parent:getBaseFrame() + end + return self + end; + setAnchor = function(self, ...) for _, value in pairs(table.pack(...)) do if (value == "right") or (value == "left") then @@ -269,13 +269,24 @@ local function Object(name) return self end; - onEvent = function(self, func) - self:registerEvent("custom_event_handler", func) + onClickUp = function(self, func) + self:registerEvent("mouse_up", func) return self end; - onClickUp = function(self, func) - self:registerEvent("mouse_up", func) + + onScroll = function(self, func) + self:registerEvent("mouse_scroll", func) + return self + end; + + onDrag = function(self, func) + self:registerEvent("mouse_drag", func) + return self + end; + + onEvent = function(self, func) + self:registerEvent("custom_event_handler", func) return self end; @@ -330,7 +341,7 @@ local function Object(name) return eventSystem:sendEvent(event, self, ...) end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local objX, objY = self:getAbsolutePosition(self:getAnchorPosition()) if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (isVisible) then if (self.parent ~= nil) then diff --git a/source/project/mainBottom.lua b/source/project/mainBottom.lua index 6ac2ee5..de190ff 100644 --- a/source/project/mainBottom.lua +++ b/source/project/mainBottom.lua @@ -1,16 +1,36 @@ +local function drawFrames() + mainFrame:draw() + mainFrame:drawUpdate() + for _,v in pairs(monFrames)do + v:draw() + v:drawUpdate() + end +end + local updaterActive = false local function basaltUpdateEvent(event, p1, p2, p3, p4) - if (event == "mouse_click") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "mouse_drag") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "mouse_up") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "mouse_scroll") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "monitor_touch") then - activeFrame:mouseClickHandler(event, p1, p2, p3, p4) - elseif (event == "key") or (event == "char") then + if(mainFrame~=nil)then + if (event == "mouse_click") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "mouse_drag") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "mouse_up") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "mouse_scroll") then + mainFrame:mouseHandler(event, p1, p2, p3, p4) + activeFrame = mainFrame + elseif (event == "monitor_touch") then + if(monFrames[p1]~=nil)then + monFrames[p1]:mouseHandler(event, p1, p2, p3, p4) + activeFrame = monFrames[p1] + end + end + end + + if(event == "key") or (event == "char") then activeFrame:keyHandler(event, p1) activeFrame:backgroundKeyHandler(event, p1) end @@ -23,20 +43,18 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4) keyActive[p1] = false end - for _, value in pairs(frames) do - value:eventHandler(event, p1, p2, p3, p4) + for _, v in pairs(frames) do + v:eventHandler(event, p1, p2, p3, p4) end if (updaterActive) then - activeFrame:draw() - activeFrame:drawUpdate() + drawFrames() end end function basalt.autoUpdate(isActive) - parentTerminal.clear() - updaterActive = isActive or true - activeFrame:draw() - activeFrame:drawUpdate() + updaterActive = isActive + if(isActive==nil)then updaterActive = true end + drawFrames() while updaterActive do local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later basaltUpdateEvent(event, p1, p2, p3, p4) @@ -47,8 +65,7 @@ function basalt.update(event, p1, p2, p3, p4) if (event ~= nil) then basaltUpdateEvent(event, p1, p2, p3, p4) else - activeFrame:draw() - activeFrame:drawUpdate() + drawFrames() end end @@ -82,32 +99,34 @@ function basalt.setActiveFrame(frame) end function basalt.createFrame(name) - return Frame(name) + for _, v in pairs(frames) do + if (v.name == name) then + return nil + end + end + local newFrame = Frame(name) + table.insert(frames, newFrame) + return newFrame end function basalt.removeFrame(name) - for key, value in pairs(frames) do - if (value.name == name) then - frames[key] = nil - return true - end - end - return false + frames[name] = nil end + if (basalt.debugger) then basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray) basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show() basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show() - basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = activeFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show() + basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = mainFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):ignoreOffset():setZIndex(20):show() end if (basalt.debugger) then function basalt.debug(...) local args = { ... } - if (activeFrame.name ~= "basaltDebuggingFrame") then - if (activeFrame ~= basalt.debugLabel.frame) then - basalt.debugLabel:setParent(activeFrame) + if (mainFrame.name ~= "basaltDebuggingFrame") then + if (mainFrame ~= basalt.debugFrame) then + basalt.debugLabel:setParent(mainFrame) end end local str = "" diff --git a/source/project/mainTop.lua b/source/project/mainTop.lua index e53d725..327456c 100644 --- a/source/project/mainTop.lua +++ b/source/project/mainTop.lua @@ -1,7 +1,12 @@ local basalt = { debugger = true, version = 1 } -local activeFrame +local keyActive = {} +local focusedObject local frames = {} -local keyActive = {} +local activeFrame + +local mainFrame +local monFrames = {} + local parentTerminal = term.current() local sub = string.sub diff --git a/source/project/objects/Checkbox.lua b/source/project/objects/Checkbox.lua index a28c294..e22df58 100644 --- a/source/project/objects/Checkbox.lua +++ b/source/project/objects/Checkbox.lua @@ -17,8 +17,8 @@ local function Checkbox(name) return objectType end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then if (self:getValue() ~= true) and (self:getValue() ~= false) then self:setValue(false) diff --git a/source/project/objects/Dropdown.lua b/source/project/objects/Dropdown.lua index 5819339..1d4e366 100644 --- a/source/project/objects/Dropdown.lua +++ b/source/project/objects/Dropdown.lua @@ -94,7 +94,7 @@ local function Dropdown(name) return self end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) if (isOpened) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then @@ -129,7 +129,7 @@ local function Dropdown(name) end self:setVisualChanged() end - if (base.mouseClickHandler(self, event, button, x, y)) then + if (base.mouseHandler(self, event, button, x, y)) then isOpened = true else isOpened = false diff --git a/source/project/objects/Input.lua b/source/project/objects/Input.lua index 58bf7d5..10aa372 100644 --- a/source/project/objects/Input.lua +++ b/source/project/objects/Input.lua @@ -187,8 +187,8 @@ local function Input(name) end end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then if (event == "mouse_click") and (button == 1) then end diff --git a/source/project/objects/List.lua b/source/project/objects/List.lua index af65875..cbc0f7d 100644 --- a/source/project/objects/List.lua +++ b/source/project/objects/List.lua @@ -92,7 +92,7 @@ local function List(name) return self end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (obx <= x) and (obx + self.width > x) and (oby <= y) and (oby + self.height > y) and (self:isVisible()) then if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then diff --git a/source/project/objects/Menubar.lua b/source/project/objects/Menubar.lua index 0855144..1d8836e 100644 --- a/source/project/objects/Menubar.lua +++ b/source/project/objects/Menubar.lua @@ -126,8 +126,8 @@ local function Menubar(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if(base.mouseClickHandler(self, event, button, x, y))then + mouseHandler = function(self, event, button, x, y) + if(base.mouseHandler(self, event, button, x, y))then local objX, objY = self:getAbsolutePosition(self:getAnchorPosition()) if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then if (self.parent ~= nil) then diff --git a/source/project/objects/Program.lua b/source/project/objects/Program.lua index 5bfa79b..12e0e23 100644 --- a/source/project/objects/Program.lua +++ b/source/project/objects/Program.lua @@ -534,15 +534,15 @@ local function Program(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then if (curProcess == nil) then return false end if not (curProcess:isDead()) then if not (paused) then local absX, absY = self:getAbsolutePosition(self:getAnchorPosition(nil, nil, true)) - curProcess:resume(event, button, x - absX + 1, y - absY + 1) + curProcess:resume(event, button, x - (absX - 1), y - (absY - 1)) end end return true diff --git a/source/project/objects/Radio.lua b/source/project/objects/Radio.lua index 3bcd147..7a32766 100644 --- a/source/project/objects/Radio.lua +++ b/source/project/objects/Radio.lua @@ -80,7 +80,7 @@ local function Radio(name) return self end; - mouseClickHandler = function(self, event, button, x, y) + mouseHandler = function(self, event, button, x, y) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then if (#list > 0) then diff --git a/source/project/objects/Scrollbar.lua b/source/project/objects/Scrollbar.lua index b8e45b2..2928547 100644 --- a/source/project/objects/Scrollbar.lua +++ b/source/project/objects/Scrollbar.lua @@ -61,8 +61,8 @@ local function Scrollbar(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then if (barType == "horizontal") then diff --git a/source/project/objects/Slider.lua b/source/project/objects/Slider.lua index 7697fe4..0227cf2 100644 --- a/source/project/objects/Slider.lua +++ b/source/project/objects/Slider.lua @@ -60,8 +60,8 @@ local function Slider(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then if (barType == "horizontal") then diff --git a/source/project/objects/Switch.lua b/source/project/objects/Switch.lua index 5ece53f..826f059 100644 --- a/source/project/objects/Switch.lua +++ b/source/project/objects/Switch.lua @@ -36,8 +36,8 @@ local function Switch(name) return self end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if ((event == "mouse_click") and (button == 1))or(event=="monitor_touch") then self:setValue(not self:getValue()) diff --git a/source/project/objects/Textfield.lua b/source/project/objects/Textfield.lua index 5f3669c..fa7b59c 100644 --- a/source/project/objects/Textfield.lua +++ b/source/project/objects/Textfield.lua @@ -244,8 +244,8 @@ local function Textfield(name) end end; - mouseClickHandler = function(self, event, button, x, y) - if (base.mouseClickHandler(self, event, button, x, y)) then + mouseHandler = function(self, event, button, x, y) + if (base.mouseHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local anchx, anchy = self:getAnchorPosition() if (event == "mouse_click")or(event=="monitor_touch") then @@ -262,7 +262,7 @@ local function Textfield(name) end end if (self.parent ~= nil) then - self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) + self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor) end end end @@ -280,7 +280,7 @@ local function Textfield(name) end end if (self.parent ~= nil) then - self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) + self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor) end end end @@ -297,7 +297,7 @@ local function Textfield(name) if (self.parent ~= nil) then if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then - self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) + self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor) else self.parent:setCursor(false) end