1 line
64 KiB
Lua
1 line
64 KiB
Lua
local a={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local b={debugger=true,version=1}local c;local d={}local e={}local f=term.current()local g=string.sub;local function h(i,j,k)i=string.sub(i,1,j)local l=j-string.len(i)if k=="right"then i=string.rep(" ",l)..i elseif k=="center"then i=string.rep(" ",math.floor(l/2))..i..string.rep(" ",math.floor(l/2))i=i..(string.len(i)<j and" "or"")else i=i..string.rep(" ",l)end;return i end;local function m(n,k)local l=0;if k=="center"then l=math.ceil(n/2)if l<1 then l=1 end end;if k=="bottom"then l=n end;return l end;local function o(p)return function(p,q)q=q-1;if q~=0 then return q,p[q]end end,p,#p+1 end;local r={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local function s()local t=f;local j,u=t.getSize()local v={}local w={}local x={}local y={}local z={}local A={}local B;local C={}local function D()B=(" "):rep(j)for E=0,15 do local F=2^E;local G=r[F]C[F]=G:rep(j)end end;D()local function H()local I=B;local J=C[colors.white]local K=C[colors.black]for L=1,u do v[L]=g(v[L]==nil and I or v[L]..I:sub(1,j-v[L]:len()),1,j)x[L]=g(x[L]==nil and J or x[L]..J:sub(1,j-x[L]:len()),1,j)w[L]=g(w[L]==nil and K or w[L]..K:sub(1,j-w[L]:len()),1,j)end end;H()local function M(N,O,i)if O>=1 and O<=u then if N+i:len()>0 and N<=j then local P=v[O]local Q;local R=N+#i-1;if N<1 then local S=1-N+1;local T=j-N+1;i=g(i,S,T)elseif R>j then local T=j-N+1;i=g(i,1,T)end;if N>1 then local T=N-1;Q=g(P,1,T)..i else Q=i end;if R<j then Q=Q..g(P,R+1,j)end;v[O]=Q end end end;local function U(N,O,V)if O>=1 and O<=u then if N+V:len()>0 and N<=j then local P=w[O]local Q;local R=N+#V-1;if N<1 then V=g(V,1-N+1,j-N+1)elseif R>j then V=g(V,1,j-N+1)end;if N>1 then Q=g(P,1,N-1)..V else Q=V end;if R<j then Q=Q..g(P,R+1,j)end;w[O]=Q end end end;local function W(N,O,V)if O>=1 and O<=u then if N+V:len()>0 and N<=j then local P=x[O]local Q;local R=N+#V-1;if N<1 then local S=1-N+1;local T=j-N+1;V=g(V,S,T)elseif R>j then local T=j-N+1;V=g(V,1,T)end;if N>1 then local T=N-1;Q=g(P,1,T)..V else Q=V end;if R<j then Q=Q..g(P,R+1,j)end;x[O]=Q end end end;local X={setBG=function(N,O,V)U(N,O,V)end,setText=function(N,O,i)M(N,O,i)end,setFG=function(N,O,V)W(N,O,V)end,drawBackgroundBox=function(N,O,Y,n,Z)for E=1,n do U(N,O+E-1,r[Z]:rep(Y))end end,drawForegroundBox=function(N,O,Y,n,_)for E=1,n do W(N,O+E-1,r[_]:rep(Y))end end,drawTextBox=function(N,O,Y,n,a0)for E=1,n do M(N,O+E-1,a0:rep(Y))end end,writeText=function(N,O,i,Z,_)Z=Z or t.getBackgroundColor()_=_ or t.getTextColor()M(N,O,i)U(N,O,r[Z]:rep(i:len()))W(N,O,r[_]:rep(i:len()))end,update=function()local a1,a2=t.getCursorPos()local a3=false;if t.getCursorBlink~=nil then a3=t.getCursorBlink()end;t.setCursorBlink(false)for E=1,u do t.setCursorPos(1,E)t.blit(v[E],x[E],w[E])end;t.setCursorBlink(a3)t.setCursorPos(a1,a2)end,setTerm=function(a4)t=a4 end}return X end;local X=s()local function a5()local a6={}local a7={}local a8={registerEvent=function(self,a9,aa)if a6[a9]==nil then a6[a9]={}a7[a9]=1 end;a6[a9][a7[a9]]=aa;a7[a9]=a7[a9]+1;return a7[a9]-1 end,removeEvent=function(self,a9,a7)a6[a9][a7[a9]]=nil end,sendEvent=function(self,a9,...)if a6[a9]~=nil then for ab,ac in pairs(a6[a9])do ac(...)end end end}a8.__index=a8;return a8 end;local ad={}local ae={}local af=0;function ae:new(ag,ah,...)local ai=table.pack(...)local aj=setmetatable({path=ag},{__index=self})aj.window=ah;aj.processId=af;aj.coroutine=coroutine.create(function()os.run({basalt=b},ag,table.unpack(ai))end)ad[af]=aj;af=af+1;return aj end;function ae:resume(a8,...)term.redirect(self.window)local ak,al=coroutine.resume(self.coroutine,a8,...)self.window=term.current()if ak then self.filter=al else b.debug(al)end end;function ae:isDead()if self.coroutine~=nil then if coroutine.status(self.coroutine)=="dead"then table.remove(ad,self.processId)return true end else return true end;return false end;function ae:getStatus()if self.coroutine~=nil then return coroutine.status(self.coroutine)end;return nil end;function ae:start()coroutine.resume(self.coroutine)end;local function am(an)local ao="Object"local ac=nil;local ap=1;local aq="left"local ar="top"local as=false;local at=false;local au=true;local av=a5()local aw={x=1,y=1,w=1,h=1,bgcolor=colors.black,fgcolor=colors.white,name=an or"Object",parent=nil,show=function(self)at=true;au=true;return self end,hide=function(self)at=false;au=true;return self end,isVisible=function(self)return at end,getZIndex=function(self)return ap end,setFocus=function(self)if self.parent~=nil then self.parent:setFocusedObject(self)end;return self end,setZIndex=function(self,a7)ap=a7;if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end;return self end,getType=function(self)return ao end,getName=function(self)return self.name end,remove=function(self)if self.parent~=nil then self.parent:removeObject(self)end;return self end,setParent=function(self,ax)if ax.getType~=nil and ax:getType()=="Frame"then self:remove()ax:addObject(self)if self.draw then self:show()end end;return self end,setValue=function(self,ay)if ac~=ay then ac=ay;au=true;self:valueChangedHandler()end;return self end,getValue=function(self)return ac end,getVisualChanged=function(self)return au end,setVisualChanged=function(self,az)au=az or true;return self end,getEventSystem=function(self)return av end,getParent=function(self)return self.parent end,setPosition=function(self,aA,aB,aC)if aC then self.x,self.y=self.x+aA,self.y+aB else self.x,self.y=aA,aB end;au=true;return self end,getPosition=function(self)return self.x,self.y end,getVisibility=function(self)return at end,setVisibility=function(self,aD)at=aD or not at;au=true;return self end,setSize=function(self,Y,n)self.weight,self.height=Y,n;au=true;return self end,getHeight=function(self)return self.h end,getWidth=function(self)return self.w end,setBackground=function(self,aE)self.bgcolor=aE;au=true;return self end,getBackground=function(self)return self.bgcolor end,setForeground=function(self,aE)self.fgcolor=aE;au=true;return self end,getForeground=function(self)return self.fgcolor end,draw=function(self)if at then return true end;return false end,getAbsolutePosition=function(self,N,O)if N==nil then N=self.x end;if O==nil then O=self.y end;if self.parent~=nil then local aF,aG=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())N=aF+N-1;O=aG+O-1 end;return N,O end,getAnchorPosition=function(self,N,O,aH)if N==nil then N=self.x end;if O==nil then O=self.y end;if aq=="right"then N=self.parent.w-N-self.weight+2 end;if ar=="bottom"then O=self.parent.h-O-self.height+2 end;local aI,aJ=self:getOffset()if as or aH then return N,O end;return N+aI,O+aJ end,getOffset=function(self)if self.parent~=nil and as==false then return self.parent:getFrameOffset()end;return 0,0 end,ignoreOffset=function(self,aK)as=aK or true;return self end,setAnchor=function(self,...)for ab,ac in pairs(table.pack(...))do if ac=="right"or ac=="left"then aq=ac end;if ac=="top"or ac=="bottom"then ar=ac end end;au=true;return self end,getAnchor=function(self)return aq,ar end,onChange=function(self,aa)self:registerEvent("value_changed",aa)return self end,onClick=function(self,aa)self:registerEvent("mouse_click",aa)return self end,onEvent=function(self,aa)self:registerEvent("custom_event_handler",aa)return self end,onClickUp=function(self,aa)self:registerEvent("mouse_up",aa)return self end,onKey=function(self,aa)self:registerEvent("key",aa)self:registerEvent("char",aa)return self end,onKeyUp=function(self,aa)self:registerEvent("key_up",aa)return self end,onBackgroundKey=function(self,aa)self:registerEvent("background_key",aa)self:registerEvent("background_char",aa)return self end,onBackgroundKeyUp=function(self,aa)self:registerEvent("background_key_up",aa)return self end,isFocused=function(self)if self.parent~=nil then return self.parent:getFocusedObject()==self end;return false end,onGetFocus=function(self,aa)self:registerEvent("get_focus",aa)return self end,onLoseFocus=function(self,aa)self:registerEvent("lose_focus",aa)return self end,registerEvent=function(self,a8,aa)return av:registerEvent(a8,aa)end,removeEvent=function(self,a8,a7)return av:removeEvent(a8,a7)end,sendEvent=function(self,a8,...)return av:sendEvent(a8,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 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<Y then local bs=R+1;bo=bo..g(bl,bs,Y)bp=bp..g(bm,bs,Y)bq=bq..g(bn,bs,Y)end;v[b3]=bo;x[b3]=bp;w[b3]=bq end end;b2=R+1;if b7 then ba()end end end;local function M(bt,bu,i)if i~=nil then local bv=v[bu]if bv~=nil then v[bu]=g(bv:sub(1,bt-1)..i..bv:sub(bt+i:len(),Y),1,Y)end end end;local function U(bt,bu,V)if V~=nil then local bw=w[bu]if bw~=nil then w[bu]=g(bw:sub(1,bt-1)..V..bw:sub(bt+V:len(),Y),1,Y)end end end;local function W(bt,bu,V)if V~=nil then local bx=x[bu]if bx~=nil then x[bu]=g(bx:sub(1,bt-1)..V..bx:sub(bt+V:len(),Y),1,Y)end end end;local by=function(aE)if type(aE)~="number"then error("bad argument #1 (expected number, got "..type(aE)..")",2)elseif r[aE]==nil then error("Invalid color (got "..aE..")",2)end;b5=aE end;local bz=function(aE)if type(aE)~="number"then error("bad argument #1 (expected number, got "..type(aE)..")",2)elseif r[aE]==nil then error("Invalid color (got "..aE..")",2)end;b4=aE end;local bA=function(bB,bC,bD,bE)if type(bB)~="number"then error("bad argument #1 (expected number, got "..type(bB)..")",2)end;if r[bB]==nil then error("Invalid color (got "..bB..")",2)end;local bF;if type(bC)=="number"and bD==nil and bE==nil then bF={colours.rgb8(bC)}b8[bB]=bF else if type(bC)~="number"then error("bad argument #2 (expected number, got "..type(bC)..")",2)end;if type(bD)~="number"then error("bad argument #3 (expected number, got "..type(bD)..")",2)end;if type(bE)~="number"then error("bad argument #4 (expected number, got "..type(bE)..")",2)end;bF=b8[bB]bF[1]=bC;bF[2]=bD;bF[3]=bE end end;local bG=function(bB)if type(bB)~="number"then error("bad argument #1 (expected number, got "..type(bB)..")",2)end;if r[bB]==nil then error("Invalid color (got "..bB..")",2)end;local bF=b8[bB]return bF[1],bF[2],bF[3]end;local bH={setCursorPos=function(bt,bu)if type(bt)~="number"then error("bad argument #1 (expected number, got "..type(bt)..")",2)end;if type(bu)~="number"then error("bad argument #2 (expected number, got "..type(bu)..")",2)end;b2=math.floor(bt)b3=math.floor(bu)if b7 then ba()end end,getCursorPos=function()return b2,b3 end,setCursorBlink=function(bI)if type(bI)~="boolean"then error("bad argument #1 (expected boolean, got "..type(bI)..")",2)end;b6=bI end,getCursorBlink=function()return b6 end,getPaletteColor=bG,getPaletteColour=bG,setBackgroundColor=bz,setBackgroundColour=bz,setTextColor=by,setTextColour=by,setPaletteColor=bA,setPaletteColour=bA,getBackgroundColor=function()return b4 end,getBackgroundColour=function()return b4 end,getSize=function()return Y,n end,getTextColor=function()return b5 end,getTextColour=function()return b5 end,basalt_resize=function(bJ,bK)Y,n=bJ,bK;H()end,basalt_reposition=function(bt,bu)N,O=bt,bu end,basalt_setVisible=function(bL)b7=bL end,drawBackgroundBox=function(bt,bu,bJ,bK,Z)for E=1,bK do U(bt,bu+E-1,r[Z]:rep(bJ))end end,drawForegroundBox=function(bt,bu,bJ,bK,_)for E=1,bK do W(bt,bu+E-1,r[_]:rep(bJ))end end,drawTextBox=function(bt,bu,bJ,bK,a0)for E=1,bK do M(bt,bu+E-1,a0:rep(bJ))end end,writeText=function(bt,bu,i,Z,_)Z=Z or b4;_=_ or b5;M(N,bu,i)U(bt,bu,r[Z]:rep(i:len()))W(bt,bu,r[_]:rep(i:len()))end,basalt_update=function()if aw.parent~=nil then for E=1,n do aw.parent:setText(N,O+E-1,v[E])aw.parent:setBG(N,O+E-1,w[E])aw.parent:setFG(N,O+E-1,x[E])end end end,scroll=function(l)if type(l)~="number"then error("bad argument #1 (expected number, got "..type(l)..")",2)end;if l~=0 then local bM=B;local bN=C[b5]local bO=C[b4]for bP=1,n do local O=bP+l;if O>=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 cW<cX then cX=cX-1 end end end end;if aO==keys.enter then if self.parent~=nil then end end;if aO==keys.right then local d7=tostring(aU.getValue()):len()cW=cW+1;if cW>d7 then cW=d7+1 end;if cW<1 then cW=1 end;if cW<cX or cW>=self.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<cX or 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()<cV or cV<=0 then if cU=="number"then local d8=i;if aO=="."or tonumber(aO)~=nil then self:setValue(i:sub(1,cW-1)..aO..i:sub(cW,i:len()))cW=cW+1 end;if tonumber(aU.getValue())==nil then self:setValue(d8)end else self:setValue(i:sub(1,cW-1)..aO..i:sub(cW,i:len()))cW=cW+1 end;if cW>=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 cW<cX then cX=cX-1 end end end;if dd<dc then dc=dc-1 end;self:setValue("")end;if aO==keys.delete then if cW>de[dd]:len()then if de[dd+1]~=nil then de[dd]=de[dd]..de[dd+1]table.remove(de,dd+1)end else de[dd]=de[dd]:sub(1,cW-1)..de[dd]:sub(cW+1,de[dd]:len())end end;if 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 cW<cX then cX=cW-self.weight+1;if cX<1 then cX=1 end end end;if dc>1 then if dd<dc then dc=dc-1 end end end end;if aO==keys.down then if dd<#de then dd=dd+1;if cW>de[dd]:len()+1 then cW=de[dd]:len()+1 end;if dd>=dc+self.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<cX or 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<cX or 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-dc<self.height and dd-dc or dd-dc-1;if d9<1 then d9=0 end;self.parent:setCursor(true,aY+d9,aZ+dh,self.fgcolor)return true end end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())local di,dj=self:getAnchorPosition()if a8=="mouse_click"then if de[O-aZ+dc]~=nil then cW=N-aY+cX;dd=O-aZ+dc;if cW>de[dd]:len()then cW=de[dd]:len()+1 end;if cW<cX then cX=cW-1;if cX<1 then cX=1 end end;if self.parent~=nil then self.parent:setCursor(true,di+cW-cX,dj+dd-dc)end end end;if a8=="mouse_drag"then if de[O-aZ+dc]~=nil then cW=N-aY+cX;dd=O-aZ+dc;if cW>de[dd]:len()then cW=de[dd]:len()+1 end;if cW<cX then cX=cW-1;if cX<1 then cX=1 end end;if self.parent~=nil then self.parent:setCursor(true,di+cW-cX,dj+dd-dc)end end end;if a8=="mouse_scroll"then dc=dc+aL;if dc>#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 aA<self.weight+dz 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):sub(1,self.weight+dz-aA),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):sub(1,self.weight+dz-aA),bY.bgCol,bY.fgCol)end;aA=aA+bY.text:len()+da*2 end end end end end end}return setmetatable(aw,aU)end;local function dD(an)local aU=am(an)local ao="Dropdown"aU.weight=12;aU.height=1;aU.bgcolor=a.dropdownBG;aU.fgcolor=a.dropdownFG;aU:setZIndex(6)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dr=0;local dE=16;local dF=6;local dG="\16"local dH="\31"local dI=1;local aw={getType=function(self)return ao end,setIndexOffset=function(self,dt)dr=dt;return self end,getIndexOffset=function(self)return dr end,addItem=function(self,i,Z,_,...)table.insert(dl,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})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,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,setDropdownSize=function(self,Y,n)dE,dF=Y,n;return self end,mouseClickHandler=function(self,a8,aL,N,O)if dI==2 then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if a8=="mouse_click"then if aL==1 then if#dl>0 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+1<a7 or E+1>a7-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 |