Files
Basalt/basalt-minified.lua

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