diff --git a/basalt-minified.lua b/basalt-minified.lua index a9e8f7e..bb3345a 100644 --- a/basalt-minified.lua +++ b/basalt-minified.lua @@ -1 +1 @@ -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)=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=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=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 RN and aN<=O and aN+self.height>O and at then if self.parent~=nil then self.parent:setFocusedObject(self)end;av:sendEvent(a8,self,a8,aL,N,O)return true end;return false end,keyHandler=function(self,a8,aO)if self:isFocused()then av:sendEvent(a8,self,a8,aO)return true end;return false end,backgroundKeyHandler=function(self,a8,aO)av:sendEvent("background_"..a8,self,a8,aO)end,valueChangedHandler=function(self)av:sendEvent("value_changed",self)end,eventHandler=function(self,a8,aP,aQ,aR,aS)av:sendEvent("custom_event_handler",self,a8,aP,aQ,aR,aS)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 aT(an)local aU=am(an)local ao="Button"aU:setValue("Button")aU:setZIndex(5)aU.weight=8;aU.bgcolor=a.ButtonBG;aU.fgcolor=a.ButtonFG;local aV="center"local aW="center"local aw={getType=function(self)return ao end,setHorizontalAlign=function(self,aX)aV=aX end,setVerticalAlign=function(self,aX)aW=aX end,setText=function(self,i)aU:setValue(i)return self end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()local a_=m(self.height,aW)self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)self.parent:drawTextBox(aY,aZ,self.weight,self.height," ")for E=1,self.height do if E==a_ then self.parent:setText(aY,aZ+E-1,h(self:getValue(),self.weight,aV))end end end end end}return setmetatable(aw,aU)end;local function b0(an)local aU=am(an)local ao="Program"aU:setZIndex(5)local aw;local function b1(N,O,Y,n)local b2,b3=1,1;local b4,b5=colors.black,colors.white;local b6=false;local b7=false;local v={}local w={}local x={}local b8={}local B;local C={}for q=0,15 do local b9=2^q;b8[b9]={f.getPaletteColour(b9)}end;local function D()B=(" "):rep(Y)for E=0,15 do local F=2^E;local G=r[F]C[F]=G:rep(Y)end end;local function H()D()local I=B;local J=C[colors.white]local K=C[colors.black]for E=1,n do v[E]=g(v[E]==nil and I or v[E]..I:sub(1,Y-v[E]:len()),1,Y)x[E]=g(x[E]==nil and J or x[E]..J:sub(1,Y-x[E]:len()),1,Y)w[E]=g(w[E]==nil and K or w[E]..K:sub(1,Y-w[E]:len()),1,Y)end end;H()local function ba()if b2>=1 and b3>=1 and b2<=Y and b3<=n then else end end;local function bb(bc,bd,be)local bf=b2;local R=bf+#bc-1;if b3>=1 and b3<=n then if bf<=Y and R>=1 then if bf==1 and R==Y then v[b3]=bc;x[b3]=bd;w[b3]=be else local bg,bh,bi;if bf<1 then local bj=1-bf+1;local bk=Y-bf+1;bg=g(bc,bj,bk)bh=g(bd,bj,bk)bi=g(be,bj,bk)elseif R>Y then local bk=Y-bf+1;bg=g(bc,1,bk)bh=g(bd,1,bk)bi=g(be,1,bk)else bg=bc;bh=bd;bi=be end;local bl=v[b3]local bm=x[b3]local bn=w[b3]local bo,bp,bq;if bf>1 then local br=bf-1;bo=g(bl,1,br)..bg;bp=g(bm,1,br)..bh;bq=g(bn,1,br)..bi else bo=bg;bp=bh;bq=bi end;if R=1 and O<=n then v[bP]=v[O]w[bP]=w[O]x[bP]=x[O]else v[bP]=bM;x[bP]=bN;w[bP]=bO end end end;if b7 then ba()end end,isColor=function()return f.isColor()end,isColour=function()return f.isColor()end,write=function(i)i=tostring(i)if b7 then bb(i,r[b5]:rep(i:len()),r[b4]:rep(i:len()))end end,clearLine=function()if b7 then M(1,b3,(" "):rep(Y))U(1,b3,r[b4]:rep(Y))W(1,b3,r[b5]:rep(Y))end;if b7 then ba()end end,clear=function()for E=1,n do M(1,E,(" "):rep(Y))U(1,E,r[b4]:rep(Y))W(1,E,r[b5]:rep(Y))end;if b7 then ba()end end,blit=function(i,bQ,bR)if type(i)~="string"then error("bad argument #1 (expected string, got "..type(i)..")",2)end;if type(bQ)~="string"then error("bad argument #2 (expected string, got "..type(bQ)..")",2)end;if type(bR)~="string"then error("bad argument #3 (expected string, got "..type(bR)..")",2)end;if#bQ~=#i or#bR~=#i then error("Arguments must be the same length",2)end;if b7 then bb(i,bQ,bR)end end}return bH end;aU.weight=30;aU.height=12;local bS=b1(1,1,aU.weight,aU.height)local bT;local bU=false;local bV={}aw={getType=function(self)return ao end,show=function(self)aU.show(self)bS.setBackgroundColor(self.bgcolor)bS.setTextColor(self.fgcolor)bS.basalt_setVisible(true)return self end,hide=function(self)aU.hide(self)bS.basalt_setVisible(false)return self end,setPosition=function(self,N,O,aC)aU.setPosition(self,N,O,aC)bS.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return bS end,getBasaltProcess=function()return bT end,setSize=function(self,Y,n)aU.setSize(self,Y,n)bS.basalt_resize(self.weight,self.height)return self end,getStatus=function(self)if bT~=nil then return bT:getStatus()end;return"inactive"end,execute=function(self,ag,...)bT=ae:new(ag,bS,...)bS.setBackgroundColor(colors.black)bS.setTextColor(colors.white)bS.clear()bS.setCursorPos(1,1)bT:resume()bU=false;return self end,stop=function(self)if bT~=nil then if not bT:isDead()then bT:resume("terminate")if bT:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,bW)bU=bW or not bU;if bT~=nil then if not bT:isDead()then if not bU then self:injectEvents(bV)bV={}end end end;return self end,isPaused=function(self)return bU end,injectEvent=function(self,a8,aP,aQ,aR,aS,bX)if bT~=nil then if not bT:isDead()then if bU==false or bX then bT:resume(a8,aP,aQ,aR,aS)else table.insert(bV,{event=a8,args={aP,aQ,aR,aS}})end end end;return self end,getQueuedEvents=function(self)return bV end,updateQueuedEvents=function(self,a6)bV=a6 or bV;return self end,injectEvents=function(self,a6)if bT~=nil then if not bT:isDead()then for ab,bY in pairs(a6)do bT:resume(bY.event,table.unpack(bY.args))end end end;return self end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then if bT==nil then return false end;if not bT:isDead()then if not bU then local bZ,b_=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))bT:resume(a8,aL,N-bZ+1,O-b_+1)end end;return true end end,keyHandler=function(self,a8,aO)aU.keyHandler(self,a8,aO)if self:isFocused()then if bT==nil then return false end;if not bT:isDead()then if not bU then if self.draw then bT:resume(a8,aO)end end end end end,getFocusHandler=function(self)aU.getFocusHandler(self)if bT~=nil then if not bT:isDead()then if not bU then if self.parent~=nil then local c0,c1=bS.getCursorPos()local aY,aZ=self:getAnchorPosition()if self.parent~=nil then if aY+c0-1>=1 and aY+c0-1<=aY+self.weight-1 and c1+aZ-1>=1 and c1+aZ-1<=aZ+self.height-1 then self.parent:setCursor(bS.getCursorBlink(),aY+c0-1,c1+aZ-1,bS.getTextColor())end end end end end end end,loseFocusHandler=function(self)aU.loseFocusHandler(self)if bT~=nil then if not bT:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,a8,aP,aQ,aR,aS)if bT==nil then return end;if not bT:isDead()then if not bU then if a8~="mouse_click"and a8~="mouse_up"and a8~="mouse_scroll"and a8~="mouse_drag"and a8~="key_up"and a8~="key"and a8~="char"and a8~="terminate"then bT:resume(a8,aP,aQ,aR,aS)end;if self:isFocused()then local aY,aZ=self:getAnchorPosition()local c0,c1=bS.getCursorPos()if self.parent~=nil then if aY+c0-1>=1 and aY+c0-1<=aY+self.weight-1 and c1+aZ-1>=1 and c1+aZ-1<=aZ+self.height-1 then self.parent:setCursor(bS.getCursorBlink(),aY+c0-1,c1+aZ-1,bS.getTextColor())end end;if a8=="terminate"and self:isFocused()then self:stop()end end else if a8~="mouse_click"and a8~="mouse_up"and a8~="mouse_scroll"and a8~="mouse_drag"and a8~="key_up"and a8~="key"and a8~="char"and a8~="terminate"then table.insert(bV,{event=a8,args={aP,aQ,aR,aS}})end end end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()bS.basalt_reposition(aY,aZ)self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)bS.basalt_update()end end end}return setmetatable(aw,aU)end;local function c2(an)local aU=am(an)local ao="Label"aU:setZIndex(3)local c3=true;aU:setValue("")local aw={getType=function(self)return ao end,setText=function(self,i)i=tostring(i)aU:setValue(i)if c3 then self.weight=i:len()end;return self end,setSize=function(self,Y,n)self.weight,self.height=Y,n;c3=false;return self end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:writeText(aY,aZ,self:getValue(),self.bgcolor,self.fgcolor)end end end}return setmetatable(aw,aU)end;local function c4(an)local aU=am(an)local ao="Pane"local aw={getType=function(self)return ao end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.bgcolor)end end end}return setmetatable(aw,aU)end;local function c5(an)local aU=am(an)local ao="Image"aU: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 q=0,15 do cc[2^q]=q end;do local ce="0123456789abcdef"for q=1,16 do cb[ce:sub(q,q)]=q-1;cb[q-1]=ce:sub(q,q)cd[ce:sub(q,q)]=2^(q-1)cd[2^(q-1)]=ce:sub(q,q)local cf=ca[q-1]for q=1,#cf do cf[q]=2^cf[q]end end end;local function cg(ch)local ci=ca[cc[ch[#ch][1]]]for cj=1,#ci do local ck=ci[cj]for q=1,#ch-1 do if ch[q][1]==ck then return q end end end;return 1 end;local function cl(cm,cn)if not cn then local co={}cn={}for q=1,6 do local cp=cm[q]local cq=cn[cp]cn[cp],co[q]=cq and cq+1 or 1,cp end;cm=co end;local ch={}for aO,ac in pairs(cn)do ch[#ch+1]={aO,ac}end;if#ch>1 then while#ch>2 do table.sort(ch,function(cr,bE)return cr[2]>bE[2]end)local cs,ct=cg(ch),#ch;local cu,cv=ch[ct][1],ch[cs][1]for q=1,6 do if cm[q]==cu then cm[q]=cv;ch[cs][2]=ch[cs][2]+1 end end;ch[ct]=nil end;local cw=128;for q=1,#cm-1 do if cm[q]~=cm[6]then cw=cw+2^(q-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,j,u,Z={{},{},{}},0,#c6+#c6%3,aU.bgcolor or colors.black;for q=1,#c6 do if#c6[q]>j then j=#c6[q]end end;for O=0,u-1,3 do local cy,cz,cA,cB={},{},{},1;for N=0,j-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 Z or c6[O+cC][N+cD])or Z;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 ao end,loadImage=function(self,ag)c6=paintutils.loadImage(ag)c8=false;return self end,loadBlittleImage=function(self,ag)c8=true;return self end,shrinkImage=function(self)c9()c8=true;return self end,draw=function(self)if aU.draw(self)then if self.parent~=nil then if c6~=nil then local aY,aZ=self:getAnchorPosition()if c8 then local p,cE,cF=c7[1],c7[2],c7[3]for q=1,c7.height do local cG=p[q]if type(cG)=="string"then self.parent:setText(aY,aZ+q-1,cG)self.parent:setFG(aY,aZ+q-1,cE[q])self.parent:setBG(aY,aZ+q-1,cF[q])elseif type(cG)=="table"then self.parent:setText(aY,aZ+q-1,cG[2])self.parent:setFG(aY,aZ+q-1,cE[q])self.parent:setBG(aY,aZ+q-1,cF[q])end end else for aB=1,math.min(#c6,self.height)do local cH=c6[aB]for aA=1,math.min(#cH,self.weight)do if cH[aA]>0 then self.parent:drawBackgroundBox(aY+aA-1,aZ+aB-1,1,1,cH[aA])end end end end end end end end}return setmetatable(aw,aU)end;local function cI(an)local aU=am(an)local ao="Checkbox"aU:setZIndex(5)aU:setValue(false)aU.weight=1;aU.height=1;aU.bgcolor=a.CheckboxBG;aU.fgcolor=a.CheckboxFG;local aw={symbol="\42",getType=function(self)return ao end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then if a8=="mouse_click"and aL==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 aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()local a_=m(self.height,"center")self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)for E=1,self.height do if E==a_ then if self:getValue()==true then self.parent:writeText(aY,aZ+E-1,h(self.symbol,self.weight,"center"),self.bgcolor,self.fgcolor)else self.parent:writeText(aY,aZ+E-1,h(" ",self.weight,"center"),self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(aw,aU)end;local function cJ(an)local aU=am(an)local ao="Progressbar"local cK=0;aU:setZIndex(5)aU:setValue(false)aU.weight=25;aU.height=1;aU.bgcolor=a.CheckboxBG;aU.fgcolor=a.CheckboxFG;local cL=colors.black;local cM=""local cN=colors.white;local cO=""local cP=0;local aw={getType=function(self)return ao end,setDirection=function(self,cQ)cP=cQ;return self end,setProgressBar=function(self,aE,a0,cR)cL=aE or cL;cM=a0 or cM;cN=cR or cN;return self end,setBackgroundSymbol=function(self,a0)cO=a0:sub(1,1)return self end,setProgress=function(self,ac)if ac>=0 and ac<=100 and cK~=ac then cK=ac;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 aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)self.parent:drawTextBox(aY,aZ,self.weight,self.height,cO)if cP==1 then self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height/100*cK,cL)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height/100*cK,cN)self.parent:drawTextBox(aY,aZ,self.weight,self.height/100*cK,cM)elseif cP==2 then self.parent:drawBackgroundBox(aY,aZ+math.ceil(self.height-self.height/100*cK),self.weight,self.height/100*cK,cL)self.parent:drawForegroundBox(aY,aZ+math.ceil(self.height-self.height/100*cK),self.weight,self.height/100*cK,cN)self.parent:drawTextBox(aY,aZ+math.ceil(self.height-self.height/100*cK),self.weight,self.height/100*cK,cM)elseif cP==3 then self.parent:drawBackgroundBox(aY+math.ceil(self.weight-self.weight/100*cK),aZ,self.weight/100*cK,self.height,cL)self.parent:drawForegroundBox(aY+math.ceil(self.weight-self.weight/100*cK),aZ,self.weight/100*cK,self.height,cN)self.parent:drawTextBox(aY+math.ceil(self.weight-self.weight/100*cK),aZ,self.weight/100*cK,self.height,cM)else self.parent:drawBackgroundBox(aY,aZ,self.weight/100*cK,self.height,cL)self.parent:drawForegroundBox(aY,aZ,self.weight/100*cK,self.height,cN)self.parent:drawTextBox(aY,aZ,self.weight/100*cK,self.height,cM)end end end end}return setmetatable(aw,aU)end;local function cT(an)local aU=am(an)local ao="Input"local cU="text"local cV=0;aU:setZIndex(5)aU:setValue("")aU.weight=10;aU.height=1;aU.bgcolor=a.InputBG;aU.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 ao 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)aU.setValue(self,tostring(d5))if not d1 then cW=tostring(d5):len()+1 end;return self end,getValue=function(self)local d5=aU.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)aU.getFocusHandler(self)if self.parent~=nil then local aY,aZ=self:getAnchorPosition()d0=""if self.parent~=nil then self.parent:setCursor(true,aY+cW-cX,aZ,self.fgcolor)end end end,loseFocusHandler=function(self)aU.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)d0=cY end end,keyHandler=function(self,a8,aO)if aU.keyHandler(self,a8,aO)then d1=true;if a8=="key"then if aO==keys.backspace then local i=tostring(aU.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 cWd7 then cW=d7+1 end;if cW<1 then cW=1 end;if cW=self.weight+cX then cX=cW-self.weight+1 end;if cX<1 then cX=1 end end;if aO==keys.left then cW=cW-1;if cW>=1 then if cW=self.weight+cX then cX=cW end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a8=="char"then local i=aU.getValue()if i:len()=self.weight+cX then cX=cX+1 end end end;local aY,aZ=self:getAnchorPosition()local d5=tostring(aU.getValue())local d9=(cW<=d5:len()and cW-1 or d5:len())-(cX-1)if d9>self.x+self.weight-1 then d9=self.x+self.weight-1 end;if self.parent~=nil then self.parent:setCursor(true,aY+d9,aZ,self.fgcolor)end;d1=false end end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then if a8=="mouse_click"and aL==1 then end;return true end;return false end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()local a_=m(self.height,"center")self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)for E=1,self.height do if E==a_ then local d5=tostring(aU.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.weight+cX-1)local da=self.weight-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(aY,aZ+E-1,i,d4,d3)end end end end end}return setmetatable(aw,aU)end;local function db(an)local aU=am(an)local ao="Textfield"local dc,cX,cW,dd=1,1,1,1;local de={""}local df={[colors.purple]={"break"}}aU.weight=20;aU.height=8;aU.bgcolor=a.textfieldBG;aU.fgcolor=a.textfieldFG;aU:setZIndex(5)local aw={getType=function(self)return ao end,getLines=function(self)return de end,getLine=function(self,a7)return de[a7]or""end,editLine=function(self,a7,i)de[a7]=i or de[a7]return self end,addLine=function(self,i,a7)if a7~=nil then table.insert(de,a7,i)else table.insert(de,i)end;return self end,addKeyword=function(self,dg,aE)end,removeLine=function(self,a7)table.remove(de,a7 or#de)if#de<=0 then table.insert(de,"")end;return self end,getTextCursor=function(self)return cW,dd end,getFocusHandler=function(self)aU.getFocusHandler(self)if self.parent~=nil then local aY,aZ=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,aY+cW-cX,aZ+dd-dc,self.fgcolor)end end end,loseFocusHandler=function(self)aU.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,a8,aO)if aU.keyHandler(self,a8,aO)then local aY,aZ=self:getAnchorPosition()if a8=="key"then if aO==keys.backspace then if de[dd]==""then if dd>1 then table.remove(de,dd)cW=de[dd-1]:len()+1;cX=cW-self.weight+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.weight+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 cWde[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 aO==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.height then dc=dc+1 end;self:setValue("")end;if aO==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 cW1 then if ddde[dd]:len()+1 then cW=de[dd]:len()+1 end;if dd>=dc+self.height then dc=dc+1 end end end;if aO==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=self.weight+cX then cX=cW-self.weight+1 end;if cX<1 then cX=1 end end;if aO==keys.left then cW=cW-1;if cW>=1 then if cW=self.weight+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.weight+1 end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a8=="char"then de[dd]=de[dd]:sub(1,cW-1)..aO..de[dd]:sub(cW,de[dd]:len())cW=cW+1;if cW>=self.weight+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.weight-1 then d9=self.x+self.weight-1 end;local dh=dd-dcde[dd]:len()then cW=de[dd]:len()+1 end;if cWde[dd]:len()then cW=de[dd]:len()+1 end;if cW#de-(self.height-1)then dc=#de-(self.height-1)end;if dc<1 then dc=1 end;if self.parent~=nil then if aY+cW-cX>=aY and aY+cW-cX<=aY+self.weight and(aZ+dd-dc>=aZ and aZ+dd-dc<=aZ+self.height)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 aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)for E=1,self.height do local i=""if de[E+dc-1]~=nil then i=de[E+dc-1]end;i=i:sub(cX,self.weight+cX-1)local da=self.weight-i:len()if da<0 then da=0 end;i=i..string.rep(" ",da)self.parent:setText(aY,aZ+E-1,i)end end end end}return setmetatable(aw,aU)end;local function dk(an)local aU=am(an)local ao="List"aU.weight=16;aU.height=6;aU.bgcolor=a.listBG;aU.fgcolor=a.listFG;aU: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 ao end,addItem=function(self,i,Z,_,...)table.insert(dl,{text=i,bgCol=Z or self.bgcolor,fgCol=_ 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,a7)table.remove(dl,a7)return self end,getItem=function(self,a7)return dl[a7]end,getItemIndex=function(self)local du=self:getValue()for dv,bY in pairs(dl)do if bY==du then return dv end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a7,i,Z,_,...)table.remove(dl,a7)table.insert(dl,a7,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})return self end,selectItem=function(self,a7)self:setValue(dl[a7]or{})return self end,setSelectedItem=function(self,Z,_,dw)dm=Z or self.bgcolor;dn=_ or self.fgcolor;dp=dw;return self end,setScrollable=function(self,dx)ds=dx;return self end,mouseClickHandler=function(self,a8,aL,N,O)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if aY<=N and aY+self.weight>N and aZ<=O and aZ+self.height>O and self:isVisible()then if a8=="mouse_click"or a8=="mouse_drag"then if aL==1 then if#dl>0 then for E=1,self.height do if dl[E+dr]~=nil then if aY<=N and aY+self.weight>N and aZ+E-1==O then self:setValue(dl[E+dr])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dl[E+dr])end end end end end end;if a8=="mouse_scroll"and ds then dr=dr+aL;if dr<0 then dr=0 end;if aL>=1 then if#dl>self.height then if dr>#dl-self.height 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 aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)for E=1,self.height do if dl[E+dr]~=nil then if dl[E+dr]==self:getValue()then if dp then self.parent:writeText(aY,aZ+E-1,h(dl[E+dr].text,self.weight,dq),dm,dn)else self.parent:writeText(aY,aZ+E-1,h(dl[E+dr].text,self.weight,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end else self.parent:writeText(aY,aZ+E-1,h(dl[E+dr].text,self.weight,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end end end end end end}return setmetatable(aw,aU)end;local function dy(an)local aU=am(an)local ao="Menubar"local aw={}aU.weight=30;aU.height=1;aU.bgcolor=colors.gray;aU.fgcolor=colors.lightGray;aU:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dz=0;local da=2;local ds=false;local function dA()local dB=0;local aA=1;for E=1,#dl do if aA+dl[E].text:len()+da*2>aw.w then dB=dB+dl[E].text:len()+da*2 end;aA=aA+dl[E].text:len()+da*2 end;return dB end;aw={getType=function(self)return ao end,addItem=function(self,i,Z,_,...)table.insert(dl,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,getItemIndex=function(self)local du=self:getValue()for dv,bY in pairs(dl)do if bY==du then return dv end end end,clear=function(self)dl={}self:setValue({})return self end,setSpace=function(self,dC)da=dC or da;return self end,setButtonOffset=function(self,l)dz=l or 0;if dz<0 then dz=0 end;local dB=dA()if dz>dB then dz=dB end;return self end,setScrollable=function(self,dx)ds=dx;return self end,removeItem=function(self,a7)table.remove(dl,a7)return self end,getItem=function(self,a7)return dl[a7]end,getItemCount=function(self)return#dl end,editItem=function(self,a7,i,Z,_,...)table.remove(dl,a7)table.insert(dl,a7,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})return self end,selectItem=function(self,a7)self:setValue(dl[a7]or{})return self end,setSelectedItem=function(self,Z,_,dw)dm=Z or self.bgcolor;dn=_ or self.fgcolor;dp=dw;return self end,mouseClickHandler=function(self,a8,aL,N,O)local aM,aN=self:getAbsolutePosition(self:getAnchorPosition())if aM<=N and aM+self.weight>N and aN<=O and aN+self.height>O and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if a8=="mouse_click"then local aA=1;for E=1+dz,#dl do if dl[E]~=nil then if aA+dl[E].text:len()+da*2<=self.weight then if aM+aA-1<=N and aM+aA-1+dl[E].text:len()+da*2>N and aN==O then self:setValue(dl[E])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dl[E])end;aA=aA+dl[E].text:len()+da*2 else break end end end end;if a8=="mouse_scroll"and ds then dz=dz+aL;if dz<0 then dz=0 end;local dB=dA()if dz>dB then dz=dB end end;return true end;return false end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)local aA=0;for ab,bY in pairs(dl)do if aA+bY.text:len()+da*2<=self.weight then if bY==self:getValue()then self.parent:writeText(aY+aA-1+-dz,aZ,h((" "):rep(da)..bY.text..(" "):rep(da),bY.text:len()+da*2,dq),dm or bY.bgCol,dn or bY.fgCol)else self.parent:writeText(aY+aA-1+-dz,aZ,h((" "):rep(da)..bY.text..(" "):rep(da),bY.text:len()+da*2,dq),bY.bgCol,bY.fgCol)end;aA=aA+bY.text:len()+da*2 else if aA0 then for E=1,dF do if dl[E+dr]~=nil then if aY<=N and aY+dE>N and aZ+E==O then self:setValue(dl[E+dr])return true end end end end end end;if a8=="mouse_scroll"then dr=dr+aL;if dr<0 then dr=0 end;if aL==1 then if#dl>dF then if dr>#dl-dF then dr=#dl-dF end else dr=dl-1 end end;return true end;self:setVisualChanged()end;if aU.mouseClickHandler(self,a8,aL,N,O)then dI=2 else dI=1 end end,draw=function(self)if aU.draw(self)then local aY,aZ=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)if#dl>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if dI==1 then self.parent:writeText(aY,aZ,h(self:getValue().text,self.weight,dq):sub(1,self.weight-1)..dG,self.bgcolor,self.fgcolor)else self.parent:writeText(aY,aZ,h(self:getValue().text,self.weight,dq):sub(1,self.weight-1)..dH,self.bgcolor,self.fgcolor)end end end;if dI==2 then for E=1,dF do if dl[E+dr]~=nil then if dl[E+dr]==self:getValue()then if dp then self.parent:writeText(aY,aZ+E,h(dl[E+dr].text,dE,dq),dm,dn)else self.parent:writeText(aY,aZ+E,h(dl[E+dr].text,dE,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end else self.parent:writeText(aY,aZ+E,h(dl[E+dr].text,dE,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end end end end end end end end}return setmetatable(aw,aU)end;local function dJ(an)local aU=am(an)local ao="Radio"aU.weight=8;aU.bgcolor=a.listBG;aU.fgcolor=a.listFG;aU:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dK=aU.bgcolor;local dL=aU.fgcolor;local dp=true;local a0="\7"local dq="left"local aw={getType=function(self)return ao end,addItem=function(self,i,N,O,Z,_,...)table.insert(dl,{x=N or 1,y=O or 1,text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,removeItem=function(self,a7)table.remove(dl,a7)return self end,getItem=function(self,a7)return dl[a7]end,getItemIndex=function(self)local du=self:getValue()for dv,bY in pairs(dl)do if bY==du then return dv end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a7,i,N,O,Z,_,...)table.remove(dl,a7)table.insert(dl,a7,{x=N or 1,y=O or 1,text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})return self end,selectItem=function(self,a7)self:setValue(dl[a7]or{})return self end,setSelectedItem=function(self,Z,_,dM,dN,dw)dm=Z or dm;dn=_ or dn;dK=dM or dK;dL=dN or dL;dp=dw;return self end,mouseClickHandler=function(self,a8,aL,N,O)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if a8=="mouse_click"then if aL==1 then if#dl>0 then for ab,bY in pairs(dl)do if aY+bY.x-1<=N and aY+bY.x-1+bY.text:len()+2>=N and aZ+bY.y-1==O then self:setValue(bY)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 aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()for ab,bY in pairs(dl)do if bY==self:getValue()then if dq=="left"then self.parent:writeText(bY.x+aY-1,bY.y+aZ-1,a0,dK,dL)self.parent:writeText(bY.x+2+aY-1,bY.y+aZ-1,bY.text,dm,dn)end else self.parent:drawBackgroundBox(bY.x+aY-1,bY.y+aZ-1,1,1,self.bgcolor)self.parent:writeText(bY.x+2+aY-1,bY.y+aZ-1,bY.text,bY.bgCol,bY.fgCol)end end end end end}return setmetatable(aw,aU)end;local function dO(an)local ao="Timer"local dP=0;local dQ=0;local dR=0;local dS;local av=a5()local aw={name=an,getType=function(self)return ao end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,dT,dU)dP=dT or 0;dQ=dU or 1;return self end,start=function(self)dR=dQ;dS=os.startTimer(dP)return self end,cancel=function(self)if dS~=nil then os.cancelTimer(dS)end;return self end,onCall=function(self,aa)av:registerEvent("timed_event",aa)return self end,eventHandler=function(self,a8,dV)if a8=="timer"and dV==dS then av:sendEvent("timed_event",self)if dR>=1 then dR=dR-1;if dR>=1 then dS=os.startTimer(dP)end elseif dR==-1 then dS=os.startTimer(dP)end end end}aw.__index=aw;return aw end;local function dW(an)local aw;local ao="Thread"local aa;local dX;local dY=false;aw={name=an,getType=function(self)return ao 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;aa=cS;dX=coroutine.create(aa)dY=true;local ak,al=coroutine.resume(dX)if not ak then if al~="Terminated"then error("Threaderror - "..al)end end;return self end,getStatus=function(self,cS)if dX~=nil then return coroutine.status(dX)end;return nil end,stop=function(self,cS)dY=false;return self end,eventHandler=function(self,a8,aP,aQ,aR)if dY then if coroutine.status(dX)~="dead"then local ak,al=coroutine.resume(dX,a8,aP,aQ,aR)if not ak then if al~="Terminated"then error("Threaderror - "..al)end end else dY=false end end end}aw.__index=aw;return aw end;local function dZ(an)local aw={}local ao="Animation"local dS;local d_={}local a7=1;local e0=0;local e1;local function e2()if d_[a7]~=nil then d_[a7].f(aw,a7)end;a7=a7+1;if d_[a7]~=nil then if d_[a7].t>0 then dS=os.startTimer(d_[a7].t)else e2()end end end;aw={name=an,getType=function(self)return ao end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,aa,e3)e1=aa;table.insert(d_,{f=aa,t=e3 or e0})return self end,wait=function(self,e3)e0=e3;return self end,rep=function(self,e4)for N=1,e4 do table.insert(d_,{f=e1,t=e0})end;return self end,clear=function(self)d_={}e1=nil;e0=0;a7=1;return self end,play=function(self)a7=1;if d_[a7]~=nil then if d_[a7].t>0 then dS=os.startTimer(d_[a7].t)else e2()end end;return self end,cancel=function(self)os.cancelTimer(dS)return self end,eventHandler=function(self,a8,dV)if a8=="timer"and dV==dS then if d_[a7]~=nil then e2()end end end}aw.__index=aw;return aw end;local function e5(an)local aU=am(an)local ao="Slider"aU.weight=8;aU.bgcolor=colors.lightGray;aU.fgcolor=colors.gray;aU:setValue(1)local e6="horizontal"local a0=" "local e7=colors.black;local e8="\140"local e9=aU.w;local a7=1;local aw={getType=function(self)return ao end,setSymbol=function(self,ea)a0=ea:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,eb)e8=string.sub(eb,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,ec)e7=ec;self:setVisualChanged()return self end,setBarType=function(self,ed)e6=ed:lower()return self end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if e6=="horizontal"then for ee=0,self.weight-1 do if aY+ee==N and aZ<=O and aZ+self.height>O then a7=ee+1;self:setValue(e9/self.weight*a7)self:setVisualChanged()end end end;if e6=="vertical"then for ee=0,self.height-1 do if aZ+ee==O and aY<=N and aY+self.weight>N then a7=ee+1;self:setValue(e9/self.height*a7)self:setVisualChanged()end end end end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()if e6=="horizontal"then self.parent:writeText(aY,aZ,e8:rep(a7-1),self.bgcolor,self.fgcolor)self.parent:writeText(aY+a7-1,aZ,a0,e7,e7)self.parent:writeText(aY+a7,aZ,e8:rep(self.weight-a7),self.bgcolor,self.fgcolor)end;if e6=="vertical"then for E=0,self.height-1 do if E+1==a7 then self.parent:writeText(aY,aZ+E,a0,e7,e7)else self.parent:writeText(aY,aZ+E,e8,self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(aw,aU)end;local function ef(an)local aU=am(an)local ao="Scrollbar"aU.weight=1;aU.height=8;aU.bgcolor=colors.lightGray;aU.fgcolor=colors.gray;aU:setValue(1)aU:setZIndex(2)local e6="vertical"local a0=" "local e7=colors.black;local e8="\127"local e9=aU.h;local a7=1;local eg=1;local aw={getType=function(self)return ao end,setSymbol=function(self,ea)a0=ea:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,eh)eg=tonumber(eh)or 1;if e6=="vertical"then self:setValue(a7-1*e9/(self.height-(eg-1))-e9/(self.height-(eg-1)))elseif e6=="horizontal"then self:setValue(a7-1*e9/(self.weight-(eg-1))-e9/(self.weight-(eg-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,d5)e9=d5;return self end,setBackgroundSymbol=function(self,eb)e8=string.sub(eb,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,ec)e7=ec;self:setVisualChanged()return self end,setBarType=function(self,ed)e6=ed:lower()return self end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if(a8=="mouse_click"or a8=="mouse_drag")and aL==1 then if e6=="horizontal"then for ee=0,self.weight do if aY+ee==N and aZ<=O and aZ+self.height>O then a7=math.min(ee+1,self.weight-(eg-1))self:setValue(e9/self.weight*a7)self:setVisualChanged()end end end;if e6=="vertical"then for ee=0,self.height do if aZ+ee==O and aY<=N and aY+self.weight>N then a7=math.min(ee+1,self.height-(eg-1))self:setValue(e9/self.height*a7)self:setVisualChanged()end end end end;if a8=="mouse_scroll"then a7=a7+aL;if a7<1 then a7=1 end;a7=math.min(a7,(e6=="vertical"and self.height or self.weight)-(eg-1))self:setValue(e9/(e6=="vertical"and self.height or self.weight)*a7)end;return true end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()if e6=="horizontal"then self.parent:writeText(aY,aZ,e8:rep(a7-1),self.bgcolor,self.fgcolor)self.parent:writeText(aY+a7-1,aZ,a0:rep(eg),e7,e7)self.parent:writeText(aY+a7+eg-1,aZ,e8:rep(self.weight-(a7+eg-1)),self.bgcolor,self.fgcolor)end;if e6=="vertical"then for E=0,self.height-1 do if a7==E+1 then for ei=0,math.min(eg-1,self.height)do self.parent:writeText(aY,aZ+E+ei,a0,e7,e7)end else if E+1a7-1+eg then self.parent:writeText(aY,aZ+E,e8,self.bgcolor,self.fgcolor)end end end end end end end}return setmetatable(aw,aU)end;local function ej(an)local aU=am(an)local ao="Switch"aU.weight=3;aU.height=1;aU.bgcolor=colors.lightGray;aU.fgcolor=colors.gray;aU:setValue(false)aU:setZIndex(5)local aw={getType=function(self)return ao end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if(a8=="mouse_click"or a8=="mouse_drag")and aL==1 then end;return true end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()end end end}return setmetatable(aw,aU)end;local function ek(an,el)local aU=am(an)local ao="Frame"local em={}local en={}local aw={}local eo;aU:setZIndex(10)local b6=false;local b2=1;local b3=1;local ep=colors.white;local eq,dr=0,0;if el~=nil then aU.parent=el;aU.weight,aU.height=el.w,el.h;aU.bgcolor=a.FrameBG;aU.fgcolor=a.FrameFG else local er,es=f.getSize()aU.weight,aU.height=er,es;aU.bgcolor=a.basaltBG;aU.fgcolor=a.basaltFG end;local function et(an)for dv,bY in pairs(em)do for cr,bE in pairs(bY)do if bE.name==an then return bY end end end end;local function eu(ev)local ap=ev:getZIndex()if et(ev.name)~=nil then return nil end;if em[ap]==nil then for N=1,#en+1 do if en[N]~=nil then if ap==en[N]then break end;if ap>en[N]then table.insert(en,N,ap)break end else table.insert(en,ap)end end;if#en<=0 then table.insert(en,ap)end;em[ap]={}end;ev.parent=aw;table.insert(em[ap],ev)return ev end;local function ew(ev)for cr,bE in pairs(em)do for dv,bY in pairs(bE)do if bY==ev then table.remove(em[cr],dv)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 ao end,setFocusedObject=function(self,ev)for ab,a7 in pairs(en)do for ab,bY in pairs(em[a7])do if bY==ev then if eo~=nil then eo:loseFocusHandler()end;eo=ev;eo:getFocusHandler()end end end;return self end,setOffset=function(self,aI,aJ)eq=aI~=nil and math.floor(aI<0 and math.abs(aI)or-aI)or eq;dr=aJ~=nil and math.floor(aJ<0 and math.abs(aJ)or-aJ)or dr;return self end,getFrameOffset=function(self)return eq,dr end,removeFocusedObject=function(self)if eo~=nil then eo:loseFocusHandler()end;eo=nil;return self end,getFocusedObject=function(self)return eo end,show=function(self)aU:show()if self.parent==nil then c=self end;return self end,setCursor=function(self,ex,ey,ez,aE)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())b6=ex or false;if ey~=nil then b2=aY+ey-1 end;if ez~=nil then b3=aZ+ez-1 end;ep=aE or ep;self:setVisualChanged()return self end,setMoveable=function(self,eA)self.isMoveable=eA or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,eB)self.barActive=eB or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,i,Z,_)self.barText=i or""self.barBackground=Z or self.barBackground;self.barTextcolor=_ 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 eC=aU.getVisualChanged(self)for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.getVisualChanged~=nil and bY:getVisualChanged()then eC=true end end end end;return eC end,loseFocusHandler=function(self)aU.loseFocusHandler(self)end,getFocusHandler=function(self)aU.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,a8,aO)if eo~=nil then if eo.keyHandler~=nil then if eo:keyHandler(a8,aO)then return true end end end;return false end,backgroundKeyHandler=function(self,a8,aO)aU.backgroundKeyHandler(self,a8,aO)for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.backgroundKeyHandler~=nil then bY:backgroundKeyHandler(a8,aO)end end end end end,eventHandler=function(self,a8,aP,aQ,aR,aS)aU.eventHandler(self,a8,aP,aQ,aR,aS)for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.eventHandler~=nil then bY:eventHandler(a8,aP,aQ,aR,aS)end end end end;if a8=="terminate"then f.clear()f.setCursorPos(1,1)b.stop()end end,mouseClickHandler=function(self,a8,aL,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 a8=="mouse_drag"then local eD=1;local eE=1;if self.parent~=nil then eD,eE=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(N+self.xToRem-(eD-1)+aI,O-(eE-1)+aJ)end;if a8=="mouse_up"then self.drag=false end;return true end;if aU.mouseClickHandler(self,a8,aL,N,O)then local aF,aG=self:getAbsolutePosition(self:getAnchorPosition())for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in o(em[a7])do if bY.mouseClickHandler~=nil then if bY:mouseClickHandler(a8,aL,N+aI,O+aJ)then return true end end end end end;if self.isMoveable then if N>=aF and N<=aF+self.weight-1 and O==aG and a8=="mouse_click"then self.drag=true;self.xToRem=aF-N end end;if eo~=nil then eo:loseFocusHandler()eo=nil end;return true end;return false end,setText=function(self,N,O,i)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:setText(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(i,math.max(1-N+1,1),self.weight-N+1))else X.setText(math.max(N+aY-1,aY),aZ+O-1,g(i,math.max(1-N+1,1),self.weight-N+1))end end end,setBG=function(self,N,O,Z)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:setBG(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(Z,math.max(1-N+1,1),self.weight-N+1))else X.setBG(math.max(N+aY-1,aY),aZ+O-1,g(Z,math.max(1-N+1,1),self.weight-N+1))end end end,setFG=function(self,N,O,_)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:setFG(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(_,math.max(1-N+1,1),self.weight-N+1))else X.setFG(math.max(N+aY-1,aY),aZ+O-1,g(_,math.max(1-N+1,1),self.weight-N+1))end end end,writeText=function(self,N,O,i,Z,_)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:writeText(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(i,math.max(1-N+1,1),self.weight-N+1),Z,_)else X.writeText(math.max(N+aY-1,aY),aZ+O-1,g(i,math.max(1-N+1,1),self.weight-N+1),Z,_)end end end,drawBackgroundBox=function(self,N,O,Y,n,Z)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.height and self.height or n+O-1)or(n+O>self.height and self.height-O+1 or n)Y=N<1 and(Y+N>self.weight and self.weight or Y+N-1)or(Y+N>self.weight and self.weight-N+1 or Y)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(N+aY-1,aY)-(self.parent.x-1),math.max(O+aZ-1,aZ)-(self.parent.y-1),Y,n,Z)else X.drawBackgroundBox(math.max(N+aY-1,aY),math.max(O+aZ-1,aZ),Y,n,Z)end end,drawTextBox=function(self,N,O,Y,n,a0)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.height and self.height or n+O-1)or(n+O>self.height and self.height-O+1 or n)Y=N<1 and(Y+N>self.weight and self.weight or Y+N-1)or(Y+N>self.weight and self.weight-N+1 or Y)if self.parent~=nil then self.parent:drawTextBox(math.max(N+aY-1,aY)-(self.parent.x-1),math.max(O+aZ-1,aZ)-(self.parent.y-1),Y,n,a0:sub(1,1))else X.drawTextBox(math.max(N+aY-1,aY),math.max(O+aZ-1,aZ),Y,n,a0:sub(1,1))end end,drawForegroundBox=function(self,N,O,Y,n,_)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.height and self.height or n+O-1)or(n+O>self.height and self.height-O+1 or n)Y=N<1 and(Y+N>self.weight and self.weight or Y+N-1)or(Y+N>self.weight and self.weight-N+1 or Y)if self.parent~=nil then self.parent:drawForegroundBox(math.max(N+aY-1,aY)-(self.parent.x-1),math.max(O+aZ-1,aZ)-(self.parent.y-1),Y,n,_)else X.drawForegroundBox(math.max(N+aY-1,aY),math.max(O+aZ-1,aZ),Y,n,_)end end,draw=function(self)if self:getVisualChanged()then if aU.draw(self)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())local di,dj=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(di,dj,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(di,dj,self.weight,self.height,self.fgcolor)self.parent:drawTextBox(di,dj,self.weight,self.height," ")else X.drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)X.drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)X.drawTextBox(aY,aZ,self.weight,self.height," ")end;f.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(di,dj,h(self.barText,self.weight,self.barTextAlign),self.barBackground,self.barTextcolor)else X.writeText(aY,aZ,h(self.barText,self.weight,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for ab,a7 in o(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.draw~=nil then bY:draw()end end end end;if b6 then f.setTextColor(ep)f.setCursorPos(b2,b3)if self.parent~=nil then f.setCursorBlink(self:isFocused())else f.setCursorBlink(b6)end end;self:setVisualChanged(false)end end end,addObject=function(self,ev)return eu(ev)end,removeObject=function(self,ev)return ew(ev)end,getObject=function(self,ev)return et(ev)end,addButton=function(self,an)local ev=aT(an)ev.name=an;return eu(ev)end,addLabel=function(self,an)local ev=c2(an)ev.name=an;ev.bgcolor=self.bgcolor;ev.fgcolor=self.fgcolor;return eu(ev)end,addCheckbox=function(self,an)local ev=cI(an)ev.name=an;return eu(ev)end,addInput=function(self,an)local ev=cT(an)ev.name=an;return eu(ev)end,addProgram=function(self,an)local ev=b0(an)ev.name=an;return eu(ev)end,addTextfield=function(self,an)local ev=db(an)ev.name=an;return eu(ev)end,addList=function(self,an)local ev=dk(an)ev.name=an;return eu(ev)end,addDropdown=function(self,an)local ev=dD(an)ev.name=an;return eu(ev)end,addRadio=function(self,an)local ev=dJ(an)ev.name=an;return eu(ev)end,addTimer=function(self,an)local ev=dO(an)ev.name=an;return eu(ev)end,addAnimation=function(self,an)local ev=dZ(an)ev.name=an;return eu(ev)end,addSlider=function(self,an)local ev=e5(an)ev.name=an;return eu(ev)end,addScrollbar=function(self,an)local ev=ef(an)ev.name=an;return eu(ev)end,addMenubar=function(self,an)local ev=dy(an)ev.name=an;return eu(ev)end,addThread=function(self,an)local ev=dW(an)ev.name=an;return eu(ev)end,addPane=function(self,an)local ev=c4(an)ev.name=an;return eu(ev)end,addImage=function(self,an)local ev=c5(an)ev.name=an;return eu(ev)end,addProgressbar=function(self,an)local ev=cJ(an)ev.name=an;return eu(ev)end,addFrame=function(self,an)local ev=ek(an,self)ev.name=an;return eu(ev)end}setmetatable(aw,aU)if el==nil then table.insert(d,aw)end;return aw end;local eF=false;local function eG(a8,aP,aQ,aR,aS)if a8=="mouse_click"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="mouse_drag"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="mouse_up"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="mouse_scroll"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="key"or a8=="char"then c:keyHandler(a8,aP)c:backgroundKeyHandler(a8,aP)end;for ab,bY in pairs(d)do bY:eventHandler(a8,aP,aQ,aR,aS)end;if eF then c:draw()X.update()end end;function b.autoUpdate(dY)f.clear()eF=dY or true;c:draw()X.update()while eF do local a8,aP,aQ,aR,aS=os.pullEventRaw()eG(a8,aP,aQ,aR,aS)end end;function b.update(a8,aP,aQ,aR,aS)if a8~="nil"then eG(a8,aP,aQ,aR,aS)else c:draw()X.update()end end;function b.stop()eF=false end;function b.getFrame(an)for dv,bY in pairs(d)do if bY.name==an then return bY 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(an)local ax=ek(an)return ax end;function b.removeFrame(an)for dv,bY in pairs(d)do if bY.name==an then d[dv]=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 ai={...}if c.name~="basaltDebuggingFrame"then if c~=b.debugLabel.frame then b.debugLabel:setParent(c)end end;local eH=""for dv,bY in pairs(ai)do eH=eH..tostring(bY)..(#ai~=dv and", "or"")end;b.debugLabel:setText("[Debug] "..eH)b.debugList:addItem(eH)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 \ No newline at end of file +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)=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=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=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 RN 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.weight=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=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.weight=30;aT.height=12;local bR=b0(1,1,aT.weight,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 cUd5 then cU=d5+1 end;if cU<1 then cU=1 end;if 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=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()=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 cUdc[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 cU1 then if dbdc[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=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=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-dadc[db]:len()then cU=dc[db]:len()+1 end;if cUdc[db]:len()then cU=dc[db]:len()+1 end;if cU#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 az0 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+1a6-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 \ No newline at end of file