Files
Basalt/basalt.lua
2022-05-18 20:18:57 +02:00

1 line
63 KiB
Lua

local a={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 b={debugger=true,version=1}local c;local d={}local e={}local f=term.current()local g=string.sub;local function h(i,j,k)local i=string.sub(i,1,j)local l=j-string.len(i)if k=="right"then i=string.rep(" ",l)..i elseif k=="center"then i=string.rep(" ",math.floor(l/2))..i..string.rep(" ",math.floor(l/2))i=i..(string.len(i)<j and" "or"")else i=i..string.rep(" ",l)end;return i end;local function m(n,k)local o=0;if k=="center"then o=math.ceil(n/2)if o<1 then o=1 end end;if k=="bottom"then o=n end;return o end;local function p(q)return function(q,r)r=r-1;if r~=0 then return r,q[r]end end,q,#q+1 end;local s={[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 function t()local u=f;local j,n=u.getSize()local v={}local w={}local x={}local y={}local z={}local A={}local B;local C={}local function D()B=(" "):rep(j)for l=0,15 do local E=2^l;local F=s[E]C[E]=F:rep(j)end end;D()local function G()local H=B;local I=C[colors.white]local J=C[colors.black]for l=1,n do v[l]=g(v[l]==nil and H or v[l]..H:sub(1,j-v[l]:len()),1,j)x[l]=g(x[l]==nil and I or x[l]..I:sub(1,j-x[l]:len()),1,j)w[l]=g(w[l]==nil and J or w[l]..J:sub(1,j-w[l]:len()),1,j)end end;G()local function K(L,M,i)if M>=1 and M<=n then if L+i:len()>0 and L<=j then local N=v[M]local O;local P=L+#i-1;if L<1 then local Q=1-L+1;local R=j-L+1;i=g(i,Q,R)elseif P>j then local R=j-L+1;i=g(i,1,R)end;if L>1 then local R=L-1;O=g(N,1,R)..i else O=i end;if P<j then O=O..g(N,P+1,j)end;v[M]=O end end end;local function S(L,M,T)if M>=1 and M<=n then if L+T:len()>0 and L<=j then local N=w[M]local O;local P=L+#T-1;if L<1 then T=g(T,1-L+1,j-L+1)elseif P>j then T=g(T,1,j-L+1)end;if L>1 then O=g(N,1,L-1)..T else O=T end;if P<j then O=O..g(N,P+1,j)end;w[M]=O end end end;local function U(L,M,T)if M>=1 and M<=n then if L+T:len()>0 and L<=j then local N=x[M]local O;local P=L+#T-1;if L<1 then local Q=1-L+1;local R=j-L+1;T=g(T,Q,R)elseif P>j then local R=j-L+1;T=g(T,1,R)end;if L>1 then local R=L-1;O=g(N,1,R)..T else O=T end;if P<j then O=O..g(N,P+1,j)end;x[M]=O end end end;local V={setBG=function(L,M,T)S(L,M,T)end,setText=function(L,M,i)K(L,M,i)end,setFG=function(L,M,T)U(L,M,T)end,drawBackgroundBox=function(L,M,j,n,W)for l=1,n do S(L,M+l-1,s[W]:rep(j))end end,drawForegroundBox=function(L,M,j,n,X)for l=1,n do U(L,M+l-1,s[X]:rep(j))end end,drawTextBox=function(L,M,j,n,Y)for l=1,n do K(L,M+l-1,Y:rep(j))end end,writeText=function(L,M,i,W,X)W=W or u.getBackgroundColor()X=X or u.getTextColor()K(L,M,i)S(L,M,s[W]:rep(i:len()))U(L,M,s[X]:rep(i:len()))end,update=function()local Z,_=u.getCursorPos()local a0=false;if u.getCursorBlink~=nil then a0=u.getCursorBlink()end;u.setCursorBlink(false)for l=1,n do u.setCursorPos(1,l)u.blit(v[l],x[l],w[l])end;u.setCursorBlink(a0)u.setCursorPos(Z,_)end,setTerm=function(a1)u=a1 end}return V end;local V=t()local function a2()local a3={}local a4={}local a5={registerEvent=function(self,a6,a7)if a3[a6]==nil then a3[a6]={}a4[a6]=1 end;a3[a6][a4[a6]]=a7;a4[a6]=a4[a6]+1;return a4[a6]-1 end,removeEvent=function(self,a6,a4)a3[a6][a4[a6]]=nil end,sendEvent=function(self,a6,...)if a3[a6]~=nil then for a8,a9 in pairs(a3[a6])do a9(...)end end end}a5.__index=a5;return a5 end;local aa={}local ab={}local ac=0;function ab:new(ad,ae,...)local af=table.pack(...)local ag=setmetatable({path=ad},{__index=self})ag.window=ae;ag.processId=ac;ag.coroutine=coroutine.create(function()os.run({basalt=b},ad,table.unpack(af))end)aa[ac]=ag;ac=ac+1;return ag end;function ab:resume(a5,...)term.redirect(self.window)local ah,ai=coroutine.resume(self.coroutine,a5,...)self.window=term.current()if ah then self.filter=ai else b.debug(ai)end end;function ab:isDead()if self.coroutine~=nil then if coroutine.status(self.coroutine)=="dead"then table.remove(aa,self.processId)return true end else return true end;return false end;function ab:getStatus()if self.coroutine~=nil then return coroutine.status(self.coroutine)end;return nil end;function ab:start()coroutine.resume(self.coroutine)end;local function aj(ak)local al="Object"local am=nil;local an=1;local ao="left"local ap="top"local aq=false;local ar=false;local as=true;local at=a2()local au={x=1,y=1,w=1,h=1,bgcolor=colors.black,fgcolor=colors.white,name=ak or"Object",parent=nil,show=function(self)ar=true;as=true;return self end,hide=function(self)ar=false;as=true;return self end,isVisible=function(self)return ar end,getZIndex=function(self)return an end,setFocus=function(self)if self.parent~=nil then self.parent:setFocusedObject(self)end;return self end,setZIndex=function(self,a4)an=a4;if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end;return self end,getType=function(self)return al 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,av)if av.getType~=nil and av:getType()=="Frame"then self:remove()av:addObject(self)if self.draw then self:show()end end;return self end,setValue=function(self,aw)if am~=aw then am=aw;as=true;self:valueChangedHandler()end;return self end,getValue=function(self)return am end,getVisualChanged=function(self)return as end,setVisualChanged=function(self,ax)as=ax or true;return self end,getEventSystem=function(self)return at end,getParent=function(self)return self.parent end,setPosition=function(self,ay,az,aA)if aA then self.x,self.y=self.x+ay,self.y+az else self.x,self.y=ay,az end;as=true;return self end,getPosition=function(self)return self.x,self.y end,getVisibility=function(self)return ar end,setVisibility=function(self,aB)ar=aB or not ar;as=true;return self end,setSize=function(self,j,n)self.w,self.h=j,n;as=true;return self end,getHeight=function(self)return self.h end,getWidth=function(self)return self.w end,setBackground=function(self,aC)self.bgcolor=aC;as=true;return self end,getBackground=function(self)return self.bgcolor end,setForeground=function(self,aC)self.fgcolor=aC;as=true;return self end,getForeground=function(self)return self.fgcolor end,draw=function(self)if ar then return true end;return false end,getAbsolutePosition=function(self,L,M)if L==nil then L=self.x end;if M==nil then M=self.y end;if self.parent~=nil then local aD,aE=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())L=aD+L-1;M=aE+M-1 end;return L,M end,getAnchorPosition=function(self,L,M,aF)if L==nil then L=self.x end;if M==nil then M=self.y end;if ao=="right"then L=self.parent.w-L-self.w+2 end;if ap=="bottom"then M=self.parent.h-M-self.h+2 end;local aG,aH=self:getOffset()if aq or aF then return L,M end;return L+aG,M+aH end,getOffset=function(self)if self.parent~=nil and aq==false then return self.parent:getFrameOffset()end;return 0,0 end,ignoreOffset=function(self,aI)aq=aI or true;return self end,setAnchor=function(self,...)for aJ,a9 in pairs(table.pack(...))do if a9=="right"or a9=="left"then ao=a9 end;if a9=="top"or a9=="bottom"then ap=a9 end end;as=true;return self end,getAnchor=function(self)return ao,ap end,onChange=function(self,a7)self:registerEvent("value_changed",a7)return self end,onClick=function(self,a7)self:registerEvent("mouse_click",a7)return self end,onEvent=function(self,a7)self:registerEvent("custom_event_handler",a7)return self end,onClickUp=function(self,a7)self:registerEvent("mouse_up",a7)return self end,onKey=function(self,a7)self:registerEvent("key",a7)self:registerEvent("char",a7)return self end,onKeyUp=function(self,a7)self:registerEvent("key_up",a7)return self end,onBackgroundKey=function(self,a7)self:registerEvent("background_key",a7)self:registerEvent("background_char",a7)return self end,onBackgroundKeyUp=function(self,a7)self:registerEvent("background_key_up",a7)return self end,isFocused=function(self)if self.parent~=nil then return self.parent:getFocusedObject()==self end;return false end,onGetFocus=function(self,a7)self:registerEvent("get_focus",a7)return self end,onLoseFocus=function(self,a7)self:registerEvent("lose_focus",a7)return self end,registerEvent=function(self,a5,a7)return at:registerEvent(a5,a7)end,removeEvent=function(self,a5,a4)return at:removeEvent(a5,a4)end,sendEvent=function(self,a5,...)return at:sendEvent(a5,self,...)end,mouseClickHandler=function(self,a5,aK,L,M)local aL,aM=self:getAbsolutePosition(self:getAnchorPosition())if aL<=L and aL+self.w>L and aM<=M and aM+self.h>M and ar then if self.parent~=nil then self.parent:setFocusedObject(self)end;at:sendEvent(a5,self,a5,aK,L,M)return true end;return false end,keyHandler=function(self,a5,aN)if self:isFocused()then at:sendEvent(a5,self,a5,aN)return true end;return false end,backgroundKeyHandler=function(self,a5,aN)at:sendEvent("background_"..a5,self,a5,aN)end,valueChangedHandler=function(self)at:sendEvent("value_changed",self)end,eventHandler=function(self,a5,aO,aP,aQ,aR)at:sendEvent("custom_event_handler",self,a5,aO,aP,aQ,aR)end,getFocusHandler=function(self)at:sendEvent("get_focus",self)end,loseFocusHandler=function(self)at:sendEvent("lose_focus",self)end}au.__index=au;return au end;local function aS(ak)local aT=aj(ak)local al="Button"aT:setValue("Button")aT:setZIndex(5)aT.w=8;aT.bgcolor=a.ButtonBG;aT.fgcolor=a.ButtonFG;local aU="center"local aV="center"local au={getType=function(self)return al end,setHorizontalAlign=function(self,aW)aU=aW end,setVerticalAlign=function(self,aW)aV=aW end,setText=function(self,i)aT:setValue(i)return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,aV)self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)self.parent:drawTextBox(aX,aY,self.w,self.h," ")for l=1,self.h do if l==aZ then self.parent:setText(aX,aY+l-1,h(self:getValue(),self.w,aU))end end end end end}return setmetatable(au,aT)end;local function a_(ak)local aT=aj(ak)local al="Program"aT:setZIndex(5)local au;local function b0(L,M,j,n)local b1,b2=1,1;local b3,b4=colors.black,colors.white;local b5=false;local b6=false;local v={}local w={}local x={}local b7={}local B;local C={}for r=0,15 do local b8=2^r;b7[b8]={f.getPaletteColour(b8)}end;local function D()B=(" "):rep(j)for l=0,15 do local E=2^l;local F=s[E]C[E]=F:rep(j)end end;local function G()D()local H=B;local I=C[colors.white]local J=C[colors.black]for l=1,n do v[l]=g(v[l]==nil and H or v[l]..H:sub(1,j-v[l]:len()),1,j)x[l]=g(x[l]==nil and I or x[l]..I:sub(1,j-x[l]:len()),1,j)w[l]=g(w[l]==nil and J or w[l]..J:sub(1,j-w[l]:len()),1,j)end end;G()local function b9()if b1>=1 and b2>=1 and b1<=j and b2<=n then else end end;local function ba(bb,bc,bd)local be=b1;local P=be+#bb-1;if b2>=1 and b2<=n then if be<=j and P>=1 then if be==1 and P==j then v[b2]=bb;x[b2]=bc;w[b2]=bd else local bf,bg,bh;if be<1 then local bi=1-be+1;local bj=j-be+1;bf=g(bb,bi,bj)bg=g(bc,bi,bj)bh=g(bd,bi,bj)elseif P>j then local bj=j-be+1;bf=g(bb,1,bj)bg=g(bc,1,bj)bh=g(bd,1,bj)else bf=bb;bg=bc;bh=bd end;local bk=v[b2]local bl=x[b2]local bm=w[b2]local bn,bo,bp;if be>1 then local bq=be-1;bn=g(bk,1,bq)..bf;bo=g(bl,1,bq)..bg;bp=g(bm,1,bq)..bh else bn=bf;bo=bg;bp=bh end;if P<j then local br=P+1;bn=bn..g(bk,br,j)bo=bo..g(bl,br,j)bp=bp..g(bm,br,j)end;v[b2]=bn;x[b2]=bo;w[b2]=bp end end;b1=P+1;if b6 then b9()end end end;local function K(bs,bt,i)if i~=nil then local bu=v[bt]if bu~=nil then v[bt]=g(bu:sub(1,bs-1)..i..bu:sub(bs+i:len(),j),1,j)end end end;local function S(bs,bt,T)if T~=nil then local bv=w[bt]if bv~=nil then w[bt]=g(bv:sub(1,bs-1)..T..bv:sub(bs+T:len(),j),1,j)end end end;local function U(bs,bt,T)if T~=nil then local bw=x[bt]if bw~=nil then x[bt]=g(bw:sub(1,bs-1)..T..bw:sub(bs+T:len(),j),1,j)end end end;local bx=function(aC)if type(aC)~="number"then error("bad argument #1 (expected number, got "..type(aC)..")",2)elseif s[aC]==nil then error("Invalid color (got "..aC..")",2)end;b4=aC end;local by=function(aC)if type(aC)~="number"then error("bad argument #1 (expected number, got "..type(aC)..")",2)elseif s[aC]==nil then error("Invalid color (got "..aC..")",2)end;b3=aC end;local bz=function(bA,bB,bC,bD)if type(bA)~="number"then error("bad argument #1 (expected number, got "..type(bA)..")",2)end;if s[bA]==nil then error("Invalid color (got "..bA..")",2)end;local bE;if type(bB)=="number"and bC==nil and bD==nil then bE={colours.rgb8(bB)}b7[bA]=bE else if type(bB)~="number"then error("bad argument #2 (expected number, got "..type(bB)..")",2)end;if type(bC)~="number"then error("bad argument #3 (expected number, got "..type(bC)..")",2)end;if type(bD)~="number"then error("bad argument #4 (expected number, got "..type(bD)..")",2)end;bE=b7[bA]bE[1]=bB;bE[2]=bC;bE[3]=bD end end;local bF=function(bA)if type(bA)~="number"then error("bad argument #1 (expected number, got "..type(bA)..")",2)end;if s[bA]==nil then error("Invalid color (got "..bA..")",2)end;local bE=b7[bA]return bE[1],bE[2],bE[3]end;local bG={setCursorPos=function(bs,bt)if type(bs)~="number"then error("bad argument #1 (expected number, got "..type(bs)..")",2)end;if type(bt)~="number"then error("bad argument #2 (expected number, got "..type(bt)..")",2)end;b1=math.floor(bs)b2=math.floor(bt)if b6 then b9()end end,getCursorPos=function()return b1,b2 end,setCursorBlink=function(bH)if type(bH)~="boolean"then error("bad argument #1 (expected boolean, got "..type(bH)..")",2)end;b5=bH end,getCursorBlink=function()return b5 end,getPaletteColor=bF,getPaletteColour=bF,setBackgroundColor=by,setBackgroundColour=by,setTextColor=bx,setTextColour=bx,setPaletteColor=bz,setPaletteColour=bz,getBackgroundColor=function()return b3 end,getBackgroundColour=function()return b3 end,getSize=function()return j,n end,getTextColor=function()return b4 end,getTextColour=function()return b4 end,basalt_resize=function(bI,bJ)j,n=bI,bJ;G()end,basalt_reposition=function(bs,bt)L,M=bs,bt end,basalt_setVisible=function(bK)b6=bK end,drawBackgroundBox=function(bs,bt,bI,bJ,W)for l=1,bJ do S(bs,bt+l-1,s[W]:rep(bI))end end,drawForegroundBox=function(bs,bt,bI,bJ,X)for l=1,bJ do U(bs,bt+l-1,s[X]:rep(bI))end end,drawTextBox=function(bs,bt,bI,bJ,Y)for l=1,bJ do K(bs,bt+l-1,Y:rep(bI))end end,writeText=function(bs,bt,i,W,X)W=W or b3;X=X or b4;K(L,bt,i)S(bs,bt,s[W]:rep(i:len()))U(bs,bt,s[X]:rep(i:len()))end,basalt_update=function()if au.parent~=nil then for l=1,n do au.parent:setText(L,M+l-1,v[l])au.parent:setBG(L,M+l-1,w[l])au.parent:setFG(L,M+l-1,x[l])end end end,scroll=function(o)if type(o)~="number"then error("bad argument #1 (expected number, got "..type(o)..")",2)end;if o~=0 then local bL=B;local bM=C[b4]local bN=C[b3]for bO=1,n do local M=bO+o;if M>=1 and M<=n then v[bO]=v[M]w[bO]=w[M]x[bO]=x[M]else v[bO]=bL;x[bO]=bM;w[bO]=bN end end end;if b6 then b9()end end,isColor=function()return f.isColor()end,isColour=function()return f.isColor()end,write=function(i)i=tostring(i)if b6 then ba(i,s[b4]:rep(i:len()),s[b3]:rep(i:len()))end end,clearLine=function()if b6 then K(1,b2,(" "):rep(j))S(1,b2,s[b3]:rep(j))U(1,b2,s[b4]:rep(j))end;if b6 then b9()end end,clear=function()for l=1,n do K(1,l,(" "):rep(j))S(1,l,s[b3]:rep(j))U(1,l,s[b4]:rep(j))end;if b6 then b9()end end,blit=function(i,bP,bQ)if type(i)~="string"then error("bad argument #1 (expected string, got "..type(i)..")",2)end;if type(bP)~="string"then error("bad argument #2 (expected string, got "..type(bP)..")",2)end;if type(bQ)~="string"then error("bad argument #3 (expected string, got "..type(bQ)..")",2)end;if#bP~=#i or#bQ~=#i then error("Arguments must be the same length",2)end;if b6 then ba(i,bP,bQ)end end}return bG end;aT.w=30;aT.h=12;local bR=b0(1,1,aT.w,aT.h)local bS;local bT=false;local bU={}au={getType=function(self)return al end,show=function(self)aT.show(self)bR.setBackgroundColor(self.bgcolor)bR.setTextColor(self.fgcolor)bR.basalt_setVisible(true)return self end,hide=function(self)aT.hide(self)bR.basalt_setVisible(false)return self end,setPosition=function(self,L,M,aA)aT.setPosition(self,L,M,aA)bR.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return bR end,getBasaltProcess=function()return bS end,setSize=function(self,j,n)aT.setSize(self,j,n)bR.basalt_resize(self.w,self.h)return self end,getStatus=function(self)if bS~=nil then return bS:getStatus()end;return"inactive"end,execute=function(self,ad,...)bS=ab:new(ad,bR,...)bR.setBackgroundColor(colors.black)bR.setTextColor(colors.white)bR.clear()bR.setCursorPos(1,1)bS:resume()bT=false;return self end,stop=function(self)if bS~=nil then if not bS:isDead()then bS:resume("terminate")if bS:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,bV)bT=bV or not bT;if bS~=nil then if not bS:isDead()then if not bT then self:injectEvents(bU)bU={}end end end;return self end,isPaused=function(self)return bT end,injectEvent=function(self,a5,aO,aP,aQ,aR,bW)if bS~=nil then if not bS:isDead()then if bT==false or bW then bS:resume(a5,aO,aP,aQ,aR)else table.insert(bU,{event=a5,args={aO,aP,aQ,aR}})end end end;return self end,getQueuedEvents=function(self)return bU end,updateQueuedEvents=function(self,a3)bU=a3 or bU;return self end,injectEvents=function(self,a3)if bS~=nil then if not bS:isDead()then for aJ,a9 in pairs(a3)do bS:resume(a9.event,table.unpack(a9.args))end end end;return self end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then if bS==nil then return false end;if not bS:isDead()then if not bT then local bX,bY=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))bS:resume(a5,aK,L-bX+1,M-bY+1)end end;return true end end,keyHandler=function(self,a5,aN)aT.keyHandler(self,a5,aN)if self:isFocused()then if bS==nil then return false end;if not bS:isDead()then if not bT then if self.draw then bS:resume(a5,aN)end end end end end,getFocusHandler=function(self)aT.getFocusHandler(self)if bS~=nil then if not bS:isDead()then if not bT then if self.parent~=nil then local bZ,b_=bR.getCursorPos()local aX,aY=self:getAnchorPosition()if self.parent~=nil then if aX+bZ-1>=1 and aX+bZ-1<=aX+self.w-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.h-1 then self.parent:setCursor(bR.getCursorBlink(),aX+bZ-1,b_+aY-1,bR.getTextColor())end end end end end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if bS~=nil then if not bS:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,a5,aO,aP,aQ,aR)if bS==nil then return end;if not bS:isDead()then if not bT then if a5~="mouse_click"and a5~="mouse_up"and a5~="mouse_scroll"and a5~="mouse_drag"and a5~="key_up"and a5~="key"and a5~="char"and a5~="terminate"then bS:resume(a5,aO,aP,aQ,aR)end;if self:isFocused()then local aX,aY=self:getAnchorPosition()local bZ,b_=bR.getCursorPos()if self.parent~=nil then if aX+bZ-1>=1 and aX+bZ-1<=aX+self.w-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.h-1 then self.parent:setCursor(bR.getCursorBlink(),aX+bZ-1,b_+aY-1,bR.getTextColor())end end;if a5=="terminate"and self:isFocused()then self:stop()end end else if a5~="mouse_click"and a5~="mouse_up"and a5~="mouse_scroll"and a5~="mouse_drag"and a5~="key_up"and a5~="key"and a5~="char"and a5~="terminate"then table.insert(bU,{event=a5,args={aO,aP,aQ,aR}})end end end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()bR.basalt_reposition(aX,aY)self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)bR.basalt_update()end end end}return setmetatable(au,aT)end;local function c0(ak)local aT=aj(ak)local al="Label"aT:setZIndex(3)local c1=true;aT:setValue("")local au={getType=function(self)return al end,setText=function(self,i)i=tostring(i)aT:setValue(i)if c1 then self.w=i:len()end;return self end,setSize=function(self,j,n)self.w,self.h=j,n;c1=false;return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:writeText(aX,aY,self:getValue(),self.bgcolor,self.fgcolor)end end end}return setmetatable(au,aT)end;local function c2(ak)local aT=aj(ak)local al="Pane"local au={getType=function(self)return al end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.bgcolor)end end end}return setmetatable(au,aT)end;local function c3(ak)local aT=aj(ak)local al="Image"aT:setZIndex(2)local c4;local c5;local c6=false;local function c7()local c8={[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 c9,ca,cb={},{},{}for r=0,15 do ca[2^r]=r end;do local cc="0123456789abcdef"for r=1,16 do c9[cc:sub(r,r)]=r-1;c9[r-1]=cc:sub(r,r)cb[cc:sub(r,r)]=2^(r-1)cb[2^(r-1)]=cc:sub(r,r)local cd=c8[r-1]for r=1,#cd do cd[r]=2^cd[r]end end end;local function ce(cf)local cg=c8[ca[cf[#cf][1]]]for ch=1,#cg do local ci=cg[ch]for r=1,#cf-1 do if cf[r][1]==ci then return r end end end;return 1 end;local function cj(ck,cl)if not cl then local cm={}cl={}for r=1,6 do local cn=ck[r]local co=cl[cn]cl[cn],cm[r]=co and co+1 or 1,cn end;ck=cm end;local cf={}for aN,am in pairs(cl)do cf[#cf+1]={aN,am}end;if#cf>1 then while#cf>2 do table.sort(cf,function(cp,bD)return cp[2]>bD[2]end)local cq,cr=ce(cf),#cf;local cs,ct=cf[cr][1],cf[cq][1]for r=1,6 do if ck[r]==cs then ck[r]=ct;cf[cq][2]=cf[cq][2]+1 end end;cf[cr]=nil end;local cu=128;for r=1,#ck-1 do if ck[r]~=ck[6]then cu=cu+2^(r-1)end end;return string.char(cu),cb[cf[1][1]==ck[6]and cf[2][1]or cf[1][1]],cb[ck[6]]else return"\128",cb[ck[1]],cb[ck[1]]end end;local cv,cw,cx,W={{},{},{}},0,#c4+#c4%3,aT.bgcolor or colors.black;for r=1,#c4 do if#c4[r]>cw then cw=#c4[r]end end;for M=0,cx-1,3 do local cy,cz,cA,cB={},{},{},1;for L=0,cw-1,2 do local ck,cl={},{}for cC=1,3 do for cD=1,2 do ck[#ck+1]=c4[M+cC]and c4[M+cC][L+cD]and(c4[M+cC][L+cD]==0 and W or c4[M+cC][L+cD])or W;cl[ck[#ck]]=cl[ck[#ck]]and cl[ck[#ck]]+1 or 1 end end;cy[cB],cz[cB],cA[cB]=cj(ck,cl)cB=cB+1 end;cv[1][#cv[1]+1],cv[2][#cv[2]+1],cv[3][#cv[3]+1]=table.concat(cy),table.concat(cz),table.concat(cA)end;cv.width,cv.height=#cv[1][1],#cv[1]c5=cv end;local au={getType=function(self)return al end,loadImage=function(self,ad)c4=paintutils.loadImage(ad)c6=false;return self end,loadBlittleImage=function(self,ad)c6=true;return self end,shrinkImage=function(self)c7()c6=true;return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then if c4~=nil then local aX,aY=self:getAnchorPosition()if c6 then local q,cE,cF=c5[1],c5[2],c5[3]for r=1,c5.height do local cG=q[r]if type(cG)=="string"then self.parent:setText(aX,aY+r-1,cG)self.parent:setFG(aX,aY+r-1,cE[r])self.parent:setBG(aX,aY+r-1,cF[r])elseif type(cG)=="table"then self.parent:setText(aX,aY+r-1,cG[2])self.parent:setFG(aX,aY+r-1,cE[r])self.parent:setBG(aX,aY+r-1,cF[r])end end else for az=1,math.min(#c4,self.h)do local cH=c4[az]for ay=1,math.min(#cH,self.w)do if cH[ay]>0 then self.parent:drawBackgroundBox(aX+ay-1,aY+az-1,1,1,cH[ay])end end end end end end end end}return setmetatable(au,aT)end;local function cI(ak)local aT=aj(ak)local al="Checkbox"aT:setZIndex(5)aT:setValue(false)aT.w=1;aT.h=1;aT.bgcolor=a.CheckboxBG;aT.fgcolor=a.CheckboxFG;local au={symbol="\42",getType=function(self)return al end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then if a5=="mouse_click"and aK==1 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 aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,"center")self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if l==aZ then if self:getValue()==true then self.parent:writeText(aX,aY+l-1,h(self.symbol,self.w,"center"),self.bgcolor,self.fgcolor)else self.parent:writeText(aX,aY+l-1,h(" ",self.w,"center"),self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(au,aT)end;local function cJ(ak)local aT=aj(ak)local al="Progressbar"local cK=0;aT:setZIndex(5)aT:setValue(false)aT.w=25;aT.h=1;aT.bgcolor=a.CheckboxBG;aT.fgcolor=a.CheckboxFG;local cL=colors.black;local cM=""local cN=colors.white;local cO=""local cP=0;local au={getType=function(self)return al end,setDirection=function(self,cQ)cP=cQ;return self end,setProgressBar=function(self,aC,Y,cR)cL=aC or cL;cM=Y or cM;cN=cR or cN;return self end,setBackgroundSymbol=function(self,Y)cO=Y:sub(1,1)return self end,setProgress=function(self,am)if am>=0 and am<=100 and cK~=am then cK=am;self:setValue(cK)if cK==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return cK end,onProgressDone=function(self,cS)self:registerEvent("progress_done",cS)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)self.parent:drawTextBox(aX,aY,self.w,self.h,cO)if cP==1 then self.parent:drawBackgroundBox(aX,aY,self.w,self.h/100*cK,cL)self.parent:drawForegroundBox(aX,aY,self.w,self.h/100*cK,cN)self.parent:drawTextBox(aX,aY,self.w,self.h/100*cK,cM)elseif cP==2 then self.parent:drawBackgroundBox(aX,aY+math.ceil(self.h-self.h/100*cK),self.w,self.h/100*cK,cL)self.parent:drawForegroundBox(aX,aY+math.ceil(self.h-self.h/100*cK),self.w,self.h/100*cK,cN)self.parent:drawTextBox(aX,aY+math.ceil(self.h-self.h/100*cK),self.w,self.h/100*cK,cM)elseif cP==3 then self.parent:drawBackgroundBox(aX+math.ceil(self.w-self.w/100*cK),aY,self.w/100*cK,self.h,cL)self.parent:drawForegroundBox(aX+math.ceil(self.w-self.w/100*cK),aY,self.w/100*cK,self.h,cN)self.parent:drawTextBox(aX+math.ceil(self.w-self.w/100*cK),aY,self.w/100*cK,self.h,cM)else self.parent:drawBackgroundBox(aX,aY,self.w/100*cK,self.h,cL)self.parent:drawForegroundBox(aX,aY,self.w/100*cK,self.h,cN)self.parent:drawTextBox(aX,aY,self.w/100*cK,self.h,cM)end end end end}return setmetatable(au,aT)end;local function cT(ak)local aT=aj(ak)local al="Input"local cU="text"local cV=0;aT:setZIndex(5)aT:setValue("")aT.w=10;aT.h=1;aT.bgcolor=a.InputBG;aT.fgcolor=a.InputFG;local cW=1;local cX=1;local cY=""local cZ;local c_;local d0=cY;local d1=false;local au={getType=function(self)return al end,setInputType=function(self,d2)if d2=="password"or d2=="number"or d2=="text"then cU=d2 end;return self end,setDefaultText=function(self,i,d3,d4)cY=i;cZ=d4 or cZ;c_=d3 or c_;if self:isFocused()then d0=""else d0=cY end;return self end,getInputType=function(self)return cU end,setValue=function(self,d5)aT.setValue(self,tostring(d5))if not d1 then cW=tostring(d5):len()+1 end;return self end,getValue=function(self)local d5=aT.getValue(self)return cU=="number"and tonumber(d5)or d5 end,setInputLimit=function(self,d6)cV=tonumber(d6)or cV;return self end,getInputLimit=function(self)return cV end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then local aX,aY=self:getAnchorPosition()d0=""if self.parent~=nil then self.parent:setCursor(true,aX+cW-cX,aY,self.fgcolor)end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)d0=cY end end,keyHandler=function(self,a5,aN)if aT.keyHandler(self,a5,aN)then d1=true;if a5=="key"then if aN==keys.backspace then local i=tostring(aT.getValue())if cW>1 then self:setValue(i:sub(1,cW-2)..i:sub(cW,i:len()))if cW>1 then cW=cW-1 end;if cX>1 then if cW<cX then cX=cX-1 end end end end;if aN==keys.enter then if self.parent~=nil then end end;if aN==keys.right then local d7=tostring(aT.getValue()):len()cW=cW+1;if cW>d7 then cW=d7+1 end;if cW<1 then cW=1 end;if cW<cX or cW>=self.w+cX then cX=cW-self.w+1 end;if cX<1 then cX=1 end end;if aN==keys.left then cW=cW-1;if cW>=1 then if cW<cX or cW>=self.w+cX then cX=cW end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a5=="char"then local i=aT.getValue()if i:len()<cV or cV<=0 then if cU=="number"then local d8=i;if aN=="."or tonumber(aN)~=nil then self:setValue(i:sub(1,cW-1)..aN..i:sub(cW,i:len()))cW=cW+1 end;if tonumber(aT.getValue())==nil then self:setValue(d8)end else self:setValue(i:sub(1,cW-1)..aN..i:sub(cW,i:len()))cW=cW+1 end;if cW>=self.w+cX then cX=cX+1 end end end;local aX,aY=self:getAnchorPosition()local d5=tostring(aT.getValue())local d9=(cW<=d5:len()and cW-1 or d5:len())-(cX-1)if d9>self.x+self.w-1 then d9=self.x+self.w-1 end;if self.parent~=nil then self.parent:setCursor(true,aX+d9,aY,self.fgcolor)end;d1=false end end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then if a5=="mouse_click"and aK==1 then end;return true end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,"center")self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if l==aZ then local d5=tostring(aT.getValue())local d4=self.bgcolor;local d3=self.fgcolor;local i;if d5:len()<=0 then i=d0;d4=cZ or d4;d3=c_ or d3 end;i=d0;if d5~=""then i=d5 end;i=i:sub(cX,self.w+cX-1)local da=self.w-i:len()if da<0 then da=0 end;if cU=="password"and d5~=""then i=string.rep("*",i:len())end;i=i..string.rep(" ",da)self.parent:writeText(aX,aY+l-1,i,d4,d3)end end end end end}return setmetatable(au,aT)end;local function db(ak)local aT=aj(ak)local al="Textfield"local dc,cX,cW,dd=1,1,1,1;local de={""}local df={[colors.purple]={"break"}}aT.w=20;aT.h=8;aT.bgcolor=a.textfieldBG;aT.fgcolor=a.textfieldFG;aT:setZIndex(5)local au={getType=function(self)return al end,getLines=function(self)return de end,getLine=function(self,a4)return de[a4]or""end,editLine=function(self,a4,i)de[a4]=i or de[a4]return self end,addLine=function(self,i,a4)if a4~=nil then table.insert(de,a4,i)else table.insert(de,i)end;return self end,addKeyword=function(self,dg,aC)end,removeLine=function(self,a4)table.remove(de,a4 or#de)if#de<=0 then table.insert(de,"")end;return self end,getTextCursor=function(self)return cW,dd end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then local aX,aY=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,aX+cW-cX,aY+dd-dc,self.fgcolor)end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,a5,aN)if aT.keyHandler(self,a5,aN)then local aX,aY=self:getAnchorPosition()if a5=="key"then if aN==keys.backspace then if de[dd]==""then if dd>1 then table.remove(de,dd)cW=de[dd-1]:len()+1;cX=cW-self.w+1;if cX<1 then cX=1 end;dd=dd-1 end elseif cW<=1 then if dd>1 then cW=de[dd-1]:len()+1;cX=cW-self.w+1;if cX<1 then cX=1 end;de[dd-1]=de[dd-1]..de[dd]table.remove(de,dd)dd=dd-1 end else de[dd]=de[dd]:sub(1,cW-2)..de[dd]:sub(cW,de[dd]:len())if cW>1 then cW=cW-1 end;if cX>1 then if cW<cX then cX=cX-1 end end end;if dd<dc then dc=dc-1 end;self:setValue("")end;if aN==keys.delete then if cW>de[dd]:len()then if de[dd+1]~=nil then de[dd]=de[dd]..de[dd+1]table.remove(de,dd+1)end else de[dd]=de[dd]:sub(1,cW-1)..de[dd]:sub(cW+1,de[dd]:len())end end;if aN==keys.enter then table.insert(de,dd+1,de[dd]:sub(cW,de[dd]:len()))de[dd]=de[dd]:sub(1,cW-1)dd=dd+1;cW=1;cX=1;if dd-dc>=self.h then dc=dc+1 end;self:setValue("")end;if aN==keys.up then if dd>1 then dd=dd-1;if cW>de[dd]:len()+1 then cW=de[dd]:len()+1 end;if cX>1 then if cW<cX then cX=cW-self.w+1;if cX<1 then cX=1 end end end;if dc>1 then if dd<dc then dc=dc-1 end end end end;if aN==keys.down then if dd<#de then dd=dd+1;if cW>de[dd]:len()+1 then cW=de[dd]:len()+1 end;if dd>=dc+self.h then dc=dc+1 end end end;if aN==keys.right then cW=cW+1;if dd<#de then if cW>de[dd]:len()+1 then cW=1;dd=dd+1 end elseif cW>de[dd]:len()then cW=de[dd]:len()+1 end;if cW<1 then cW=1 end;if cW<cX or cW>=self.w+cX then cX=cW-self.w+1 end;if cX<1 then cX=1 end end;if aN==keys.left then cW=cW-1;if cW>=1 then if cW<cX or cW>=self.w+cX then cX=cW end end;if dd>1 then if cW<1 then dd=dd-1;cW=de[dd]:len()+1;cX=cW-self.w+1 end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a5=="char"then de[dd]=de[dd]:sub(1,cW-1)..aN..de[dd]:sub(cW,de[dd]:len())cW=cW+1;if cW>=self.w+cX then cX=cX+1 end;self:setValue("")end;local d9=(cW<=de[dd]:len()and cW-1 or de[dd]:len())-(cX-1)if d9>self.x+self.w-1 then d9=self.x+self.w-1 end;local dh=dd-dc<self.h and dd-dc or dd-dc-1;if d9<1 then d9=0 end;self.parent:setCursor(true,aX+d9,aY+dh,self.fgcolor)return true end end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())local di,dj=self:getAnchorPosition()if a5=="mouse_click"then if de[M-aY+dc]~=nil then cW=L-aX+cX;dd=M-aY+dc;if cW>de[dd]:len()then cW=de[dd]:len()+1 end;if cW<cX then cX=cW-1;if cX<1 then cX=1 end end;if self.parent~=nil then self.parent:setCursor(true,di+cW-cX,dj+dd-dc)end end end;if a5=="mouse_drag"then if de[M-aY+dc]~=nil then cW=L-aX+cX;dd=M-aY+dc;if cW>de[dd]:len()then cW=de[dd]:len()+1 end;if cW<cX then cX=cW-1;if cX<1 then cX=1 end end;if self.parent~=nil then self.parent:setCursor(true,di+cW-cX,dj+dd-dc)end end end;if a5=="mouse_scroll"then dc=dc+aK;if dc>#de-(self.h-1)then dc=#de-(self.h-1)end;if dc<1 then dc=1 end;if self.parent~=nil then if aX+cW-cX>=aX and aX+cW-cX<=aX+self.w and(aY+dd-dc>=aY and aY+dd-dc<=aY+self.h)then self.parent:setCursor(true,di+cW-cX,dj+dd-dc)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)for l=1,self.h do local i=""if de[l+dc-1]~=nil then i=de[l+dc-1]end;i=i:sub(cX,self.w+cX-1)local da=self.w-i:len()if da<0 then da=0 end;i=i..string.rep(" ",da)self.parent:setText(aX,aY+l-1,i)end end end end}return setmetatable(au,aT)end;local function dk(ak)local aT=aj(ak)local al="List"aT.w=16;aT.h=6;aT.bgcolor=a.listBG;aT.fgcolor=a.listFG;aT:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dr=0;local ds=true;local au={getType=function(self)return al end,addItem=function(self,i,W,X,...)table.insert(dl,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,setIndexOffset=function(self,dt)dr=dt;return self end,getIndexOffset=function(self)return dr end,removeItem=function(self,a4)table.remove(dl,a4)return self end,getItem=function(self,a4)return dl[a4]end,getItemIndex=function(self)local du=self:getValue()for a8,a9 in pairs(dl)do if a9==du then return a8 end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a4,i,W,X,...)table.remove(dl,a4)table.insert(dl,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(dl[a4]or{})return self end,setSelectedItem=function(self,W,X,dv)dm=W or self.bgcolor;dn=X or self.fgcolor;dp=dv;return self end,setScrollable=function(self,dw)ds=dw;return self end,mouseClickHandler=function(self,a5,aK,L,M)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if aX<=L and aX+self.w>L and aY<=M and aY+self.h>M and self:isVisible()then if a5=="mouse_click"or a5=="mouse_drag"then if aK==1 then if#dl>0 then for l=1,self.h do if dl[l+dr]~=nil then if aX<=L and aX+self.w>L and aY+l-1==M then self:setValue(dl[l+dr])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,L,M,dl[l+dr])end end end end end end;if a5=="mouse_scroll"and ds then dr=dr+aK;if dr<0 then dr=0 end;if aK>=1 then if#dl>self.h then if dr>#dl-self.h then dr=#dl-self.h end;if dr>=#dl then dr=#dl-1 end else dr=dr-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if dl[l+dr]~=nil then if dl[l+dr]==self:getValue()then if dp then self.parent:writeText(aX,aY+l-1,h(dl[l+dr].text,self.w,dq),dm,dn)else self.parent:writeText(aX,aY+l-1,h(dl[l+dr].text,self.w,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end else self.parent:writeText(aX,aY+l-1,h(dl[l+dr].text,self.w,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end end end end end end}return setmetatable(au,aT)end;local function dx(ak)local aT=aj(ak)local al="Menubar"local au={}aT.w=30;aT.h=1;aT.bgcolor=colors.gray;aT.fgcolor=colors.lightGray;aT:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dy=0;local da=2;local ds=false;local function dz()local dA=0;local ay=1;for l=1,#dl do if ay+dl[l].text:len()+da*2>au.w then dA=dA+dl[l].text:len()+da*2 end;ay=ay+dl[l].text:len()+da*2 end;return dA end;au={getType=function(self)return al end,addItem=function(self,i,W,X,...)table.insert(dl,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,getItemIndex=function(self)local du=self:getValue()for a8,a9 in pairs(dl)do if a9==du then return a8 end end end,clear=function(self)dl={}self:setValue({})return self end,setSpace=function(self,dB)da=dB or da;return self end,setButtonOffset=function(self,o)dy=o or 0;if dy<0 then dy=0 end;local dA=dz()if dy>dA then dy=dA end;return self end,setScrollable=function(self,dw)ds=dw;return self end,removeItem=function(self,a4)table.remove(dl,a4)return self end,getItem=function(self,a4)return dl[a4]end,getItemCount=function(self)return#dl end,editItem=function(self,a4,i,W,X,...)table.remove(dl,a4)table.insert(dl,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(dl[a4]or{})return self end,setSelectedItem=function(self,W,X,dv)dm=W or self.bgcolor;dn=X or self.fgcolor;dp=dv;return self end,mouseClickHandler=function(self,a5,aK,L,M)local aL,aM=self:getAbsolutePosition(self:getAnchorPosition())if aL<=L and aL+self.w>L and aM<=M and aM+self.h>M and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if a5=="mouse_click"then local ay=1;for l=1+dy,#dl do if dl[l]~=nil then if ay+dl[l].text:len()+da*2<=self.w then if aL+ay-1<=L and aL+ay-1+dl[l].text:len()+da*2>L and aM==M then self:setValue(dl[l])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,L,M,dl[l])end;ay=ay+dl[l].text:len()+da*2 else break end end end end;if a5=="mouse_scroll"and ds then dy=dy+aK;if dy<0 then dy=0 end;local dA=dz()if dy>dA then dy=dA end end;return true end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)local ay=0;for a8,a9 in pairs(dl)do if ay+a9.text:len()+da*2<=self.w then if a9==self:getValue()then self.parent:writeText(aX+ay-1+-dy,aY,h((" "):rep(da)..a9.text..(" "):rep(da),a9.text:len()+da*2,dq),dm or a9.bgCol,dn or a9.fgCol)else self.parent:writeText(aX+ay-1+-dy,aY,h((" "):rep(da)..a9.text..(" "):rep(da),a9.text:len()+da*2,dq),a9.bgCol,a9.fgCol)end;ay=ay+a9.text:len()+da*2 else if ay<self.w+dy then if a9==self:getValue()then self.parent:writeText(aX+ay-1+-dy,aY,h((" "):rep(da)..a9.text..(" "):rep(da),a9.text:len()+da*2,dq):sub(1,self.w+dy-ay),dm or a9.bgCol,dn or a9.fgCol)else self.parent:writeText(aX+ay-1+-dy,aY,h((" "):rep(da)..a9.text..(" "):rep(da),a9.text:len()+da*2,dq):sub(1,self.w+dy-ay),a9.bgCol,a9.fgCol)end;ay=ay+a9.text:len()+da*2 end end end end end end}return setmetatable(au,aT)end;local function dC(ak)local aT=aj(ak)local al="Dropdown"aT.w=12;aT.h=1;aT.bgcolor=a.dropdownBG;aT.fgcolor=a.dropdownFG;aT:setZIndex(6)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dr=0;local dD=16;local dE=6;local dF="\16"local dG="\31"local dH=1;local au={getType=function(self)return al end,setIndexOffset=function(self,dt)dr=dt;return self end,getIndexOffset=function(self)return dr end,addItem=function(self,i,W,X,...)table.insert(dl,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,removeItem=function(self,a4)table.remove(dl,a4)return self end,getItem=function(self,a4)return dl[a4]end,getItemIndex=function(self)local du=self:getValue()for a8,a9 in pairs(dl)do if a9==du then return a8 end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a4,i,W,X,...)table.remove(dl,a4)table.insert(dl,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(dl[a4]or{})return self end,setSelectedItem=function(self,W,X,dv)dm=W or self.bgcolor;dn=X or self.fgcolor;dp=dv;return self end,setDropdownSize=function(self,j,n)dD,dE=j,n;return self end,mouseClickHandler=function(self,a5,aK,L,M)if dH==2 then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"then if aK==1 then if#dl>0 then for l=1,dE do if dl[l+dr]~=nil then if aX<=L and aX+dD>L and aY+l==M then self:setValue(dl[l+dr])return true end end end end end end;if a5=="mouse_scroll"then dr=dr+aK;if dr<0 then dr=0 end;if aK==1 then if#dl>dE then if dr>#dl-dE then dr=#dl-dE end else dr=dl-1 end end;return true end;self:setVisualChanged()end;if aT.mouseClickHandler(self,a5,aK,L,M)then dH=2 else dH=1 end end,draw=function(self)if aT.draw(self)then local aX,aY=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)if#dl>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if dH==1 then self.parent:writeText(aX,aY,h(self:getValue().text,self.w,dq):sub(1,self.w-1)..dF,self.bgcolor,self.fgcolor)else self.parent:writeText(aX,aY,h(self:getValue().text,self.w,dq):sub(1,self.w-1)..dG,self.bgcolor,self.fgcolor)end end end;if dH==2 then for l=1,dE do if dl[l+dr]~=nil then if dl[l+dr]==self:getValue()then if dp then self.parent:writeText(aX,aY+l,h(dl[l+dr].text,dD,dq),dm,dn)else self.parent:writeText(aX,aY+l,h(dl[l+dr].text,dD,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end else self.parent:writeText(aX,aY+l,h(dl[l+dr].text,dD,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end end end end end end end end}return setmetatable(au,aT)end;local function dI(ak)local aT=aj(ak)local al="Radio"aT.w=8;aT.bgcolor=a.listBG;aT.fgcolor=a.listFG;aT:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dJ=aT.bgcolor;local dK=aT.fgcolor;local dp=true;local Y="\7"local dq="left"local au={getType=function(self)return al end,addItem=function(self,i,L,M,W,X,...)table.insert(dl,{x=L or 1,y=M or 1,text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,removeItem=function(self,a4)table.remove(dl,a4)return self end,getItem=function(self,a4)return dl[a4]end,getItemIndex=function(self)local du=self:getValue()for a8,a9 in pairs(dl)do if a9==du then return a8 end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a4,i,L,M,W,X,...)table.remove(dl,a4)table.insert(dl,a4,{x=L or 1,y=M or 1,text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(dl[a4]or{})return self end,setSelectedItem=function(self,W,X,dL,dM,dv)dm=W or dm;dn=X or dn;dJ=dL or dJ;dK=dM or dK;dp=dv;return self end,mouseClickHandler=function(self,a5,aK,L,M)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"then if aK==1 then if#dl>0 then for aJ,a9 in pairs(dl)do if aX+a9.x-1<=L and aX+a9.x-1+a9.text:len()+2>=L and aY+a9.y-1==M then self:setValue(a9)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()for aJ,a9 in pairs(dl)do if a9==self:getValue()then if dq=="left"then self.parent:writeText(a9.x+aX-1,a9.y+aY-1,Y,dJ,dK)self.parent:writeText(a9.x+2+aX-1,a9.y+aY-1,a9.text,dm,dn)end else self.parent:drawBackgroundBox(a9.x+aX-1,a9.y+aY-1,1,1,self.bgcolor)self.parent:writeText(a9.x+2+aX-1,a9.y+aY-1,a9.text,a9.bgCol,a9.fgCol)end end end end end}return setmetatable(au,aT)end;local function dN(ak)local al="Timer"local dO=0;local dP=0;local dQ=0;local dR;local at=a2()local au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,dS,dT)dO=dS or 0;dP=dT or 1;return self end,start=function(self)dQ=dP;dR=os.startTimer(dO)return self end,cancel=function(self)if dR~=nil then os.cancelTimer(dR)end;return self end,onCall=function(self,a7)at:registerEvent("timed_event",a7)return self end,eventHandler=function(self,a5,dU)if a5=="timer"and dU==dR then at:sendEvent("timed_event",self)if dQ>=1 then dQ=dQ-1;if dQ>=1 then dR=os.startTimer(dO)end elseif dQ==-1 then dR=os.startTimer(dO)end end end}au.__index=au;return au end;local function dV(ak)local au;local al="Thread"local a7;local dW;local dX=false;au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,cS)if cS==nil then error("function is nil")end;a7=cS;dW=coroutine.create(a7)dX=true;local ah,ai=coroutine.resume(dW)if not ah then if ai~="Terminated"then error("Threaderror - "..ai)end end;return self end,getStatus=function(self,cS)if dW~=nil then return coroutine.status(dW)end;return nil end,stop=function(self,cS)dX=false;return self end,eventHandler=function(self,a5,aO,aP,aQ)if dX then if coroutine.status(dW)~="dead"then local ah,ai=coroutine.resume(dW,a5,aO,aP,aQ)if not ah then if ai~="Terminated"then error("Threaderror - "..ai)end end else dX=false end end end}au.__index=au;return au end;local function dY(ak)local au={}local al="Animation"local dR;local dZ={}local a4=1;local d_=0;local e0;local function e1()if dZ[a4]~=nil then dZ[a4].f(au,a4)end;a4=a4+1;if dZ[a4]~=nil then if dZ[a4].t>0 then dR=os.startTimer(dZ[a4].t)else e1()end end end;au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,a7,e2)e0=a7;table.insert(dZ,{f=a7,t=e2 or d_})return self end,wait=function(self,e2)d_=e2;return self end,rep=function(self,e3)for L=1,e3 do table.insert(dZ,{f=e0,t=d_})end;return self end,clear=function(self)dZ={}e0=nil;d_=0;a4=1;return self end,play=function(self)a4=1;if dZ[a4]~=nil then if dZ[a4].t>0 then dR=os.startTimer(dZ[a4].t)else e1()end end;return self end,cancel=function(self)os.cancelTimer(dR)return self end,eventHandler=function(self,a5,dU)if a5=="timer"and dU==dR then if dZ[a4]~=nil then e1()end end end}au.__index=au;return au end;local function e4(ak)local aT=aj(ak)local al="Slider"aT.w=8;aT.bgcolor=colors.lightGray;aT.fgcolor=colors.gray;aT:setValue(1)local e5="horizontal"local Y=" "local e6=colors.black;local e7="\140"local e8=aT.w;local a4=1;local au={getType=function(self)return al end,setSymbol=function(self,e9)Y=e9:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,ea)e7=string.sub(ea,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eb)e6=eb;self:setVisualChanged()return self end,setBarType=function(self,ec)e5=ec:lower()return self end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if e5=="horizontal"then for ed=0,self.w-1 do if aX+ed==L and aY<=M and aY+self.h>M then a4=ed+1;self:setValue(e8/self.w*a4)self:setVisualChanged()end end end;if e5=="vertical"then for ed=0,self.h-1 do if aY+ed==M and aX<=L and aX+self.w>L then a4=ed+1;self:setValue(e8/self.h*a4)self:setVisualChanged()end end end end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()if e5=="horizontal"then self.parent:writeText(aX,aY,e7:rep(a4-1),self.bgcolor,self.fgcolor)self.parent:writeText(aX+a4-1,aY,Y,e6,e6)self.parent:writeText(aX+a4,aY,e7:rep(self.w-a4),self.bgcolor,self.fgcolor)end;if e5=="vertical"then for l=0,self.h-1 do if l+1==a4 then self.parent:writeText(aX,aY+l,Y,e6,e6)else self.parent:writeText(aX,aY+l,e7,self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(au,aT)end;local function ee(ak)local aT=aj(ak)local al="Scrollbar"aT.w=1;aT.h=8;aT.bgcolor=colors.lightGray;aT.fgcolor=colors.gray;aT:setValue(1)aT:setZIndex(2)local e5="vertical"local Y=" "local e6=colors.black;local e7="\127"local e8=aT.h;local a4=1;local ef=1;local au={getType=function(self)return al end,setSymbol=function(self,e9)Y=e9:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,eg)ef=tonumber(eg)or 1;if e5=="vertical"then self:setValue(a4-1*e8/(self.h-(ef-1))-e8/(self.h-(ef-1)))elseif e5=="horizontal"then self:setValue(a4-1*e8/(self.w-(ef-1))-e8/(self.w-(ef-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,d5)e8=d5;return self end,setBackgroundSymbol=function(self,ea)e7=string.sub(ea,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eb)e6=eb;self:setVisualChanged()return self end,setBarType=function(self,ec)e5=ec:lower()return self end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if(a5=="mouse_click"or a5=="mouse_drag")and aK==1 then if e5=="horizontal"then for ed=0,self.w do if aX+ed==L and aY<=M and aY+self.h>M then a4=math.min(ed+1,self.w-(ef-1))self:setValue(e8/self.w*a4)self:setVisualChanged()end end end;if e5=="vertical"then for ed=0,self.h do if aY+ed==M and aX<=L and aX+self.w>L then a4=math.min(ed+1,self.h-(ef-1))self:setValue(e8/self.h*a4)self:setVisualChanged()end end end end;if a5=="mouse_scroll"then a4=a4+aK;if a4<1 then a4=1 end;a4=math.min(a4,(e5=="vertical"and self.h or self.w)-(ef-1))self:setValue(e8/(e5=="vertical"and self.h or self.w)*a4)end;return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()if e5=="horizontal"then self.parent:writeText(aX,aY,e7:rep(a4-1),self.bgcolor,self.fgcolor)self.parent:writeText(aX+a4-1,aY,Y:rep(ef),e6,e6)self.parent:writeText(aX+a4+ef-1,aY,e7:rep(self.w-(a4+ef-1)),self.bgcolor,self.fgcolor)end;if e5=="vertical"then for l=0,self.h-1 do if a4==l+1 then for eh=0,math.min(ef-1,self.h)do self.parent:writeText(aX,aY+l+eh,Y,e6,e6)end else if l+1<a4 or l+1>a4-1+ef then self.parent:writeText(aX,aY+l,e7,self.bgcolor,self.fgcolor)end end end end end end end}return setmetatable(au,aT)end;local function ei(ak)local aT=aj(ak)local al="Switch"aT.w=3;aT.h=1;aT.bgcolor=colors.lightGray;aT.fgcolor=colors.gray;aT:setValue(false)aT:setZIndex(5)local au={getType=function(self)return al end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if(a5=="mouse_click"or a5=="mouse_drag")and aK==1 then end;return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()end end end}return setmetatable(au,aT)end;local function ej(ak,ek)local aT=aj(ak)local al="Frame"local el={}local em={}local au={}local en;aT:setZIndex(10)local b5=false;local b1=1;local b2=1;local eo=colors.white;local ep,dr=0,0;if ek~=nil then aT.parent=ek;aT.w,aT.h=ek.w,ek.h;aT.bgcolor=a.FrameBG;aT.fgcolor=a.FrameFG else local eq,er=f.getSize()aT.w,aT.h=eq,er;aT.bgcolor=a.basaltBG;aT.fgcolor=a.basaltFG end;local function es(ak)for a8,a9 in pairs(el)do for cp,bD in pairs(a9)do if bD.name==ak then return a9 end end end end;local function et(eu)local an=eu:getZIndex()if es(eu.name)~=nil then return nil end;if el[an]==nil then for L=1,#em+1 do if em[L]~=nil then if an==em[L]then break end;if an>em[L]then table.insert(em,L,an)break end else table.insert(em,an)end end;if#em<=0 then table.insert(em,an)end;el[an]={}end;eu.parent=au;table.insert(el[an],eu)return eu end;local function ev(eu)for cp,bD in pairs(el)do for a8,a9 in pairs(bD)do if a9==eu then table.remove(el[cp],a8)return true end end end;return false end;au={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return al end,setFocusedObject=function(self,eu)for aJ,a4 in pairs(em)do for aJ,a9 in pairs(el[a4])do if a9==eu then if en~=nil then en:loseFocusHandler()end;en=eu;en:getFocusHandler()end end end;return self end,setOffset=function(self,aG,aH)ep=aG~=nil and math.floor(aG<0 and math.abs(aG)or-aG)or ep;dr=aH~=nil and math.floor(aH<0 and math.abs(aH)or-aH)or dr;return self end,getFrameOffset=function(self)return ep,dr end,removeFocusedObject=function(self)if en~=nil then en:loseFocusHandler()end;en=nil;return self end,getFocusedObject=function(self)return en end,show=function(self)aT:show()if self.parent==nil then c=self end;return self end,setCursor=function(self,ew,ex,ey,aC)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())b5=ew or false;if ex~=nil then b1=aX+ex-1 end;if ey~=nil then b2=aY+ey-1 end;eo=aC or eo;self:setVisualChanged()return self end,setMoveable=function(self,ez)self.isMoveable=ez or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,eA)self.barActive=eA or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,i,W,X)self.barText=i or""self.barBackground=W or self.barBackground;self.barTextcolor=X or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,dq)self.barTextAlign=dq or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local eB=aT.getVisualChanged(self)for aJ,a4 in pairs(em)do if el[a4]~=nil then for aJ,a9 in pairs(el[a4])do if a9.getVisualChanged~=nil and a9:getVisualChanged()then eB=true end end end end;return eB end,loseFocusHandler=function(self)aT.loseFocusHandler(self)end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,a5,aN)if en~=nil then if en.keyHandler~=nil then if en:keyHandler(a5,aN)then return true end end end;return false end,backgroundKeyHandler=function(self,a5,aN)aT.backgroundKeyHandler(self,a5,aN)for aJ,a4 in pairs(em)do if el[a4]~=nil then for aJ,a9 in pairs(el[a4])do if a9.backgroundKeyHandler~=nil then a9:backgroundKeyHandler(a5,aN)end end end end end,eventHandler=function(self,a5,aO,aP,aQ,aR)aT.eventHandler(self,a5,aO,aP,aQ,aR)for aJ,a4 in pairs(em)do if el[a4]~=nil then for aJ,a9 in pairs(el[a4])do if a9.eventHandler~=nil then a9:eventHandler(a5,aO,aP,aQ,aR)end end end end;if a5=="terminate"then f.clear()f.setCursorPos(1,1)b.stop()end end,mouseClickHandler=function(self,a5,aK,L,M)local aG,aH=self:getOffset()aG=aG<0 and math.abs(aG)or-aG;aH=aH<0 and math.abs(aH)or-aH;if self.drag then if a5=="mouse_drag"then local eC=1;local eD=1;if self.parent~=nil then eC,eD=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(L+self.xToRem-(eC-1)+aG,M-(eD-1)+aH)end;if a5=="mouse_up"then self.drag=false end;return true end;if aT.mouseClickHandler(self,a5,aK,L,M)then local aD,aE=self:getAbsolutePosition(self:getAnchorPosition())for aJ,a4 in pairs(em)do if el[a4]~=nil then for aJ,a9 in p(el[a4])do if a9.mouseClickHandler~=nil then if a9:mouseClickHandler(a5,aK,L+aG,M+aH)then return true end end end end end;if self.isMoveable then if L>=aD and L<=aD+self.w-1 and M==aE and a5=="mouse_click"then self.drag=true;self.xToRem=aD-L end end;if en~=nil then en:loseFocusHandler()en=nil end;return true end;return false end,setText=function(self,L,M,i)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setText(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(i,math.max(1-L+1,1),self.w-L+1))else V.setText(math.max(L+aX-1,aX),aY+M-1,g(i,math.max(1-L+1,1),self.w-L+1))end end end,setBG=function(self,L,M,W)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setBG(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(W,math.max(1-L+1,1),self.w-L+1))else V.setBG(math.max(L+aX-1,aX),aY+M-1,g(W,math.max(1-L+1,1),self.w-L+1))end end end,setFG=function(self,L,M,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setFG(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(X,math.max(1-L+1,1),self.w-L+1))else V.setFG(math.max(L+aX-1,aX),aY+M-1,g(X,math.max(1-L+1,1),self.w-L+1))end end end,writeText=function(self,L,M,i,W,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:writeText(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(i,math.max(1-L+1,1),self.w-L+1),W,X)else V.writeText(math.max(L+aX-1,aX),aY+M-1,g(i,math.max(1-L+1,1),self.w-L+1),W,X)end end end,drawBackgroundBox=function(self,L,M,j,n,W)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,W)else V.drawBackgroundBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,W)end end,drawTextBox=function(self,L,M,j,n,Y)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawTextBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,Y:sub(1,1))else V.drawTextBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,Y:sub(1,1))end end,drawForegroundBox=function(self,L,M,j,n,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawForegroundBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,X)else V.drawForegroundBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,X)end end,draw=function(self)if self:getVisualChanged()then if aT.draw(self)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())local di,dj=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(di,dj,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(di,dj,self.w,self.h,self.fgcolor)self.parent:drawTextBox(di,dj,self.w,self.h," ")else V.drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)V.drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)V.drawTextBox(aX,aY,self.w,self.h," ")end;f.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(di,dj,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)else V.writeText(aX,aY,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aJ,a4 in p(em)do if el[a4]~=nil then for aJ,a9 in pairs(el[a4])do if a9.draw~=nil then a9:draw()end end end end;if b5 then f.setTextColor(eo)f.setCursorPos(b1,b2)if self.parent~=nil then f.setCursorBlink(self:isFocused())else f.setCursorBlink(b5)end end;self:setVisualChanged(false)end end end,addObject=function(self,eu)return et(eu)end,removeObject=function(self,eu)return ev(eu)end,getObject=function(self,eu)return es(eu)end,addButton=function(self,ak)local eu=aS(ak)eu.name=ak;return et(eu)end,addLabel=function(self,ak)local eu=c0(ak)eu.name=ak;eu.bgcolor=self.bgcolor;eu.fgcolor=self.fgcolor;return et(eu)end,addCheckbox=function(self,ak)local eu=cI(ak)eu.name=ak;return et(eu)end,addInput=function(self,ak)local eu=cT(ak)eu.name=ak;return et(eu)end,addProgram=function(self,ak)local eu=a_(ak)eu.name=ak;return et(eu)end,addTextfield=function(self,ak)local eu=db(ak)eu.name=ak;return et(eu)end,addList=function(self,ak)local eu=dk(ak)eu.name=ak;return et(eu)end,addDropdown=function(self,ak)local eu=dC(ak)eu.name=ak;return et(eu)end,addRadio=function(self,ak)local eu=dI(ak)eu.name=ak;return et(eu)end,addTimer=function(self,ak)local eu=dN(ak)eu.name=ak;return et(eu)end,addAnimation=function(self,ak)local eu=dY(ak)eu.name=ak;return et(eu)end,addSlider=function(self,ak)local eu=e4(ak)eu.name=ak;return et(eu)end,addScrollbar=function(self,ak)local eu=ee(ak)eu.name=ak;return et(eu)end,addMenubar=function(self,ak)local eu=dx(ak)eu.name=ak;return et(eu)end,addThread=function(self,ak)local eu=dV(ak)eu.name=ak;return et(eu)end,addPane=function(self,ak)local eu=c2(ak)eu.name=ak;return et(eu)end,addImage=function(self,ak)local eu=c3(ak)eu.name=ak;return et(eu)end,addProgressbar=function(self,ak)local eu=cJ(ak)eu.name=ak;return et(eu)end,addFrame=function(self,ak)local eu=ej(ak,self)eu.name=ak;return et(eu)end}setmetatable(au,aT)if ek==nil then table.insert(d,au)end;return au end;local eE=false;local function eF(a5,aO,aP,aQ,aR)if a5=="mouse_click"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_drag"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_up"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_scroll"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="key"or a5=="char"then c:keyHandler(a5,aO)c:backgroundKeyHandler(a5,aO)end;for aJ,a9 in pairs(d)do a9:eventHandler(a5,aO,aP,aQ,aR)end;if eE then c:draw()V.update()end end;function b.autoUpdate(dX)f.clear()eE=dX or true;c:draw()V.update()while eE do local a5,aO,aP,aQ,aR=os.pullEventRaw()eF(a5,aO,aP,aQ,aR)end end;function b.update(a5,aO,aP,aQ,aR)if a5~="nil"then eF(a5,aO,aP,aQ,aR)else c:draw()V.update()end end;function b.stop()eE=false end;function b.getFrame(ak)for a8,a9 in pairs(d)do if a9.name==ak then return a9 end end end;function b.getActiveFrame()return c end;function b.setActiveFrame(av)if av:getType()=="Frame"then c=av;return true end;return false end;function b.createFrame(ak)local av=ej(ak)return av end;function b.removeFrame(ak)for a8,a9 in pairs(d)do if a9.name==ak then d[a8]=nil;return true end end;return false end;if b.debugger then b.debugFrame=b.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)b.debugList=b.debugFrame:addList("debugList"):setSize(b.debugFrame.w-2,b.debugFrame.h-3):setPosition(2,3):setScrollable(true):show()b.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()b.oldFrame:show()end):setBackground(colors.red):show()b.debugLabel=b.debugFrame:addLabel("debugLabel"):onClick(function()b.oldFrame=c;b.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if b.debugger then function b.debug(...)local af={...}if c.name~="basaltDebuggingFrame"then if c~=b.debugLabel.frame then b.debugLabel:setParent(c)end end;local eG=""for a8,a9 in pairs(af)do eG=eG..tostring(a9)..(#af~=a8 and", "or"")end;b.debugLabel:setText("[Debug] "..eG)b.debugList:addItem(eG)if b.debugList:getItemCount()>50 then b.debugList:removeItem(1)end;b.debugList:setValue(b.debugList:getItem(b.debugList:getItemCount()))b.debugLabel:show()end end;return b