From 6a0224b91148874d3220f2329cdc0204b49ded98 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Wed, 11 May 2022 06:31:08 +0200 Subject: [PATCH] changed keys, small bugfix --- basalt.lua | 2 +- source/basalt.lua | 94 +++++++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 44 deletions(-) diff --git a/basalt.lua b/basalt.lua index fdd122b..2404433 100644 --- a/basalt.lua +++ b/basalt.lua @@ -1 +1 @@ -local a={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local b={debugger=true,version=1}local c;local d={}local e={}local f=term.current()local g=string.sub;local function h(i,j,k)local i=string.sub(i,1,j)local l=j-string.len(i)if k=="right"then i=string.rep(" ",l)..i elseif k=="center"then i=string.rep(" ",math.floor(l/2))..i..string.rep(" ",math.floor(l/2))i=i..(string.len(i)=1 and M<=n then if L+i:len()>0 and L<=j then local N=v[M]local O;local P=L+#i-1;if L<1 then local Q=1-L+1;local R=j-L+1;i=g(i,Q,R)elseif P>j then local R=j-L+1;i=g(i,1,R)end;if L>1 then local R=L-1;O=g(N,1,R)..i else O=i end;if P=1 and M<=n then if L+T:len()>0 and L<=j then local N=w[M]local O;local P=L+#T-1;if L<1 then T=g(T,1-L+1,j-L+1)elseif P>j then T=g(T,1,j-L+1)end;if L>1 then O=g(N,1,L-1)..T else O=T end;if P=1 and M<=n then if L+T:len()>0 and L<=j then local N=x[M]local O;local P=L+#T-1;if L<1 then local Q=1-L+1;local R=j-L+1;T=g(T,Q,R)elseif P>j then local R=j-L+1;T=g(T,1,R)end;if L>1 then local R=L-1;O=g(N,1,R)..T else O=T end;if PL and aM<=M and aM+self.h>M and ar then if self.parent~=nil then self.parent:setFocusedObject(self)end;at:sendEvent(a5,self,a5,aK,L,M)return true end;return false end,keyHandler=function(self,a5,aN)if self:isFocused()then at:sendEvent(a5,self,a5,aN)return true end;return false end,backgroundKeyHandler=function(self,a5,aN)at:sendEvent("background_"..a5,self,a5,aN)end,valueChangedHandler=function(self)at:sendEvent("value_changed",self)end,eventHandler=function(self,a5,aO,aP,aQ,aR)at:sendEvent("custom_event_handler",self,a5,aO,aP,aQ,aR)end,getFocusHandler=function(self)at:sendEvent("get_focus",self)end,loseFocusHandler=function(self)at:sendEvent("lose_focus",self)end}au.__index=au;return au end;local function aS(ak)local aT=aj(ak)local al="Button"aT:setValue("Button")aT:setZIndex(5)aT.w=8;aT.bgcolor=a.ButtonBG;aT.fgcolor=a.ButtonFG;local aU="center"local aV="center"local au={getType=function(self)return al end,setHorizontalAlign=function(self,aW)aU=aW end,setVerticalAlign=function(self,aW)aV=aW end,setText=function(self,i)aT:setValue(i)return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition(self.x,self.y)local aZ=m(self.h,aV)self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)self.parent:drawTextBox(aX,aY,self.w,self.h," ")for l=1,self.h do if l==aZ then self.parent:setText(aX,aY+l-1,h(self:getValue(),self.w,aU))end end end end end}return setmetatable(au,aT)end;local function a_(ak)local aT=aj(ak)local al="Program"aT:setZIndex(5)local au;local function b0(L,M,j,n)local b1,b2=1,1;local b3,b4=colors.black,colors.white;local b5=false;local b6=false;local v={}local w={}local x={}local b7={}local B;local C={}for r=0,15 do local b8=2^r;b7[b8]={f.getPaletteColour(b8)}end;local function D()B=(" "):rep(j)for l=0,15 do local E=2^l;local F=s[E]C[E]=F:rep(j)end end;local function G()D()local H=B;local I=C[colors.white]local J=C[colors.black]for l=1,n do v[l]=g(v[l]==nil and H or v[l]..H:sub(1,j-v[l]:len()),1,j)x[l]=g(x[l]==nil and I or x[l]..I:sub(1,j-x[l]:len()),1,j)w[l]=g(w[l]==nil and J or w[l]..J:sub(1,j-w[l]:len()),1,j)end end;G()local function b9()if b1>=1 and b2>=1 and b1<=j and b2<=n then else end end;local function ba(bb,bc,bd)local be=b1;local P=be+#bb-1;if b2>=1 and b2<=n then if be<=j and P>=1 then if be==1 and P==j then v[b2]=bb;x[b2]=bc;w[b2]=bd else local bf,bg,bh;if be<1 then local bi=1-be+1;local bj=j-be+1;bf=g(bb,bi,bj)bg=g(bc,bi,bj)bh=g(bd,bi,bj)elseif P>j then local bj=j-be+1;bf=g(bb,1,bj)bg=g(bc,1,bj)bh=g(bd,1,bj)else bf=bb;bg=bc;bh=bd end;local bk=v[b2]local bl=x[b2]local bm=w[b2]local bn,bo,bp;if be>1 then local bq=be-1;bn=g(bk,1,bq)..bf;bo=g(bl,1,bq)..bg;bp=g(bm,1,bq)..bh else bn=bf;bo=bg;bp=bh end;if P=1 and M<=n then v[bO]=v[M]w[bO]=w[M]x[bO]=x[M]else v[bO]=bL;x[bO]=bM;w[bO]=bN end end end;if b6 then b9()end end,isColor=function()return f.isColor()end,isColour=function()return f.isColor()end,write=function(i)i=tostring(i)if b6 then ba(i,s[b4]:rep(i:len()),s[b3]:rep(i:len()))end end,clearLine=function()if b6 then K(1,b2,(" "):rep(j))S(1,b2,s[b3]:rep(j))U(1,b2,s[b4]:rep(j))end;if b6 then b9()end end,clear=function()for l=1,n do K(1,l,(" "):rep(j))S(1,l,s[b3]:rep(j))U(1,l,s[b4]:rep(j))end;if b6 then b9()end end,blit=function(i,bP,bQ)if type(i)~="string"then error("bad argument #1 (expected string, got "..type(i)..")",2)end;if type(bP)~="string"then error("bad argument #2 (expected string, got "..type(bP)..")",2)end;if type(bQ)~="string"then error("bad argument #3 (expected string, got "..type(bQ)..")",2)end;if#bP~=#i or#bQ~=#i then error("Arguments must be the same length",2)end;if b6 then ba(i,bP,bQ)end end}return bG end;aT.w=30;aT.h=12;local bR=b0(1,1,aT.w,aT.h)local bS;local bT=false;local bU={}au={getType=function(self)return al end,show=function(self)aT.show(self)bR.setBackgroundColor(self.bgcolor)bR.setTextColor(self.fgcolor)bR.basalt_setVisible(true)return self end,hide=function(self)aT.hide(self)bR.basalt_setVisible(false)return self end,setPosition=function(self,L,M,aA)aT.setPosition(self,L,M,aA)bR.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return bR end,getBasaltProcess=function()return bS end,setSize=function(self,j,n)aT.setSize(self,j,n)bR.basalt_resize(self.w,self.h)return self end,getStatus=function(self)if bS~=nil then return bS:getStatus()end;return"inactive"end,execute=function(self,ad,...)bS=ab:new(ad,bR,...)bR.setBackgroundColor(colors.black)bR.setTextColor(colors.white)bR.clear()bR.setCursorPos(1,1)bS:resume()bT=false;return self end,stop=function(self)if bS~=nil then if not bS:isDead()then bS:resume("terminate")if bS:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,bV)bT=bV or not bT;if bS~=nil then if not bS:isDead()then if not bT then self:injectEvents(bU)bU={}end end end;return self end,isPaused=function(self)return bT end,injectEvent=function(self,a5,aO,aP,aQ,aR,bW)if bS~=nil then if not bS:isDead()then if bT==false or bW then bS:resume(a5,aO,aP,aQ,aR)else table.insert(bU,{event=a5,args={aO,aP,aQ,aR}})end end end;return self end,getQueuedEvents=function(self)return bU end,updateQueuedEvents=function(self,a3)bU=a3 or bU;return self end,injectEvents=function(self,a3)if bS~=nil then if not bS:isDead()then for aJ,a9 in pairs(a3)do bS:resume(a9.event,table.unpack(a9.args))end end end;return self end,mouseHandler=function(self,a5,aK,L,M)if aT.mouseHandler(self,a5,aK,L,M)then if bS==nil then return false end;if not bS:isDead()then if not bT then local bX,bY=self:getAbsolutePosition(self:getAnchorPosition())bS:resume(a5,aK,L-bX+1,M-bY+1)end end;return true end end,keyHandler=function(self,a5,aN)aT.keyHandler(self,a5,aN)if self:isFocused()then if bS==nil then return false end;if not bS:isDead()then if not bT then if self.draw then bS:resume(a5,aN)end end end end end,getFocusHandler=function(self)aT.getFocusHandler(self)if bS~=nil then if not bS:isDead()then if not bT then if self.parent~=nil then local bZ,b_=bR.getCursorPos()local aX,aY=self:getAnchorPosition()if self.parent~=nil then if aX+bZ-1>=1 and aX+bZ-1<=aX+self.w-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.h-1 then self.parent:setCursor(bR.getCursorBlink(),aX+bZ-1,b_+aY-1,bR.getTextColor())end end end end end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if bS~=nil then if not bS:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,a5,aO,aP,aQ,aR)if bS==nil then return end;if not bS:isDead()then if not bT then if a5~="mouse_click"and a5~="mouse_up"and a5~="mouse_scroll"and a5~="mouse_drag"and a5~="key_up"and a5~="key"and a5~="char"and a5~="terminate"then bS:resume(a5,aO,aP,aQ,aR)end;if self:isFocused()then local aX,aY=self:getAnchorPosition()local bZ,b_=bR.getCursorPos()if self.parent~=nil then if aX+bZ-1>=1 and aX+bZ-1<=aX+self.w-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.h-1 then self.parent:setCursor(bR.getCursorBlink(),aX+bZ-1,b_+aY-1,bR.getTextColor())end end;if a5=="terminate"and self:isFocused()then self:stop()end end else if a5~="mouse_click"and a5~="mouse_up"and a5~="mouse_scroll"and a5~="mouse_drag"and a5~="key_up"and a5~="key"and a5~="char"and a5~="terminate"then table.insert(bU,{event=a5,args={aO,aP,aQ,aR}})end end end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()bR.basalt_reposition(aX,aY)self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)bR.basalt_update()end end end}return setmetatable(au,aT)end;local function c0(ak)local aT=aj(ak)local al="Label"aT:setZIndex(3)local c1=true;aT:setValue("")local au={getType=function(self)return al end,setText=function(self,i)i=tostring(i)aT:setValue(i)if c1 then self.w=i:len()end;return self end,setSize=function(self,j,n)self.w,self.h=j,n;c1=false;return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:writeText(aX,aY,self:getValue(),self.bgcolor,self.fgcolor)end end end}return setmetatable(au,aT)end;local function c2(ak)local aT=aj(ak)local al="Pane"local au={getType=function(self)return al end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)end end end}return setmetatable(au,aT)end;local function c3(ak)local aT=aj(ak)local al="Image"aT:setZIndex(2)local c4;local au={getType=function(self)return al end,loadImage=function(self,ad)c4=paintutils.loadImage(ad)return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then if c4~=nil then local aX,aY=self:getAnchorPosition()for az=1,math.min(#c4,self.h)do local c5=c4[az]for ay=1,math.min(#c5,self.w)do if c5[ay]>0 then self.parent:drawBackgroundBox(aX+ay-1,aY+az-1,1,1,c5[ay])end end end end end end end}return setmetatable(au,aT)end;local function c6(ak)local aT=aj(ak)local al="Checkbox"aT:setZIndex(5)aT:setValue(false)aT.w=1;aT.h=1;aT.bgcolor=a.CheckboxBG;aT.fgcolor=a.CheckboxFG;local au={symbol="\42",getType=function(self)return al end,mouseHandler=function(self,a5,aK,L,M)if aT.mouseHandler(self,a5,aK,L,M)then if a5=="mouse_click"and aK==1 then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,"center")self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if l==aZ then if self:getValue()==true then self.parent:writeText(aX,aY+l-1,h(self.symbol,self.w,"center"),self.bgcolor,self.fgcolor)else self.parent:writeText(aX,aY+l-1,h(" ",self.w,"center"),self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(au,aT)end;local function c7(ak)local aT=aj(ak)local al="Input"local c8="text"local c9=0;aT:setZIndex(5)aT:setValue("")aT.w=10;aT.h=1;aT.bgcolor=a.InputBG;aT.fgcolor=a.InputFG;local ca=1;local cb=1;local cc=""local cd;local ce;local cf=cc;local cg=false;local au={getType=function(self)return al end,setInputType=function(self,ch)if ch=="password"or ch=="number"or ch=="text"then c8=ch end;return self end,setDefaultText=function(self,i,ci,cj)cc=i;cd=cj or cd;ce=ci or ce;if self:isFocused()then cf=""else cf=cc end;return self end,getInputType=function(self)return c8 end,setValue=function(self,ck)aT.setValue(self,tostring(ck))if not cg then ca=tostring(ck):len()+1 end;return self end,getValue=function(self)local ck=aT.getValue(self)return c8=="number"and tonumber(ck)or ck end,setInputLimit=function(self,cl)c9=tonumber(cl)or c9;return self end,getInputLimit=function(self)return c9 end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then local aX,aY=self:getAnchorPosition()cf=""if self.parent~=nil then self.parent:setCursor(true,aX+ca-cb,aY,self.fgcolor)end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)cf=cc end end,keyHandler=function(self,a5,aN)if aT.keyHandler(self,a5,aN)then cg=true;if a5=="key"then if aN==259 then local i=tostring(aT.getValue())if ca>1 then self:setValue(i:sub(1,ca-2)..i:sub(ca,i:len()))if ca>1 then ca=ca-1 end;if cb>1 then if cacm then ca=cm+1 end;if ca<1 then ca=1 end;if ca=self.w+cb then cb=ca-self.w+1 end;if cb<1 then cb=1 end end;if aN==263 then ca=ca-1;if ca>=1 then if ca=self.w+cb then cb=ca end end;if ca<1 then ca=1 end;if cb<1 then cb=1 end end end;if a5=="char"then local i=aT.getValue()if i:len()=self.w+cb then cb=cb+1 end end end;local aX,aY=self:getAnchorPosition()local ck=tostring(aT.getValue())local co=(ca<=ck:len()and ca-1 or ck:len())-(cb-1)if co>self.x+self.w-1 then co=self.x+self.w-1 end;if self.parent~=nil then self.parent:setCursor(true,aX+co,aY,self.fgcolor)end;cg=false end end,mouseHandler=function(self,a5,aK,L,M)if aT.mouseHandler(self,a5,aK,L,M)then if a5=="mouse_click"and aK==1 then end;return true end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,"center")self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if l==aZ then local ck=tostring(aT.getValue())local cj=self.bgcolor;local ci=self.fgcolor;local i;if ck:len()<=0 then i=cf;cj=cd or cj;ci=ce or ci end;i=cf;if ck~=""then i=ck end;i=i:sub(cb,self.w+cb-1)local cp=self.w-i:len()if cp<0 then cp=0 end;if c8=="password"and ck~=""then i=string.rep("*",i:len())end;i=i..string.rep(" ",cp)self.parent:writeText(aX,aY+l-1,i,cj,ci)end end end end end}return setmetatable(au,aT)end;local function cq(ak)local aT=aj(ak)local al="Textfield"local cr,cb,ca,cs=1,1,1,1;local ct={""}local cu={}local cv=colors.lightBlue;aT.w=20;aT.h=8;aT.bgcolor=a.textfieldBG;aT.fgcolor=a.textfieldFG;aT:setZIndex(5)local au={getType=function(self)return al end,getLines=function(self)return ct end,getLine=function(self,a4)return ct[a4]or""end,editLine=function(self,a4,i)ct[a4]=i or ct[a4]return self end,addLine=function(self,i,a4)if a4~=nil then table.insert(ct,a4,i)else table.insert(ct,i)end;return self end,removeLine=function(self,a4)table.remove(ct,a4 or#ct)if#ct<=0 then table.insert(ct,"")end;return self end,getTextCursor=function(self)return ca,cs end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then local aX,aY=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,aX+ca-cb,aY+cs-cr,self.fgcolor)end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,a5,aN)if aT.keyHandler(self,a5,aN)then local aX,aY=self:getAnchorPosition()if a5=="key"then if aN==259 then if ct[cs]==""then if cs>1 then table.remove(ct,cs)ca=ct[cs-1]:len()+1;cb=ca-self.w+1;if cb<1 then cb=1 end;cs=cs-1 end elseif ca<=1 then if cs>1 then ca=ct[cs-1]:len()+1;cb=ca-self.w+1;if cb<1 then cb=1 end;ct[cs-1]=ct[cs-1]..ct[cs]table.remove(ct,cs)cs=cs-1 end else ct[cs]=ct[cs]:sub(1,ca-2)..ct[cs]:sub(ca,ct[cs]:len())if ca>1 then ca=ca-1 end;if cb>1 then if ca=self.h then cr=cr+1 end;self:setValue("")end;if aN==265 then if cs>1 then cs=cs-1;if ca>ct[cs]:len()+1 then ca=ct[cs]:len()+1 end;if cb>1 then if ca1 then if csct[cs]:len()+1 then ca=ct[cs]:len()+1 end;if cs>=cr+self.h then cr=cr+1 end end end;if aN==262 then ca=ca+1;if cs<#ct then if ca>ct[cs]:len()+1 then ca=1;cs=cs+1 end elseif ca>ct[cs]:len()then ca=ct[cs]:len()+1 end;if ca<1 then ca=1 end;if ca=self.w+cb then cb=ca-self.w+1 end;if cb<1 then cb=1 end end;if aN==263 then ca=ca-1;if ca>=1 then if ca=self.w+cb then cb=ca end end;if cs>1 then if ca<1 then cs=cs-1;ca=ct[cs]:len()+1;cb=ca-self.w+1 end end;if ca<1 then ca=1 end;if cb<1 then cb=1 end end end;if a5=="char"then ct[cs]=ct[cs]:sub(1,ca-1)..aN..ct[cs]:sub(ca,ct[cs]:len())ca=ca+1;if ca>=self.w+cb then cb=cb+1 end;self:setValue("")end;local co=(ca<=ct[cs]:len()and ca-1 or ct[cs]:len())-(cb-1)if co>self.x+self.w-1 then co=self.x+self.w-1 end;local cw=cs-crct[cs]:len()then ca=ct[cs]:len()+1 end;if ca#ct-(self.h-1)then cr=#ct-(self.h-1)end;if cr<1 then cr=1 end;if self.parent~=nil then if aX+ca-cb>=aX and aX+ca-cb<=aX+self.w and(aY+cs-cr>=aY and aY+cs-cr<=aY+self.h)then self.parent:setCursor(true,cx+ca-cb,cy+cs-cr)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)for l=1,self.h do local i=""if ct[l+cr-1]~=nil then i=ct[l+cr-1]end;i=i:sub(cb,self.w+cb-1)local cp=self.w-i:len()if cp<0 then cp=0 end;i=i..string.rep(" ",cp)self.parent:setText(aX,aY+l-1,i)end end end end}return setmetatable(au,aT)end;local function cz(ak)local aT=aj(ak)local al="List"aT.w=16;aT.h=6;aT.bgcolor=a.listBG;aT.fgcolor=a.listFG;aT:setZIndex(5)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cD=true;local cE="left"local cF=0;local cG=true;local au={getType=function(self)return al end,addItem=function(self,i,W,X,...)table.insert(cA,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#cA==1 then self:setValue(cA[1])end;return self end,setIndexOffset=function(self,cH)cF=cH;return self end,getIndexOffset=function(self)return cF end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cJ)cB=W or self.bgcolor;cC=X or self.fgcolor;cD=cJ;return self end,setScrollable=function(self,cK)cG=cK;return self end,mouseHandler=function(self,a5,aK,L,M)if aT.mouseHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"or a5=="mouse_drag"then if aK==1 then if#cA>0 then for l=1,self.h do if cA[l+cF]~=nil then if aX<=L and aX+self.w>L and aY+l-1==M then self:setValue(cA[l+cF])end end end end end end;if a5=="mouse_scroll"and cG then cF=cF+aK;if cF<0 then cF=0 end;if aK>=1 then if#cA>self.h then if cF>#cA-self.h then cF=#cA-self.h end;if cF>=#cA then cF=#cA-1 end else cF=cF-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if cA[l+cF]~=nil then if cA[l+cF]==self:getValue()then if cD then self.parent:writeText(aX,aY+l-1,h(cA[l+cF].text,self.w,cE),cB,cC)else self.parent:writeText(aX,aY+l-1,h(cA[l+cF].text,self.w,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end else self.parent:writeText(aX,aY+l-1,h(cA[l+cF].text,self.w,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end end end end end end}return setmetatable(au,aT)end;local function cL(ak)local aT=aj(ak)local al="Menubar"aT.w=30;aT.h=1;aT.bgcolor=colors.gray;aT.fgcolor=colors.lightGray;aT:setZIndex(5)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cD=true;local cE="left"local cM=0;local cp=2;local cG=false;local function cN()local cO=0;local ay=1;for l=1,#cA do if ay+cA[l].text:len()+cp*2>aT.w then cO=cO+1 end;ay=ay+cA[l].text:len()+cp*2 end;return cO end;local au={getType=function(self)return al end,addItem=function(self,i,W,X,...)table.insert(cA,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#cA==1 then self:setValue(cA[1])end;return self end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,setSpace=function(self,cP)cp=cP or cp;return self end,setButtonOffset=function(self,o)cM=o or 0;if cM<0 then cM=0 end;local cO=cN()if cM>cO then cM=cO end;return self end,setScrollable=function(self,cK)cG=cK;return self end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cJ)cB=W or self.bgcolor;cC=X or self.fgcolor;cD=cJ;return self end,mouseHandler=function(self,a5,aK,L,M)if aT.mouseHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"then local ay=1;for l=1+cM,#cA do if cA[l]~=nil then if ay+cA[l].text:len()+cp*2<=self.w then if aX+ay-1<=L and aX+ay-1+cA[l].text:len()+cp*2>L and aY==M then self:setValue(cA[l])end;ay=ay+cA[l].text:len()+cp*2 else break end end end end;if a5=="mouse_scroll"and cG then cM=cM+aK;if cM<0 then cM=0 end;local cO=cN()if cM>cO then cM=cO end end end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)local ay=1;for l=1+cM,#cA do if cA[l]~=nil then if ay+cA[l].text:len()+cp*2<=self.w then if cA[l]==self:getValue()then self.parent:writeText(aX+ay-1,aY,h((" "):rep(cp)..cA[l].text..(" "):rep(cp),cA[l].text:len()+cp*2,cE),cB or cA[l].bgCol,cC or cA[l].fgCol)else self.parent:writeText(aX+ay-1,aY,h((" "):rep(cp)..cA[l].text..(" "):rep(cp),cA[l].text:len()+cp*2,cE),cA[l].bgCol,cA[l].fgCol)end;ay=ay+cA[l].text:len()+cp*2 else break end end end end end end}return setmetatable(au,aT)end;local function cQ(ak)local aT=aj(ak)local al="Dropdown"aT.w=12;aT.h=1;aT.bgcolor=a.dropdownBG;aT.fgcolor=a.dropdownFG;aT:setZIndex(6)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cD=true;local cE="left"local cF=0;local cR=16;local cS=6;local cT="\16"local cU="\31"local cV=1;local au={getType=function(self)return al end,setIndexOffset=function(self,cH)cF=cH;return self end,getIndexOffset=function(self)return cF end,addItem=function(self,i,W,X,...)table.insert(cA,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#cA==1 then self:setValue(cA[1])end;return self end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cJ)cB=W or self.bgcolor;cC=X or self.fgcolor;cD=cJ;return self end,setDropdownSize=function(self,j,n)cR,cS=j,n;return self end,mouseHandler=function(self,a5,aK,L,M)if cV==2 then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"then if aK==1 then if#cA>0 then for l=1,cS do if cA[l+cF]~=nil then if aX<=L and aX+cR>L and aY+l==M then self:setValue(cA[l+cF])return true end end end end end end;if a5=="mouse_scroll"then cF=cF+aK;if cF<0 then cF=0 end;if aK==1 then if#cA>cS then if cF>#cA-cS then cF=#cA-cS end else cF=cA-1 end end;return true end;self:setVisualChanged()end;if aT.mouseHandler(self,a5,aK,L,M)then cV=2 else cV=1 end end,draw=function(self)if aT.draw(self)then local aX,aY=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)if#cA>=1 then if self:getValue().text~=nil then if cV==1 then self.parent:writeText(aX,aY,h(self:getValue().text,self.w,cE):sub(1,self.w-1)..cT,self.bgcolor,self.fgcolor)else self.parent:writeText(aX,aY,h(self:getValue().text,self.w,cE):sub(1,self.w-1)..cU,self.bgcolor,self.fgcolor)end end;if cV==2 then for l=1,cS do if cA[l+cF]~=nil then if cA[l+cF]==self:getValue()then if cD then self.parent:writeText(aX,aY+l,h(cA[l+cF].text,cR,cE),cB,cC)else self.parent:writeText(aX,aY+l,h(cA[l+cF].text,cR,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end else self.parent:writeText(aX,aY+l,h(cA[l+cF].text,cR,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end end end end end end end end}return setmetatable(au,aT)end;local function cW(ak)local aT=aj(ak)local al="Radio"aT.w=8;aT.bgcolor=a.listBG;aT.fgcolor=a.listFG;aT:setZIndex(5)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cX=aT.bgcolor;local cY=aT.fgcolor;local cD=true;local Y="\7"local cE="left"local au={getType=function(self)return al end,addItem=function(self,i,L,M,W,X,...)table.insert(cA,{x=L or 1,y=M or 1,text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#cA==1 then self:setValue(cA[1])end;return self end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,L,M,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{x=L or 1,y=M or 1,text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cZ,c_,cJ)cB=W or cB;cC=X or cC;cX=cZ or cX;cY=c_ or cY;cD=cJ;return self end,mouseHandler=function(self,a5,aK,L,M)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"then if aK==1 then if#cA>0 then for aJ,a9 in pairs(cA)do if aX+a9.x-1<=L and aX+a9.x-1+a9.text:len()+2>=L and aY+a9.y-1==M then self:setValue(a9)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()for aJ,a9 in pairs(cA)do if a9==self:getValue()then if cE=="left"then self.parent:writeText(a9.x+aX-1,a9.y+aY-1,Y,cX,cY)self.parent:writeText(a9.x+2+aX-1,a9.y+aY-1,a9.text,cB,cC)end else self.parent:drawBackgroundBox(a9.x+aX-1,a9.y+aY-1,1,1,self.bgcolor)self.parent:writeText(a9.x+2+aX-1,a9.y+aY-1,a9.text,a9.bgCol,a9.fgCol)end end end end end}return setmetatable(au,aT)end;local function d0(ak)local al="Timer"local d1=0;local d2=0;local d3=0;local d4;local at=a2()local au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,d5,d6)d1=d5 or 0;d2=d6 or 1;return self end,start=function(self)d3=d2;d4=os.startTimer(d1)return self end,cancel=function(self)if d4~=nil then os.cancelTimer(d4)end;return self end,onCall=function(self,a7)at:registerEvent("timed_event",a7)return self end,eventHandler=function(self,a5,d7)if a5=="timer"and d7==d4 then at:sendEvent("timed_event",self)if d3>=1 then d3=d3-1;if d3>=1 then d4=os.startTimer(d1)end elseif d3==-1 then d4=os.startTimer(d1)end end end}au.__index=au;return au end;local function d8(ak)local au;local al="Thread"local a7;local d9;local da=false;au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,db)if db==nil then error("function is nil")end;a7=db;d9=coroutine.create(a7)da=true;local ah,ai=coroutine.resume(d9)if not ah then if ai~="Terminated"then error("Threaderror - "..ai)end end;return self end,getStatus=function(self,db)if d9~=nil then return coroutine.status(d9)end;return nil end,stop=function(self,db)da=false;return self end,eventHandler=function(self,a5,aO,aP,aQ)if da then if coroutine.status(d9)~="dead"then local ah,ai=coroutine.resume(d9,a5,aO,aP,aQ)if not ah then if ai~="Terminated"then error("Threaderror - "..ai)end end else da=false end end end}au.__index=au;return au end;local function dc(ak)local au={}local al="Animation"local d4;local dd={}local a4=1;local de=0;local df;local function dg()if dd[a4]~=nil then dd[a4].f(au,a4)end;a4=a4+1;if dd[a4]~=nil then if dd[a4].t>0 then d4=os.startTimer(dd[a4].t)else dg()end end end;au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,a7,dh)df=a7;table.insert(dd,{f=a7,t=dh or de})return self end,wait=function(self,dh)de=dh;return self end,rep=function(self,di)for L=1,di do table.insert(dd,{f=df,t=de})end;return self end,clear=function(self)dd={}df=nil;de=0;a4=1;return self end,play=function(self)a4=1;if dd[a4]~=nil then if dd[a4].t>0 then d4=os.startTimer(dd[a4].t)else dg()end end;return self end,cancel=function(self)os.cancelTimer(d4)return self end,eventHandler=function(self,a5,d7)if a5=="timer"and d7==d4 then if dd[a4]~=nil then dg()end end end}au.__index=au;return au end;local function dj(ak)local aT=aj(ak)local al="Slider"aT.w=8;aT.bgcolor=colors.lightGray;aT.fgcolor=colors.gray;aT:setValue(1)local dk="horizontal"local Y=" "local dl=colors.black;local dm="\140"local dn=aT.w;local a4=1;local au={getType=function(self)return al end,setSymbol=function(self,dp)Y=dp:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,dq)dm=string.sub(dq,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dr)dl=dr;self:setVisualChanged()return self end,setBarType=function(self,ds)dk=ds:lower()return self end,mouseHandler=function(self,a5,aK,L,M)if aT.mouseHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if dk=="horizontal"then for dt=0,self.w-1 do if aX+dt==L and aY<=M and aY+self.h>M then a4=dt+1;self:setValue(dn/self.w*a4)self:setVisualChanged()end end end;if dk=="vertical"then for dt=0,self.h-1 do if aY+dt==M and aX<=L and aX+self.w>L then a4=dt+1;self:setValue(dn/self.h*a4)self:setVisualChanged()end end end end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()if dk=="horizontal"then self.parent:writeText(aX,aY,dm:rep(a4-1),self.bgcolor,self.fgcolor)self.parent:writeText(aX+a4-1,aY,Y,dl,dl)self.parent:writeText(aX+a4,aY,dm:rep(self.w-a4),self.bgcolor,self.fgcolor)end;if dk=="vertical"then for l=0,self.h-1 do if l+1==a4 then self.parent:writeText(aX,aY+l,Y,dl,dl)else self.parent:writeText(aX,aY+l,dm,self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(au,aT)end;local function du(ak)local aT=aj(ak)local al="Scrollbar"aT.w=1;aT.h=8;aT.bgcolor=colors.lightGray;aT.fgcolor=colors.gray;aT:setValue(1)aT:setZIndex(2)local dk="vertical"local Y=" "local dl=colors.black;local dm="\127"local dn=aT.h;local a4=1;local dv=1;local au={getType=function(self)return al end,setSymbol=function(self,dp)Y=dp:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,dw)dv=tonumber(dw)or 1;if dk=="vertical"then self:setValue(a4-1*dn/(self.h-(dv-1))-dn/(self.h-(dv-1)))elseif dk=="horizontal"then self:setValue(a4-1*dn/(self.w-(dv-1))-dn/(self.w-(dv-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,ck)dn=ck;return self end,setBackgroundSymbol=function(self,dq)dm=string.sub(dq,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dr)dl=dr;self:setVisualChanged()return self end,setBarType=function(self,ds)dk=ds:lower()return self end,mouseHandler=function(self,a5,aK,L,M)if aT.mouseHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if(a5=="mouse_click"or a5=="mouse_drag")and aK==1 then if dk=="horizontal"then for dt=0,self.w do if aX+dt==L and aY<=M and aY+self.h>M then a4=math.min(dt+1,self.w-(dv-1))self:setValue(dn/self.w*a4)self:setVisualChanged()end end end;if dk=="vertical"then for dt=0,self.h do if aY+dt==M and aX<=L and aX+self.w>L then a4=math.min(dt+1,self.h-(dv-1))self:setValue(dn/self.h*a4)self:setVisualChanged()end end end end;if a5=="mouse_scroll"then a4=a4+aK;if a4<1 then a4=1 end;a4=math.min(a4,(dk=="vertical"and self.h or self.w)-(dv-1))self:setValue(dn/(dk=="vertical"and self.h or self.w)*a4)end;return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()if dk=="horizontal"then self.parent:writeText(aX,aY,dm:rep(a4-1),self.bgcolor,self.fgcolor)self.parent:writeText(aX+a4-1,aY,Y:rep(dv),dl,dl)self.parent:writeText(aX+a4+dv-1,aY,dm:rep(self.w-(a4+dv-1)),self.bgcolor,self.fgcolor)end;if dk=="vertical"then for l=0,self.h-1 do if a4==l+1 then for dx=0,math.min(dv-1,self.h)do self.parent:writeText(aX,aY+l+dx,Y,dl,dl)end else if l+1a4-1+dv then self.parent:writeText(aX,aY+l,dm,self.bgcolor,self.fgcolor)end end end end end end end}return setmetatable(au,aT)end;local function dy(ak,dz)local aT=aj(ak)local al="Frame"local dA={}local dB={}local au={}local dC;aT:setZIndex(10)local b5=false;local b1=1;local b2=1;local dD=colors.white;local dE,cF=0,0;if dz~=nil then aT.parent=dz;aT.w,aT.h=dz.w,dz.h;aT.bgcolor=a.FrameBG;aT.fgcolor=a.FrameFG else local dF,dG=f.getSize()aT.w,aT.h=dF,dG;aT.bgcolor=a.basaltBG;aT.fgcolor=a.basaltFG end;local function dH(ak)for a8,a9 in pairs(dA)do for dI,bD in pairs(a9)do if bD.name==ak then return a9 end end end end;local function dJ(dK)local an=dK:getZIndex()if dH(dK.name)~=nil then return nil end;if dA[an]==nil then for L=1,#dB+1 do if dB[L]~=nil then if an==dB[L]then break end;if an>dB[L]then table.insert(dB,L,an)break end else table.insert(dB,an)end end;if#dB<=0 then table.insert(dB,an)end;dA[an]={}end;dK.parent=au;table.insert(dA[an],dK)return dK end;local function dL(dK)for dI,bD in pairs(dA)do for a8,a9 in pairs(bD)do if a9==dK then table.remove(dA[dI],a8)return end end end end;au={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return al end,setFocusedObject=function(self,dK)for aJ,a4 in pairs(dB)do for aJ,a9 in pairs(dA[a4])do if a9==dK then if dC~=nil then dC:loseFocusHandler()end;dC=dK;dC:getFocusHandler()end end end;return self end,setOffset=function(self,aG,aH)dE=aG~=nil and math.floor(aG<0 and math.abs(aG)or-aG)or dE;cF=aH~=nil and math.floor(aH<0 and math.abs(aH)or-aH)or cF;return self end,getFrameOffset=function(self)return dE,cF end,removeFocusedObject=function(self)if dC~=nil then dC:loseFocusHandler()end;dC=nil;return self end,getFocusedObject=function(self)return dC end,show=function(self)aT:show()if self.parent==nil then c=self end;return self end,setCursor=function(self,dM,dN,dO,aC)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())b5=dM or false;if dN~=nil then b1=aX+dN-1 end;if dO~=nil then b2=aY+dO-1 end;dD=aC or dD;self:setVisualChanged()return self end,setMoveable=function(self,dP)self.isMoveable=dP or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,dQ)self.barActive=dQ or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,i,W,X)self.barText=i or""self.barBackground=W or self.barBackground;self.barTextcolor=X or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,cE)self.barTextAlign=cE or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local dR=aT.getVisualChanged(self)for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.getVisualChanged~=nil and a9:getVisualChanged()then dR=true end end end end;return dR end,loseFocusHandler=function(self)aT.loseFocusHandler(self)end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,a5,aN)if dC~=nil then if dC.keyHandler~=nil then if dC:keyHandler(a5,aN)then return true end end end;return false end,backgroundKeyHandler=function(self,a5,aN)aT.backgroundKeyHandler(self,a5,aN)for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.backgroundKeyHandler~=nil then a9:backgroundKeyHandler(a5,aN)end end end end end,eventHandler=function(self,a5,aO,aP,aQ,aR)aT.eventHandler(self,a5,aO,aP,aQ,aR)for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.eventHandler~=nil then a9:eventHandler(a5,aO,aP,aQ,aR)end end end end;if a5=="terminate"then f.clear()f.setCursorPos(1,1)b.stop()end end,mouseHandler=function(self,a5,aK,L,M)local aG,aH=self:getOffset()aG=aG<0 and math.abs(aG)or-aG;aH=aH<0 and math.abs(aH)or-aH;if self.drag then if a5=="mouse_drag"then local dS=1;local dT=1;if self.parent~=nil then dS,dT=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(L+self.xToRem-(dS-1)+aG,M-(dT-1)+aH)end;if a5=="mouse_up"then self.drag=false end;return true end;if aT.mouseHandler(self,a5,aK,L,M)then local aD,aE=self:getAbsolutePosition(self:getAnchorPosition())for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in p(dA[a4])do if a9.mouseHandler~=nil then if a9:mouseHandler(a5,aK,L+aG,M+aH)then return true end end end end end;if self.isMoveable then if L>=aD and L<=aD+self.w-1 and M==aE and a5=="mouse_click"then self.drag=true;self.xToRem=aD-L end end;if dC~=nil then dC:loseFocusHandler()dC=nil end;return true end;return false end,setText=function(self,L,M,i)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setText(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(i,math.max(1-L+1,1),self.w-L+1))else V.setText(math.max(L+aX-1,aX),aY+M-1,g(i,math.max(1-L+1,1),self.w-L+1))end end end,setBG=function(self,L,M,W)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setBG(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(W,math.max(1-L+1,1),self.w-L+1))else V.setBG(math.max(L+aX-1,aX),aY+M-1,g(W,math.max(1-L+1,1),self.w-L+1))end end end,setFG=function(self,L,M,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setFG(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(X,math.max(1-L+1,1),self.w-L+1))else V.setFG(math.max(L+aX-1,aX),aY+M-1,g(X,math.max(1-L+1,1),self.w-L+1))end end end,writeText=function(self,L,M,i,W,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:writeText(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(i,math.max(1-L+1,1),self.w-L+1),W,X)else V.writeText(math.max(L+aX-1,aX),aY+M-1,g(i,math.max(1-L+1,1),self.w-L+1),W,X)end end end,drawBackgroundBox=function(self,L,M,j,n,W)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,W)else V.drawBackgroundBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,W)end end,drawTextBox=function(self,L,M,j,n,Y)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawTextBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,Y:sub(1,1))else V.drawTextBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,Y:sub(1,1))end end,drawForegroundBox=function(self,L,M,j,n,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawForegroundBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,X)else V.drawForegroundBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,X)end end,draw=function(self)if self:getVisualChanged()then if aT.draw(self)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())local cx,cy=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(cx,cy,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(cx,cy,self.w,self.h,self.fgcolor)self.parent:drawTextBox(cx,cy,self.w,self.h," ")else V.drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)V.drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)V.drawTextBox(aX,aY,self.w,self.h," ")end;f.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(cx,cy,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)else V.writeText(aX,aY,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aJ,a4 in p(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.draw~=nil then a9:draw()end end end end;if b5 then f.setTextColor(dD)f.setCursorPos(b1,b2)if self.parent~=nil then f.setCursorBlink(self:isFocused())else f.setCursorBlink(b5)end end;self:setVisualChanged(false)end end end,addObject=function(self,dK)return dJ(dK)end,removeObject=function(self,dK)return dL(dK)end,addButton=function(self,ak)local dK=aS(ak)dK.name=ak;return dJ(dK)end,addLabel=function(self,ak)local dK=c0(ak)dK.name=ak;dK.bgcolor=self.bgcolor;dK.fgcolor=self.fgcolor;return dJ(dK)end,addCheckbox=function(self,ak)local dK=c6(ak)dK.name=ak;return dJ(dK)end,addInput=function(self,ak)local dK=c7(ak)dK.name=ak;return dJ(dK)end,addProgram=function(self,ak)local dK=a_(ak)dK.name=ak;return dJ(dK)end,addTextfield=function(self,ak)local dK=cq(ak)dK.name=ak;return dJ(dK)end,addList=function(self,ak)local dK=cz(ak)dK.name=ak;return dJ(dK)end,addDropdown=function(self,ak)local dK=cQ(ak)dK.name=ak;return dJ(dK)end,addRadio=function(self,ak)local dK=cW(ak)dK.name=ak;return dJ(dK)end,addTimer=function(self,ak)local dK=d0(ak)dK.name=ak;return dJ(dK)end,addAnimation=function(self,ak)local dK=dc(ak)dK.name=ak;return dJ(dK)end,addSlider=function(self,ak)local dK=dj(ak)dK.name=ak;return dJ(dK)end,addScrollbar=function(self,ak)local dK=du(ak)dK.name=ak;return dJ(dK)end,addMenubar=function(self,ak)local dK=cL(ak)dK.name=ak;return dJ(dK)end,addThread=function(self,ak)local dK=d8(ak)dK.name=ak;return dJ(dK)end,addPane=function(self,ak)local dK=c2(ak)dK.name=ak;return dJ(dK)end,addImage=function(self,ak)local dK=c3(ak)dK.name=ak;return dJ(dK)end,addFrame=function(self,ak)local dK=dy(ak,self)dK.name=ak;return dJ(dK)end}setmetatable(au,aT)if dz==nil then table.insert(d,au)end;return au end;local dU=false;local function dV(a5,aO,aP,aQ,aR)if a5=="mouse_click"then c:mouseHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_drag"then c:mouseHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_up"then c:mouseHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_scroll"then c:mouseHandler(a5,aO,aP,aQ,aR)end;if a5=="key"or a5=="char"then c:keyHandler(a5,aO)c:backgroundKeyHandler(a5,aO)end;for aJ,a9 in pairs(d)do a9:eventHandler(a5,aO,aP,aQ,aR)end;if dU then c:draw()V.update()end end;function b.autoUpdate(da)f.clear()dU=da or true;c:draw()V.update()while dU do local a5,aO,aP,aQ,aR=os.pullEventRaw()dV(a5,aO,aP,aQ,aR)end end;function b.update(a5,aO,aP,aQ,aR)if a5~="nil"then dV(a5,aO,aP,aQ,aR)else c:draw()V.update()end end;function b.stop()dU=false end;function b.getFrame(ak)for a8,a9 in pairs(d)do if a9.name==ak then return a9 end end end;function b.getActiveFrame()return c end;function b.setActiveFrame(av)if av:getType()=="Frame"then c=av;return true end;return false end;function b.createFrame(ak)local av=dy(ak)return av end;function b.removeFrame(ak)for a8,a9 in pairs(d)do if a9.name==ak then d[a8]=nil;return true end end;return false end;if b.debugger then b.debugFrame=b.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)b.debugList=b.debugFrame:addList("debugList"):setSize(b.debugFrame.w-2,b.debugFrame.h-3):setPosition(2,3):show()b.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()b.oldFrame:show()end):setBackground(colors.red):show()b.debugLabel=b.debugFrame:addLabel("debugLabel"):onClick(function()b.oldFrame=c;b.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):show()end;if b.debugger then function b.debug(...)local af={...}if c.name~="basaltDebuggingFrame"then if c~=b.debugLabel.frame then b.debugLabel:setParent(c)end end;local dW=""for a8,a9 in pairs(af)do dW=dW..tostring(a9)..(#af~=a8 and", "or"")end;b.debugLabel:setText("[Debug] "..dW)b.debugList:addItem(dW)if b.debugList:getItemCount()>b.debugList.h then b.debugList:removeItem(1)end;b.debugLabel:show()end end;return b \ No newline at end of file +local a={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local b={debugger=true,version=1}local c;local d={}local e={}local f=term.current()local g=string.sub;local function h(i,j,k)local i=string.sub(i,1,j)local l=j-string.len(i)if k=="right"then i=string.rep(" ",l)..i elseif k=="center"then i=string.rep(" ",math.floor(l/2))..i..string.rep(" ",math.floor(l/2))i=i..(string.len(i)=1 and M<=n then if L+i:len()>0 and L<=j then local N=v[M]local O;local P=L+#i-1;if L<1 then local Q=1-L+1;local R=j-L+1;i=g(i,Q,R)elseif P>j then local R=j-L+1;i=g(i,1,R)end;if L>1 then local R=L-1;O=g(N,1,R)..i else O=i end;if P=1 and M<=n then if L+T:len()>0 and L<=j then local N=w[M]local O;local P=L+#T-1;if L<1 then T=g(T,1-L+1,j-L+1)elseif P>j then T=g(T,1,j-L+1)end;if L>1 then O=g(N,1,L-1)..T else O=T end;if P=1 and M<=n then if L+T:len()>0 and L<=j then local N=x[M]local O;local P=L+#T-1;if L<1 then local Q=1-L+1;local R=j-L+1;T=g(T,Q,R)elseif P>j then local R=j-L+1;T=g(T,1,R)end;if L>1 then local R=L-1;O=g(N,1,R)..T else O=T end;if PL and aM<=M and aM+self.h>M and ar then if self.parent~=nil then self.parent:setFocusedObject(self)end;at:sendEvent(a5,self,a5,aK,L,M)return true end;return false end,keyHandler=function(self,a5,aN)if self:isFocused()then at:sendEvent(a5,self,a5,aN)return true end;return false end,backgroundKeyHandler=function(self,a5,aN)at:sendEvent("background_"..a5,self,a5,aN)end,valueChangedHandler=function(self)at:sendEvent("value_changed",self)end,eventHandler=function(self,a5,aO,aP,aQ,aR)at:sendEvent("custom_event_handler",self,a5,aO,aP,aQ,aR)end,getFocusHandler=function(self)at:sendEvent("get_focus",self)end,loseFocusHandler=function(self)at:sendEvent("lose_focus",self)end}au.__index=au;return au end;local function aS(ak)local aT=aj(ak)local al="Button"aT:setValue("Button")aT:setZIndex(5)aT.w=8;aT.bgcolor=a.ButtonBG;aT.fgcolor=a.ButtonFG;local aU="center"local aV="center"local au={getType=function(self)return al end,setHorizontalAlign=function(self,aW)aU=aW end,setVerticalAlign=function(self,aW)aV=aW end,setText=function(self,i)aT:setValue(i)return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,aV)self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)self.parent:drawTextBox(aX,aY,self.w,self.h," ")for l=1,self.h do if l==aZ then self.parent:setText(aX,aY+l-1,h(self:getValue(),self.w,aU))end end end end end}return setmetatable(au,aT)end;local function a_(ak)local aT=aj(ak)local al="Program"aT:setZIndex(5)local au;local function b0(L,M,j,n)local b1,b2=1,1;local b3,b4=colors.black,colors.white;local b5=false;local b6=false;local v={}local w={}local x={}local b7={}local B;local C={}for r=0,15 do local b8=2^r;b7[b8]={f.getPaletteColour(b8)}end;local function D()B=(" "):rep(j)for l=0,15 do local E=2^l;local F=s[E]C[E]=F:rep(j)end end;local function G()D()local H=B;local I=C[colors.white]local J=C[colors.black]for l=1,n do v[l]=g(v[l]==nil and H or v[l]..H:sub(1,j-v[l]:len()),1,j)x[l]=g(x[l]==nil and I or x[l]..I:sub(1,j-x[l]:len()),1,j)w[l]=g(w[l]==nil and J or w[l]..J:sub(1,j-w[l]:len()),1,j)end end;G()local function b9()if b1>=1 and b2>=1 and b1<=j and b2<=n then else end end;local function ba(bb,bc,bd)local be=b1;local P=be+#bb-1;if b2>=1 and b2<=n then if be<=j and P>=1 then if be==1 and P==j then v[b2]=bb;x[b2]=bc;w[b2]=bd else local bf,bg,bh;if be<1 then local bi=1-be+1;local bj=j-be+1;bf=g(bb,bi,bj)bg=g(bc,bi,bj)bh=g(bd,bi,bj)elseif P>j then local bj=j-be+1;bf=g(bb,1,bj)bg=g(bc,1,bj)bh=g(bd,1,bj)else bf=bb;bg=bc;bh=bd end;local bk=v[b2]local bl=x[b2]local bm=w[b2]local bn,bo,bp;if be>1 then local bq=be-1;bn=g(bk,1,bq)..bf;bo=g(bl,1,bq)..bg;bp=g(bm,1,bq)..bh else bn=bf;bo=bg;bp=bh end;if P=1 and M<=n then v[bO]=v[M]w[bO]=w[M]x[bO]=x[M]else v[bO]=bL;x[bO]=bM;w[bO]=bN end end end;if b6 then b9()end end,isColor=function()return f.isColor()end,isColour=function()return f.isColor()end,write=function(i)i=tostring(i)if b6 then ba(i,s[b4]:rep(i:len()),s[b3]:rep(i:len()))end end,clearLine=function()if b6 then K(1,b2,(" "):rep(j))S(1,b2,s[b3]:rep(j))U(1,b2,s[b4]:rep(j))end;if b6 then b9()end end,clear=function()for l=1,n do K(1,l,(" "):rep(j))S(1,l,s[b3]:rep(j))U(1,l,s[b4]:rep(j))end;if b6 then b9()end end,blit=function(i,bP,bQ)if type(i)~="string"then error("bad argument #1 (expected string, got "..type(i)..")",2)end;if type(bP)~="string"then error("bad argument #2 (expected string, got "..type(bP)..")",2)end;if type(bQ)~="string"then error("bad argument #3 (expected string, got "..type(bQ)..")",2)end;if#bP~=#i or#bQ~=#i then error("Arguments must be the same length",2)end;if b6 then ba(i,bP,bQ)end end}return bG end;aT.w=30;aT.h=12;local bR=b0(1,1,aT.w,aT.h)local bS;local bT=false;local bU={}au={getType=function(self)return al end,show=function(self)aT.show(self)bR.setBackgroundColor(self.bgcolor)bR.setTextColor(self.fgcolor)bR.basalt_setVisible(true)return self end,hide=function(self)aT.hide(self)bR.basalt_setVisible(false)return self end,setPosition=function(self,L,M,aA)aT.setPosition(self,L,M,aA)bR.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return bR end,getBasaltProcess=function()return bS end,setSize=function(self,j,n)aT.setSize(self,j,n)bR.basalt_resize(self.w,self.h)return self end,getStatus=function(self)if bS~=nil then return bS:getStatus()end;return"inactive"end,execute=function(self,ad,...)bS=ab:new(ad,bR,...)bR.setBackgroundColor(colors.black)bR.setTextColor(colors.white)bR.clear()bR.setCursorPos(1,1)bS:resume()bT=false;return self end,stop=function(self)if bS~=nil then if not bS:isDead()then bS:resume("terminate")if bS:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,bV)bT=bV or not bT;if bS~=nil then if not bS:isDead()then if not bT then self:injectEvents(bU)bU={}end end end;return self end,isPaused=function(self)return bT end,injectEvent=function(self,a5,aO,aP,aQ,aR,bW)if bS~=nil then if not bS:isDead()then if bT==false or bW then bS:resume(a5,aO,aP,aQ,aR)else table.insert(bU,{event=a5,args={aO,aP,aQ,aR}})end end end;return self end,getQueuedEvents=function(self)return bU end,updateQueuedEvents=function(self,a3)bU=a3 or bU;return self end,injectEvents=function(self,a3)if bS~=nil then if not bS:isDead()then for aJ,a9 in pairs(a3)do bS:resume(a9.event,table.unpack(a9.args))end end end;return self end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then if bS==nil then return false end;if not bS:isDead()then if not bT then local bX,bY=self:getAbsolutePosition(self:getAnchorPosition())bS:resume(a5,aK,L-bX+1,M-bY+1)end end;return true end end,keyHandler=function(self,a5,aN)aT.keyHandler(self,a5,aN)if self:isFocused()then if bS==nil then return false end;if not bS:isDead()then if not bT then if self.draw then bS:resume(a5,aN)end end end end end,getFocusHandler=function(self)aT.getFocusHandler(self)if bS~=nil then if not bS:isDead()then if not bT then if self.parent~=nil then local bZ,b_=bR.getCursorPos()local aX,aY=self:getAnchorPosition()if self.parent~=nil then if aX+bZ-1>=1 and aX+bZ-1<=aX+self.w-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.h-1 then self.parent:setCursor(bR.getCursorBlink(),aX+bZ-1,b_+aY-1,bR.getTextColor())end end end end end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if bS~=nil then if not bS:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,a5,aO,aP,aQ,aR)if bS==nil then return end;if not bS:isDead()then if not bT then if a5~="mouse_click"and a5~="mouse_up"and a5~="mouse_scroll"and a5~="mouse_drag"and a5~="key_up"and a5~="key"and a5~="char"and a5~="terminate"then bS:resume(a5,aO,aP,aQ,aR)end;if self:isFocused()then local aX,aY=self:getAnchorPosition()local bZ,b_=bR.getCursorPos()if self.parent~=nil then if aX+bZ-1>=1 and aX+bZ-1<=aX+self.w-1 and b_+aY-1>=1 and b_+aY-1<=aY+self.h-1 then self.parent:setCursor(bR.getCursorBlink(),aX+bZ-1,b_+aY-1,bR.getTextColor())end end;if a5=="terminate"and self:isFocused()then self:stop()end end else if a5~="mouse_click"and a5~="mouse_up"and a5~="mouse_scroll"and a5~="mouse_drag"and a5~="key_up"and a5~="key"and a5~="char"and a5~="terminate"then table.insert(bU,{event=a5,args={aO,aP,aQ,aR}})end end end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()bR.basalt_reposition(aX,aY)self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)bR.basalt_update()end end end}return setmetatable(au,aT)end;local function c0(ak)local aT=aj(ak)local al="Label"aT:setZIndex(3)local c1=true;aT:setValue("")local au={getType=function(self)return al end,setText=function(self,i)i=tostring(i)aT:setValue(i)if c1 then self.w=i:len()end;return self end,setSize=function(self,j,n)self.w,self.h=j,n;c1=false;return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:writeText(aX,aY,self:getValue(),self.bgcolor,self.fgcolor)end end end}return setmetatable(au,aT)end;local function c2(ak)local aT=aj(ak)local al="Pane"local au={getType=function(self)return al end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)end end end}return setmetatable(au,aT)end;local function c3(ak)local aT=aj(ak)local al="Image"aT:setZIndex(2)local c4;local au={getType=function(self)return al end,loadImage=function(self,ad)c4=paintutils.loadImage(ad)return self end,draw=function(self)if aT.draw(self)then if self.parent~=nil then if c4~=nil then local aX,aY=self:getAnchorPosition()for az=1,math.min(#c4,self.h)do local c5=c4[az]for ay=1,math.min(#c5,self.w)do if c5[ay]>0 then self.parent:drawBackgroundBox(aX+ay-1,aY+az-1,1,1,c5[ay])end end end end end end end}return setmetatable(au,aT)end;local function c6(ak)local aT=aj(ak)local al="Checkbox"aT:setZIndex(5)aT:setValue(false)aT.w=1;aT.h=1;aT.bgcolor=a.CheckboxBG;aT.fgcolor=a.CheckboxFG;local au={symbol="\42",getType=function(self)return al end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then if a5=="mouse_click"and aK==1 then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,"center")self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if l==aZ then if self:getValue()==true then self.parent:writeText(aX,aY+l-1,h(self.symbol,self.w,"center"),self.bgcolor,self.fgcolor)else self.parent:writeText(aX,aY+l-1,h(" ",self.w,"center"),self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(au,aT)end;local function c7(ak)local aT=aj(ak)local al="Input"local c8="text"local c9=0;aT:setZIndex(5)aT:setValue("")aT.w=10;aT.h=1;aT.bgcolor=a.InputBG;aT.fgcolor=a.InputFG;local ca=1;local cb=1;local cc=""local cd;local ce;local cf=cc;local cg=false;local au={getType=function(self)return al end,setInputType=function(self,ch)if ch=="password"or ch=="number"or ch=="text"then c8=ch end;return self end,setDefaultText=function(self,i,ci,cj)cc=i;cd=cj or cd;ce=ci or ce;if self:isFocused()then cf=""else cf=cc end;return self end,getInputType=function(self)return c8 end,setValue=function(self,ck)aT.setValue(self,tostring(ck))if not cg then ca=tostring(ck):len()+1 end;return self end,getValue=function(self)local ck=aT.getValue(self)return c8=="number"and tonumber(ck)or ck end,setInputLimit=function(self,cl)c9=tonumber(cl)or c9;return self end,getInputLimit=function(self)return c9 end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then local aX,aY=self:getAnchorPosition()cf=""if self.parent~=nil then self.parent:setCursor(true,aX+ca-cb,aY,self.fgcolor)end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)cf=cc end end,keyHandler=function(self,a5,aN)if aT.keyHandler(self,a5,aN)then cg=true;if a5=="key"then if aN==259 then local i=tostring(aT.getValue())if ca>1 then self:setValue(i:sub(1,ca-2)..i:sub(ca,i:len()))if ca>1 then ca=ca-1 end;if cb>1 then if cacm then ca=cm+1 end;if ca<1 then ca=1 end;if ca=self.w+cb then cb=ca-self.w+1 end;if cb<1 then cb=1 end end;if aN==263 then ca=ca-1;if ca>=1 then if ca=self.w+cb then cb=ca end end;if ca<1 then ca=1 end;if cb<1 then cb=1 end end end;if a5=="char"then local i=aT.getValue()if i:len()=self.w+cb then cb=cb+1 end end end;local aX,aY=self:getAnchorPosition()local ck=tostring(aT.getValue())local co=(ca<=ck:len()and ca-1 or ck:len())-(cb-1)if co>self.x+self.w-1 then co=self.x+self.w-1 end;if self.parent~=nil then self.parent:setCursor(true,aX+co,aY,self.fgcolor)end;cg=false end end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then if a5=="mouse_click"and aK==1 then end;return true end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()local aZ=m(self.h,"center")self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if l==aZ then local ck=tostring(aT.getValue())local cj=self.bgcolor;local ci=self.fgcolor;local i;if ck:len()<=0 then i=cf;cj=cd or cj;ci=ce or ci end;i=cf;if ck~=""then i=ck end;i=i:sub(cb,self.w+cb-1)local cp=self.w-i:len()if cp<0 then cp=0 end;if c8=="password"and ck~=""then i=string.rep("*",i:len())end;i=i..string.rep(" ",cp)self.parent:writeText(aX,aY+l-1,i,cj,ci)end end end end end}return setmetatable(au,aT)end;local function cq(ak)local aT=aj(ak)local al="Textfield"local cr,cb,ca,cs=1,1,1,1;local ct={""}local cu={}local cv=colors.lightBlue;aT.w=20;aT.h=8;aT.bgcolor=a.textfieldBG;aT.fgcolor=a.textfieldFG;aT:setZIndex(5)local au={getType=function(self)return al end,getLines=function(self)return ct end,getLine=function(self,a4)return ct[a4]or""end,editLine=function(self,a4,i)ct[a4]=i or ct[a4]return self end,addLine=function(self,i,a4)if a4~=nil then table.insert(ct,a4,i)else table.insert(ct,i)end;return self end,removeLine=function(self,a4)table.remove(ct,a4 or#ct)if#ct<=0 then table.insert(ct,"")end;return self end,getTextCursor=function(self)return ca,cs end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then local aX,aY=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,aX+ca-cb,aY+cs-cr,self.fgcolor)end end end,loseFocusHandler=function(self)aT.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,a5,aN)if aT.keyHandler(self,a5,aN)then local aX,aY=self:getAnchorPosition()if a5=="key"then if aN==259 then if ct[cs]==""then if cs>1 then table.remove(ct,cs)ca=ct[cs-1]:len()+1;cb=ca-self.w+1;if cb<1 then cb=1 end;cs=cs-1 end elseif ca<=1 then if cs>1 then ca=ct[cs-1]:len()+1;cb=ca-self.w+1;if cb<1 then cb=1 end;ct[cs-1]=ct[cs-1]..ct[cs]table.remove(ct,cs)cs=cs-1 end else ct[cs]=ct[cs]:sub(1,ca-2)..ct[cs]:sub(ca,ct[cs]:len())if ca>1 then ca=ca-1 end;if cb>1 then if ca=self.h then cr=cr+1 end;self:setValue("")end;if aN==265 then if cs>1 then cs=cs-1;if ca>ct[cs]:len()+1 then ca=ct[cs]:len()+1 end;if cb>1 then if ca1 then if csct[cs]:len()+1 then ca=ct[cs]:len()+1 end;if cs>=cr+self.h then cr=cr+1 end end end;if aN==262 then ca=ca+1;if cs<#ct then if ca>ct[cs]:len()+1 then ca=1;cs=cs+1 end elseif ca>ct[cs]:len()then ca=ct[cs]:len()+1 end;if ca<1 then ca=1 end;if ca=self.w+cb then cb=ca-self.w+1 end;if cb<1 then cb=1 end end;if aN==263 then ca=ca-1;if ca>=1 then if ca=self.w+cb then cb=ca end end;if cs>1 then if ca<1 then cs=cs-1;ca=ct[cs]:len()+1;cb=ca-self.w+1 end end;if ca<1 then ca=1 end;if cb<1 then cb=1 end end end;if a5=="char"then ct[cs]=ct[cs]:sub(1,ca-1)..aN..ct[cs]:sub(ca,ct[cs]:len())ca=ca+1;if ca>=self.w+cb then cb=cb+1 end;self:setValue("")end;local co=(ca<=ct[cs]:len()and ca-1 or ct[cs]:len())-(cb-1)if co>self.x+self.w-1 then co=self.x+self.w-1 end;local cw=cs-crct[cs]:len()then ca=ct[cs]:len()+1 end;if ca#ct-(self.h-1)then cr=#ct-(self.h-1)end;if cr<1 then cr=1 end;if self.parent~=nil then if aX+ca-cb>=aX and aX+ca-cb<=aX+self.w and(aY+cs-cr>=aY and aY+cs-cr<=aY+self.h)then self.parent:setCursor(true,cx+ca-cb,cy+cs-cr)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)for l=1,self.h do local i=""if ct[l+cr-1]~=nil then i=ct[l+cr-1]end;i=i:sub(cb,self.w+cb-1)local cp=self.w-i:len()if cp<0 then cp=0 end;i=i..string.rep(" ",cp)self.parent:setText(aX,aY+l-1,i)end end end end}return setmetatable(au,aT)end;local function cz(ak)local aT=aj(ak)local al="List"aT.w=16;aT.h=6;aT.bgcolor=a.listBG;aT.fgcolor=a.listFG;aT:setZIndex(5)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cD=true;local cE="left"local cF=0;local cG=true;local au={getType=function(self)return al end,addItem=function(self,i,W,X,...)table.insert(cA,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#cA==1 then self:setValue(cA[1])end;return self end,setIndexOffset=function(self,cH)cF=cH;return self end,getIndexOffset=function(self)return cF end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cJ)cB=W or self.bgcolor;cC=X or self.fgcolor;cD=cJ;return self end,setScrollable=function(self,cK)cG=cK;return self end,mouseClickHandler=function(self,a5,aK,L,M)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if aX<=L and aX+self.w>L and aY<=M and aY+self.h>M and self:isVisible()then if a5=="mouse_click"or a5=="mouse_drag"then if aK==1 then if#cA>0 then for l=1,self.h do if cA[l+cF]~=nil then if aX<=L and aX+self.w>L and aY+l-1==M then self:setValue(cA[l+cF])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,L,M,cA[l+cF])end end end end end end;if a5=="mouse_scroll"and cG then cF=cF+aK;if cF<0 then cF=0 end;if aK>=1 then if#cA>self.h then if cF>#cA-self.h then cF=#cA-self.h end;if cF>=#cA then cF=#cA-1 end else cF=cF-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)for l=1,self.h do if cA[l+cF]~=nil then if cA[l+cF]==self:getValue()then if cD then self.parent:writeText(aX,aY+l-1,h(cA[l+cF].text,self.w,cE),cB,cC)else self.parent:writeText(aX,aY+l-1,h(cA[l+cF].text,self.w,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end else self.parent:writeText(aX,aY+l-1,h(cA[l+cF].text,self.w,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end end end end end end}return setmetatable(au,aT)end;local function cL(ak)local aT=aj(ak)local al="Menubar"aT.w=30;aT.h=1;aT.bgcolor=colors.gray;aT.fgcolor=colors.lightGray;aT:setZIndex(5)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cD=true;local cE="left"local cM=0;local cp=2;local cG=false;local function cN()local cO=0;local ay=1;for l=1,#cA do if ay+cA[l].text:len()+cp*2>aT.w then cO=cO+1 end;ay=ay+cA[l].text:len()+cp*2 end;return cO end;local au={getType=function(self)return al end,addItem=function(self,i,W,X,...)table.insert(cA,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#cA==1 then self:setValue(cA[1])end;return self end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,setSpace=function(self,cP)cp=cP or cp;return self end,setButtonOffset=function(self,o)cM=o or 0;if cM<0 then cM=0 end;local cO=cN()if cM>cO then cM=cO end;return self end,setScrollable=function(self,cK)cG=cK;return self end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cJ)cB=W or self.bgcolor;cC=X or self.fgcolor;cD=cJ;return self end,mouseClickHandler=function(self,a5,aK,L,M)local aL,aM=self:getAbsolutePosition(self:getAnchorPosition())if aL<=L and aL+self.w>L and aM<=M and aM+self.h>M and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if a5=="mouse_click"then local ay=1;for l=1+cM,#cA do if cA[l]~=nil then if ay+cA[l].text:len()+cp*2<=self.w then if aL+ay-1<=L and aL+ay-1+cA[l].text:len()+cp*2>L and aM==M then self:setValue(cA[l])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,L,M,cA[l])end;ay=ay+cA[l].text:len()+cp*2 else break end end end end;if a5=="mouse_scroll"and cG then cM=cM+aK;if cM<0 then cM=0 end;local cO=cN()if cM>cO then cM=cO end end;return true end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)local ay=1;for l=1+cM,#cA do if cA[l]~=nil then if ay+cA[l].text:len()+cp*2<=self.w then if cA[l]==self:getValue()then self.parent:writeText(aX+ay-1,aY,h((" "):rep(cp)..cA[l].text..(" "):rep(cp),cA[l].text:len()+cp*2,cE),cB or cA[l].bgCol,cC or cA[l].fgCol)else self.parent:writeText(aX+ay-1,aY,h((" "):rep(cp)..cA[l].text..(" "):rep(cp),cA[l].text:len()+cp*2,cE),cA[l].bgCol,cA[l].fgCol)end;ay=ay+cA[l].text:len()+cp*2 else break end end end end end end}return setmetatable(au,aT)end;local function cQ(ak)local aT=aj(ak)local al="Dropdown"aT.w=12;aT.h=1;aT.bgcolor=a.dropdownBG;aT.fgcolor=a.dropdownFG;aT:setZIndex(6)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cD=true;local cE="left"local cF=0;local cR=16;local cS=6;local cT="\16"local cU="\31"local cV=1;local au={getType=function(self)return al end,setIndexOffset=function(self,cH)cF=cH;return self end,getIndexOffset=function(self)return cF end,addItem=function(self,i,W,X,...)table.insert(cA,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cJ)cB=W or self.bgcolor;cC=X or self.fgcolor;cD=cJ;return self end,setDropdownSize=function(self,j,n)cR,cS=j,n;return self end,mouseClickHandler=function(self,a5,aK,L,M)if cV==2 then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"then if aK==1 then if#cA>0 then for l=1,cS do if cA[l+cF]~=nil then if aX<=L and aX+cR>L and aY+l==M then self:setValue(cA[l+cF])return true end end end end end end;if a5=="mouse_scroll"then cF=cF+aK;if cF<0 then cF=0 end;if aK==1 then if#cA>cS then if cF>#cA-cS then cF=#cA-cS end else cF=cA-1 end end;return true end;self:setVisualChanged()end;if aT.mouseClickHandler(self,a5,aK,L,M)then cV=2 else cV=1 end end,draw=function(self)if aT.draw(self)then local aX,aY=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)if#cA>=1 then if self:getValue().text~=nil then if cV==1 then self.parent:writeText(aX,aY,h(self:getValue().text,self.w,cE):sub(1,self.w-1)..cT,self.bgcolor,self.fgcolor)else self.parent:writeText(aX,aY,h(self:getValue().text,self.w,cE):sub(1,self.w-1)..cU,self.bgcolor,self.fgcolor)end end;if cV==2 then for l=1,cS do if cA[l+cF]~=nil then if cA[l+cF]==self:getValue()then if cD then self.parent:writeText(aX,aY+l,h(cA[l+cF].text,cR,cE),cB,cC)else self.parent:writeText(aX,aY+l,h(cA[l+cF].text,cR,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end else self.parent:writeText(aX,aY+l,h(cA[l+cF].text,cR,cE),cA[l+cF].bgCol,cA[l+cF].fgCol)end end end end end end end end}return setmetatable(au,aT)end;local function cW(ak)local aT=aj(ak)local al="Radio"aT.w=8;aT.bgcolor=a.listBG;aT.fgcolor=a.listFG;aT:setZIndex(5)local cA={}local cB=a.selectionBG;local cC=a.selectionFG;local cX=aT.bgcolor;local cY=aT.fgcolor;local cD=true;local Y="\7"local cE="left"local au={getType=function(self)return al end,addItem=function(self,i,L,M,W,X,...)table.insert(cA,{x=L or 1,y=M or 1,text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})if#cA==1 then self:setValue(cA[1])end;return self end,removeItem=function(self,a4)table.remove(cA,a4)return self end,getItem=function(self,a4)return cA[a4]end,getItemIndex=function(self)local cI=self:getValue()for a8,a9 in pairs(cA)do if a9==cI then return a8 end end end,clear=function(self)cA={}self:setValue({})return self end,getItemCount=function(self)return#cA end,editItem=function(self,a4,i,L,M,W,X,...)table.remove(cA,a4)table.insert(cA,a4,{x=L or 1,y=M or 1,text=i,bgCol=W or self.bgcolor,fgCol=X or self.fgcolor,args={...}})return self end,selectItem=function(self,a4)self:setValue(cA[a4]or{})return self end,setSelectedItem=function(self,W,X,cZ,c_,cJ)cB=W or cB;cC=X or cC;cX=cZ or cX;cY=c_ or cY;cD=cJ;return self end,mouseClickHandler=function(self,a5,aK,L,M)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if a5=="mouse_click"then if aK==1 then if#cA>0 then for aJ,a9 in pairs(cA)do if aX+a9.x-1<=L and aX+a9.x-1+a9.text:len()+2>=L and aY+a9.y-1==M then self:setValue(a9)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end end;return false end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()for aJ,a9 in pairs(cA)do if a9==self:getValue()then if cE=="left"then self.parent:writeText(a9.x+aX-1,a9.y+aY-1,Y,cX,cY)self.parent:writeText(a9.x+2+aX-1,a9.y+aY-1,a9.text,cB,cC)end else self.parent:drawBackgroundBox(a9.x+aX-1,a9.y+aY-1,1,1,self.bgcolor)self.parent:writeText(a9.x+2+aX-1,a9.y+aY-1,a9.text,a9.bgCol,a9.fgCol)end end end end end}return setmetatable(au,aT)end;local function d0(ak)local al="Timer"local d1=0;local d2=0;local d3=0;local d4;local at=a2()local au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,d5,d6)d1=d5 or 0;d2=d6 or 1;return self end,start=function(self)d3=d2;d4=os.startTimer(d1)return self end,cancel=function(self)if d4~=nil then os.cancelTimer(d4)end;return self end,onCall=function(self,a7)at:registerEvent("timed_event",a7)return self end,eventHandler=function(self,a5,d7)if a5=="timer"and d7==d4 then at:sendEvent("timed_event",self)if d3>=1 then d3=d3-1;if d3>=1 then d4=os.startTimer(d1)end elseif d3==-1 then d4=os.startTimer(d1)end end end}au.__index=au;return au end;local function d8(ak)local au;local al="Thread"local a7;local d9;local da=false;au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,db)if db==nil then error("function is nil")end;a7=db;d9=coroutine.create(a7)da=true;local ah,ai=coroutine.resume(d9)if not ah then if ai~="Terminated"then error("Threaderror - "..ai)end end;return self end,getStatus=function(self,db)if d9~=nil then return coroutine.status(d9)end;return nil end,stop=function(self,db)da=false;return self end,eventHandler=function(self,a5,aO,aP,aQ)if da then if coroutine.status(d9)~="dead"then local ah,ai=coroutine.resume(d9,a5,aO,aP,aQ)if not ah then if ai~="Terminated"then error("Threaderror - "..ai)end end else da=false end end end}au.__index=au;return au end;local function dc(ak)local au={}local al="Animation"local d4;local dd={}local a4=1;local de=0;local df;local function dg()if dd[a4]~=nil then dd[a4].f(au,a4)end;a4=a4+1;if dd[a4]~=nil then if dd[a4].t>0 then d4=os.startTimer(dd[a4].t)else dg()end end end;au={name=ak,getType=function(self)return al end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,a7,dh)df=a7;table.insert(dd,{f=a7,t=dh or de})return self end,wait=function(self,dh)de=dh;return self end,rep=function(self,di)for L=1,di do table.insert(dd,{f=df,t=de})end;return self end,clear=function(self)dd={}df=nil;de=0;a4=1;return self end,play=function(self)a4=1;if dd[a4]~=nil then if dd[a4].t>0 then d4=os.startTimer(dd[a4].t)else dg()end end;return self end,cancel=function(self)os.cancelTimer(d4)return self end,eventHandler=function(self,a5,d7)if a5=="timer"and d7==d4 then if dd[a4]~=nil then dg()end end end}au.__index=au;return au end;local function dj(ak)local aT=aj(ak)local al="Slider"aT.w=8;aT.bgcolor=colors.lightGray;aT.fgcolor=colors.gray;aT:setValue(1)local dk="horizontal"local Y=" "local dl=colors.black;local dm="\140"local dn=aT.w;local a4=1;local au={getType=function(self)return al end,setSymbol=function(self,dp)Y=dp:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,dq)dm=string.sub(dq,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dr)dl=dr;self:setVisualChanged()return self end,setBarType=function(self,ds)dk=ds:lower()return self end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if dk=="horizontal"then for dt=0,self.w-1 do if aX+dt==L and aY<=M and aY+self.h>M then a4=dt+1;self:setValue(dn/self.w*a4)self:setVisualChanged()end end end;if dk=="vertical"then for dt=0,self.h-1 do if aY+dt==M and aX<=L and aX+self.w>L then a4=dt+1;self:setValue(dn/self.h*a4)self:setVisualChanged()end end end end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()if dk=="horizontal"then self.parent:writeText(aX,aY,dm:rep(a4-1),self.bgcolor,self.fgcolor)self.parent:writeText(aX+a4-1,aY,Y,dl,dl)self.parent:writeText(aX+a4,aY,dm:rep(self.w-a4),self.bgcolor,self.fgcolor)end;if dk=="vertical"then for l=0,self.h-1 do if l+1==a4 then self.parent:writeText(aX,aY+l,Y,dl,dl)else self.parent:writeText(aX,aY+l,dm,self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(au,aT)end;local function du(ak)local aT=aj(ak)local al="Scrollbar"aT.w=1;aT.h=8;aT.bgcolor=colors.lightGray;aT.fgcolor=colors.gray;aT:setValue(1)aT:setZIndex(2)local dk="vertical"local Y=" "local dl=colors.black;local dm="\127"local dn=aT.h;local a4=1;local dv=1;local au={getType=function(self)return al end,setSymbol=function(self,dp)Y=dp:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,dw)dv=tonumber(dw)or 1;if dk=="vertical"then self:setValue(a4-1*dn/(self.h-(dv-1))-dn/(self.h-(dv-1)))elseif dk=="horizontal"then self:setValue(a4-1*dn/(self.w-(dv-1))-dn/(self.w-(dv-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,ck)dn=ck;return self end,setBackgroundSymbol=function(self,dq)dm=string.sub(dq,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,dr)dl=dr;self:setVisualChanged()return self end,setBarType=function(self,ds)dk=ds:lower()return self end,mouseClickHandler=function(self,a5,aK,L,M)if aT.mouseClickHandler(self,a5,aK,L,M)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if(a5=="mouse_click"or a5=="mouse_drag")and aK==1 then if dk=="horizontal"then for dt=0,self.w do if aX+dt==L and aY<=M and aY+self.h>M then a4=math.min(dt+1,self.w-(dv-1))self:setValue(dn/self.w*a4)self:setVisualChanged()end end end;if dk=="vertical"then for dt=0,self.h do if aY+dt==M and aX<=L and aX+self.w>L then a4=math.min(dt+1,self.h-(dv-1))self:setValue(dn/self.h*a4)self:setVisualChanged()end end end end;if a5=="mouse_scroll"then a4=a4+aK;if a4<1 then a4=1 end;a4=math.min(a4,(dk=="vertical"and self.h or self.w)-(dv-1))self:setValue(dn/(dk=="vertical"and self.h or self.w)*a4)end;return true end end,draw=function(self)if aT.draw(self)then if self.parent~=nil then local aX,aY=self:getAnchorPosition()if dk=="horizontal"then self.parent:writeText(aX,aY,dm:rep(a4-1),self.bgcolor,self.fgcolor)self.parent:writeText(aX+a4-1,aY,Y:rep(dv),dl,dl)self.parent:writeText(aX+a4+dv-1,aY,dm:rep(self.w-(a4+dv-1)),self.bgcolor,self.fgcolor)end;if dk=="vertical"then for l=0,self.h-1 do if a4==l+1 then for dx=0,math.min(dv-1,self.h)do self.parent:writeText(aX,aY+l+dx,Y,dl,dl)end else if l+1a4-1+dv then self.parent:writeText(aX,aY+l,dm,self.bgcolor,self.fgcolor)end end end end end end end}return setmetatable(au,aT)end;local function dy(ak,dz)local aT=aj(ak)local al="Frame"local dA={}local dB={}local au={}local dC;aT:setZIndex(10)local b5=false;local b1=1;local b2=1;local dD=colors.white;local dE,cF=0,0;if dz~=nil then aT.parent=dz;aT.w,aT.h=dz.w,dz.h;aT.bgcolor=a.FrameBG;aT.fgcolor=a.FrameFG else local dF,dG=f.getSize()aT.w,aT.h=dF,dG;aT.bgcolor=a.basaltBG;aT.fgcolor=a.basaltFG end;local function dH(ak)for a8,a9 in pairs(dA)do for dI,bD in pairs(a9)do if bD.name==ak then return a9 end end end end;local function dJ(dK)local an=dK:getZIndex()if dH(dK.name)~=nil then return nil end;if dA[an]==nil then for L=1,#dB+1 do if dB[L]~=nil then if an==dB[L]then break end;if an>dB[L]then table.insert(dB,L,an)break end else table.insert(dB,an)end end;if#dB<=0 then table.insert(dB,an)end;dA[an]={}end;dK.parent=au;table.insert(dA[an],dK)return dK end;local function dL(dK)for dI,bD in pairs(dA)do for a8,a9 in pairs(bD)do if a9==dK then table.remove(dA[dI],a8)return end end end end;au={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return al end,setFocusedObject=function(self,dK)for aJ,a4 in pairs(dB)do for aJ,a9 in pairs(dA[a4])do if a9==dK then if dC~=nil then dC:loseFocusHandler()end;dC=dK;dC:getFocusHandler()end end end;return self end,setOffset=function(self,aG,aH)dE=aG~=nil and math.floor(aG<0 and math.abs(aG)or-aG)or dE;cF=aH~=nil and math.floor(aH<0 and math.abs(aH)or-aH)or cF;return self end,getFrameOffset=function(self)return dE,cF end,removeFocusedObject=function(self)if dC~=nil then dC:loseFocusHandler()end;dC=nil;return self end,getFocusedObject=function(self)return dC end,show=function(self)aT:show()if self.parent==nil then c=self end;return self end,setCursor=function(self,dM,dN,dO,aC)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())b5=dM or false;if dN~=nil then b1=aX+dN-1 end;if dO~=nil then b2=aY+dO-1 end;dD=aC or dD;self:setVisualChanged()return self end,setMoveable=function(self,dP)self.isMoveable=dP or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,dQ)self.barActive=dQ or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,i,W,X)self.barText=i or""self.barBackground=W or self.barBackground;self.barTextcolor=X or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,cE)self.barTextAlign=cE or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local dR=aT.getVisualChanged(self)for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.getVisualChanged~=nil and a9:getVisualChanged()then dR=true end end end end;return dR end,loseFocusHandler=function(self)aT.loseFocusHandler(self)end,getFocusHandler=function(self)aT.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,a5,aN)if dC~=nil then if dC.keyHandler~=nil then if dC:keyHandler(a5,aN)then return true end end end;return false end,backgroundKeyHandler=function(self,a5,aN)aT.backgroundKeyHandler(self,a5,aN)for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.backgroundKeyHandler~=nil then a9:backgroundKeyHandler(a5,aN)end end end end end,eventHandler=function(self,a5,aO,aP,aQ,aR)aT.eventHandler(self,a5,aO,aP,aQ,aR)for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.eventHandler~=nil then a9:eventHandler(a5,aO,aP,aQ,aR)end end end end;if a5=="terminate"then f.clear()f.setCursorPos(1,1)b.stop()end end,mouseClickHandler=function(self,a5,aK,L,M)local aG,aH=self:getOffset()aG=aG<0 and math.abs(aG)or-aG;aH=aH<0 and math.abs(aH)or-aH;if self.drag then if a5=="mouse_drag"then local dS=1;local dT=1;if self.parent~=nil then dS,dT=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(L+self.xToRem-(dS-1)+aG,M-(dT-1)+aH)end;if a5=="mouse_up"then self.drag=false end;return true end;if aT.mouseClickHandler(self,a5,aK,L,M)then local aD,aE=self:getAbsolutePosition(self:getAnchorPosition())for aJ,a4 in pairs(dB)do if dA[a4]~=nil then for aJ,a9 in p(dA[a4])do if a9.mouseClickHandler~=nil then if a9:mouseClickHandler(a5,aK,L+aG,M+aH)then return true end end end end end;if self.isMoveable then if L>=aD and L<=aD+self.w-1 and M==aE and a5=="mouse_click"then self.drag=true;self.xToRem=aD-L end end;if dC~=nil then dC:loseFocusHandler()dC=nil end;return true end;return false end,setText=function(self,L,M,i)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setText(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(i,math.max(1-L+1,1),self.w-L+1))else V.setText(math.max(L+aX-1,aX),aY+M-1,g(i,math.max(1-L+1,1),self.w-L+1))end end end,setBG=function(self,L,M,W)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setBG(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(W,math.max(1-L+1,1),self.w-L+1))else V.setBG(math.max(L+aX-1,aX),aY+M-1,g(W,math.max(1-L+1,1),self.w-L+1))end end end,setFG=function(self,L,M,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:setFG(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(X,math.max(1-L+1,1),self.w-L+1))else V.setFG(math.max(L+aX-1,aX),aY+M-1,g(X,math.max(1-L+1,1),self.w-L+1))end end end,writeText=function(self,L,M,i,W,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())if M>=1 and M<=self.h then if self.parent~=nil then self.parent:writeText(math.max(L+aX-1,aX)-(self.parent.x-1),aY+M-1-(self.parent.y-1),g(i,math.max(1-L+1,1),self.w-L+1),W,X)else V.writeText(math.max(L+aX-1,aX),aY+M-1,g(i,math.max(1-L+1,1),self.w-L+1),W,X)end end end,drawBackgroundBox=function(self,L,M,j,n,W)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,W)else V.drawBackgroundBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,W)end end,drawTextBox=function(self,L,M,j,n,Y)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawTextBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,Y:sub(1,1))else V.drawTextBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,Y:sub(1,1))end end,drawForegroundBox=function(self,L,M,j,n,X)local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())n=M<1 and(n+M>self.h and self.h or n+M-1)or(n+M>self.h and self.h-M+1 or n)j=L<1 and(j+L>self.w and self.w or j+L-1)or(j+L>self.w and self.w-L+1 or j)if self.parent~=nil then self.parent:drawForegroundBox(math.max(L+aX-1,aX)-(self.parent.x-1),math.max(M+aY-1,aY)-(self.parent.y-1),j,n,X)else V.drawForegroundBox(math.max(L+aX-1,aX),math.max(M+aY-1,aY),j,n,X)end end,draw=function(self)if self:getVisualChanged()then if aT.draw(self)then local aX,aY=self:getAbsolutePosition(self:getAnchorPosition())local cx,cy=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(cx,cy,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(cx,cy,self.w,self.h,self.fgcolor)self.parent:drawTextBox(cx,cy,self.w,self.h," ")else V.drawBackgroundBox(aX,aY,self.w,self.h,self.bgcolor)V.drawForegroundBox(aX,aY,self.w,self.h,self.fgcolor)V.drawTextBox(aX,aY,self.w,self.h," ")end;f.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(cx,cy,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)else V.writeText(aX,aY,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aJ,a4 in p(dB)do if dA[a4]~=nil then for aJ,a9 in pairs(dA[a4])do if a9.draw~=nil then a9:draw()end end end end;if b5 then f.setTextColor(dD)f.setCursorPos(b1,b2)if self.parent~=nil then f.setCursorBlink(self:isFocused())else f.setCursorBlink(b5)end end;self:setVisualChanged(false)end end end,addObject=function(self,dK)return dJ(dK)end,removeObject=function(self,dK)return dL(dK)end,getObject=function(self,dK)return dH(dK)end,addButton=function(self,ak)local dK=aS(ak)dK.name=ak;return dJ(dK)end,addLabel=function(self,ak)local dK=c0(ak)dK.name=ak;dK.bgcolor=self.bgcolor;dK.fgcolor=self.fgcolor;return dJ(dK)end,addCheckbox=function(self,ak)local dK=c6(ak)dK.name=ak;return dJ(dK)end,addInput=function(self,ak)local dK=c7(ak)dK.name=ak;return dJ(dK)end,addProgram=function(self,ak)local dK=a_(ak)dK.name=ak;return dJ(dK)end,addTextfield=function(self,ak)local dK=cq(ak)dK.name=ak;return dJ(dK)end,addList=function(self,ak)local dK=cz(ak)dK.name=ak;return dJ(dK)end,addDropdown=function(self,ak)local dK=cQ(ak)dK.name=ak;return dJ(dK)end,addRadio=function(self,ak)local dK=cW(ak)dK.name=ak;return dJ(dK)end,addTimer=function(self,ak)local dK=d0(ak)dK.name=ak;return dJ(dK)end,addAnimation=function(self,ak)local dK=dc(ak)dK.name=ak;return dJ(dK)end,addSlider=function(self,ak)local dK=dj(ak)dK.name=ak;return dJ(dK)end,addScrollbar=function(self,ak)local dK=du(ak)dK.name=ak;return dJ(dK)end,addMenubar=function(self,ak)local dK=cL(ak)dK.name=ak;return dJ(dK)end,addThread=function(self,ak)local dK=d8(ak)dK.name=ak;return dJ(dK)end,addPane=function(self,ak)local dK=c2(ak)dK.name=ak;return dJ(dK)end,addImage=function(self,ak)local dK=c3(ak)dK.name=ak;return dJ(dK)end,addFrame=function(self,ak)local dK=dy(ak,self)dK.name=ak;return dJ(dK)end}setmetatable(au,aT)if dz==nil then table.insert(d,au)end;return au end;local dU=false;local function dV(a5,aO,aP,aQ,aR)if a5=="mouse_click"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_drag"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_up"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="mouse_scroll"then c:mouseClickHandler(a5,aO,aP,aQ,aR)end;if a5=="key"or a5=="char"then c:keyHandler(a5,aO)c:backgroundKeyHandler(a5,aO)end;for aJ,a9 in pairs(d)do a9:eventHandler(a5,aO,aP,aQ,aR)end;if dU then c:draw()V.update()end end;function b.autoUpdate(da)f.clear()dU=da or true;c:draw()V.update()while dU do local a5,aO,aP,aQ,aR=os.pullEventRaw()dV(a5,aO,aP,aQ,aR)end end;function b.update(a5,aO,aP,aQ,aR)if a5~="nil"then dV(a5,aO,aP,aQ,aR)else c:draw()V.update()end end;function b.stop()dU=false end;function b.getFrame(ak)for a8,a9 in pairs(d)do if a9.name==ak then return a9 end end end;function b.getActiveFrame()return c end;function b.setActiveFrame(av)if av:getType()=="Frame"then c=av;return true end;return false end;function b.createFrame(ak)local av=dy(ak)return av end;function b.removeFrame(ak)for a8,a9 in pairs(d)do if a9.name==ak then d[a8]=nil;return true end end;return false end;if b.debugger then b.debugFrame=b.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)b.debugList=b.debugFrame:addList("debugList"):setSize(b.debugFrame.w-2,b.debugFrame.h-3):setPosition(2,3):setScrollable(true):show()b.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()b.oldFrame:show()end):setBackground(colors.red):show()b.debugLabel=b.debugFrame:addLabel("debugLabel"):onClick(function()b.oldFrame=c;b.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if b.debugger then function b.debug(...)local af={...}if c.name~="basaltDebuggingFrame"then if c~=b.debugLabel.frame then b.debugLabel:setParent(c)end end;local dW=""for a8,a9 in pairs(af)do dW=dW..tostring(a9)..(#af~=a8 and", "or"")end;b.debugLabel:setText("[Debug] "..dW)b.debugList:addItem(dW)if b.debugList:getItemCount()>50 then b.debugList:removeItem(1)end;b.debugList:setValue(b.debugList:getItem(b.debugList:getItemCount()))b.debugLabel:show()end end;return b \ No newline at end of file diff --git a/source/basalt.lua b/source/basalt.lua index 9da3038..f0bb4ca 100644 --- a/source/basalt.lua +++ b/source/basalt.lua @@ -437,9 +437,11 @@ local function Object(name) -- Base object end; setValue = function(self, _value) - value = _value - visualsChanged = true - self:valueChangedHandler() + if(value~=_value)then + value = _value + visualsChanged = true + self:valueChangedHandler() + end return self end; @@ -656,7 +658,7 @@ local function Object(name) -- Base object return eventSystem:removeEvent(event, index) end; - mouseHandler = function(self, event, button, x, y) + mouseClickHandler = function(self, event, button, x, y) local objX,objY = self:getAbsolutePosition(self:getAnchorPosition()) if(objX<=x)and(objX+self.w>x)and(objY<=y)and(objY+self.h>y)and(isVisible)then if(self.parent~=nil)then self.parent:setFocusedObject(self) end @@ -734,7 +736,7 @@ local function Button(name) -- Button draw = function(self) if(base.draw(self))then if(self.parent~=nil)then - local obx, oby = self:getAnchorPosition(self.x,self.y) + local obx, oby = self:getAnchorPosition() local verticalAlign = getTextVerticalAlign(self.h, textVerticalAlign) self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) @@ -1263,8 +1265,8 @@ local function Program(name) return self end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self,event,button,x,y))then + mouseClickHandler = function(self, event, button, x, y) + if(base.mouseClickHandler(self,event,button,x,y))then if(curProcess==nil)then return false end if not(curProcess:isDead())then if not(paused)then @@ -1488,8 +1490,8 @@ local function Checkbox(name) -- Checkbox return typ end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self, event, button, x, y))then + mouseClickHandler = function(self, event, button, x, y) + if(base.mouseClickHandler(self, event, button, x, y))then if(event == "mouse_click")and(button == 1)then if(self:getValue()~=true)and(self:getValue()~=false)then self:setValue(false) @@ -1697,8 +1699,8 @@ local function Input(name) -- Input end end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self, event, button, x, y))then + mouseClickHandler = function(self, event, button, x, y) + if(base.mouseClickHandler(self, event, button, x, y))then if(event == "mouse_click")and(button == 1)then end @@ -1943,8 +1945,8 @@ local function Textfield(name) end end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self, event, button, x, y))then + mouseClickHandler = function(self, event, button, x, y) + if(base.mouseClickHandler(self, event, button, x, y))then local obx,oby = self:getAbsolutePosition(self:getAnchorPosition()) local anchx,anchy = self:getAnchorPosition() if(event=="mouse_click")then @@ -2098,9 +2100,9 @@ local function List(name) return self end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self, event, button, x, y))then - local obx,oby = self:getAbsolutePosition(self:getAnchorPosition()) + mouseClickHandler = function(self, event, button, x, y) + local obx,oby = self:getAbsolutePosition(self:getAnchorPosition()) + if(obx<=x)and(obx+self.w>x)and(oby<=y)and(oby+self.h>y)and(self:isVisible())then if(event=="mouse_click")or(event=="mouse_drag")then -- remove mouse_drag if i want to make objects moveable uwuwuwuw if(button==1)then if(#list>0)then @@ -2108,6 +2110,7 @@ local function List(name) if(list[n+yOffset]~=nil)then if(obx<=x)and(obx+self.w>x)and(oby+n-1==y)then self:setValue(list[n+yOffset]) + self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n+yOffset]) end end end @@ -2274,16 +2277,18 @@ local function Menubar(name) return self end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self,event,button,x,y))then - local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) + mouseClickHandler = function(self, event, button, x, y) + local objX,objY = self:getAbsolutePosition(self:getAnchorPosition()) + if(objX<=x)and(objX+self.w>x)and(objY<=y)and(objY+self.h>y)and(self:isVisible())then + if(self.parent~=nil)then self.parent:setFocusedObject(self) end if(event=="mouse_click")then local xPos = 1 for n=1+itemOffset,#list do if(list[n]~=nil)then if(xPos + list[n].text:len() + space*2 <= self.w)then - if(obx + (xPos-1)<= x)and(obx + (xPos-1) + list[n].text:len() + space*2 > x)and(oby == y)then + if(objX + (xPos-1)<= x)and(objX + (xPos-1) + list[n].text:len() + space*2 > x)and(objY == y)then self:setValue(list[n]) + self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n]) end xPos = xPos+list[n].text:len()+space*2 else @@ -2305,7 +2310,9 @@ local function Menubar(name) itemOffset = mScroll end end + return true end + return false end; draw = function(self) @@ -2374,9 +2381,6 @@ local function Dropdown(name) addItem = function(self, text, bgCol, fgCol, ...) table.insert(list, {text=text, bgCol = bgCol or self.bgcolor, fgCol = fgCol or self.fgcolor, args={...}}) - if(#list==1)then - self:setValue(list[1]) - end return self end; @@ -2431,7 +2435,7 @@ local function Dropdown(name) return self end; - mouseHandler = function(self, event, button, x, y) + mouseClickHandler = function(self, event, button, x, y) if(state == 2)then local obx,oby = self:getAbsolutePosition(self:getAnchorPosition()) if(event=="mouse_click")then -- remove mouse_drag if i want to make objects moveable uwuwuwuw @@ -2465,7 +2469,7 @@ local function Dropdown(name) end self:setVisualChanged() end - if(base.mouseHandler(self, event, button, x, y))then + if(base.mouseClickHandler(self, event, button, x, y))then state = 2 else state = 1 @@ -2587,7 +2591,7 @@ local function Radio(name) return self end; - mouseHandler = function(self, event, button, x, y) + mouseClickHandler = function(self, event, button, x, y) local obx,oby = self:getAbsolutePosition(self:getAnchorPosition()) if(event=="mouse_click")then -- remove mouse_drag if i want to make objects moveable uwuwuwuw if(button==1)then @@ -2906,8 +2910,8 @@ local function Slider(name) return self end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self,event,button,x,y))then + mouseClickHandler = function(self, event, button, x, y) + if(base.mouseClickHandler(self,event,button,x,y))then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if(barType=="horizontal")then for _index=0,self.w-1 do @@ -3029,8 +3033,8 @@ local function Scrollbar(name) return self end; - mouseHandler = function(self, event, button, x, y) - if(base.mouseHandler(self,event,button,x,y))then + mouseClickHandler = function(self, event, button, x, y) + if(base.mouseClickHandler(self,event,button,x,y))then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if((event=="mouse_click")or(event=="mouse_drag"))and(button==1)then if(barType=="horizontal")then @@ -3327,7 +3331,7 @@ local function Frame(name,parent) -- Frame end end; - mouseHandler = function(self, event, button, x, y) + mouseClickHandler = function(self, event, button, x, y) local xO, yO = self:getOffset() xO = xO < 0 and math.abs(xO) or -xO yO = yO < 0 and math.abs(yO) or -yO @@ -3345,14 +3349,14 @@ local function Frame(name,parent) -- Frame return true end - if(base.mouseHandler(self,event,button,x,y))then + if(base.mouseClickHandler(self,event,button,x,y))then local fx,fy = self:getAbsolutePosition(self:getAnchorPosition()) for _,index in pairs(objZIndex)do if(objects[index]~=nil)then for _,v in rpairs(objects[index])do - if(v.mouseHandler~=nil)then - if(v:mouseHandler(event,button,x+xO,y+yO))then - return true + if(v.mouseClickHandler~=nil)then + if(v:mouseClickHandler(event,button,x+xO,y+yO))then + return true end end end @@ -3503,6 +3507,10 @@ local function Frame(name,parent) -- Frame return removeObject(obj) end; + getObject = function(self, obj) + return getObject(obj) + end; + addButton = function(self, name) local obj = Button(name) obj.name = name @@ -3623,10 +3631,10 @@ end local updaterActive = false local function basaltUpdateEvent(event, p1,p2,p3,p4) - if(event=="mouse_click")then activeFrame:mouseHandler(event,p1,p2,p3,p4) end - if(event=="mouse_drag")then activeFrame:mouseHandler(event,p1,p2,p3,p4) end - if(event=="mouse_up")then activeFrame:mouseHandler(event,p1,p2,p3,p4) end - if(event=="mouse_scroll")then activeFrame:mouseHandler(event,p1,p2,p3,p4) end + if(event=="mouse_click")then activeFrame:mouseClickHandler(event,p1,p2,p3,p4) end + if(event=="mouse_drag")then activeFrame:mouseClickHandler(event,p1,p2,p3,p4) end + if(event=="mouse_up")then activeFrame:mouseClickHandler(event,p1,p2,p3,p4) end + if(event=="mouse_scroll")then activeFrame:mouseClickHandler(event,p1,p2,p3,p4) end if(event=="key")or(event=="char")then activeFrame:keyHandler(event,p1) activeFrame:backgroundKeyHandler(event,p1) end for _,v in pairs(frames)do v:eventHandler(event, p1, p2, p3, p4) @@ -3698,9 +3706,9 @@ end if(basalt.debugger)then basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) - basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.w - 2, basalt.debugFrame.h - 3):setPosition(2,3):show() + basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.w - 2, basalt.debugFrame.h - 3):setPosition(2,3):setScrollable(true):show() basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show() - basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = activeFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):show() + basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = activeFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show() end @@ -3718,8 +3726,8 @@ if(basalt.debugger)then end basalt.debugLabel:setText("[Debug] "..str) basalt.debugList:addItem(str) - if(basalt.debugList:getItemCount()>basalt.debugList.h)then basalt.debugList:removeItem(1) end - + if(basalt.debugList:getItemCount()>50)then basalt.debugList:removeItem(1) end + basalt.debugList:setValue(basalt.debugList:getItem(basalt.debugList:getItemCount())) basalt.debugLabel:show() end end