Files
Basalt/basalt-minfied.lua
2022-05-18 19:59:33 -04:00

1 line
63 KiB
Lua

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