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 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 q=0,15 do local b8=2^q;b7[b8]={f.getPaletteColour(b8)}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 b9()if b1>=1 and b2>=1 and b1<=j and b2<=u then else end end;local function ba(bb,bc,bd)local be=b1;local R=be+#bb-1;if b2>=1 and b2<=u then if be<=j and R>=1 then if be==1 and R==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 R>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 R<j then local br=R+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=R+1;if b6 then b9()end end end;local function M(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 U(bs,bt,V)if V~=nil then local bv=w[bt]if bv~=nil then w[bt]=g(bv:sub(1,bs-1)..V..bv:sub(bs+V:len(),j),1,j)end end end;local function W(bs,bt,V)if V~=nil then local bw=x[bt]if bw~=nil then x[bt]=g(bw:sub(1,bs-1)..V..bw:sub(bs+V:len(),j),1,j)end end end;local bx=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;b4=aD end;local by=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;b3=aD 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 r[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 r[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,u end,getTextColor=function()return b4 end,getTextColour=function()return b4 end,basalt_resize=function(bI,bJ)j,u=bI,bJ;H()end,basalt_reposition=function(bs,bt)N,O=bs,bt end,basalt_setVisible=function(bK)b6=bK end,drawBackgroundBox=function(bs,bt,bI,bJ,Y)for E=1,bJ do U(bs,bt+E-1,r[Y]:rep(bI))end end,drawForegroundBox=function(bs,bt,bI,bJ,Z)for E=1,bJ do W(bs,bt+E-1,r[Z]:rep(bI))end end,drawTextBox=function(bs,bt,bI,bJ,_)for E=1,bJ do M(bs,bt+E-1,_:rep(bI))end end,writeText=function(bs,bt,i,Y,Z)Y=Y or b3;Z=Z or b4;M(N,bt,i)U(bs,bt,r[Y]:rep(i:len()))W(bs,bt,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 bL=B;local bM=C[b4]local bN=C[b3]for bO=1,u do local O=bO+l;if O>=1 and O<=u then v[bO]=v[O]w[bO]=w[O]x[bO]=x[O]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,r[b4]:rep(i:len()),r[b3]:rep(i:len()))end end,clearLine=function()if b6 then M(1,b2,(" "):rep(j))U(1,b2,r[b3]:rep(j))W(1,b2,r[b4]:rep(j))end;if b6 then b9()end end,clear=function()for E=1,u do M(1,E,(" "):rep(j))U(1,E,r[b3]:rep(j))W(1,E,r[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.width=30;aT.height=12;local bR=b0(1,1,aT.width,aT.height)local bS;local bT=false;local bU={}av={getType=function(self)return an 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,N,O,aB)aT.setPosition(self,N,O,aB)bR.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return bR end,getBasaltProcess=function()return bS end,setSize=function(self,j,u)aT.setSize(self,j,u)bR.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if bS~=nil then return bS:getStatus()end;return"inactive"end,execute=function(self,af,...)bS=ad:new(af,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,a7,aO,aP,aQ,aR,bW)if bS~=nil then if not bS:isDead()then if bT==false or bW then bS:resume(a7,aO,aP,aQ,aR)else table.insert(bU,{event=a7,args={aO,aP,aQ,aR}})end end end;return self end,getQueuedEvents=function(self)return bU end,updateQueuedEvents=function(self,a5)bU=a5 or bU;return self end,injectEvents=function(self,a5)if bS~=nil then if not bS:isDead()then for aa,ab in pairs(a5)do bS: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 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(a7,aK,N-bX+1,O-bY+1)end end;return true end end,keyHandler=function(self,a7,aN)aT.keyHandler(self,a7,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(a7,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.width-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.height-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,a7,aO,aP,aQ,aR)if bS==nil then return end;if not bS:isDead()then if not bT 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 bS:resume(a7,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.width-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.height-1 then self.parent:setCursor(bR.getCursorBlink(),aX+bZ-1,b_+aY-1,bR.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(bU,{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()bR.basalt_reposition(aX,aY)self.parent:drawBackgroundBox(aX,aY,self.width,self.height,self.bgColor)bR.basalt_update()end end end}return setmetatable(av,aT)end;local function c0(am)local aT=al(am)local an="Label"aT:setZIndex(3)local c1=true;aT:setValue("")local av={getType=function(self)return an end,setText=function(self,i)i=tostring(i)aT:setValue(i)if c1 then self.width=i:len()end;return self end,setSize=function(self,j,n)self.width,self.height=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(av,aT)end;local function c2(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 c3(am)local aT=al(am)local an="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 q=0,15 do ca[2^q]=q end;do local cc="0123456789abcdef"for q=1,16 do c9[cc:sub(q,q)]=q-1;c9[q-1]=cc:sub(q,q)cb[cc:sub(q,q)]=2^(q-1)cb[2^(q-1)]=cc:sub(q,q)local cd=c8[q-1]for q=1,#cd do cd[q]=2^cd[q]end end end;local function ce(cf)local cg=c8[ca[cf[#cf][1]]]for ch=1,#cg do local ci=cg[ch]for q=1,#cf-1 do if cf[q][1]==ci then return q end end end;return 1 end;local function cj(ck,cl)if not cl then local cm={}cl={}for q=1,6 do local cn=ck[q]local co=cl[cn]cl[cn],cm[q]=co and co+1 or 1,cn end;ck=cm end;local cf={}for aN,ab in pairs(cl)do cf[#cf+1]={aN,ab}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 q=1,6 do if ck[q]==cs then ck[q]=ct;cf[cq][2]=cf[cq][2]+1 end end;cf[cr]=nil end;local cu=128;for q=1,#ck-1 do if ck[q]~=ck[6]then cu=cu+2^(q-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,j,u,Y={{},{},{}},0,#c4+#c4%3,aT.bgColor or colors.black;for q=1,#c4 do if#c4[q]>j then j=#c4[q]end end;for O=0,u-1,3 do local cw,cx,cy,cz={},{},{},1;for N=0,j-1,2 do local ck,cl={},{}for cA=1,3 do for cB=1,2 do ck[#ck+1]=c4[O+cA]and c4[O+cA][N+cB]and(c4[O+cA][N+cB]==0 and Y or c4[O+cA][N+cB])or Y;cl[ck[#ck]]=cl[ck[#ck]]and cl[ck[#ck]]+1 or 1 end end;cw[cz],cx[cz],cy[cz]=cj(ck,cl)cz=cz+1 end;cv[1][#cv[1]+1],cv[2][#cv[2]+1],cv[3][#cv[3]+1]=table.concat(cw),table.concat(cx),table.concat(cy)end;cv.width,cv.height=#cv[1][1],#cv[1]c5=cv end;local av={getType=function(self)return an end,loadImage=function(self,af)c4=paintutils.loadImage(af)c6=false;return self end,loadBlittleImage=function(self,af)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 p,cC,cD=c5[1],c5[2],c5[3]for q=1,c5.height do local cE=p[q]if type(cE)=="string"then self.parent:setText(aX,aY+q-1,cE)self.parent:setFG(aX,aY+q-1,cC[q])self.parent:setBG(aX,aY+q-1,cD[q])elseif type(cE)=="table"then self.parent:setText(aX,aY+q-1,cE[2])self.parent:setFG(aX,aY+q-1,cC[q])self.parent:setBG(aX,aY+q-1,cD[q])end end else for aA=1,math.min(#c4,self.height)do local cF=c4[aA]for az=1,math.min(#cF,self.width)do if cF[az]>0 then self.parent:drawBackgroundBox(aX+az-1,aY+aA-1,1,1,cF[az])end end end end end end end end}return setmetatable(av,aT)end;local function cG(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 cH(am)local aT=al(am)local an="Progressbar"local cI=0;aT:setZIndex(5)aT:setValue(false)aT.width=25;aT.height=1;aT.bgColor=a.CheckboxBG;aT.fgColor=a.CheckboxFG;local cJ=colors.black;local cK=""local cL=colors.white;local cM=""local cN=0;local av={getType=function(self)return an end,setDirection=function(self,cO)cN=cO;return self end,setProgressBar=function(self,aD,_,cP)cJ=aD or cJ;cK=_ or cK;cL=cP or cL;return self end,setBackgroundSymbol=function(self,_)cM=_:sub(1,1)return self end,setProgress=function(self,ab)if ab>=0 and ab<=100 and cI~=ab then cI=ab;self:setValue(cI)if cI==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return cI end,onProgressDone=function(self,cQ)self:registerEvent("progress_done",cQ)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,cM)if cN==1 then self.parent:drawBackgroundBox(aX,aY,self.width,self.height/100*cI,cJ)self.parent:drawForegroundBox(aX,aY,self.width,self.height/100*cI,cL)self.parent:drawTextBox(aX,aY,self.width,self.height/100*cI,cK)elseif cN==2 then self.parent:drawBackgroundBox(aX,aY+math.ceil(self.height-self.height/100*cI),self.width,self.height/100*cI,cJ)self.parent:drawForegroundBox(aX,aY+math.ceil(self.height-self.height/100*cI),self.width,self.height/100*cI,cL)self.parent:drawTextBox(aX,aY+math.ceil(self.height-self.height/100*cI),self.width,self.height/100*cI,cK)elseif cN==3 then self.parent:drawBackgroundBox(aX+math.ceil(self.width-self.width/100*cI),aY,self.width/100*cI,self.height,cJ)self.parent:drawForegroundBox(aX+math.ceil(self.width-self.width/100*cI),aY,self.width/100*cI,self.height,cL)self.parent:drawTextBox(aX+math.ceil(self.width-self.width/100*cI),aY,self.width/100*cI,self.height,cK)else self.parent:drawBackgroundBox(aX,aY,self.width/100*cI,self.height,cJ)self.parent:drawForegroundBox(aX,aY,self.width/100*cI,self.height,cL)self.parent:drawTextBox(aX,aY,self.width/100*cI,self.height,cK)end end end end}return setmetatable(av,aT)end;local function cR(am)local aT=al(am)local an="Input"local cS="text"local cT=0;aT:setZIndex(5)aT:setValue("")aT.width=10;aT.height=1;aT.bgColor=a.InputBG;aT.fgColor=a.InputFG;local cU=1;local cV=1;local cW=""local cX;local cY;local cZ=cW;local c_=false;local av={getType=function(self)return an end,setInputType=function(self,d0)if d0=="password"or d0=="number"or d0=="text"then cS=d0 end;return self end,setDefaultText=function(self,i,d1,d2)cW=i;cX=d2 or cX;cY=d1 or cY;if self:isFocused()then cZ=""else cZ=cW end;return self end,getInputType=function(self)return cS end,setValue=function(self,d3)aT.setValue(self,tostring(d3))if not c_ then cU=tostring(d3):len()+1 end;return self end,getValue=function(self)local d3=aT.getValue(self)return cS=="number"and tonumber(d3)or d3 end,setInputLimit=function(self,d4)cT=tonumber(d4)or cT;return self end,getInputLimit=function(self)return cT end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then local aX,aY=self:getAnchorPosition()cZ=""if self.parent~=nil then self.parent:setCursor(true,aX+cU-cV,aY,self.fgColor)end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)cZ=cW end end,keyHandler=function(self,a7,aN)if aT.keyHandler(self,a7,aN)then c_=true;if a7=="key"then if aN==keys.backspace then local i=tostring(aT.getValue())if cU>1 then self:setValue(i:sub(1,cU-2)..i:sub(cU,i:len()))if cU>1 then cU=cU-1 end;if cV>1 then if cU<cV then cV=cV-1 end end end end;if aN==keys.enter then if self.parent~=nil then end end;if aN==keys.right then local d5=tostring(aT.getValue()):len()cU=cU+1;if cU>d5 then cU=d5+1 end;if cU<1 then cU=1 end;if cU<cV or cU>=self.width+cV then cV=cU-self.width+1 end;if cV<1 then cV=1 end end;if aN==keys.left then cU=cU-1;if cU>=1 then if cU<cV or cU>=self.width+cV then cV=cU end end;if cU<1 then cU=1 end;if cV<1 then cV=1 end end end;if a7=="char"then local i=aT.getValue()if i:len()<cT or cT<=0 then if cS=="number"then local d6=i;if aN=="."or tonumber(aN)~=nil then self:setValue(i:sub(1,cU-1)..aN..i:sub(cU,i:len()))cU=cU+1 end;if tonumber(aT.getValue())==nil then self:setValue(d6)end else self:setValue(i:sub(1,cU-1)..aN..i:sub(cU,i:len()))cU=cU+1 end;if cU>=self.width+cV then cV=cV+1 end end end;local aX,aY=self:getAnchorPosition()local d3=tostring(aT.getValue())local d7=(cU<=d3:len()and cU-1 or d3:len())-(cV-1)if d7>self.x+self.width-1 then d7=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,aX+d7,aY,self.fgColor)end;c_=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 d3=tostring(aT.getValue())local d2=self.bgColor;local d1=self.fgColor;local i;if d3:len()<=0 then i=cZ;d2=cX or d2;d1=cY or d1 end;i=cZ;if d3~=""then i=d3 end;i=i:sub(cV,self.width+cV-1)local d8=self.width-i:len()if d8<0 then d8=0 end;if cS=="password"and d3~=""then i=string.rep("*",i:len())end;i=i..string.rep(" ",d8)self.parent:writeText(aX,aY+E-1,i,d2,d1)end end end end end}return setmetatable(av,aT)end;local function d9(am)local aT=al(am)local an="Textfield"local da,cV,cU,db=1,1,1,1;local dc={""}local dd={[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 dc end,getLine=function(self,a6)return dc[a6]or""end,editLine=function(self,a6,i)dc[a6]=i or dc[a6]return self end,addLine=function(self,i,a6)if a6~=nil then table.insert(dc,a6,i)else table.insert(dc,i)end;return self end,addKeyword=function(self,de,aD)end,removeLine=function(self,a6)table.remove(dc,a6 or#dc)if#dc<=0 then table.insert(dc,"")end;return self end,getTextCursor=function(self)return cU,db 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+cU-cV,aY+db-da,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 dc[db]==""then if db>1 then table.remove(dc,db)cU=dc[db-1]:len()+1;cV=cU-self.width+1;if cV<1 then cV=1 end;db=db-1 end elseif cU<=1 then if db>1 then cU=dc[db-1]:len()+1;cV=cU-self.width+1;if cV<1 then cV=1 end;dc[db-1]=dc[db-1]..dc[db]table.remove(dc,db)db=db-1 end else dc[db]=dc[db]:sub(1,cU-2)..dc[db]:sub(cU,dc[db]:len())if cU>1 then cU=cU-1 end;if cV>1 then if cU<cV then cV=cV-1 end end end;if db<da then da=da-1 end;self:setValue("")end;if aN==keys.delete then if cU>dc[db]:len()then if dc[db+1]~=nil then dc[db]=dc[db]..dc[db+1]table.remove(dc,db+1)end else dc[db]=dc[db]:sub(1,cU-1)..dc[db]:sub(cU+1,dc[db]:len())end end;if aN==keys.enter then table.insert(dc,db+1,dc[db]:sub(cU,dc[db]:len()))dc[db]=dc[db]:sub(1,cU-1)db=db+1;cU=1;cV=1;if db-da>=self.height then da=da+1 end;self:setValue("")end;if aN==keys.up then if db>1 then db=db-1;if cU>dc[db]:len()+1 then cU=dc[db]:len()+1 end;if cV>1 then if cU<cV then cV=cU-self.width+1;if cV<1 then cV=1 end end end;if da>1 then if db<da then da=da-1 end end end end;if aN==keys.down then if db<#dc then db=db+1;if cU>dc[db]:len()+1 then cU=dc[db]:len()+1 end;if db>=da+self.height then da=da+1 end end end;if aN==keys.right then cU=cU+1;if db<#dc then if cU>dc[db]:len()+1 then cU=1;db=db+1 end elseif cU>dc[db]:len()then cU=dc[db]:len()+1 end;if cU<1 then cU=1 end;if cU<cV or cU>=self.width+cV then cV=cU-self.width+1 end;if cV<1 then cV=1 end end;if aN==keys.left then cU=cU-1;if cU>=1 then if cU<cV or cU>=self.width+cV then cV=cU end end;if db>1 then if cU<1 then db=db-1;cU=dc[db]:len()+1;cV=cU-self.width+1 end end;if cU<1 then cU=1 end;if cV<1 then cV=1 end end end;if a7=="char"then dc[db]=dc[db]:sub(1,cU-1)..aN..dc[db]:sub(cU,dc[db]:len())cU=cU+1;if cU>=self.width+cV then cV=cV+1 end;self:setValue("")end;local d7=(cU<=dc[db]:len()and cU-1 or dc[db]:len())-(cV-1)if d7>self.x+self.width-1 then d7=self.x+self.width-1 end;local df=db-da<self.height and db-da or db-da-1;if d7<1 then d7=0 end;self.parent:setCursor(true,aX+d7,aY+df,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 dg,dh=self:getAnchorPosition()if a7=="mouse_click"then if dc[O-aY+da]~=nil then cU=N-aX+cV;db=O-aY+da;if cU>dc[db]:len()then cU=dc[db]:len()+1 end;if cU<cV then cV=cU-1;if cV<1 then cV=1 end end;if self.parent~=nil then self.parent:setCursor(true,dg+cU-cV,dh+db-da)end end end;if a7=="mouse_drag"then if dc[O-aY+da]~=nil then cU=N-aX+cV;db=O-aY+da;if cU>dc[db]:len()then cU=dc[db]:len()+1 end;if cU<cV then cV=cU-1;if cV<1 then cV=1 end end;if self.parent~=nil then self.parent:setCursor(true,dg+cU-cV,dh+db-da)end end end;if a7=="mouse_scroll"then da=da+aK;if da>#dc-(self.height-1)then da=#dc-(self.height-1)end;if da<1 then da=1 end;if self.parent~=nil then if aX+cU-cV>=aX and aX+cU-cV<=aX+self.width and(aY+db-da>=aY and aY+db-da<=aY+self.height)then self.parent:setCursor(true,dg+cU-cV,dh+db-da)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 dc[E+da-1]~=nil then i=dc[E+da-1]end;i=i:sub(cV,self.width+cV-1)local d8=self.width-i:len()if d8<0 then d8=0 end;i=i..string.rep(" ",d8)self.parent:setText(aX,aY+E-1,i)end end end end}return setmetatable(av,aT)end;local function di(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 dj={}local dk=a.selectionBG;local dl=a.selectionFG;local dm=true;local dn="left"local dp=0;local dq=true;local av={getType=function(self)return an end,addItem=function(self,i,Y,Z,...)table.insert(dj,{text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})if#dj==1 then self:setValue(dj[1])end;return self end,setIndexOffset=function(self,dr)dp=dr;return self end,getIndexOffset=function(self)return dp end,removeItem=function(self,a6)table.remove(dj,a6)return self end,getItem=function(self,a6)return dj[a6]end,getItemIndex=function(self)local ds=self:getValue()for aN,ab in pairs(dj)do if ab==ds then return aN end end end,clear=function(self)dj={}self:setValue({})return self end,getItemCount=function(self)return#dj end,editItem=function(self,a6,i,Y,Z,...)table.remove(dj,a6)table.insert(dj,a6,{text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})return self end,selectItem=function(self,a6)self:setValue(dj[a6]or{})return self end,setSelectedItem=function(self,Y,Z,dt)dk=Y or self.bgColor;dl=Z or self.fgColor;dm=dt;return self end,setScrollable=function(self,du)dq=du;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#dj>0 then for E=1,self.height do if dj[E+dp]~=nil then if aX<=N and aX+self.width>N and aY+E-1==O then self:setValue(dj[E+dp])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dj[E+dp])end end end end end end;if a7=="mouse_scroll"and dq then dp=dp+aK;if dp<0 then dp=0 end;if aK>=1 then if#dj>self.height then if dp>#dj-self.height then dp=#dj-self.height end;if dp>=#dj then dp=#dj-1 end else dp=dp-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 dj[E+dp]~=nil then if dj[E+dp]==self:getValue()then if dm then self.parent:writeText(aX,aY+E-1,h(dj[E+dp].text,self.width,dn),dk,dl)else self.parent:writeText(aX,aY+E-1,h(dj[E+dp].text,self.width,dn),dj[E+dp].bgCol,dj[E+dp].fgCol)end else self.parent:writeText(aX,aY+E-1,h(dj[E+dp].text,self.width,dn),dj[E+dp].bgCol,dj[E+dp].fgCol)end end end end end end}return setmetatable(av,aT)end;local function dv(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 dj={}local dk=a.selectionBG;local dl=a.selectionFG;local dm=true;local dn="left"local dw=0;local d8=2;local dq=false;local function dx()local dy=0;local az=1;for E=1,#dj do if az+dj[E].text:len()+d8*2>av.w then dy=dy+dj[E].text:len()+d8*2 end;az=az+dj[E].text:len()+d8*2 end;return dy end;av={getType=function(self)return an end,addItem=function(self,i,Y,Z,...)table.insert(dj,{text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})if#dj==1 then self:setValue(dj[1])end;return self end,getItemIndex=function(self)local ds=self:getValue()for aN,ab in pairs(dj)do if ab==ds then return aN end end end,clear=function(self)dj={}self:setValue({})return self end,setSpace=function(self,dz)d8=dz or d8;return self end,setButtonOffset=function(self,l)dw=l or 0;if dw<0 then dw=0 end;local dy=dx()if dw>dy then dw=dy end;return self end,setScrollable=function(self,du)dq=du;return self end,removeItem=function(self,a6)table.remove(dj,a6)return self end,getItem=function(self,a6)return dj[a6]end,getItemCount=function(self)return#dj end,editItem=function(self,a6,i,Y,Z,...)table.remove(dj,a6)table.insert(dj,a6,{text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})return self end,selectItem=function(self,a6)self:setValue(dj[a6]or{})return self end,setSelectedItem=function(self,Y,Z,dt)dk=Y or self.bgColor;dl=Z or self.fgColor;dm=dt;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+dw,#dj do if dj[E]~=nil then if az+dj[E].text:len()+d8*2<=self.width then if aL+az-1<=N and aL+az-1+dj[E].text:len()+d8*2>N and aM==O then self:setValue(dj[E])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dj[E])end;az=az+dj[E].text:len()+d8*2 else break end end end end;if a7=="mouse_scroll"and dq then dw=dw+aK;if dw<0 then dw=0 end;local dy=dx()if dw>dy then dw=dy 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(dj)do if az+ab.text:len()+d8*2<=self.width then if ab==self:getValue()then self.parent:writeText(aX+az-1+-dw,aY,h((" "):rep(d8)..ab.text..(" "):rep(d8),ab.text:len()+d8*2,dn),dk or ab.bgCol,dl or ab.fgCol)else self.parent:writeText(aX+az-1+-dw,aY,h((" "):rep(d8)..ab.text..(" "):rep(d8),ab.text:len()+d8*2,dn),ab.bgCol,ab.fgCol)end;az=az+ab.text:len()+d8*2 else if az<self.width+dw then if ab==self:getValue()then self.parent:writeText(aX+az-1+-dw,aY,h((" "):rep(d8)..ab.text..(" "):rep(d8),ab.text:len()+d8*2,dn):sub(1,self.width+dw-az),dk or ab.bgCol,dl or ab.fgCol)else self.parent:writeText(aX+az-1+-dw,aY,h((" "):rep(d8)..ab.text..(" "):rep(d8),ab.text:len()+d8*2,dn):sub(1,self.width+dw-az),ab.bgCol,ab.fgCol)end;az=az+ab.text:len()+d8*2 end end end end end end}return setmetatable(av,aT)end;local function dA(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 dj={}local dk=a.selectionBG;local dl=a.selectionFG;local dm=true;local dn="left"local dp=0;local dB=16;local dC=6;local dD="\16"local dE="\31"local dF=1;local av={getType=function(self)return an end,setIndexOffset=function(self,dr)dp=dr;return self end,getIndexOffset=function(self)return dp end,addItem=function(self,i,Y,Z,...)table.insert(dj,{text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})return self end,removeItem=function(self,a6)table.remove(dj,a6)return self end,getItem=function(self,a6)return dj[a6]end,getItemIndex=function(self)local ds=self:getValue()for aN,ab in pairs(dj)do if ab==ds then return aN end end end,clear=function(self)dj={}self:setValue({})return self end,getItemCount=function(self)return#dj end,editItem=function(self,a6,i,Y,Z,...)table.remove(dj,a6)table.insert(dj,a6,{text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})return self end,selectItem=function(self,a6)self:setValue(dj[a6]or{})return self end,setSelectedItem=function(self,Y,Z,dt)dk=Y or self.bgColor;dl=Z or self.fgColor;dm=dt;return self end,setDropdownSize=function(self,j,u)dB,dC=j,u;return self end,mouseClickHandler=function(self,a7,aK,N,O)if dF==2 then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a7=="mouse_click"then if aK==1 then if#dj>0 then for E=1,dC do if dj[E+dp]~=nil then if aX<=N and aX+dB>N and aY+E==O then self:setValue(dj[E+dp])return true end end end end end end;if a7=="mouse_scroll"then dp=dp+aK;if dp<0 then dp=0 end;if aK==1 then if#dj>dC then if dp>#dj-dC then dp=#dj-dC end else dp=dj-1 end end;return true end;self:setVisualChanged()end;if aT.mouseClickHandler(self,a7,aK,N,O)then dF=2 else dF=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#dj>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if dF==1 then self.parent:writeText(aX,aY,h(self:getValue().text,self.width,dn):sub(1,self.width-1)..dD,self.bgColor,self.fgColor)else self.parent:writeText(aX,aY,h(self:getValue().text,self.width,dn):sub(1,self.width-1)..dE,self.bgColor,self.fgColor)end end end;if dF==2 then for E=1,dC do if dj[E+dp]~=nil then if dj[E+dp]==self:getValue()then if dm then self.parent:writeText(aX,aY+E,h(dj[E+dp].text,dB,dn),dk,dl)else self.parent:writeText(aX,aY+E,h(dj[E+dp].text,dB,dn),dj[E+dp].bgCol,dj[E+dp].fgCol)end else self.parent:writeText(aX,aY+E,h(dj[E+dp].text,dB,dn),dj[E+dp].bgCol,dj[E+dp].fgCol)end end end end end end end end}return setmetatable(av,aT)end;local function dG(am)local aT=al(am)local an="Radio"aT.width=8;aT.bgColor=a.listBG;aT.fgColor=a.listFG;aT:setZIndex(5)local dj={}local dk=a.selectionBG;local dl=a.selectionFG;local dH=aT.bgColor;local dI=aT.fgColor;local dm=true;local _="\7"local dn="left"local av={getType=function(self)return an end,addItem=function(self,i,N,O,Y,Z,...)table.insert(dj,{x=N or 1,y=O or 1,text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})if#dj==1 then self:setValue(dj[1])end;return self end,removeItem=function(self,a6)table.remove(dj,a6)return self end,getItem=function(self,a6)return dj[a6]end,getItemIndex=function(self)local ds=self:getValue()for aN,ab in pairs(dj)do if ab==ds then return aN end end end,clear=function(self)dj={}self:setValue({})return self end,getItemCount=function(self)return#dj end,editItem=function(self,a6,i,N,O,Y,Z,...)table.remove(dj,a6)table.insert(dj,a6,{x=N or 1,y=O or 1,text=i,bgCol=Y or self.bgColor,fgCol=Z or self.fgColor,args={...}})return self end,selectItem=function(self,a6)self:setValue(dj[a6]or{})return self end,setSelectedItem=function(self,Y,Z,dJ,dK,dt)dk=Y or dk;dl=Z or dl;dH=dJ or dH;dI=dK or dI;dm=dt;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#dj>0 then for aa,ab in pairs(dj)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(dj)do if ab==self:getValue()then if dn=="left"then self.parent:writeText(ab.x+aX-1,ab.y+aY-1,_,dH,dI)self.parent:writeText(ab.x+2+aX-1,ab.y+aY-1,ab.text,dk,dl)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.bgCol,ab.fgCol)end end end end end}return setmetatable(av,aT)end;local function dL(am)local an="Timer"local dM=0;local dN=0;local dO=0;local dP;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,dQ,dR)dM=dQ or 0;dN=dR or 1;return self end,start=function(self)dO=dN;dP=os.startTimer(dM)return self end,cancel=function(self)if dP~=nil then os.cancelTimer(dP)end;return self end,onCall=function(self,a9)au:registerEvent("timed_event",a9)return self end,eventHandler=function(self,a7,dS)if a7=="timer"and dS==dP then au:sendEvent("timed_event",self)if dO>=1 then dO=dO-1;if dO>=1 then dP=os.startTimer(dM)end elseif dO==-1 then dP=os.startTimer(dM)end end end}av.__index=av;return av end;local function dT(am)local av;local an="Thread"local a9;local dU;local dV=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,cQ)if cQ==nil then error("function is nil")end;a9=cQ;dU=coroutine.create(a9)dV=true;local aj,ak=coroutine.resume(dU)if not aj then if ak~="Terminated"then error("Threaderror - "..ak)end end;return self end,getStatus=function(self,cQ)if dU~=nil then return coroutine.status(dU)end;return nil end,stop=function(self,cQ)dV=false;return self end,eventHandler=function(self,a7,aO,aP,aQ)if dV then if coroutine.status(dU)~="dead"then local aj,ak=coroutine.resume(dU,a7,aO,aP,aQ)if not aj then if ak~="Terminated"then error("Threaderror - "..ak)end end else dV=false end end end}av.__index=av;return av end;local function dW(am)local av={}local an="Animation"local dP;local dX={}local a6=1;local dY=0;local dZ;local function d_()if dX[a6]~=nil then dX[a6].f(av,a6)end;a6=a6+1;if dX[a6]~=nil then if dX[a6].t>0 then dP=os.startTimer(dX[a6].t)else d_()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,e0)dZ=a9;table.insert(dX,{f=a9,t=e0 or dY})return self end,wait=function(self,e0)dY=e0;return self end,rep=function(self,e1)for N=1,e1 do table.insert(dX,{f=dZ,t=dY})end;return self end,clear=function(self)dX={}dZ=nil;dY=0;a6=1;return self end,play=function(self)a6=1;if dX[a6]~=nil then if dX[a6].t>0 then dP=os.startTimer(dX[a6].t)else d_()end end;return self end,cancel=function(self)os.cancelTimer(dP)return self end,eventHandler=function(self,a7,dS)if a7=="timer"and dS==dP then if dX[a6]~=nil then d_()end end end}av.__index=av;return av end;local function e2(am)local aT=al(am)local an="Slider"aT.width=8;aT.bgColor=colors.lightGray;aT.fgColor=colors.gray;aT:setValue(1)local e3="horizontal"local _=" "local e4=colors.black;local e5="\140"local e6=aT.width;local a6=1;local av={getType=function(self)return an end,setSymbol=function(self,e7)_=e7:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,e8)e5=string.sub(e8,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,e9)e4=e9;self:setVisualChanged()return self end,setBarType=function(self,ea)e3=ea: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 e3=="horizontal"then for eb=0,self.width-1 do if aX+eb==N and aY<=O and aY+self.height>O then a6=eb+1;self:setValue(e6/self.width*a6)self:setVisualChanged()end end end;if e3=="vertical"then for eb=0,self.height-1 do if aY+eb==O and aX<=N and aX+self.width>N then a6=eb+1;self:setValue(e6/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 e3=="horizontal"then self.parent:writeText(aX,aY,e5:rep(a6-1),self.bgColor,self.fgColor)self.parent:writeText(aX+a6-1,aY,_,e4,e4)self.parent:writeText(aX+a6,aY,e5:rep(self.width-a6),self.bgColor,self.fgColor)end;if e3=="vertical"then for E=0,self.height-1 do if E+1==a6 then self.parent:writeText(aX,aY+E,_,e4,e4)else self.parent:writeText(aX,aY+E,e5,self.bgColor,self.fgColor)end end end end end end}return setmetatable(av,aT)end;local function ec(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 e3="vertical"local _=" "local e4=colors.black;local e5="\127"local e6=aT.height;local a6=1;local ed=1;local av={getType=function(self)return an end,setSymbol=function(self,e7)_=e7:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,ee)ed=tonumber(ee)or 1;if e3=="vertical"then self:setValue(a6-1*e6/(self.height-(ed-1))-e6/(self.height-(ed-1)))elseif e3=="horizontal"then self:setValue(a6-1*e6/(self.width-(ed-1))-e6/(self.width-(ed-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,d3)e6=d3;return self end,setBackgroundSymbol=function(self,e8)e5=string.sub(e8,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,e9)e4=e9;self:setVisualChanged()return self end,setBarType=function(self,ea)e3=ea: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 e3=="horizontal"then for eb=0,self.width do if aX+eb==N and aY<=O and aY+self.height>O then a6=math.min(eb+1,self.width-(ed-1))self:setValue(e6/self.width*a6)self:setVisualChanged()end end end;if e3=="vertical"then for eb=0,self.height do if aY+eb==O and aX<=N and aX+self.width>N then a6=math.min(eb+1,self.height-(ed-1))self:setValue(e6/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,(e3=="vertical"and self.height or self.width)-(ed-1))self:setValue(e6/(e3=="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 e3=="horizontal"then self.parent:writeText(aX,aY,e5:rep(a6-1),self.bgColor,self.fgColor)self.parent:writeText(aX+a6-1,aY,_:rep(ed),e4,e4)self.parent:writeText(aX+a6+ed-1,aY,e5:rep(self.width-(a6+ed-1)),self.bgColor,self.fgColor)end;if e3=="vertical"then for E=0,self.height-1 do if a6==E+1 then for ef=0,math.min(ed-1,self.height)do self.parent:writeText(aX,aY+E+ef,_,e4,e4)end else if E+1<a6 or E+1>a6-1+ed then self.parent:writeText(aX,aY+E,e5,self.bgColor,self.fgColor)end end end end end end end}return setmetatable(av,aT)end;local function eg(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 eh(am,ei)local aT=al(am)local an="Frame"local ej={}local ek={}local av={}local el;aT:setZIndex(10)local b5=false;local b1=1;local b2=1;local em=colors.white;local en,dp=0,0;if ei~=nil then aT.parent=ei;aT.width,aT.height=ei.w,ei.h;aT.bgColor=a.FrameBG;aT.fgColor=a.FrameFG else local eo,ep=f.getSize()aT.width,aT.height=eo,ep;aT.bgColor=a.basaltBG;aT.fgColor=a.basaltFG end;local function eq(am)for aa,ab in pairs(ej)do for aa,bD in pairs(ab)do if bD.name==am then return ab end end end end;local function er(es)local ao=es:getZIndex()if eq(es.name)~=nil then return nil end;if ej[ao]==nil then for N=1,#ek+1 do if ek[N]~=nil then if ao==ek[N]then break end;if ao>ek[N]then table.insert(ek,N,ao)break end else table.insert(ek,ao)end end;if#ek<=0 then table.insert(ek,ao)end;ej[ao]={}end;es.parent=av;table.insert(ej[ao],es)return es end;local function et(es)for cp,bD in pairs(ej)do for aN,ab in pairs(bD)do if ab==es then table.remove(ej[cp],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,es)for aa,a6 in pairs(ek)do for aa,ab in pairs(ej[a6])do if ab==es then if el~=nil then el:loseFocusHandler()end;el=es;el:getFocusHandler()end end end;return self end,setOffset=function(self,aH,aI)en=aH~=nil and math.floor(aH<0 and math.abs(aH)or-aH)or en;dp=aI~=nil and math.floor(aI<0 and math.abs(aI)or-aI)or dp;return self end,getFrameOffset=function(self)return en,dp end,removeFocusedObject=function(self)if el~=nil then el:loseFocusHandler()end;el=nil;return self end,getFocusedObject=function(self)return el end,show=function(self)aT:show()if self.parent==nil then c=self end;return self end,setCursor=function(self,eu,ev,ew,aD)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())b5=eu or false;if ev~=nil then b1=aX+ev-1 end;if ew~=nil then b2=aY+ew-1 end;em=aD or em;self:setVisualChanged()return self end,setMoveable=function(self,ex)self.isMoveable=ex or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,ey)self.barActive=ey 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,dn)self.barTextAlign=dn or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local ez=aT.getVisualChanged(self)for aa,a6 in pairs(ek)do if ej[a6]~=nil then for aa,ab in pairs(ej[a6])do if ab.getVisualChanged~=nil and ab:getVisualChanged()then ez=true end end end end;return ez 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 el~=nil then if el.keyHandler~=nil then if el: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(ek)do if ej[a6]~=nil then for aa,ab in pairs(ej[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(ek)do if ej[a6]~=nil then for aa,ab in pairs(ej[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 eA=1;local eB=1;if self.parent~=nil then eA,eB=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(N+self.xToRem-(eA-1)+aH,O-(eB-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(ek)do if ej[a6]~=nil then for aa,ab in o(ej[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 el~=nil then el:loseFocusHandler()el=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,Y)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,Y)else X.drawBackgroundBox(math.max(N+aX-1,aX),math.max(O+aY-1,aY),j,u,Y)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 dg,dh=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(dg,dh,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(dg,dh,self.width,self.height,self.fgColor)self.parent:drawTextBox(dg,dh,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(dg,dh,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(ek)do if ej[a6]~=nil then for aa,ab in pairs(ej[a6])do if ab.draw~=nil then ab:draw()end end end end;if b5 then f.setTextColor(em)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,es)return er(es)end,removeObject=function(self,es)return et(es)end,getObject=function(self,es)return eq(es)end,addButton=function(self,am)local es=aS(am)es.name=am;return er(es)end,addLabel=function(self,am)local es=c0(am)es.name=am;es.bgColor=self.bgColor;es.fgColor=self.fgColor;return er(es)end,addCheckbox=function(self,am)local es=cG(am)es.name=am;return er(es)end,addInput=function(self,am)local es=cR(am)es.name=am;return er(es)end,addProgram=function(self,am)local es=a_(am)es.name=am;return er(es)end,addTextfield=function(self,am)local es=d9(am)es.name=am;return er(es)end,addList=function(self,am)local es=di(am)es.name=am;return er(es)end,addDropdown=function(self,am)local es=dA(am)es.name=am;return er(es)end,addRadio=function(self,am)local es=dG(am)es.name=am;return er(es)end,addTimer=function(self,am)local es=dL(am)es.name=am;return er(es)end,addAnimation=function(self,am)local es=dW(am)es.name=am;return er(es)end,addSlider=function(self,am)local es=e2(am)es.name=am;return er(es)end,addScrollbar=function(self,am)local es=ec(am)es.name=am;return er(es)end,addMenubar=function(self,am)local es=dv(am)es.name=am;return er(es)end,addThread=function(self,am)local es=dT(am)es.name=am;return er(es)end,addPane=function(self,am)local es=c2(am)es.name=am;return er(es)end,addImage=function(self,am)local es=c3(am)es.name=am;return er(es)end,addProgressbar=function(self,am)local es=cH(am)es.name=am;return er(es)end,addFrame=function(self,am)local es=eh(am,self)es.name=am;return er(es)end}setmetatable(av,aT)if ei==nil then table.insert(d,av)end;return av end;local eC=false;local function eD(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 eC then c:draw()X.update()end end;function b.autoUpdate(dV)f.clear()eC=dV or true;c:draw()X.update()while eC do local a7,aO,aP,aQ,aR=os.pullEventRaw()eD(a7,aO,aP,aQ,aR)end end;function b.update(a7,aO,aP,aQ,aR)if a7~="nil"then eD(a7,aO,aP,aQ,aR)else c:draw()X.update()end end;function b.stop()eC=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=eh(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 eE=""for aN,ab in pairs(ah)do eE=eE..tostring(ab)..(#ah~=aN and", "or"")end;b.debugLabel:setText("[Debug] "..eE)b.debugList:addItem(eE)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