From 1f97eeacd1b93d30e979ecf8dfb607d43c43c58e Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Fri, 27 May 2022 21:57:32 +0200 Subject: [PATCH] fixed red cursor bug --- basalt.lua | 2 +- source/project/lib/drawHelper.lua | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/basalt.lua b/basalt.lua index bbe719f..20f9126 100644 --- a/basalt.lua +++ b/basalt.lua @@ -1 +1 @@ -local a={debugger=true,version=1}local b;local c={}local d={}local e=term.current()local f=string.sub;local g={[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 h={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 function i()local j=e;local k,l=j.getSize()local m={}local n={}local o={}local p={}local q={}local r={}local s;local t={}local function u()s=(" "):rep(k)for v=0,15 do local w=2^v;local x=g[w]t[w]=x:rep(k)end end;u()local function y()local z=s;local A=t[colors.white]local B=t[colors.black]for C=1,l do m[C]=f(m[C]==nil and z or m[C]..z:sub(1,k-m[C]:len()),1,k)o[C]=f(o[C]==nil and A or o[C]..A:sub(1,k-o[C]:len()),1,k)n[C]=f(n[C]==nil and B or n[C]..B:sub(1,k-n[C]:len()),1,k)end end;y()local function D(E,F,G)if F>=1 and F<=l then if E+G:len()>0 and E<=k then local H=m[F]local I;local J=E+#G-1;if E<1 then local K=1-E+1;local L=k-E+1;G=f(G,K,L)elseif J>k then local L=k-E+1;G=f(G,1,L)end;if E>1 then local L=E-1;I=f(H,1,L)..G else I=G end;if J=1 and F<=l then if E+N:len()>0 and E<=k then local H=n[F]local I;local J=E+#N-1;if E<1 then N=f(N,1-E+1,k-E+1)elseif J>k then N=f(N,1,k-E+1)end;if E>1 then I=f(H,1,E-1)..N else I=N end;if J=1 and F<=l then if E+N:len()>0 and E<=k then local H=o[F]local I;local J=E+#N-1;if E<1 then local K=1-E+1;local L=k-E+1;N=f(N,K,L)elseif J>k then local L=k-E+1;N=f(N,1,L)end;if E>1 then local L=E-1;I=f(H,1,L)..N else I=N end;if JE and aM<=F and aM+self.height>F and as then if self.parent~=nil then self.parent:setFocusedObject(self)end;au:sendEvent(_,self,_,aK,E,F)return true end;return false end,keyHandler=function(self,_,aN)if self:isFocused()then au:sendEvent(_,self,_,aN)return true end;return false end,backgroundKeyHandler=function(self,_,aN)au:sendEvent("background_".._,self,_,aN)end,valueChangedHandler=function(self)au:sendEvent("value_changed",self)end,eventHandler=function(self,_,aO,aP,aQ,aR)au:sendEvent("custom_event_handler",self,_,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 av={}local an="Animation"local aT;local aU={}local Z=1;local aV=0;local aW;local function aX()if aU[Z]~=nil then aU[Z].f(av,Z)end;Z=Z+1;if aU[Z]~=nil then if aU[Z].t>0 then aT=os.startTimer(aU[Z].t)else aX()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,a1,aY)aW=a1;table.insert(aU,{f=a1,t=aY or aV})return self end,wait=function(self,aY)aV=aY;return self end,rep=function(self,aZ)for E=1,aZ do table.insert(aU,{f=aW,t=aV})end;return self end,clear=function(self)aU={}aW=nil;aV=0;Z=1;return self end,play=function(self)Z=1;if aU[Z]~=nil then if aU[Z].t>0 then aT=os.startTimer(aU[Z].t)else aX()end end;return self end,cancel=function(self)os.cancelTimer(aT)return self end,eventHandler=function(self,_,a_)if _=="timer"and a_==aT then if aU[Z]~=nil then aX()end end end}av.__index=av;return av end;local function b0(am)local b1=al(am)local an="Button"b1:setValue("Button")b1:setZIndex(5)b1.width=8;b1.bgColor=h.ButtonBG;b1.fgColor=h.ButtonFG;local b2="center"local b3="center"local av={getType=function(self)return an end,setHorizontalAlign=function(self,b4)b2=b4 end,setVerticalAlign=function(self,b4)b3=b4 end,setText=function(self,G)b1:setValue(G)return self end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,b3)self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)self.parent:drawTextBox(b5,b6,self.width,self.height," ")for v=1,self.height do if v==b7 then self.parent:setText(b5,b6+v-1,ad(self:getValue(),self.width,b2))end end end end end}return setmetatable(av,b1)end;local function b8(am)local b1=al(am)local an="Checkbox"b1:setZIndex(5)b1:setValue(false)b1.width=1;b1.height=1;b1.bgColor=h.CheckboxBG;b1.fgColor=h.CheckboxFG;local av={symbol="\42",getType=function(self)return an end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then if _=="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 b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,"center")self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)for v=1,self.height do if v==b7 then if self:getValue()==true then self.parent:writeText(b5,b6+v-1,ad(self.symbol,self.width,"center"),self.bgColor,self.fgColor)else self.parent:writeText(b5,b6+v-1,ad(" ",self.width,"center"),self.bgColor,self.fgColor)end end end end end end}return setmetatable(av,b1)end;local function b9(am)local b1=al(am)local an="Dropdown"b1.width=12;b1.height=1;b1.bgColor=h.dropdownBG;b1.fgColor=h.dropdownFG;b1:setZIndex(6)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local bd=true;local be="left"local bf=0;local bg=16;local bh=6;local bi="\16"local bj="\31"local bk=1;local av={getType=function(self)return an end,setIndexOffset=function(self,bl)bf=bl;return self end,getIndexOffset=function(self)return bf end,addItem=function(self,G,Q,R,...)table.insert(ba,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,bn)bb=Q or self.bgColor;bc=R or self.fgColor;bd=bn;return self end,setDropdownSize=function(self,k,l)bg,bh=k,l;return self end,mouseClickHandler=function(self,_,aK,E,F)if bk==2 then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if _=="mouse_click"then if aK==1 then if#ba>0 then for v=1,bh do if ba[v+bf]~=nil then if b5<=E and b5+bg>E and b6+v==F then self:setValue(ba[v+bf])return true end end end end end end;if _=="mouse_scroll"then bf=bf+aK;if bf<0 then bf=0 end;if aK==1 then if#ba>bh then if bf>#ba-bh then bf=#ba-bh end else bf=ba-1 end end;return true end;self:setVisualChanged()end;if b1.mouseClickHandler(self,_,aK,E,F)then bk=2 else bk=1 end end,draw=function(self)if b1.draw(self)then local b5,b6=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)if#ba>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if bk==1 then self.parent:writeText(b5,b6,ad(self:getValue().text,self.width,be):sub(1,self.width-1)..bi,self.bgColor,self.fgColor)else self.parent:writeText(b5,b6,ad(self:getValue().text,self.width,be):sub(1,self.width-1)..bj,self.bgColor,self.fgColor)end end end;if bk==2 then for v=1,bh do if ba[v+bf]~=nil then if ba[v+bf]==self:getValue()then if bd then self.parent:writeText(b5,b6+v,ad(ba[v+bf].text,bg,be),bb,bc)else self.parent:writeText(b5,b6+v,ad(ba[v+bf].text,bg,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end else self.parent:writeText(b5,b6+v,ad(ba[v+bf].text,bg,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end end end end end end end end}return setmetatable(av,b1)end;local function bo(am)local b1=al(am)local an="Image"b1:setZIndex(2)local bp;local bq;local br=false;local function bs()local bt={[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 bu,bv,bw={},{},{}for ak=0,15 do bv[2^ak]=ak end;do local bx="0123456789abcdef"for ak=1,16 do bu[bx:sub(ak,ak)]=ak-1;bu[ak-1]=bx:sub(ak,ak)bw[bx:sub(ak,ak)]=2^(ak-1)bw[2^(ak-1)]=bx:sub(ak,ak)local by=bt[ak-1]for ak=1,#by do by[ak]=2^by[ak]end end end;local function bz(bA)local bB=bt[bv[bA[#bA][1]]]for bC=1,#bB do local bD=bB[bC]for ak=1,#bA-1 do if bA[ak][1]==bD then return ak end end end;return 1 end;local function bE(bF,bG)if not bG then local bH={}bG={}for ak=1,6 do local bI=bF[ak]local bJ=bG[bI]bG[bI],bH[ak]=bJ and bJ+1 or 1,bI end;bF=bH end;local bA={}for aN,a3 in pairs(bG)do bA[#bA+1]={aN,a3}end;if#bA>1 then while#bA>2 do table.sort(bA,function(bK,bL)return bK[2]>bL[2]end)local bM,bN=bz(bA),#bA;local bO,bP=bA[bN][1],bA[bM][1]for ak=1,6 do if bF[ak]==bO then bF[ak]=bP;bA[bM][2]=bA[bM][2]+1 end end;bA[bN]=nil end;local bQ=128;for ak=1,#bF-1 do if bF[ak]~=bF[6]then bQ=bQ+2^(ak-1)end end;return string.char(bQ),bw[bA[1][1]==bF[6]and bA[2][1]or bA[1][1]],bw[bF[6]]else return"\128",bw[bF[1]],bw[bF[1]]end end;local bR,k,l,Q={{},{},{}},0,#bp+#bp%3,b1.bgColor or colors.black;for ak=1,#bp do if#bp[ak]>k then k=#bp[ak]end end;for F=0,l-1,3 do local bS,bT,bU,bV={},{},{},1;for E=0,k-1,2 do local bF,bG={},{}for bW=1,3 do for bX=1,2 do bF[#bF+1]=bp[F+bW]and bp[F+bW][E+bX]and(bp[F+bW][E+bX]==0 and Q or bp[F+bW][E+bX])or Q;bG[bF[#bF]]=bG[bF[#bF]]and bG[bF[#bF]]+1 or 1 end end;bS[bV],bT[bV],bU[bV]=bE(bF,bG)bV=bV+1 end;bR[1][#bR[1]+1],bR[2][#bR[2]+1],bR[3][#bR[3]+1]=table.concat(bS),table.concat(bT),table.concat(bU)end;bR.width,bR.height=#bR[1][1],#bR[1]bq=bR end;local av={getType=function(self)return an end,loadImage=function(self,a7)bp=paintutils.loadImage(a7)br=false;return self end,loadBlittleImage=function(self,a7)br=true;return self end,shrink=function(self)bs()br=true;return self end,draw=function(self)if b1.draw(self)then if self.parent~=nil then if bp~=nil then local b5,b6=self:getAnchorPosition()if br then local aj,bY,bZ=bq[1],bq[2],bq[3]for ak=1,bq.height do local b_=aj[ak]if type(b_)=="string"then self.parent:setText(b5,b6+ak-1,b_)self.parent:setFG(b5,b6+ak-1,bY[ak])self.parent:setBG(b5,b6+ak-1,bZ[ak])elseif type(b_)=="table"then self.parent:setText(b5,b6+ak-1,b_[2])self.parent:setFG(b5,b6+ak-1,bY[ak])self.parent:setBG(b5,b6+ak-1,bZ[ak])end end else for aA=1,math.min(#bp,self.height)do local c0=bp[aA]for az=1,math.min(#c0,self.width)do if c0[az]>0 then self.parent:drawBackgroundBox(b5+az-1,b6+aA-1,1,1,c0[az])end end end end end end end end}return setmetatable(av,b1)end;local function c1(am)local b1=al(am)local an="Input"local c2="text"local c3=0;b1:setZIndex(5)b1:setValue("")b1.width=10;b1.height=1;b1.bgColor=h.InputBG;b1.fgColor=h.InputFG;local c4=1;local c5=1;local c6=""local c7;local c8;local c9=c6;local ca=false;local av={getType=function(self)return an end,setInputType=function(self,cb)if cb=="password"or cb=="number"or cb=="text"then c2=cb end;return self end,setDefaultText=function(self,G,cc,cd)c6=G;c7=cd or c7;c8=cc or c8;if self:isFocused()then c9=""else c9=c6 end;return self end,getInputType=function(self)return c2 end,setValue=function(self,ce)b1.setValue(self,tostring(ce))if not ca then c4=tostring(ce):len()+1 end;return self end,getValue=function(self)local ce=b1.getValue(self)return c2=="number"and tonumber(ce)or ce end,setInputLimit=function(self,cf)c3=tonumber(cf)or c3;return self end,getInputLimit=function(self)return c3 end,getFocusHandler=function(self)b1.getFocusHandler(self)if self.parent~=nil then local b5,b6=self:getAnchorPosition()c9=""if self.parent~=nil then self.parent:setCursor(true,b5+c4-c5,b6,self.fgColor)end end end,loseFocusHandler=function(self)b1.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)c9=c6 end end,keyHandler=function(self,_,aN)if b1.keyHandler(self,_,aN)then ca=true;if _=="key"then if aN==keys.backspace then local G=tostring(b1.getValue())if c4>1 then self:setValue(G:sub(1,c4-2)..G:sub(c4,G:len()))if c4>1 then c4=c4-1 end;if c5>1 then if c4cg then c4=cg+1 end;if c4<1 then c4=1 end;if c4=self.width+c5 then c5=c4-self.width+1 end;if c5<1 then c5=1 end end;if aN==keys.left then c4=c4-1;if c4>=1 then if c4=self.width+c5 then c5=c4 end end;if c4<1 then c4=1 end;if c5<1 then c5=1 end end end;if _=="char"then local G=b1.getValue()if G:len()=self.width+c5 then c5=c5+1 end end end;local b5,b6=self:getAnchorPosition()local ce=tostring(b1.getValue())local ci=(c4<=ce:len()and c4-1 or ce:len())-(c5-1)if ci>self.x+self.width-1 then ci=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,b5+ci,b6,self.fgColor)end;ca=false end end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then if _=="mouse_click"and aK==1 then end;return true end;return false end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,"center")self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)for v=1,self.height do if v==b7 then local ce=tostring(b1.getValue())local cd=self.bgColor;local cc=self.fgColor;local G;if ce:len()<=0 then G=c9;cd=c7 or cd;cc=c8 or cc end;G=c9;if ce~=""then G=ce end;G=G:sub(c5,self.width+c5-1)local cj=self.width-G:len()if cj<0 then cj=0 end;if c2=="password"and ce~=""then G=string.rep("*",G:len())end;G=G..string.rep(" ",cj)self.parent:writeText(b5,b6+v-1,G,cd,cc)end end end end end}return setmetatable(av,b1)end;local function ck(am)local b1=al(am)local an="Label"b1:setZIndex(3)local cl=true;b1:setValue("")local b2="left"local b3="top"local av={getType=function(self)return an end,setText=function(self,G)G=tostring(G)b1:setValue(G)if cl then self.width=G:len()end;return self end,setTextAlign=function(self,cm,cn)b2=cm or b2;b3=cn or b3;self:setVisualChanged()return self end,setSize=function(self,k,l)b1.setSize(self,k,l)cl=false;self:setVisualChanged()return self end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,b3)self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)self.parent:drawTextBox(b5,b6,self.width,self.height," ")for v=1,self.height do if v==b7 then self.parent:writeText(b5,b6+v-1,ad(self:getValue(),self.width,b2),self.bgColor,self.fgColor)end end end end end}return setmetatable(av,b1)end;local function co(am)local b1=al(am)local an="List"b1.width=16;b1.height=6;b1.bgColor=h.listBG;b1.fgColor=h.listFG;b1:setZIndex(5)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local bd=true;local be="left"local bf=0;local cp=true;local av={getType=function(self)return an end,addItem=function(self,G,Q,R,...)table.insert(ba,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})if#ba==1 then self:setValue(ba[1])end;return self end,setIndexOffset=function(self,bl)bf=bl;return self end,getIndexOffset=function(self)return bf end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,bn)bb=Q or self.bgColor;bc=R or self.fgColor;bd=bn;return self end,setScrollable=function(self,cq)cp=cq;return self end,mouseClickHandler=function(self,_,aK,E,F)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if b5<=E and b5+self.width>E and b6<=F and b6+self.height>F and self:isVisible()then if _=="mouse_click"or _=="mouse_drag"then if aK==1 then if#ba>0 then for v=1,self.height do if ba[v+bf]~=nil then if b5<=E and b5+self.width>E and b6+v-1==F then self:setValue(ba[v+bf])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,E,F,ba[v+bf])end end end end end end;if _=="mouse_scroll"and cp then bf=bf+aK;if bf<0 then bf=0 end;if aK>=1 then if#ba>self.height then if bf>#ba-self.height then bf=#ba-self.height end;if bf>=#ba then bf=#ba-1 end else bf=bf-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)for v=1,self.height do if ba[v+bf]~=nil then if ba[v+bf]==self:getValue()then if bd then self.parent:writeText(b5,b6+v-1,ad(ba[v+bf].text,self.width,be),bb,bc)else self.parent:writeText(b5,b6+v-1,ad(ba[v+bf].text,self.width,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end else self.parent:writeText(b5,b6+v-1,ad(ba[v+bf].text,self.width,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end end end end end end}return setmetatable(av,b1)end;local function cr(am)local b1=al(am)local an="Menubar"local av={}b1.width=30;b1.height=1;b1.bgColor=colors.gray;b1.fgColor=colors.lightGray;b1:setZIndex(5)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local bd=true;local be="left"local cs=0;local cj=2;local cp=false;local function ct()local cu=0;local az=1;for v=1,#ba do if az+ba[v].text:len()+cj*2>av.w then cu=cu+ba[v].text:len()+cj*2 end;az=az+ba[v].text:len()+cj*2 end;return cu end;av={getType=function(self)return an end,addItem=function(self,G,Q,R,...)table.insert(ba,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})if#ba==1 then self:setValue(ba[1])end;return self end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,setSpace=function(self,cv)cj=cv or cj;return self end,setButtonOffset=function(self,af)cs=af or 0;if cs<0 then cs=0 end;local cu=ct()if cs>cu then cs=cu end;return self end,setScrollable=function(self,cq)cp=cq;return self end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,bn)bb=Q or self.bgColor;bc=R or self.fgColor;bd=bn;return self end,mouseClickHandler=function(self,_,aK,E,F)local aL,aM=self:getAbsolutePosition(self:getAnchorPosition())if aL<=E and aL+self.width>E and aM<=F and aM+self.height>F and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if _=="mouse_click"then local az=1;for v=1+cs,#ba do if ba[v]~=nil then if az+ba[v].text:len()+cj*2<=self.width then if aL+az-1<=E and aL+az-1+ba[v].text:len()+cj*2>E and aM==F then self:setValue(ba[v])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,E,F,ba[v])end;az=az+ba[v].text:len()+cj*2 else break end end end end;if _=="mouse_scroll"and cp then cs=cs+aK;if cs<0 then cs=0 end;local cu=ct()if cs>cu then cs=cu end end;return true end;return false end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)local az=0;for a2,a3 in pairs(ba)do if az+a3.text:len()+cj*2<=self.width then if a3==self:getValue()then self.parent:writeText(b5+az-1+-cs,b6,ad((" "):rep(cj)..a3.text..(" "):rep(cj),a3.text:len()+cj*2,be),bb or a3.bgCol,bc or a3.fgCol)else self.parent:writeText(b5+az-1+-cs,b6,ad((" "):rep(cj)..a3.text..(" "):rep(cj),a3.text:len()+cj*2,be),a3.bgCol,a3.fgCol)end;az=az+a3.text:len()+cj*2 else if az=1 and cA>=1 and cz<=k and cA<=l then else end end;local function cI(cJ,cK,cL)local cM=cz;local J=cM+#cJ-1;if cA>=1 and cA<=l then if cM<=k and J>=1 then if cM==1 and J==k then m[cA]=cJ;o[cA]=cK;n[cA]=cL else local cN,cO,cP;if cM<1 then local cQ=1-cM+1;local cR=k-cM+1;cN=f(cJ,cQ,cR)cO=f(cK,cQ,cR)cP=f(cL,cQ,cR)elseif J>k then local cR=k-cM+1;cN=f(cJ,1,cR)cO=f(cK,1,cR)cP=f(cL,1,cR)else cN=cJ;cO=cK;cP=cL end;local cS=m[cA]local cT=o[cA]local cU=n[cA]local cV,cW,cX;if cM>1 then local cY=cM-1;cV=f(cS,1,cY)..cN;cW=f(cT,1,cY)..cO;cX=f(cU,1,cY)..cP else cV=cN;cW=cO;cX=cP end;if J=1 and F<=l then m[dk]=m[F]n[dk]=n[F]o[dk]=o[F]else m[dk]=dh;o[dk]=di;n[dk]=dj end end end;if cE then cH()end end,isColor=function()return e.isColor()end,isColour=function()return e.isColor()end,write=function(G)G=tostring(G)if cE then cI(G,g[cC]:rep(G:len()),g[cB]:rep(G:len()))end end,clearLine=function()if cE then D(1,cA,(" "):rep(k))M(1,cA,g[cB]:rep(k))O(1,cA,g[cC]:rep(k))end;if cE then cH()end end,clear=function()for v=1,l do D(1,v,(" "):rep(k))M(1,v,g[cB]:rep(k))O(1,v,g[cC]:rep(k))end;if cE then cH()end end,blit=function(G,dl,dm)if type(G)~="string"then error("bad argument #1 (expected string, got "..type(G)..")",2)end;if type(dl)~="string"then error("bad argument #2 (expected string, got "..type(dl)..")",2)end;if type(dm)~="string"then error("bad argument #3 (expected string, got "..type(dm)..")",2)end;if#dl~=#G or#dm~=#G then error("Arguments must be the same length",2)end;if cE then cI(G,dl,dm)end end}return dc end;b1.width=30;b1.height=12;local dn=cy(1,1,b1.width,b1.height)local dp;local dq=false;local dr={}av={getType=function(self)return an end,show=function(self)b1.show(self)dn.setBackgroundColor(self.bgColor)dn.setTextColor(self.fgColor)dn.basalt_setVisible(true)return self end,hide=function(self)b1.hide(self)dn.basalt_setVisible(false)return self end,setPosition=function(self,E,F,aB)b1.setPosition(self,E,F,aB)dn.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return dn end,getBasaltProcess=function()return dp end,setSize=function(self,k,l)b1.setSize(self,k,l)dn.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if dp~=nil then return dp:getStatus()end;return"inactive"end,execute=function(self,a7,...)dp=a5:new(a7,dn,...)dn.setBackgroundColor(colors.black)dn.setTextColor(colors.white)dn.clear()dn.setCursorPos(1,1)dp:resume()dq=false;return self end,stop=function(self)if dp~=nil then if not dp:isDead()then dp:resume("terminate")if dp:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,ds)dq=ds or not dq;if dp~=nil then if not dp:isDead()then if not dq then self:injectEvents(dr)dr={}end end end;return self end,isPaused=function(self)return dq end,injectEvent=function(self,_,aO,aP,aQ,aR,dt)if dp~=nil then if not dp:isDead()then if dq==false or dt then dp:resume(_,aO,aP,aQ,aR)else table.insert(dr,{event=_,args={aO,aP,aQ,aR}})end end end;return self end,getQueuedEvents=function(self)return dr end,updateQueuedEvents=function(self,Y)dr=Y or dr;return self end,injectEvents=function(self,Y)if dp~=nil then if not dp:isDead()then for a2,a3 in pairs(Y)do dp:resume(a3.event,table.unpack(a3.args))end end end;return self end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then if dp==nil then return false end;if not dp:isDead()then if not dq then local du,dv=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))dp:resume(_,aK,E-du+1,F-dv+1)end end;return true end end,keyHandler=function(self,_,aN)b1.keyHandler(self,_,aN)if self:isFocused()then if dp==nil then return false end;if not dp:isDead()then if not dq then if self.draw then dp:resume(_,aN)end end end end end,getFocusHandler=function(self)b1.getFocusHandler(self)if dp~=nil then if not dp:isDead()then if not dq then if self.parent~=nil then local dw,dx=dn.getCursorPos()local b5,b6=self:getAnchorPosition()if self.parent~=nil then if b5+dw-1>=1 and b5+dw-1<=b5+self.width-1 and dx+b6-1>=1 and dx+b6-1<=b6+self.height-1 then self.parent:setCursor(dn.getCursorBlink(),b5+dw-1,dx+b6-1,dn.getTextColor())end end end end end end end,loseFocusHandler=function(self)b1.loseFocusHandler(self)if dp~=nil then if not dp:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,_,aO,aP,aQ,aR)if dp==nil then return end;if not dp:isDead()then if not dq then if _~="mouse_click"and _~="mouse_up"and _~="mouse_scroll"and _~="mouse_drag"and _~="key_up"and _~="key"and _~="char"and _~="terminate"then dp:resume(_,aO,aP,aQ,aR)end;if self:isFocused()then local b5,b6=self:getAnchorPosition()local dw,dx=dn.getCursorPos()if self.parent~=nil then if b5+dw-1>=1 and b5+dw-1<=b5+self.width-1 and dx+b6-1>=1 and dx+b6-1<=b6+self.height-1 then self.parent:setCursor(dn.getCursorBlink(),b5+dw-1,dx+b6-1,dn.getTextColor())end end;if _=="terminate"and self:isFocused()then self:stop()end end else if _~="mouse_click"and _~="mouse_up"and _~="mouse_scroll"and _~="mouse_drag"and _~="key_up"and _~="key"and _~="char"and _~="terminate"then table.insert(dr,{event=_,args={aO,aP,aQ,aR}})end end end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()dn.basalt_reposition(b5,b6)self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)dn.basalt_update()end end end}return setmetatable(av,b1)end;local function dy(am)local b1=al(am)local an="Progressbar"local dz=0;b1:setZIndex(5)b1:setValue(false)b1.width=25;b1.height=1;b1.bgColor=h.CheckboxBG;b1.fgColor=h.CheckboxFG;local dA=colors.black;local dB=""local dC=colors.white;local dD=""local dE=0;local av={getType=function(self)return an end,setDirection=function(self,dF)dE=dF;return self end,setProgressBar=function(self,aD,S,dG)dA=aD or dA;dB=S or dB;dC=dG or dC;return self end,setBackgroundSymbol=function(self,S)dD=S:sub(1,1)return self end,setProgress=function(self,a3)if a3>=0 and a3<=100 and dz~=a3 then dz=a3;self:setValue(dz)if dz==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return dz end,onProgressDone=function(self,dH)self:registerEvent("progress_done",dH)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)self.parent:drawTextBox(b5,b6,self.width,self.height,dD)if dE==1 then self.parent:drawBackgroundBox(b5,b6,self.width,self.height/100*dz,dA)self.parent:drawForegroundBox(b5,b6,self.width,self.height/100*dz,dC)self.parent:drawTextBox(b5,b6,self.width,self.height/100*dz,dB)elseif dE==2 then self.parent:drawBackgroundBox(b5,b6+math.ceil(self.height-self.height/100*dz),self.width,self.height/100*dz,dA)self.parent:drawForegroundBox(b5,b6+math.ceil(self.height-self.height/100*dz),self.width,self.height/100*dz,dC)self.parent:drawTextBox(b5,b6+math.ceil(self.height-self.height/100*dz),self.width,self.height/100*dz,dB)elseif dE==3 then self.parent:drawBackgroundBox(b5+math.ceil(self.width-self.width/100*dz),b6,self.width/100*dz,self.height,dA)self.parent:drawForegroundBox(b5+math.ceil(self.width-self.width/100*dz),b6,self.width/100*dz,self.height,dC)self.parent:drawTextBox(b5+math.ceil(self.width-self.width/100*dz),b6,self.width/100*dz,self.height,dB)else self.parent:drawBackgroundBox(b5,b6,self.width/100*dz,self.height,dA)self.parent:drawForegroundBox(b5,b6,self.width/100*dz,self.height,dC)self.parent:drawTextBox(b5,b6,self.width/100*dz,self.height,dB)end end end end}return setmetatable(av,b1)end;local function dI(am)local b1=al(am)local an="Radio"b1.width=8;b1.bgColor=h.listBG;b1.fgColor=h.listFG;b1:setZIndex(5)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local dJ=b1.bgColor;local dK=b1.fgColor;local bd=true;local S="\7"local be="left"local av={getType=function(self)return an end,addItem=function(self,G,E,F,Q,R,...)table.insert(ba,{x=E or 1,y=F or 1,text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})if#ba==1 then self:setValue(ba[1])end;return self end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,E,F,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{x=E or 1,y=F or 1,text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,dL,dM,bn)bb=Q or bb;bc=R or bc;dJ=dL or dJ;dK=dM or dK;bd=bn;return self end,mouseClickHandler=function(self,_,aK,E,F)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if _=="mouse_click"then if aK==1 then if#ba>0 then for a2,a3 in pairs(ba)do if b5+a3.x-1<=E and b5+a3.x-1+a3.text:len()+2>=E and b6+a3.y-1==F then self:setValue(a3)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 b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()for a2,a3 in pairs(ba)do if a3==self:getValue()then if be=="left"then self.parent:writeText(a3.x+b5-1,a3.y+b6-1,S,dJ,dK)self.parent:writeText(a3.x+2+b5-1,a3.y+b6-1,a3.text,bb,bc)end else self.parent:drawBackgroundBox(a3.x+b5-1,a3.y+b6-1,1,1,self.bgColor)self.parent:writeText(a3.x+2+b5-1,a3.y+b6-1,a3.text,a3.bgCol,a3.fgCol)end end end end end}return setmetatable(av,b1)end;local function dN(am)local b1=al(am)local an="Scrollbar"b1.width=1;b1.height=8;b1.bgColor=colors.lightGray;b1.fgColor=colors.gray;b1:setValue(1)b1:setZIndex(2)local dO="vertical"local S=" "local dP=colors.black;local dQ="\127"local dR=b1.height;local Z=1;local dS=1;local av={getType=function(self)return an end,setSymbol=function(self,dT)S=dT:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,dU)dS=tonumber(dU)or 1;if dO=="vertical"then self:setValue(Z-1*dR/(self.height-(dS-1))-dR/(self.height-(dS-1)))elseif dO=="horizontal"then self:setValue(Z-1*dR/(self.width-(dS-1))-dR/(self.width-(dS-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,ce)dR=ce;return self end,setBackgroundSymbol=function(self,dV)dQ=string.sub(dV,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dW)dP=dW;self:setVisualChanged()return self end,setBarType=function(self,dX)dO=dX:lower()return self end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if(_=="mouse_click"or _=="mouse_drag")and aK==1 then if dO=="horizontal"then for dY=0,self.width do if b5+dY==E and b6<=F and b6+self.height>F then Z=math.min(dY+1,self.width-(dS-1))self:setValue(dR/self.width*Z)self:setVisualChanged()end end end;if dO=="vertical"then for dY=0,self.height do if b6+dY==F and b5<=E and b5+self.width>E then Z=math.min(dY+1,self.height-(dS-1))self:setValue(dR/self.height*Z)self:setVisualChanged()end end end end;if _=="mouse_scroll"then Z=Z+aK;if Z<1 then Z=1 end;Z=math.min(Z,(dO=="vertical"and self.height or self.width)-(dS-1))self:setValue(dR/(dO=="vertical"and self.height or self.width)*Z)end;return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()if dO=="horizontal"then self.parent:writeText(b5,b6,dQ:rep(Z-1),self.bgColor,self.fgColor)self.parent:writeText(b5+Z-1,b6,S:rep(dS),dP,dP)self.parent:writeText(b5+Z+dS-1,b6,dQ:rep(self.width-(Z+dS-1)),self.bgColor,self.fgColor)end;if dO=="vertical"then for v=0,self.height-1 do if Z==v+1 then for dZ=0,math.min(dS-1,self.height)do self.parent:writeText(b5,b6+v+dZ,S,dP,dP)end else if v+1Z-1+dS then self.parent:writeText(b5,b6+v,dQ,self.bgColor,self.fgColor)end end end end end end end}return setmetatable(av,b1)end;local function d_(am)local b1=al(am)local an="Slider"b1.width=8;b1.bgColor=colors.lightGray;b1.fgColor=colors.gray;b1:setValue(1)local dO="horizontal"local S=" "local dP=colors.black;local dQ="\140"local dR=b1.width;local Z=1;local av={getType=function(self)return an end,setSymbol=function(self,dT)S=dT:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,dV)dQ=string.sub(dV,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dW)dP=dW;self:setVisualChanged()return self end,setBarType=function(self,dX)dO=dX:lower()return self end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if dO=="horizontal"then for dY=0,self.width-1 do if b5+dY==E and b6<=F and b6+self.height>F then Z=dY+1;self:setValue(dR/self.width*Z)self:setVisualChanged()end end end;if dO=="vertical"then for dY=0,self.height-1 do if b6+dY==F and b5<=E and b5+self.width>E then Z=dY+1;self:setValue(dR/self.height*Z)self:setVisualChanged()end end end end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()if dO=="horizontal"then self.parent:writeText(b5,b6,dQ:rep(Z-1),self.bgColor,self.fgColor)self.parent:writeText(b5+Z-1,b6,S,dP,dP)self.parent:writeText(b5+Z,b6,dQ:rep(self.width-Z),self.bgColor,self.fgColor)end;if dO=="vertical"then for v=0,self.height-1 do if v+1==Z then self.parent:writeText(b5,b6+v,S,dP,dP)else self.parent:writeText(b5,b6+v,dQ,self.bgColor,self.fgColor)end end end end end end}return setmetatable(av,b1)end;local function e0(am)local b1=al(am)local an="Switch"b1.width=3;b1.height=1;b1.bgColor=colors.lightGray;b1.fgColor=colors.gray;b1:setValue(false)b1:setZIndex(5)local av={getType=function(self)return an end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if(_=="mouse_click"or _=="mouse_drag")and aK==1 then end;return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()end end end}return setmetatable(av,b1)end;local function e1(am)local b1=al(am)local an="Textfield"local e2,c5,c4,e3=1,1,1,1;local e4={""}local e5={[colors.purple]={"break"}}b1.width=20;b1.height=8;b1.bgColor=h.textfieldBG;b1.fgColor=h.textfieldFG;b1:setZIndex(5)local av={getType=function(self)return an end,getLines=function(self)return e4 end,getLine=function(self,Z)return e4[Z]or""end,editLine=function(self,Z,G)e4[Z]=G or e4[Z]return self end,addLine=function(self,G,Z)if Z~=nil then table.insert(e4,Z,G)else table.insert(e4,G)end;return self end,addKeyword=function(self,e6,aD)end,removeLine=function(self,Z)table.remove(e4,Z or#e4)if#e4<=0 then table.insert(e4,"")end;return self end,getTextCursor=function(self)return c4,e3 end,getFocusHandler=function(self)b1.getFocusHandler(self)if self.parent~=nil then local b5,b6=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,b5+c4-c5,b6+e3-e2,self.fgColor)end end end,loseFocusHandler=function(self)b1.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,_,aN)if b1.keyHandler(self,_,aN)then local b5,b6=self:getAnchorPosition()if _=="key"then if aN==keys.backspace then if e4[e3]==""then if e3>1 then table.remove(e4,e3)c4=e4[e3-1]:len()+1;c5=c4-self.width+1;if c5<1 then c5=1 end;e3=e3-1 end elseif c4<=1 then if e3>1 then c4=e4[e3-1]:len()+1;c5=c4-self.width+1;if c5<1 then c5=1 end;e4[e3-1]=e4[e3-1]..e4[e3]table.remove(e4,e3)e3=e3-1 end else e4[e3]=e4[e3]:sub(1,c4-2)..e4[e3]:sub(c4,e4[e3]:len())if c4>1 then c4=c4-1 end;if c5>1 then if c4e4[e3]:len()then if e4[e3+1]~=nil then e4[e3]=e4[e3]..e4[e3+1]table.remove(e4,e3+1)end else e4[e3]=e4[e3]:sub(1,c4-1)..e4[e3]:sub(c4+1,e4[e3]:len())end end;if aN==keys.enter then table.insert(e4,e3+1,e4[e3]:sub(c4,e4[e3]:len()))e4[e3]=e4[e3]:sub(1,c4-1)e3=e3+1;c4=1;c5=1;if e3-e2>=self.height then e2=e2+1 end;self:setValue("")end;if aN==keys.up then if e3>1 then e3=e3-1;if c4>e4[e3]:len()+1 then c4=e4[e3]:len()+1 end;if c5>1 then if c41 then if e3e4[e3]:len()+1 then c4=e4[e3]:len()+1 end;if e3>=e2+self.height then e2=e2+1 end end end;if aN==keys.right then c4=c4+1;if e3<#e4 then if c4>e4[e3]:len()+1 then c4=1;e3=e3+1 end elseif c4>e4[e3]:len()then c4=e4[e3]:len()+1 end;if c4<1 then c4=1 end;if c4=self.width+c5 then c5=c4-self.width+1 end;if c5<1 then c5=1 end end;if aN==keys.left then c4=c4-1;if c4>=1 then if c4=self.width+c5 then c5=c4 end end;if e3>1 then if c4<1 then e3=e3-1;c4=e4[e3]:len()+1;c5=c4-self.width+1 end end;if c4<1 then c4=1 end;if c5<1 then c5=1 end end end;if _=="char"then e4[e3]=e4[e3]:sub(1,c4-1)..aN..e4[e3]:sub(c4,e4[e3]:len())c4=c4+1;if c4>=self.width+c5 then c5=c5+1 end;self:setValue("")end;local ci=(c4<=e4[e3]:len()and c4-1 or e4[e3]:len())-(c5-1)if ci>self.x+self.width-1 then ci=self.x+self.width-1 end;local e7=e3-e2e4[e3]:len()then c4=e4[e3]:len()+1 end;if c4e4[e3]:len()then c4=e4[e3]:len()+1 end;if c4#e4-(self.height-1)then e2=#e4-(self.height-1)end;if e2<1 then e2=1 end;if self.parent~=nil then if b5+c4-c5>=b5 and b5+c4-c5<=b5+self.width and(b6+e3-e2>=b6 and b6+e3-e2<=b6+self.height)then self.parent:setCursor(true,e8+c4-c5,e9+e3-e2)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)for v=1,self.height do local G=""if e4[v+e2-1]~=nil then G=e4[v+e2-1]end;G=G:sub(c5,self.width+c5-1)local cj=self.width-G:len()if cj<0 then cj=0 end;G=G..string.rep(" ",cj)self.parent:setText(b5,b6+v-1,G)end end end end}return setmetatable(av,b1)end;local function ea(am)local av;local an="Thread"local a1;local eb;local ec=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,dH)if dH==nil then error("Function provided to thread is nil")end;a1=dH;eb=coroutine.create(a1)ec=true;local ab,ac=coroutine.resume(eb)if not ab then if ac~="Terminated"then error("Thread Error Occurred - "..ac)end end;return self end,getStatus=function(self,dH)if eb~=nil then return coroutine.status(eb)end;return nil end,stop=function(self,dH)ec=false;return self end,eventHandler=function(self,_,aO,aP,aQ)if ec then if coroutine.status(eb)~="dead"then local ab,ac=coroutine.resume(eb,_,aO,aP,aQ)if not ab then if ac~="Terminated"then error("Thread Error Occurred - "..ac)end end else ec=false end end end}av.__index=av;return av end;local function ed(am)local an="Timer"local ee=0;local ef=0;local eg=0;local aT;local au=X()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,eh,ei)ee=eh or 0;ef=ei or 1;return self end,start=function(self)eg=ef;aT=os.startTimer(ee)return self end,cancel=function(self)if aT~=nil then os.cancelTimer(aT)end;return self end,onCall=function(self,a1)au:registerEvent("timed_event",a1)return self end,eventHandler=function(self,_,a_)if _=="timer"and a_==aT then au:sendEvent("timed_event",self)if eg>=1 then eg=eg-1;if eg>=1 then aT=os.startTimer(ee)end elseif eg==-1 then aT=os.startTimer(ee)end end end}av.__index=av;return av end;local function ej(am,ek)local b1=al(am)local an="Frame"local el={}local em={}local av={}local en;b1:setZIndex(10)local cD=false;local cz=1;local cA=1;local eo=colors.white;local ep,bf=0,0;if ek~=nil then b1.parent=ek;b1.width,b1.height=ek.w,ek.h;b1.bgColor=h.FrameBG;b1.fgColor=h.FrameFG else local eq,er=e.getSize()b1.width,b1.height=eq,er;b1.bgColor=h.basaltBG;b1.fgColor=h.basaltFG end;local function es(am)for a2,a3 in pairs(el)do for a2,bL in pairs(a3)do if bL.name==am then return a3 end end end end;local function et(eu)local ao=eu:getZIndex()if es(eu.name)~=nil then return nil end;if el[ao]==nil then for E=1,#em+1 do if em[E]~=nil then if ao==em[E]then break end;if ao>em[E]then table.insert(em,E,ao)break end else table.insert(em,ao)end end;if#em<=0 then table.insert(em,ao)end;el[ao]={}end;eu.parent=av;table.insert(el[ao],eu)return eu end;local function ev(eu)for bK,bL in pairs(el)do for aN,a3 in pairs(bL)do if a3==eu then table.remove(el[bK],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,eu)for a2,Z in pairs(em)do for a2,a3 in pairs(el[Z])do if a3==eu then if en~=nil then en:loseFocusHandler()end;en=eu;en:getFocusHandler()end end end;return self end,setOffset=function(self,aH,aI)ep=aH~=nil and math.floor(aH<0 and math.abs(aH)or-aH)or ep;bf=aI~=nil and math.floor(aI<0 and math.abs(aI)or-aI)or bf;return self end,getFrameOffset=function(self)return ep,bf end,removeFocusedObject=function(self)if en~=nil then en:loseFocusHandler()end;en=nil;return self end,getFocusedObject=function(self)return en end,show=function(self)b1:show()if self.parent==nil then b=self end;return self end,setCursor=function(self,ew,ex,ey,aD)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())cD=ew or false;if ex~=nil then cz=b5+ex-1 end;if ey~=nil then cA=b6+ey-1 end;eo=aD or eo;self:setVisualChanged()return self end,setMoveable=function(self,ez)self.isMoveable=ez or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,eA)self.barActive=eA or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,G,Q,R)self.barText=G or""self.barBackground=Q or self.barBackground;self.barTextcolor=R or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,be)self.barTextAlign=be or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local eB=b1.getVisualChanged(self)for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.getVisualChanged~=nil and a3:getVisualChanged()then eB=true end end end end;return eB end,loseFocusHandler=function(self)b1.loseFocusHandler(self)end,getFocusHandler=function(self)b1.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,_,aN)if en~=nil then if en.keyHandler~=nil then if en:keyHandler(_,aN)then return true end end end;return false end,backgroundKeyHandler=function(self,_,aN)b1.backgroundKeyHandler(self,_,aN)for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.backgroundKeyHandler~=nil then a3:backgroundKeyHandler(_,aN)end end end end end,eventHandler=function(self,_,aO,aP,aQ,aR)b1.eventHandler(self,_,aO,aP,aQ,aR)for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.eventHandler~=nil then a3:eventHandler(_,aO,aP,aQ,aR)end end end end;if _=="terminate"then e.clear()e.setCursorPos(1,1)a.stop()end end,mouseClickHandler=function(self,_,aK,E,F)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 _=="mouse_drag"then local eC=1;local eD=1;if self.parent~=nil then eC,eD=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(E+self.xToRem-(eC-1)+aH,F-(eD-1)+aI)end;if _=="mouse_up"then self.drag=false end;return true end;if b1.mouseClickHandler(self,_,aK,E,F)then local aE,aF=self:getAbsolutePosition(self:getAnchorPosition())for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in ai(el[Z])do if a3.mouseClickHandler~=nil then if a3:mouseClickHandler(_,aK,E+aH,F+aI)then return true end end end end end;if self.isMoveable then if E>=aE and E<=aE+self.width-1 and F==aF and _=="mouse_click"then self.drag=true;self.xToRem=aE-E end end;if en~=nil then en:loseFocusHandler()en=nil end;return true end;return false end,setText=function(self,E,F,G)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:setText(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(G,math.max(1-E+1,1),self.width-E+1))else P.setText(math.max(E+b5-1,b5),b6+F-1,f(G,math.max(1-E+1,1),self.width-E+1))end end end,setBG=function(self,E,F,Q)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:setBG(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(Q,math.max(1-E+1,1),self.width-E+1))else P.setBG(math.max(E+b5-1,b5),b6+F-1,f(Q,math.max(1-E+1,1),self.width-E+1))end end end,setFG=function(self,E,F,R)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:setFG(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(R,math.max(1-E+1,1),self.width-E+1))else P.setFG(math.max(E+b5-1,b5),b6+F-1,f(R,math.max(1-E+1,1),self.width-E+1))end end end,writeText=function(self,E,F,G,Q,R)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:writeText(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(G,math.max(1-E+1,1),self.width-E+1),Q,R)else P.writeText(math.max(E+b5-1,b5),b6+F-1,f(G,math.max(1-E+1,1),self.width-E+1),Q,R)end end end,drawBackgroundBox=function(self,E,F,k,l,Q)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())l=F<1 and(l+F>self.height and self.height or l+F-1)or(l+F>self.height and self.height-F+1 or l)k=E<1 and(k+E>self.width and self.width or k+E-1)or(k+E>self.width and self.width-E+1 or k)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(E+b5-1,b5)-(self.parent.x-1),math.max(F+b6-1,b6)-(self.parent.y-1),k,l,Q)else P.drawBackgroundBox(math.max(E+b5-1,b5),math.max(F+b6-1,b6),k,l,Q)end end,drawTextBox=function(self,E,F,k,l,S)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())l=F<1 and(l+F>self.height and self.height or l+F-1)or(l+F>self.height and self.height-F+1 or l)k=E<1 and(k+E>self.width and self.width or k+E-1)or(k+E>self.width and self.width-E+1 or k)if self.parent~=nil then self.parent:drawTextBox(math.max(E+b5-1,b5)-(self.parent.x-1),math.max(F+b6-1,b6)-(self.parent.y-1),k,l,S:sub(1,1))else P.drawTextBox(math.max(E+b5-1,b5),math.max(F+b6-1,b6),k,l,S:sub(1,1))end end,drawForegroundBox=function(self,E,F,k,l,R)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())l=F<1 and(l+F>self.height and self.height or l+F-1)or(l+F>self.height and self.height-F+1 or l)k=E<1 and(k+E>self.width and self.width or k+E-1)or(k+E>self.width and self.width-E+1 or k)if self.parent~=nil then self.parent:drawForegroundBox(math.max(E+b5-1,b5)-(self.parent.x-1),math.max(F+b6-1,b6)-(self.parent.y-1),k,l,R)else P.drawForegroundBox(math.max(E+b5-1,b5),math.max(F+b6-1,b6),k,l,R)end end,draw=function(self)if self:getVisualChanged()then if b1.draw(self)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())local e8,e9=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(e8,e9,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(e8,e9,self.width,self.height,self.fgColor)self.parent:drawTextBox(e8,e9,self.width,self.height," ")else P.drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)P.drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)P.drawTextBox(b5,b6,self.width,self.height," ")end;e.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(e8,e9,ad(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)else P.writeText(b5,b6,ad(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for a2,Z in ai(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.draw~=nil then a3:draw()end end end end;if cD then e.setTextColor(eo)e.setCursorPos(cz,cA)if self.parent~=nil then e.setCursorBlink(self:isFocused())else e.setCursorBlink(cD)end end;self:setVisualChanged(false)end end end,addObject=function(self,eu)return et(eu)end,removeObject=function(self,eu)return ev(eu)end,getObject=function(self,eu)return es(eu)end,addButton=function(self,am)local eu=b0(am)eu.name=am;return et(eu)end,addLabel=function(self,am)local eu=ck(am)eu.name=am;eu.bgColor=self.bgColor;eu.fgColor=self.fgColor;return et(eu)end,addCheckbox=function(self,am)local eu=b8(am)eu.name=am;return et(eu)end,addInput=function(self,am)local eu=c1(am)eu.name=am;return et(eu)end,addProgram=function(self,am)local eu=cx(am)eu.name=am;return et(eu)end,addTextfield=function(self,am)local eu=e1(am)eu.name=am;return et(eu)end,addList=function(self,am)local eu=co(am)eu.name=am;return et(eu)end,addDropdown=function(self,am)local eu=b9(am)eu.name=am;return et(eu)end,addRadio=function(self,am)local eu=dI(am)eu.name=am;return et(eu)end,addTimer=function(self,am)local eu=ed(am)eu.name=am;return et(eu)end,addAnimation=function(self,am)local eu=aS(am)eu.name=am;return et(eu)end,addSlider=function(self,am)local eu=d_(am)eu.name=am;return et(eu)end,addScrollbar=function(self,am)local eu=dN(am)eu.name=am;return et(eu)end,addMenubar=function(self,am)local eu=cr(am)eu.name=am;return et(eu)end,addThread=function(self,am)local eu=ea(am)eu.name=am;return et(eu)end,addPane=function(self,am)local eu=cw(am)eu.name=am;return et(eu)end,addImage=function(self,am)local eu=bo(am)eu.name=am;return et(eu)end,addProgressbar=function(self,am)local eu=dy(am)eu.name=am;return et(eu)end,addFrame=function(self,am)local eu=ej(am,self)eu.name=am;return et(eu)end}setmetatable(av,b1)if ek==nil then table.insert(c,av)end;return av end;local eE=false;local function eF(_,aO,aP,aQ,aR)if _=="mouse_click"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="mouse_drag"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="mouse_up"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="mouse_scroll"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="key"or _=="char"then b:keyHandler(_,aO)b:backgroundKeyHandler(_,aO)end;for a2,a3 in pairs(c)do a3:eventHandler(_,aO,aP,aQ,aR)end;if eE then b:draw()P.update()end end;function a.autoUpdate(ec)e.clear()eE=ec or true;b:draw()P.update()while eE do local _,aO,aP,aQ,aR=os.pullEventRaw()eF(_,aO,aP,aQ,aR)end end;function a.update(_,aO,aP,aQ,aR)if _~="nil"then eF(_,aO,aP,aQ,aR)else b:draw()P.update()end end;function a.stop()eE=false end;function a.getFrame(am)for a2,a3 in pairs(c)do if a3.name==am then return a3 end end end;function a.getActiveFrame()return b end;function a.setActiveFrame(aw)if aw:getType()=="Frame"then b=aw;return true end;return false end;function a.createFrame(am)local aw=ej(am)return aw end;function a.removeFrame(am)for aN,a3 in pairs(c)do if a3.name==am then c[aN]=nil;return true end end;return false end;if a.debugger then a.debugFrame=a.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)a.debugList=a.debugFrame:addList("debugList"):setSize(a.debugFrame.width-2,a.debugFrame.height-3):setPosition(2,3):setScrollable(true):show()a.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()a.oldFrame:show()end):setBackground(colors.red):show()a.debugLabel=a.debugFrame:addLabel("debugLabel"):onClick(function()a.oldFrame=b;a.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if a.debugger then function a.debug(...)local a9={...}if b.name~="basaltDebuggingFrame"then if b~=a.debugLabel.frame then a.debugLabel:setParent(b)end end;local eG=""for aN,a3 in pairs(a9)do eG=eG..tostring(a3)..(#a9~=aN and", "or"")end;a.debugLabel:setText("[Debug] "..eG)a.debugList:addItem(eG)if a.debugList:getItemCount()>50 then a.debugList:removeItem(1)end;a.debugList:setValue(a.debugList:getItem(a.debugList:getItemCount()))a.debugLabel:show()end end;return a \ No newline at end of file +local a={debugger=true,version=1}local b;local c={}local d={}local e=term.current()local f=string.sub;local g={[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 h={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 function i()local j=e;local k,l=j.getSize()local m={}local n={}local o={}local p={}local q={}local r={}local s;local t={}local function u()s=(" "):rep(k)for v=0,15 do local w=2^v;local x=g[w]t[w]=x:rep(k)end end;u()local function y()local z=s;local A=t[colors.white]local B=t[colors.black]for C=1,l do m[C]=f(m[C]==nil and z or m[C]..z:sub(1,k-m[C]:len()),1,k)o[C]=f(o[C]==nil and A or o[C]..A:sub(1,k-o[C]:len()),1,k)n[C]=f(n[C]==nil and B or n[C]..B:sub(1,k-n[C]:len()),1,k)end end;y()local function D(E,F,G)if F>=1 and F<=l then if E+G:len()>0 and E<=k then local H=m[F]local I;local J=E+#G-1;if E<1 then local K=1-E+1;local L=k-E+1;G=f(G,K,L)elseif J>k then local L=k-E+1;G=f(G,1,L)end;if E>1 then local L=E-1;I=f(H,1,L)..G else I=G end;if J=1 and F<=l then if E+N:len()>0 and E<=k then local H=n[F]local I;local J=E+#N-1;if E<1 then N=f(N,1-E+1,k-E+1)elseif J>k then N=f(N,1,k-E+1)end;if E>1 then I=f(H,1,E-1)..N else I=N end;if J=1 and F<=l then if E+N:len()>0 and E<=k then local H=o[F]local I;local J=E+#N-1;if E<1 then local K=1-E+1;local L=k-E+1;N=f(N,K,L)elseif J>k then local L=k-E+1;N=f(N,1,L)end;if E>1 then local L=E-1;I=f(H,1,L)..N else I=N end;if JE and aM<=F and aM+self.height>F and as then if self.parent~=nil then self.parent:setFocusedObject(self)end;au:sendEvent(_,self,_,aK,E,F)return true end;return false end,keyHandler=function(self,_,aN)if self:isFocused()then au:sendEvent(_,self,_,aN)return true end;return false end,backgroundKeyHandler=function(self,_,aN)au:sendEvent("background_".._,self,_,aN)end,valueChangedHandler=function(self)au:sendEvent("value_changed",self)end,eventHandler=function(self,_,aO,aP,aQ,aR)au:sendEvent("custom_event_handler",self,_,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 av={}local an="Animation"local aT;local aU={}local Z=1;local aV=0;local aW;local function aX()if aU[Z]~=nil then aU[Z].f(av,Z)end;Z=Z+1;if aU[Z]~=nil then if aU[Z].t>0 then aT=os.startTimer(aU[Z].t)else aX()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,a1,aY)aW=a1;table.insert(aU,{f=a1,t=aY or aV})return self end,wait=function(self,aY)aV=aY;return self end,rep=function(self,aZ)for E=1,aZ do table.insert(aU,{f=aW,t=aV})end;return self end,clear=function(self)aU={}aW=nil;aV=0;Z=1;return self end,play=function(self)Z=1;if aU[Z]~=nil then if aU[Z].t>0 then aT=os.startTimer(aU[Z].t)else aX()end end;return self end,cancel=function(self)os.cancelTimer(aT)return self end,eventHandler=function(self,_,a_)if _=="timer"and a_==aT then if aU[Z]~=nil then aX()end end end}av.__index=av;return av end;local function b0(am)local b1=al(am)local an="Button"b1:setValue("Button")b1:setZIndex(5)b1.width=8;b1.bgColor=h.ButtonBG;b1.fgColor=h.ButtonFG;local b2="center"local b3="center"local av={getType=function(self)return an end,setHorizontalAlign=function(self,b4)b2=b4 end,setVerticalAlign=function(self,b4)b3=b4 end,setText=function(self,G)b1:setValue(G)return self end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,b3)self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)self.parent:drawTextBox(b5,b6,self.width,self.height," ")for v=1,self.height do if v==b7 then self.parent:setText(b5,b6+v-1,ad(self:getValue(),self.width,b2))end end end end end}return setmetatable(av,b1)end;local function b8(am)local b1=al(am)local an="Checkbox"b1:setZIndex(5)b1:setValue(false)b1.width=1;b1.height=1;b1.bgColor=h.CheckboxBG;b1.fgColor=h.CheckboxFG;local av={symbol="\42",getType=function(self)return an end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then if _=="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 b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,"center")self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)for v=1,self.height do if v==b7 then if self:getValue()==true then self.parent:writeText(b5,b6+v-1,ad(self.symbol,self.width,"center"),self.bgColor,self.fgColor)else self.parent:writeText(b5,b6+v-1,ad(" ",self.width,"center"),self.bgColor,self.fgColor)end end end end end end}return setmetatable(av,b1)end;local function b9(am)local b1=al(am)local an="Dropdown"b1.width=12;b1.height=1;b1.bgColor=h.dropdownBG;b1.fgColor=h.dropdownFG;b1:setZIndex(6)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local bd=true;local be="left"local bf=0;local bg=16;local bh=6;local bi="\16"local bj="\31"local bk=1;local av={getType=function(self)return an end,setIndexOffset=function(self,bl)bf=bl;return self end,getIndexOffset=function(self)return bf end,addItem=function(self,G,Q,R,...)table.insert(ba,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,bn)bb=Q or self.bgColor;bc=R or self.fgColor;bd=bn;return self end,setDropdownSize=function(self,k,l)bg,bh=k,l;return self end,mouseClickHandler=function(self,_,aK,E,F)if bk==2 then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if _=="mouse_click"then if aK==1 then if#ba>0 then for v=1,bh do if ba[v+bf]~=nil then if b5<=E and b5+bg>E and b6+v==F then self:setValue(ba[v+bf])return true end end end end end end;if _=="mouse_scroll"then bf=bf+aK;if bf<0 then bf=0 end;if aK==1 then if#ba>bh then if bf>#ba-bh then bf=#ba-bh end else bf=ba-1 end end;return true end;self:setVisualChanged()end;if b1.mouseClickHandler(self,_,aK,E,F)then bk=2 else bk=1 end end,draw=function(self)if b1.draw(self)then local b5,b6=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)if#ba>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if bk==1 then self.parent:writeText(b5,b6,ad(self:getValue().text,self.width,be):sub(1,self.width-1)..bi,self.bgColor,self.fgColor)else self.parent:writeText(b5,b6,ad(self:getValue().text,self.width,be):sub(1,self.width-1)..bj,self.bgColor,self.fgColor)end end end;if bk==2 then for v=1,bh do if ba[v+bf]~=nil then if ba[v+bf]==self:getValue()then if bd then self.parent:writeText(b5,b6+v,ad(ba[v+bf].text,bg,be),bb,bc)else self.parent:writeText(b5,b6+v,ad(ba[v+bf].text,bg,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end else self.parent:writeText(b5,b6+v,ad(ba[v+bf].text,bg,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end end end end end end end end}return setmetatable(av,b1)end;local function bo(am)local b1=al(am)local an="Image"b1:setZIndex(2)local bp;local bq;local br=false;local function bs()local bt={[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 bu,bv,bw={},{},{}for ak=0,15 do bv[2^ak]=ak end;do local bx="0123456789abcdef"for ak=1,16 do bu[bx:sub(ak,ak)]=ak-1;bu[ak-1]=bx:sub(ak,ak)bw[bx:sub(ak,ak)]=2^(ak-1)bw[2^(ak-1)]=bx:sub(ak,ak)local by=bt[ak-1]for ak=1,#by do by[ak]=2^by[ak]end end end;local function bz(bA)local bB=bt[bv[bA[#bA][1]]]for bC=1,#bB do local bD=bB[bC]for ak=1,#bA-1 do if bA[ak][1]==bD then return ak end end end;return 1 end;local function bE(bF,bG)if not bG then local bH={}bG={}for ak=1,6 do local bI=bF[ak]local bJ=bG[bI]bG[bI],bH[ak]=bJ and bJ+1 or 1,bI end;bF=bH end;local bA={}for aN,a3 in pairs(bG)do bA[#bA+1]={aN,a3}end;if#bA>1 then while#bA>2 do table.sort(bA,function(bK,bL)return bK[2]>bL[2]end)local bM,bN=bz(bA),#bA;local bO,bP=bA[bN][1],bA[bM][1]for ak=1,6 do if bF[ak]==bO then bF[ak]=bP;bA[bM][2]=bA[bM][2]+1 end end;bA[bN]=nil end;local bQ=128;for ak=1,#bF-1 do if bF[ak]~=bF[6]then bQ=bQ+2^(ak-1)end end;return string.char(bQ),bw[bA[1][1]==bF[6]and bA[2][1]or bA[1][1]],bw[bF[6]]else return"\128",bw[bF[1]],bw[bF[1]]end end;local bR,k,l,Q={{},{},{}},0,#bp+#bp%3,b1.bgColor or colors.black;for ak=1,#bp do if#bp[ak]>k then k=#bp[ak]end end;for F=0,l-1,3 do local bS,bT,bU,bV={},{},{},1;for E=0,k-1,2 do local bF,bG={},{}for bW=1,3 do for bX=1,2 do bF[#bF+1]=bp[F+bW]and bp[F+bW][E+bX]and(bp[F+bW][E+bX]==0 and Q or bp[F+bW][E+bX])or Q;bG[bF[#bF]]=bG[bF[#bF]]and bG[bF[#bF]]+1 or 1 end end;bS[bV],bT[bV],bU[bV]=bE(bF,bG)bV=bV+1 end;bR[1][#bR[1]+1],bR[2][#bR[2]+1],bR[3][#bR[3]+1]=table.concat(bS),table.concat(bT),table.concat(bU)end;bR.width,bR.height=#bR[1][1],#bR[1]bq=bR end;local av={getType=function(self)return an end,loadImage=function(self,a7)bp=paintutils.loadImage(a7)br=false;return self end,loadBlittleImage=function(self,a7)br=true;return self end,shrink=function(self)bs()br=true;return self end,draw=function(self)if b1.draw(self)then if self.parent~=nil then if bp~=nil then local b5,b6=self:getAnchorPosition()if br then local aj,bY,bZ=bq[1],bq[2],bq[3]for ak=1,bq.height do local b_=aj[ak]if type(b_)=="string"then self.parent:setText(b5,b6+ak-1,b_)self.parent:setFG(b5,b6+ak-1,bY[ak])self.parent:setBG(b5,b6+ak-1,bZ[ak])elseif type(b_)=="table"then self.parent:setText(b5,b6+ak-1,b_[2])self.parent:setFG(b5,b6+ak-1,bY[ak])self.parent:setBG(b5,b6+ak-1,bZ[ak])end end else for aA=1,math.min(#bp,self.height)do local c0=bp[aA]for az=1,math.min(#c0,self.width)do if c0[az]>0 then self.parent:drawBackgroundBox(b5+az-1,b6+aA-1,1,1,c0[az])end end end end end end end end}return setmetatable(av,b1)end;local function c1(am)local b1=al(am)local an="Input"local c2="text"local c3=0;b1:setZIndex(5)b1:setValue("")b1.width=10;b1.height=1;b1.bgColor=h.InputBG;b1.fgColor=h.InputFG;local c4=1;local c5=1;local c6=""local c7;local c8;local c9=c6;local ca=false;local av={getType=function(self)return an end,setInputType=function(self,cb)if cb=="password"or cb=="number"or cb=="text"then c2=cb end;return self end,setDefaultText=function(self,G,cc,cd)c6=G;c7=cd or c7;c8=cc or c8;if self:isFocused()then c9=""else c9=c6 end;return self end,getInputType=function(self)return c2 end,setValue=function(self,ce)b1.setValue(self,tostring(ce))if not ca then c4=tostring(ce):len()+1 end;return self end,getValue=function(self)local ce=b1.getValue(self)return c2=="number"and tonumber(ce)or ce end,setInputLimit=function(self,cf)c3=tonumber(cf)or c3;return self end,getInputLimit=function(self)return c3 end,getFocusHandler=function(self)b1.getFocusHandler(self)if self.parent~=nil then local b5,b6=self:getAnchorPosition()c9=""if self.parent~=nil then self.parent:setCursor(true,b5+c4-c5,b6,self.fgColor)end end end,loseFocusHandler=function(self)b1.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)c9=c6 end end,keyHandler=function(self,_,aN)if b1.keyHandler(self,_,aN)then ca=true;if _=="key"then if aN==keys.backspace then local G=tostring(b1.getValue())if c4>1 then self:setValue(G:sub(1,c4-2)..G:sub(c4,G:len()))if c4>1 then c4=c4-1 end;if c5>1 then if c4cg then c4=cg+1 end;if c4<1 then c4=1 end;if c4=self.width+c5 then c5=c4-self.width+1 end;if c5<1 then c5=1 end end;if aN==keys.left then c4=c4-1;if c4>=1 then if c4=self.width+c5 then c5=c4 end end;if c4<1 then c4=1 end;if c5<1 then c5=1 end end end;if _=="char"then local G=b1.getValue()if G:len()=self.width+c5 then c5=c5+1 end end end;local b5,b6=self:getAnchorPosition()local ce=tostring(b1.getValue())local ci=(c4<=ce:len()and c4-1 or ce:len())-(c5-1)if ci>self.x+self.width-1 then ci=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,b5+ci,b6,self.fgColor)end;ca=false end end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then if _=="mouse_click"and aK==1 then end;return true end;return false end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,"center")self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)for v=1,self.height do if v==b7 then local ce=tostring(b1.getValue())local cd=self.bgColor;local cc=self.fgColor;local G;if ce:len()<=0 then G=c9;cd=c7 or cd;cc=c8 or cc end;G=c9;if ce~=""then G=ce end;G=G:sub(c5,self.width+c5-1)local cj=self.width-G:len()if cj<0 then cj=0 end;if c2=="password"and ce~=""then G=string.rep("*",G:len())end;G=G..string.rep(" ",cj)self.parent:writeText(b5,b6+v-1,G,cd,cc)end end end end end}return setmetatable(av,b1)end;local function ck(am)local b1=al(am)local an="Label"b1:setZIndex(3)local cl=true;b1:setValue("")local b2="left"local b3="top"local av={getType=function(self)return an end,setText=function(self,G)G=tostring(G)b1:setValue(G)if cl then self.width=G:len()end;return self end,setTextAlign=function(self,cm,cn)b2=cm or b2;b3=cn or b3;self:setVisualChanged()return self end,setSize=function(self,k,l)b1.setSize(self,k,l)cl=false;self:setVisualChanged()return self end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()local b7=ag(self.height,b3)self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)self.parent:drawTextBox(b5,b6,self.width,self.height," ")for v=1,self.height do if v==b7 then self.parent:writeText(b5,b6+v-1,ad(self:getValue(),self.width,b2),self.bgColor,self.fgColor)end end end end end}return setmetatable(av,b1)end;local function co(am)local b1=al(am)local an="List"b1.width=16;b1.height=6;b1.bgColor=h.listBG;b1.fgColor=h.listFG;b1:setZIndex(5)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local bd=true;local be="left"local bf=0;local cp=true;local av={getType=function(self)return an end,addItem=function(self,G,Q,R,...)table.insert(ba,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})if#ba==1 then self:setValue(ba[1])end;return self end,setIndexOffset=function(self,bl)bf=bl;return self end,getIndexOffset=function(self)return bf end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,bn)bb=Q or self.bgColor;bc=R or self.fgColor;bd=bn;return self end,setScrollable=function(self,cq)cp=cq;return self end,mouseClickHandler=function(self,_,aK,E,F)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if b5<=E and b5+self.width>E and b6<=F and b6+self.height>F and self:isVisible()then if _=="mouse_click"or _=="mouse_drag"then if aK==1 then if#ba>0 then for v=1,self.height do if ba[v+bf]~=nil then if b5<=E and b5+self.width>E and b6+v-1==F then self:setValue(ba[v+bf])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,E,F,ba[v+bf])end end end end end end;if _=="mouse_scroll"and cp then bf=bf+aK;if bf<0 then bf=0 end;if aK>=1 then if#ba>self.height then if bf>#ba-self.height then bf=#ba-self.height end;if bf>=#ba then bf=#ba-1 end else bf=bf-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)for v=1,self.height do if ba[v+bf]~=nil then if ba[v+bf]==self:getValue()then if bd then self.parent:writeText(b5,b6+v-1,ad(ba[v+bf].text,self.width,be),bb,bc)else self.parent:writeText(b5,b6+v-1,ad(ba[v+bf].text,self.width,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end else self.parent:writeText(b5,b6+v-1,ad(ba[v+bf].text,self.width,be),ba[v+bf].bgCol,ba[v+bf].fgCol)end end end end end end}return setmetatable(av,b1)end;local function cr(am)local b1=al(am)local an="Menubar"local av={}b1.width=30;b1.height=1;b1.bgColor=colors.gray;b1.fgColor=colors.lightGray;b1:setZIndex(5)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local bd=true;local be="left"local cs=0;local cj=2;local cp=false;local function ct()local cu=0;local az=1;for v=1,#ba do if az+ba[v].text:len()+cj*2>av.w then cu=cu+ba[v].text:len()+cj*2 end;az=az+ba[v].text:len()+cj*2 end;return cu end;av={getType=function(self)return an end,addItem=function(self,G,Q,R,...)table.insert(ba,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})if#ba==1 then self:setValue(ba[1])end;return self end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,setSpace=function(self,cv)cj=cv or cj;return self end,setButtonOffset=function(self,af)cs=af or 0;if cs<0 then cs=0 end;local cu=ct()if cs>cu then cs=cu end;return self end,setScrollable=function(self,cq)cp=cq;return self end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,bn)bb=Q or self.bgColor;bc=R or self.fgColor;bd=bn;return self end,mouseClickHandler=function(self,_,aK,E,F)local aL,aM=self:getAbsolutePosition(self:getAnchorPosition())if aL<=E and aL+self.width>E and aM<=F and aM+self.height>F and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if _=="mouse_click"then local az=1;for v=1+cs,#ba do if ba[v]~=nil then if az+ba[v].text:len()+cj*2<=self.width then if aL+az-1<=E and aL+az-1+ba[v].text:len()+cj*2>E and aM==F then self:setValue(ba[v])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,E,F,ba[v])end;az=az+ba[v].text:len()+cj*2 else break end end end end;if _=="mouse_scroll"and cp then cs=cs+aK;if cs<0 then cs=0 end;local cu=ct()if cs>cu then cs=cu end end;return true end;return false end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)local az=0;for a2,a3 in pairs(ba)do if az+a3.text:len()+cj*2<=self.width then if a3==self:getValue()then self.parent:writeText(b5+az-1+-cs,b6,ad((" "):rep(cj)..a3.text..(" "):rep(cj),a3.text:len()+cj*2,be),bb or a3.bgCol,bc or a3.fgCol)else self.parent:writeText(b5+az-1+-cs,b6,ad((" "):rep(cj)..a3.text..(" "):rep(cj),a3.text:len()+cj*2,be),a3.bgCol,a3.fgCol)end;az=az+a3.text:len()+cj*2 else if az=1 and cA>=1 and cz<=k and cA<=l then else end end;local function cI(cJ,cK,cL)local cM=cz;local J=cM+#cJ-1;if cA>=1 and cA<=l then if cM<=k and J>=1 then if cM==1 and J==k then m[cA]=cJ;o[cA]=cK;n[cA]=cL else local cN,cO,cP;if cM<1 then local cQ=1-cM+1;local cR=k-cM+1;cN=f(cJ,cQ,cR)cO=f(cK,cQ,cR)cP=f(cL,cQ,cR)elseif J>k then local cR=k-cM+1;cN=f(cJ,1,cR)cO=f(cK,1,cR)cP=f(cL,1,cR)else cN=cJ;cO=cK;cP=cL end;local cS=m[cA]local cT=o[cA]local cU=n[cA]local cV,cW,cX;if cM>1 then local cY=cM-1;cV=f(cS,1,cY)..cN;cW=f(cT,1,cY)..cO;cX=f(cU,1,cY)..cP else cV=cN;cW=cO;cX=cP end;if J=1 and F<=l then m[dk]=m[F]n[dk]=n[F]o[dk]=o[F]else m[dk]=dh;o[dk]=di;n[dk]=dj end end end;if cE then cH()end end,isColor=function()return e.isColor()end,isColour=function()return e.isColor()end,write=function(G)G=tostring(G)if cE then cI(G,g[cC]:rep(G:len()),g[cB]:rep(G:len()))end end,clearLine=function()if cE then D(1,cA,(" "):rep(k))M(1,cA,g[cB]:rep(k))O(1,cA,g[cC]:rep(k))end;if cE then cH()end end,clear=function()for v=1,l do D(1,v,(" "):rep(k))M(1,v,g[cB]:rep(k))O(1,v,g[cC]:rep(k))end;if cE then cH()end end,blit=function(G,dl,dm)if type(G)~="string"then error("bad argument #1 (expected string, got "..type(G)..")",2)end;if type(dl)~="string"then error("bad argument #2 (expected string, got "..type(dl)..")",2)end;if type(dm)~="string"then error("bad argument #3 (expected string, got "..type(dm)..")",2)end;if#dl~=#G or#dm~=#G then error("Arguments must be the same length",2)end;if cE then cI(G,dl,dm)end end}return dc end;b1.width=30;b1.height=12;local dn=cy(1,1,b1.width,b1.height)local dp;local dq=false;local dr={}av={getType=function(self)return an end,show=function(self)b1.show(self)dn.setBackgroundColor(self.bgColor)dn.setTextColor(self.fgColor)dn.basalt_setVisible(true)return self end,hide=function(self)b1.hide(self)dn.basalt_setVisible(false)return self end,setPosition=function(self,E,F,aB)b1.setPosition(self,E,F,aB)dn.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return dn end,getBasaltProcess=function()return dp end,setSize=function(self,k,l)b1.setSize(self,k,l)dn.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if dp~=nil then return dp:getStatus()end;return"inactive"end,execute=function(self,a7,...)dp=a5:new(a7,dn,...)dn.setBackgroundColor(colors.black)dn.setTextColor(colors.white)dn.clear()dn.setCursorPos(1,1)dp:resume()dq=false;return self end,stop=function(self)if dp~=nil then if not dp:isDead()then dp:resume("terminate")if dp:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,ds)dq=ds or not dq;if dp~=nil then if not dp:isDead()then if not dq then self:injectEvents(dr)dr={}end end end;return self end,isPaused=function(self)return dq end,injectEvent=function(self,_,aO,aP,aQ,aR,dt)if dp~=nil then if not dp:isDead()then if dq==false or dt then dp:resume(_,aO,aP,aQ,aR)else table.insert(dr,{event=_,args={aO,aP,aQ,aR}})end end end;return self end,getQueuedEvents=function(self)return dr end,updateQueuedEvents=function(self,Y)dr=Y or dr;return self end,injectEvents=function(self,Y)if dp~=nil then if not dp:isDead()then for a2,a3 in pairs(Y)do dp:resume(a3.event,table.unpack(a3.args))end end end;return self end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then if dp==nil then return false end;if not dp:isDead()then if not dq then local du,dv=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))dp:resume(_,aK,E-du+1,F-dv+1)end end;return true end end,keyHandler=function(self,_,aN)b1.keyHandler(self,_,aN)if self:isFocused()then if dp==nil then return false end;if not dp:isDead()then if not dq then if self.draw then dp:resume(_,aN)end end end end end,getFocusHandler=function(self)b1.getFocusHandler(self)if dp~=nil then if not dp:isDead()then if not dq then if self.parent~=nil then local dw,dx=dn.getCursorPos()local b5,b6=self:getAnchorPosition()if self.parent~=nil then if b5+dw-1>=1 and b5+dw-1<=b5+self.width-1 and dx+b6-1>=1 and dx+b6-1<=b6+self.height-1 then self.parent:setCursor(dn.getCursorBlink(),b5+dw-1,dx+b6-1,dn.getTextColor())end end end end end end end,loseFocusHandler=function(self)b1.loseFocusHandler(self)if dp~=nil then if not dp:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,_,aO,aP,aQ,aR)if dp==nil then return end;if not dp:isDead()then if not dq then if _~="mouse_click"and _~="mouse_up"and _~="mouse_scroll"and _~="mouse_drag"and _~="key_up"and _~="key"and _~="char"and _~="terminate"then dp:resume(_,aO,aP,aQ,aR)end;if self:isFocused()then local b5,b6=self:getAnchorPosition()local dw,dx=dn.getCursorPos()if self.parent~=nil then if b5+dw-1>=1 and b5+dw-1<=b5+self.width-1 and dx+b6-1>=1 and dx+b6-1<=b6+self.height-1 then self.parent:setCursor(dn.getCursorBlink(),b5+dw-1,dx+b6-1,dn.getTextColor())end end;if _=="terminate"and self:isFocused()then self:stop()end end else if _~="mouse_click"and _~="mouse_up"and _~="mouse_scroll"and _~="mouse_drag"and _~="key_up"and _~="key"and _~="char"and _~="terminate"then table.insert(dr,{event=_,args={aO,aP,aQ,aR}})end end end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()dn.basalt_reposition(b5,b6)self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)dn.basalt_update()end end end}return setmetatable(av,b1)end;local function dy(am)local b1=al(am)local an="Progressbar"local dz=0;b1:setZIndex(5)b1:setValue(false)b1.width=25;b1.height=1;b1.bgColor=h.CheckboxBG;b1.fgColor=h.CheckboxFG;local dA=colors.black;local dB=""local dC=colors.white;local dD=""local dE=0;local av={getType=function(self)return an end,setDirection=function(self,dF)dE=dF;return self end,setProgressBar=function(self,aD,S,dG)dA=aD or dA;dB=S or dB;dC=dG or dC;return self end,setBackgroundSymbol=function(self,S)dD=S:sub(1,1)return self end,setProgress=function(self,a3)if a3>=0 and a3<=100 and dz~=a3 then dz=a3;self:setValue(dz)if dz==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return dz end,onProgressDone=function(self,dH)self:registerEvent("progress_done",dH)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)self.parent:drawTextBox(b5,b6,self.width,self.height,dD)if dE==1 then self.parent:drawBackgroundBox(b5,b6,self.width,self.height/100*dz,dA)self.parent:drawForegroundBox(b5,b6,self.width,self.height/100*dz,dC)self.parent:drawTextBox(b5,b6,self.width,self.height/100*dz,dB)elseif dE==2 then self.parent:drawBackgroundBox(b5,b6+math.ceil(self.height-self.height/100*dz),self.width,self.height/100*dz,dA)self.parent:drawForegroundBox(b5,b6+math.ceil(self.height-self.height/100*dz),self.width,self.height/100*dz,dC)self.parent:drawTextBox(b5,b6+math.ceil(self.height-self.height/100*dz),self.width,self.height/100*dz,dB)elseif dE==3 then self.parent:drawBackgroundBox(b5+math.ceil(self.width-self.width/100*dz),b6,self.width/100*dz,self.height,dA)self.parent:drawForegroundBox(b5+math.ceil(self.width-self.width/100*dz),b6,self.width/100*dz,self.height,dC)self.parent:drawTextBox(b5+math.ceil(self.width-self.width/100*dz),b6,self.width/100*dz,self.height,dB)else self.parent:drawBackgroundBox(b5,b6,self.width/100*dz,self.height,dA)self.parent:drawForegroundBox(b5,b6,self.width/100*dz,self.height,dC)self.parent:drawTextBox(b5,b6,self.width/100*dz,self.height,dB)end end end end}return setmetatable(av,b1)end;local function dI(am)local b1=al(am)local an="Radio"b1.width=8;b1.bgColor=h.listBG;b1.fgColor=h.listFG;b1:setZIndex(5)local ba={}local bb=h.selectionBG;local bc=h.selectionFG;local dJ=b1.bgColor;local dK=b1.fgColor;local bd=true;local S="\7"local be="left"local av={getType=function(self)return an end,addItem=function(self,G,E,F,Q,R,...)table.insert(ba,{x=E or 1,y=F or 1,text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})if#ba==1 then self:setValue(ba[1])end;return self end,removeItem=function(self,Z)table.remove(ba,Z)return self end,getItem=function(self,Z)return ba[Z]end,getItemIndex=function(self)local bm=self:getValue()for aN,a3 in pairs(ba)do if a3==bm then return aN end end end,clear=function(self)ba={}self:setValue({})return self end,getItemCount=function(self)return#ba end,editItem=function(self,Z,G,E,F,Q,R,...)table.remove(ba,Z)table.insert(ba,Z,{x=E or 1,y=F or 1,text=G,bgCol=Q or self.bgColor,fgCol=R or self.fgColor,args={...}})return self end,selectItem=function(self,Z)self:setValue(ba[Z]or{})return self end,setSelectedItem=function(self,Q,R,dL,dM,bn)bb=Q or bb;bc=R or bc;dJ=dL or dJ;dK=dM or dK;bd=bn;return self end,mouseClickHandler=function(self,_,aK,E,F)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if _=="mouse_click"then if aK==1 then if#ba>0 then for a2,a3 in pairs(ba)do if b5+a3.x-1<=E and b5+a3.x-1+a3.text:len()+2>=E and b6+a3.y-1==F then self:setValue(a3)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 b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()for a2,a3 in pairs(ba)do if a3==self:getValue()then if be=="left"then self.parent:writeText(a3.x+b5-1,a3.y+b6-1,S,dJ,dK)self.parent:writeText(a3.x+2+b5-1,a3.y+b6-1,a3.text,bb,bc)end else self.parent:drawBackgroundBox(a3.x+b5-1,a3.y+b6-1,1,1,self.bgColor)self.parent:writeText(a3.x+2+b5-1,a3.y+b6-1,a3.text,a3.bgCol,a3.fgCol)end end end end end}return setmetatable(av,b1)end;local function dN(am)local b1=al(am)local an="Scrollbar"b1.width=1;b1.height=8;b1.bgColor=colors.lightGray;b1.fgColor=colors.gray;b1:setValue(1)b1:setZIndex(2)local dO="vertical"local S=" "local dP=colors.black;local dQ="\127"local dR=b1.height;local Z=1;local dS=1;local av={getType=function(self)return an end,setSymbol=function(self,dT)S=dT:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,dU)dS=tonumber(dU)or 1;if dO=="vertical"then self:setValue(Z-1*dR/(self.height-(dS-1))-dR/(self.height-(dS-1)))elseif dO=="horizontal"then self:setValue(Z-1*dR/(self.width-(dS-1))-dR/(self.width-(dS-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,ce)dR=ce;return self end,setBackgroundSymbol=function(self,dV)dQ=string.sub(dV,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dW)dP=dW;self:setVisualChanged()return self end,setBarType=function(self,dX)dO=dX:lower()return self end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if(_=="mouse_click"or _=="mouse_drag")and aK==1 then if dO=="horizontal"then for dY=0,self.width do if b5+dY==E and b6<=F and b6+self.height>F then Z=math.min(dY+1,self.width-(dS-1))self:setValue(dR/self.width*Z)self:setVisualChanged()end end end;if dO=="vertical"then for dY=0,self.height do if b6+dY==F and b5<=E and b5+self.width>E then Z=math.min(dY+1,self.height-(dS-1))self:setValue(dR/self.height*Z)self:setVisualChanged()end end end end;if _=="mouse_scroll"then Z=Z+aK;if Z<1 then Z=1 end;Z=math.min(Z,(dO=="vertical"and self.height or self.width)-(dS-1))self:setValue(dR/(dO=="vertical"and self.height or self.width)*Z)end;return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()if dO=="horizontal"then self.parent:writeText(b5,b6,dQ:rep(Z-1),self.bgColor,self.fgColor)self.parent:writeText(b5+Z-1,b6,S:rep(dS),dP,dP)self.parent:writeText(b5+Z+dS-1,b6,dQ:rep(self.width-(Z+dS-1)),self.bgColor,self.fgColor)end;if dO=="vertical"then for v=0,self.height-1 do if Z==v+1 then for dZ=0,math.min(dS-1,self.height)do self.parent:writeText(b5,b6+v+dZ,S,dP,dP)end else if v+1Z-1+dS then self.parent:writeText(b5,b6+v,dQ,self.bgColor,self.fgColor)end end end end end end end}return setmetatable(av,b1)end;local function d_(am)local b1=al(am)local an="Slider"b1.width=8;b1.bgColor=colors.lightGray;b1.fgColor=colors.gray;b1:setValue(1)local dO="horizontal"local S=" "local dP=colors.black;local dQ="\140"local dR=b1.width;local Z=1;local av={getType=function(self)return an end,setSymbol=function(self,dT)S=dT:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,dV)dQ=string.sub(dV,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dW)dP=dW;self:setVisualChanged()return self end,setBarType=function(self,dX)dO=dX:lower()return self end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if dO=="horizontal"then for dY=0,self.width-1 do if b5+dY==E and b6<=F and b6+self.height>F then Z=dY+1;self:setValue(dR/self.width*Z)self:setVisualChanged()end end end;if dO=="vertical"then for dY=0,self.height-1 do if b6+dY==F and b5<=E and b5+self.width>E then Z=dY+1;self:setValue(dR/self.height*Z)self:setVisualChanged()end end end end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()if dO=="horizontal"then self.parent:writeText(b5,b6,dQ:rep(Z-1),self.bgColor,self.fgColor)self.parent:writeText(b5+Z-1,b6,S,dP,dP)self.parent:writeText(b5+Z,b6,dQ:rep(self.width-Z),self.bgColor,self.fgColor)end;if dO=="vertical"then for v=0,self.height-1 do if v+1==Z then self.parent:writeText(b5,b6+v,S,dP,dP)else self.parent:writeText(b5,b6+v,dQ,self.bgColor,self.fgColor)end end end end end end}return setmetatable(av,b1)end;local function e0(am)local b1=al(am)local an="Switch"b1.width=3;b1.height=1;b1.bgColor=colors.lightGray;b1.fgColor=colors.gray;b1:setValue(false)b1:setZIndex(5)local av={getType=function(self)return an end,mouseClickHandler=function(self,_,aK,E,F)if b1.mouseClickHandler(self,_,aK,E,F)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if(_=="mouse_click"or _=="mouse_drag")and aK==1 then end;return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()end end end}return setmetatable(av,b1)end;local function e1(am)local b1=al(am)local an="Textfield"local e2,c5,c4,e3=1,1,1,1;local e4={""}local e5={[colors.purple]={"break"}}b1.width=20;b1.height=8;b1.bgColor=h.textfieldBG;b1.fgColor=h.textfieldFG;b1:setZIndex(5)local av={getType=function(self)return an end,getLines=function(self)return e4 end,getLine=function(self,Z)return e4[Z]or""end,editLine=function(self,Z,G)e4[Z]=G or e4[Z]return self end,addLine=function(self,G,Z)if Z~=nil then table.insert(e4,Z,G)else table.insert(e4,G)end;return self end,addKeyword=function(self,e6,aD)end,removeLine=function(self,Z)table.remove(e4,Z or#e4)if#e4<=0 then table.insert(e4,"")end;return self end,getTextCursor=function(self)return c4,e3 end,getFocusHandler=function(self)b1.getFocusHandler(self)if self.parent~=nil then local b5,b6=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,b5+c4-c5,b6+e3-e2,self.fgColor)end end end,loseFocusHandler=function(self)b1.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,_,aN)if b1.keyHandler(self,_,aN)then local b5,b6=self:getAnchorPosition()if _=="key"then if aN==keys.backspace then if e4[e3]==""then if e3>1 then table.remove(e4,e3)c4=e4[e3-1]:len()+1;c5=c4-self.width+1;if c5<1 then c5=1 end;e3=e3-1 end elseif c4<=1 then if e3>1 then c4=e4[e3-1]:len()+1;c5=c4-self.width+1;if c5<1 then c5=1 end;e4[e3-1]=e4[e3-1]..e4[e3]table.remove(e4,e3)e3=e3-1 end else e4[e3]=e4[e3]:sub(1,c4-2)..e4[e3]:sub(c4,e4[e3]:len())if c4>1 then c4=c4-1 end;if c5>1 then if c4e4[e3]:len()then if e4[e3+1]~=nil then e4[e3]=e4[e3]..e4[e3+1]table.remove(e4,e3+1)end else e4[e3]=e4[e3]:sub(1,c4-1)..e4[e3]:sub(c4+1,e4[e3]:len())end end;if aN==keys.enter then table.insert(e4,e3+1,e4[e3]:sub(c4,e4[e3]:len()))e4[e3]=e4[e3]:sub(1,c4-1)e3=e3+1;c4=1;c5=1;if e3-e2>=self.height then e2=e2+1 end;self:setValue("")end;if aN==keys.up then if e3>1 then e3=e3-1;if c4>e4[e3]:len()+1 then c4=e4[e3]:len()+1 end;if c5>1 then if c41 then if e3e4[e3]:len()+1 then c4=e4[e3]:len()+1 end;if e3>=e2+self.height then e2=e2+1 end end end;if aN==keys.right then c4=c4+1;if e3<#e4 then if c4>e4[e3]:len()+1 then c4=1;e3=e3+1 end elseif c4>e4[e3]:len()then c4=e4[e3]:len()+1 end;if c4<1 then c4=1 end;if c4=self.width+c5 then c5=c4-self.width+1 end;if c5<1 then c5=1 end end;if aN==keys.left then c4=c4-1;if c4>=1 then if c4=self.width+c5 then c5=c4 end end;if e3>1 then if c4<1 then e3=e3-1;c4=e4[e3]:len()+1;c5=c4-self.width+1 end end;if c4<1 then c4=1 end;if c5<1 then c5=1 end end end;if _=="char"then e4[e3]=e4[e3]:sub(1,c4-1)..aN..e4[e3]:sub(c4,e4[e3]:len())c4=c4+1;if c4>=self.width+c5 then c5=c5+1 end;self:setValue("")end;local ci=(c4<=e4[e3]:len()and c4-1 or e4[e3]:len())-(c5-1)if ci>self.x+self.width-1 then ci=self.x+self.width-1 end;local e7=e3-e2e4[e3]:len()then c4=e4[e3]:len()+1 end;if c4e4[e3]:len()then c4=e4[e3]:len()+1 end;if c4#e4-(self.height-1)then e2=#e4-(self.height-1)end;if e2<1 then e2=1 end;if self.parent~=nil then if b5+c4-c5>=b5 and b5+c4-c5<=b5+self.width and(b6+e3-e2>=b6 and b6+e3-e2<=b6+self.height)then self.parent:setCursor(true,e8+c4-c5,e9+e3-e2)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if b1.draw(self)then if self.parent~=nil then local b5,b6=self:getAnchorPosition()self.parent:drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)for v=1,self.height do local G=""if e4[v+e2-1]~=nil then G=e4[v+e2-1]end;G=G:sub(c5,self.width+c5-1)local cj=self.width-G:len()if cj<0 then cj=0 end;G=G..string.rep(" ",cj)self.parent:setText(b5,b6+v-1,G)end end end end}return setmetatable(av,b1)end;local function ea(am)local av;local an="Thread"local a1;local eb;local ec=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,dH)if dH==nil then error("Function provided to thread is nil")end;a1=dH;eb=coroutine.create(a1)ec=true;local ab,ac=coroutine.resume(eb)if not ab then if ac~="Terminated"then error("Thread Error Occurred - "..ac)end end;return self end,getStatus=function(self,dH)if eb~=nil then return coroutine.status(eb)end;return nil end,stop=function(self,dH)ec=false;return self end,eventHandler=function(self,_,aO,aP,aQ)if ec then if coroutine.status(eb)~="dead"then local ab,ac=coroutine.resume(eb,_,aO,aP,aQ)if not ab then if ac~="Terminated"then error("Thread Error Occurred - "..ac)end end else ec=false end end end}av.__index=av;return av end;local function ed(am)local an="Timer"local ee=0;local ef=0;local eg=0;local aT;local au=X()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,eh,ei)ee=eh or 0;ef=ei or 1;return self end,start=function(self)eg=ef;aT=os.startTimer(ee)return self end,cancel=function(self)if aT~=nil then os.cancelTimer(aT)end;return self end,onCall=function(self,a1)au:registerEvent("timed_event",a1)return self end,eventHandler=function(self,_,a_)if _=="timer"and a_==aT then au:sendEvent("timed_event",self)if eg>=1 then eg=eg-1;if eg>=1 then aT=os.startTimer(ee)end elseif eg==-1 then aT=os.startTimer(ee)end end end}av.__index=av;return av end;local function ej(am,ek)local b1=al(am)local an="Frame"local el={}local em={}local av={}local en;b1:setZIndex(10)local cD=false;local cz=1;local cA=1;local eo=colors.white;local ep,bf=0,0;if ek~=nil then b1.parent=ek;b1.width,b1.height=ek.w,ek.h;b1.bgColor=h.FrameBG;b1.fgColor=h.FrameFG else local eq,er=e.getSize()b1.width,b1.height=eq,er;b1.bgColor=h.basaltBG;b1.fgColor=h.basaltFG end;local function es(am)for a2,a3 in pairs(el)do for a2,bL in pairs(a3)do if bL.name==am then return a3 end end end end;local function et(eu)local ao=eu:getZIndex()if es(eu.name)~=nil then return nil end;if el[ao]==nil then for E=1,#em+1 do if em[E]~=nil then if ao==em[E]then break end;if ao>em[E]then table.insert(em,E,ao)break end else table.insert(em,ao)end end;if#em<=0 then table.insert(em,ao)end;el[ao]={}end;eu.parent=av;table.insert(el[ao],eu)return eu end;local function ev(eu)for bK,bL in pairs(el)do for aN,a3 in pairs(bL)do if a3==eu then table.remove(el[bK],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,eu)for a2,Z in pairs(em)do for a2,a3 in pairs(el[Z])do if a3==eu then if en~=nil then en:loseFocusHandler()end;en=eu;en:getFocusHandler()end end end;return self end,setOffset=function(self,aH,aI)ep=aH~=nil and math.floor(aH<0 and math.abs(aH)or-aH)or ep;bf=aI~=nil and math.floor(aI<0 and math.abs(aI)or-aI)or bf;return self end,getFrameOffset=function(self)return ep,bf end,removeFocusedObject=function(self)if en~=nil then en:loseFocusHandler()end;en=nil;return self end,getFocusedObject=function(self)return en end,show=function(self)b1:show()if self.parent==nil then b=self end;return self end,setCursor=function(self,ew,ex,ey,aD)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())cD=ew or false;if ex~=nil then cz=b5+ex-1 end;if ey~=nil then cA=b6+ey-1 end;eo=aD or eo;self:setVisualChanged()return self end,setMoveable=function(self,ez)self.isMoveable=ez or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,eA)self.barActive=eA or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,G,Q,R)self.barText=G or""self.barBackground=Q or self.barBackground;self.barTextcolor=R or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,be)self.barTextAlign=be or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local eB=b1.getVisualChanged(self)for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.getVisualChanged~=nil and a3:getVisualChanged()then eB=true end end end end;return eB end,loseFocusHandler=function(self)b1.loseFocusHandler(self)end,getFocusHandler=function(self)b1.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,_,aN)if en~=nil then if en.keyHandler~=nil then if en:keyHandler(_,aN)then return true end end end;return false end,backgroundKeyHandler=function(self,_,aN)b1.backgroundKeyHandler(self,_,aN)for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.backgroundKeyHandler~=nil then a3:backgroundKeyHandler(_,aN)end end end end end,eventHandler=function(self,_,aO,aP,aQ,aR)b1.eventHandler(self,_,aO,aP,aQ,aR)for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.eventHandler~=nil then a3:eventHandler(_,aO,aP,aQ,aR)end end end end;if _=="terminate"then e.clear()e.setCursorPos(1,1)a.stop()end end,mouseClickHandler=function(self,_,aK,E,F)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 _=="mouse_drag"then local eC=1;local eD=1;if self.parent~=nil then eC,eD=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(E+self.xToRem-(eC-1)+aH,F-(eD-1)+aI)end;if _=="mouse_up"then self.drag=false end;return true end;if b1.mouseClickHandler(self,_,aK,E,F)then local aE,aF=self:getAbsolutePosition(self:getAnchorPosition())for a2,Z in pairs(em)do if el[Z]~=nil then for a2,a3 in ai(el[Z])do if a3.mouseClickHandler~=nil then if a3:mouseClickHandler(_,aK,E+aH,F+aI)then return true end end end end end;if self.isMoveable then if E>=aE and E<=aE+self.width-1 and F==aF and _=="mouse_click"then self.drag=true;self.xToRem=aE-E end end;if en~=nil then en:loseFocusHandler()en=nil end;return true end;return false end,setText=function(self,E,F,G)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:setText(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(G,math.max(1-E+1,1),self.width-E+1))else P.setText(math.max(E+b5-1,b5),b6+F-1,f(G,math.max(1-E+1,1),self.width-E+1))end end end,setBG=function(self,E,F,Q)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:setBG(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(Q,math.max(1-E+1,1),self.width-E+1))else P.setBG(math.max(E+b5-1,b5),b6+F-1,f(Q,math.max(1-E+1,1),self.width-E+1))end end end,setFG=function(self,E,F,R)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:setFG(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(R,math.max(1-E+1,1),self.width-E+1))else P.setFG(math.max(E+b5-1,b5),b6+F-1,f(R,math.max(1-E+1,1),self.width-E+1))end end end,writeText=function(self,E,F,G,Q,R)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())if F>=1 and F<=self.height then if self.parent~=nil then self.parent:writeText(math.max(E+b5-1,b5)-(self.parent.x-1),b6+F-1-(self.parent.y-1),f(G,math.max(1-E+1,1),self.width-E+1),Q,R)else P.writeText(math.max(E+b5-1,b5),b6+F-1,f(G,math.max(1-E+1,1),self.width-E+1),Q,R)end end end,drawBackgroundBox=function(self,E,F,k,l,Q)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())l=F<1 and(l+F>self.height and self.height or l+F-1)or(l+F>self.height and self.height-F+1 or l)k=E<1 and(k+E>self.width and self.width or k+E-1)or(k+E>self.width and self.width-E+1 or k)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(E+b5-1,b5)-(self.parent.x-1),math.max(F+b6-1,b6)-(self.parent.y-1),k,l,Q)else P.drawBackgroundBox(math.max(E+b5-1,b5),math.max(F+b6-1,b6),k,l,Q)end end,drawTextBox=function(self,E,F,k,l,S)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())l=F<1 and(l+F>self.height and self.height or l+F-1)or(l+F>self.height and self.height-F+1 or l)k=E<1 and(k+E>self.width and self.width or k+E-1)or(k+E>self.width and self.width-E+1 or k)if self.parent~=nil then self.parent:drawTextBox(math.max(E+b5-1,b5)-(self.parent.x-1),math.max(F+b6-1,b6)-(self.parent.y-1),k,l,S:sub(1,1))else P.drawTextBox(math.max(E+b5-1,b5),math.max(F+b6-1,b6),k,l,S:sub(1,1))end end,drawForegroundBox=function(self,E,F,k,l,R)local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())l=F<1 and(l+F>self.height and self.height or l+F-1)or(l+F>self.height and self.height-F+1 or l)k=E<1 and(k+E>self.width and self.width or k+E-1)or(k+E>self.width and self.width-E+1 or k)if self.parent~=nil then self.parent:drawForegroundBox(math.max(E+b5-1,b5)-(self.parent.x-1),math.max(F+b6-1,b6)-(self.parent.y-1),k,l,R)else P.drawForegroundBox(math.max(E+b5-1,b5),math.max(F+b6-1,b6),k,l,R)end end,draw=function(self)if self:getVisualChanged()then if b1.draw(self)then local b5,b6=self:getAbsolutePosition(self:getAnchorPosition())local e8,e9=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(e8,e9,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(e8,e9,self.width,self.height,self.fgColor)self.parent:drawTextBox(e8,e9,self.width,self.height," ")else P.drawBackgroundBox(b5,b6,self.width,self.height,self.bgColor)P.drawForegroundBox(b5,b6,self.width,self.height,self.fgColor)P.drawTextBox(b5,b6,self.width,self.height," ")end;e.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(e8,e9,ad(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)else P.writeText(b5,b6,ad(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for a2,Z in ai(em)do if el[Z]~=nil then for a2,a3 in pairs(el[Z])do if a3.draw~=nil then a3:draw()end end end end;if cD then e.setTextColor(eo)e.setCursorPos(cz,cA)if self.parent~=nil then e.setCursorBlink(self:isFocused())else e.setCursorBlink(cD)end end;self:setVisualChanged(false)end end end,addObject=function(self,eu)return et(eu)end,removeObject=function(self,eu)return ev(eu)end,getObject=function(self,eu)return es(eu)end,addButton=function(self,am)local eu=b0(am)eu.name=am;return et(eu)end,addLabel=function(self,am)local eu=ck(am)eu.name=am;eu.bgColor=self.bgColor;eu.fgColor=self.fgColor;return et(eu)end,addCheckbox=function(self,am)local eu=b8(am)eu.name=am;return et(eu)end,addInput=function(self,am)local eu=c1(am)eu.name=am;return et(eu)end,addProgram=function(self,am)local eu=cx(am)eu.name=am;return et(eu)end,addTextfield=function(self,am)local eu=e1(am)eu.name=am;return et(eu)end,addList=function(self,am)local eu=co(am)eu.name=am;return et(eu)end,addDropdown=function(self,am)local eu=b9(am)eu.name=am;return et(eu)end,addRadio=function(self,am)local eu=dI(am)eu.name=am;return et(eu)end,addTimer=function(self,am)local eu=ed(am)eu.name=am;return et(eu)end,addAnimation=function(self,am)local eu=aS(am)eu.name=am;return et(eu)end,addSlider=function(self,am)local eu=d_(am)eu.name=am;return et(eu)end,addScrollbar=function(self,am)local eu=dN(am)eu.name=am;return et(eu)end,addMenubar=function(self,am)local eu=cr(am)eu.name=am;return et(eu)end,addThread=function(self,am)local eu=ea(am)eu.name=am;return et(eu)end,addPane=function(self,am)local eu=cw(am)eu.name=am;return et(eu)end,addImage=function(self,am)local eu=bo(am)eu.name=am;return et(eu)end,addProgressbar=function(self,am)local eu=dy(am)eu.name=am;return et(eu)end,addFrame=function(self,am)local eu=ej(am,self)eu.name=am;return et(eu)end}setmetatable(av,b1)if ek==nil then table.insert(c,av)end;return av end;local eE=false;local function eF(_,aO,aP,aQ,aR)if _=="mouse_click"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="mouse_drag"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="mouse_up"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="mouse_scroll"then b:mouseClickHandler(_,aO,aP,aQ,aR)end;if _=="key"or _=="char"then b:keyHandler(_,aO)b:backgroundKeyHandler(_,aO)end;for a2,a3 in pairs(c)do a3:eventHandler(_,aO,aP,aQ,aR)end;if eE then b:draw()P.update()end end;function a.autoUpdate(ec)e.clear()eE=ec or true;b:draw()P.update()while eE do local _,aO,aP,aQ,aR=os.pullEventRaw()eF(_,aO,aP,aQ,aR)end end;function a.update(_,aO,aP,aQ,aR)if _~="nil"then eF(_,aO,aP,aQ,aR)else b:draw()P.update()end end;function a.stop()eE=false end;function a.getFrame(am)for a2,a3 in pairs(c)do if a3.name==am then return a3 end end end;function a.getActiveFrame()return b end;function a.setActiveFrame(aw)if aw:getType()=="Frame"then b=aw;return true end;return false end;function a.createFrame(am)local aw=ej(am)return aw end;function a.removeFrame(am)for aN,a3 in pairs(c)do if a3.name==am then c[aN]=nil;return true end end;return false end;if a.debugger then a.debugFrame=a.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)a.debugList=a.debugFrame:addList("debugList"):setSize(a.debugFrame.width-2,a.debugFrame.height-3):setPosition(2,3):setScrollable(true):show()a.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()a.oldFrame:show()end):setBackground(colors.red):show()a.debugLabel=a.debugFrame:addLabel("debugLabel"):onClick(function()a.oldFrame=b;a.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if a.debugger then function a.debug(...)local a9={...}if b.name~="basaltDebuggingFrame"then if b~=a.debugLabel.frame then a.debugLabel:setParent(b)end end;local eG=""for aN,a3 in pairs(a9)do eG=eG..tostring(a3)..(#a9~=aN and", "or"")end;a.debugLabel:setText("[Debug] "..eG)a.debugList:addItem(eG)if a.debugList:getItemCount()>50 then a.debugList:removeItem(1)end;a.debugList:setValue(a.debugList:getItem(a.debugList:getItemCount()))a.debugLabel:show()end end;return a \ No newline at end of file diff --git a/source/project/lib/drawHelper.lua b/source/project/lib/drawHelper.lua index 2e6aec9..6bdc65c 100644 --- a/source/project/lib/drawHelper.lua +++ b/source/project/lib/drawHelper.lua @@ -168,10 +168,9 @@ local function basaltDrawHelper() terminal.setCursorPos(1, n) terminal.blit(cacheT[n], cacheFG[n], cacheBG[n]) end + terminal.setBackgroundColor(colors.black) terminal.setCursorBlink(isBlinking) terminal.setCursorPos(xC, yC) - terminal.setBackgroundColor(colors.black) - terminal.setTextColor(colors.red) end; setTerm = function(newTerm)