From 6c235b04dfe772205281b477eb0425210bf98b35 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Tue, 2 May 2023 18:28:47 +0200 Subject: [PATCH] Small themes fix - Fixed themes bug --- Basalt/plugins/themes.lua | 6 +- docs/docs1_6/versions/basalt-1.0.0.lua | 1 - docs/docs1_6/versions/basalt-1.5.0.lua | 2411 ------------------ docs/docs1_6/versions/basalt-1.6.0.lua | 2706 --------------------- docs/docs1_6/versions/basalt-1.6.2.lua | 2790 --------------------- docs/docs1_6/versions/basalt-1.6.3.lua | 2737 --------------------- docs/docs1_6/versions/basalt-1.6.4.lua | 3066 ----------------------- docs/docs1_6/versions/basalt.lua | 3083 ------------------------ docs/docs1_6/versions/latest.lua | 3083 ------------------------ 9 files changed, 3 insertions(+), 19880 deletions(-) delete mode 100644 docs/docs1_6/versions/basalt-1.0.0.lua delete mode 100644 docs/docs1_6/versions/basalt-1.5.0.lua delete mode 100644 docs/docs1_6/versions/basalt-1.6.0.lua delete mode 100644 docs/docs1_6/versions/basalt-1.6.2.lua delete mode 100644 docs/docs1_6/versions/basalt-1.6.3.lua delete mode 100644 docs/docs1_6/versions/basalt-1.6.4.lua delete mode 100644 docs/docs1_6/versions/basalt.lua delete mode 100644 docs/docs1_6/versions/latest.lua diff --git a/Basalt/plugins/themes.lua b/Basalt/plugins/themes.lua index 8342b85..414e11b 100644 --- a/Basalt/plugins/themes.lua +++ b/Basalt/plugins/themes.lua @@ -64,16 +64,16 @@ local plugin = { return object end, - basaltInternal = function() + basalt = function() return { getTheme = function(name) return baseTheme[name] end, setTheme = function(_theme, col) if(type(_theme)=="table")then - theme = _theme + baseTheme = _theme elseif(type(_theme)=="string")then - theme[_theme] = col + baseTheme[_theme] = col end end } diff --git a/docs/docs1_6/versions/basalt-1.0.0.lua b/docs/docs1_6/versions/basalt-1.0.0.lua deleted file mode 100644 index 249a5da..0000000 --- a/docs/docs1_6/versions/basalt-1.0.0.lua +++ /dev/null @@ -1 +0,0 @@ -local a={debugger=true,version=1}local b={}local c;local d={}local e;local f;local g={}local h=term.current()local i=string.sub;local j={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local k={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 l={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{[[000110000110110000110010101000000010000000100101]],[[000000110110000000000010101000000010000000100101]],[[000000000000000000000000000000000000000000000000]],[[100010110100000010000110110000010100000100000110]],[[000000110000000010110110000110000000000000110000]],[[000000000000000000000000000000000000000000000000]],[[000000110110000010000000100000100000000000000010]],[[000000000110110100010000000010000000000000000100]],[[000000000000000000000000000000000000000000000000]],[[010000000000100110000000000000000000000110010000]],[[000000000000000000000000000010000000010110000000]],[[000000000000000000000000000000000000000000000000]],[[011110110000000100100010110000000100000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110000110110000000000000000000010100100010000000]],[[000010000000000000110110000000000100010010000000]],[[000000000000000000000000000000000000000000000000]],[[010110010110100110110110010000000100000110110110]],[[000000000000000000000110000000000110000000000000]],[[000000000000000000000000000000000000000000000000]],[[010100010110110000000000000000110000000010000000]],[[110110000000000000110000110110100000000010000000]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[000000000000000000000000000000000000000000000000]],[[000100011111000100011111000100011111000100011111]],[[000000000000100100100100011011011011111111111111]],[[100100100100100100100100100100100100100100100100]],[[000000110100110110000010000011110000000000011000]],[[000000000100000000000010000011000110000000001000]],[[000000000000000000000000000000000000000000000000]],[[010000100100000000000000000100000000010010110000]],[[000000000000000000000000000000110110110110110000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110000000110110110110110110110110]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[000000000000110110000110010000000000000000010010]],[[000010000000000000000000000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110110110110000000000000]],[[000000000000000000000110000000000000000000000000]],[[000000000000000000000000000000000000000000000000]],[[110110110110110110110000110000000000000000010000]],[[000000000000000000000000100000000000000110000110]],[[000000000000000000000000000000000000000000000000]]}}local m={}local n={}do local o=0;local p=#l[1]local q=#l[1][1]for r=1,p,3 do for s=1,q,3 do local t=string.char(o)local u={}u[1]=l[1][r]:sub(s,s+2)u[2]=l[1][r+1]:sub(s,s+2)u[3]=l[1][r+2]:sub(s,s+2)local v={}v[1]=l[2][r]:sub(s,s+2)v[2]=l[2][r+1]:sub(s,s+2)v[3]=l[2][r+2]:sub(s,s+2)n[t]={u,v}o=o+1 end end;m[1]=n end;local function w(x,y)local z={["0"]="1",["1"]="0"}if x<=#m then return true end;for A=#m+1,x do local B={}local C=m[A-1]for o=0,255 do local t=string.char(o)local u={}local v={}local D=C[t][1]local E=C[t][2]for r=1,#D do local F,G,H,I,J,K={},{},{},{},{},{}for s=1,#D[1]do local L=n[D[r]:sub(s,s)][1]table.insert(F,L[1])table.insert(G,L[2])table.insert(H,L[3])local M=n[D[r]:sub(s,s)][2]if E[r]:sub(s,s)=="1"then table.insert(I,M[1]:gsub("[01]",z))table.insert(J,M[2]:gsub("[01]",z))table.insert(K,M[3]:gsub("[01]",z))else table.insert(I,M[1])table.insert(J,M[2])table.insert(K,M[3])end end;table.insert(u,table.concat(F))table.insert(u,table.concat(G))table.insert(u,table.concat(H))table.insert(v,table.concat(I))table.insert(v,table.concat(J))table.insert(v,table.concat(K))end;B[t]={u,v}if y then y="Font"..A.."Yeld"..o;os.queueEvent(y)os.pullEvent(y)end end;m[A]=B end;return true end;local function N(O,P,Q,R,S)if not type(P)=="string"then error("Not a String",3)end;local T=type(Q)=="string"and Q:sub(1,1)or j[Q]or error("Wrong Front Color",3)local U=type(R)=="string"and R:sub(1,1)or j[R]or error("Wrong Back Color",3)if m[O]==nil then w(3,false)end;local V=m[O]or error("Wrong font size selected",3)if P==""then return{{""},{""},{""}}end;local W={}for r in P:gmatch('.')do table.insert(W,r)end;local X={}local p=#V[W[1]][1]for Y=1,p do local Z={}for r=1,#W do Z[r]=V[W[r]]and V[W[r]][1][Y]or""end;X[Y]=table.concat(Z)end;local _={}local a0={}local a1={["0"]=T,["1"]=U}local a2={["0"]=U,["1"]=T}for Y=1,p do local a3={}local a4={}for r=1,#W do local a5=V[W[r]]and V[W[r]][2][Y]or""a3[r]=a5:gsub("[01]",S and{["0"]=Q:sub(r,r),["1"]=R:sub(r,r)}or a1)a4[r]=a5:gsub("[01]",S and{["0"]=R:sub(r,r),["1"]=Q:sub(r,r)}or a2)end;_[Y]=table.concat(a3)a0[Y]=table.concat(a4)end;return{X,_,a0}end;local function a6(a7)local a8=a7;local a9,p=a8.getSize()local aa={}local ab={}local ac={}local ad={}local ae={}local af={}local ag;local ah={}local function ai()ag=(" "):rep(a9)for aj=0,15 do local ak=2^aj;local al=j[ak]ah[ak]=al:rep(a9)end end;ai()local function am()local an=ag;local ao=ah[colors.white]local ap=ah[colors.black]for aq=1,p do aa[aq]=i(aa[aq]==nil and an or aa[aq]..an:sub(1,a9-aa[aq]:len()),1,a9)ac[aq]=i(ac[aq]==nil and ao or ac[aq]..ao:sub(1,a9-ac[aq]:len()),1,a9)ab[aq]=i(ab[aq]==nil and ap or ab[aq]..ap:sub(1,a9-ab[aq]:len()),1,a9)end end;am()local function ar(as,at,au)if at>=1 and at<=p then if as+au:len()>0 and as<=a9 then local av=aa[at]local aw;local ax=as+#au-1;if as<1 then local ay=1-as+1;local az=a9-as+1;au=i(au,ay,az)elseif ax>a9 then local az=a9-as+1;au=i(au,1,az)end;if as>1 then local az=as-1;aw=i(av,1,az)..au else aw=au end;if ax=1 and at<=p then if as+aB:len()>0 and as<=a9 then local av=ab[at]local aw;local ax=as+#aB-1;if as<1 then aB=i(aB,1-as+1,a9-as+1)elseif ax>a9 then aB=i(aB,1,a9-as+1)end;if as>1 then aw=i(av,1,as-1)..aB else aw=aB end;if ax=1 and at<=p then if as+aB:len()>0 and as<=a9 then local av=ac[at]local aw;local ax=as+#aB-1;if as<1 then local ay=1-as+1;local az=a9-as+1;aB=i(aB,ay,az)elseif ax>a9 then local az=a9-as+1;aB=i(aB,1,az)end;if as>1 then local az=as-1;aw=i(av,1,az)..aB else aw=aB end;if ax1 then while#bm>2 do table.sort(bm,function(bw,bx)return bw[2]>bx[2]end)local by,bz=bl(bm),#bm;local bA,bB=bm[bz][1],bm[by][1]for r=1,6 do if bq[r]==bA then bq[r]=bB;bm[by][2]=bm[by][2]+1 end end;bm[bz]=nil end;local bC=128;for r=1,#bq-1 do if bq[r]~=bq[6]then bC=bC+2^(r-1)end end;return string.char(bC),bi[bm[1][1]==bq[6]and bm[2][1]or bm[1][1]],bi[bq[6]]else return"\128",bi[bq[1]],bi[bq[1]]end end;local bD,a9,p,aE={{},{},{}},0,#bd+#bd%3,be or colors.black;for r=1,#bd do if#bd[r]>a9 then a9=#bd[r]end end;for at=0,p-1,3 do local bE,bF,bG,bH={},{},{},1;for as=0,a9-1,2 do local bq,br={},{}for bI=1,3 do for bJ=1,2 do bq[#bq+1]=bd[at+bI]and bd[at+bI][as+bJ]and(bd[at+bI][as+bJ]==0 and aE or bd[at+bI][as+bJ])or aE;br[bq[#bq]]=br[bq[#bq]]and br[bq[#bq]]+1 or 1 end end;bE[bH],bF[bH],bG[bH]=bp(bq,br)bH=bH+1 end;bD[1][#bD[1]+1],bD[2][#bD[2]+1],bD[3][#bD[3]+1]=table.concat(bE),table.concat(bF),table.concat(bG)end;bD.width,bD.height=#bD[1][1],#bD[1]return bD end;local function bK(bL)local bM="Object"local aT;local bN=1;local bO="topLeft"local bP=false;local bQ=false;local bR=false;local bS=false;local bT=false;local bU=false;local bV=false;local bW=colors.black;local bX=colors.black;local bY=true;local aV=aL()local bZ={x=1,y=1,width=1,height=1,bgColor=colors.black,fgColor=colors.white,name=bL or"Object",parent=nil,show=function(self)bQ=true;bY=true;return self end,hide=function(self)bQ=false;bY=true;return self end,isVisible=function(self)return bQ end,setFocus=function(self)if self.parent~=nil then self.parent:setFocusedObject(self)end;return self end,setZIndex=function(self,aN)bN=aN;if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end;return self end,getZIndex=function(self)return bN end,getType=function(self)return bM end,getName=function(self)return self.name end,remove=function(self)if self.parent~=nil then self.parent:removeObject(self)end;return self end,setParent=function(self,b_)if b_.getType~=nil and b_:getType()=="Frame"then self:remove()b_:addObject(self)if self.draw then self:show()end end;return self end,setValue=function(self,c0)if aT~=c0 then aT=c0;bY=true;self:valueChangedHandler()end;return self end,getValue=function(self)return aT end,getVisualChanged=function(self)return bY end,setVisualChanged=function(self,c1)bY=c1 or true;if c1==nil then bY=true end;return self end,getEventSystem=function(self)return aV end,getParent=function(self)return self.parent end,setPosition=function(self,c2,c3,c4)if c4 then self.x,self.y=math.floor(self.x+c2),math.floor(self.y+c3)else self.x,self.y=math.floor(c2),math.floor(c3)end;bY=true;return self end,getPosition=function(self)return self.x,self.y end,getVisibility=function(self)return bQ end,setVisibility=function(self,c5)bQ=c5 or not bQ;bY=true;return self end,setSize=function(self,a9,p)self.width,self.height=a9,p;aV:sendEvent("basalt_resize",self)bY=true;return self end,getHeight=function(self)return self.height end,getWidth=function(self)return self.width end,getSize=function(self)return self.width,self.height end,setBackground=function(self,c6)self.bgColor=c6;bY=true;return self end,getBackground=function(self)return self.bgColor end,setForeground=function(self,c6)self.fgColor=c6;bY=true;return self end,getForeground=function(self)return self.fgColor end,showShadow=function(self,c7)bR=c7 or not bR;return self end,setShadow=function(self,c6)bW=c6;return self end,isShadowActive=function(self)return bR end,showBorder=function(self,...)for aS,c8 in pairs(table.pack(...))do if c8=="left"then bS=true end;if c8=="top"then bT=true end;if c8=="right"then bU=true end;if c8=="bottom"then bV=true end end;return self end,setBorder=function(self,c6)bW=c6;return self end,getBorder=function(self,c9)if c9=="left"then return bS end;if c9=="top"then return bT end;if c9=="right"then return bU end;if c9=="bottom"then return bV end end,draw=function(self)if bQ then if self.parent~=nil then local as,at=self:getAnchorPosition()if bR then self.parent:drawBackgroundBox(as+1,at+self.height,self.width,1,bW)self.parent:drawBackgroundBox(as+self.width,at+1,1,self.height,bW)self.parent:drawForegroundBox(as+1,at+self.height,self.width,1,bW)self.parent:drawForegroundBox(as+self.width,at+1,1,self.height,bW)end;if bS then self.parent:drawTextBox(as-1,at,1,self.height,"\149")self.parent:drawForegroundBox(as-1,at,1,self.height,bX)if self.bgColor~=false then self.parent:drawBackgroundBox(as-1,at,1,self.height,self.bgColor)end end;if bS and bT then self.parent:drawTextBox(as-1,at-1,1,1,"\151")self.parent:drawForegroundBox(as-1,at-1,1,1,bX)if self.bgColor~=false then self.parent:drawBackgroundBox(as-1,at-1,1,1,self.bgColor)end end;if bT then self.parent:drawTextBox(as,at-1,self.width,1,"\131")self.parent:drawForegroundBox(as,at-1,self.width,1,bX)if self.bgColor~=false then self.parent:drawBackgroundBox(as,at-1,self.width,1,self.bgColor)end end;if bT and bU then self.parent:drawTextBox(as+self.width,at-1,1,1,"\149")self.parent:drawForegroundBox(as+self.width,at-1,1,1,bX)end;if bU then self.parent:drawTextBox(as+self.width,at,1,self.height,"\149")self.parent:drawForegroundBox(as+self.width,at,1,self.height,bX)end;if bU and bV then self.parent:drawTextBox(as+self.width,at+self.height,1,1,"\129")self.parent:drawForegroundBox(as+self.width,at+self.height,1,1,bX)end;if bV then self.parent:drawTextBox(as,at+self.height,self.width,1,"\131")self.parent:drawForegroundBox(as,at+self.height,self.width,1,bX)end;if bV and bS then self.parent:drawTextBox(as-1,at+self.height,1,1,"\131")self.parent:drawForegroundBox(as-1,at+self.height,1,1,bX)end end;return true end;return false end,getAbsolutePosition=function(self,as,at)if as==nil or at==nil then as,at=self:getAnchorPosition()end;if self.parent~=nil then local ca,cb=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())as=ca+as-1;at=cb+at-1 end;return as,at end,getAnchorPosition=function(self,as,at,cc)if as==nil then as=self.x end;if at==nil then at=self.y end;if bO=="top"then as=math.floor(self.parent.width/2)+as-1 elseif bO=="topRight"then as=self.parent.width+as-1 elseif bO=="right"then as=self.parent.width+as-1;at=math.floor(self.parent.height/2)+at-1 elseif bO=="bottomRight"then as=self.parent.width+as-1;at=self.parent.height+at-1 elseif bO=="bottom"then as=math.floor(self.parent.width/2)+as-1;at=self.parent.height+at-1 elseif bO=="bottomLeft"then at=self.parent.height+at-1 elseif bO=="left"then at=math.floor(self.parent.height/2)+at-1 elseif bO=="center"then as=math.floor(self.parent.width/2)+as-1;at=math.floor(self.parent.height/2)+at-1 end;local cd,ce=self:getOffset()if not(bP or cc)then return as+cd,at+ce end;return as,at end,getOffset=function(self)if self.parent~=nil then return self.parent:getFrameOffset()end;return 0,0 end,ignoreOffset=function(self,cf)bP=cf;if cf==nil then bP=true end;return self end,getBaseFrame=function(self)if self.parent~=nil then return self.parent:getBaseFrame()end;return self end,setAnchor=function(self,cg)bO=cg;bY=true;return self end,getAnchor=function(self)return bO end,onChange=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("value_changed",c8)end end;return self end,onClick=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("mouse_click",c8)self:registerEvent("monitor_touch",c8)end end;return self end,onClickUp=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("mouse_up",c8)end end;return self end,onScroll=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("mouse_scroll",c8)end end;return self end,onDrag=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("mouse_drag",c8)end end;return self end,onEvent=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("custom_event_handler",c8)end end;return self end,onKey=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("key",c8)self:registerEvent("char",c8)end end;return self end,onResize=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("basalt_resize",c8)end end;return self end,onKeyUp=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("key_up",c8)end end;return self end,onBackgroundKey=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("background_key",c8)self:registerEvent("background_char",c8)end end;return self end,onBackgroundKeyUp=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("background_key_up",c8)end end;return self end,isFocused=function(self)if self.parent~=nil then return self.parent:getFocusedObject()==self end;return false end,onGetFocus=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("get_focus",c8)end end;return self end,onLoseFocus=function(self,...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then self:registerEvent("lose_focus",c8)end end;return self end,registerEvent=function(self,aO,aQ)return aV:registerEvent(aO,aQ)end,removeEvent=function(self,aO,aN)return aV:removeEvent(aO,aN)end,sendEvent=function(self,aO,...)return aV:sendEvent(aO,self,...)end,mouseHandler=function(self,aO,ch,as,at)local ci,cj=self:getAbsolutePosition(self:getAnchorPosition())local ck=false;if cj-1==at and self:getBorder("top")then at=at+1;ck=true end;if ci<=as and ci+self.width>as and cj<=at and cj+self.height>at and bQ then if self.parent~=nil then self.parent:setFocusedObject(self)end;local aU=aV:sendEvent(aO,self,aO,ch,as,at)if aU~=nil then return aU end;return true end;return false end,keyHandler=function(self,aO,bv)if self:isFocused()then local aU=aV:sendEvent(aO,self,aO,bv)if aU~=nil then return aU end;return true end;return false end,backgroundKeyHandler=function(self,aO,bv)local aU=aV:sendEvent("background_"..aO,self,aO,bv)if aU~=nil then return aU end;return true end,valueChangedHandler=function(self)aV:sendEvent("value_changed",self)end,eventHandler=function(self,aO,cl,cm,cn,co)aV:sendEvent("custom_event_handler",self,aO,cl,cm,cn,co)end,getFocusHandler=function(self)local aU=aV:sendEvent("get_focus",self)if aU~=nil then return aU end;return true end,loseFocusHandler=function(self)local aU=aV:sendEvent("lose_focus",self)if aU~=nil then return aU end;return true end}bZ.__index=bZ;return bZ end;local function cp(bL)local bZ={}local bM="Animation"local cq;local cr={}local aN=1;local cs=0;local ct;local function cu()if cr[aN]~=nil then cr[aN].f(bZ,aN)end;aN=aN+1;if cr[aN]~=nil then if cr[aN].t>0 then cq=os.startTimer(cr[aN].t)else cu()end end end;bZ={name=bL,getType=function(self)return bM end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,aQ,cv)ct=aQ;table.insert(cr,{f=aQ,t=cv or cs})return self end,wait=function(self,cv)cs=cv;return self end,rep=function(self,cw)for as=1,cw do table.insert(cr,{f=ct,t=cs})end;return self end,clear=function(self)cr={}ct=nil;cs=0;aN=1;return self end,play=function(self)aN=1;if cr[aN]~=nil then if cr[aN].t>0 then cq=os.startTimer(cr[aN].t)else cu()end end;return self end,cancel=function(self)os.cancelTimer(cq)return self end,eventHandler=function(self,aO,cx)if aO=="timer"and cx==cq then if cr[aN]~=nil then cu()end end end}bZ.__index=bZ;return bZ end;local function cy(bL)local cz=bK(bL)local bM="Button"cz:setValue("Button")cz:setZIndex(5)cz.width=8;cz.bgColor=k.ButtonBG;cz.fgColor=k.ButtonFG;local cA="center"local cB="center"local bZ={getType=function(self)return bM end,setHorizontalAlign=function(self,cC)cA=cC end,setVerticalAlign=function(self,cC)cB=cC end,setText=function(self,au)cz:setValue(au)return self end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()local cF=b8(self.height,cB)if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)self.parent:drawTextBox(cD,cE,self.width,self.height," ")end;if self.fgColor~=false then self.parent:drawForegroundBox(cD,cE,self.width,self.height,self.fgColor)end;for aj=1,self.height do if aj==cF then self.parent:setText(cD,cE+aj-1,b4(self:getValue(),self.width,cA))end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function cG(bL)local cz=bK(bL)local bM="Checkbox"cz:setZIndex(5)cz:setValue(false)cz.width=1;cz.height=1;cz.bgColor=k.CheckboxBG;cz.fgColor=k.CheckboxFG;local bZ={symbol="\42",getType=function(self)return bM end,mouseHandler=function(self,aO,ch,as,at)if cz.mouseHandler(self,aO,ch,as,at)then if aO=="mouse_click"and ch==1 or aO=="monitor_touch"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 cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()local cF=b8(self.height,"center")if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)end;for aj=1,self.height do if aj==cF then if self:getValue()==true then self.parent:writeText(cD,cE+aj-1,b4(self.symbol,self.width,"center"),self.bgColor,self.fgColor)else self.parent:writeText(cD,cE+aj-1,b4(" ",self.width,"center"),self.bgColor,self.fgColor)end end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function cH(bL)local cz=bK(bL)local bM="Dropdown"cz.width=12;cz.height=1;cz.bgColor=k.dropdownBG;cz.fgColor=k.dropdownFG;cz:setZIndex(6)local cI={}local cJ=k.selectionBG;local cK=k.selectionFG;local cL=true;local cM="left"local cN=0;local cO=16;local cP=6;local cQ="\16"local cR="\31"local cS=false;local bZ={getType=function(self)return bM end,setIndexOffset=function(self,ck)cN=ck;return self end,getIndexOffset=function(self)return cN end,addItem=function(self,au,aE,aF,...)table.insert(cI,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,getAll=function(self)return cI end,removeItem=function(self,aN)table.remove(cI,aN)return self end,getItem=function(self,aN)return cI[aN]end,getItemIndex=function(self)local cT=self:getValue()for bv,aT in pairs(cI)do if aT==cT then return bv end end end,clear=function(self)cI={}self:setValue({})return self end,getItemCount=function(self)return#cI end,editItem=function(self,aN,au,aE,aF,...)table.remove(cI,aN)table.insert(cI,aN,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cI[aN]or{})return self end,setSelectedItem=function(self,aE,aF,cU)cJ=aE or self.bgColor;cK=aF or self.fgColor;cL=cU;return self end,setDropdownSize=function(self,a9,p)cO,cP=a9,p;return self end,mouseHandler=function(self,aO,ch,as,at)if cS then local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if aO=="mouse_click"and ch==1 or aO=="monitor_touch"then if#cI>0 then for aj=1,cP do if cI[aj+cN]~=nil then if cD<=as and cD+cO>as and cE+aj==at then self:setValue(cI[aj+cN])return true end end end end end;if aO=="mouse_scroll"then cN=cN+ch;if cN<0 then cN=0 end;if ch==1 then if#cI>cP then if cN>#cI-cP then cN=#cI-cP end else cN=cI-1 end end;return true end;self:setVisualChanged()end;if cz.mouseHandler(self,aO,ch,as,at)then cS=true else cS=false end end,draw=function(self)if cz.draw(self)then local cD,cE=self:getAnchorPosition()if self.parent~=nil then if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)end;local aU=self:getValue()local au=b4(aU~=nil and aU.text or"",self.width,cM):sub(1,self.width-1)..(cS and cR or cQ)self.parent:writeText(cD,cE,au,self.bgColor,self.fgColor)if cS then for aj=1,cP do if cI[aj+cN]~=nil then if cI[aj+cN]==aU then if cL then self.parent:writeText(cD,cE+aj,b4(cI[aj+cN].text,cO,cM),cJ,cK)else self.parent:writeText(cD,cE+aj,b4(cI[aj+cN].text,cO,cM),cI[aj+cN].bgCol,cI[aj+cN].fgCol)end else self.parent:writeText(cD,cE+aj,b4(cI[aj+cN].text,cO,cM),cI[aj+cN].bgCol,cI[aj+cN].fgCol)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function cV(bL)local cz=bK(bL)local bM="Image"cz:setZIndex(2)local cW;local cX;local cY=false;local function bc()local bf={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local bg,bh,bi={},{},{}for r=0,15 do bh[2^r]=r end;do local bj="0123456789abcdef"for r=1,16 do bg[bj:sub(r,r)]=r-1;bg[r-1]=bj:sub(r,r)bi[bj:sub(r,r)]=2^(r-1)bi[2^(r-1)]=bj:sub(r,r)local bk=bf[r-1]for r=1,#bk do bk[r]=2^bk[r]end end end;local function bl(bm)local bn=bf[bh[bm[#bm][1]]]for s=1,#bn do local bo=bn[s]for r=1,#bm-1 do if bm[r][1]==bo then return r end end end;return 1 end;local function bp(bq,br)if not br then local bs={}br={}for r=1,6 do local bt=bq[r]local bu=br[bt]br[bt],bs[r]=bu and bu+1 or 1,bt end;bq=bs end;local bm={}for bv,aT in pairs(br)do bm[#bm+1]={bv,aT}end;if#bm>1 then while#bm>2 do table.sort(bm,function(bw,bx)return bw[2]>bx[2]end)local by,bz=bl(bm),#bm;local bA,bB=bm[bz][1],bm[by][1]for r=1,6 do if bq[r]==bA then bq[r]=bB;bm[by][2]=bm[by][2]+1 end end;bm[bz]=nil end;local bC=128;for r=1,#bq-1 do if bq[r]~=bq[6]then bC=bC+2^(r-1)end end;return string.char(bC),bi[bm[1][1]==bq[6]and bm[2][1]or bm[1][1]],bi[bq[6]]else return"\128",bi[bq[1]],bi[bq[1]]end end;local bD,a9,p,aE={{},{},{}},0,#cW+#cW%3,cz.bgColor or colors.black;for r=1,#cW do if#cW[r]>a9 then a9=#cW[r]end end;for at=0,p-1,3 do local bE,bF,bG,bH={},{},{},1;for as=0,a9-1,2 do local bq,br={},{}for bI=1,3 do for bJ=1,2 do bq[#bq+1]=cW[at+bI]and cW[at+bI][as+bJ]and(cW[at+bI][as+bJ]==0 and aE or cW[at+bI][as+bJ])or aE;br[bq[#bq]]=br[bq[#bq]]and br[bq[#bq]]+1 or 1 end end;bE[bH],bF[bH],bG[bH]=bp(bq,br)bH=bH+1 end;bD[1][#bD[1]+1],bD[2][#bD[2]+1],bD[3][#bD[3]+1]=table.concat(bE),table.concat(bF),table.concat(bG)end;bD.width,bD.height=#bD[1][1],#bD[1]cX=bD end;local bZ={getType=function(self)return bM end,loadImage=function(self,aZ)cW=paintutils.loadImage(aZ)cY=false;return self end,loadBlittleImage=function(self,aZ)return self end,shrink=function(self)bc()cY=true;return self end,draw=function(self)if cz.draw(self)then if self.parent~=nil then if cW~=nil then local cD,cE=self:getAnchorPosition()if cY then local bb,cZ,c_=cX[1],cX[2],cX[3]for r=1,cX.height do local d0=bb[r]if type(d0)=="string"then self.parent:setText(cD,cE+r-1,d0)self.parent:setFG(cD,cE+r-1,cZ[r])self.parent:setBG(cD,cE+r-1,c_[r])elseif type(d0)=="table"then self.parent:setText(cD,cE+r-1,d0[2])self.parent:setFG(cD,cE+r-1,cZ[r])self.parent:setBG(cD,cE+r-1,c_[r])end end else for c3=1,math.min(#cW,self.height)do local d1=cW[c3]for c2=1,math.min(#d1,self.width)do if d1[c2]>0 then self.parent:drawBackgroundBox(cD+c2-1,cE+c3-1,1,1,d1[c2])end end end end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function d2(bL)local cz=bK(bL)local bM="Input"local d3="text"local d4=0;cz:setZIndex(5)cz:setValue("")cz.width=10;cz.height=1;cz.bgColor=k.InputBG;cz.fgColor=k.InputFG;local d5=1;local d6=1;local d7=""local d8;local d9;local da=d7;local db=false;local bZ={getType=function(self)return bM end,setInputType=function(self,dc)if dc=="password"or dc=="number"or dc=="text"then d3=dc end;return self end,setDefaultText=function(self,au,dd,de)d7=au;d8=de or d8;d9=dd or d9;if self:isFocused()then da=""else da=d7 end;return self end,getInputType=function(self)return d3 end,setValue=function(self,aU)cz.setValue(self,tostring(aU))if not db then d5=tostring(aU):len()+1 end;return self end,getValue=function(self)local aU=cz.getValue(self)return d3=="number"and tonumber(aU)or aU end,setInputLimit=function(self,df)d4=tonumber(df)or d4;return self end,getInputLimit=function(self)return d4 end,getFocusHandler=function(self)cz.getFocusHandler(self)if self.parent~=nil then local cD,cE=self:getAnchorPosition()da=""if self.parent~=nil then self.parent:setCursor(true,cD+d5-d6,cE+math.floor(self.height/2),self.fgColor)end end end,loseFocusHandler=function(self)cz.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)da=d7 end end,keyHandler=function(self,aO,bv)if cz.keyHandler(self,aO,bv)then db=true;if aO=="key"then if bv==keys.backspace then local au=tostring(cz.getValue())if d5>1 then self:setValue(au:sub(1,d5-2)..au:sub(d5,au:len()))if d5>1 then d5=d5-1 end;if d6>1 then if d5dg then d5=dg+1 end;if d5<1 then d5=1 end;if d5=self.width+d6 then d6=d5-self.width+1 end;if d6<1 then d6=1 end end;if bv==keys.left then d5=d5-1;if d5>=1 then if d5=self.width+d6 then d6=d5 end end;if d5<1 then d5=1 end;if d6<1 then d6=1 end end end;if aO=="char"then local au=cz.getValue()if au:len()=self.width+d6 then d6=d6+1 end end end;local cD,cE=self:getAnchorPosition()local aU=tostring(cz.getValue())local di=(d5<=aU:len()and d5-1 or aU:len())-(d6-1)if di>self.x+self.width-1 then di=self.x+self.width-1 end;if self.parent~=nil then self.parent:setCursor(true,cD+di,cE+math.floor(self.height/2),self.fgColor)end;db=false end end,mouseHandler=function(self,aO,ch,as,at)if cz.mouseHandler(self,aO,ch,as,at)then if aO=="mouse_click"and ch==1 then end;return true end;return false end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()local cF=b8(self.height,"center")if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)end;for aj=1,self.height do if aj==cF then local aU=tostring(cz.getValue())local de=self.bgColor;local dd=self.fgColor;local au;if aU:len()<=0 then au=da;de=d8 or de;dd=d9 or dd end;au=da;if aU~=""then au=aU end;au=au:sub(d6,self.width+d6-1)local dj=self.width-au:len()if dj<0 then dj=0 end;if d3=="password"and aU~=""then au=string.rep("*",au:len())end;au=au..string.rep(" ",dj)self.parent:writeText(cD,cE+aj-1,au,de,dd)end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function dk(bL)local cz=bK(bL)local bM="Label"cz:setZIndex(3)cz.fgColor=colors.white;cz.bgcolor=colors.black;local dl=true;cz:setValue("")local cA="left"local cB="top"local dm=0;local bZ={getType=function(self)return bM end,setText=function(self,au)au=tostring(au)cz:setValue(au)if dl then self.width=au:len()end;return self end,setTextAlign=function(self,dn,dp)cA=dn or cA;cB=dp or cB;self:setVisualChanged()return self end,setFontSize=function(self,x)if x>0 and x<=4 then dm=x-1 or 0 end;return self end,getFontSize=function(self)return dm+1 end,setSize=function(self,a9,p)cz.setSize(self,a9,p)dl=false;self:setVisualChanged()return self end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()local cF=b8(self.height,cB)if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)self.parent:drawTextBox(cD,cE,self.width,self.height," ")end;if self.fgColor~=false then self.parent:drawForegroundBox(cD,cE,self.width,self.height,self.fgColor)end;if dm==0 then for aj=1,self.height do if aj==cF then self.parent:setText(cD,cE+aj-1,b4(self:getValue(),self.width,cA))end end else local dq=N(dm,self:getValue(),self.fgColor,self.bgColor or colors.black)if dl then self.height=#dq[1]-1;self.width=#dq[1][1]end;for aj=1,self.height do if aj==cF then local dr,ds=self.parent:getSize()local dt,du=#dq[1][1],#dq[1]cD=cD or math.floor((dr-dt)/2)+1;cE=cE or math.floor((ds-du)/2)+1;for r=1,du do self.parent:setFG(cD,cE+r+aj-2,b4(dq[2][r],self.width,cA))self.parent:setBG(cD,cE+r+aj-2,b4(dq[3][r],self.width,cA,j[self.bgColor or colors.black]))self.parent:setText(cD,cE+r+aj-2,b4(dq[1][r],self.width,cA))end end end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function dv(bL)local cz=bK(bL)local bM="List"cz.width=16;cz.height=6;cz.bgColor=k.listBG;cz.fgColor=k.listFG;cz:setZIndex(5)local cI={}local cJ=k.selectionBG;local cK=k.selectionFG;local cL=true;local cM="left"local cN=0;local dw=true;local bZ={getType=function(self)return bM end,addItem=function(self,au,aE,aF,...)table.insert(cI,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})if#cI==1 then self:setValue(cI[1])end;return self end,setIndexOffset=function(self,ck)cN=ck;return self end,getIndexOffset=function(self)return cN end,removeItem=function(self,aN)table.remove(cI,aN)return self end,getItem=function(self,aN)return cI[aN]end,getAll=function(self)return cI end,getItemIndex=function(self)local cT=self:getValue()for bv,aT in pairs(cI)do if aT==cT then return bv end end end,clear=function(self)cI={}self:setValue({})return self end,getItemCount=function(self)return#cI end,editItem=function(self,aN,au,aE,aF,...)table.remove(cI,aN)table.insert(cI,aN,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cI[aN]or{})return self end,setSelectedItem=function(self,aE,aF,cU)cJ=aE or self.bgColor;cK=aF or self.fgColor;cL=cU;return self end,setScrollable=function(self,dx)dw=dx;return self end,mouseHandler=function(self,aO,ch,as,at)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if cD<=as and cD+self.width>as and cE<=at and cE+self.height>at and self:isVisible()then if(aO=="mouse_click"or aO=="mouse_drag")and ch==1 or aO=="monitor_touch"then if#cI>0 then for aj=1,self.height do if cI[aj+cN]~=nil then if cD<=as and cD+self.width>as and cE+aj-1==at then self:setValue(cI[aj+cN])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,as,at,cI[aj+cN])end end end end end;if aO=="mouse_scroll"and dw then cN=cN+ch;if cN<0 then cN=0 end;if ch>=1 then if#cI>self.height then if cN>#cI-self.height then cN=#cI-self.height end;if cN>=#cI then cN=#cI-1 end else cN=cN-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)end;for aj=1,self.height do if cI[aj+cN]~=nil then if cI[aj+cN]==self:getValue()then if cL then self.parent:writeText(cD,cE+aj-1,b4(cI[aj+cN].text,self.width,cM),cJ,cK)else self.parent:writeText(cD,cE+aj-1,b4(cI[aj+cN].text,self.width,cM),cI[aj+cN].bgCol,cI[aj+cN].fgCol)end else self.parent:writeText(cD,cE+aj-1,b4(cI[aj+cN].text,self.width,cM),cI[aj+cN].bgCol,cI[aj+cN].fgCol)end end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function dy(bL)local cz=bK(bL)local bM="Menubar"local bZ={}cz.width=30;cz.height=1;cz.bgColor=colors.gray;cz.fgColor=colors.lightGray;cz:setZIndex(5)local cI={}local cJ=k.selectionBG;local cK=k.selectionFG;local cL=true;local cM="left"local dz=0;local dj=1;local dw=false;local function dA()local dB=0;local c2=0;for aj=1,#cI do if c2+cI[aj].text:len()+dj*2>bZ.width then if c2dB then dz=dB end;return self end,getPositionOffset=function(self)return dz end,setScrollable=function(self,dx)dw=dx;if dx==nil then dw=true end;return self end,removeItem=function(self,aN)table.remove(cI,aN)return self end,getItem=function(self,aN)return cI[aN]end,getItemCount=function(self)return#cI end,editItem=function(self,aN,au,aE,aF,...)table.remove(cI,aN)table.insert(cI,aN,{text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cI[aN]or{})return self end,setSelectedItem=function(self,aE,aF,cU)cJ=aE or self.bgColor;cK=aF or self.fgColor;cL=cU;return self end,mouseHandler=function(self,aO,ch,as,at)if cz.mouseHandler(self,aO,ch,as,at)then local ci,cj=self:getAbsolutePosition(self:getAnchorPosition())if ci<=as and ci+self.width>as and cj<=at and cj+self.height>at and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if aO=="mouse_click"or aO=="monitor_touch"then local c2=0;for aj=1,#cI do if cI[aj]~=nil then if ci+c2<=as+dz and ci+c2+cI[aj].text:len()+dj*2>as+dz and cj==at then self:setValue(cI[aj])self:getEventSystem():sendEvent(aO,self,aO,0,as,at,cI[aj])end;c2=c2+cI[aj].text:len()+dj*2 end end end;if aO=="mouse_scroll"and dw then dz=dz+ch;if dz<0 then dz=0 end;local dB=dA()if dz>dB then dz=dB end end;self:setVisualChanged(true)return true end end;return false end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)end;local au=""local dD=""local dE=""for aS,c8 in pairs(cI)do local dF=(" "):rep(dj)..c8.text..(" "):rep(dj)au=au..dF;if c8==self:getValue()then dD=dD..j[cJ or c8.bgCol or self.bgColor]:rep(dF:len())dE=dE..j[cK or c8.FgCol or self.fgColor]:rep(dF:len())else dD=dD..j[c8.bgCol or self.bgColor]:rep(dF:len())dE=dE..j[c8.FgCol or self.fgColor]:rep(dF:len())end end;self.parent:setText(cD,cE,au:sub(dz+1,self.width+dz))self.parent:setBG(cD,cE,dD:sub(dz+1,self.width+dz))self.parent:setFG(cD,cE,dE:sub(dz+1,self.width+dz))end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function dG(bL)local cz=bK(bL)local bM="Pane"local bZ={getType=function(self)return bM end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cD,cE,self.width,self.height,self.bgColor)end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function dH(bL)local cz=bK(bL)local bM="Program"cz:setZIndex(5)local bZ;local function dI(as,at,a9,p)local dJ,dK=1,1;local be,dL=colors.black,colors.white;local dM=false;local dN=false;local aa={}local ab={}local ac={}local dO={}local ag;local ah={}for r=0,15 do local dP=2^r;dO[dP]={h.getPaletteColour(dP)}end;local function ai()ag=(" "):rep(a9)for aj=0,15 do local ak=2^aj;local al=j[ak]ah[ak]=al:rep(a9)end end;local function am()ai()local an=ag;local ao=ah[colors.white]local ap=ah[colors.black]for aj=1,p do aa[aj]=i(aa[aj]==nil and an or aa[aj]..an:sub(1,a9-aa[aj]:len()),1,a9)ac[aj]=i(ac[aj]==nil and ao or ac[aj]..ao:sub(1,a9-ac[aj]:len()),1,a9)ab[aj]=i(ab[aj]==nil and ap or ab[aj]..ap:sub(1,a9-ab[aj]:len()),1,a9)end end;am()local function dQ()if dJ>=1 and dK>=1 and dJ<=a9 and dK<=p then else end end;local function dR(dS,dT,dU)local dV=dJ;local ax=dV+#dS-1;if dK>=1 and dK<=p then if dV<=a9 and ax>=1 then if dV==1 and ax==a9 then aa[dK]=dS;ac[dK]=dT;ab[dK]=dU else local dW,dX,dY;if dV<1 then local dZ=1-dV+1;local d_=a9-dV+1;dW=i(dS,dZ,d_)dX=i(dT,dZ,d_)dY=i(dU,dZ,d_)elseif ax>a9 then local d_=a9-dV+1;dW=i(dS,1,d_)dX=i(dT,1,d_)dY=i(dU,1,d_)else dW=dS;dX=dT;dY=dU end;local e0=aa[dK]local e1=ac[dK]local e2=ab[dK]local e3,e4,e5;if dV>1 then local e6=dV-1;e3=i(e0,1,e6)..dW;e4=i(e1,1,e6)..dX;e5=i(e2,1,e6)..dY else e3=dW;e4=dX;e5=dY end;if ax=1 and at<=p then aa[et]=aa[at]ab[et]=ab[at]ac[et]=ac[at]else aa[et]=eq;ac[et]=er;ab[et]=es end end end;if dN then dQ()end end,isColor=function()return h.isColor()end,isColour=function()return h.isColor()end,write=function(au)au=tostring(au)if dN then dR(au,j[dL]:rep(au:len()),j[be]:rep(au:len()))end end,clearLine=function()if dN then ar(1,dK,(" "):rep(a9))aA(1,dK,j[be]:rep(a9))aC(1,dK,j[dL]:rep(a9))end;if dN then dQ()end end,clear=function()for aj=1,p do ar(1,aj,(" "):rep(a9))aA(1,aj,j[be]:rep(a9))aC(1,aj,j[dL]:rep(a9))end;if dN then dQ()end end,blit=function(au,eu,ev)if type(au)~="string"then error("bad argument #1 (expected string, got "..type(au)..")",2)end;if type(eu)~="string"then error("bad argument #2 (expected string, got "..type(eu)..")",2)end;if type(ev)~="string"then error("bad argument #3 (expected string, got "..type(ev)..")",2)end;if#eu~=#au or#ev~=#au then error("Arguments must be the same length",2)end;if dN then dR(au,eu,ev)end end}return el end;cz.width=30;cz.height=12;local ew=dI(1,1,cz.width,cz.height)local ex;local ey=false;local ez={}bZ={getType=function(self)return bM end,show=function(self)cz.show(self)ew.setBackgroundColor(self.bgColor)ew.setTextColor(self.fgColor)ew.basalt_setVisible(true)return self end,hide=function(self)cz.hide(self)ew.basalt_setVisible(false)return self end,setPosition=function(self,as,at,c4)cz.setPosition(self,as,at,c4)ew.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return ew end,getBasaltProcess=function()return ex end,setSize=function(self,a9,p)cz.setSize(self,a9,p)ew.basalt_resize(self.width,self.height)return self end,getStatus=function(self)if ex~=nil then return ex:getStatus()end;return"inactive"end,execute=function(self,aZ,...)ex=aX:new(aZ,ew,...)ew.setBackgroundColor(colors.black)ew.setTextColor(colors.white)ew.clear()ew.setCursorPos(1,1)ex:resume()ey=false;return self end,stop=function(self)if ex~=nil then if not ex:isDead()then ex:resume("terminate")if ex:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,eA)ey=eA or not ey;if ex~=nil then if not ex:isDead()then if not ey then self:injectEvents(ez)ez={}end end end;return self end,isPaused=function(self)return ey end,injectEvent=function(self,aO,cl,cm,cn,co,eB)if ex~=nil then if not ex:isDead()then if ey==false or eB then ex:resume(aO,cl,cm,cn,co)else table.insert(ez,{event=aO,args={cl,cm,cn,co}})end end end;return self end,getQueuedEvents=function(self)return ez end,updateQueuedEvents=function(self,aM)ez=aM or ez;return self end,injectEvents=function(self,aM)if ex~=nil then if not ex:isDead()then for aS,aT in pairs(aM)do ex:resume(aT.event,table.unpack(aT.args))end end end;return self end,mouseHandler=function(self,aO,ch,as,at)if cz.mouseHandler(self,aO,ch,as,at)then if ex==nil then return false end;if not ex:isDead()then if not ey then local eC,eD=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))ex:resume(aO,ch,as-(eC-1),at-(eD-1))a.debug(aO,ch,as-(eC-1),at-(eD-1))end end;return true end end,keyHandler=function(self,aO,bv)cz.keyHandler(self,aO,bv)if self:isFocused()then if ex==nil then return false end;if not ex:isDead()then if not ey then if self.draw then ex:resume(aO,bv)end end end end end,getFocusHandler=function(self)cz.getFocusHandler(self)if ex~=nil then if not ex:isDead()then if not ey then if self.parent~=nil then local eE,eF=ew.getCursorPos()local cD,cE=self:getAnchorPosition()if self.parent~=nil then if cD+eE-1>=1 and cD+eE-1<=cD+self.width-1 and eF+cE-1>=1 and eF+cE-1<=cE+self.height-1 then self.parent:setCursor(ew.getCursorBlink(),cD+eE-1,eF+cE-1,ew.getTextColor())end end end end end end end,loseFocusHandler=function(self)cz.loseFocusHandler(self)if ex~=nil then if not ex:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,aO,cl,cm,cn,co)if ex==nil then return end;if not ex:isDead()then if not ey then if aO~="mouse_click"and aO~="monitor_touch"and aO~="mouse_up"and aO~="mouse_scroll"and aO~="mouse_drag"and aO~="key_up"and aO~="key"and aO~="char"and aO~="terminate"then ex:resume(aO,cl,cm,cn,co)end;if self:isFocused()then local cD,cE=self:getAnchorPosition()local eE,eF=ew.getCursorPos()if self.parent~=nil then if cD+eE-1>=1 and cD+eE-1<=cD+self.width-1 and eF+cE-1>=1 and eF+cE-1<=cE+self.height-1 then self.parent:setCursor(ew.getCursorBlink(),cD+eE-1,eF+cE-1,ew.getTextColor())end end;if aO=="terminate"and self:isFocused()then self:stop()end end else if aO~="mouse_click"and aO~="monitor_touch"and aO~="mouse_up"and aO~="mouse_scroll"and aO~="mouse_drag"and aO~="key_up"and aO~="key"and aO~="char"and aO~="terminate"then table.insert(ez,{event=aO,args={cl,cm,cn,co}})end end end end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()ew.basalt_reposition(cD,cE)if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)end;ew.basalt_update()end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function eG(bL)local cz=bK(bL)local bM="Progressbar"local eH=0;cz:setZIndex(5)cz:setValue(false)cz.width=25;cz.height=1;cz.bgColor=k.CheckboxBG;cz.fgColor=k.CheckboxFG;local eI=colors.black;local eJ=""local eK=colors.white;local eL=""local eM=0;local bZ={getType=function(self)return bM end,setDirection=function(self,eN)eM=eN;return self end,setProgressBar=function(self,c6,aG,eO)eI=c6 or eI;eJ=aG or eJ;eK=eO or eK;return self end,setBackgroundSymbol=function(self,aG)eL=aG:sub(1,1)return self end,setProgress=function(self,aT)if aT>=0 and aT<=100 and eH~=aT then eH=aT;self:setValue(eH)if eH==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return eH end,onProgressDone=function(self,A)self:registerEvent("progress_done",A)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done",self)end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)self.parent:drawForegroundBox(cD,cE,self.width,self.height,self.fgColor)self.parent:drawTextBox(cD,cE,self.width,self.height,eL)if eM==1 then self.parent:drawBackgroundBox(cD,cE,self.width,self.height/100*eH,eI)self.parent:drawForegroundBox(cD,cE,self.width,self.height/100*eH,eK)self.parent:drawTextBox(cD,cE,self.width,self.height/100*eH,eJ)elseif eM==2 then self.parent:drawBackgroundBox(cD,cE+math.ceil(self.height-self.height/100*eH),self.width,self.height/100*eH,eI)self.parent:drawForegroundBox(cD,cE+math.ceil(self.height-self.height/100*eH),self.width,self.height/100*eH,eK)self.parent:drawTextBox(cD,cE+math.ceil(self.height-self.height/100*eH),self.width,self.height/100*eH,eJ)elseif eM==3 then self.parent:drawBackgroundBox(cD+math.ceil(self.width-self.width/100*eH),cE,self.width/100*eH,self.height,eI)self.parent:drawForegroundBox(cD+math.ceil(self.width-self.width/100*eH),cE,self.width/100*eH,self.height,eK)self.parent:drawTextBox(cD+math.ceil(self.width-self.width/100*eH),cE,self.width/100*eH,self.height,eJ)else self.parent:drawBackgroundBox(cD,cE,self.width/100*eH,self.height,eI)self.parent:drawForegroundBox(cD,cE,self.width/100*eH,self.height,eK)self.parent:drawTextBox(cD,cE,self.width/100*eH,self.height,eJ)end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function eP(bL)local cz=bK(bL)local bM="Radio"cz.width=8;cz.bgColor=k.listBG;cz.fgColor=k.listFG;cz:setZIndex(5)local cI={}local cJ=k.selectionBG;local cK=k.selectionFG;local eQ=cz.bgColor;local eR=cz.fgColor;local cL=true;local aG="\7"local cM="left"local bZ={getType=function(self)return bM end,addItem=function(self,au,as,at,aE,aF,...)table.insert(cI,{x=as or 1,y=at or 1,text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})if#cI==1 then self:setValue(cI[1])end;return self end,getAll=function(self)return cI end,removeItem=function(self,aN)table.remove(cI,aN)return self end,getItem=function(self,aN)return cI[aN]end,getItemIndex=function(self)local cT=self:getValue()for bv,aT in pairs(cI)do if aT==cT then return bv end end end,clear=function(self)cI={}self:setValue({})return self end,getItemCount=function(self)return#cI end,editItem=function(self,aN,au,as,at,aE,aF,...)table.remove(cI,aN)table.insert(cI,aN,{x=as or 1,y=at or 1,text=au,bgCol=aE or self.bgColor,fgCol=aF or self.fgColor,args={...}})return self end,selectItem=function(self,aN)self:setValue(cI[aN]or{})return self end,setSelectedItem=function(self,aE,aF,eS,eT,cU)cJ=aE or cJ;cK=aF or cK;eQ=eS or eQ;eR=eT or eR;cL=cU;return self end,mouseHandler=function(self,aO,ch,as,at)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if aO=="mouse_click"and ch==1 or aO=="monitor_touch"then if#cI>0 then for aS,aT in pairs(cI)do if cD+aT.x-1<=as and cD+aT.x-1+aT.text:len()+2>=as and cE+aT.y-1==at then self:setValue(aT)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end;return false end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()for aS,aT in pairs(cI)do if aT==self:getValue()then if cM=="left"then self.parent:writeText(aT.x+cD-1,aT.y+cE-1,aG,eQ,eR)self.parent:writeText(aT.x+2+cD-1,aT.y+cE-1,aT.text,cJ,cK)end else self.parent:drawBackgroundBox(aT.x+cD-1,aT.y+cE-1,1,1,self.bgColor)self.parent:writeText(aT.x+2+cD-1,aT.y+cE-1,aT.text,aT.bgCol,aT.fgCol)end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function eU(bL)local cz=bK(bL)local bM="Scrollbar"cz.width=1;cz.height=8;cz.bgColor=colors.lightGray;cz.fgColor=colors.gray;cz:setValue(1)cz:setZIndex(2)local eV="vertical"local aG=" "local eW=colors.black;local eX="\127"local eY=cz.height;local aN=1;local eZ=1;local bZ={getType=function(self)return bM end,setSymbol=function(self,e_)aG=e_:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,x)eZ=tonumber(x)or 1;if eV=="vertical"then self:setValue(aN-1*eY/(self.height-(eZ-1))-eY/(self.height-(eZ-1)))elseif eV=="horizontal"then self:setValue(aN-1*eY/(self.width-(eZ-1))-eY/(self.width-(eZ-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,aU)eY=aU;return self end,setBackgroundSymbol=function(self,f0)eX=string.sub(f0,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,f1)eW=f1;self:setVisualChanged()return self end,setBarType=function(self,f2)eV=f2:lower()return self end,mouseHandler=function(self,aO,ch,as,at)if cz.mouseHandler(self,aO,ch,as,at)then local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if(aO=="mouse_click"or aO=="mouse_drag")and ch==1 or aO=="monitor_touch"then if eV=="horizontal"then for f3=0,self.width do if cD+f3==as and cE<=at and cE+self.height>at then aN=math.min(f3+1,self.width-(eZ-1))self:setValue(eY/self.width*aN)self:setVisualChanged()end end end;if eV=="vertical"then for f3=0,self.height do if cE+f3==at and cD<=as and cD+self.width>as then aN=math.min(f3+1,self.height-(eZ-1))self:setValue(eY/self.height*aN)self:setVisualChanged()end end end end;if aO=="mouse_scroll"then aN=aN+ch;if aN<1 then aN=1 end;aN=math.min(aN,(eV=="vertical"and self.height or self.width)-(eZ-1))self:setValue(eY/(eV=="vertical"and self.height or self.width)*aN)end;return true end end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()if eV=="horizontal"then self.parent:writeText(cD,cE,eX:rep(aN-1),self.bgColor,self.fgColor)self.parent:writeText(cD+aN-1,cE,aG:rep(eZ),eW,eW)self.parent:writeText(cD+aN+eZ-1,cE,eX:rep(self.width-(aN+eZ-1)),self.bgColor,self.fgColor)end;if eV=="vertical"then for aj=0,self.height-1 do if aN==aj+1 then for f4=0,math.min(eZ-1,self.height)do self.parent:writeText(cD,cE+aj+f4,aG,eW,eW)end else if aj+1aN-1+eZ then self.parent:writeText(cD,cE+aj,eX,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function f5(bL)local cz=bK(bL)local bM="Slider"cz.width=8;cz.height=1;cz.bgColor=colors.lightGray;cz.fgColor=colors.gray;cz:setValue(1)local eV="horizontal"local aG=" "local eW=colors.black;local eX="\140"local eY=cz.width;local aN=1;local eZ=1;local bZ={getType=function(self)return bM end,setSymbol=function(self,e_)aG=e_:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,x)eZ=tonumber(x)or 1;if eV=="vertical"then self:setValue(aN-1*eY/(self.height-(eZ-1))-eY/(self.height-(eZ-1)))elseif eV=="horizontal"then self:setValue(aN-1*eY/(self.width-(eZ-1))-eY/(self.width-(eZ-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,aU)eY=aU;return self end,setBackgroundSymbol=function(self,f0)eX=string.sub(f0,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,f1)eW=f1;self:setVisualChanged()return self end,setBarType=function(self,f2)eV=f2:lower()return self end,mouseHandler=function(self,aO,ch,as,at)if cz.mouseHandler(self,aO,ch,as,at)then local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if(aO=="mouse_click"or aO=="mouse_drag")and ch==1 or aO=="monitor_touch"then if eV=="horizontal"then for f3=0,self.width do if cD+f3==as and cE<=at and cE+self.height>at then aN=math.min(f3+1,self.width-(eZ-1))self:setValue(eY/self.width*aN)self:setVisualChanged()end end end;if eV=="vertical"then for f3=0,self.height do if cE+f3==at and cD<=as and cD+self.width>as then aN=math.min(f3+1,self.height-(eZ-1))self:setValue(eY/self.height*aN)self:setVisualChanged()end end end end;if aO=="mouse_scroll"then aN=aN+ch;if aN<1 then aN=1 end;aN=math.min(aN,(eV=="vertical"and self.height or self.width)-(eZ-1))self:setValue(eY/(eV=="vertical"and self.height or self.width)*aN)end;return true end end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()if eV=="horizontal"then self.parent:writeText(cD,cE,eX:rep(aN-1),self.bgColor,self.fgColor)self.parent:writeText(cD+aN-1,cE,aG:rep(eZ),eW,eW)self.parent:writeText(cD+aN+eZ-1,cE,eX:rep(self.width-(aN+eZ-1)),self.bgColor,self.fgColor)end;if eV=="vertical"then for aj=0,self.height-1 do if aN==aj+1 then for f4=0,math.min(eZ-1,self.height)do self.parent:writeText(cD,cE+aj+f4,aG,eW,eW)end else if aj+1aN-1+eZ then self.parent:writeText(cD,cE+aj,eX,self.bgColor,self.fgColor)end end end end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function f6(bL)local cz=bK(bL)local bM="Switch"cz.width=2;cz.height=1;cz.bgColor=colors.lightGray;cz.fgColor=colors.gray;cz:setValue(false)cz:setZIndex(5)local eX=colors.black;local f7=colors.red;local f8=colors.green;local bZ={getType=function(self)return bM end,setSymbolColor=function(self,eW)eX=eW;self:setVisualChanged()return self end,setActiveBackground=function(self,ev)f8=ev;self:setVisualChanged()return self end,setInactiveBackground=function(self,ev)f7=ev;self:setVisualChanged()return self end,mouseHandler=function(self,aO,ch,as,at)if cz.mouseHandler(self,aO,ch,as,at)then local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if aO=="mouse_click"and ch==1 or aO=="monitor_touch"then self:setValue(not self:getValue())end;return true end end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)if self:getValue()then self.parent:drawBackgroundBox(cD,cE,1,self.height,f8)self.parent:drawBackgroundBox(cD+1,cE,1,self.height,eX)else self.parent:drawBackgroundBox(cD,cE,1,self.height,eX)self.parent:drawBackgroundBox(cD+1,cE,1,self.height,f7)end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function f9(bL)local cz=bK(bL)local bM="Textfield"local fa,d6,d5,fb=1,1,1,1;local fc={""}local fd={[colors.purple]={"break"}}cz.width=20;cz.height=8;cz.bgColor=k.textfieldBG;cz.fgColor=k.textfieldFG;cz:setZIndex(5)local bZ={getType=function(self)return bM end,getLines=function(self)return fc end,getLine=function(self,aN)return fc[aN]or""end,editLine=function(self,aN,au)fc[aN]=au or fc[aN]return self end,addLine=function(self,au,aN)if aN~=nil then table.insert(fc,aN,au)else table.insert(fc,au)end;return self end,addKeyword=function(self,fe,c6)end,removeLine=function(self,aN)table.remove(fc,aN or#fc)if#fc<=0 then table.insert(fc,"")end;return self end,getTextCursor=function(self)return d5,fb end,getFocusHandler=function(self)cz.getFocusHandler(self)if self.parent~=nil then local cD,cE=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,cD+d5-d6,cE+fb-fa,self.fgColor)end end end,loseFocusHandler=function(self)cz.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,aO,bv)if cz.keyHandler(self,aO,bv)then local cD,cE=self:getAnchorPosition()if aO=="key"then if bv==keys.backspace then if fc[fb]==""then if fb>1 then table.remove(fc,fb)d5=fc[fb-1]:len()+1;d6=d5-self.width+1;if d6<1 then d6=1 end;fb=fb-1 end elseif d5<=1 then if fb>1 then d5=fc[fb-1]:len()+1;d6=d5-self.width+1;if d6<1 then d6=1 end;fc[fb-1]=fc[fb-1]..fc[fb]table.remove(fc,fb)fb=fb-1 end else fc[fb]=fc[fb]:sub(1,d5-2)..fc[fb]:sub(d5,fc[fb]:len())if d5>1 then d5=d5-1 end;if d6>1 then if d5fc[fb]:len()then if fc[fb+1]~=nil then fc[fb]=fc[fb]..fc[fb+1]table.remove(fc,fb+1)end else fc[fb]=fc[fb]:sub(1,d5-1)..fc[fb]:sub(d5+1,fc[fb]:len())end end;if bv==keys.enter then table.insert(fc,fb+1,fc[fb]:sub(d5,fc[fb]:len()))fc[fb]=fc[fb]:sub(1,d5-1)fb=fb+1;d5=1;d6=1;if fb-fa>=self.height then fa=fa+1 end;self:setValue("")end;if bv==keys.up then if fb>1 then fb=fb-1;if d5>fc[fb]:len()+1 then d5=fc[fb]:len()+1 end;if d6>1 then if d51 then if fbfc[fb]:len()+1 then d5=fc[fb]:len()+1 end;if fb>=fa+self.height then fa=fa+1 end end end;if bv==keys.right then d5=d5+1;if fb<#fc then if d5>fc[fb]:len()+1 then d5=1;fb=fb+1 end elseif d5>fc[fb]:len()then d5=fc[fb]:len()+1 end;if d5<1 then d5=1 end;if d5=self.width+d6 then d6=d5-self.width+1 end;if d6<1 then d6=1 end end;if bv==keys.left then d5=d5-1;if d5>=1 then if d5=self.width+d6 then d6=d5 end end;if fb>1 then if d5<1 then fb=fb-1;d5=fc[fb]:len()+1;d6=d5-self.width+1 end end;if d5<1 then d5=1 end;if d6<1 then d6=1 end end end;if aO=="char"then fc[fb]=fc[fb]:sub(1,d5-1)..bv..fc[fb]:sub(d5,fc[fb]:len())d5=d5+1;if d5>=self.width+d6 then d6=d6+1 end;self:setValue("")end;local di=(d5<=fc[fb]:len()and d5-1 or fc[fb]:len())-(d6-1)if di>self.x+self.width-1 then di=self.x+self.width-1 end;local ff=fb-fafc[fb]:len()then d5=fc[fb]:len()+1 end;if d5fc[fb]:len()then d5=fc[fb]:len()+1 end;if d5#fc-(self.height-1)then fa=#fc-(self.height-1)end;if fa<1 then fa=1 end;if self.parent~=nil then if cD+d5-d6>=cD and cD+d5-d6<=cD+self.width and(cE+fb-fa>=cE and cE+fb-fa<=cE+self.height)then self.parent:setCursor(true,fg+d5-d6,fh+fb-fa,self.fgColor)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if cz.draw(self)then if self.parent~=nil then local cD,cE=self:getAnchorPosition()if self.bgColor~=false then self.parent:drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)end;if self.fgColor~=false then self.parent:drawForegroundBox(cD,cE,self.width,self.height,self.fgColor)end;for aj=1,self.height do local au=""if fc[aj+fa-1]~=nil then au=fc[aj+fa-1]end;au=au:sub(d6,self.width+d6-1)local dj=self.width-au:len()if dj<0 then dj=0 end;au=au..string.rep(" ",dj)self.parent:setText(cD,cE+aj-1,au)end end;self:setVisualChanged(false)end end}return setmetatable(bZ,cz)end;local function fi(bL)local bZ;local bM="Thread"local aQ;local fj;local fk=false;bZ={name=bL,getType=function(self)return bM end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,A)if A==nil then error("Function provided to thread is nil")end;aQ=A;fj=coroutine.create(aQ)fk=true;local b2,b3=coroutine.resume(fj)if not b2 then if b3~="Terminated"then error("Thread Error Occurred - "..b3)end end;return self end,getStatus=function(self,A)if fj~=nil then return coroutine.status(fj)end;return nil end,stop=function(self,A)fk=false;return self end,eventHandler=function(self,aO,cl,cm,cn)if fk then if coroutine.status(fj)~="dead"then local b2,b3=coroutine.resume(fj,aO,cl,cm,cn)if not b2 then if b3~="Terminated"then error("Thread Error Occurred - "..b3)end end else fk=false end end end}bZ.__index=bZ;return bZ end;local function fl(bL)local bM="Timer"local fm=0;local fn=0;local fo=0;local cq;local aV=aL()local fp=false;local bZ={name=bL,getType=function(self)return bM end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,fq,fr)fm=fq or 0;fn=fr or 1;return self end,start=function(self)if fp then os.cancelTimer(cq)end;fo=fn;cq=os.startTimer(fm)fp=true;return self end,isActive=function(self)return fp end,cancel=function(self)if cq~=nil then os.cancelTimer(cq)end;fp=false;return self end,onCall=function(self,aQ)aV:registerEvent("timed_event",aQ)return self end,eventHandler=function(self,aO,cx)if aO=="timer"and cx==cq and fp then aV:sendEvent("timed_event",self)if fo>=1 then fo=fo-1;if fo>=1 then cq=os.startTimer(fm)end elseif fo==-1 then cq=os.startTimer(fm)end end end}bZ.__index=bZ;return bZ end;local function fs(bL,ft)local cz=bK(bL)local bM="Frame"local fu={}local fv={}local bZ={}local fw=h;local fx=""local fy=false;local fz=false;local fA=0;local fB=0;cz:setZIndex(10)local aD=a6(fw)local dM=false;local dJ=1;local dK=1;local fC=colors.white;local fD,cN=0,0;if ft~=nil then cz.parent=ft;cz.width,cz.height=ft:getSize()cz.bgColor=k.FrameBG;cz.fgColor=k.FrameFG else cz.width,cz.height=fw.getSize()cz.bgColor=k.basaltBG;cz.fgColor=k.basaltFG end;local function fE(bL)for aS,aT in pairs(fu)do for aS,bx in pairs(aT)do if bx.name==bL then return aT end end end end;local function fF(fG)local bN=fG:getZIndex()if fE(fG.name)~=nil then return nil end;if fu[bN]==nil then for as=1,#fv+1 do if fv[as]~=nil then if bN==fv[as]then break end;if bN>fv[as]then table.insert(fv,as,bN)break end else table.insert(fv,bN)end end;if#fv<=0 then table.insert(fv,bN)end;fu[bN]={}end;fG.parent=bZ;table.insert(fu[bN],fG)return fG end;local function fH(fG)for bw,bx in pairs(fu)do for bv,aT in pairs(bx)do if aT==fG then table.remove(fu[bw],bv)return true end end end;return false end;bZ={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return bM end,setFocusedObject=function(self,fG)if c~=nil then c:loseFocusHandler()c=nil end;if fG~=nil then c=fG;fG:getFocusHandler()end;return self end,setSize=function(self,fI,b9)cz.setSize(self,fI,b9)for aS,aN in pairs(fv)do if fu[aN]~=nil then for aS,aT in pairs(fu[aN])do if aT.eventHandler~=nil then aT:sendEvent("basalt_resize",aT,self)end end end end;return self end,setOffset=function(self,cd,ce)fD=cd~=nil and math.floor(cd<0 and math.abs(cd)or-cd)or fD;cN=ce~=nil and math.floor(ce<0 and math.abs(ce)or-ce)or cN;return self end,getFrameOffset=function(self)return fD,cN end,removeFocusedObject=function(self)if c~=nil then c:loseFocusHandler()end;c=nil;return self end,getFocusedObject=function(self)return c end,setCursor=function(self,fJ,fK,fL,c6)if self.parent~=nil then local cD,cE=self:getAnchorPosition()self.parent:setCursor(fJ or false,(fK or 0)+cD-1,(fL or 0)+cE-1,c6 or fC)else local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())dM=fJ or false;if fK~=nil then dJ=cD+fK-1 end;if fL~=nil then dK=cE+fL-1 end;fC=c6 or fC;self:setVisualChanged()end;return self end,setMoveable=function(self,fM)self.isMoveable=fM or not self.isMoveable;self:setVisualChanged()return self end,show=function(self)cz.show(self)if self.parent==nil then e=self;if fy then g[fx]=self else f=self end end;return self end,hide=function(self)cz.hide(self)if self.parent==nil then if e==self then e=nil end;if fy then if g[fx]==self then g[fx]=nil end else if f==self then f=nil end end end;return self end,showBar=function(self,fN)self.barActive=fN or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,au,aE,aF)self.barText=au or""self.barBackground=aE or self.barBackground;self.barTextcolor=aF or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,cM)self.barTextAlign=cM or"left"self:setVisualChanged()return self end,setMonitor=function(self,c9)if c9~=nil and c9~=false then if peripheral.getType(c9)=="monitor"then fw=peripheral.wrap(c9)fz=true end;fy=true else fw=h;fy=false;if g[fx]==self then g[fx]=nil end end;aD=a6(fw)fx=c9 or nil;return self end,getVisualChanged=function(self)local fO=cz.getVisualChanged(self)for aS,aN in pairs(fv)do if fu[aN]~=nil then for aS,aT in pairs(fu[aN])do if aT.getVisualChanged~=nil and aT:getVisualChanged()then fO=true end end end end;return fO end,loseFocusHandler=function(self)cz.loseFocusHandler(self)end,getFocusHandler=function(self)cz.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,aO,bv)if c~=nil then if c~=self then if c.keyHandler~=nil then if c:keyHandler(aO,bv)then return true end end else cz.keyHandler(self,aO,bv)end end;return false end,backgroundKeyHandler=function(self,aO,bv)cz.backgroundKeyHandler(self,aO,bv)for aS,aN in pairs(fv)do if fu[aN]~=nil then for aS,aT in pairs(fu[aN])do if aT.backgroundKeyHandler~=nil then aT:backgroundKeyHandler(aO,bv)end end end end end,eventHandler=function(self,aO,cl,cm,cn,co)cz.eventHandler(self,aO,cl,cm,cn,co)for aS,aN in pairs(fv)do if fu[aN]~=nil then for aS,aT in pairs(fu[aN])do if aT.eventHandler~=nil then aT:eventHandler(aO,cl,cm,cn,co)end end end end;if fy then if aO=="peripheral"and cl==fx then if peripheral.getType(fx)=="monitor"then fz=true;fw=peripheral.wrap(fx)aD=a6(fw)end end;if aO=="peripheral_detach"and cl==fx then fz=false end end;if aO=="terminate"then fw.clear()fw.setCursorPos(1,1)a.stop()end end,mouseHandler=function(self,aO,ch,as,at)local cd,ce=self:getOffset()cd=cd<0 and math.abs(cd)or-cd;ce=ce<0 and math.abs(ce)or-ce;if self.drag then if aO=="mouse_drag"then local fP=1;local fQ=1;if self.parent~=nil then fP,fQ=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(as+fA-(fP-1)+cd,at+fB-(fQ-1)+ce)end;if aO=="mouse_up"then self.drag=false end;return true end;local ci,cj=self:getAbsolutePosition(self:getAnchorPosition())local ck=false;if cj-1==at and self:getBorder("top")then at=at+1;ck=true end;if cz.mouseHandler(self,aO,ch,as,at)then local ca,cb=self:getAbsolutePosition(self:getAnchorPosition())ca=ca+fD;cb=cb+cN;for aS,aN in pairs(fv)do if fu[aN]~=nil then for aS,aT in ba(fu[aN])do if aT.mouseHandler~=nil then if aT:mouseHandler(aO,ch,as,at)then return true end end end end end;if self.isMoveable then local ca,cb=self:getAbsolutePosition(self:getAnchorPosition())if as>=ca and as<=ca+self.width-1 and at==cb and aO=="mouse_click"then self.drag=true;fA=ca-as;fB=ck and 1 or 0 end end;if c~=nil then c:loseFocusHandler()c=nil end;return true end;return false end,setText=function(self,as,at,au)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fP,fQ=self.parent:getAnchorPosition()self.parent:setText(math.max(as+cD-1,cD)-(fP-1),cE+at-1-(fQ-1),i(au,math.max(1-as+1,1),math.max(self.width-as+1,1)))else aD.setText(math.max(as+cD-1,cD),cE+at-1,i(au,math.max(1-as+1,1),math.max(self.width-as+1,1)))end end end,setBG=function(self,as,at,aE)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fP,fQ=self.parent:getAnchorPosition()self.parent:setBG(math.max(as+cD-1,cD)-(fP-1),cE+at-1-(fQ-1),i(aE,math.max(1-as+1,1),math.max(self.width-as+1,1)))else aD.setBG(math.max(as+cD-1,cD),cE+at-1,i(aE,math.max(1-as+1,1),math.max(self.width-as+1,1)))end end end,setFG=function(self,as,at,aF)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fP,fQ=self.parent:getAnchorPosition()self.parent:setFG(math.max(as+cD-1,cD)-(fP-1),cE+at-1-(fQ-1),i(aF,math.max(1-as+1,1),math.max(self.width-as+1,1)))else aD.setFG(math.max(as+cD-1,cD),cE+at-1,i(aF,math.max(1-as+1,1),math.max(self.width-as+1,1)))end end end,writeText=function(self,as,at,au,aE,aF)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())if at>=1 and at<=self.height then if self.parent~=nil then local fP,fQ=self.parent:getAnchorPosition()self.parent:writeText(math.max(as+cD-1,cD)-(fP-1),cE+at-1-(fQ-1),i(au,math.max(1-as+1,1),self.width-as+1),aE,aF)else aD.writeText(math.max(as+cD-1,cD),cE+at-1,i(au,math.max(1-as+1,1),math.max(self.width-as+1,1)),aE,aF)end end end,drawBackgroundBox=function(self,as,at,a9,p,aE)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())p=at<1 and(p+at>self.height and self.height or p+at-1)or(p+at>self.height and self.height-at+1 or p)a9=as<1 and(a9+as>self.width and self.width or a9+as-1)or(a9+as>self.width and self.width-as+1 or a9)if self.parent~=nil then local fP,fQ=self.parent:getAnchorPosition()self.parent:drawBackgroundBox(math.max(as+cD-1,cD)-(fP-1),math.max(at+cE-1,cE)-(fQ-1),a9,p,aE)else aD.drawBackgroundBox(math.max(as+cD-1,cD),math.max(at+cE-1,cE),a9,p,aE)end end,drawTextBox=function(self,as,at,a9,p,aG)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())p=at<1 and(p+at>self.height and self.height or p+at-1)or(p+at>self.height and self.height-at+1 or p)a9=as<1 and(a9+as>self.width and self.width or a9+as-1)or(a9+as>self.width and self.width-as+1 or a9)if self.parent~=nil then local fP,fQ=self.parent:getAnchorPosition()self.parent:drawTextBox(math.max(as+cD-1,cD)-(fP-1),math.max(at+cE-1,cE)-(fQ-1),a9,p,aG:sub(1,1))else aD.drawTextBox(math.max(as+cD-1,cD),math.max(at+cE-1,cE),a9,p,aG:sub(1,1))end end,drawForegroundBox=function(self,as,at,a9,p,aF)local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())p=at<1 and(p+at>self.height and self.height or p+at-1)or(p+at>self.height and self.height-at+1 or p)a9=as<1 and(a9+as>self.width and self.width or a9+as-1)or(a9+as>self.width and self.width-as+1 or a9)if self.parent~=nil then local fP,fQ=self.parent:getAnchorPosition()self.parent:drawForegroundBox(math.max(as+cD-1,cD)-(fP-1),math.max(at+cE-1,cE)-(fQ-1),a9,p,aF)else aD.drawForegroundBox(math.max(as+cD-1,cD),math.max(at+cE-1,cE),a9,p,aF)end end,draw=function(self)if fy and not fz then return false end;if self:getVisualChanged()then if cz.draw(self)then local cD,cE=self:getAbsolutePosition(self:getAnchorPosition())local fg,fh=self:getAnchorPosition()if self.parent~=nil then if self.bgColor~=false then self.parent:drawBackgroundBox(fg,fh,self.width,self.height,self.bgColor)self.parent:drawTextBox(fg,fh,self.width,self.height," ")end;if self.bgColor~=false then self.parent:drawForegroundBox(fg,fh,self.width,self.height,self.fgColor)end else if self.bgColor~=false then aD.drawBackgroundBox(cD,cE,self.width,self.height,self.bgColor)aD.drawTextBox(cD,cE,self.width,self.height," ")end;if self.fgColor~=false then aD.drawForegroundBox(cD,cE,self.width,self.height,self.fgColor)end end;fw.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(fg,fh,b4(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)else aD.writeText(cD,cE,b4(self.barText,self.width,self.barTextAlign),self.barBackground,self.barTextcolor)end;if self:getBorder("left")then if self.parent~=nil then self.parent:drawBackgroundBox(fg-1,fh,1,1,self.barBackground)if self.bgColor~=false then self.parent:drawBackgroundBox(fg-1,fh+1,1,self.height-1,self.bgColor)end end end;if self:getBorder("top")then if self.parent~=nil then self.parent:drawBackgroundBox(fg-1,fh-1,self.width+1,1,self.barBackground)end end end;for aS,aN in ba(fv)do if fu[aN]~=nil then for aS,aT in pairs(fu[aN])do if aT.draw~=nil then aT:draw()end end end end;if dM then fw.setTextColor(fC)fw.setCursorPos(dJ,dK)if self.parent~=nil then fw.setCursorBlink(self:isFocused())else fw.setCursorBlink(dM)end end;self:setVisualChanged(false)end end end,drawUpdate=function(self)if fy and not fz then return false end;aD.update()end,addObject=function(self,fG)return fF(fG)end,removeObject=function(self,fG)return fH(fG)end,getObject=function(self,fG)return fE(fG)end,addButton=function(self,bL)local fG=cy(bL)fG.name=bL;return fF(fG)end,addLabel=function(self,bL)local fG=dk(bL)fG.bgColor=self.bgColor;fG.fgColor=self.fgColor;return fF(fG)end,addCheckbox=function(self,bL)local fG=cG(bL)return fF(fG)end,addInput=function(self,bL)local fG=d2(bL)return fF(fG)end,addProgram=function(self,bL)local fG=dH(bL)return fF(fG)end,addTextfield=function(self,bL)local fG=f9(bL)return fF(fG)end,addList=function(self,bL)local fG=dv(bL)fG.name=nam;return fF(fG)end,addDropdown=function(self,bL)local fG=cH(bL)return fF(fG)end,addRadio=function(self,bL)local fG=eP(bL)return fF(fG)end,addTimer=function(self,bL)local fG=fl(bL)return fF(fG)end,addAnimation=function(self,bL)local fG=cp(bL)return fF(fG)end,addSlider=function(self,bL)local fG=f5(bL)return fF(fG)end,addScrollbar=function(self,bL)local fG=eU(bL)return fF(fG)end,addMenubar=function(self,bL)local fG=dy(bL)return fF(fG)end,addThread=function(self,bL)local fG=fi(bL)return fF(fG)end,addPane=function(self,bL)local fG=dG(bL)return fF(fG)end,addImage=function(self,bL)local fG=cV(bL)return fF(fG)end,addProgressbar=function(self,bL)local fG=eG(bL)return fF(fG)end,addSwitch=function(self,bL)local fG=f6(bL)return fF(fG)end,addFrame=function(self,bL)local fG=fs(bL,self)return fF(fG)end}setmetatable(bZ,cz)return bZ end;local function fR()f:draw()f:drawUpdate()for aS,c8 in pairs(g)do c8:draw()c8:drawUpdate()end end;local fS=false;local function fT(aO,cl,cm,cn,co)if aV:sendEvent("basaltEventCycle",aO,cl,cm,cn,co)==false then return end;if f~=nil then if aO=="mouse_click"then f:mouseHandler(aO,cl,cm,cn,co)e=f elseif aO=="mouse_drag"then f:mouseHandler(aO,cl,cm,cn,co)e=f elseif aO=="mouse_up"then f:mouseHandler(aO,cl,cm,cn,co)e=f elseif aO=="mouse_scroll"then f:mouseHandler(aO,cl,cm,cn,co)e=f elseif aO=="monitor_touch"then if g[cl]~=nil then g[cl]:mouseHandler(aO,cl,cm,cn,co)e=g[cl]end end end;if aO=="key"or aO=="char"then e:keyHandler(aO,cl)e:backgroundKeyHandler(aO,cl)end;if aO=="key"then b[cl]=true end;if aO=="key_up"then b[cl]=false end;for aS,c8 in pairs(d)do c8:eventHandler(aO,cl,cm,cn,co)end;fR()end;function a.autoUpdate(fk)fS=fk;if fk==nil then fS=true end;fR()while fS do local aO,cl,cm,cn,co=os.pullEventRaw()fT(aO,cl,cm,cn,co)end end;function a.update(aO,cl,cm,cn,co)if aO~=nil then fT(aO,cl,cm,cn,co)end end;function a.stop()fS=false end;function a.isKeyDown(bv)if b[bv]==nil then return false end;return b[bv]end;function a.getFrame(bL)for aS,aT in pairs(d)do if aT.name==bL then return aT end end end;function a.getActiveFrame()return e end;function a.setActiveFrame(b_)if b_:getType()=="Frame"then e=b_;return true end;return false end;function a.onEvent(...)for aS,c8 in pairs(table.pack(...))do if type(c8)=="function"then aV:registerEvent("basaltEventCycle",c8)end end end;function a.createFrame(bL)for aS,c8 in pairs(d)do if c8.name==bL then return nil end end;local fU=fs(bL)table.insert(d,fU)return fU end;function a.removeFrame(bL)d[bL]=nil end;if a.debugger then a.debugFrame=a.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)a.debugList=a.debugFrame:addList("debugList"):setSize(a.debugFrame.width-2,a.debugFrame.height-3):setPosition(2,3):setScrollable(true):show()a.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()a.oldFrame:show()end):setBackground(colors.red):show()a.debugLabel=a.debugFrame:addLabel("debugLabel"):onClick(function()a.oldFrame=f;a.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()end;if a.debugger then function a.debug(...)local b0={...}if f.name~="basaltDebuggingFrame"then if f~=a.debugFrame then a.debugLabel:setParent(f)end end;local fV=""for bv,aT in pairs(b0)do fV=fV..tostring(aT)..(#b0~=bv and", "or"")end;a.debugLabel:setText("[Debug] "..fV)a.debugList:addItem(fV)if a.debugList:getItemCount()>50 then a.debugList:removeItem(1)end;a.debugList:setValue(a.debugList:getItem(a.debugList:getItemCount()))if a.debugList.getItemCount()>a.debugList:getHeight()then a.debugList:setIndexOffset(a.debugList:getItemCount()-a.debugList:getHeight())end;a.debugLabel:show()end end;return a \ No newline at end of file diff --git a/docs/docs1_6/versions/basalt-1.5.0.lua b/docs/docs1_6/versions/basalt-1.5.0.lua deleted file mode 100644 index 4cbcb78..0000000 --- a/docs/docs1_6/versions/basalt-1.5.0.lua +++ /dev/null @@ -1,2411 +0,0 @@ -local project = {} -local packaged = true -local baseRequire = require -local require = function(path) - for _,v in pairs(project)do - for name,b in pairs(v)do - if(name==path)then - return b() - end - end - end - return baseRequire(path); -end -local getProject = function(subDir) - if(subDir~=nil)then - return project[subDir] - end - return project -end -project['objects'] = {}project['libraries'] = {}project['default'] = {}project['objects']['Animation'] = function(...)local ab=require("utils").getValueFromXML -local bb=require("basaltEvent")local cb=math.floor -local db=function(ad,bd,cd)return ad+ (bd-ad)*cd end;local _c=function(ad)return ad end -local ac=function(ad)return 1 -ad end;local bc=function(ad)return ad*ad*ad end;local cc=function(ad) -return ac(bc(ac(ad)))end;local dc=function(ad) -return db(bc(ad),cc(ad),ad)end -local _d={linear=_c,lerp=db,flip=ac,easeIn=bc,easeOut=cc,easeInOut=dc} -return -function(ad)local bd={}local cd="Animation"local dd;local __a={}local a_a=0;local b_a=false;local c_a=1;local d_a=false;local _aa=bb() -local aaa=0;local baa;local caa=false;local daa=false;local _ba="easeOut"local aba;local function bba(aca)for bca,cca in pairs(aca)do -cca(bd,__a[c_a].t,c_a)end end -local function cba(aca)if(c_a==1)then -aca:animationStartHandler()end;if(__a[c_a]~=nil)then bba(__a[c_a].f) -a_a=__a[c_a].t end;c_a=c_a+1 -if(__a[c_a]==nil)then if(d_a)then c_a=1;a_a=0 else -aca:animationDoneHandler()return end end;if(__a[c_a].t>0)then -dd=os.startTimer(__a[c_a].t-a_a)else cba(aca)end end -local function dba(aca,bca)for n=1,#__a do -if(__a[n].t==aca)then table.insert(__a[n].f,bca)return end end -for n=1,#__a do -if(__a[n].t>aca)then if -(__a[n-1]~=nil)then if(__a[n-1].t0)then -aca:changeTextColor(cca,dca or 0,table.unpack(_da))end end -if(bca["background"]~=nil)then -local cca=ab("duration",bca["background"])local dca=ab("time",bca["background"])local _da={} -local ada=bca["background"]["color"] -if(ada~=nil)then if(ada.properties~=nil)then ada={ada}end;for bda,cda in pairs(ada)do -table.insert(_da,colors[cda:value()])end end;if(cca~=nil)and(#_da>0)then -aca:changeBackground(cca,dca or 0,table.unpack(_da))end end -if(bca["text"]~=nil)then local cca=ab("duration",bca["text"]) -local dca=ab("time",bca["text"])local _da={}local ada=bca["text"]["text"] -if(ada~=nil)then if(ada.properties~=nil)then -ada={ada}end;for bda,cda in pairs(ada)do -table.insert(_da,cda:value())end end;if(cca~=nil)and(#_da>0)then -aca:changeText(cca,dca or 0,table.unpack(_da))end end;if(ab("onDone",bca)~=nil)then -aca:generateXMLEventFunction(aca.onDone,ab("onDone",bca))end;if(ab("onStart",bca)~=nil)then -aca:generateXMLEventFunction(aca.onDone,ab("onStart",bca))end -if -(ab("autoDestroy",bca)~=nil)then if(ab("autoDestroy",bca))then daa=true end end;_ba=ab("mode",bca)or _ba -if(ab("play",bca)~=nil)then if -(ab("play",bca))then aca:play(caa)end end;return aca end,getZIndex=function(aca)return -1 end,getName=function(aca)return aca.name end,setObject=function(aca,bca)aba=bca;return aca end,move=function(aca,bca,cca,dca,_da,ada)aba= -ada or aba -_ca(bca,cca,dca,_da or 0,aba.getPosition,aba.setPosition)return aca end,offset=function(aca,bca,cca,dca,_da,ada) -aba=ada or aba -_ca(bca,cca,dca,_da or 0,aba.getOffset,aba.setOffset)return aca end,size=function(aca,bca,cca,dca,_da,ada) -aba=ada or aba;_ca(bca,cca,dca,_da or 0,aba.getSize,aba.setSize)return -aca end,changeText=function(aca,bca,cca,...)local dca={...}cca= -cca or 0;aba=obj or aba;for n=1,#dca do -dba(cca+n* (bca/#dca),function() -aba.setText(aba,dca[n])end)end;return aca end,changeBackground=function(aca,bca,cca,...) -local dca={...}cca=cca or 0;aba=obj or aba;for n=1,#dca do -dba(cca+n* (bca/#dca),function() -aba.setBackground(aba,dca[n])end)end;return aca end,changeTextColor=function(aca,bca,cca,...) -local dca={...}cca=cca or 0;aba=obj or aba;for n=1,#dca do -dba(cca+n* (bca/#dca),function() -aba.setForeground(aba,dca[n])end)end;return aca end,add=function(aca,bca,cca) -baa=bca -dba((cca or aaa)+ -(__a[#__a]~=nil and __a[#__a].t or 0),bca)return aca end,wait=function(aca,bca)aaa=bca;return aca end,rep=function(aca,bca) -if( -baa~=nil)then for n=1,bca or 1 do -dba((wait or aaa)+ -(__a[#__a]~=nil and __a[#__a].t or 0),baa)end end;return aca end,onDone=function(aca,bca) -_aa:registerEvent("animation_done",bca)return aca end,onStart=function(aca,bca) -_aa:registerEvent("animation_start",bca)return aca end,setAutoDestroy=function(aca,bca) -daa=bca~=nil and bca or true;return aca end,animationDoneHandler=function(aca) -_aa:sendEvent("animation_done",aca) -if(daa)then aca.parent:removeObject(aca)aca=nil end end,animationStartHandler=function(aca) -_aa:sendEvent("animation_start",aca)end,clear=function(aca)__a={}baa=nil;aaa=0;c_a=1;a_a=0;d_a=false;return aca end,play=function(aca,bca) -aca:cancel()b_a=true;d_a=bca and true or false;c_a=1;a_a=0 -if(__a[c_a]~=nil)then -if( -__a[c_a].t>0)then dd=os.startTimer(__a[c_a].t)else cba()end else aca:animationDoneHandler()end;return aca end,cancel=function(aca)if( -dd~=nil)then os.cancelTimer(dd)d_a=false end;b_a=false;return -aca end,internalObjetCall=function(aca)aca:play(caa)end,eventHandler=function(aca,bca,cca)if -(b_a)then -if(bca=="timer")and(cca==dd)then if(__a[c_a]~=nil)then cba(aca)else -aca:animationDoneHandler()end end end end}bd.__index=bd;return bd end -end; -project['objects']['Button'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Button"local _b="center"local ab="center"ca:setZIndex(5) -ca:setValue("Button")ca.width=12;ca.height=3 -local bb={init=function(cb) -cb.bgColor=cb.parent:getTheme("ButtonBG")cb.fgColor=cb.parent:getTheme("ButtonText")end,getType=function(cb)return -da end,setHorizontalAlign=function(cb,db)_b=db end,setVerticalAlign=function(cb,db)ab=db end,setText=function(cb,db)ca:setValue(db) -return cb end,setValuesByXMLData=function(cb,db)ca.setValuesByXMLData(cb,db) -if(aa("text",db)~= -nil)then cb:setText(aa("text",db))end;if(aa("horizontalAlign",db)~=nil)then -_b=aa("horizontalAlign",db)end;if(aa("verticalAlign",db)~=nil)then -ab=aa("verticalAlign",db)end;return cb end,draw=function(cb) -if -(ca.draw(cb))then -if(cb.parent~=nil)then local db,_c=cb:getAnchorPosition() -local ac,bc=cb:getSize()local cc=_a.getTextVerticalAlign(bc,ab) -if(cb.bgColor~=false)then -cb.parent:drawBackgroundBox(db,_c,ac,bc,cb.bgColor)cb.parent:drawTextBox(db,_c,ac,bc," ")end;if(cb.fgColor~=false)then -cb.parent:drawForegroundBox(db,_c,ac,bc,cb.fgColor)end -for n=1,bc do if(n==cc)then -cb.parent:setText(db,_c+ (n-1),_a.getTextHorizontalAlign(cb:getValue(),ac,_b))end end end;cb:setVisualChanged(false)end end}return setmetatable(bb,ca)end -end; -project['objects']['Checkbox'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Checkbox"ca:setZIndex(5)ca:setValue(false) -ca.width=1;ca.height=1 -local _b={symbol="\42",init=function(ab) -ab.bgColor=ab.parent:getTheme("CheckboxBG")ab.fgColor=ab.parent:getTheme("CheckboxText")end,getType=function(ab)return -da end,mouseHandler=function(ab,bb,cb,db,_c) -if(ca.mouseHandler(ab,bb,cb,db,_c))then -if -( (bb=="mouse_click")and(cb==1))or(bb=="monitor_touch")then -if(ab:getValue()~=true)and( -ab:getValue()~=false)then ab:setValue(false)else ab:setValue(not -ab:getValue())end end;return true end;return false end,setValuesByXMLData=function(ab,bb) -ca.setValuesByXMLData(ab,bb) -if(aa("checked",bb)~=nil)then if(aa("checked",bb))then ab:setValue(true)else -ab:setValue(false)end end;return ab end,draw=function(ab) -if -(ca.draw(ab))then -if(ab.parent~=nil)then local bb,cb=ab:getAnchorPosition() -local db,_c=ab:getSize()local ac=_a.getTextVerticalAlign(_c,"center")if -(ab.bgColor~=false)then -ab.parent:drawBackgroundBox(bb,cb,db,_c,ab.bgColor)end -for n=1,_c do -if(n==ac)then -if(ab:getValue()==true)then -ab.parent:writeText(bb, -cb+ (n-1),_a.getTextHorizontalAlign(ab.symbol,db,"center"),ab.bgColor,ab.fgColor)else -ab.parent:writeText(bb,cb+ (n-1),_a.getTextHorizontalAlign(" ",db,"center"),ab.bgColor,ab.fgColor)end end end end;ab:setVisualChanged(false)end end}return setmetatable(_b,ca)end -end; -project['objects']['Dropdown'] = function(...)local d=require("Object")local _a=require("utils") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Dropdown"ca.width=12;ca.height=1;ca:setZIndex(6) -local _b={}local ab;local bb;local cb=true;local db="left"local _c=0;local ac=16;local bc=6;local cc="\16"local dc="\31"local _d=false -local ad={getType=function(bd) -return da end,init=function(bd) -bd.bgColor=bd.parent:getTheme("DropdownBG")bd.fgColor=bd.parent:getTheme("DropdownText") -ab=bd.parent:getTheme("SelectionBG")bb=bd.parent:getTheme("SelectionText")end,setValuesByXMLData=function(bd,cd) -ca.setValuesByXMLData(bd,cd)if(aa("selectionBG",cd)~=nil)then -ab=colors[aa("selectionBG",cd)]end;if(aa("selectionFG",cd)~=nil)then -bb=colors[aa("selectionFG",cd)]end;if(aa("dropdownWidth",cd)~=nil)then -ac=aa("dropdownWidth",cd)end;if(aa("dropdownHeight",cd)~=nil)then -bc=aa("dropdownHeight",cd)end;if(aa("offset",cd)~=nil)then -_c=aa("offset",cd)end -if(cd["item"]~=nil)then local dd=cd["item"]if -(dd.properties~=nil)then dd={dd}end;for __a,a_a in pairs(dd)do -bd:addItem(aa("text",a_a),colors[aa("bg",a_a)],colors[aa("fg",a_a)])end end end,setOffset=function(bd,cd) -_c=cd;return bd end,getOffset=function(bd)return _c end,addItem=function(bd,cd,dd,__a,...) -table.insert(_b,{text=cd,bgCol=dd or bd.bgColor,fgCol=__a or bd.fgColor,args={...}})return bd end,getAll=function(bd)return _b end,removeItem=function(bd,cd) -table.remove(_b,cd)return bd end,getItem=function(bd,cd)return _b[cd]end,getItemIndex=function(bd) -local cd=bd:getValue()for dd,__a in pairs(_b)do if(__a==cd)then return dd end end end,clear=function(bd) -_b={}bd:setValue({})return bd end,getItemCount=function(bd)return#_b end,editItem=function(bd,cd,dd,__a,a_a,...) -table.remove(_b,cd) -table.insert(_b,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol=a_a or bd.fgColor,args={...}})return bd end,selectItem=function(bd,cd)bd:setValue( -_b[cd]or{})return bd end,setSelectedItem=function(bd,cd,dd,__a) -ab=cd or bd.bgColor;bb=dd or bd.fgColor;cb=__a;return bd end,setDropdownSize=function(bd,cd,dd) -ac,bc=cd,dd;return bd end,mouseHandler=function(bd,cd,dd,__a,a_a) -if(_d)then -local b_a,c_a=bd:getAbsolutePosition(bd:getAnchorPosition()) -if -( (cd=="mouse_click")and(dd==1))or(cd=="monitor_touch")then if(#_b>0)then -for n=1,bc do if(_b[n+_c]~=nil)then -if -(b_a<=__a)and(b_a+ac>__a)and(c_a+n==a_a)then bd:setValue(_b[n+_c])return true end end end end end -if(cd=="mouse_scroll")then _c=_c+dd;if(_c<0)then _c=0 end;if(dd==1)then -if(#_b>bc)then if(_c>#_b-bc)then _c=#_b- -bc end else _c=math.min(#_b-1,0)end end;return true end;bd:setVisualChanged()end -if(ca.mouseHandler(bd,cd,dd,__a,a_a))then _d=true else _d=false end end,draw=function(bd) -if -(ca.draw(bd))then local cd,dd=bd:getAnchorPosition()local __a,a_a=bd:getSize() -if -(bd.parent~=nil)then if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=bd:getValue() -local c_a=_a.getTextHorizontalAlign(( -b_a~=nil and b_a.text or""),__a,db):sub(1, -__a-1).. (_d and dc or cc) -bd.parent:writeText(cd,dd,c_a,bd.bgColor,bd.fgColor) -if(_d)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if(_b[n+_c]==b_a)then -if(cb)then -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+ -_c].text,ac,db),ab,bb)else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end end end end end;bd:setVisualChanged(false)end end}return setmetatable(ad,ca)end -end; -project['objects']['Graphic'] = function(...)local da=require("Object")local _b=require("geometricPoints") -local ab=require("tHex")local bb=require("utils").getValueFromXML -local cb,db,_c,ac=string.sub,string.len,math.max,math.min -return -function(bc)local cc=da(bc)local dc="Graphic"cc:setZIndex(2)local _d={}local ad={}local bd={} -local cd=false;local dd,__a=0,0;local a_a=false;local b_a,c_a;local d_a,_aa=40,15;local aaa=false;local baa={}for n=1,16 do baa[string.byte("0123456789abcdef",n,n)]= -2 ^ (n-1)end -local function caa(dba)local _ca={}for i=1, -#dba do _ca[i]=dba:sub(i,i)end;return _ca end -local function daa(dba,_ca,aca,bca,cca) -if(_ca>=1)and(_ca<=bca)then -if(dba+db(cca)>0)and(dba<=aca)then -local dca=ad[_ca]local _da;local ada=dba+#cca-1 -if(dba<1)then -cca=cb(cca,1 -dba+1,aca-dba+1)elseif(ada>aca)then cca=cb(cca,1,aca-dba+1)end -if(dba>1)then _da=cb(dca,1,dba-1)..cca else _da=cca end;if ada -ad[y]:len())then ad[y]=ad[y].. -(ab[cc.bgColor]):rep(dba-ad[y]:len())else -ad[y]=ad[y]:sub(1,dba)end else -ad[y]=(ab[cc.bgColor]):rep(dba)end end end;_ba() -local function aba() -local function dba(b_b,c_b)local d_b={}for x=1,c_b:len()do -d_b[x]=baa[string.byte(c_b,x,x)]or 0 end;table.insert(b_b,d_b)end -function parseImage(b_b)if type(b_b)~="string"then -error("bad argument #1 (expected string, got "..type(b_b)..")")end;local c_b={}for d_b in -(b_b.."\n"):gmatch("(.-)\n")do dba(c_b,d_b)end;return c_b end;local _ca=""for y=1,#ad do -if(y==#ad)then _ca=_ca..ad[y]else _ca=_ca..ad[y].."\n"end end;local aca=parseImage(_ca) -local bca={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local cca,dca,_da={},{},{}for i=0,15 do dca[2 ^i]=i end -do local b_b="0123456789abcdef" -for i=1,16 do cca[b_b:sub(i,i)]= -i-1;cca[i-1]=b_b:sub(i,i) -_da[b_b:sub(i,i)]=2 ^ (i-1)_da[2 ^ (i-1)]=b_b:sub(i,i)local c_b=bca[i-1]for i=1,#c_b do -c_b[i]=2 ^c_b[i]end end end -local function ada(b_b)local c_b=bca[dca[b_b[#b_b][1] ] ] -for j=1,#c_b do local d_b=c_b[j]for i=1, -#b_b-1 do if b_b[i][1]==d_b then return i end end end;return 1 end -local function bda(b_b,c_b) -if not c_b then local _ab={}c_b={}for i=1,6 do local aab=b_b[i]local bab=c_b[aab] -c_b[aab],_ab[i]=bab and(bab+1)or 1,aab end;b_b=_ab end;local d_b={}for _ab,aab in pairs(c_b)do d_b[#d_b+1]={_ab,aab}end -if# -d_b>1 then -while#d_b>2 do -table.sort(d_b,function(_bb,abb)return _bb[2]>abb[2]end)local aab,bab=ada(d_b),#d_b;local cab,dab=d_b[bab][1],d_b[aab][1]for i=1,6 do -if b_b[i]== -cab then b_b[i]=dab;d_b[aab][2]=d_b[aab][2]+1 end end;d_b[bab]=nil end;local _ab=128;for i=1,#b_b-1 do -if b_b[i]~=b_b[6]then _ab=_ab+2 ^ (i-1)end end;return string.char(_ab),_da[d_b[1][1]==b_b[6]and -d_b[2][1]or d_b[1][1] ], -_da[b_b[6] ]else -return"\128",_da[b_b[1] ],_da[b_b[1] ]end end -local cda,dda,__b,a_b={{},{},{}},0,#aca+#aca%3,cc.bgColor or colors.black -for i=1,#aca do if#aca[i]>dda then dda=#aca[i]end end -for y=0,__b-1,3 do local b_b,c_b,d_b,_ab={},{},{},1 -for x=0,dda-1,2 do local aab,bab={},{} -for yy=1,3 do -for xx=1,2 do -aab[#aab+1]= -(aca[y+yy]and aca[y+yy][ -x+xx])and(aca[y+yy][x+xx]==0 and a_b or aca[y+yy][ -x+xx])or a_b;bab[aab[#aab] ]= -bab[aab[#aab] ]and(bab[aab[#aab] ]+1)or 1 end end;b_b[_ab],c_b[_ab],d_b[_ab]=bda(aab,bab)_ab=_ab+1 end -cda[1][#cda[1]+1],cda[2][#cda[2]+1],cda[3][#cda[3]+1]=table.concat(b_b),table.concat(c_b),table.concat(d_b)end;cda.width,cda.height=#cda[1][1],#cda[1]bd=cda end -local function bba()local dba,_ca=d_a,_aa;if(cd)then dba=dba*2;_ca=_ca*3 end;for aca,bca in pairs(_d)do -for cca,dca in -pairs(bca[1])do daa(dca.x,dca.y,dba,_ca,bca[2])end end;if(cd)then aba()end end -local cba={init=function(dba)dba.bgColor=dba.parent:getTheme("GraphicBG")end,getType=function(dba)return -dc end,setSize=function(dba,_ca,aca,bca)cc.setSize(dba,_ca,aca,bca)if not(aaa)then d_a=_ca -_aa=aca;_ba()end;bba()return dba end,setOffset=function(dba,_ca,aca)dd= -_ca or dd;__a=aca or __a;return dba end,setCanvasSize=function(dba,_ca,aca) -d_a,_aa=_ca,aca;aaa=true;_ba()return dba end,clearCanvas=function(dba)_d={}ad={}_ba()end,getOffset=function(dba)return -dd,__a end,setValuesByXMLData=function(dba,_ca)cc.setValuesByXMLData(dba,_ca) -if( -bb("text",_ca)~=nil)then dba:setText(bb("text",_ca))end;if(bb("xOffset",_ca)~=nil)then -dba:setOffset(bb("xOffset",_ca),__a)end;if(bb("yOffset",_ca)~=nil)then -dba:setOffset(dd,bb("yOffset",_ca))end;if(bb("wCanvas",_ca)~=nil)then -d_a=bb("wCanvas",_ca)end;if(bb("hCanvas",_ca)~=nil)then -_aa=bb("hCanvas",_ca)end;if(bb("shrink",_ca)~=nil)then if(bb("shrink",_ca))then -dba:shrink()end end -if -(bb("dragable",_ca)~=nil)then if(bb("dragable",_ca))then a_a=true end end -if(_ca["ellipse"]~=nil)then local aca=_ca["ellipse"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=bb("radius",cca)local ada=bb("radius2",cca)local bda=bb("x",cca)local cda=bb("y",cca) -local dda=bb("filled",cca)dba:addEllipse(dca,_da,ada,bda,cda,dda)end end -if(_ca["circle"]~=nil)then local aca=_ca["circle"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("radius",cca))local ada=tonumber(bb("x",cca)) -local bda=tonumber(bb("y",cca))local cda=bb("filled",cca) -dba:addCircle(dca,_da,ada,bda,cda)end end -if(_ca["line"]~=nil)then local aca=_ca["line"] -if(aca.properties~=nil)then aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("x",cca))local ada=tonumber(bb("x2",cca)) -local bda=tonumber(bb("y",cca))local cda=tonumber(bb("y2",cca)) -dba:addLine(dca,_da,bda,ada,cda)end end -if(_ca["rectangle"]~=nil)then local aca=_ca["rectangle"]if -(aca.properties~=nil)then aca={aca}end -for bca,cca in pairs(aca)do -local dca=colors[bb("color",cca)]local _da=tonumber(bb("x",cca)) -local ada=tonumber(bb("x2",cca))local bda=tonumber(bb("y",cca)) -local cda=tonumber(bb("y2",cca)) -local dda=bb("filled",cca)=="true"and true or false;dba:addRectangle(dca,_da,bda,ada,cda,dda)end end -if(_ca["triangle"]~=nil)then local aca=_ca["triangle"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("x",cca))local ada=tonumber(bb("x2",cca)) -local bda=tonumber(bb("x2",cca))local cda=tonumber(bb("y",cca)) -local dda=tonumber(bb("y2",cca))local __b=tonumber(bb("y3",cca))local a_b=bb("filled",cca) -dba:addTriangle(dca,_da,cda,ada,dda,bda,__b,a_b)end end;return dba end,addCircle=function(dba,_ca,aca,bca,cca,dca) -local _da=ab[_ca] -table.insert(_d,{_b.circle(bca or 1,cca or 1,aca,dca),ab[_ca]})bba()return dba end,addEllipse=function(dba,_ca,aca,bca,cca,dca,_da) -table.insert(_d,{_b.ellipse( -cca or 1,dca or 1,aca,bca,_da),ab[_ca]})bba()return dba end,addLine=function(dba,_ca,aca,bca,cca,dca) -table.insert(_d,{_b.line( -aca or 1,bca or 1,cca or 1,dca or 1),ab[_ca]})bba()return dba end,addTriangle=function(dba,_ca,aca,bca,cca,dca,_da,ada,bda) -table.insert(_d,{_b.triangle( -aca or 1,bca or 1,cca or 1,dca or 1,_da or 1,ada or 1,bda),ab[_ca]})bba()return dba end,addRectangle=function(dba,_ca,aca,bca,cca,dca,_da) -table.insert(_d,{_b.rectangle( -aca or 1,bca or 1,cca or 1,dca or 1,_da),ab[_ca]})bba()return dba end,shrink=function(dba) -cd=true;_ba()aba()return dba end,setDragable=function(dba,_ca) -a_a=_ca==true and true or false;return dba end,mouseHandler=function(dba,_ca,aca,bca,cca) -if(cc.mouseHandler(dba,_ca,aca,bca,cca))then -if -(a_a)then if(_ca=="mouse_click")then b_a,c_a=bca,cca end -if(_ca=="mouse_drag")then if -(b_a~=nil)and(c_a~=nil)then -dd=_c(ac(dd+b_a-bca,d_a-dba:getWidth()),0)b_a=bca -__a=_c(ac(__a+c_a-cca,_aa-dba:getHeight()),0)c_a=cca end end end;return true end;return false end,draw=function(dba) -if -(cc.draw(dba))then -if(dba.parent~=nil)then local _ca,aca=dba:getAnchorPosition() -local bca,cca=dba:getSize()if(dba.bgColor~=false)then -dba.parent:drawBackgroundBox(_ca,aca,bca,cca,dba.bgColor)end -if(cd)then local dca,_da,ada=bd[1],bd[2],bd[3] -for i=1,bd.height -do local bda,cda=_ca+dd,aca+i-1 +__a -if -(cda>aca-1)and(cda<=aca+cca-1)and(bda<=bca+_ca)then local dda=dca[i]local __b,a_b,b_b=_c(bda,_ca),_c(1 -bda+1,1),ac( -bca- (bda-_ca),bca) -if -type(dda)=="string"then dba.parent:setText(__b,cda,cb(dda,a_b,b_b)) -dba.parent:setFG(__b,cda,cb(_da[i],a_b,b_b)) -dba.parent:setBG(__b,cda,cb(ada[i],a_b,b_b))elseif type(dda)=="table"then -dba.parent:setText(__b,cda,cb(dda[2],a_b,b_b)) -dba.parent:setFG(__b,cda,cb(_da[i],a_b,b_b)) -dba.parent:setBG(__b,cda,cb(ada[i],a_b,b_b))end end end else -for i=1,#ad do local dca,_da=_ca+dd,aca+i-1 +__a -if -(_da>aca-1)and(_da<=aca+cca-1)and(dca<=bca+_ca)then local ada,bda,cda=_c(dca,_ca),_c(1 -dca+1,1),ac(bca- -(dca-_ca),bca) -dba.parent:setBG(ada,_da,cb(ad[i],bda,cda))end end end end;dba:setVisualChanged(false)end end}return setmetatable(cba,cc)end -end; -project['objects']['Image'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Image"aa:setZIndex(2)local ca;local da;local _b=false -local function ab() -local cb={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local db,_c,ac={},{},{}for i=0,15 do _c[2 ^i]=i end -do local cd="0123456789abcdef" -for i=1,16 do db[cd:sub(i,i)]= -i-1;db[i-1]=cd:sub(i,i) -ac[cd:sub(i,i)]=2 ^ (i-1)ac[2 ^ (i-1)]=cd:sub(i,i)local dd=cb[i-1]for i=1,#dd do -dd[i]=2 ^dd[i]end end end -local function bc(cd)local dd=cb[_c[cd[#cd][1] ] ] -for j=1,#dd do local __a=dd[j]for i=1,#cd-1 do if -cd[i][1]==__a then return i end end end;return 1 end -local function cc(cd,dd) -if not dd then local a_a={}dd={}for i=1,6 do local b_a=cd[i]local c_a=dd[b_a] -dd[b_a],a_a[i]=c_a and(c_a+1)or 1,b_a end;cd=a_a end;local __a={}for a_a,b_a in pairs(dd)do __a[#__a+1]={a_a,b_a}end -if -#__a>1 then -while#__a>2 do -table.sort(__a,function(aaa,baa)return aaa[2]>baa[2]end)local b_a,c_a=bc(__a),#__a;local d_a,_aa=__a[c_a][1],__a[b_a][1]for i=1,6 do -if -cd[i]==d_a then cd[i]=_aa;__a[b_a][2]=__a[b_a][2]+1 end end;__a[c_a]=nil end;local a_a=128 -for i=1,#cd-1 do if cd[i]~=cd[6]then a_a=a_a+2 ^ (i-1)end end -return string.char(a_a),ac[__a[1][1]==cd[6]and __a[2][1]or -__a[1][1] ],ac[cd[6] ]else return"\128",ac[cd[1] ],ac[cd[1] ]end end -local dc,_d,ad,bd={{},{},{}},0,#ca+#ca%3,aa.bgColor or colors.black;for i=1,#ca do if#ca[i]>_d then _d=#ca[i]end end -for y=0,ad-1,3 do -local cd,dd,__a,a_a={},{},{},1 -for x=0,_d-1,2 do local b_a,c_a={},{} -for yy=1,3 do -for xx=1,2 do -b_a[#b_a+1]=(ca[y+yy]and ca[y+yy][x+xx])and -(ca[y+ -yy][x+xx]==0 and bd or ca[y+yy][x+xx])or bd;c_a[b_a[#b_a] ]= -c_a[b_a[#b_a] ]and(c_a[b_a[#b_a] ]+1)or 1 end end;cd[a_a],dd[a_a],__a[a_a]=cc(b_a,c_a)a_a=a_a+1 end -dc[1][#dc[1]+1],dc[2][#dc[2]+1],dc[3][#dc[3]+1]=table.concat(cd),table.concat(dd),table.concat(__a)end;dc.width,dc.height=#dc[1][1],#dc[1]da=dc end -local bb={init=function(cb)cb.bgColor=cb.parent:getTheme("ImageBG")end,getType=function(cb)return -ba end,loadImage=function(cb,db)ca=paintutils.loadImage(db)_b=false;return cb end,shrink=function(cb) -ab()_b=true;return cb end,setValuesByXMLData=function(cb,db)aa.setValuesByXMLData(cb,db) -if( -d("shrink",db)~=nil)then if(d("shrink",db))then cb:shrink()end end -if(d("path",db)~=nil)then cb:loadImage(d("path",db))end;return cb end,draw=function(cb) -if -(aa.draw(cb))then -if(cb.parent~=nil)then -if(ca~=nil)then local db,_c=cb:getAnchorPosition() -local ac,bc=cb:getSize() -if(_b)then local cc,dc,_d=da[1],da[2],da[3] -for i=1,da.height do local ad=cc[i] -if type(ad)=="string"then cb.parent:setText(db, -_c+i-1,ad) -cb.parent:setFG(db,_c+i-1,dc[i])cb.parent:setBG(db,_c+i-1,_d[i])elseif -type(ad)=="table"then cb.parent:setText(db,_c+i-1,ad[2])cb.parent:setFG(db,_c+ -i-1,dc[i]) -cb.parent:setBG(db,_c+i-1,_d[i])end end else -for yPos=1,math.min(#ca,bc)do local cc=ca[yPos] -for xPos=1,math.min(#cc,ac)do if cc[xPos]>0 then -cb.parent:drawBackgroundBox( -db+xPos-1,_c+yPos-1,1,1,cc[xPos])end end end end end end;cb:setVisualChanged(false)end end}return setmetatable(bb,aa)end -end; -project['objects']['Input'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Input"local _b="text"local ab=0;ca:setZIndex(5) -ca:setValue("")ca.width=10;ca.height=1;local bb=1;local cb=1;local db=""local _c;local ac;local bc=db;local cc=false -local dc={init=function(_d) -_d.bgColor=_d.parent:getTheme("InputBG")_d.fgColor=_d.parent:getTheme("InputFG")end,getType=function(_d)return -da end,setInputType=function(_d,ad)if -(ad=="password")or(ad=="number")or(ad=="text")then _b=ad end;return _d end,setDefaultText=function(_d,ad,bd,cd) -db=ad;_c=cd or _c;ac=bd or ac;if(_d:isFocused())then bc=""else bc=db end -return _d end,getInputType=function(_d)return _b end,setValue=function(_d,ad) -ca.setValue(_d,tostring(ad)) -if not(cc)then bb=tostring(ad):len()+1 end;return _d end,getValue=function(_d) -local ad=ca.getValue(_d)return _b=="number"and tonumber(ad)or ad end,setInputLimit=function(_d,ad)ab= -tonumber(ad)or ab;return _d end,getInputLimit=function(_d)return ab end,setValuesByXMLData=function(_d,ad) -ca.setValuesByXMLData(_d,ad)local bd,cd -if(aa("defaultBG",ad)~=nil)then bd=aa("defaultBG",ad)end -if(aa("defaultFG",ad)~=nil)then cd=aa("defaultFG",ad)end;if(aa("default",ad)~=nil)then -_d:setDefaultText(aa("default",ad),cd~=nil and colors[cd], -bd~=nil and colors[bd])end -if -(aa("limit",ad)~=nil)then _d:setInputLimit(aa("limit",ad))end -if(aa("type",ad)~=nil)then _d:setInputType(aa("type",ad))end;return _d end,getFocusHandler=function(_d) -ca.getFocusHandler(_d) -if(_d.parent~=nil)then local ad,bd=_d:getAnchorPosition()bc=""if(_d.parent~=nil)then -_d.parent:setCursor(true, -ad+bb-cb,bd+math.floor(_d.height/2),_d.fgColor)end end end,loseFocusHandler=function(_d) -ca.loseFocusHandler(_d) -if(_d.parent~=nil)then _d.parent:setCursor(false)bc=db end end,keyHandler=function(_d,ad,bd) -if(ca.keyHandler(_d,ad,bd))then -local cd,dd=_d:getSize()cc=true -if(ad=="key")then -if(bd==keys.backspace)then -local d_a=tostring(ca.getValue())if(bb>1)then -_d:setValue(d_a:sub(1,bb-2)..d_a:sub(bb,d_a:len()))if(bb>1)then bb=bb-1 end -if(cb>1)then if(bbd_a)then bb=d_a+1 end;if(bb<1)then bb=1 end;if -(bb=cd+cb)then cb=bb-cd+1 end;if(cb<1)then cb=1 end end -if(bd==keys.left)then bb=bb-1;if(bb>=1)then -if(bb=cd+cb)then cb=bb end end;if(bb<1)then bb=1 end;if(cb<1)then cb=1 end end end -if(ad=="char")then local d_a=ca.getValue() -if(d_a:len()=cd+cb)then cb=cb+1 end end end;local __a,a_a=_d:getAnchorPosition() -local b_a=tostring(ca.getValue()) -local c_a=(bb<=b_a:len()and bb-1 or b_a:len())- (cb-1)if(c_a>_d.x+cd-1)then c_a=_d.x+cd-1 end;if -(_d.parent~=nil)then -_d.parent:setCursor(true,__a+c_a,a_a+math.floor(dd/2),_d.fgColor)end;cc=false end end,mouseHandler=function(_d,ad,bd,cd,dd) -if -(ca.mouseHandler(_d,ad,bd,cd,dd))then if(ad=="mouse_click")and(bd==1)then end;return true end;return false end,draw=function(_d) -if -(ca.draw(_d))then -if(_d.parent~=nil)then local ad,bd=_d:getAnchorPosition() -local cd,dd=_d:getSize()local __a=_a.getTextVerticalAlign(dd,"center")if -(_d.bgColor~=false)then -_d.parent:drawBackgroundBox(ad,bd,cd,dd,_d.bgColor)end -for n=1,dd do -if(n==__a)then -local a_a=tostring(ca.getValue())local b_a=_d.bgColor;local c_a=_d.fgColor;local d_a;if(a_a:len()<=0)then d_a=bc;b_a=_c or b_a;c_a= -ac or c_a end;d_a=bc -if(a_a~="")then d_a=a_a end;d_a=d_a:sub(cb,cd+cb-1)local _aa=cd-d_a:len() -if(_aa<0)then _aa=0 end;if(_b=="password")and(a_a~="")then -d_a=string.rep("*",d_a:len())end -d_a=d_a..string.rep(" ",_aa)_d.parent:writeText(ad,bd+ (n-1),d_a,b_a,c_a)end end end;_d:setVisualChanged(false)end end}return setmetatable(dc,ca)end -end; -project['objects']['Label'] = function(...)local ba=require("Object")local ca=require("utils") -local da=ca.getValueFromXML;local _b=ca.createText;local ab=require("tHex")local bb=require("bigfont") -return -function(cb) -local db=ba(cb)local _c="Label"db:setZIndex(3)local ac=true;db:setValue("Label") -db.width=5;local bc="left"local cc="top"local dc=0;local _d,ad=false,false -local bd={getType=function(cd)return _c end,setText=function(cd,dd) -dd=tostring(dd)db:setValue(dd)if(ac)then cd.width=dd:len()end -if not(_d)then cd.fgColor= -cd.parent:getForeground()or colors.white end;if not(ad)then -cd.bgColor=cd.parent:getBackground()or colors.black end;return cd end,setBackground=function(cd,dd) -db.setBackground(cd,dd)ad=true;return cd end,setForeground=function(cd,dd) -db.setForeground(cd,dd)_d=true;return cd end,setTextAlign=function(cd,dd,__a)bc=dd or bc;cc=__a or cc -cd:setVisualChanged()return cd end,setFontSize=function(cd,dd)if(dd>0)and(dd<=4)then -dc=dd-1 or 0 end;return cd end,getFontSize=function(cd)return dc+1 end,setValuesByXMLData=function(cd,dd) -db.setValuesByXMLData(cd,dd) -if(da("text",dd)~=nil)then cd:setText(da("text",dd))end -if(da("verticalAlign",dd)~=nil)then cc=da("verticalAlign",dd)end;if(da("horizontalAlign",dd)~=nil)then -bc=da("horizontalAlign",dd)end;if(da("font",dd)~=nil)then -cd:setFontSize(da("font",dd))end;return cd end,setSize=function(cd,dd,__a) -db.setSize(cd,dd,__a)ac=false;cd:setVisualChanged()return cd end,draw=function(cd) -if -(db.draw(cd))then -if(cd.parent~=nil)then local dd,__a=cd:getAnchorPosition() -local a_a,b_a=cd:getSize()local c_a=ca.getTextVerticalAlign(b_a,cc) -if(cd.bgColor~=false)then -cd.parent:drawBackgroundBox(dd,__a,a_a,b_a,cd.bgColor)cd.parent:drawTextBox(dd,__a,a_a,b_a," ")end;if(cd.fgColor~=false)then -cd.parent:drawForegroundBox(dd,__a,a_a,b_a,cd.fgColor)end -if(dc==0)then -if not(ac)then -local d_a=_b(cd:getValue(),cd:getWidth()) -for _aa,aaa in pairs(d_a)do cd.parent:setText(dd,__a+_aa-1,aaa)end else -for n=1,b_a do if(n==c_a)then -cd.parent:setText(dd,__a+ (n-1),ca.getTextHorizontalAlign(cd:getValue(),a_a,bc))end end end else -local d_a=bb(dc,cd:getValue(),cd.fgColor,cd.bgColor or colors.black) -if(ac)then cd:setSize(#d_a[1][1],#d_a[1]-1)end -for n=1,b_a do -if(n==c_a)then local _aa,aaa=cd.parent:getSize() -local baa,caa=#d_a[1][1],#d_a[1] -dd=dd or math.floor((_aa-baa)/2)+1 -__a=__a or math.floor((aaa-caa)/2)+1 -for i=1,caa do -cd.parent:setFG(dd,__a+i+n-2,ca.getTextHorizontalAlign(d_a[2][i],a_a,bc)) -cd.parent:setBG(dd,__a+i+n-2,ca.getTextHorizontalAlign(d_a[3][i],a_a,bc,ab[cd.bgColor or colors.black])) -cd.parent:setText(dd,__a+i+n-2,ca.getTextHorizontalAlign(d_a[1][i],a_a,bc))end end end end end;cd:setVisualChanged(false)end end}return setmetatable(bd,db)end -end; -project['objects']['List'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="List"ca.width=16;ca.height=6;ca:setZIndex(5)local _b={} -local ab;local bb;local cb=true;local db="left"local _c=0;local ac=true -local bc={init=function(cc) -cc.bgColor=cc.parent:getTheme("ListBG")cc.fgColor=cc.parent:getTheme("ListText") -ab=cc.parent:getTheme("SelectionBG")bb=cc.parent:getTheme("SelectionText")end,getType=function(cc)return -da end,addItem=function(cc,dc,_d,ad,...) -table.insert(_b,{text=dc,bgCol=_d or cc.bgColor,fgCol=ad or cc.fgColor,args={...}})if(#_b==1)then cc:setValue(_b[1])end;return cc end,setOffset=function(cc,dc) -_c=dc;return cc end,getOffset=function(cc)return _c end,removeItem=function(cc,dc)table.remove(_b,dc) -return cc end,getItem=function(cc,dc)return _b[dc]end,getAll=function(cc)return _b end,getItemIndex=function(cc) -local dc=cc:getValue()for _d,ad in pairs(_b)do if(ad==dc)then return _d end end end,clear=function(cc) -_b={}cc:setValue({})return cc end,getItemCount=function(cc)return#_b end,editItem=function(cc,dc,_d,ad,bd,...) -table.remove(_b,dc) -table.insert(_b,dc,{text=_d,bgCol=ad or cc.bgColor,fgCol=bd or cc.fgColor,args={...}})return cc end,selectItem=function(cc,dc)cc:setValue( -_b[dc]or{})return cc end,setSelectedItem=function(cc,dc,_d,ad) -ab=dc or cc.bgColor;bb=_d or cc.fgColor;cb=ad;return cc end,setScrollable=function(cc,dc) -ac=dc;return cc end,setValuesByXMLData=function(cc,dc)ca.setValuesByXMLData(cc,dc) -if( -aa("selectionBG",dc)~=nil)then ab=colors[aa("selectionBG",dc)]end;if(aa("selectionFG",dc)~=nil)then -bb=colors[aa("selectionFG",dc)]end;if(aa("scrollable",dc)~=nil)then -if -(aa("scrollable",dc))then cc:setScrollable(true)else cc:setScrollable(false)end end;if -(aa("offset",dc)~=nil)then _c=aa("offset",dc)end -if(dc["item"]~=nil)then -local _d=dc["item"]if(_d.properties~=nil)then _d={_d}end;for ad,bd in pairs(_d)do -cc:addItem(aa("text",bd),colors[aa("bg",bd)],colors[aa("fg",bd)])end end;return cc end,mouseHandler=function(cc,dc,_d,ad,bd) -local cd,dd=cc:getAbsolutePosition(cc:getAnchorPosition())local __a,a_a=cc:getSize() -if - -(cd<=ad)and(cd+__a>ad)and(dd<=bd)and(dd+a_a>bd)and(cc:isVisible())then -if -( ( (dc=="mouse_click")or(dc=="mouse_drag"))and(_d==1))or(dc=="monitor_touch")then -if(#_b>0)then -for n=1,a_a do -if( -_b[n+_c]~=nil)then if(cd<=ad)and(cd+__a>ad)and(dd+n-1 ==bd)then cc:setValue(_b[ -n+_c]) -cc:getEventSystem():sendEvent("mouse_click",cc,"mouse_click",0,ad,bd,_b[ -n+_c])end end end end end -if(dc=="mouse_scroll")and(ac)then _c=_c+_d;if(_c<0)then _c=0 end -if(_d>=1)then if(#_b>a_a)then if( -_c>#_b-a_a)then _c=#_b-a_a end -if(_c>=#_b)then _c=#_b-1 end else _c=_c-1 end end end;cc:setVisualChanged()return true end end,draw=function(cc) -if -(ca.draw(cc))then -if(cc.parent~=nil)then local dc,_d=cc:getAnchorPosition() -local ad,bd=cc:getSize()if(cc.bgColor~=false)then -cc.parent:drawBackgroundBox(dc,_d,ad,bd,cc.bgColor)end -for n=1,bd do -if(_b[n+_c]~=nil)then -if(_b[n+_c]== -cc:getValue())then -if(cb)then -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),ab,bb)else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end end end end;cc:setVisualChanged(false)end end}return setmetatable(bc,ca)end -end; -project['objects']['Menubar'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=aa.getValueFromXML;local ca=require("tHex") -return -function(da)local _b=_a(da)local ab="Menubar"local bb={}_b.width=30 -_b.height=1;_b:setZIndex(5)local cb={}local db;local _c;local ac=true;local bc="left"local cc=0;local dc=1 -local _d=false -local function ad()local bd=0;local cd=0;local dd=bb:getWidth() -for n=1,#cb do if(cd+cb[n].text:len()+ -dc*2 >dd)then -if(cddd)then cc=dd end;return bd end,getOffset=function(bd)return -cc end,setScrollable=function(bd,cd)_d=cd;if(cd==nil)then _d=true end;return bd end,setValuesByXMLData=function(bd,cd) -_b.setValuesByXMLData(bd,cd)if(ba("selectionBG",cd)~=nil)then -db=colors[ba("selectionBG",cd)]end;if(ba("selectionFG",cd)~=nil)then -_c=colors[ba("selectionFG",cd)]end;if(ba("scrollable",cd)~=nil)then -if -(ba("scrollable",cd))then bd:setScrollable(true)else bd:setScrollable(false)end end -if -(ba("offset",cd)~=nil)then bd:setOffset(ba("offset",cd))end;if(ba("space",cd)~=nil)then dc=ba("space",cd)end -if( -cd["item"]~=nil)then local dd=cd["item"]if(dd.properties~=nil)then dd={dd}end;for __a,a_a in -pairs(dd)do -bd:addItem(ba("text",a_a),colors[ba("bg",a_a)],colors[ba("fg",a_a)])end end;return bd end,removeItem=function(bd,cd) -table.remove(cb,cd)return bd end,getItem=function(bd,cd)return cb[cd]end,getItemCount=function(bd)return#cb end,editItem=function(bd,cd,dd,__a,a_a,...) -table.remove(cb,cd) -table.insert(cb,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol=a_a or bd.fgColor,args={...}})return bd end,selectItem=function(bd,cd)bd:setValue( -cb[cd]or{})return bd end,setSelectedItem=function(bd,cd,dd,__a) -db=cd or bd.bgColor;_c=dd or bd.fgColor;ac=__a;return bd end,mouseHandler=function(bd,cd,dd,__a,a_a) -if -(_b.mouseHandler(bd,cd,dd,__a,a_a))then -local b_a,c_a=bd:getAbsolutePosition(bd:getAnchorPosition())local d_a,_aa=bd:getSize() -if - -(b_a<=__a)and(b_a+d_a>__a)and(c_a<=a_a)and(c_a+_aa>a_a)and(bd:isVisible())then -if(bd.parent~=nil)then bd.parent:setFocusedObject(bd)end -if(cd=="mouse_click")or(cd=="monitor_touch")then local aaa=0 -for n=1,#cb do -if -(cb[n]~=nil)then -if -(b_a+aaa<=__a+cc)and( -b_a+aaa+cb[n].text:len()+ (dc*2)>__a+cc)and(c_a==a_a)then bd:setValue(cb[n]) -bd:getEventSystem():sendEvent(cd,bd,cd,0,__a,a_a,cb[n])end;aaa=aaa+cb[n].text:len()+dc*2 end end end;if(cd=="mouse_scroll")and(_d)then cc=cc+dd;if(cc<0)then cc=0 end;local aaa=ad()if -(cc>aaa)then cc=aaa end end -bd:setVisualChanged(true)return true end end;return false end,draw=function(bd) -if -(_b.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=""local c_a=""local d_a="" -for _aa,aaa in pairs(cb)do -local baa= -(" "):rep(dc)..aaa.text.. (" "):rep(dc)b_a=b_a..baa -if(aaa==bd:getValue())then c_a=c_a.. -ca[db or aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[_c or aaa.FgCol or -bd.fgColor]:rep(baa:len())else c_a=c_a.. -ca[aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[aaa.FgCol or bd.fgColor]:rep(baa:len())end end -bd.parent:setText(cd,dd,b_a:sub(cc+1,__a+cc)) -bd.parent:setBG(cd,dd,c_a:sub(cc+1,__a+cc)) -bd.parent:setFG(cd,dd,d_a:sub(cc+1,__a+cc))end;bd:setVisualChanged(false)end end}return setmetatable(bb,_b)end -end; -project['objects']['Pane'] = function(...)local b=require("Object") -return -function(c)local d=b(c)local _a="Pane" -local aa={init=function(ba) -ba.bgColor=ba.parent:getTheme("PaneBG")ba.fgColor=ba.parent:getTheme("PaneBG")end,getType=function(ba)return -_a end,draw=function(ba) -if(d.draw(ba))then -if(ba.parent~=nil)then -local ca,da=ba:getAnchorPosition()local _b,ab=ba:getSize() -ba.parent:drawBackgroundBox(ca,da,_b,ab,ba.bgColor) -ba.parent:drawForegroundBox(ca,da,_b,ab,ba.fgColor)end;ba:setVisualChanged(false)end end}return setmetatable(aa,d)end -end; -project['objects']['Program'] = function(...)local aa=require("Object")local ba=require("tHex") -local ca=require("process")local da=require("utils").getValueFromXML;local _b=string.sub -return -function(ab,bb) -local cb=aa(ab)local db="Program"cb:setZIndex(5)local _c;local ac -local function bc(bd,cd,dd,__a)local a_a,b_a=1,1 -local c_a,d_a=colors.black,colors.white;local _aa=false;local aaa=false;local baa={}local caa={}local daa={}local _ba={}local aba;local bba={}for i=0,15 do local __b=2 ^i -_ba[__b]={bb:getBasaltInstance().getBaseTerm().getPaletteColour(__b)}end;local function cba()aba=(" "):rep(dd) -for n=0,15 -do local __b=2 ^n;local a_b=ba[__b]bba[__b]=a_b:rep(dd)end end -local function dba()cba()local __b=aba -local a_b=bba[colors.white]local b_b=bba[colors.black] -for n=1,__a do -baa[n]=_b(baa[n]==nil and __b or baa[n]..__b:sub(1,dd- -baa[n]:len()),1,dd) -daa[n]=_b(daa[n]==nil and a_b or daa[n].. -a_b:sub(1,dd-daa[n]:len()),1,dd) -caa[n]=_b(caa[n]==nil and b_b or caa[n].. -b_b:sub(1,dd-caa[n]:len()),1,dd)end end;dba()local function _ca() -if a_a>=1 and b_a>=1 and a_a<=dd and b_a<=__a then else end end -local function aca(__b,a_b,b_b)local c_b=a_a;local d_b=c_b+#__b-1 -if -b_a>=1 and b_a<=__a then -if c_b<=dd and d_b>=1 then -if c_b==1 and d_b==dd then -baa[b_a]=__b;daa[b_a]=a_b;caa[b_a]=b_b else local _ab,aab,bab -if c_b<1 then local dbb=1 -c_b+1 -local _cb=dd-c_b+1;_ab=_b(__b,dbb,_cb)aab=_b(a_b,dbb,_cb)bab=_b(b_b,dbb,_cb)elseif -d_b>dd then local dbb=dd-c_b+1;_ab=_b(__b,1,dbb)aab=_b(a_b,1,dbb) -bab=_b(b_b,1,dbb)else _ab=__b;aab=a_b;bab=b_b end;local cab=baa[b_a]local dab=daa[b_a]local _bb=caa[b_a]local abb,bbb,cbb -if c_b>1 then local dbb=c_b-1;abb= -_b(cab,1,dbb).._ab;bbb=_b(dab,1,dbb)..aab -cbb=_b(_bb,1,dbb)..bab else abb=_ab;bbb=aab;cbb=bab end -if d_b
=1 and d_b<=__a then -baa[newY]=baa[d_b]caa[newY]=caa[d_b]daa[newY]=daa[d_b]else baa[newY]=a_b -daa[newY]=b_b;caa[newY]=c_b end end end;if(aaa)then _ca()end end,isColor=function()return -bb:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return -bb:getBasaltInstance().getBaseTerm().isColor()end,write=function(__b) -__b=tostring(__b)if(aaa)then -aca(__b,ba[d_a]:rep(__b:len()),ba[c_a]:rep(__b:len()))end end,clearLine=function() -if -(aaa)then bca(1,b_a,(" "):rep(dd)) -cca(1,b_a,ba[c_a]:rep(dd))dca(1,b_a,ba[d_a]:rep(dd))end;if(aaa)then _ca()end end,clear=function() -for n=1,__a -do bca(1,n,(" "):rep(dd)) -cca(1,n,ba[c_a]:rep(dd))dca(1,n,ba[d_a]:rep(dd))end;if(aaa)then _ca()end end,blit=function(__b,a_b,b_b)if -type(__b)~="string"then -error("bad argument #1 (expected string, got "..type(__b)..")",2)end;if type(a_b)~="string"then -error( -"bad argument #2 (expected string, got "..type(a_b)..")",2)end;if type(b_b)~="string"then -error( -"bad argument #3 (expected string, got "..type(b_b)..")",2)end -if -#a_b~=#__b or#b_b~=#__b then error("Arguments must be the same length",2)end;if(aaa)then aca(__b,a_b,b_b)end end}return dda end;cb.width=30;cb.height=12;local cc=bc(1,1,cb.width,cb.height)local dc -local _d=false;local ad={} -_c={init=function(bd)bd.bgColor=bd.parent:getTheme("ProgramBG")end,getType=function(bd)return -db end,show=function(bd)cb.show(bd) -cc.setBackgroundColor(bd.bgColor)cc.setTextColor(bd.fgColor) -cc.basalt_setVisible(true)return bd end,hide=function(bd) -cb.hide(bd)cc.basalt_setVisible(false)return bd end,setPosition=function(bd,cd,dd,__a) -cb.setPosition(bd,cd,dd,__a) -cc.basalt_reposition(bd:getAnchorPosition())return bd end,setValuesByXMLData=function(bd,cd) -cb.setValuesByXMLData(bd,cd)if(da("path",cd)~=nil)then ac=da("path",cd)end;if( -da("execute",cd)~=nil)then -if(da("execute",cd))then if(ac~=nil)then bd:execute(ac)end end end end,getBasaltWindow=function()return -cc end,getBasaltProcess=function()return dc end,setSize=function(bd,cd,dd,__a)cb.setSize(bd,cd,dd,__a) -cc.basalt_resize(bd:getSize())return bd end,getStatus=function(bd)if(dc~=nil)then -return dc:getStatus()end;return"inactive"end,execute=function(bd,cd,...) -ac=cd or ac;dc=ca:new(ac,cc,...) -cc.setBackgroundColor(colors.black)cc.setTextColor(colors.white)cc.clear() -cc.setCursorPos(1,1)cc.setBackgroundColor(bd.bgColor) -cc.setTextColor(bd.fgColor)cc.basalt_setVisible(true)dc:resume()_d=false;return bd end,stop=function(bd)if( -dc~=nil)then -if not(dc:isDead())then dc:resume("terminate")if(dc:isDead())then -if( -bd.parent~=nil)then bd.parent:setCursor(false)end end end end -return bd end,pause=function(bd,cd)_d= -cd or(not _d) -if(dc~=nil)then if not(dc:isDead())then if not(_d)then -bd:injectEvents(ad)ad={}end end end;return bd end,isPaused=function(bd) -return _d end,injectEvent=function(bd,cd,dd,__a,a_a,b_a,c_a) -if(dc~=nil)then -if not(dc:isDead())then if(_d==false)or(c_a)then -dc:resume(cd,dd,__a,a_a,b_a)else -table.insert(ad,{event=cd,args={dd,__a,a_a,b_a}})end end end;return bd end,getQueuedEvents=function(bd)return -ad end,updateQueuedEvents=function(bd,cd)ad=cd or ad;return bd end,injectEvents=function(bd,cd)if(dc~=nil)then -if -not(dc:isDead())then for dd,__a in pairs(cd)do -dc:resume(__a.event,table.unpack(__a.args))end end end;return bd end,mouseHandler=function(bd,cd,dd,__a,a_a) -if -(cb.mouseHandler(bd,cd,dd,__a,a_a))then if(dc==nil)then return false end -if not(dc:isDead())then -if not(_d)then -local b_a,c_a=bd:getAbsolutePosition(bd:getAnchorPosition( -nil,nil,true))dc:resume(cd,dd,__a-b_a+1,a_a-c_a+1)end end;return true end end,keyHandler=function(bd,cd,dd) -cb.keyHandler(bd,cd,dd)if(bd:isFocused())then if(dc==nil)then return false end -if not(dc:isDead())then if not(_d)then if -(bd.draw)then dc:resume(cd,dd)end end end end end,getFocusHandler=function(bd) -cb.getFocusHandler(bd) -if(dc~=nil)then -if not(dc:isDead())then -if not(_d)then -if(bd.parent~=nil)then -local cd,dd=cc.getCursorPos()local __a,a_a=bd:getAnchorPosition() -if(bd.parent~=nil)then -local b_a,c_a=bd:getSize() -if -(__a+cd-1 >=1 and __a+cd-1 <=__a+b_a-1 and -dd+a_a-1 >=1 and dd+a_a-1 <=a_a+c_a-1)then -bd.parent:setCursor(cc.getCursorBlink(),__a+cd-1,dd+a_a-1,cc.getTextColor())end end end end end end end,loseFocusHandler=function(bd) -cb.loseFocusHandler(bd) -if(dc~=nil)then if not(dc:isDead())then if(bd.parent~=nil)then -bd.parent:setCursor(false)end end end end,eventHandler=function(bd,cd,dd,__a,a_a,b_a)if -(dc==nil)then return end -if not(dc:isDead())then -if not(_d)then -if - - - -(cd~="mouse_click")and -(cd~="monitor_touch")and(cd~="mouse_up")and(cd~= -"mouse_scroll")and(cd~="mouse_drag")and(cd~="key_up")and( -cd~="key")and(cd~="char")and(cd~="terminate")then dc:resume(cd,dd,__a,a_a,b_a)end -if(bd:isFocused())then local c_a,d_a=bd:getAnchorPosition() -local _aa,aaa=cc.getCursorPos() -if(bd.parent~=nil)then local baa,caa=bd:getSize() -if -( -c_a+_aa-1 >=1 and c_a+_aa-1 <= -c_a+baa-1 and aaa+d_a-1 >=1 and aaa+d_a-1 <=d_a+caa-1)then -bd.parent:setCursor(cc.getCursorBlink(),c_a+_aa-1,aaa+d_a-1,cc.getTextColor())end end -if(cd=="terminate")and(bd:isFocused())then bd:stop()end end else -if - - - - -(cd~="mouse_click")and(cd~="monitor_touch")and(cd~="mouse_up")and(cd~="mouse_scroll")and -(cd~="mouse_drag")and(cd~="key_up")and(cd~="key")and(cd~="char")and(cd~="terminate")then -table.insert(ad,{event=cd,args={dd,__a,a_a,b_a}})end end end end,draw=function(bd) -if -(cb.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()cc.basalt_reposition(cd,dd)if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;cc.basalt_update()end;bd:setVisualChanged(false)end end}return setmetatable(_c,cb)end -end; -project['objects']['Progressbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Progressbar"local ca=0;aa:setZIndex(5) -aa:setValue(false)aa.width=25;aa.height=1;local da;local _b=""local ab=colors.white;local bb=""local cb=0 -local db={init=function(_c) -_c.bgColor=_c.parent:getTheme("ProgressbarBG")_c.fgColor=_c.parent:getTheme("ProgressbarText") -da=_c.parent:getTheme("ProgressbarActiveBG")end,getType=function(_c)return -ba end,setValuesByXMLData=function(_c,ac)aa.setValuesByXMLData(_c,ac)if(d("direction",ac)~= -nil)then cb=d("direction",ac)end -if( -d("progressColor",ac)~=nil)then da=colors[d("progressColor",ac)]end -if(d("progressSymbol",ac)~=nil)then _b=d("progressSymbol",ac)end;if(d("backgroundSymbol",ac)~=nil)then -bb=d("backgroundSymbol",ac)end -if -(d("progressSymbolColor",ac)~=nil)then ab=colors[d("progressSymbolColor",ac)]end;if(d("onDone",ac)~=nil)then -_c:generateXMLEventFunction(_c.onProgressDone,d("onDone",ac))end;return _c end,setDirection=function(_c,ac) -cb=ac;return _c end,setProgressBar=function(_c,ac,bc,cc)da=ac or da;_b=bc or _b;ab=cc or ab;return _c end,setBackgroundSymbol=function(_c,ac) -bb=ac:sub(1,1)return _c end,setProgress=function(_c,ac) -if(ac>=0)and(ac<=100)and(ca~=ac)then ca=ac -_c:setValue(ca)if(ca==100)then _c:progressDoneHandler()end end;return _c end,getProgress=function(_c) -return ca end,onProgressDone=function(_c,ac)_c:registerEvent("progress_done",ac)return _c end,progressDoneHandler=function(_c) -_c:sendEvent("progress_done",_c)end,draw=function(_c) -if(aa.draw(_c))then -if(_c.parent~=nil)then -local ac,bc=_c:getAnchorPosition()local cc,dc=_c:getSize()if(_c.bgColor~=false)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc,_c.bgColor)end;if(bb~="")then -_c.parent:drawTextBox(ac,bc,cc,dc,bb)end;if(_c.fgColor~=false)then -_c.parent:drawForegroundBox(ac,bc,cc,dc,_c.fgColor)end -if(cb==1)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc,cc,dc/100 *ca,ab) -_c.parent:drawTextBox(ac,bc,cc,dc/100 *ca,_b)elseif(cb==2)then -_c.parent:drawBackgroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc,dc/ -100 *ca,ab) -_c.parent:drawTextBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,_b)elseif(cb==3)then -_c.parent:drawBackgroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac+math.ceil(cc-cc/100 *ca),bc,cc/100 * -ca,dc,_b)else -_c.parent:drawBackgroundBox(ac,bc,cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac,bc,cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac,bc,cc/100 *ca,dc,_b)end end;_c:setVisualChanged(false)end end}return setmetatable(db,aa)end -end; -project['objects']['Radio'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Radio"ca.width=8;ca:setZIndex(5)local _b={}local ab;local bb;local cb -local db;local _c;local ac;local bc=true;local cc="\7"local dc="left" -local _d={init=function(ad) -ad.bgColor=ad.parent:getTheme("MenubarBG")ad.fgColor=ad.parent:getTheme("MenubarFG") -ab=ad.parent:getTheme("SelectionBG")bb=ad.parent:getTheme("SelectionText") -cb=ad.parent:getTheme("MenubarBG")db=ad.parent:getTheme("MenubarText")end,getType=function(ad)return -da end,setValuesByXMLData=function(ad,bd)ca.setValuesByXMLData(ad,bd) -if( -aa("selectionBG",bd)~=nil)then ab=colors[aa("selectionBG",bd)]end;if(aa("selectionFG",bd)~=nil)then -bb=colors[aa("selectionFG",bd)]end;if(aa("boxBG",bd)~=nil)then -cb=colors[aa("boxBG",bd)]end;if(aa("inactiveBoxBG",bd)~=nil)then -_c=colors[aa("inactiveBoxBG",bd)]end;if(aa("inactiveBoxFG",bd)~=nil)then -ac=colors[aa("inactiveBoxFG",bd)]end;if(aa("boxFG",bd)~=nil)then -db=colors[aa("boxFG",bd)]end;if(aa("symbol",bd)~=nil)then -cc=aa("symbol",bd)end -if(bd["item"]~=nil)then local cd=bd["item"]if -(cd.properties~=nil)then cd={cd}end;for dd,__a in pairs(cd)do -ad:addItem(aa("text",__a),aa("x",__a),aa("y",__a),colors[aa("bg",__a)],colors[aa("fg",__a)])end end;return ad end,addItem=function(ad,bd,cd,dd,__a,a_a,...) -table.insert(_b,{x= -cd or 1,y=dd or 1,text=bd,bgCol=__a or ad.bgColor,fgCol=a_a or ad.fgColor,args={...}})if(#_b==1)then ad:setValue(_b[1])end;return ad end,getAll=function(ad)return -_b end,removeItem=function(ad,bd)table.remove(_b,bd)return ad end,getItem=function(ad,bd)return -_b[bd]end,getItemIndex=function(ad)local bd=ad:getValue()for cd,dd in pairs(_b)do -if(dd==bd)then return cd end end end,clear=function(ad) -_b={}ad:setValue({})return ad end,getItemCount=function(ad)return#_b end,editItem=function(ad,bd,cd,dd,__a,a_a,b_a,...) -table.remove(_b,bd) -table.insert(_b,bd,{x=dd or 1,y=__a or 1,text=cd,bgCol=a_a or ad.bgColor,fgCol=b_a or ad.fgColor,args={...}})return ad end,selectItem=function(ad,bd)ad:setValue( -_b[bd]or{})return ad end,setActiveSymbol=function(ad,bd) -cc=bd:sub(1,1)return ad end,setSelectedItem=function(ad,bd,cd,dd,__a,a_a)ab=bd or ab;bb=cd or bb;cb=dd or cb -db=__a or db;bc=a_a~=nil and a_a or true;return ad end,mouseHandler=function(ad,bd,cd,dd,__a) -local a_a,b_a=ad:getAbsolutePosition(ad:getAnchorPosition()) -if -( (bd=="mouse_click")and(cd==1))or(bd=="monitor_touch")then -if(#_b>0)then -for c_a,d_a in pairs(_b)do -if(a_a+d_a.x-1 <=dd)and( -a_a+d_a.x-1 +d_a.text:len()+2 >=dd)and( -b_a+d_a.y-1 ==__a)then -ad:setValue(d_a) -if(ad.parent~=nil)then ad.parent:setFocusedObject(ad)end -ad:getEventSystem():sendEvent(bd,ad,bd,cd,dd,__a)ad:setVisualChanged()return true end end end end;return false end,draw=function(ad) -if -(ca.draw(ad))then -if(ad.parent~=nil)then local bd,cd=ad:getAnchorPosition() -for dd,__a in pairs(_b)do -if(__a== -ad:getValue())then if(dc=="left")then -ad.parent:writeText(__a.x+bd-1,__a.y+cd-1,cc,cb,db) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,ab,bb)end else -ad.parent:drawBackgroundBox( -__a.x+bd-1,__a.y+cd-1,1,1,_c or ad.bgColor) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,__a.bgCol,__a.fgCol)end end end;ad:setVisualChanged(false)end end}return setmetatable(_d,ca)end -end; -project['objects']['Scrollbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Scrollbar"aa.width=1;aa.height=8;aa:setValue(1) -aa:setZIndex(2)local ca="vertical"local da=" "local _b;local ab="\127"local bb=aa.height;local cb=1;local db=1 -local _c={init=function(ac) -ac.bgColor=ac.parent:getTheme("ScrollbarBG")ac.fgColor=ac.parent:getTheme("ScrollbarText") -_b=ac.parent:getTheme("ScrollbarSymbolColor")end,getType=function(ac)return -ba end,setSymbol=function(ac,bc)da=bc:sub(1,1)ac:setVisualChanged()return ac end,setValuesByXMLData=function(ac,bc) -aa.setValuesByXMLData(ac,bc) -if(d("maxValue",bc)~=nil)then bb=d("maxValue",bc)end;if(d("backgroundSymbol",bc)~=nil)then -ab=d("backgroundSymbol",bc):sub(1,1)end;if(d("symbol",bc)~=nil)then -da=d("symbol",bc):sub(1,1)end;if(d("barType",bc)~=nil)then -ca=d("barType",bc):lower()end;if(d("symbolSize",bc)~=nil)then -ac:setSymbolSize(d("symbolSize",bc))end;if(d("symbolColor",bc)~=nil)then -_b=colors[d("symbolColor",bc)]end;if(d("index",bc)~=nil)then -ac:setIndex(d("index",bc))end end,setIndex=function(ac,bc) -cb=bc;if(cb<1)then cb=1 end;local cc,dc=ac:getSize() -cb=math.min(cb,(ca=="vertical"and dc or -cc)- (db-1)) -ac:setValue(bb/ (ca=="vertical"and dc or cc)*cb)return ac end,getIndex=function(ac)return -cb end,setSymbolSize=function(ac,bc)db=tonumber(bc)or 1;local cc,dc=ac:getSize() -if(ca== -"vertical")then -ac:setValue(cb-1 * (bb/ (dc- (db-1)))- -(bb/ (dc- (db-1))))elseif(ca=="horizontal")then -ac:setValue(cb-1 * (bb/ (cc- (db-1)))- (bb/ (cc- -(db-1))))end;ac:setVisualChanged()return ac end,setMaxValue=function(ac,bc) -bb=bc;return ac end,setBackgroundSymbol=function(ac,bc)ab=string.sub(bc,1,1) -ac:setVisualChanged()return ac end,setSymbolColor=function(ac,bc)_b=bc -ac:setVisualChanged()return ac end,setBarType=function(ac,bc)ca=bc:lower()return ac end,mouseHandler=function(ac,bc,cc,dc,_d) -if -(aa.mouseHandler(ac,bc,cc,dc,_d))then -local ad,bd=ac:getAbsolutePosition(ac:getAnchorPosition())local cd,dd=ac:getSize() -if -( -( (bc=="mouse_click")or(bc=="mouse_drag"))and(cc==1))or(bc=="monitor_touch")then -if(ca=="horizontal")then -for _index=0,cd do -if -(ad+_index==dc)and(bd<=_d)and(bd+dd>_d)then cb=math.min(_index+1,cd- (db-1)) -ac:setValue(bb/cd* (cb))ac:setVisualChanged()end end end -if(ca=="vertical")then -for _index=0,dd do -if -(bd+_index==_d)and(ad<=dc)and(ad+cd>dc)then cb=math.min(_index+1,dd- (db-1)) -ac:setValue(bb/dd* (cb))ac:setVisualChanged()end end end end -if(bc=="mouse_scroll")then cb=cb+cc;if(cb<1)then cb=1 end -cb=math.min(cb,( -ca=="vertical"and dd or cd)- (db-1)) -ac:setValue(bb/ (ca=="vertical"and dd or cd)*cb)end;return true end end,draw=function(ac) -if -(aa.draw(ac))then -if(ac.parent~=nil)then local bc,cc=ac:getAnchorPosition() -local dc,_d=ac:getSize() -if(ca=="horizontal")then -ac.parent:writeText(bc,cc,ab:rep(cb-1),ac.bgColor,ac.fgColor) -ac.parent:writeText(bc+cb-1,cc,da:rep(db),_b,_b) -ac.parent:writeText(bc+cb+db-1,cc,ab:rep(dc- (cb+db-1)),ac.bgColor,ac.fgColor)end -if(ca=="vertical")then -for n=0,_d-1 do -if(cb==n+1)then for curIndexOffset=0,math.min(db-1,_d)do -ac.parent:writeText(bc,cc+n+curIndexOffset,da,_b,_b)end else if -(n+1 cb-1 +db)then -ac.parent:writeText(bc,cc+n,ab,ac.bgColor,ac.fgColor)end end end end end;ac:setVisualChanged(false)end end}return setmetatable(_c,aa)end -end; -project['objects']['Slider'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Slider"aa.width=8;aa.height=1;aa:setValue(1) -local ca="horizontal"local da=" "local _b;local ab="\140"local bb=aa.width;local cb=1;local db=1 -local _c={init=function(ac) -ac.bgColor=ac.parent:getTheme("SliderBG")ac.fgColor=ac.parent:getTheme("SliderText") -_b=ac.parent:getTheme("SliderSymbolColor")end,getType=function(ac) -return ba end,setSymbol=function(ac,bc)da=bc:sub(1,1)ac:setVisualChanged()return ac end,setValuesByXMLData=function(ac,bc) -aa.setValuesByXMLData(ac,bc) -if(d("maxValue",bc)~=nil)then bb=d("maxValue",bc)end;if(d("backgroundSymbol",bc)~=nil)then -ab=d("backgroundSymbol",bc):sub(1,1)end;if(d("barType",bc)~=nil)then -ca=d("barType",bc):lower()end;if(d("symbol",bc)~=nil)then -da=d("symbol",bc):sub(1,1)end;if(d("symbolSize",bc)~=nil)then -ac:setSymbolSize(d("symbolSize",bc))end;if(d("symbolColor",bc)~=nil)then -_b=colors[d("symbolColor",bc)]end;if(d("index",bc)~=nil)then -ac:setIndex(d("index",bc))end end,setIndex=function(ac,bc) -cb=bc;if(cb<1)then cb=1 end;local cc,dc=ac:getSize() -cb=math.min(cb,(ca=="vertical"and dc or -cc)- (db-1)) -ac:setValue(bb/ (ca=="vertical"and dc or cc)*cb)return ac end,getIndex=function(ac)return -cb end,setSymbolSize=function(ac,bc)db=tonumber(bc)or 1 -if(ca=="vertical")then -ac:setValue(cb-1 * (bb/ -(h- (db-1)))- (bb/ (h- (db-1))))elseif(ca=="horizontal")then -ac:setValue(cb-1 * (bb/ (w- (db-1)))- (bb/ -(w- (db-1))))end;ac:setVisualChanged()return ac end,setMaxValue=function(ac,bc) -bb=bc;return ac end,setBackgroundSymbol=function(ac,bc)ab=string.sub(bc,1,1) -ac:setVisualChanged()return ac end,setSymbolColor=function(ac,bc)_b=bc -ac:setVisualChanged()return ac end,setBarType=function(ac,bc)ca=bc:lower()return ac end,mouseHandler=function(ac,bc,cc,dc,_d) -if -(aa.mouseHandler(ac,bc,cc,dc,_d))then -local ad,bd=ac:getAbsolutePosition(ac:getAnchorPosition())local cd,dd=ac:getSize() -if -( -( (bc=="mouse_click")or(bc=="mouse_drag"))and(cc==1))or(bc=="monitor_touch")then -if(ca=="horizontal")then -for _index=0,cd do -if -(ad+_index==dc)and(bd<=_d)and(bd+dd>_d)then cb=math.min(_index+1,cd- (db-1)) -ac:setValue(bb/cd* (cb))ac:setVisualChanged()end end end -if(ca=="vertical")then -for _index=0,dd do -if -(bd+_index==_d)and(ad<=dc)and(ad+cd>dc)then cb=math.min(_index+1,dd- (db-1)) -ac:setValue(bb/dd* (cb))ac:setVisualChanged()end end end end -if(bc=="mouse_scroll")then cb=cb+cc;if(cb<1)then cb=1 end -cb=math.min(cb,( -ca=="vertical"and dd or cd)- (db-1)) -ac:setValue(bb/ (ca=="vertical"and dd or cd)*cb)end;return true end end,draw=function(ac) -if -(aa.draw(ac))then -if(ac.parent~=nil)then local bc,cc=ac:getAnchorPosition() -local dc,_d=ac:getSize() -if(ca=="horizontal")then -ac.parent:writeText(bc,cc,ab:rep(cb-1),ac.bgColor,ac.fgColor) -ac.parent:writeText(bc+cb-1,cc,da:rep(db),_b,_b) -ac.parent:writeText(bc+cb+db-1,cc,ab:rep(dc- (cb+db-1)),ac.bgColor,ac.fgColor)end -if(ca=="vertical")then -for n=0,_d-1 do -if(cb==n+1)then for curIndexOffset=0,math.min(db-1,_d)do -ac.parent:writeText(bc,cc+n+curIndexOffset,da,_b,_b)end else if -(n+1 cb-1 +db)then -ac.parent:writeText(bc,cc+n,ab,ac.bgColor,ac.fgColor)end end end end end;ac:setVisualChanged(false)end end}return setmetatable(_c,aa)end -end; -project['objects']['Switch'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Switch"aa.width=2;aa.height=1 -aa.bgColor=colors.lightGray;aa.fgColor=colors.gray;aa:setValue(false)aa:setZIndex(5) -local ca=colors.black;local da=colors.red;local _b=colors.green -local ab={init=function(bb) -bb.bgColor=bb.parent:getTheme("SwitchBG")bb.fgColor=bb.parent:getTheme("SwitchText") -ca=bb.parent:getTheme("SwitchBGSymbol")da=bb.parent:getTheme("SwitchInactive") -_b=bb.parent:getTheme("SwitchActive")end,getType=function(bb)return -ba end,setSymbolColor=function(bb,cb)ca=cb;bb:setVisualChanged()return bb end,setActiveBackground=function(bb,cb) -_b=cb;bb:setVisualChanged()return bb end,setInactiveBackground=function(bb,cb)da=cb -bb:setVisualChanged()return bb end,setValuesByXMLData=function(bb,cb)aa.setValuesByXMLData(bb,cb) -if( -d("inactiveBG",cb)~=nil)then da=colors[d("inactiveBG",cb)]end -if(d("activeBG",cb)~=nil)then _b=colors[d("activeBG",cb)]end;if(d("symbolColor",cb)~=nil)then -ca=colors[d("symbolColor",cb)]end end,mouseHandler=function(bb,cb,db,_c,ac) -if -(aa.mouseHandler(bb,cb,db,_c,ac))then -local bc,cc=bb:getAbsolutePosition(bb:getAnchorPosition()) -if -( (cb=="mouse_click")and(db==1))or(cb=="monitor_touch")then bb:setValue(not bb:getValue())end;return true end end,draw=function(bb) -if -(aa.draw(bb))then -if(bb.parent~=nil)then local cb,db=bb:getAnchorPosition() -local _c,ac=bb:getSize() -bb.parent:drawBackgroundBox(cb,db,_c,ac,bb.bgColor) -if(bb:getValue())then -bb.parent:drawBackgroundBox(cb,db,1,ac,_b)bb.parent:drawBackgroundBox(cb+1,db,1,ac,ca)else -bb.parent:drawBackgroundBox(cb,db,1,ac,ca)bb.parent:drawBackgroundBox(cb+1,db,1,ac,da)end end;bb:setVisualChanged(false)end end}return setmetatable(ab,aa)end -end; -project['objects']['Textfield'] = function(...)local d=require("Object")local _a=require("tHex") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Textfield"local _b,ab,bb,cb=1,1,1,1;local db={""}local _c={""}local ac={""} -local bc={}local cc={}ca.width=30;ca.height=12;ca:setZIndex(5) -local function dc(cd,dd)local __a={} -if(cd:len()>0)then -for a_a in -string.gmatch(cd,dd)do local b_a,c_a=string.find(cd,a_a) -if(b_a~=nil)and(c_a~=nil)then -table.insert(__a,b_a)table.insert(__a,c_a) -local d_a=string.sub(cd,1,(b_a-1))local _aa=string.sub(cd,c_a+1,cd:len())cd=d_a.. -(":"):rep(a_a:len()).._aa end end end;return __a end -local function _d(cd,dd)dd=dd or cb -local __a=_a[cd.fgColor]:rep(ac[dd]:len()) -local a_a=_a[cd.bgColor]:rep(_c[dd]:len()) -for b_a,c_a in pairs(cc)do local d_a=dc(db[dd],c_a[1]) -if(#d_a>0)then -for x=1,#d_a/2 do local _aa=x*2 -1;if( -c_a[2]~=nil)then -__a=__a:sub(1,d_a[_aa]-1).._a[c_a[2] ]:rep(d_a[_aa+1]- -(d_a[_aa]-1)).. -__a:sub(d_a[_aa+1]+1,__a:len())end;if -(c_a[3]~=nil)then -a_a=a_a:sub(1,d_a[_aa]-1).. - -_a[c_a[3] ]:rep(d_a[_aa+1]- (d_a[_aa]-1))..a_a:sub(d_a[_aa+1]+1,a_a:len())end end end end -for b_a,c_a in pairs(bc)do -for d_a,_aa in pairs(c_a)do local aaa=dc(db[dd],_aa) -if(#aaa>0)then for x=1,#aaa/2 do local baa=x*2 -1 -__a=__a:sub(1, -aaa[baa]-1).. - -_a[b_a]:rep(aaa[baa+1]- (aaa[baa]-1))..__a:sub(aaa[baa+1]+1,__a:len())end end end end;ac[dd]=__a;_c[dd]=a_a end;local function ad(cd)for n=1,#db do _d(cd,n)end end -local bd={init=function(cd) -cd.bgColor=cd.parent:getTheme("TextfieldBG")cd.fgColor=cd.parent:getTheme("TextfieldText")end,getType=function(cd)return -da end,setBackground=function(cd,dd)ca.setBackground(cd,dd)ad(cd)return cd end,setForeground=function(cd,dd) -ca.setForeground(cd,dd)ad(cd)return cd end,setValuesByXMLData=function(cd,dd) -ca.setValuesByXMLData(cd,dd) -if(dd["lines"]~=nil)then local __a=dd["lines"]["line"]if -(__a.properties~=nil)then __a={__a}end;for a_a,b_a in pairs(__a)do -cd:addLine(b_a:value())end end -if(dd["keywords"]~=nil)then -for __a,a_a in pairs(dd["keywords"])do -if(colors[__a]~=nil)then -local b_a=a_a;if(b_a.properties~=nil)then b_a={b_a}end;local c_a={} -for d_a,_aa in pairs(b_a)do -local aaa=_aa["keyword"]if(_aa["keyword"].properties~=nil)then -aaa={_aa["keyword"]}end;for baa,caa in pairs(aaa)do -table.insert(c_a,caa:value())end end;cd:addKeywords(colors[__a],c_a)end end end -if(dd["rules"]~=nil)then -if(dd["rules"]["rule"]~=nil)then -local __a=dd["rules"]["rule"]if(dd["rules"]["rule"].properties~=nil)then -__a={dd["rules"]["rule"]}end -for a_a,b_a in pairs(__a)do if(aa("pattern",b_a)~=nil)then -cd:addRule(aa("pattern",b_a),colors[aa("fg",b_a)],colors[aa("bg",b_a)])end end end end end,getLines=function(cd)return -db end,getLine=function(cd,dd)return db[dd]end,editLine=function(cd,dd,__a)db[dd]=__a or db[dd] -return cd end,clear=function(cd)db={""}_c={""}ac={""}_b,ab,bb,cb=1,1,1,1;return cd end,addLine=function(cd,dd,__a) -if( -dd~=nil)then -if(#db==1)and(db[1]=="")then db[1]=dd -_c[1]=_a[cd.bgColor]:rep(dd:len())ac[1]=_a[cd.fgColor]:rep(dd:len())return cd end -if(__a~=nil)then table.insert(db,__a,dd) -table.insert(_c,__a,_a[cd.bgColor]:rep(dd:len())) -table.insert(ac,_a[cd.fgColor]:rep(dd:len()))else table.insert(db,dd) -table.insert(_c,_a[cd.bgColor]:rep(dd:len())) -table.insert(ac,_a[cd.fgColor]:rep(dd:len()))end end;return cd end,addKeywords=function(cd,dd,__a)if( -bc[dd]==nil)then bc[dd]={}end;for a_a,b_a in pairs(__a)do -table.insert(bc[dd],b_a)end;return cd end,addRule=function(cd,dd,__a,a_a) -table.insert(cc,{dd,__a,a_a})return cd end,editRule=function(cd,dd,__a,a_a) -for b_a,c_a in pairs(cc)do if(c_a[1]==dd)then -cc[b_a][2]=__a;cc[b_a][3]=a_a end end;return cd end,removeRule=function(cd,dd) -for __a,a_a in pairs(cc)do if( -a_a[1]==dd)then table.remove(cc,__a)end end;return cd end,setKeywords=function(cd,dd,__a)bc[dd]=__a;return cd end,removeLine=function(cd,dd)table.remove(db, -dd or#db) -if(#db<=0)then table.insert(db,"")end;return cd end,getTextCursor=function(cd)return bb,cb end,getFocusHandler=function(cd) -ca.getFocusHandler(cd) -if(cd.parent~=nil)then local dd,__a=cd:getAnchorPosition()if(cd.parent~=nil)then -cd.parent:setCursor(true, -dd+bb-ab,__a+cb-_b,cd.fgColor)end end end,loseFocusHandler=function(cd) -ca.loseFocusHandler(cd) -if(cd.parent~=nil)then cd.parent:setCursor(false)end end,keyHandler=function(cd,dd,__a) -if(ca.keyHandler(cd,dd,__a))then -local a_a,b_a=cd:getAnchorPosition()local c_a,d_a=cd:getSize() -if(dd=="key")then -if(__a==keys.backspace)then -if(db[cb]=="")then -if(cb>1)then -table.remove(db,cb)table.remove(ac,cb)table.remove(_c,cb)bb= -db[cb-1]:len()+1;ab=bb-c_a+1;if(ab<1)then ab=1 end;cb=cb-1 end elseif(bb<=1)then -if(cb>1)then bb=db[cb-1]:len()+1;ab=bb-c_a+1 -if(ab<1)then ab=1 end;db[cb-1]=db[cb-1]..db[cb] -ac[cb-1]=ac[cb-1]..ac[cb]_c[cb-1]=_c[cb-1].._c[cb]table.remove(db,cb) -table.remove(ac,cb)table.remove(_c,cb)cb=cb-1 end else -db[cb]=db[cb]:sub(1,bb-2)..db[cb]:sub(bb,db[cb]:len()) -ac[cb]=ac[cb]:sub(1,bb-2)..ac[cb]:sub(bb,ac[cb]:len()) -_c[cb]=_c[cb]:sub(1,bb-2).._c[cb]:sub(bb,_c[cb]:len())if(bb>1)then bb=bb-1 end -if(ab>1)then if(bbdb[cb]:len())then -if(db[cb+1]~=nil)then db[cb]=db[cb].. -db[cb+1]table.remove(db,cb+1) -table.remove(_c,cb+1)table.remove(ac,cb+1)end else -db[cb]=db[cb]:sub(1,bb-1)..db[cb]:sub(bb+1,db[cb]:len()) -ac[cb]=ac[cb]:sub(1,bb-1)..ac[cb]:sub(bb+1,ac[cb]:len()) -_c[cb]=_c[cb]:sub(1,bb-1).._c[cb]:sub(bb+1,_c[cb]:len())end;_d(cd)end -if(__a==keys.enter)then -table.insert(db,cb+1,db[cb]:sub(bb,db[cb]:len())) -table.insert(ac,cb+1,ac[cb]:sub(bb,ac[cb]:len())) -table.insert(_c,cb+1,_c[cb]:sub(bb,_c[cb]:len()))db[cb]=db[cb]:sub(1,bb-1) -ac[cb]=ac[cb]:sub(1,bb-1)_c[cb]=_c[cb]:sub(1,bb-1)cb=cb+1;bb=1;ab=1;if(cb-_b>=d_a)then -_b=_b+1 end;cd:setValue("")end -if(__a==keys.up)then -if(cb>1)then cb=cb-1;if(bb>db[cb]:len()+1)then bb= -db[cb]:len()+1 end;if(ab>1)then if(bb1)then if( -cb<_b)then _b=_b-1 end end end end -if(__a==keys.down)then if(cb<#db)then cb=cb+1;if(bb>db[cb]:len()+1)then bb= -db[cb]:len()+1 end -if(cb>=_b+d_a)then _b=_b+1 end end end -if(__a==keys.right)then bb=bb+1;if(cb<#db)then if(bb>db[cb]:len()+1)then bb=1 -cb=cb+1 end elseif(bb>db[cb]:len())then -bb=db[cb]:len()+1 end;if(bb<1)then bb=1 end;if -(bb=c_a+ab)then ab=bb-c_a+1 end -if(ab<1)then ab=1 end end -if(__a==keys.left)then bb=bb-1;if(bb>=1)then -if(bb=c_a+ab)then ab=bb end end -if(cb>1)then if(bb<1)then cb=cb-1 -bb=db[cb]:len()+1;ab=bb-c_a+1 end end;if(bb<1)then bb=1 end;if(ab<1)then ab=1 end end end -if(dd=="char")then db[cb]=db[cb]:sub(1,bb-1)..__a.. -db[cb]:sub(bb,db[cb]:len())ac[cb]=ac[cb]:sub(1, -bb-1).. -_a[cd.fgColor]..ac[cb]:sub(bb,ac[cb]:len())_c[cb]=_c[cb]:sub(1, -bb-1).. -_a[cd.bgColor].._c[cb]:sub(bb,_c[cb]:len()) -bb=bb+1;if(bb>=c_a+ab)then ab=ab+1 end;_d(cd)cd:setValue("")end;local _aa= -(bb<=db[cb]:len()and bb-1 or db[cb]:len())- (ab-1)if(_aa> -cd.x+c_a-1)then _aa=cd.x+c_a-1 end;local aaa=( -cb-_bdb[cb]:len())then bb= -db[cb]:len()+1 end -if(bbdb[cb]:len())then bb=db[cb]:len()+1 end;if(bb#db- (caa-1))then _b=#db- (caa-1)end;if(_b<1)then _b=1 end -if(cd.parent~=nil)then -if(c_a+bb-ab>=c_a and -c_a+bb-ab=d_a and d_a+cb-_b=1)then da=da-1;if(da>=1)then -_b=os.startTimer(ba)end elseif(da==-1)then _b=os.startTimer(ba)end end end}db.__index=db;return db end -end; -project['libraries']['basaltDraw'] = function(...)local d=require("tHex")local _a,aa=string.sub,string.rep -return -function(ba) -local ca=ba or term.current()local da;local _b,ab=ca.getSize()local bb={}local cb={}local db={}local _c={}local ac={}local bc={}local cc -local dc={}local function _d()cc=aa(" ",_b) -for n=0,15 do local a_a=2 ^n;local b_a=d[a_a]dc[a_a]=aa(b_a,_b)end end;_d() -local function ad()local a_a=cc -local b_a=dc[colors.white]local c_a=dc[colors.black] -for currentY=1,ab do -bb[currentY]=_a( -bb[currentY]==nil and a_a or -bb[currentY]..a_a:sub(1,_b-bb[currentY]:len()),1,_b) -db[currentY]=_a(db[currentY]==nil and b_a or db[currentY]..b_a:sub(1,_b- -db[currentY]:len()),1,_b) -cb[currentY]=_a(cb[currentY]==nil and c_a or cb[currentY]..c_a:sub(1,_b- -cb[currentY]:len()),1,_b)end end;ad() -local function bd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if -(a_a+c_a:len()>0)and(a_a<=_b)then local d_a=bb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1 -local caa=_b-a_a+1;c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -bb[b_a]=_aa end end end -local function cd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=cb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then -c_a=_a(c_a,1 -a_a+1,_b-a_a+1)elseif(aaa>_b)then c_a=_a(c_a,1,_b-a_a+1)end -if(a_a>1)then _aa=_a(d_a,1,a_a-1)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -cb[b_a]=_aa end end end -local function dd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=db[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1;local caa=_b-a_a+1 -c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -db[b_a]=_aa end end end -local __a={setMirror=function(a_a)da=a_a end,setBG=function(a_a,b_a,c_a)cd(a_a,b_a,c_a)end,setText=function(a_a,b_a,c_a) -bd(a_a,b_a,c_a)end,setFG=function(a_a,b_a,c_a)dd(a_a,b_a,c_a)end,drawBackgroundBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -cd(a_a,b_a+ (n-1),aa(d[_aa],c_a))end end,drawForegroundBox=function(a_a,b_a,c_a,d_a,_aa) -for n=1,d_a do dd(a_a,b_a+ -(n-1),aa(d[_aa],c_a))end end,drawTextBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -bd(a_a,b_a+ (n-1),aa(_aa,c_a))end end,writeText=function(a_a,b_a,c_a,d_a,_aa)d_a=d_a or -ca.getBackgroundColor() -_aa=_aa or ca.getTextColor()bd(a_a,b_a,c_a) -cd(a_a,b_a,aa(d[d_a],c_a:len()))dd(a_a,b_a,aa(d[_aa],c_a:len()))end,update=function() -local a_a,b_a=ca.getCursorPos()local c_a=false -if(ca.getCursorBlink~=nil)then c_a=ca.getCursorBlink()end;ca.setCursorBlink(false)if(da~=nil)then -ca.setCursorBlink(false)end -for n=1,ab do ca.setCursorPos(1,n) -ca.blit(bb[n],db[n],cb[n])if(da~=nil)then da.setCursorPos(1,n) -da.blit(bb[n],db[n],cb[n])end end;ca.setBackgroundColor(colors.black) -ca.setCursorBlink(c_a)ca.setCursorPos(a_a,b_a) -if(da~=nil)then -da.setBackgroundColor(colors.black)da.setCursorBlink(c_a)da.setCursorPos(a_a,b_a)end end,setTerm=function(a_a) -ca=a_a end}return __a end -end; -project['libraries']['basaltEvent'] = function(...) -return -function()local a={}local b={} -local c={registerEvent=function(d,_a,aa)if(a[_a]==nil)then a[_a]={}b[_a]=1 end -a[_a][b[_a] ]=aa;b[_a]=b[_a]+1;return b[_a]-1 end,removeEvent=function(d,_a,aa)a[_a][aa[_a] ]= -nil end,sendEvent=function(d,_a,...)local aa -if(a[_a]~=nil)then for ba,ca in pairs(a[_a])do local da=ca(...)if(da== -false)then aa=da end end end;return aa end}c.__index=c;return c end -end; -project['libraries']['bigfont'] = function(...)local ba=require("tHex") -local ca={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{"000110000110110000110010101000000010000000100101","000000110110000000000010101000000010000000100101","000000000000000000000000000000000000000000000000","100010110100000010000110110000010100000100000110","000000110000000010110110000110000000000000110000","000000000000000000000000000000000000000000000000","000000110110000010000000100000100000000000000010","000000000110110100010000000010000000000000000100","000000000000000000000000000000000000000000000000","010000000000100110000000000000000000000110010000","000000000000000000000000000010000000010110000000","000000000000000000000000000000000000000000000000","011110110000000100100010110000000100000000000000","000000000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110000110110000000000000000000010100100010000000","000010000000000000110110000000000100010010000000","000000000000000000000000000000000000000000000000","010110010110100110110110010000000100000110110110","000000000000000000000110000000000110000000000000","000000000000000000000000000000000000000000000000","010100010110110000000000000000110000000010000000","110110000000000000110000110110100000000010000000","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","100100100100100100100100100100100100100100100100","000000110100110110000010000011110000000000011000","000000000100000000000010000011000110000000001000","000000000000000000000000000000000000000000000000","010000100100000000000000000100000000010010110000","000000000000000000000000000000110110110110110000","000000000000000000000000000000000000000000000000","110110110110110110000000110110110110110110110110","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","000000000000110110000110010000000000000000010010","000010000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110110110110000000000000","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110000000000000000010000","000000000000000000000000100000000000000110000110","000000000000000000000000000000000000000000000000"}}local da={}local _b={} -do local cb=0;local db=#ca[1]local _c=#ca[1][1] -for i=1,db,3 do -for j=1,_c,3 do -local ac=string.char(cb)local bc={}bc[1]=ca[1][i]:sub(j,j+2) -bc[2]=ca[1][i+1]:sub(j,j+2)bc[3]=ca[1][i+2]:sub(j,j+2)local cc={}cc[1]=ca[2][i]:sub(j, -j+2)cc[2]=ca[2][i+1]:sub(j,j+2)cc[3]=ca[2][ -i+2]:sub(j,j+2)_b[ac]={bc,cc}cb=cb+1 end end;da[1]=_b end -local function ab(cb,db)local _c={["0"]="1",["1"]="0"}if cb<=#da then return true end -for f=#da+1,cb do local ac={}local bc=da[ -f-1] -for char=0,255 do local cc=string.char(char)local dc={}local _d={} -local ad=bc[cc][1]local bd=bc[cc][2] -for i=1,#ad do local cd,dd,__a,a_a,b_a,c_a={},{},{},{},{},{} -for j=1,#ad[1]do -local d_a=_b[ad[i]:sub(j,j)][1]table.insert(cd,d_a[1])table.insert(dd,d_a[2]) -table.insert(__a,d_a[3])local _aa=_b[ad[i]:sub(j,j)][2] -if -bd[i]:sub(j,j)=="1"then -table.insert(a_a,(_aa[1]:gsub("[01]",_c))) -table.insert(b_a,(_aa[2]:gsub("[01]",_c))) -table.insert(c_a,(_aa[3]:gsub("[01]",_c)))else table.insert(a_a,_aa[1]) -table.insert(b_a,_aa[2])table.insert(c_a,_aa[3])end end;table.insert(dc,table.concat(cd)) -table.insert(dc,table.concat(dd))table.insert(dc,table.concat(__a)) -table.insert(_d,table.concat(a_a))table.insert(_d,table.concat(b_a)) -table.insert(_d,table.concat(c_a))end;ac[cc]={dc,_d}if db then db="Font"..f.."Yeld"..char -os.queueEvent(db)os.pullEvent(db)end end;da[f]=ac end;return true end -local function bb(cb,db,_c,ac,bc) -if not type(db)=="string"then error("Not a String",3)end -local cc=type(_c)=="string"and _c:sub(1,1)or ba[_c]or -error("Wrong Front Color",3) -local dc=type(ac)=="string"and ac:sub(1,1)or ba[ac]or -error("Wrong Back Color",3)if(da[cb]==nil)then ab(3,false)end;local _d=da[cb]or -error("Wrong font size selected",3)if db==""then -return{{""},{""},{""}}end;local ad={} -for c_a in db:gmatch('.')do table.insert(ad,c_a)end;local bd={}local cd=#_d[ad[1] ][1] -for nLine=1,cd do local c_a={} -for i=1,#ad do c_a[i]=_d[ad[i] ]and -_d[ad[i] ][1][nLine]or""end;bd[nLine]=table.concat(c_a)end;local dd={}local __a={}local a_a={["0"]=cc,["1"]=dc}local b_a={["0"]=dc,["1"]=cc} -for nLine=1,cd do -local c_a={}local d_a={} -for i=1,#ad do -local _aa=_d[ad[i] ]and _d[ad[i] ][2][nLine]or"" -c_a[i]=_aa:gsub("[01]", -bc and{["0"]=_c:sub(i,i),["1"]=ac:sub(i,i)}or a_a) -d_a[i]=_aa:gsub("[01]", -bc and{["0"]=ac:sub(i,i),["1"]=_c:sub(i,i)}or b_a)end;dd[nLine]=table.concat(c_a) -__a[nLine]=table.concat(d_a)end;return{bd,dd,__a}end;return bb -end; -project['libraries']['geometricPoints'] = function(...) -local function _a(da,_b,ab,bb)local cb={}if da==ab and _b==bb then return{x=da,y=ab}end -local db=math.min(da,ab)local _c,ac,bc;if db==da then ac,_c,bc=_b,ab,bb else ac,_c,bc=bb,da,_b end;local cc,dc=_c-db, -bc-ac -if cc>math.abs(dc)then local _d=ac;local ad=dc/cc;for x=db,_c do table.insert(cb,{x=x,y=math.floor( -_d+0.5)}) -_d=_d+ad end else local _d,ad=db,cc/dc -if bc>=ac then for y=ac,bc do table.insert(cb,{x=math.floor( -_d+0.5),y=y})_d=_d+ -ad end else for y=ac,bc,-1 do -table.insert(cb,{x=math.floor(_d+0.5),y=y})_d=_d-ad end end end;return cb end -local function aa(da,_b,ab)local bb={}for x=-ab,ab+1 do -local cb=math.floor(math.sqrt(ab*ab-x*x)) -for y=-cb,cb+1 do table.insert(bb,{x=da+x,y=_b+y})end end;return bb end -local function ba(da,_b,ab,bb,cb)local db,_c=math.ceil(math.floor(ab-0.5)/2),math.ceil( -math.floor(bb-0.5)/2)local ac,bc=0,_c -local cc=( ( -_c*_c)- (db*db*_c)+ (0.25 *db*db))local dc=2 *_c^2 *ac;local _d=2 *db^2 *bc;local ad={} -while dc<_d do -table.insert(ad,{x=ac+da,y=bc+_b})table.insert(ad,{x=-ac+da,y=bc+_b})table.insert(ad,{x=ac+ -da,y=-bc+_b}) -table.insert(ad,{x=-ac+da,y=-bc+_b})if cb then -for y=-bc+_b+1,bc+_b-1 do table.insert(ad,{x=ac+da,y=y})table.insert(ad,{x= --ac+da,y=y})end end -if cc<0 then ac=ac+1 -dc=dc+2 *_c^2;cc=cc+dc+_c^2 else ac,bc=ac+1,bc-1;dc=dc+2 *_c^2 -_d=_d-2 *db^2;cc=cc+dc-_d+_c^2 end end -local bd=( ( (_c*_c)* ( (ac+0.5)* (ac+0.5)))+ -( (db*db)* ( (bc-1)* (bc-1)))- (db*db*_c*_c)) -while bc>=0 do table.insert(ad,{x=ac+da,y=bc+_b})table.insert(ad,{x=- -ac+da,y=bc+_b}) -table.insert(ad,{x=ac+da,y=-bc+_b})table.insert(ad,{x=-ac+da,y=-bc+_b}) -if cb then for y=-bc+_b, -bc+_b do table.insert(ad,{x=ac+da,y=y}) -table.insert(ad,{x=-ac+da,y=y})end end -if bd>0 then bc=bc-1;_d=_d-2 *db^2;bd=bd+db^2 -_d else bc=bc-1;ac=ac+1;_d=_d-2 * -db^2;dc=dc+2 *_c^2;bd=bd+dc-_d+db^2 end end;return ad end;local function ca(da,_b,ab,bb)return ba(da,_b,ab,ab,bb)end -return -{circle=function(da,_b,ab,bb) -return ca(da,_b,ab,bb)end,rectangle=function(da,_b,ab,bb,cb)local db={} -if(cb)then for y=_b,bb do for x=da,ab do -table.insert(db,{x=x,y=y})end end else for y=_b,bb do -for x=da,ab do if -(x==da)or(x==ab)or(y==_b)or(y==bb)then -table.insert(db,{x=x,y=y})end end end end;return db end,triangle=function(da,_b,ab,bb,cb,db,_c) -local -function ac(dc,_d,ad,bd,cd,dd,__a)local a_a=(dd-_d)/ (__a-ad)local b_a=(dd-bd)/ (__a-cd)local c_a=math.ceil( -ad-0.5) -local d_a=math.ceil(__a-0.5)-1 -for y=c_a,d_a do local _aa=a_a* (y+0.5 -ad)+_d -local aaa=b_a* (y+0.5 -cd)+bd;local baa=math.ceil(_aa-0.5)local caa=math.ceil(aaa-0.5)for x=baa,caa do -table.insert(dc,{x=x,y=y})end end end -local function bc(dc,_d,ad,bd,cd,dd,__a)local a_a=(bd-_d)/ (cd-ad)local b_a=(dd-_d)/ (__a-ad) -local c_a=math.ceil(ad-0.5)local d_a=math.ceil(__a-0.5)-1 -for y=c_a,d_a do -local _aa=a_a* (y+0.5 -ad)+_d;local aaa=b_a* (y+0.5 -ad)+_d -local baa=math.ceil(_aa-0.5)local caa=math.ceil(aaa-0.5)for x=baa,caa do -table.insert(dc,{x=x,y=y})end end end;local cc={} -if(_c)then if bb<_b then da,_b,ab,bb=ab,bb,da,_b end;if db",">") -_a=string.gsub(_a,"\"",""") -_a=string.gsub(_a,"([^%w%&%;%p%\t% ])",function(aa) -return string.format("&#x%X;",string.byte(aa))end)return _a end -function d:FromXmlString(_a) -_a=string.gsub(_a,"&#x([%x]+)%;",function(aa) -return string.char(tonumber(aa,16))end) -_a=string.gsub(_a,"&#([0-9]+)%;",function(aa)return string.char(tonumber(aa,10))end)_a=string.gsub(_a,""","\"") -_a=string.gsub(_a,"'","'")_a=string.gsub(_a,">",">") -_a=string.gsub(_a,"<","<")_a=string.gsub(_a,"&","&")return _a end;function d:ParseArgs(_a,aa) -string.gsub(aa,"(%w+)=([\"'])(.-)%2",function(ba,ca,da) -_a:addProperty(ba,self:FromXmlString(da))end)end -function d:ParseXmlText(_a) -local aa={}local ba=c()table.insert(aa,ba)local ca,da,_b,ab,bb;local cb,db=1,1 -while true do -ca,db,da,_b,ab,bb=string.find(_a,"<(%/?)([%w_:]+)(.-)(%/?)>",cb)if not ca then break end;local ac=string.sub(_a,cb,ca-1) -if not -string.find(ac,"^%s*$")then -local bc=(ba:value()or"")..self:FromXmlString(ac)aa[#aa]:setValue(bc)end -if bb=="/"then local bc=c(_b)self:ParseArgs(bc,ab)ba:addChild(bc)elseif -da==""then local bc=c(_b)self:ParseArgs(bc,ab)table.insert(aa,bc) -ba=bc else local bc=table.remove(aa)ba=aa[#aa]if#aa<1 then -error("XmlParser: nothing to close with ".._b)end;if bc:name()~=_b then -error("XmlParser: trying to close "..bc.name.. -" with ".._b)end;ba:addChild(bc)end;cb=db+1 end;local _c=string.sub(_a,cb)if#aa>1 then -error("XmlParser: unclosed "..aa[#aa]:name())end;return ba end -function d:loadFile(_a,aa)if not aa then aa=system.ResourceDirectory end -local ba=system.pathForFile(_a,aa)local ca,da=io.open(ba,"r") -if ca and not da then local _b=ca:read("*a") -io.close(ca)return self:ParseXmlText(_b),nil else print(da)return nil end end;return d -end; -project['libraries']['process'] = function(...)local d={}local _a={}local aa=0 -function _a:new(ba,ca,...)local da=table.pack(...) -local _b=setmetatable({path=ba},{__index=self})_b.window=ca;_b.processId=aa -_b.coroutine=coroutine.create(function() -os.run({},ba,table.unpack(da))end)d[aa]=_b;aa=aa+1;return _b end -function _a:resume(ba,...)term.redirect(self.window) -local ca,da=coroutine.resume(self.coroutine,ba,...)self.window=term.current()if ca then self.filter=da else -basalt.debug(da)end end -function _a:isDead() -if(self.coroutine~=nil)then -if -(coroutine.status(self.coroutine)=="dead")then table.remove(d,self.processId)return true end else return true end;return false end -function _a:getStatus()if(self.coroutine~=nil)then -return coroutine.status(self.coroutine)end;return nil end -function _a:start()coroutine.resume(self.coroutine)end;return _a -end; -project['libraries']['tHex'] = function(...) -return -{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"} -end; -project['libraries']['utils'] = function(...) -local b=function(c,d)if d==nil then d="%s"end;local _a={}for aa in string.gmatch(c,"([^"..d.."]+)")do -table.insert(_a,aa)end;return _a end -return -{getTextHorizontalAlign=function(c,d,_a,aa)c=string.sub(c,1,d)local ba=d-string.len(c) -if(_a=="right")then c=string.rep( -aa or" ",ba)..c elseif(_a=="center")then -c=string.rep(aa or" ",math.floor( -ba/2))..c.. -string.rep(aa or" ",math.floor(ba/2)) -c=c.. (string.len(c)_aa[x])then table.insert(_aa,x,bdb)break end else -table.insert(_aa,bdb)end end;if(#_aa<=0)then table.insert(_aa,bdb)end;d_a[bdb]={}end;adb.parent=aaa;if(adb.init~=nil)then adb:init()end -table.insert(d_a[bdb],adb)return adb end -local function dbb(adb) -for bdb,cdb in pairs(d_a)do for ddb,__c in pairs(cdb)do if(__c==adb)then table.remove(d_a[bdb],ddb) -return true end end end;return false end -local function _cb(adb)local bdb,cdb=pcall(load("return "..adb)) -if not(bdb)then error(adb.. -" is not a valid dynamic code")end;return load("return "..adb)()end -local function acb(adb,bdb,cdb)for ddb,__c in pairs(daa)do -if(__c[2]==cdb)and(__c[4]==bdb)then return __c end end;_ba=_ba+1 -daa[_ba]={0,cdb,{},bdb,_ba}return daa[_ba]end -local function bcb(adb,bdb)local cdb={}local ddb={}for __c in bdb:gmatch("%a+%.x")do local a_c=__c:gsub("%.x","") -if -(a_c~="self")and(a_c~="parent")then table.insert(cdb,a_c)end end -for __c in -bdb:gmatch("%w+%.y")do local a_c=__c:gsub("%.y","")if(a_c~="self")and(a_c~="parent")then -table.insert(cdb,a_c)end end;for __c in bdb:gmatch("%a+%.w")do local a_c=__c:gsub("%.w","") -if(a_c~="self")and -(a_c~="parent")then table.insert(cdb,a_c)end end -for __c in -bdb:gmatch("%a+%.h")do local a_c=__c:gsub("%.h","")if(a_c~="self")and(a_c~="parent")then -table.insert(cdb,a_c)end end -for __c,a_c in pairs(cdb)do ddb[a_c]=abb(a_c)if(ddb[a_c]==nil)then -error("Dynamic Values - unable to find object "..a_c)end end;ddb["self"]=adb;ddb["parent"]=adb:getParent()return ddb end -local function ccb(adb,bdb)local cdb=adb;for ddb in adb:gmatch("%w+%.x")do -cdb=cdb:gsub(ddb,bdb[ddb:gsub("%.x","")]:getX())end;for ddb in adb:gmatch("%w+%.y")do -cdb=cdb:gsub(ddb,bdb[ddb:gsub("%.y","")]:getY())end;for ddb in adb:gmatch("%w+%.w")do -cdb=cdb:gsub(ddb,bdb[ddb:gsub("%.w","")]:getWidth())end;for ddb in adb:gmatch("%w+%.h")do -cdb=cdb:gsub(ddb,bdb[ddb:gsub("%.h","")]:getHeight())end;return cdb end -local function dcb() -if(#daa>0)then -for n=1,_ba do -if(daa[n]~=nil)then local adb;if(#daa[n][3]<=0)then -daa[n][3]=bcb(daa[n][4],daa[n][2])end -adb=ccb(daa[n][2],daa[n][3])daa[n][1]=_cb(adb)end end end end;local function _db(adb)return daa[adb][1]end -aaa={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,newDynamicValue=acb,recalculateDynamicValues=dcb,getDynamicValue=_db,getType=function(adb)return -c_a end,setFocusedObject=function(adb,bdb)dda=bdb;return adb end,getVariable=function(adb,bdb) -return a_a.getVariable(bdb)end,setSize=function(adb,bdb,cdb,ddb)b_a.setSize(adb,bdb,cdb,ddb) -for __c,a_c in pairs(_aa)do if( -d_a[a_c]~=nil)then -for b_c,c_c in pairs(d_a[a_c])do if(c_c.eventHandler~=nil)then -c_c:sendEvent("basalt_resize",c_c,adb)end end end end;return adb end,setTheme=function(adb,bdb) -caa=bdb;return adb end,getTheme=function(adb,bdb)return -caa[bdb]or(adb.parent~=nil and -adb.parent:getTheme(bdb)or a_a.getTheme(bdb))end,setPosition=function(adb,bdb,cdb,ddb) -b_a.setPosition(adb,bdb,cdb,ddb) -for __c,a_c in pairs(_aa)do if(d_a[a_c]~=nil)then -for b_c,c_c in pairs(d_a[a_c])do if(c_c.eventHandler~=nil)then -c_c:sendEvent("basalt_reposition",c_c,adb)end end end end;return adb end,getBasaltInstance=function(adb)return -a_a end,setOffset=function(adb,bdb,cdb) -aab=bdb~=nil and -math.floor(bdb<0 and math.abs(bdb)or-bdb)or aab -bab=cdb~=nil and -math.floor(cdb<0 and math.abs(cdb)or-cdb)or bab;return adb end,getOffsetInternal=function(adb)return -aab,bab end,getOffset=function(adb) -return aab<0 and math.abs(aab)or-aab, -bab<0 and math.abs(bab)or-bab end,removeFocusedObject=function(adb)dda=nil;return adb end,getFocusedObject=function(adb) -return __b end,setCursor=function(adb,bdb,cdb,ddb,__c) -if(adb.parent~=nil)then local a_c,b_c=adb:getAnchorPosition() -adb.parent:setCursor( -bdb or false,(cdb or 0)+a_c-1,(ddb or 0)+b_c-1,__c or _ab)else -local a_c,b_c=adb:getAbsolutePosition(adb:getAnchorPosition(adb:getX(),adb:getY(),true))b_b=bdb or false;if(cdb~=nil)then c_b=a_c+cdb-1 end;if(ddb~=nil)then d_b=b_c+ -ddb-1 end;_ab=__c or _ab -adb:setVisualChanged()end;return adb end,setMoveable=function(adb,bdb)adb.isMoveable= -bdb or not adb.isMoveable -adb:setVisualChanged()return adb end,setScrollable=function(adb,bdb) -bca=bdb and true or false;return adb end,setImportantScroll=function(adb,bdb)cda=bdb and true or false -return adb end,setMaxScroll=function(adb,bdb)dca=bdb or dca;return adb end,setMinScroll=function(adb,bdb)cca= -bdb or cca;return adb end,getMaxScroll=function(adb)return dca end,getMinScroll=function(adb)return cca end,show=function(adb) -b_a.show(adb) -if(adb.parent==nil)then a_a.setActiveFrame(adb)if(cba)then -a_a.setMonitorFrame(bba,adb)else a_a.setMainFrame(adb)end end;return adb end,hide=function(adb) -b_a.hide(adb) -if(adb.parent==nil)then if(activeFrame==adb)then activeFrame=nil end;if(cba)then -if( -a_a.getMonitorFrame(bba)==adb)then a_a.setActiveFrame(nil)end else -if(a_a.getMainFrame()==adb)then a_a.setMainFrame(nil)end end end;return adb end,addLayout=function(adb,bdb) -if( -bdb~=nil)then -if(fs.exists(bdb))then local cdb=fs.open(bdb,"r") -local ddb=ac:ParseXmlText(cdb.readAll())cdb.close()cab={}adb:setValuesByXMLData(ddb)end end;return adb end,getLastLayout=function(adb)return -cab end,addLayoutFromString=function(adb,bdb)if(bdb~=nil)then local cdb=ac:ParseXmlText(bdb) -adb:setValuesByXMLData(cdb)end;return adb end,setValuesByXMLData=function(adb,bdb) -b_a.setValuesByXMLData(adb,bdb)if(dc("moveable",bdb)~=nil)then if(dc("moveable",bdb))then -adb:setMoveable(true)end end;if( -dc("scrollable",bdb)~=nil)then -if(dc("scrollable",bdb))then adb:setScrollable(true)end end;if -(dc("monitor",bdb)~=nil)then -adb:setMonitor(dc("monitor",bdb)):show()end;if(dc("mirror",bdb)~=nil)then -adb:setMirror(dc("mirror",bdb))end -if(dc("bar",bdb)~=nil)then if(dc("bar",bdb))then -adb:showBar(true)else adb:showBar(false)end end -if(dc("barText",bdb)~=nil)then adb.barText=dc("barText",bdb)end;if(dc("barBG",bdb)~=nil)then -adb.barBackground=colors[dc("barBG",bdb)]end;if(dc("barFG",bdb)~=nil)then -adb.barTextcolor=colors[dc("barFG",bdb)]end;if(dc("barAlign",bdb)~=nil)then -adb.barTextAlign=dc("barAlign",bdb)end;if(dc("layout",bdb)~=nil)then -adb:addLayout(dc("layout",bdb))end;if(dc("xOffset",bdb)~=nil)then -adb:setOffset(dc("xOffset",bdb),bab)end;if(dc("yOffset",bdb)~=nil)then -adb:setOffset(bab,dc("yOffset",bdb))end;if(dc("maxScroll",bdb)~=nil)then -adb:setMaxScroll(dc("maxScroll",bdb))end;if(dc("minScroll",bdb)~=nil)then -adb:setMaxScroll(dc("minScroll",bdb))end;if -(dc("importantScroll",bdb)~=nil)then -adb:setImportantScroll(dc("importantScroll",bdb))end;local cdb=bdb:children() -for ddb,__c in -pairs(cdb)do if(__c.___name~="animation")then -local a_c=__c.___name:gsub("^%l",string.upper) -if(cb[a_c]~=nil)then _bb(__c,adb["add"..a_c],adb)end end end;_bb(bdb["frame"],adb.addFrame,adb) -_bb(bdb["animation"],adb.addAnimation,adb)return adb end,showBar=function(adb,bdb)adb.barActive= -bdb or not adb.barActive -adb:setVisualChanged()return adb end,setBar=function(adb,bdb,cdb,ddb) -adb.barText=bdb or""adb.barBackground=cdb or adb.barBackground -adb.barTextcolor=ddb or adb.barTextcolor;adb:setVisualChanged()return adb end,setBarTextAlign=function(adb,bdb)adb.barTextAlign= -bdb or"left"adb:setVisualChanged()return adb end,setMirror=function(adb,bdb) -bda=bdb;if(mirror~=nil)then a_b.setMirror(mirror)end;_da=true -return adb end,removeMirror=function(adb)mirror=nil;_da=false -a_b.setMirror(nil)return adb end,setMonitor=function(adb,bdb) -if(bdb~=nil)and(bdb~=false)then -if( -peripheral.getType(bdb)=="monitor")then aba=peripheral.wrap(bdb)dba=true end -if(adb.parent~=nil)then adb.parent:removeObject(adb)end;cba=true else aba=parentTerminal;cba=false;if(a_a.getMonitorFrame(bba)==adb)then a_a.setMonitorFrame(bba, -nil)end end;a_b=db(aba)bba=bdb or nil;return adb end,getVisualChanged=function(adb) -local bdb=b_a.getVisualChanged(adb) -for cdb,ddb in pairs(_aa)do if(d_a[ddb]~=nil)then -for __c,a_c in pairs(d_a[ddb])do if(a_c.getVisualChanged~=nil and -a_c:getVisualChanged())then bdb=true end end end end;return bdb end,loseFocusHandler=function(adb) -b_a.loseFocusHandler(adb)if(dda~=nil)then dda:loseFocusHandler()dda=nil end end,getFocusHandler=function(adb) -b_a.getFocusHandler(adb)if(adb.parent~=nil)then adb.parent:removeObject(adb) -adb.parent:addObject(adb)end end,keyHandler=function(adb,bdb,cdb) -if( -__b~=nil)then if(__b~=adb)then if(__b.keyHandler~=nil)then -if(__b:keyHandler(bdb,cdb))then return true end end else -b_a.keyHandler(adb,bdb,cdb)end end;return false end,backgroundKeyHandler=function(adb,bdb,cdb) -b_a.backgroundKeyHandler(adb,bdb,cdb) -for ddb,__c in pairs(_aa)do if(d_a[__c]~=nil)then -for a_c,b_c in pairs(d_a[__c])do if(b_c.backgroundKeyHandler~=nil)then -b_c:backgroundKeyHandler(bdb,cdb)end end end end end,eventHandler=function(adb,bdb,cdb,ddb,__c,a_c) -b_a.eventHandler(adb,bdb,cdb,ddb,__c,a_c) -for b_c,c_c in pairs(_aa)do if(d_a[c_c]~=nil)then -for d_c,_ac in pairs(d_a[c_c])do if(_ac.eventHandler~=nil)then -_ac:eventHandler(bdb,cdb,ddb,__c,a_c)end end end end -if(cba)then if(bdb=="peripheral")and(cdb==bba)then -if -(peripheral.getType(bba)=="monitor")then dba=true;aba=peripheral.wrap(bba)a_b=db(aba)end end -if(bdb== -"peripheral_detach")and(cdb==bba)then dba=false end end -if(_da)then if(peripheral.getType(bda)=="monitor")then ada=true -a_b.setMirror(peripheral.wrap(bda))end;if(bdb=="peripheral_detach")and -(cdb==bda)then dba=false end -if -(bdb=="monitor_touch")then adb:mouseHandler(bdb,cdb,ddb,__c,a_c)end end;if(bdb=="terminate")then aba.setCursorPos(1,1)aba.clear() -a_a.stop()end end,mouseHandler=function(adb,bdb,cdb,ddb,__c) -if -(adb.drag)then local d_c,_ac=adb.parent:getOffsetInternal()d_c=d_c<0 and -math.abs(d_c)or-d_c;_ac= -_ac<0 and math.abs(_ac)or-_ac -if(bdb=="mouse_drag")then local aac=1;local bac=1;if -(adb.parent~=nil)then -aac,bac=adb.parent:getAbsolutePosition(adb.parent:getAnchorPosition())end -adb:setPosition( -ddb+_ca- (aac-1)+d_c,__c+aca- (bac-1)+_ac)end;if(bdb=="mouse_up")then adb.drag=false end;return true end -local a_c,b_c=adb:getAbsolutePosition(adb:getAnchorPosition())local c_c=false;if(b_c-1 ==__c)and(adb:getBorder("top"))then __c=__c+1 -c_c=true end -if(b_a.mouseHandler(adb,bdb,cdb,ddb,__c))then -a_c=a_c+aab;b_c=b_c+bab;if(bca)and(cda)then -if(bdb=="mouse_scroll")then if(cdb>0)or(cdb<0)then bab=bd(ad(bab-cdb,-cca), --dca)end end end -for d_c,_ac in pairs(_aa)do -if -(d_a[_ac]~=nil)then -for aac,bac in cc(d_a[_ac])do if(bac.mouseHandler~=nil)then if(bac:mouseHandler(bdb,cdb,ddb,__c))then -return true end end end end end;adb:removeFocusedObject() -if(adb.isMoveable)then -if -(ddb>=a_c)and(ddb<= -a_c+adb:getWidth()-1)and(__c==b_c)and(bdb=="mouse_click")then adb.drag=true;_ca=a_c- -ddb;aca=c_c and 1 or 0 end end;if(bca)and(not cda)then -if(bdb=="mouse_scroll")then if(cdb>0)or(cdb<0)then bab=bd(ad(bab-cdb,-cca), --dca)end end end;return true end;return false end,setText=function(adb,bdb,cdb,ddb) -local __c,a_c=adb:getAnchorPosition() -if(cdb>=1)and(cdb<=adb:getHeight())then -if(adb.parent~=nil)then -adb.parent:setText(bd( -bdb+ (__c-1),__c),a_c+cdb-1,_d(ddb,bd(1 -bdb+1,1),bd( -adb:getWidth()-bdb+1,1)))else -a_b.setText(bd(bdb+ (__c-1),__c),a_c+cdb-1,_d(ddb,bd(1 -bdb+1,1),bd( -adb:getWidth()-bdb+1,1)))end end end,setBG=function(adb,bdb,cdb,ddb) -local __c,a_c=adb:getAnchorPosition() -if(cdb>=1)and(cdb<=adb:getHeight())then -if(adb.parent~=nil)then -adb.parent:setBG(bd( -bdb+ (__c-1),__c),a_c+cdb-1,_d(ddb,bd(1 -bdb+1,1),bd( -adb:getWidth()-bdb+1,1)))else -a_b.setBG(bd(bdb+ (__c-1),__c),a_c+cdb-1,_d(ddb,bd(1 -bdb+1,1),bd( -adb:getWidth()-bdb+1,1)))end end end,setFG=function(adb,bdb,cdb,ddb) -local __c,a_c=adb:getAnchorPosition() -if(cdb>=1)and(cdb<=adb:getHeight())then -if(adb.parent~=nil)then -adb.parent:setFG(bd( -bdb+ (__c-1),__c),a_c+cdb-1,_d(ddb,bd(1 -bdb+1,1),bd( -adb:getWidth()-bdb+1,1)))else -a_b.setFG(bd(bdb+ (__c-1),__c),a_c+cdb-1,_d(ddb,bd(1 -bdb+1,1),bd( -adb:getWidth()-bdb+1,1)))end end end,writeText=function(adb,bdb,cdb,ddb,__c,a_c) -local b_c,c_c=adb:getAnchorPosition() -if(cdb>=1)and(cdb<=adb:getHeight())then -if(adb.parent~=nil)then -adb.parent:writeText(bd( -bdb+ (b_c-1),b_c),c_c+cdb-1,_d(ddb,bd(1 -bdb+1,1), -adb:getWidth()-bdb+1),__c,a_c)else -a_b.writeText(bd(bdb+ (b_c-1),b_c),c_c+cdb-1,_d(ddb,bd(1 -bdb+1,1),bd( -adb:getWidth()-bdb+1,1)),__c,a_c)end end end,drawBackgroundBox=function(adb,bdb,cdb,ddb,__c,a_c) -local b_c,c_c=adb:getAnchorPosition() -__c=(cdb<1 and( -__c+cdb>adb:getHeight()and adb:getHeight()or __c+cdb-1)or( -__c+ -cdb>adb:getHeight()and adb:getHeight()-cdb+1 or __c)) -ddb=(bdb<1 and(ddb+bdb>adb:getWidth()and adb:getWidth()or ddb+ -bdb-1)or( - -ddb+bdb>adb:getWidth()and adb:getWidth()-bdb+1 or ddb)) -if(adb.parent~=nil)then -adb.parent:drawBackgroundBox(bd(bdb+ (b_c-1),b_c),bd(cdb+ (c_c-1),c_c),ddb,__c,a_c)else -a_b.drawBackgroundBox(bd(bdb+ (b_c-1),b_c),bd(cdb+ (c_c-1),c_c),ddb,__c,a_c)end end,drawTextBox=function(adb,bdb,cdb,ddb,__c,a_c) -local b_c,c_c=adb:getAnchorPosition() -__c=(cdb<1 and( -__c+cdb>adb:getHeight()and adb:getHeight()or __c+cdb-1)or( -__c+ -cdb>adb:getHeight()and adb:getHeight()-cdb+1 or __c)) -ddb=(bdb<1 and(ddb+bdb>adb:getWidth()and adb:getWidth()or ddb+ -bdb-1)or( - -ddb+bdb>adb:getWidth()and adb:getWidth()-bdb+1 or ddb)) -if(adb.parent~=nil)then -adb.parent:drawTextBox(bd(bdb+ (b_c-1),b_c),bd(cdb+ (c_c-1),c_c),ddb,__c,_d(a_c,1,1))else -a_b.drawTextBox(bd(bdb+ (b_c-1),b_c),bd(cdb+ (c_c-1),c_c),ddb,__c,_d(a_c,1,1))end end,drawForegroundBox=function(adb,bdb,cdb,ddb,__c,a_c) -local b_c,c_c=adb:getAnchorPosition() -__c=(cdb<1 and( -__c+cdb>adb:getHeight()and adb:getHeight()or __c+cdb-1)or( -__c+ -cdb>adb:getHeight()and adb:getHeight()-cdb+1 or __c)) -ddb=(bdb<1 and(ddb+bdb>adb:getWidth()and adb:getWidth()or ddb+ -bdb-1)or( - -ddb+bdb>adb:getWidth()and adb:getWidth()-bdb+1 or ddb)) -if(adb.parent~=nil)then -adb.parent:drawForegroundBox(bd(bdb+ (b_c-1),b_c),bd(cdb+ (c_c-1),c_c),ddb,__c,a_c)else -a_b.drawForegroundBox(bd(bdb+ (b_c-1),b_c),bd(cdb+ (c_c-1),c_c),ddb,__c,a_c)end end,draw=function(adb)if -(cba)and not(dba)then return false end -if(adb:getVisualChanged())then -if -(b_a.draw(adb))then -if(__b~=dda)then if(dda~=nil)then dda:getFocusHandler()end;if -(__b~=nil)then __b:loseFocusHandler()end;__b=dda end -local bdb,cdb=adb:getAbsolutePosition(adb:getAnchorPosition())local ddb,__c=adb:getAnchorPosition()local a_c,b_c=adb:getSize() -if( -adb.parent~=nil)then -if(adb.bgColor~=false)then -adb.parent:drawBackgroundBox(ddb,__c,a_c,b_c,adb.bgColor)adb.parent:drawTextBox(ddb,__c,a_c,b_c," ")end;if(adb.bgColor~=false)then -adb.parent:drawForegroundBox(ddb,__c,a_c,b_c,adb.fgColor)end else -if(adb.bgColor~=false)then -a_b.drawBackgroundBox(ddb,__c,a_c,b_c,adb.bgColor)a_b.drawTextBox(ddb,__c,a_c,b_c," ")end;if(adb.fgColor~=false)then -a_b.drawForegroundBox(ddb,__c,a_c,b_c,adb.fgColor)end end;aba.setCursorBlink(false) -if(adb.barActive)then -if(adb.parent~=nil)then -adb.parent:writeText(ddb,__c,_c.getTextHorizontalAlign(adb.barText,a_c,adb.barTextAlign),adb.barBackground,adb.barTextcolor)else -a_b.writeText(ddb,__c,_c.getTextHorizontalAlign(adb.barText,a_c,adb.barTextAlign),adb.barBackground,adb.barTextcolor)end -if(adb:getBorder("left"))then -if(adb.parent~=nil)then -adb.parent:drawBackgroundBox(ddb-1,__c,1,1,adb.barBackground)if(adb.bgColor~=false)then -adb.parent:drawBackgroundBox(ddb-1,__c+1,1,b_c-1,adb.bgColor)end end end -if(adb:getBorder("top"))then if(adb.parent~=nil)then -adb.parent:drawBackgroundBox(ddb-1,__c-1,a_c+1,1,adb.barBackground)end end end;for c_c,d_c in cc(_aa)do -if(d_a[d_c]~=nil)then for _ac,aac in pairs(d_a[d_c])do -if(aac.draw~=nil)then aac:draw()end end end end -if(b_b)then -aba.setTextColor(_ab)aba.setCursorPos(c_b,d_b) -if(adb.parent~=nil)then -aba.setCursorBlink(adb:isFocused())else aba.setCursorBlink(b_b)end end;adb:setVisualChanged(false)end end end,drawUpdate=function(adb)if -(cba)and not(dba)then return false end;a_b.update()end,addObject=function(adb,bdb)return -cbb(bdb)end,removeObject=function(adb,bdb)return dbb(bdb)end,getObject=function(adb,bdb)return abb(bdb)end,getDeepObject=function(adb,bdb)return -bbb(bdb)end,addFrame=function(adb,bdb) -local cdb=a_a.newFrame(bdb or bc(),adb,nil,a_a)return cbb(cdb)end} -for adb,bdb in pairs(cb)do aaa["add"..adb]=function(cdb,ddb) -return cbb(bdb(ddb or bc(),cdb))end end;setmetatable(aaa,b_a)return aaa end -end; -project['default']['loadObjects'] = function(...)local d={}if(packaged)then -for ba,ca in pairs(getProject("objects"))do d[ba]=ca()end;return d end -local _a=table.pack(...)local aa=fs.getDir(_a[2]or"Basalt")if(aa==nil)then -error("Unable to find directory ".. -_a[2].." please report this bug to our discord.")end;for ba,ca in -pairs(fs.list(fs.combine(aa,"objects")))do -if(ca~="example.lua")then local da=ca:gsub(".lua","")d[da]=require(da)end end;return d -end; -project['default']['Object'] = function(...)local aa=require("basaltEvent")local ba=require("utils") -local ca=ba.splitString;local da=ba.numberFromString;local _b=ba.getValueFromXML -return -function(ab)local bb="Object"local cb={}local db=1 -local _c;local ac="topLeft"local bc=false;local cc=true;local dc=false;local _d=false;local ad=false;local bd=false -local cd=false;local dd=colors.black;local __a=colors.black;local a_a=true;local b_a=false;local c_a,d_a,_aa,aaa=0,0,0,0 -local baa=true;local caa=aa() -cb={x=1,y=1,width=1,height=1,bgColor=colors.black,fgColor=colors.white,name=ab or"Object",parent=nil,show=function(daa)cc=true;baa=true;return daa end,hide=function(daa) -cc=false;baa=true;return daa end,enable=function(daa)a_a=true;return daa end,disable=function(daa) -a_a=false;return daa end,generateXMLEventFunction=function(daa,_ba,aba) -local bba=function(cba) -if(cba:sub(1,1)=="#")then -local dba=daa:getBaseFrame():getDeepObject(cba:sub(2,cba:len())) -if(dba~=nil)and(dba.internalObjetCall~=nil)then _ba(daa,function() -dba:internalObjetCall()end)end else -_ba(daa,daa:getBaseFrame():getVariable(cba))end end;if(type(aba)=="string")then bba(aba)elseif(type(aba)=="table")then -for cba,dba in pairs(aba)do bba(dba)end end;return daa end,setValuesByXMLData=function(daa,_ba) -local aba=daa:getBaseFrame()if(_b("x",_ba)~=nil)then -daa:setPosition(_b("x",_ba),daa.y)end;if(_b("y",_ba)~=nil)then -daa:setPosition(daa.x,_b("y",_ba))end;if(_b("width",_ba)~=nil)then -daa:setSize(_b("width",_ba),daa.height)end;if(_b("height",_ba)~=nil)then -daa:setSize(daa.width,_b("height",_ba))end;if(_b("bg",_ba)~=nil)then -daa:setBackground(colors[_b("bg",_ba)])end;if(_b("fg",_ba)~=nil)then -daa:setForeground(colors[_b("fg",_ba)])end;if(_b("value",_ba)~=nil)then -daa:setValue(colors[_b("value",_ba)])end -if(_b("visible",_ba)~=nil)then if -(_b("visible",_ba))then daa:show()else daa:hide()end end -if(_b("enabled",_ba)~=nil)then if(_b("enabled",_ba))then daa:enable()else -daa:disable()end end;if(_b("zIndex",_ba)~=nil)then -daa:setZIndex(_b("zIndex",_ba))end;if(_b("anchor",_ba)~=nil)then -daa:setAnchor(_b("anchor",_ba))end;if(_b("shadow",_ba)~=nil)then if(_b("shadow",_ba))then -daa:showShadow(true)end end;if( -_b("shadowColor",_ba)~=nil)then -daa:setShadow(colors[_b("shadowColor",_ba)])end -if(_b("border",_ba)~=nil)then if -(_b("border",_ba))then _d,ad,bd,cd=true,true,true,true end end;if(_b("borderLeft",_ba)~=nil)then -if(_b("borderLeft",_ba))then _d=true else _d=false end end -if -(_b("borderTop",_ba)~=nil)then if(_b("borderTop",_ba))then ad=true else ad=false end end;if(_b("borderRight",_ba)~=nil)then -if(_b("borderRight",_ba))then bd=true else bd=false end end -if -(_b("borderBottom",_ba)~=nil)then if(_b("borderBottom",_ba))then cd=true else cd=false end end;if(_b("borderColor",_ba)~=nil)then -daa:setBorder(colors[_b("borderColor",_ba)])end;if -(_b("ignoreOffset",_ba)~=nil)then -if(_b("ignoreOffset",_ba))then daa:ignoreOffset(true)end end;if -(_b("onClick",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onClick,_b("onClick",_ba))end;if -(_b("onClickUp",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onClickUp,_b("onClickUp",_ba))end;if -(_b("onScroll",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onScroll,_b("onScroll",_ba))end;if -(_b("onDrag",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onDrag,_b("onDrag",_ba))end;if(_b("onKey",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onKey,_b("onKey",_ba))end;if(_b("onKeyUp",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onKeyUp,_b("onKeyUp",_ba))end;if -(_b("onChange",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onChange,_b("onChange",_ba))end;if -(_b("onResize",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onResize,_b("onResize",_ba))end;if -(_b("onReposition",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onReposition,_b("onReposition",_ba))end;if -(_b("onEvent",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onEvent,_b("onEvent",_ba))end;if -(_b("onGetFocus",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onGetFocus,_b("onGetFocus",_ba))end;if -(_b("onLoseFocus",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onLoseFocus,_b("onLoseFocus",_ba))end;if( -_b("onBackgroundKey",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onBackgroundKey,_b("onBackgroundKey",_ba))end;if( -_b("onBackgroundKeyUp",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onBackgroundKeyUp,_b("onBackgroundKeyUp",_ba))end;return daa end,isVisible=function(daa)return -cc end,setFocus=function(daa)if(daa.parent~=nil)then -daa.parent:setFocusedObject(daa)end;return daa end,setZIndex=function(daa,_ba) -db=_ba;if(daa.parent~=nil)then daa.parent:removeObject(daa) -daa.parent:addObject(daa)end;return daa end,getZIndex=function(daa)return -db end,getType=function(daa)return bb end,getName=function(daa)return daa.name end,remove=function(daa) -if -(daa.parent~=nil)then daa.parent:removeObject(daa)end;return daa end,setParent=function(daa,_ba) -if(_ba.getType~=nil and -_ba:getType()=="Frame")then daa:remove() -_ba:addObject(daa)if(daa.draw)then daa:show()end end;return daa end,setValue=function(daa,_ba) -if( -_c~=_ba)then _c=_ba;baa=true;daa:valueChangedHandler()end;return daa end,getValue=function(daa)return _c end,getVisualChanged=function(daa) -return baa end,setVisualChanged=function(daa,_ba)baa=_ba or true;if(_ba==nil)then baa=true end;return daa end,getEventSystem=function(daa)return -caa end,getParent=function(daa)return daa.parent end,getObjectReferencesForDynVal=function(daa,_ba)end,setPosition=function(daa,_ba,aba,bba) -if -(type(_ba)=="number")then daa.x=bba and daa:getX()+_ba or _ba end;if(type(aba)=="number")then -daa.y=bba and daa:getY()+aba or aba end -if(daa.parent~=nil)then if(type(_ba)=="string")then -daa.x=daa.parent:newDynamicValue(daa,_ba)end;if(type(aba)=="string")then -daa.y=daa.parent:newDynamicValue(daa,aba)end -daa.parent:recalculateDynamicValues()end;caa:sendEvent("basalt_reposition",daa)baa=true;return daa end,getX=function(daa)return - -type(daa.x)=="number"and daa.x or math.floor(daa.x[1]+0.5)end,getY=function(daa)return - -type(daa.y)=="number"and daa.y or math.floor(daa.y[1]+0.5)end,getPosition=function(daa)return -daa:getX(),daa:getY()end,getVisibility=function(daa)return cc end,setVisibility=function(daa,_ba) -cc=_ba or not cc;baa=true;return daa end,setSize=function(daa,_ba,aba,bba) -if(type(_ba)=="number")then daa.width=bba and -daa.width+_ba or _ba end;if(type(aba)=="number")then -daa.height=bba and daa.height+aba or aba end -if(daa.parent~=nil)then if(type(_ba)=="string")then -daa.width=daa.parent:newDynamicValue(daa,_ba)end;if(type(aba)=="string")then -daa.height=daa.parent:newDynamicValue(daa,aba)end -daa.parent:recalculateDynamicValues()end;caa:sendEvent("basalt_resize",daa)baa=true;return daa end,getHeight=function(daa) -return -type(daa.height)=="number"and daa.height or -math.floor(daa.height[1]+0.5)end,getWidth=function(daa)return - -type(daa.width)=="number"and daa.width or math.floor(daa.width[1]+0.5)end,getSize=function(daa)return -daa:getWidth(),daa:getHeight()end,calculateDynamicValues=function(daa) -if( -type(daa.width)=="table")then daa.width:calculate()end -if(type(daa.height)=="table")then daa.height:calculate()end -if(type(daa.x)=="table")then daa.x:calculate()end -if(type(daa.y)=="table")then daa.y:calculate()end;return daa end,setBackground=function(daa,_ba)daa.bgColor= -_ba or false;baa=true;return daa end,getBackground=function(daa)return -daa.bgColor end,setForeground=function(daa,_ba)daa.fgColor=_ba or false;baa=true;return daa end,getForeground=function(daa)return -daa.fgColor end,showShadow=function(daa,_ba)dc=_ba or(not dc)return daa end,setShadow=function(daa,_ba) -dd=_ba;return daa end,isShadowActive=function(daa)return dc end,showBorder=function(daa,...) -for _ba,aba in pairs(table.pack(...))do if( -aba=="left")then _d=true end;if(aba=="top")then ad=true end;if -(aba=="right")then bd=true end;if(aba=="bottom")then cd=true end end;return daa end,setBorder=function(daa,_ba) -__a=_ba;return daa end,getBorder=function(daa,_ba)if(_ba=="left")then return _d end -if(_ba=="top")then return ad end;if(_ba=="right")then return bd end;if(_ba=="bottom")then return cd end end,draw=function(daa) -if -(cc)then -if(daa.parent~=nil)then local _ba,aba=daa:getAnchorPosition() -local bba,cba=daa:getSize() -if(dc)then -daa.parent:drawBackgroundBox(_ba+1,aba+cba,bba,1,dd) -daa.parent:drawBackgroundBox(_ba+bba,aba+1,1,cba,dd) -daa.parent:drawForegroundBox(_ba+1,aba+cba,bba,1,dd) -daa.parent:drawForegroundBox(_ba+bba,aba+1,1,cba,dd)end -if(_d)then -daa.parent:drawTextBox(_ba-1,aba,1,cba,"\149") -daa.parent:drawForegroundBox(_ba-1,aba,1,cba,__a)if(daa.bgColor~=false)then -daa.parent:drawBackgroundBox(_ba-1,aba,1,cba,daa.bgColor)end end -if(_d)and(ad)then -daa.parent:drawTextBox(_ba-1,aba-1,1,1,"\151") -daa.parent:drawForegroundBox(_ba-1,aba-1,1,1,__a)if(daa.bgColor~=false)then -daa.parent:drawBackgroundBox(_ba-1,aba-1,1,1,daa.bgColor)end end -if(ad)then -daa.parent:drawTextBox(_ba,aba-1,bba,1,"\131") -daa.parent:drawForegroundBox(_ba,aba-1,bba,1,__a)if(daa.bgColor~=false)then -daa.parent:drawBackgroundBox(_ba,aba-1,bba,1,daa.bgColor)end end;if(ad)and(bd)then -daa.parent:drawTextBox(_ba+bba,aba-1,1,1,"\149") -daa.parent:drawForegroundBox(_ba+bba,aba-1,1,1,__a)end -if(bd)then daa.parent:drawTextBox( -_ba+bba,aba,1,cba,"\149")daa.parent:drawForegroundBox( -_ba+bba,aba,1,cba,__a)end;if(bd)and(cd)then -daa.parent:drawTextBox(_ba+bba,aba+cba,1,1,"\129") -daa.parent:drawForegroundBox(_ba+bba,aba+cba,1,1,__a)end -if(cd)then daa.parent:drawTextBox(_ba, -aba+cba,bba,1,"\131")daa.parent:drawForegroundBox(_ba, -aba+cba,bba,1,__a)end;if(cd)and(_d)then -daa.parent:drawTextBox(_ba-1,aba+cba,1,1,"\131") -daa.parent:drawForegroundBox(_ba-1,aba+cba,1,1,__a)end end;return true end;return false end,getAbsolutePosition=function(daa,_ba,aba) -if( -_ba==nil)or(aba==nil)then _ba,aba=daa:getAnchorPosition()end -if(daa.parent~=nil)then -local bba,cba=daa.parent:getAbsolutePosition()_ba=bba+_ba-1;aba=cba+aba-1 end;return _ba,aba end,getAnchorPosition=function(daa,_ba,aba,bba)if( -_ba==nil)then _ba=daa:getX()end -if(aba==nil)then aba=daa:getY()end -if(daa.parent~=nil)then local cba,dba=daa.parent:getSize() -if(ac=="top")then _ba=math.floor( -cba/2)+_ba-1 elseif(ac=="topRight")then -_ba=cba+_ba-1 elseif(ac=="right")then _ba=cba+_ba-1 -aba=math.floor(dba/2)+aba-1 elseif(ac=="bottomRight")then _ba=cba+_ba-1;aba=dba+aba-1 elseif(ac=="bottom")then _ba=math.floor( -cba/2)+_ba-1;aba=dba+aba-1 elseif(ac== -"bottomLeft")then aba=dba+aba-1 elseif(ac=="left")then -aba=math.floor(dba/2)+aba-1 elseif(ac=="center")then _ba=math.floor(cba/2)+_ba-1;aba=math.floor( -dba/2)+aba-1 end;local _ca,aca=daa.parent:getOffsetInternal()if not(bc or bba)then return _ba+ -_ca,aba+aca end end;return _ba,aba end,ignoreOffset=function(daa,_ba) -bc=_ba;if(_ba==nil)then bc=true end;return daa end,getBaseFrame=function(daa) -if( -daa.parent~=nil)then return daa.parent:getBaseFrame()end;return daa end,setAnchor=function(daa,_ba)ac=_ba;baa=true;return daa end,getAnchor=function(daa)return -ac end,onChange=function(daa,...) -for _ba,aba in pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("value_changed",aba)end end;return daa end,onClick=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do -if(type(aba)=="function")then -daa:registerEvent("mouse_click",aba)daa:registerEvent("monitor_touch",aba)end end;return daa end,onClickUp=function(daa,...)for _ba,aba in -pairs(table.pack(...))do -if(type(aba)=="function")then daa:registerEvent("mouse_up",aba)end end;return daa end,onScroll=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_scroll",aba)end end;return daa end,onDrag=function(daa,...)if -(a_a)then -for _ba,aba in pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_drag",aba)end end end;return daa end,onEvent=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("custom_event_handler",aba)end end;return daa end,onKey=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then daa:registerEvent("key",aba) -daa:registerEvent("char",aba)end end;return daa end,onResize=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("basalt_resize",aba)end end;return daa end,onReposition=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("basalt_reposition",aba)end end;return daa end,onKeyUp=function(daa,...)for _ba,aba in -pairs(table.pack(...))do -if(type(aba)=="function")then daa:registerEvent("key_up",aba)end end;return daa end,onBackgroundKey=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do -if(type(aba)=="function")then -daa:registerEvent("background_key",aba)daa:registerEvent("background_char",aba)end end;return daa end,onBackgroundKeyUp=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("background_key_up",aba)end end;return daa end,isFocused=function(daa)if( -daa.parent~=nil)then -return daa.parent:getFocusedObject()==daa end;return false end,onGetFocus=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("get_focus",aba)end end;return daa end,onLoseFocus=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("lose_focus",aba)end end;return daa end,registerEvent=function(daa,_ba,aba)return -caa:registerEvent(_ba,aba)end,removeEvent=function(daa,_ba,aba) -return caa:removeEvent(_ba,aba)end,sendEvent=function(daa,_ba,...)return caa:sendEvent(_ba,daa,...)end,mouseHandler=function(daa,_ba,aba,bba,cba) -if -(a_a)and(cc)then -local dba,_ca=daa:getAbsolutePosition(daa:getAnchorPosition())local aca,bca=daa:getSize()local cca=false;if -(_ca-1 ==cba)and(daa:getBorder("top"))then cba=cba+1;cca=true end;if(_ba=="mouse_up")then -b_a=false end -if(b_a)and(_ba=="mouse_drag")then local dca,_da,ada,bda=0,0,1,1 -if(daa.parent~= -nil)then dca,_da=daa.parent:getOffsetInternal()dca=dca<0 and -math.abs(dca)or-dca;_da= -_da<0 and math.abs(_da)or-_da -ada,bda=daa.parent:getAbsolutePosition(daa.parent:getAnchorPosition())end -local cda,dda=bba+_aa- (ada-1)+dca,cba+aaa- (bda-1)+_da -local __b=caa:sendEvent(_ba,daa,_ba,aba,cda,dda,c_a,d_a,bba,cba)end -if(dba<=bba)and(dba+aca>bba)and(_ca<=cba)and -(_ca+bca>cba)then if(_ba=="mouse_click")then b_a=true;c_a,d_a=bba,cba;_aa,aaa=dba-bba, -_ca-cba end -if(_ba~="mouse_drag")then if( -_ba~="mouse_up")then if(daa.parent~=nil)then -daa.parent:setFocusedObject(daa)end end -local dca=caa:sendEvent(_ba,daa,_ba,aba,bba,cba)if(dca~=nil)then return dca end end;return true end end;return false end,keyHandler=function(daa,_ba,aba)if -(a_a)then -if(daa:isFocused())then local bba=caa:sendEvent(_ba,daa,_ba,aba)if(bba~=nil)then -return bba end;return true end end;return false end,backgroundKeyHandler=function(daa,_ba,aba) -if -(a_a)then -local bba=caa:sendEvent("background_".._ba,daa,_ba,aba)if(bba~=nil)then return bba end end;return true end,valueChangedHandler=function(daa) -caa:sendEvent("value_changed",daa)end,eventHandler=function(daa,_ba,aba,bba,cba,dba) -caa:sendEvent("custom_event_handler",daa,_ba,aba,bba,cba,dba)end,getFocusHandler=function(daa) -local _ba=caa:sendEvent("get_focus",daa)if(_ba~=nil)then return _ba end;return true end,loseFocusHandler=function(daa) -local _ba=caa:sendEvent("lose_focus",daa)if(_ba~=nil)then return _ba end;return true end}cb.__index=cb;return cb end -end; -project['default']['theme'] = function(...) -return -{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=colors.lightGray,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green} -end; -local aaa=require("basaltEvent")() -local baa=require("Frame")local caa=require("theme")local daa=require("utils")local _ba=daa.uuid -local aba=daa.createText;local bba=term.current()local cba=5;local dba=true -local _ca=fs.getDir(table.pack(...)[2]or"")local aca,bca,cca,dca,_da={},{},{},{},{}local ada,bda,cda,dda;if not term.isColor or -not term.isColor()then -error('Basalt requires an advanced (golden) computer to run.',0)end -local function __b()dda=false end;local a_b=function(abb,bbb)dca[abb]=bbb end -local b_b=function(abb)return dca[abb]end;local c_b=function(abb)caa=abb end -local d_b=function(abb)return caa[abb]end -local _ab={getMainFrame=function()return ada end,setVariable=a_b,getVariable=b_b,getTheme=d_b,setMainFrame=function(abb)ada=abb end,getActiveFrame=function()return bda end,setActiveFrame=function(abb)bda=abb end,getFocusedObject=function()return -cda end,setFocusedObject=function(abb)cda=abb end,getMonitorFrame=function(abb)return cca[abb]end,setMonitorFrame=function(abb,bbb) -cca[abb]=bbb end,getBaseTerm=function()return bba end,stop=__b,newFrame=baa,getDirectory=function()return _ca end} -local aab=function(abb)bba.clear()bba.setBackgroundColor(colors.black) -bba.setTextColor(colors.red)local bbb,cbb=bba.getSize() -local dbb=function(ccb,dcb)if dcb==nil then dcb="%s"end;local _db={} -for adb in string.gmatch(ccb, -"([^"..dcb.."]+)")do table.insert(_db,adb)end;return _db end;local _cb=dbb(abb," ")local acb="Basalt error: "local bcb=1 -for n=1,#_cb do -bba.setCursorPos(1,bcb)if(#acb+#_cb[n]0)then local acb={} -for n=1,#_da do -if(_da[n]~=nil)then -if -(coroutine.status(_da[n])=="suspended")then -local bcb,ccb=coroutine.resume(_da[n],abb,bbb,cbb,dbb,_cb)if not(bcb)then aab(ccb)end else table.insert(acb,n)end end end -for n=1,#acb do table.remove(_da,acb[n]- (n-1))end end end;local function cab() -if(dda)then if(ada~=nil)then ada:draw()ada:drawUpdate()end;for abb,bbb in -pairs(cca)do bbb:draw()bbb:drawUpdate()end end end -local function dab(abb,bbb,cbb,dbb,_cb) -if( -aaa:sendEvent("basaltEventCycle",abb,bbb,cbb,dbb,_cb)==false)then return end -if(ada~=nil)then -if(abb=="mouse_click")then -ada:mouseHandler(abb,bbb,cbb,dbb,_cb)bda=ada elseif(abb=="mouse_drag")then -ada:mouseHandler(abb,bbb,cbb,dbb,_cb)bda=ada elseif(abb=="mouse_up")then -ada:mouseHandler(abb,bbb,cbb,dbb,_cb)bda=ada elseif(abb=="mouse_scroll")then -ada:mouseHandler(abb,bbb,cbb,dbb,_cb)bda=ada elseif(abb=="monitor_touch")then if(cca[bbb]~=nil)then -cca[bbb]:mouseHandler(abb,bbb,cbb,dbb,_cb)bda=cca[bbb]end end end;if(abb=="key")or(abb=="char")then -if(bda~=nil)then -bda:keyHandler(abb,bbb)bda:backgroundKeyHandler(abb,bbb)end end;if(abb=="key")then -aca[bbb]=true end;if(abb=="key_up")then aca[bbb]=false end -for acb,bcb in -pairs(bca)do bcb:eventHandler(abb,bbb,cbb,dbb,_cb)end;bab(abb,bbb,cbb,dbb,_cb)cab()end;local _bb={} -_bb={setTheme=c_b,getTheme=d_b,getVersion=function()return cba end,setVariable=a_b,getVariable=b_b,setBaseTerm=function(abb)bba=abb end,autoUpdate=function(abb)local bbb=pcall;dda=abb;if -(abb==nil)then dda=true end;cab() -while dda do local cbb,dbb,_cb,acb,bcb=os.pullEventRaw() -local ccb,dcb=bbb(dab,cbb,dbb,_cb,acb,bcb)if not(ccb)then aab(dcb)return end end end,update=function(abb,bbb,cbb,dbb,_cb)if( -abb~=nil)then dab(abb,bbb,cbb,dbb,_cb)end end,stop=__b,isKeyDown=function(abb)if( -aca[abb]==nil)then return false end;return aca[abb]end,getFrame=function(abb)for bbb,cbb in -pairs(bca)do if(cbb.name==abb)then return cbb end end end,getActiveFrame=function()return -bda end,setActiveFrame=function(abb) -if(abb:getType()=="Frame")then bda=abb;return true end;return false end,onEvent=function(...) -for abb,bbb in -pairs(table.pack(...))do if(type(bbb)=="function")then -aaa:registerEvent("basaltEventCycle",bbb)end end end,schedule=function(abb) -assert(abb~= -"function","Schedule needs a function in order to work!")return -function(...)local bbb=coroutine.create(abb) -local cbb,dbb=coroutine.resume(bbb,...)if(cbb)then table.insert(_da,bbb)else aab(dbb)end end end,createFrame=function(abb)abb= -abb or _ba() -for cbb,dbb in pairs(bca)do if(dbb.name==abb)then return nil end end;local bbb=baa(abb,nil,nil,_ab)table.insert(bca,bbb) -if(ada==nil)and( -bbb:getName()~="basaltDebuggingFrame")then bbb:show()end;return bbb end,removeFrame=function(abb)bca[abb]= -nil end,setProjectDir=function(abb)_ca=abb end,debug=function(...)local abb={...}if -(ada.name~="basaltDebuggingFrame")then -if(ada~=_bb.debugFrame)then _bb.debugLabel:setParent(ada)end end;local bbb=""for cbb,dbb in pairs(abb)do -bbb=bbb.. -tostring(dbb).. (#abb~=cbb and", "or"")end -_bb.debugLabel:setText("[Debug] "..bbb)for cbb,dbb in pairs(aba(bbb,_bb.debugList:getWidth()))do -_bb.debugList:addItem(dbb)end -if( -_bb.debugList:getItemCount()>50)then _bb.debugList:removeItem(1)end -_bb.debugList:setValue(_bb.debugList:getItem(_bb.debugList:getItemCount()))if -(_bb.debugList.getItemCount()>_bb.debugList:getHeight())then -_bb.debugList:setOffset(_bb.debugList:getItemCount()- -_bb.debugList:getHeight())end -_bb.debugLabel:show()end} -_bb.debugFrame=_bb.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) -_bb.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if( -_bb.oldFrame~=nil)then _bb.oldFrame:show()end end):setBackground(colors.red):show() -_bb.debugList=_bb.debugFrame:addList("debugList"):setSize( -_bb.debugFrame.width-2,_bb.debugFrame.height-3):setPosition(2,3):setScrollable(true):show() -_bb.debugLabel=_bb.debugFrame:addLabel("debugLabel"):onClick(function() -_bb.oldFrame=ada;_bb.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return _bb \ No newline at end of file diff --git a/docs/docs1_6/versions/basalt-1.6.0.lua b/docs/docs1_6/versions/basalt-1.6.0.lua deleted file mode 100644 index 7648338..0000000 --- a/docs/docs1_6/versions/basalt-1.6.0.lua +++ /dev/null @@ -1,2706 +0,0 @@ -local project = {} -local packaged = true -local baseRequire = require -local require = function(path) - for _,v in pairs(project)do - for name,b in pairs(v)do - if(name==path)then - return b() - end - end - end - return baseRequire(path); -end -local getProject = function(subDir) - if(subDir~=nil)then - return project[subDir] - end - return project -end -project['objects'] = {}project['libraries'] = {}project['default'] = {}project['objects']['Animation'] = function(...)local cc=require("utils").getValueFromXML -local dc=require("basaltEvent")local _d,ad,bd,cd=math.floor,math.sin,math.cos,math.pi;local dd=function(_ba,aba,bba)return -_ba+ (aba-_ba)*bba end -local __a=function(_ba)return _ba end;local a_a=function(_ba)return 1 -_ba end -local b_a=function(_ba)return _ba*_ba*_ba end -local c_a=function(_ba)return a_a(b_a(a_a(_ba)))end -local d_a=function(_ba)return dd(b_a(_ba),c_a(_ba),_ba)end;local _aa=function(_ba)return ad((_ba*cd)/2)end -local aaa=function(_ba)return a_a(bd(( -_ba*cd)/2))end -local baa=function(_ba)return- (bd(cd*x)-1)/2 end -local caa={linear=__a,lerp=dd,flip=a_a,easeIn=b_a,easeOut=c_a,easeInOut=d_a,easeOutSine=_aa,easeInSine=aaa,easeInOutSine=baa}local daa={} -return -function(_ba)local aba={}local bba="Animation"local cba;local dba={}local _ca=0;local aca=false;local bca=1;local cca=false -local dca=dc()local _da=0;local ada;local bda=false;local cda=false;local dda="easeOut"local __b;local function a_b(_ab)for aab,bab in pairs(_ab)do -bab(aba,dba[bca].t,bca)end end -local function b_b(_ab)if(bca==1)then -_ab:animationStartHandler()end;if(dba[bca]~=nil)then a_b(dba[bca].f) -_ca=dba[bca].t end;bca=bca+1 -if(dba[bca]==nil)then if(cca)then bca=1;_ca=0 else -_ab:animationDoneHandler()return end end;if(dba[bca].t>0)then -cba=os.startTimer(dba[bca].t-_ca)else b_b(_ab)end end -local function c_b(_ab,aab)for n=1,#dba do -if(dba[n].t==_ab)then table.insert(dba[n].f,aab)return end end -for n=1,#dba do -if(dba[n].t>_ab)then if -(dba[n-1]~=nil)then if(dba[n-1].t<_ab)then -table.insert(dba,n-1,{t=_ab,f={aab}})return end else -table.insert(dba,n,{t=_ab,f={aab}})return end end end -if(#dba<=0)then table.insert(dba,1,{t=_ab,f={aab}})return elseif( -dba[#dba].t<_ab)then table.insert(dba,{t=_ab,f={aab}})end end -local function d_b(_ab,aab,bab,cab,dab,_bb,abb,bbb)local cbb=__b;local dbb,_cb;local acb=""if(cbb.parent~=nil)then -acb=cbb.parent:getName()end;acb=acb..cbb:getName() -c_b(cab+0.05,function() -if -(abb~=nil)then if(daa[abb]==nil)then daa[abb]={}end;if(daa[abb][acb]~=nil)then -if( -daa[abb][acb]~=bbb)then daa[abb][acb]:cancel()end end;daa[abb][acb]=bbb end;dbb,_cb=dab(cbb)end) -for n=0.05,bab+0.01,0.05 do -c_b(cab+n,function() -local bcb=math.floor(caa.lerp(dbb,_ab,caa[dda](n/bab))+0.5) -local ccb=math.floor(caa.lerp(_cb,aab,caa[dda](n/bab))+0.5)_bb(cbb,bcb,ccb) -if(abb~=nil)then if(n>=bab-0.01)then if(daa[abb][acb]==bbb)then daa[abb][acb]= -nil end end end end)end end -aba={name=_ba,getType=function(_ab)return bba end,getBaseFrame=function(_ab)if(_ab.parent~=nil)then -return _ab.parent:getBaseFrame()end;return _ab end,setMode=function(_ab,aab) -dda=aab;return _ab end,generateXMLEventFunction=function(_ab,aab,bab) -local cab=function(dab) -if(dab:sub(1,1)=="#")then -local _bb=_ab:getBaseFrame():getDeepObject(dab:sub(2,dab:len())) -if(_bb~=nil)and(_bb.internalObjetCall~=nil)then aab(_ab,function() -_bb:internalObjetCall()end)end else -aab(_ab,_ab:getBaseFrame():getVariable(dab))end end;if(type(bab)=="string")then cab(bab)elseif(type(bab)=="table")then -for dab,_bb in pairs(bab)do cab(_bb)end end;return _ab end,setValuesByXMLData=function(_ab,aab)bda= -cc("loop",aab)==true and true or false -if( -cc("object",aab)~=nil)then -local bab=_ab:getBaseFrame():getDeepObject(cc("object",aab))if(bab==nil)then -bab=_ab:getBaseFrame():getVariable(cc("object",aab))end -if(bab~=nil)then _ab:setObject(bab)end end -if(aab["move"]~=nil)then local bab=cc("x",aab["move"]) -local cab=cc("y",aab["move"])local dab=cc("duration",aab["move"]) -local _bb=cc("time",aab["move"])_ab:move(bab,cab,dab,_bb)end -if(aab["size"]~=nil)then local bab=cc("width",aab["size"]) -local cab=cc("height",aab["size"])local dab=cc("duration",aab["size"]) -local _bb=cc("time",aab["size"])_ab:size(bab,cab,dab,_bb)end -if(aab["offset"]~=nil)then local bab=cc("x",aab["offset"]) -local cab=cc("y",aab["offset"])local dab=cc("duration",aab["offset"]) -local _bb=cc("time",aab["offset"])_ab:offset(bab,cab,dab,_bb)end -if(aab["textColor"]~=nil)then -local bab=cc("duration",aab["textColor"])local cab=cc("time",aab["textColor"])local dab={} -local _bb=aab["textColor"]["color"] -if(_bb~=nil)then if(_bb.properties~=nil)then _bb={_bb}end;for abb,bbb in pairs(_bb)do -table.insert(dab,colors[bbb:value()])end end;if(bab~=nil)and(#dab>0)then -_ab:changeTextColor(bab,cab or 0,table.unpack(dab))end end -if(aab["background"]~=nil)then -local bab=cc("duration",aab["background"])local cab=cc("time",aab["background"])local dab={} -local _bb=aab["background"]["color"] -if(_bb~=nil)then if(_bb.properties~=nil)then _bb={_bb}end;for abb,bbb in pairs(_bb)do -table.insert(dab,colors[bbb:value()])end end;if(bab~=nil)and(#dab>0)then -_ab:changeBackground(bab,cab or 0,table.unpack(dab))end end -if(aab["text"]~=nil)then local bab=cc("duration",aab["text"]) -local cab=cc("time",aab["text"])local dab={}local _bb=aab["text"]["text"] -if(_bb~=nil)then if(_bb.properties~=nil)then -_bb={_bb}end;for abb,bbb in pairs(_bb)do -table.insert(dab,bbb:value())end end;if(bab~=nil)and(#dab>0)then -_ab:changeText(bab,cab or 0,table.unpack(dab))end end;if(cc("onDone",aab)~=nil)then -_ab:generateXMLEventFunction(_ab.onDone,cc("onDone",aab))end;if(cc("onStart",aab)~=nil)then -_ab:generateXMLEventFunction(_ab.onDone,cc("onStart",aab))end -if -(cc("autoDestroy",aab)~=nil)then if(cc("autoDestroy",aab))then cda=true end end;dda=cc("mode",aab)or dda -if(cc("play",aab)~=nil)then if -(cc("play",aab))then _ab:play(bda)end end;return _ab end,getZIndex=function(_ab)return -1 end,getName=function(_ab)return _ab.name end,setObject=function(_ab,aab)__b=aab;return _ab end,move=function(_ab,aab,bab,cab,dab,_bb)__b= -_bb or __b -d_b(aab,bab,cab,dab or 0,__b.getPosition,__b.setPosition,"position",_ab)return _ab end,offset=function(_ab,aab,bab,cab,dab,_bb)__b= -_bb or __b -d_b(aab,bab,cab,dab or 0,__b.getOffset,__b.setOffset,"offset",_ab)return _ab end,size=function(_ab,aab,bab,cab,dab,_bb)__b=_bb or -__b -d_b(aab,bab,cab,dab or 0,__b.getSize,__b.setSize,"size",_ab)return _ab end,changeText=function(_ab,aab,bab,...) -local cab={...}bab=bab or 0;__b=obj or __b;for n=1,#cab do -c_b(bab+n* (aab/#cab),function() -__b.setText(__b,cab[n])end)end;return _ab end,changeBackground=function(_ab,aab,bab,...) -local cab={...}bab=bab or 0;__b=obj or __b;for n=1,#cab do -c_b(bab+n* (aab/#cab),function() -__b.setBackground(__b,cab[n])end)end;return _ab end,changeTextColor=function(_ab,aab,bab,...) -local cab={...}bab=bab or 0;__b=obj or __b;for n=1,#cab do -c_b(bab+n* (aab/#cab),function() -__b.setForeground(__b,cab[n])end)end;return _ab end,add=function(_ab,aab,bab) -ada=aab -c_b((bab or _da)+ -(dba[#dba]~=nil and dba[#dba].t or 0),aab)return _ab end,wait=function(_ab,aab)_da=aab;return _ab end,rep=function(_ab,aab) -if( -ada~=nil)then for n=1,aab or 1 do -c_b((wait or _da)+ -(dba[#dba]~=nil and dba[#dba].t or 0),ada)end end;return _ab end,onDone=function(_ab,aab) -dca:registerEvent("animation_done",aab)return _ab end,onStart=function(_ab,aab) -dca:registerEvent("animation_start",aab)return _ab end,setAutoDestroy=function(_ab,aab) -cda=aab~=nil and aab or true;return _ab end,animationDoneHandler=function(_ab) -dca:sendEvent("animation_done",_ab)_ab.parent:removeEvent("other_event",_ab)if(cda)then -_ab.parent:removeObject(_ab)_ab=nil end end,animationStartHandler=function(_ab) -dca:sendEvent("animation_start",_ab)end,clear=function(_ab)dba={}ada=nil;_da=0;bca=1;_ca=0;cca=false;return _ab end,play=function(_ab,aab) -_ab:cancel()aca=true;cca=aab and true or false;bca=1;_ca=0 -if(dba[bca]~=nil)then -if( -dba[bca].t>0)then cba=os.startTimer(dba[bca].t)else b_b(_ab)end else _ab:animationDoneHandler()end;_ab.parent:addEvent("other_event",_ab)return _ab end,cancel=function(_ab)if( -cba~=nil)then os.cancelTimer(cba)cca=false end -aca=false;_ab.parent:removeEvent("other_event",_ab)return _ab end,internalObjetCall=function(_ab) -_ab:play(bda)end,eventHandler=function(_ab,aab,bab)if(aca)then -if(aab=="timer")and(bab==cba)then if(dba[bca]~=nil)then -b_b(_ab)else _ab:animationDoneHandler()end end end end}aba.__index=aba;return aba end -end; -project['objects']['Button'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=aa.getValueFromXML;local ca=require("tHex") -return -function(da)local _b=_a(da)local ab="Button"local bb="center" -local cb="center"_b:setZIndex(5)_b:setValue("Button")_b.width=12 -_b.height=3 -local db={init=function(_c)_c.bgColor=_c.parent:getTheme("ButtonBG") -_c.fgColor=_c.parent:getTheme("ButtonText")end,getType=function(_c)return ab end,setHorizontalAlign=function(_c,ac)bb=ac -_c:updateDraw()return _c end,setVerticalAlign=function(_c,ac)cb=ac;_c:updateDraw()return _c end,setText=function(_c,ac) -_b:setValue(ac)_c:updateDraw()return _c end,setValuesByXMLData=function(_c,ac) -_b.setValuesByXMLData(_c,ac) -if(ba("text",ac)~=nil)then _c:setText(ba("text",ac))end;if(ba("horizontalAlign",ac)~=nil)then -bb=ba("horizontalAlign",ac)end;if(ba("verticalAlign",ac)~=nil)then -cb=ba("verticalAlign",ac)end;return _c end,draw=function(_c) -if -(_b.draw(_c))then -if(_c.parent~=nil)then local ac,bc=_c:getAnchorPosition() -local cc,dc=_c:getSize()local _d=aa.getTextVerticalAlign(dc,cb) -for n=1,dc do -if(n==_d)then -_c.parent:setText(ac,bc+ (n-1),aa.getTextHorizontalAlign(_c:getValue(),cc,bb)) -_c.parent:setFG(ac,bc+ (n-1),aa.getTextHorizontalAlign(ca[_c.fgColor]:rep(_c:getValue():len()),cc,bb))end end end end end}return setmetatable(db,_b)end -end; -project['objects']['Checkbox'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Checkbox"ca:setZIndex(5)ca:setValue(false) -ca.width=1;ca.height=1;local _b="\42" -local ab={getType=function(bb)return da end,setSymbol=function(bb,cb)_b=cb;bb:updateDraw()return bb end,mouseHandler=function(bb,cb,db,_c) -if -(ca.mouseHandler(bb,cb,db,_c))then -if(cb==1)then if -(bb:getValue()~=true)and(bb:getValue()~=false)then bb:setValue(false)else -bb:setValue(not bb:getValue())end -bb:updateDraw()return true end end;return false end,touchHandler=function(bb,cb,db)return -bb:mouseHandler(1,cb,db)end,setValuesByXMLData=function(bb,cb) -ca.setValuesByXMLData(bb,cb) -if(aa("checked",cb)~=nil)then if(aa("checked",cb))then bb:setValue(true)else -bb:setValue(false)end end;return bb end,draw=function(bb) -if -(ca.draw(bb))then -if(bb.parent~=nil)then local cb,db=bb:getAnchorPosition() -local _c,ac=bb:getSize()local bc=_a.getTextVerticalAlign(ac,"center")if -(bb.bgColor~=false)then -bb.parent:drawBackgroundBox(cb,db,_c,ac,bb.bgColor)end -for n=1,ac do -if(n==bc)then -if(bb:getValue()==true)then -bb.parent:writeText(cb, -db+ (n-1),_a.getTextHorizontalAlign(_b,_c,"center"),bb.bgColor,bb.fgColor)else -bb.parent:writeText(cb,db+ (n-1),_a.getTextHorizontalAlign(" ",_c,"center"),bb.bgColor,bb.fgColor)end end end end end end,init=function(bb) -ca.init(bb)bb.bgColor=bb.parent:getTheme("CheckboxBG") -bb.fgColor=bb.parent:getTheme("CheckboxText")bb.parent:addEvent("mouse_click",bb)end}return setmetatable(ab,ca)end -end; -project['objects']['Dropdown'] = function(...)local d=require("Object")local _a=require("utils") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Dropdown"ca.width=12;ca.height=1;ca:setZIndex(6) -local _b={}local ab;local bb;local cb=true;local db="left"local _c=0;local ac=16;local bc=6;local cc="\16"local dc="\31"local _d=false -local ad={getType=function(bd) -return da end,setValuesByXMLData=function(bd,cd)ca.setValuesByXMLData(bd,cd) -if -(aa("selectionBG",cd)~=nil)then ab=colors[aa("selectionBG",cd)]end;if(aa("selectionFG",cd)~=nil)then -bb=colors[aa("selectionFG",cd)]end;if(aa("dropdownWidth",cd)~=nil)then -ac=aa("dropdownWidth",cd)end;if(aa("dropdownHeight",cd)~=nil)then -bc=aa("dropdownHeight",cd)end;if(aa("offset",cd)~=nil)then -_c=aa("offset",cd)end -if(cd["item"]~=nil)then local dd=cd["item"]if -(dd.properties~=nil)then dd={dd}end;for __a,a_a in pairs(dd)do -bd:addItem(aa("text",a_a),colors[aa("bg",a_a)],colors[aa("fg",a_a)])end end end,setOffset=function(bd,cd) -_c=cd;bd:updateDraw()return bd end,getOffset=function(bd)return _c end,addItem=function(bd,cd,dd,__a,...) -table.insert(_b,{text=cd,bgCol= -dd or bd.bgColor,fgCol=__a or bd.fgColor,args={...}})bd:updateDraw()return bd end,getAll=function(bd)return -_b end,removeItem=function(bd,cd)table.remove(_b,cd)bd:updateDraw()return bd end,getItem=function(bd,cd)return -_b[cd]end,getItemIndex=function(bd)local cd=bd:getValue()for dd,__a in pairs(_b)do -if(__a==cd)then return dd end end end,clear=function(bd) -_b={}bd:setValue({})bd:updateDraw()return bd end,getItemCount=function(bd)return -#_b end,editItem=function(bd,cd,dd,__a,a_a,...)table.remove(_b,cd) -table.insert(_b,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol= -a_a or bd.fgColor,args={...}})bd:updateDraw()return bd end,selectItem=function(bd,cd)bd:setValue( -_b[cd]or{})bd:updateDraw()return bd end,setSelectedItem=function(bd,cd,dd,__a)ab= -cd or bd.bgColor;bb=dd or bd.fgColor;cb=__a -bd:updateDraw()return bd end,setDropdownSize=function(bd,cd,dd)ac,bc=cd,dd -bd:updateDraw()return bd end,mouseHandler=function(bd,cd,dd,__a) -if(_d)then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition()) -if(cd==1)then -if(#_b>0)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if -(a_a<=dd)and(a_a+ac>dd)and(b_a+n==__a)then bd:setValue(_b[n+_c])bd:updateDraw() -local c_a=bd:getEventSystem():sendEvent("mouse_click",bd,"mouse_click",dir,dd,__a)if(c_a==false)then return c_a end;return true end end end end end end -if(ca.mouseHandler(bd,cd,dd,__a))then _d=(not _d)bd:updateDraw()return true else if(_d)then -bd:updateDraw()_d=false end;return false end end,mouseUpHandler=function(bd,cd,dd,__a) -if -(_d)then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition()) -if(cd==1)then -if(#_b>0)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if -(a_a<=dd)and(a_a+ac>dd)and(b_a+n==__a)then _d=false;bd:updateDraw() -local c_a=bd:getEventSystem():sendEvent("mouse_up",bd,"mouse_up",dir,dd,__a)if(c_a==false)then return c_a end;return true end end end end end end end,scrollHandler=function(bd,cd,dd,__a) -if -(_d)and(bd:isFocused())then _c=_c+cd;if(_c<0)then _c=0 end;if(cd==1)then -if(#_b>bc)then if -(_c>#_b-bc)then _c=#_b-bc end else _c=math.min(#_b-1,0)end end -local a_a=bd:getEventSystem():sendEvent("mouse_scroll",bd,"mouse_scroll",cd,dd,__a)if(a_a==false)then return a_a end;bd:updateDraw()return true end end,draw=function(bd) -if -(ca.draw(bd))then local cd,dd=bd:getAnchorPosition()local __a,a_a=bd:getSize() -if -(bd.parent~=nil)then if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=bd:getValue() -local c_a=_a.getTextHorizontalAlign(( -b_a~=nil and b_a.text or""),__a,db):sub(1, -__a-1).. (_d and dc or cc) -bd.parent:writeText(cd,dd,c_a,bd.bgColor,bd.fgColor) -if(_d)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if(_b[n+_c]==b_a)then -if(cb)then -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+ -_c].text,ac,db),ab,bb)else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end end end end end end end,init=function(bd) -bd.bgColor=bd.parent:getTheme("DropdownBG")bd.fgColor=bd.parent:getTheme("DropdownText") -ab=bd.parent:getTheme("SelectionBG")bb=bd.parent:getTheme("SelectionText")if(bd.parent~=nil)then -bd.parent:addEvent("mouse_click",bd)bd.parent:addEvent("mouse_up",bd) -bd.parent:addEvent("mouse_scroll",bd)end end}return setmetatable(ad,ca)end -end; -project['objects']['Graphic'] = function(...)local da=require("Object")local _b=require("geometricPoints") -local ab=require("tHex")local bb=require("utils").getValueFromXML -local cb,db,_c,ac=string.sub,string.len,math.max,math.min -return -function(bc)local cc=da(bc)local dc="Graphic"cc:setZIndex(2)local _d={}local ad={}local bd={} -local cd=false;local dd,__a=0,0;local a_a=false;local b_a,c_a;local d_a,_aa=40,15;local aaa=false;local baa={}for n=1,16 do baa[string.byte("0123456789abcdef",n,n)]= -2 ^ (n-1)end -local function caa(dba)local _ca={}for i=1, -#dba do _ca[i]=dba:sub(i,i)end;return _ca end -local function daa(dba,_ca,aca,bca,cca) -if(_ca>=1)and(_ca<=bca)then -if(dba+db(cca)>0)and(dba<=aca)then -local dca=ad[_ca]local _da;local ada=dba+#cca-1 -if(dba<1)then -cca=cb(cca,1 -dba+1,aca-dba+1)elseif(ada>aca)then cca=cb(cca,1,aca-dba+1)end -if(dba>1)then _da=cb(dca,1,dba-1)..cca else _da=cca end;if ada -ad[y]:len())then ad[y]=ad[y].. -(ab[cc.bgColor]):rep(dba-ad[y]:len())else -ad[y]=ad[y]:sub(1,dba)end else -ad[y]=(ab[cc.bgColor]):rep(dba)end end end;_ba() -local function aba() -local function dba(b_b,c_b)local d_b={}for x=1,c_b:len()do -d_b[x]=baa[string.byte(c_b,x,x)]or 0 end;table.insert(b_b,d_b)end -function parseImage(b_b)if type(b_b)~="string"then -error("bad argument #1 (expected string, got "..type(b_b)..")")end;local c_b={}for d_b in -(b_b.."\n"):gmatch("(.-)\n")do dba(c_b,d_b)end;return c_b end;local _ca=""for y=1,#ad do -if(y==#ad)then _ca=_ca..ad[y]else _ca=_ca..ad[y].."\n"end end;local aca=parseImage(_ca) -local bca={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local cca,dca,_da={},{},{}for i=0,15 do dca[2 ^i]=i end -do local b_b="0123456789abcdef" -for i=1,16 do cca[b_b:sub(i,i)]= -i-1;cca[i-1]=b_b:sub(i,i) -_da[b_b:sub(i,i)]=2 ^ (i-1)_da[2 ^ (i-1)]=b_b:sub(i,i)local c_b=bca[i-1]for i=1,#c_b do -c_b[i]=2 ^c_b[i]end end end -local function ada(b_b)local c_b=bca[dca[b_b[#b_b][1] ] ] -for j=1,#c_b do local d_b=c_b[j]for i=1, -#b_b-1 do if b_b[i][1]==d_b then return i end end end;return 1 end -local function bda(b_b,c_b) -if not c_b then local _ab={}c_b={}for i=1,6 do local aab=b_b[i]local bab=c_b[aab] -c_b[aab],_ab[i]=bab and(bab+1)or 1,aab end;b_b=_ab end;local d_b={}for _ab,aab in pairs(c_b)do d_b[#d_b+1]={_ab,aab}end -if# -d_b>1 then -while#d_b>2 do -table.sort(d_b,function(_bb,abb)return _bb[2]>abb[2]end)local aab,bab=ada(d_b),#d_b;local cab,dab=d_b[bab][1],d_b[aab][1]for i=1,6 do -if b_b[i]== -cab then b_b[i]=dab;d_b[aab][2]=d_b[aab][2]+1 end end;d_b[bab]=nil end;local _ab=128;for i=1,#b_b-1 do -if b_b[i]~=b_b[6]then _ab=_ab+2 ^ (i-1)end end;return string.char(_ab),_da[d_b[1][1]==b_b[6]and -d_b[2][1]or d_b[1][1] ], -_da[b_b[6] ]else -return"\128",_da[b_b[1] ],_da[b_b[1] ]end end -local cda,dda,__b,a_b={{},{},{}},0,#aca+#aca%3,cc.bgColor or colors.black -for i=1,#aca do if#aca[i]>dda then dda=#aca[i]end end -for y=0,__b-1,3 do local b_b,c_b,d_b,_ab={},{},{},1 -for x=0,dda-1,2 do local aab,bab={},{} -for yy=1,3 do -for xx=1,2 do -aab[#aab+1]= -(aca[y+yy]and aca[y+yy][ -x+xx])and(aca[y+yy][x+xx]==0 and a_b or aca[y+yy][ -x+xx])or a_b;bab[aab[#aab] ]= -bab[aab[#aab] ]and(bab[aab[#aab] ]+1)or 1 end end;b_b[_ab],c_b[_ab],d_b[_ab]=bda(aab,bab)_ab=_ab+1 end -cda[1][#cda[1]+1],cda[2][#cda[2]+1],cda[3][#cda[3]+1]=table.concat(b_b),table.concat(c_b),table.concat(d_b)end;cda.width,cda.height=#cda[1][1],#cda[1]bd=cda end -local function bba()local dba,_ca=d_a,_aa;if(cd)then dba=dba*2;_ca=_ca*3 end;for aca,bca in pairs(_d)do -for cca,dca in -pairs(bca[1])do daa(dca.x,dca.y,dba,_ca,bca[2])end end;if(cd)then aba()end end -local cba={init=function(dba)dba.bgColor=dba.parent:getTheme("GraphicBG")end,getType=function(dba)return -dc end,setSize=function(dba,_ca,aca,bca)cc.setSize(dba,_ca,aca,bca)if not(aaa)then d_a=_ca -_aa=aca;_ba()end;bba()return dba end,setOffset=function(dba,_ca,aca)dd= -_ca or dd;__a=aca or __a;return dba end,setCanvasSize=function(dba,_ca,aca) -d_a,_aa=_ca,aca;aaa=true;_ba()return dba end,clearCanvas=function(dba)_d={}ad={}_ba()end,getOffset=function(dba)return -dd,__a end,setValuesByXMLData=function(dba,_ca)cc.setValuesByXMLData(dba,_ca) -if( -bb("text",_ca)~=nil)then dba:setText(bb("text",_ca))end;if(bb("xOffset",_ca)~=nil)then -dba:setOffset(bb("xOffset",_ca),__a)end;if(bb("yOffset",_ca)~=nil)then -dba:setOffset(dd,bb("yOffset",_ca))end;if(bb("wCanvas",_ca)~=nil)then -d_a=bb("wCanvas",_ca)end;if(bb("hCanvas",_ca)~=nil)then -_aa=bb("hCanvas",_ca)end;if(bb("shrink",_ca)~=nil)then if(bb("shrink",_ca))then -dba:shrink()end end -if -(bb("dragable",_ca)~=nil)then if(bb("dragable",_ca))then a_a=true end end -if(_ca["ellipse"]~=nil)then local aca=_ca["ellipse"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=bb("radius",cca)local ada=bb("radius2",cca)local bda=bb("x",cca)local cda=bb("y",cca) -local dda=bb("filled",cca)dba:addEllipse(dca,_da,ada,bda,cda,dda)end end -if(_ca["circle"]~=nil)then local aca=_ca["circle"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("radius",cca))local ada=tonumber(bb("x",cca)) -local bda=tonumber(bb("y",cca))local cda=bb("filled",cca) -dba:addCircle(dca,_da,ada,bda,cda)end end -if(_ca["line"]~=nil)then local aca=_ca["line"] -if(aca.properties~=nil)then aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("x",cca))local ada=tonumber(bb("x2",cca)) -local bda=tonumber(bb("y",cca))local cda=tonumber(bb("y2",cca)) -dba:addLine(dca,_da,bda,ada,cda)end end -if(_ca["rectangle"]~=nil)then local aca=_ca["rectangle"]if -(aca.properties~=nil)then aca={aca}end -for bca,cca in pairs(aca)do -local dca=colors[bb("color",cca)]local _da=tonumber(bb("x",cca)) -local ada=tonumber(bb("x2",cca))local bda=tonumber(bb("y",cca)) -local cda=tonumber(bb("y2",cca)) -local dda=bb("filled",cca)=="true"and true or false;dba:addRectangle(dca,_da,bda,ada,cda,dda)end end -if(_ca["triangle"]~=nil)then local aca=_ca["triangle"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("x",cca))local ada=tonumber(bb("x2",cca)) -local bda=tonumber(bb("x2",cca))local cda=tonumber(bb("y",cca)) -local dda=tonumber(bb("y2",cca))local __b=tonumber(bb("y3",cca))local a_b=bb("filled",cca) -dba:addTriangle(dca,_da,cda,ada,dda,bda,__b,a_b)end end;return dba end,addCircle=function(dba,_ca,aca,bca,cca,dca) -local _da=ab[_ca] -table.insert(_d,{_b.circle(bca or 1,cca or 1,aca,dca),ab[_ca]})bba()return dba end,addEllipse=function(dba,_ca,aca,bca,cca,dca,_da) -table.insert(_d,{_b.ellipse( -cca or 1,dca or 1,aca,bca,_da),ab[_ca]})bba()return dba end,addLine=function(dba,_ca,aca,bca,cca,dca) -table.insert(_d,{_b.line( -aca or 1,bca or 1,cca or 1,dca or 1),ab[_ca]})bba()return dba end,addTriangle=function(dba,_ca,aca,bca,cca,dca,_da,ada,bda) -table.insert(_d,{_b.triangle( -aca or 1,bca or 1,cca or 1,dca or 1,_da or 1,ada or 1,bda),ab[_ca]})bba()return dba end,addRectangle=function(dba,_ca,aca,bca,cca,dca,_da) -table.insert(_d,{_b.rectangle( -aca or 1,bca or 1,cca or 1,dca or 1,_da),ab[_ca]})bba()return dba end,shrink=function(dba) -cd=true;_ba()aba()return dba end,setDragable=function(dba,_ca) -a_a=_ca==true and true or false;return dba end,mouseHandler=function(dba,_ca,aca,bca,cca) -if(cc.mouseHandler(dba,_ca,aca,bca,cca))then -if -(a_a)then if(_ca=="mouse_click")then b_a,c_a=bca,cca end -if(_ca=="mouse_drag")then if -(b_a~=nil)and(c_a~=nil)then -dd=_c(ac(dd+b_a-bca,d_a-dba:getWidth()),0)b_a=bca -__a=_c(ac(__a+c_a-cca,_aa-dba:getHeight()),0)c_a=cca end end end;return true end;return false end,draw=function(dba) -if -(cc.draw(dba))then -if(dba.parent~=nil)then local _ca,aca=dba:getAnchorPosition() -local bca,cca=dba:getSize()if(dba.bgColor~=false)then -dba.parent:drawBackgroundBox(_ca,aca,bca,cca,dba.bgColor)end -if(cd)then local dca,_da,ada=bd[1],bd[2],bd[3] -for i=1,bd.height -do local bda,cda=_ca+dd,aca+i-1 +__a -if -(cda>aca-1)and(cda<=aca+cca-1)and(bda<=bca+_ca)then local dda=dca[i]local __b,a_b,b_b=_c(bda,_ca),_c(1 -bda+1,1),ac( -bca- (bda-_ca),bca) -if -type(dda)=="string"then dba.parent:setText(__b,cda,cb(dda,a_b,b_b)) -dba.parent:setFG(__b,cda,cb(_da[i],a_b,b_b)) -dba.parent:setBG(__b,cda,cb(ada[i],a_b,b_b))elseif type(dda)=="table"then -dba.parent:setText(__b,cda,cb(dda[2],a_b,b_b)) -dba.parent:setFG(__b,cda,cb(_da[i],a_b,b_b)) -dba.parent:setBG(__b,cda,cb(ada[i],a_b,b_b))end end end else -for i=1,#ad do local dca,_da=_ca+dd,aca+i-1 +__a -if -(_da>aca-1)and(_da<=aca+cca-1)and(dca<=bca+_ca)then local ada,bda,cda=_c(dca,_ca),_c(1 -dca+1,1),ac(bca- -(dca-_ca),bca) -dba.parent:setBG(ada,_da,cb(ad[i],bda,cda))end end end end;dba:setVisualChanged(false)end end}return setmetatable(cba,cc)end -end; -project['objects']['Image'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Image"aa:setZIndex(2)local ca;local da;local _b=false -local function ab() -local cb={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local db,_c,ac={},{},{}for i=0,15 do _c[2 ^i]=i end -do local cd="0123456789abcdef" -for i=1,16 do db[cd:sub(i,i)]= -i-1;db[i-1]=cd:sub(i,i) -ac[cd:sub(i,i)]=2 ^ (i-1)ac[2 ^ (i-1)]=cd:sub(i,i)local dd=cb[i-1]for i=1,#dd do -dd[i]=2 ^dd[i]end end end -local function bc(cd)local dd=cb[_c[cd[#cd][1] ] ] -for j=1,#dd do local __a=dd[j]for i=1,#cd-1 do if -cd[i][1]==__a then return i end end end;return 1 end -local function cc(cd,dd) -if not dd then local a_a={}dd={}for i=1,6 do local b_a=cd[i]local c_a=dd[b_a] -dd[b_a],a_a[i]=c_a and(c_a+1)or 1,b_a end;cd=a_a end;local __a={}for a_a,b_a in pairs(dd)do __a[#__a+1]={a_a,b_a}end -if -#__a>1 then -while#__a>2 do -table.sort(__a,function(aaa,baa)return aaa[2]>baa[2]end)local b_a,c_a=bc(__a),#__a;local d_a,_aa=__a[c_a][1],__a[b_a][1]for i=1,6 do -if -cd[i]==d_a then cd[i]=_aa;__a[b_a][2]=__a[b_a][2]+1 end end;__a[c_a]=nil end;local a_a=128 -for i=1,#cd-1 do if cd[i]~=cd[6]then a_a=a_a+2 ^ (i-1)end end -return string.char(a_a),ac[__a[1][1]==cd[6]and __a[2][1]or -__a[1][1] ],ac[cd[6] ]else return"\128",ac[cd[1] ],ac[cd[1] ]end end -local dc,_d,ad,bd={{},{},{}},0,#ca+#ca%3,aa.bgColor or colors.black;for i=1,#ca do if#ca[i]>_d then _d=#ca[i]end end -for y=0,ad-1,3 do -local cd,dd,__a,a_a={},{},{},1 -for x=0,_d-1,2 do local b_a,c_a={},{} -for yy=1,3 do -for xx=1,2 do -b_a[#b_a+1]=(ca[y+yy]and ca[y+yy][x+xx])and -(ca[y+ -yy][x+xx]==0 and bd or ca[y+yy][x+xx])or bd;c_a[b_a[#b_a] ]= -c_a[b_a[#b_a] ]and(c_a[b_a[#b_a] ]+1)or 1 end end;cd[a_a],dd[a_a],__a[a_a]=cc(b_a,c_a)a_a=a_a+1 end -dc[1][#dc[1]+1],dc[2][#dc[2]+1],dc[3][#dc[3]+1]=table.concat(cd),table.concat(dd),table.concat(__a)end;dc.width,dc.height=#dc[1][1],#dc[1]da=dc end -local bb={init=function(cb)cb.bgColor=cb.parent:getTheme("ImageBG")end,getType=function(cb)return -ba end,loadImage=function(cb,db)ca=paintutils.loadImage(db)_b=false -cb:updateDraw()return cb end,shrink=function(cb)ab()_b=true -cb:updateDraw()return cb end,setValuesByXMLData=function(cb,db)aa.setValuesByXMLData(cb,db) -if( -d("shrink",db)~=nil)then if(d("shrink",db))then cb:shrink()end end -if(d("path",db)~=nil)then cb:loadImage(d("path",db))end;return cb end,draw=function(cb) -if -(aa.draw(cb))then -if(cb.parent~=nil)then -if(ca~=nil)then local db,_c=cb:getAnchorPosition() -local ac,bc=cb:getSize() -if(_b)then local cc,dc,_d=da[1],da[2],da[3] -for i=1,da.height do local ad=cc[i] -if type(ad)=="string"then cb.parent:setText(db, -_c+i-1,ad) -cb.parent:setFG(db,_c+i-1,dc[i])cb.parent:setBG(db,_c+i-1,_d[i])elseif -type(ad)=="table"then cb.parent:setText(db,_c+i-1,ad[2])cb.parent:setFG(db,_c+ -i-1,dc[i]) -cb.parent:setBG(db,_c+i-1,_d[i])end end else -for yPos=1,math.min(#ca,bc)do local cc=ca[yPos] -for xPos=1,math.min(#cc,ac)do if cc[xPos]>0 then -cb.parent:drawBackgroundBox( -db+xPos-1,_c+yPos-1,1,1,cc[xPos])end end end end end end end end}return setmetatable(bb,aa)end -end; -project['objects']['Input'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=require("basaltLogs")local ca=aa.getValueFromXML -return -function(da)local _b=_a(da)local ab="Input"local bb="text"local cb=0 -_b:setZIndex(5)_b:setValue("")_b.width=10;_b.height=1;local db=1;local _c=1;local ac=""local bc;local cc -local dc=ac;local _d=false -local ad={getType=function(bd)return ab end,setInputType=function(bd,cd)if(cd=="password")or(cd=="number")or -(cd=="text")then bb=cd end -bd:updateDraw()return bd end,setDefaultText=function(bd,cd,dd,__a)ac=cd -bc=__a or bc;cc=dd or cc;if(bd:isFocused())then dc=""else dc=ac end -bd:updateDraw()return bd end,getInputType=function(bd)return bb end,setValue=function(bd,cd) -_b.setValue(bd,tostring(cd)) -if not(_d)then -if(bd:isFocused())then db=tostring(cd):len()+1;_c=math.max(1, -db-bd:getWidth()+1) -local dd,__a=bd:getAnchorPosition() -bd.parent:setCursor(true,dd+db-_c,__a+math.floor(bd.height/2),bd.fgColor)end end;bd:updateDraw()return bd end,getValue=function(bd) -local cd=_b.getValue(bd)return bb=="number"and tonumber(cd)or cd end,setInputLimit=function(bd,cd)cb= -tonumber(cd)or cb;bd:updateDraw()return bd end,getInputLimit=function(bd)return -cb end,setValuesByXMLData=function(bd,cd)_b.setValuesByXMLData(bd,cd)local dd,__a;if( -ca("defaultBG",cd)~=nil)then dd=ca("defaultBG",cd)end;if( -ca("defaultFG",cd)~=nil)then __a=ca("defaultFG",cd)end;if( -ca("default",cd)~=nil)then -bd:setDefaultText(ca("default",cd),__a~=nil and colors[__a],dd~=nil and -colors[dd])end -if -(ca("limit",cd)~=nil)then bd:setInputLimit(ca("limit",cd))end -if(ca("type",cd)~=nil)then bd:setInputType(ca("type",cd))end;return bd end,getFocusHandler=function(bd) -_b.getFocusHandler(bd) -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition()dc=""if(ac~="")then -bd:updateDraw()end -bd.parent:setCursor(true,cd+db-_c,dd+math.max(math.ceil( -bd:getHeight()/2 -1,1)),bd.fgColor)end end,loseFocusHandler=function(bd) -_b.loseFocusHandler(bd)if(bd.parent~=nil)then dc=ac;if(ac~="")then bd:updateDraw()end -bd.parent:setCursor(false)end end,keyHandler=function(bd,cd) -if -(_b.keyHandler(bd,cd))then local dd,__a=bd:getSize()_d=true -if(cd==keys.backspace)then -local _aa=tostring(_b.getValue())if(db>1)then -bd:setValue(_aa:sub(1,db-2).._aa:sub(db,_aa:len()))if(db>1)then db=db-1 end -if(_c>1)then if(db<_c)then _c=_c-1 end end end end;if(cd==keys.enter)then if(bd.parent~=nil)then end end -if(cd== -keys.right)then -local _aa=tostring(_b.getValue()):len()db=db+1;if(db>_aa)then db=_aa+1 end;if(db<1)then db=1 end;if -(db<_c)or(db>=dd+_c)then _c=db-dd+1 end;if(_c<1)then _c=1 end end -if(cd==keys.left)then db=db-1;if(db>=1)then -if(db<_c)or(db>=dd+_c)then _c=db end end;if(db<1)then db=1 end;if(_c<1)then _c=1 end end;local a_a,b_a=bd:getAnchorPosition() -local c_a=tostring(_b.getValue()) -local d_a=(db<=c_a:len()and db-1 or c_a:len())- (_c-1)if(d_a>bd.x+dd-1)then d_a=bd.x+dd-1 end;if -(bd.parent~=nil)then -bd.parent:setCursor(true,a_a+d_a,b_a+math.max(math.ceil(__a/2 -1,1)),bd.fgColor)end;_d=false;return true end;return false end,charHandler=function(bd,cd) -if -(_b.charHandler(bd,cd))then _d=true;local dd,__a=bd:getSize()local a_a=_b.getValue() -if(a_a:len()=dd+_c)then _c=_c+1 end end;local b_a,c_a=bd:getAnchorPosition() -local d_a=tostring(_b.getValue()) -local _aa=(db<=d_a:len()and db-1 or d_a:len())- (_c-1)local aaa=bd:getX()if(_aa>aaa+dd-1)then _aa=aaa+dd-1 end;if( -bd.parent~=nil)then -bd.parent:setCursor(true,b_a+_aa,c_a+ -math.max(math.ceil(__a/2 -1,1)),bd.fgColor)end;_d=false -bd:updateDraw()return true end;return false end,mouseHandler=function(bd,cd,dd,__a) -if -(_b.mouseHandler(bd,cd,dd,__a))then local a_a,b_a=bd:getAnchorPosition() -local c_a,d_a=bd:getAbsolutePosition(a_a,b_a)local _aa,aaa=bd:getSize()db=dd-c_a+_c;local baa=_b.getValue()if(db> -baa:len())then db=baa:len()+1 end;if(db<_c)then _c=db-1 -if(_c<1)then _c=1 end end -bd.parent:setCursor(true,c_a+db-1,d_a+ -math.max(math.ceil(aaa/2 -1,1)),bd.fgColor)return true end end,eventHandler=function(bd,cd,dd,__a,a_a,b_a) -if -(_b.eventHandler(bd,cd,dd,__a,a_a,b_a))then -if(cd=="paste")then -if(bd:isFocused())then local c_a=_b.getValue() -local d_a,_aa=bd:getSize()_d=true -if(bb=="number")then local aba=c_a -if(dd==".")or(tonumber(dd)~=nil)then -bd:setValue(c_a:sub(1, -db-1)..dd..c_a:sub(db,c_a:len()))db=db+dd:len()end -if(tonumber(_b.getValue())==nil)then bd:setValue(aba)end else -bd:setValue(c_a:sub(1,db-1)..dd..c_a:sub(db,c_a:len()))db=db+dd:len()end;if(db>=d_a+_c)then _c=(db+1)-d_a end -local aaa,baa=bd:getAnchorPosition()local caa=tostring(_b.getValue()) -local daa=( -db<=caa:len()and db-1 or caa:len())- (_c-1)local _ba=bd:getX() -if(daa>_ba+d_a-1)then daa=_ba+d_a-1 end;if(bd.parent~=nil)then -bd.parent:setCursor(true,aaa+daa,baa+ -math.max(math.ceil(_aa/2 -1,1)),bd.fgColor)end -bd:updateDraw()_d=false end end end end,draw=function(bd) -if -(_b.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()local b_a=aa.getTextVerticalAlign(a_a,"center")if -(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end -for n=1,a_a do -if(n==b_a)then -local c_a=tostring(_b.getValue())local d_a=bd.bgColor;local _aa=bd.fgColor;local aaa;if(c_a:len()<=0)then aaa=dc;d_a=bc or d_a;_aa= -cc or _aa end;aaa=dc -if(c_a~="")then aaa=c_a end;aaa=aaa:sub(_c,__a+_c-1)local baa=__a-aaa:len()if(baa<0)then -baa=0 end;if(bb=="password")and(c_a~="")then -aaa=string.rep("*",aaa:len())end -aaa=aaa..string.rep(bd.bgSymbol,baa)bd.parent:writeText(cd,dd+ (n-1),aaa,d_a,_aa)end end;if(bd:isFocused())then -bd.parent:setCursor(true,cd+db-_c,dd+math.max(math.ceil( -bd:getHeight()/2 -1,1)),bd.fgColor)end end end end,init=function(bd) -bd.bgColor=bd.parent:getTheme("InputBG")bd.fgColor=bd.parent:getTheme("InputText") -if -(bd.parent~=nil)then bd.parent:addEvent("mouse_click",bd) -bd.parent:addEvent("key",bd)bd.parent:addEvent("char",bd) -bd.parent:addEvent("other_event",bd)end end}return setmetatable(ad,_b)end -end; -project['objects']['Label'] = function(...)local ba=require("Object")local ca=require("utils") -local da=ca.getValueFromXML;local _b=ca.createText;local ab=require("tHex")local bb=require("bigfont") -return -function(cb) -local db=ba(cb)local _c="Label"db:setZIndex(3)local ac=true;db:setValue("Label") -db.width=5;local bc="left"local cc="top"local dc=0;local _d,ad=false,false -local bd={getType=function(cd)return _c end,setText=function(cd,dd) -dd=tostring(dd)db:setValue(dd)if(ac)then cd.width=dd:len()end -cd:updateDraw()return cd end,setBackground=function(cd,dd) -db.setBackground(cd,dd)ad=true;cd:updateDraw()return cd end,setForeground=function(cd,dd) -db.setForeground(cd,dd)_d=true;cd:updateDraw()return cd end,setTextAlign=function(cd,dd,__a) -bc=dd or bc;cc=__a or cc;cd:updateDraw()return cd end,setFontSize=function(cd,dd)if( -dd>0)and(dd<=4)then dc=dd-1 or 0 end -cd:updateDraw()return cd end,getFontSize=function(cd)return dc+1 end,setValuesByXMLData=function(cd,dd) -db.setValuesByXMLData(cd,dd) -if(da("text",dd)~=nil)then cd:setText(da("text",dd))end -if(da("verticalAlign",dd)~=nil)then cc=da("verticalAlign",dd)end;if(da("horizontalAlign",dd)~=nil)then -bc=da("horizontalAlign",dd)end;if(da("font",dd)~=nil)then -cd:setFontSize(da("font",dd))end;return cd end,setSize=function(cd,dd,__a,a_a) -db.setSize(cd,dd,__a,a_a)ac=false;cd:updateDraw()return cd end,draw=function(cd) -if -(db.draw(cd))then -if(cd.parent~=nil)then local dd,__a=cd:getAnchorPosition() -local a_a,b_a=cd:getSize()local c_a=ca.getTextVerticalAlign(b_a,cc) -if(dc==0)then -if not(ac)then -local d_a=_b(cd:getValue(),cd:getWidth())for _aa,aaa in pairs(d_a)do -cd.parent:writeText(dd,__a+_aa-1,aaa,cd.bgColor,cd.fgColor)end else -cd.parent:writeText(dd,__a,cd:getValue(),cd.bgColor,cd.fgColor)end else -local d_a=bb(dc,cd:getValue(),cd.fgColor,cd.bgColor or colors.lightGray) -if(ac)then cd:setSize(#d_a[1][1],#d_a[1]-1)end;local _aa,aaa=cd.parent:getSize() -local baa,caa=#d_a[1][1],#d_a[1] -dd=dd or math.floor((_aa-baa)/2)+1 -__a=__a or math.floor((aaa-caa)/2)+1 -for i=1,caa do cd.parent:setFG(dd,__a+i-2,d_a[2][i])cd.parent:setBG(dd, -__a+i-2,d_a[3][i])cd.parent:setText(dd, -__a+i-2,d_a[1][i])end end end end end,init=function(cd) -if -(db.init(cd))then cd.bgColor=cd.parent:getTheme("LabelBG") -cd.fgColor=cd.parent:getTheme("LabelText") -if -(cd.parent.bgColor==colors.black)and(cd.fgColor==colors.black)then cd.fgColor=colors.lightGray end end end}return setmetatable(bd,db)end -end; -project['objects']['List'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="List"ca.width=16;ca.height=6;ca:setZIndex(5)local _b={} -local ab;local bb;local cb=true;local db="left"local _c=0;local ac=true -local bc={getType=function(cc)return da end,addItem=function(cc,dc,_d,ad,...) -table.insert(_b,{text=dc,bgCol=_d or cc.bgColor,fgCol= -ad or cc.fgColor,args={...}})if(#_b==1)then cc:setValue(_b[1])end -cc:updateDraw()return cc end,setOffset=function(cc,dc) -_c=dc;cc:updateDraw()return cc end,getOffset=function(cc)return _c end,removeItem=function(cc,dc) -table.remove(_b,dc)cc:updateDraw()return cc end,getItem=function(cc,dc)return _b[dc]end,getAll=function(cc)return -_b end,getItemIndex=function(cc)local dc=cc:getValue() -for _d,ad in pairs(_b)do if(ad==dc)then return _d end end end,clear=function(cc)_b={}cc:setValue({}) -cc:updateDraw()return cc end,getItemCount=function(cc)return#_b end,editItem=function(cc,dc,_d,ad,bd,...) -table.remove(_b,dc) -table.insert(_b,dc,{text=_d,bgCol=ad or cc.bgColor,fgCol=bd or cc.fgColor,args={...}})cc:updateDraw()return cc end,selectItem=function(cc,dc)cc:setValue( -_b[dc]or{})cc:updateDraw()return cc end,setSelectedItem=function(cc,dc,_d,ad)ab= -dc or cc.bgColor;bb=_d or cc.fgColor -cb=ad~=nil and ad or true;cc:updateDraw()return cc end,setScrollable=function(cc,dc) -ac=dc;if(dc==nil)then ac=true end;cc:updateDraw()return cc end,setValuesByXMLData=function(cc,dc) -ca.setValuesByXMLData(cc,dc)if(aa("selectionBG",dc)~=nil)then -ab=colors[aa("selectionBG",dc)]end;if(aa("selectionFG",dc)~=nil)then -bb=colors[aa("selectionFG",dc)]end;if(aa("scrollable",dc)~=nil)then -if -(aa("scrollable",dc))then cc:setScrollable(true)else cc:setScrollable(false)end end;if -(aa("offset",dc)~=nil)then _c=aa("offset",dc)end -if(dc["item"]~=nil)then -local _d=dc["item"]if(_d.properties~=nil)then _d={_d}end;for ad,bd in pairs(_d)do -cc:addItem(aa("text",bd),colors[aa("bg",bd)],colors[aa("fg",bd)])end end;return cc end,scrollHandler=function(cc,dc,_d,ad) -if -(ca.scrollHandler(cc,dc,_d,ad))then -if(ac)then local bd,cd=cc:getSize()_c=_c+dc;if(_c<0)then _c=0 end;if(dc>=1)then -if(#_b>cd)then if -(_c>#_b-cd)then _c=#_b-cd end;if(_c>=#_b)then _c=#_b-1 end else _c=_c-1 end end -cc:updateDraw()end;return true end;return false end,mouseHandler=function(cc,dc,_d,ad) -if -(ca.mouseHandler(cc,dc,_d,ad))then -local bd,cd=cc:getAbsolutePosition(cc:getAnchorPosition())local dd,__a=cc:getSize() -if(#_b>0)then for n=1,__a do -if(_b[n+_c]~=nil)then if -(bd<=_d)and(bd+dd>_d)and(cd+n-1 ==ad)then cc:setValue(_b[n+_c]) -cc:updateDraw()end end end end;return true end;return false end,dragHandler=function(cc,dc,_d,ad)return -cc:mouseHandler(dc,_d,ad)end,touchHandler=function(cc,dc,_d) -return cc:mouseHandler(1,dc,_d)end,draw=function(cc) -if(ca.draw(cc))then -if(cc.parent~=nil)then -local dc,_d=cc:getAnchorPosition()local ad,bd=cc:getSize()if(cc.bgColor~=false)then -cc.parent:drawBackgroundBox(dc,_d,ad,bd,cc.bgColor)end -for n=1,bd do -if(_b[n+_c]~=nil)then -if(_b[n+_c]== -cc:getValue())then -if(cb)then -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),ab,bb)else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end end end end end end,init=function(cc) -cc.bgColor=cc.parent:getTheme("ListBG")cc.fgColor=cc.parent:getTheme("ListText") -ab=cc.parent:getTheme("SelectionBG")bb=cc.parent:getTheme("SelectionText") -cc.parent:addEvent("mouse_click",cc)cc.parent:addEvent("mouse_drag",cc) -cc.parent:addEvent("mouse_scroll",cc)end}return setmetatable(bc,ca)end -end; -project['objects']['Menubar'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=aa.getValueFromXML;local ca=require("tHex") -return -function(da)local _b=_a(da)local ab="Menubar"local bb={}_b.width=30 -_b.height=1;_b:setZIndex(5)local cb={}local db;local _c;local ac=true;local bc="left"local cc=0;local dc=1 -local _d=false -local function ad()local bd=0;local cd=0;local dd=bb:getWidth() -for n=1,#cb do if(cd+cb[n].text:len()+ -dc*2 >dd)then -if(cddd)then cc=dd end;bd:updateDraw() -return bd end,getOffset=function(bd)return cc end,setScrollable=function(bd,cd) -_d=cd;if(cd==nil)then _d=true end;return bd end,setValuesByXMLData=function(bd,cd) -_b.setValuesByXMLData(bd,cd)if(ba("selectionBG",cd)~=nil)then -db=colors[ba("selectionBG",cd)]end;if(ba("selectionFG",cd)~=nil)then -_c=colors[ba("selectionFG",cd)]end;if(ba("scrollable",cd)~=nil)then -if -(ba("scrollable",cd))then bd:setScrollable(true)else bd:setScrollable(false)end end -if -(ba("offset",cd)~=nil)then bd:setOffset(ba("offset",cd))end;if(ba("space",cd)~=nil)then dc=ba("space",cd)end -if( -cd["item"]~=nil)then local dd=cd["item"]if(dd.properties~=nil)then dd={dd}end;for __a,a_a in -pairs(dd)do -bd:addItem(ba("text",a_a),colors[ba("bg",a_a)],colors[ba("fg",a_a)])end end;return bd end,removeItem=function(bd,cd) -table.remove(cb,cd)bd:updateDraw()return bd end,getItem=function(bd,cd)return cb[cd]end,getItemCount=function(bd)return -#cb end,editItem=function(bd,cd,dd,__a,a_a,...)table.remove(cb,cd) -table.insert(cb,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol= -a_a or bd.fgColor,args={...}})bd:updateDraw()return bd end,selectItem=function(bd,cd)bd:setValue( -cb[cd]or{})bd:updateDraw()return bd end,setSelectedItem=function(bd,cd,dd,__a)db= -cd or bd.bgColor;_c=dd or bd.fgColor;ac=__a -bd:updateDraw()return bd end,mouseHandler=function(bd,cd,dd,__a) -if -(_b.mouseHandler(bd,cd,dd,__a))then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition())local c_a,d_a=bd:getSize()local _aa=0 -for n=1,#cb do -if(cb[n]~=nil)then -if -(a_a+_aa<=dd+cc)and(a_a+_aa+ -cb[n].text:len()+ (dc*2)>dd+cc)and(b_a==__a)then bd:setValue(cb[n]) -bd:getEventSystem():sendEvent(event,bd,event,0,dd,__a,cb[n])end;_aa=_aa+cb[n].text:len()+dc*2 end end;bd:updateDraw()return true end;return false end,scrollHandler=function(bd,cd,dd,__a) -if -(_b.scrollHandler(bd,cd,dd,__a))then if(_d)then cc=cc+cd;if(cc<0)then cc=0 end;local a_a=ad()if(cc>a_a)then cc=a_a end -bd:updateDraw()end;return true end;return false end,draw=function(bd) -if -(_b.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=""local c_a=""local d_a="" -for _aa,aaa in pairs(cb)do -local baa= -(" "):rep(dc)..aaa.text.. (" "):rep(dc)b_a=b_a..baa -if(aaa==bd:getValue())then c_a=c_a.. -ca[db or aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[_c or aaa.FgCol or -bd.fgColor]:rep(baa:len())else c_a=c_a.. -ca[aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[aaa.FgCol or bd.fgColor]:rep(baa:len())end end -bd.parent:setText(cd,dd,b_a:sub(cc+1,__a+cc)) -bd.parent:setBG(cd,dd,c_a:sub(cc+1,__a+cc)) -bd.parent:setFG(cd,dd,d_a:sub(cc+1,__a+cc))end end end,init=function(bd) -bd.bgColor=bd.parent:getTheme("MenubarBG")bd.fgColor=bd.parent:getTheme("MenubarText") -db=bd.parent:getTheme("SelectionBG")_c=bd.parent:getTheme("SelectionText") -bd.parent:addEvent("mouse_click",bd)bd.parent:addEvent("mouse_scroll",bd)end}return setmetatable(bb,_b)end -end; -project['objects']['Pane'] = function(...)local c=require("Object")local d=require("basaltLogs") -return -function(_a)local aa=c(_a) -local ba="Pane" -local ca={getType=function(da)return ba end,setBackground=function(da,_b,ab,bb)aa.setBackground(da,_b,ab,bb)return da end,init=function(da)if -(aa.init(da))then da.bgColor=da.parent:getTheme("PaneBG") -da.fgColor=da.parent:getTheme("PaneBG")end end}return setmetatable(ca,aa)end -end; -project['objects']['Program'] = function(...)local ba=require("Object")local ca=require("tHex") -local da=require("process")local _b=require("utils").getValueFromXML -local ab=require("basaltLogs")local bb=string.sub -return -function(cb,db)local _c=ba(cb)local ac="Program"_c:setZIndex(5)local bc;local cc -local function dc(b_a,c_a,d_a,_aa,aaa) -local baa,caa=1,1;local daa,_ba=colors.black,colors.white;local aba=false;local bba=false;local cba={}local dba={} -local _ca={}local aca={}local bca;local cca={}for i=0,15 do local aab=2 ^i -aca[aab]={db:getBasaltInstance().getBaseTerm().getPaletteColour(aab)}end;local function dca() -bca=(" "):rep(d_a) -for n=0,15 do local aab=2 ^n;local bab=ca[aab]cca[aab]=bab:rep(d_a)end end -local function _da()dca()local aab=bca -local bab=cca[colors.white]local cab=cca[colors.black] -for n=1,_aa do -cba[n]=bb(cba[n]==nil and aab or cba[n]..aab:sub(1, -d_a-cba[n]:len()),1,d_a) -_ca[n]=bb(_ca[n]==nil and bab or _ca[n].. -bab:sub(1,d_a-_ca[n]:len()),1,d_a) -dba[n]=bb(dba[n]==nil and cab or dba[n].. -cab:sub(1,d_a-dba[n]:len()),1,d_a)end;_c.updateDraw(_c)end;_da()local function ada()if -baa>=1 and caa>=1 and baa<=d_a and caa<=_aa then else end end -local function bda(aab,bab,cab) -local dab=baa;local _bb=dab+#aab-1 -if caa>=1 and caa<=_aa then -if dab<=d_a and _bb>=1 then -if dab==1 and _bb== -d_a then cba[caa]=aab;_ca[caa]=bab;dba[caa]=cab else local abb,bbb,cbb -if dab<1 then local _db= -1 -dab+1;local adb=d_a-dab+1;abb=bb(aab,_db,adb) -bbb=bb(bab,_db,adb)cbb=bb(cab,_db,adb)elseif _bb>d_a then local _db=d_a-dab+1;abb=bb(aab,1,_db) -bbb=bb(bab,1,_db)cbb=bb(cab,1,_db)else abb=aab;bbb=bab;cbb=cab end;local dbb=cba[caa]local _cb=_ca[caa]local acb=dba[caa]local bcb,ccb,dcb -if dab>1 then local _db=dab-1;bcb= -bb(dbb,1,_db)..abb;ccb=bb(_cb,1,_db)..bbb -dcb=bb(acb,1,_db)..cbb else bcb=abb;ccb=bbb;dcb=cbb end -if _bb=1 and _bb<=_aa then -cba[newY]=cba[_bb]dba[newY]=dba[_bb]_ca[newY]=_ca[_bb]else cba[newY]=bab -_ca[newY]=cab;dba[newY]=dab end end end;if(bba)then ada()end end,isColor=function()return -db:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return -db:getBasaltInstance().getBaseTerm().isColor()end,write=function(aab) -aab=tostring(aab)if(bba)then -bda(aab,ca[_ba]:rep(aab:len()),ca[daa]:rep(aab:len()))end end,clearLine=function() -if -(bba)then cda(1,caa,(" "):rep(d_a)) -dda(1,caa,ca[daa]:rep(d_a))__b(1,caa,ca[_ba]:rep(d_a))end;if(bba)then ada()end end,clear=function() -for n=1,_aa -do cda(1,n,(" "):rep(d_a)) -dda(1,n,ca[daa]:rep(d_a))__b(1,n,ca[_ba]:rep(d_a))end;if(bba)then ada()end end,blit=function(aab,bab,cab)if -type(aab)~="string"then -error("bad argument #1 (expected string, got "..type(aab)..")",2)end;if type(bab)~="string"then -error( -"bad argument #2 (expected string, got "..type(bab)..")",2)end;if type(cab)~="string"then -error( -"bad argument #3 (expected string, got "..type(cab)..")",2)end -if -#bab~=#aab or#cab~=#aab then error("Arguments must be the same length",2)end;if(bba)then bda(aab,bab,cab)end end}return _ab end;_c.width=30;_c.height=12;local _d=dc(1,1,_c.width,_c.height)local ad -local bd=false;local cd={} -local function dd(b_a)local c_a,d_a=_d.getCursorPos() -local _aa,aaa=b_a:getAnchorPosition()local baa,caa=b_a:getSize() -if(_aa+c_a-1 >=1 and -_aa+c_a-1 <=_aa+baa-1 and d_a+aaa-1 >=1 and -d_a+aaa-1 <=aaa+caa-1)then -b_a.parent:setCursor(_d.getCursorBlink(), -_aa+c_a-1,d_a+aaa-1,_d.getTextColor())end end -local function __a(b_a,c_a,d_a,_aa,aaa)if(ad==nil)then return false end -if not(ad:isDead())then if not(bd)then -local baa,caa=b_a:getAbsolutePosition(b_a:getAnchorPosition( -nil,nil,true))ad:resume(c_a,d_a,_aa-baa+1,aaa-caa+1) -dd(b_a)end end end -local function a_a(b_a,c_a,d_a,_aa)if(ad==nil)then return false end -if not(ad:isDead())then if not(bd)then if(b_a.draw)then -ad:resume(c_a,d_a,_aa)dd(b_a)end end end end -bc={getType=function(b_a)return ac end,show=function(b_a)_c.show(b_a) -_d.setBackgroundColor(b_a.bgColor)_d.setTextColor(b_a.fgColor) -_d.basalt_setVisible(true)return b_a end,hide=function(b_a) -_c.hide(b_a)_d.basalt_setVisible(false)return b_a end,setPosition=function(b_a,c_a,d_a,_aa) -_c.setPosition(b_a,c_a,d_a,_aa) -_d.basalt_reposition(b_a:getAnchorPosition())return b_a end,setValuesByXMLData=function(b_a,c_a) -_c.setValuesByXMLData(b_a,c_a)if(_b("path",c_a)~=nil)then cc=_b("path",c_a)end -if( -_b("execute",c_a)~=nil)then if(_b("execute",c_a))then -if(cc~=nil)then b_a:execute(cc)end end end end,getBasaltWindow=function()return -_d end,getBasaltProcess=function()return ad end,setSize=function(b_a,c_a,d_a,_aa)_c.setSize(b_a,c_a,d_a,_aa) -_d.basalt_resize(b_a:getWidth(),b_a:getHeight())return b_a end,getStatus=function(b_a)if(ad~=nil)then return -ad:getStatus()end;return"inactive"end,execute=function(b_a,c_a,...)cc= -c_a or cc;ad=da:new(cc,_d,...) -_d.setBackgroundColor(colors.black)_d.setTextColor(colors.white)_d.clear() -_d.setCursorPos(1,1)_d.setBackgroundColor(b_a.bgColor) -_d.setTextColor(b_a.fgColor)_d.basalt_setVisible(true)ad:resume()bd=false -if -(b_a.parent~=nil)then b_a.parent:addEvent("mouse_click",b_a) -b_a.parent:addEvent("mouse_up",b_a)b_a.parent:addEvent("mouse_drag",b_a) -b_a.parent:addEvent("mouse_scroll",b_a)b_a.parent:addEvent("key",b_a) -b_a.parent:addEvent("key_up",b_a)b_a.parent:addEvent("char",b_a) -b_a.parent:addEvent("other_event",b_a)end;return b_a end,stop=function(b_a)if( -ad~=nil)then -if not(ad:isDead())then ad:resume("terminate")if(ad:isDead())then -if( -b_a.parent~=nil)then b_a.parent:setCursor(false)end end end end -b_a.parent:removeEvents(b_a)return b_a end,pause=function(b_a,c_a)bd= -c_a or(not bd) -if(ad~=nil)then if not(ad:isDead())then if not(bd)then -b_a:injectEvents(cd)cd={}end end end;return b_a end,isPaused=function(b_a)return -bd end,injectEvent=function(b_a,c_a,d_a,_aa,aaa,baa,caa) -if(ad~=nil)then -if not(ad:isDead())then if(bd==false)or(caa)then -ad:resume(c_a,d_a,_aa,aaa,baa)else -table.insert(cd,{event=c_a,args={d_a,_aa,aaa,baa}})end end end;return b_a end,getQueuedEvents=function(b_a)return -cd end,updateQueuedEvents=function(b_a,c_a)cd=c_a or cd;return b_a end,injectEvents=function(b_a,c_a)if(ad~=nil)then -if not -(ad:isDead())then for d_a,_aa in pairs(c_a)do -ad:resume(_aa.event,table.unpack(_aa.args))end end end;return b_a end,mouseHandler=function(b_a,c_a,d_a,_aa) -if -(_c.mouseHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_click",c_a,d_a,_aa)return true end;return false end,mouseUpHandler=function(b_a,c_a,d_a,_aa) -if -(_c.mouseUpHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_up",c_a,d_a,_aa)return true end;return false end,scrollHandler=function(b_a,c_a,d_a,_aa) -if -(_c.scrollHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_scroll",c_a,d_a,_aa)return true end;return false end,dragHandler=function(b_a,c_a,d_a,_aa) -if -(_c.dragHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_drag",c_a,d_a,_aa)return true end;return false end,keyHandler=function(b_a,c_a,d_a)if -(_c.keyHandler(b_a,c_a,d_a))then a_a(b_a,"key",c_a,d_a)return true end;return -false end,keyUpHandler=function(b_a,c_a)if -(_c.keyUpHandler(b_a,c_a))then a_a(b_a,"key_up",c_a)return true end -return false end,charHandler=function(b_a,c_a)if -(_c.charHandler(b_a,c_a))then a_a(b_a,"char",c_a)return true end -return false end,getFocusHandler=function(b_a) -_c.getFocusHandler(b_a) -if(ad~=nil)then -if not(ad:isDead())then -if not(bd)then -if(b_a.parent~=nil)then -local c_a,d_a=_d.getCursorPos()local _aa,aaa=b_a:getAnchorPosition() -if(b_a.parent~=nil)then -local baa,caa=b_a:getSize() -if -(_aa+c_a-1 >=1 and _aa+c_a-1 <=_aa+baa-1 and -d_a+aaa-1 >=1 and d_a+aaa-1 <=aaa+caa-1)then -b_a.parent:setCursor(_d.getCursorBlink(),_aa+c_a-1,d_a+aaa-1,_d.getTextColor())end end end end end end end,loseFocusHandler=function(b_a) -_c.loseFocusHandler(b_a) -if(ad~=nil)then if not(ad:isDead())then if(b_a.parent~=nil)then -b_a.parent:setCursor(false)end end end end,eventHandler=function(b_a,c_a,d_a,_aa,aaa,baa) -if -(_c.eventHandler(b_a,c_a,d_a,_aa,aaa,baa))then if(ad==nil)then return end -if(c_a=="dynamicValueEvent")then local caa,daa=_d.getSize() -local _ba,aba=b_a:getSize() -if(caa~=_ba)or(daa~=aba)then _d.basalt_resize(_ba,aba)if not -(ad:isDead())then ad:resume("term_resize")end end -_d.basalt_reposition(b_a:getAnchorPosition())end -if not(ad:isDead())then -if not(bd)then if(c_a~="terminate")then -ad:resume(c_a,d_a,_aa,aaa,baa)end -if(b_a:isFocused())then -local caa,daa=b_a:getAnchorPosition()local _ba,aba=_d.getCursorPos() -if(b_a.parent~=nil)then -local bba,cba=b_a:getSize() -if -(caa+_ba-1 >=1 and caa+_ba-1 <=caa+bba-1 and -aba+daa-1 >=1 and aba+daa-1 <=daa+cba-1)then -b_a.parent:setCursor(_d.getCursorBlink(),caa+_ba-1,aba+daa-1,_d.getTextColor())end end;if(c_a=="terminate")then ab(b_a:isFocused())ad:resume(c_a) -b_a.parent:setCursor(false)return true end end else -table.insert(cd,{event=c_a,args={d_a,_aa,aaa,baa}})end end;return false end end,draw=function(b_a) -if -(_c.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize()_d.basalt_reposition(c_a,d_a)_d.basalt_update()end end end,init=function(b_a) -b_a.bgColor=b_a.parent:getTheme("ProgramBG")end}return setmetatable(bc,_c)end -end; -project['objects']['Progressbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Progressbar"local ca=0;aa:setZIndex(5) -aa:setValue(false)aa.width=25;aa.height=1;local da;local _b=""local ab=colors.white;local bb=""local cb=0 -local db={init=function(_c) -_c.bgColor=_c.parent:getTheme("ProgressbarBG")_c.fgColor=_c.parent:getTheme("ProgressbarText") -da=_c.parent:getTheme("ProgressbarActiveBG")end,getType=function(_c)return -ba end,setValuesByXMLData=function(_c,ac)aa.setValuesByXMLData(_c,ac)if(d("direction",ac)~= -nil)then cb=d("direction",ac)end -if( -d("progressColor",ac)~=nil)then da=colors[d("progressColor",ac)]end -if(d("progressSymbol",ac)~=nil)then _b=d("progressSymbol",ac)end;if(d("backgroundSymbol",ac)~=nil)then -bb=d("backgroundSymbol",ac)end -if -(d("progressSymbolColor",ac)~=nil)then ab=colors[d("progressSymbolColor",ac)]end;if(d("onDone",ac)~=nil)then -_c:generateXMLEventFunction(_c.onProgressDone,d("onDone",ac))end;return _c end,setDirection=function(_c,ac) -cb=ac;_c:updateDraw()return _c end,setProgressBar=function(_c,ac,bc,cc)da=ac or da -_b=bc or _b;ab=cc or ab;_c:updateDraw()return _c end,setBackgroundSymbol=function(_c,ac) -bb=ac:sub(1,1)_c:updateDraw()return _c end,setProgress=function(_c,ac)if -(ac>=0)and(ac<=100)and(ca~=ac)then ca=ac;_c:setValue(ca)if(ca==100)then -_c:progressDoneHandler()end end -_c:updateDraw()return _c end,getProgress=function(_c)return -ca end,onProgressDone=function(_c,ac)_c:registerEvent("progress_done",ac) -return _c end,progressDoneHandler=function(_c) -_c:sendEvent("progress_done",_c)end,draw=function(_c) -if(aa.draw(_c))then -if(_c.parent~=nil)then -local ac,bc=_c:getAnchorPosition()local cc,dc=_c:getSize()if(_c.bgColor~=false)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc,_c.bgColor)end;if(bb~="")then -_c.parent:drawTextBox(ac,bc,cc,dc,bb)end;if(_c.fgColor~=false)then -_c.parent:drawForegroundBox(ac,bc,cc,dc,_c.fgColor)end -if(cb==1)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc,cc,dc/100 *ca,ab) -_c.parent:drawTextBox(ac,bc,cc,dc/100 *ca,_b)elseif(cb==2)then -_c.parent:drawBackgroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc,dc/ -100 *ca,ab) -_c.parent:drawTextBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,_b)elseif(cb==3)then -_c.parent:drawBackgroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac+math.ceil(cc-cc/100 *ca),bc,cc/100 * -ca,dc,_b)else -_c.parent:drawBackgroundBox(ac,bc,cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac,bc,cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac,bc,cc/100 *ca,dc,_b)end end end end}return setmetatable(db,aa)end -end; -project['objects']['Radio'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Radio"ca.width=8;ca:setZIndex(5)local _b={}local ab;local bb;local cb -local db;local _c;local ac;local bc=true;local cc="\7"local dc="left" -local _d={getType=function(ad)return da end,setValuesByXMLData=function(ad,bd) -ca.setValuesByXMLData(ad,bd)if(aa("selectionBG",bd)~=nil)then -ab=colors[aa("selectionBG",bd)]end;if(aa("selectionFG",bd)~=nil)then -bb=colors[aa("selectionFG",bd)]end;if(aa("boxBG",bd)~=nil)then -cb=colors[aa("boxBG",bd)]end;if(aa("inactiveBoxBG",bd)~=nil)then -_c=colors[aa("inactiveBoxBG",bd)]end;if(aa("inactiveBoxFG",bd)~=nil)then -ac=colors[aa("inactiveBoxFG",bd)]end;if(aa("boxFG",bd)~=nil)then -db=colors[aa("boxFG",bd)]end;if(aa("symbol",bd)~=nil)then -cc=aa("symbol",bd)end -if(bd["item"]~=nil)then local cd=bd["item"]if -(cd.properties~=nil)then cd={cd}end;for dd,__a in pairs(cd)do -ad:addItem(aa("text",__a),aa("x",__a),aa("y",__a),colors[aa("bg",__a)],colors[aa("fg",__a)])end end;return ad end,addItem=function(ad,bd,cd,dd,__a,a_a,...) -table.insert(_b,{x= -cd or 1,y=dd or 1,text=bd,bgCol=__a or ad.bgColor,fgCol=a_a or ad.fgColor,args={...}})if(#_b==1)then ad:setValue(_b[1])end -ad:updateDraw()return ad end,getAll=function(ad)return -_b end,removeItem=function(ad,bd)table.remove(_b,bd)ad:updateDraw()return ad end,getItem=function(ad,bd)return -_b[bd]end,getItemIndex=function(ad)local bd=ad:getValue()for cd,dd in pairs(_b)do -if(dd==bd)then return cd end end end,clear=function(ad) -_b={}ad:setValue({})ad:updateDraw()return ad end,getItemCount=function(ad)return -#_b end,editItem=function(ad,bd,cd,dd,__a,a_a,b_a,...)table.remove(_b,bd) -table.insert(_b,bd,{x=dd or 1,y=__a or 1,text=cd,bgCol=a_a or -ad.bgColor,fgCol=b_a or ad.fgColor,args={...}})ad:updateDraw()return ad end,selectItem=function(ad,bd)ad:setValue( -_b[bd]or{})ad:updateDraw()return ad end,setActiveSymbol=function(ad,bd) -cc=bd:sub(1,1)ad:updateDraw()return ad end,setSelectedItem=function(ad,bd,cd,dd,__a,a_a)ab=bd or ab -bb=cd or bb;cb=dd or cb;db=__a or db;bc=a_a~=nil and a_a or true -ad:updateDraw()return ad end,mouseHandler=function(ad,bd,cd,dd) -if(#_b> -0)then -local __a,a_a=ad:getAbsolutePosition(ad:getAnchorPosition()) -for b_a,c_a in pairs(_b)do -if(__a+c_a.x-1 <=cd)and( -__a+c_a.x-1 +c_a.text:len()+1 >=cd)and( -a_a+c_a.y-1 ==dd)then ad:setValue(c_a) -local d_a=ad:getEventSystem():sendEvent("mouse_click",ad,"mouse_click",bd,cd,dd)if(d_a==false)then return d_a end;if(ad.parent~=nil)then -ad.parent:setFocusedObject(ad)end;ad:updateDraw()return true end end end;return false end,draw=function(ad) -if( -ad.parent~=nil)then local bd,cd=ad:getAnchorPosition() -for dd,__a in pairs(_b)do -if -(__a==ad:getValue())then if(dc=="left")then -ad.parent:writeText(__a.x+bd-1,__a.y+cd-1,cc,cb,db) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,ab,bb)end else -ad.parent:drawBackgroundBox( -__a.x+bd-1,__a.y+cd-1,1,1,_c or ad.bgColor) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,__a.bgCol,__a.fgCol)end end;return true end end,init=function(ad) -ad.bgColor=ad.parent:getTheme("MenubarBG")ad.fgColor=ad.parent:getTheme("MenubarFG") -ab=ad.parent:getTheme("SelectionBG")bb=ad.parent:getTheme("SelectionText") -cb=ad.parent:getTheme("MenubarBG")db=ad.parent:getTheme("MenubarText") -ad.parent:addEvent("mouse_click",ad)end}return setmetatable(_d,ca)end -end; -project['objects']['Scrollbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Scrollbar"aa.width=1;aa.height=8;aa:setValue(1) -aa:setZIndex(2)local ca="vertical"local da=" "local _b;local ab="\127"local bb=aa.height;local cb=1;local db=1 -local function _c(bc,cc,dc,_d) -local ad,bd=bc:getAbsolutePosition(bc:getAnchorPosition())local cd,dd=bc:getSize() -if(ca=="horizontal")then for _index=0,cd do -if -(ad+_index==dc)and(bd<=_d)and(bd+dd>_d)then -cb=math.min(_index+1,cd- (db-1))bc:setValue(bb/cd* (cb))bc:updateDraw()end end end -if(ca=="vertical")then for _index=0,dd do -if -(bd+_index==_d)and(ad<=dc)and(ad+cd>dc)then cb=math.min(_index+1,dd- (db-1)) -bc:setValue(bb/dd* (cb))bc:updateDraw()end end end end -local ac={getType=function(bc)return ba end,setSymbol=function(bc,cc)da=cc:sub(1,1)bc:updateDraw()return bc end,setValuesByXMLData=function(bc,cc) -aa.setValuesByXMLData(bc,cc) -if(d("maxValue",cc)~=nil)then bb=d("maxValue",cc)end;if(d("backgroundSymbol",cc)~=nil)then -ab=d("backgroundSymbol",cc):sub(1,1)end;if(d("symbol",cc)~=nil)then -da=d("symbol",cc):sub(1,1)end;if(d("barType",cc)~=nil)then -ca=d("barType",cc):lower()end;if(d("symbolSize",cc)~=nil)then -bc:setSymbolSize(d("symbolSize",cc))end;if(d("symbolColor",cc)~=nil)then -_b=colors[d("symbolColor",cc)]end;if(d("index",cc)~=nil)then -bc:setIndex(d("index",cc))end end,setIndex=function(bc,cc) -cb=cc;if(cb<1)then cb=1 end;local dc,_d=bc:getSize() -cb=math.min(cb,(ca=="vertical"and _d or -dc)- (db-1)) -bc:setValue(bb/ (ca=="vertical"and _d or dc)*cb)bc:updateDraw()return bc end,getIndex=function(bc)return -cb end,setSymbolSize=function(bc,cc)db=tonumber(cc)or 1;local dc,_d=bc:getSize() -if(ca== -"vertical")then -bc:setValue(cb-1 * (bb/ (_d- (db-1)))- -(bb/ (_d- (db-1))))elseif(ca=="horizontal")then -bc:setValue(cb-1 * (bb/ (dc- (db-1)))- (bb/ (dc- -(db-1))))end;bc:updateDraw()return bc end,setMaxValue=function(bc,cc) -bb=cc;bc:updateDraw()return bc end,setBackgroundSymbol=function(bc,cc) -ab=string.sub(cc,1,1)bc:updateDraw()return bc end,setSymbolColor=function(bc,cc)_b=cc -bc:updateDraw()return bc end,setBarType=function(bc,cc)ca=cc:lower()bc:updateDraw() -return bc end,mouseHandler=function(bc,cc,dc,_d)if(aa.mouseHandler(bc,cc,dc,_d))then -_c(bc,cc,dc,_d)return true end;return false end,dragHandler=function(bc,cc,dc,_d)if -(aa.dragHandler(bc,cc,dc,_d))then _c(bc,cc,dc,_d)return true end;return false end,scrollHandler=function(bc,cc,dc,_d) -if -(aa.scrollHandler(bc,cc,dc,_d))then local ad,bd=bc:getSize()cb=cb+cc;if(cb<1)then cb=1 end -cb=math.min(cb,( -ca=="vertical"and bd or ad)- (db-1)) -bc:setValue(bb/ (ca=="vertical"and bd or ad)*cb)bc:updateDraw()end end,draw=function(bc) -if -(aa.draw(bc))then -if(bc.parent~=nil)then local cc,dc=bc:getAnchorPosition() -local _d,ad=bc:getSize() -if(ca=="horizontal")then -bc.parent:writeText(cc,dc,ab:rep(cb-1),bc.bgColor,bc.fgColor) -bc.parent:writeText(cc+cb-1,dc,da:rep(db),_b,_b) -bc.parent:writeText(cc+cb+db-1,dc,ab:rep(_d- (cb+db-1)),bc.bgColor,bc.fgColor)end -if(ca=="vertical")then -for n=0,ad-1 do -if(cb==n+1)then for curIndexOffset=0,math.min(db-1,ad)do -bc.parent:writeText(cc,dc+n+curIndexOffset,da,_b,_b)end else if -(n+1 cb-1 +db)then -bc.parent:writeText(cc,dc+n,ab,bc.bgColor,bc.fgColor)end end end end end end end,init=function(bc) -bc.bgColor=bc.parent:getTheme("ScrollbarBG")bc.fgColor=bc.parent:getTheme("ScrollbarText") -_b=bc.parent:getTheme("ScrollbarSymbolColor")bc.parent:addEvent("mouse_click",bc) -bc.parent:addEvent("mouse_drag",bc)bc.parent:addEvent("mouse_scroll",bc)end}return setmetatable(ac,aa)end -end; -project['objects']['Slider'] = function(...)local d=require("Object")local _a=require("basaltLogs") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Slider"ca.width=8;ca.height=1;ca:setValue(1) -local _b="horizontal"local ab=" "local bb;local cb="\140"local db=ca.width;local _c=1;local ac=1 -local function bc(dc,_d,ad,bd) -local cd,dd=dc:getAbsolutePosition(dc:getAnchorPosition())local __a,a_a=dc:getSize() -if(_b=="horizontal")then for _index=0,__a do -if -(cd+_index==ad)and(dd<=bd)and(dd+a_a>bd)then -_c=math.min(_index+1,__a- (ac-1))dc:setValue(db/__a* (_c))dc:updateDraw()end end end -if(_b=="vertical")then for _index=0,a_a do -if -(dd+_index==bd)and(cd<=ad)and(cd+__a>ad)then _c=math.min(_index+1,a_a- (ac-1)) -dc:setValue(db/a_a* (_c))dc:updateDraw()end end end end -local cc={getType=function(dc)return da end,setSymbol=function(dc,_d)ab=_d:sub(1,1)dc:updateDraw()return dc end,setValuesByXMLData=function(dc,_d) -ca.setValuesByXMLData(dc,_d) -if(aa("maxValue",_d)~=nil)then db=aa("maxValue",_d)end;if(aa("backgroundSymbol",_d)~=nil)then -cb=aa("backgroundSymbol",_d):sub(1,1)end;if(aa("barType",_d)~=nil)then -_b=aa("barType",_d):lower()end;if(aa("symbol",_d)~=nil)then -ab=aa("symbol",_d):sub(1,1)end;if(aa("symbolSize",_d)~=nil)then -dc:setSymbolSize(aa("symbolSize",_d))end;if(aa("symbolColor",_d)~=nil)then -bb=colors[aa("symbolColor",_d)]end;if(aa("index",_d)~=nil)then -dc:setIndex(aa("index",_d))end end,setIndex=function(dc,_d) -_c=_d;if(_c<1)then _c=1 end;local ad,bd=dc:getSize() -_c=math.min(_c,(_b=="vertical"and bd or -ad)- (ac-1)) -dc:setValue(db/ (_b=="vertical"and bd or ad)*_c)dc:updateDraw()return dc end,getIndex=function(dc)return -_c end,setSymbolSize=function(dc,_d)ac=tonumber(_d)or 1 -if(_b=="vertical")then -dc:setValue(_c-1 * (db/ -(h- (ac-1)))- (db/ (h- (ac-1))))elseif(_b=="horizontal")then -dc:setValue(_c-1 * (db/ (w- (ac-1)))- (db/ -(w- (ac-1))))end;dc:updateDraw()return dc end,setMaxValue=function(dc,_d) -db=_d;return dc end,setBackgroundSymbol=function(dc,_d)cb=string.sub(_d,1,1) -dc:updateDraw()return dc end,setSymbolColor=function(dc,_d)bb=_d;dc:updateDraw()return dc end,setBarType=function(dc,_d) -_b=_d:lower()dc:updateDraw()return dc end,mouseHandler=function(dc,_d,ad,bd)if -(ca.mouseHandler(dc,_d,ad,bd))then bc(dc,_d,ad,bd)return true end;return false end,dragHandler=function(dc,_d,ad,bd)if -(ca.dragHandler(dc,_d,ad,bd))then bc(dc,_d,ad,bd)return true end;return false end,scrollHandler=function(dc,_d,ad,bd) -if -(ca.scrollHandler(dc,_d,ad,bd))then local cd,dd=dc:getSize()_c=_c+_d;if(_c<1)then _c=1 end -_c=math.min(_c,( -_b=="vertical"and dd or cd)- (ac-1)) -dc:setValue(db/ (_b=="vertical"and dd or cd)*_c)dc:updateDraw()return true end;return false end,draw=function(dc) -if -(ca.draw(dc))then -if(dc.parent~=nil)then local _d,ad=dc:getAnchorPosition() -local bd,cd=dc:getSize() -if(_b=="horizontal")then -dc.parent:writeText(_d,ad,cb:rep(_c-1),dc.bgColor,dc.fgColor) -dc.parent:writeText(_d+_c-1,ad,ab:rep(ac),bb,bb) -dc.parent:writeText(_d+_c+ac-1,ad,cb:rep(bd- (_c+ac-1)),dc.bgColor,dc.fgColor)end -if(_b=="vertical")then -for n=0,cd-1 do -if(_c==n+1)then for curIndexOffset=0,math.min(ac-1,cd)do -dc.parent:writeText(_d,ad+n+curIndexOffset,ab,bb,bb)end else if -(n+1 <_c)or(n+1 >_c-1 +ac)then -dc.parent:writeText(_d,ad+n,cb,dc.bgColor,dc.fgColor)end end end end end end end,init=function(dc) -dc.bgColor=dc.parent:getTheme("SliderBG")dc.fgColor=dc.parent:getTheme("SliderText") -bb=dc.parent:getTheme("SliderSymbolColor")dc.parent:addEvent("mouse_click",dc) -dc.parent:addEvent("mouse_drag",dc)dc.parent:addEvent("mouse_scroll",dc)end}return setmetatable(cc,ca)end -end; -project['objects']['Switch'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Switch"aa.width=2;aa.height=1 -aa.bgColor=colors.lightGray;aa.fgColor=colors.gray;aa:setValue(false)aa:setZIndex(5) -local ca=colors.black;local da=colors.red;local _b=colors.green -local ab={getType=function(bb)return ba end,setSymbolColor=function(bb,cb)ca=cb -bb:updateDraw()return bb end,setActiveBackground=function(bb,cb)_b=cb;bb:updateDraw()return bb end,setInactiveBackground=function(bb,cb) -da=cb;bb:updateDraw()return bb end,setValuesByXMLData=function(bb,cb) -aa.setValuesByXMLData(bb,cb)if(d("inactiveBG",cb)~=nil)then -da=colors[d("inactiveBG",cb)]end;if(d("activeBG",cb)~=nil)then -_b=colors[d("activeBG",cb)]end;if(d("symbolColor",cb)~=nil)then -ca=colors[d("symbolColor",cb)]end end,mouseHandler=function(bb,cb,db,_c) -if -(aa.mouseHandler(bb,cb,db,_c))then -local ac,bc=bb:getAbsolutePosition(bb:getAnchorPosition())bb:setValue(not bb:getValue()) -bb:updateDraw()return true end end,draw=function(bb) -if -(aa.draw(bb))then -if(bb.parent~=nil)then local cb,db=bb:getAnchorPosition() -local _c,ac=bb:getSize() -bb.parent:drawBackgroundBox(cb,db,_c,ac,bb.bgColor) -if(bb:getValue())then -bb.parent:drawBackgroundBox(cb,db,1,ac,_b)bb.parent:drawBackgroundBox(cb+1,db,1,ac,ca)else -bb.parent:drawBackgroundBox(cb,db,1,ac,ca)bb.parent:drawBackgroundBox(cb+1,db,1,ac,da)end end end end,init=function(bb) -bb.bgColor=bb.parent:getTheme("SwitchBG")bb.fgColor=bb.parent:getTheme("SwitchText") -ca=bb.parent:getTheme("SwitchBGSymbol")da=bb.parent:getTheme("SwitchInactive") -_b=bb.parent:getTheme("SwitchActive")bb.parent:addEvent("mouse_click",bb)end}return setmetatable(ab,aa)end -end; -project['objects']['Textfield'] = function(...)local aa=require("Object")local ba=require("tHex") -local ca=require("basaltLogs")local da=require("utils").getValueFromXML;local _b=string.rep -return -function(ab) -local bb=aa(ab)local cb="Textfield"local db,_c,ac,bc=1,1,1,1;local cc={""}local dc={""}local _d={""}local ad={}local bd={} -bb.width=30;bb.height=12;bb:setZIndex(5) -local function cd(b_a,c_a)local d_a={} -if(b_a:len()>0)then -for _aa in -string.gmatch(b_a,c_a)do local aaa,baa=string.find(b_a,_aa) -if(aaa~=nil)and(baa~=nil)then -table.insert(d_a,aaa)table.insert(d_a,baa) -local caa=string.sub(b_a,1,(aaa-1))local daa=string.sub(b_a,baa+1,b_a:len())b_a=caa.. -(":"):rep(_aa:len())..daa end end end;return d_a end -local function dd(b_a,c_a)c_a=c_a or bc -local d_a=ba[b_a.fgColor]:rep(_d[c_a]:len()) -local _aa=ba[b_a.bgColor]:rep(dc[c_a]:len()) -for aaa,baa in pairs(bd)do local caa=cd(cc[c_a],baa[1]) -if(#caa>0)then -for x=1,#caa/2 do local daa=x*2 -1;if( -baa[2]~=nil)then -d_a=d_a:sub(1,caa[daa]-1)..ba[baa[2] ]:rep(caa[daa+1]- -(caa[daa]-1)).. -d_a:sub(caa[daa+1]+1,d_a:len())end;if -(baa[3]~=nil)then -_aa=_aa:sub(1,caa[daa]-1).. - -ba[baa[3] ]:rep(caa[daa+1]- (caa[daa]-1)).._aa:sub(caa[daa+1]+1,_aa:len())end end end end -for aaa,baa in pairs(ad)do -for caa,daa in pairs(baa)do local _ba=cd(cc[c_a],daa) -if(#_ba>0)then for x=1,#_ba/2 do local aba=x*2 -1 -d_a=d_a:sub(1, -_ba[aba]-1).. - -ba[aaa]:rep(_ba[aba+1]- (_ba[aba]-1))..d_a:sub(_ba[aba+1]+1,d_a:len())end end end end;_d[c_a]=d_a;dc[c_a]=_aa;b_a:updateDraw()end;local function __a(b_a)for n=1,#cc do dd(b_a,n)end end -local a_a={getType=function(b_a)return cb end,setBackground=function(b_a,c_a) -bb.setBackground(b_a,c_a)__a(b_a)return b_a end,setForeground=function(b_a,c_a) -bb.setForeground(b_a,c_a)__a(b_a)return b_a end,setValuesByXMLData=function(b_a,c_a) -bb.setValuesByXMLData(b_a,c_a) -if(c_a["lines"]~=nil)then local d_a=c_a["lines"]["line"]if -(d_a.properties~=nil)then d_a={d_a}end;for _aa,aaa in pairs(d_a)do -b_a:addLine(aaa:value())end end -if(c_a["keywords"]~=nil)then -for d_a,_aa in pairs(c_a["keywords"])do -if(colors[d_a]~=nil)then -local aaa=_aa;if(aaa.properties~=nil)then aaa={aaa}end;local baa={} -for caa,daa in pairs(aaa)do -local _ba=daa["keyword"]if(daa["keyword"].properties~=nil)then -_ba={daa["keyword"]}end;for aba,bba in pairs(_ba)do -table.insert(baa,bba:value())end end;b_a:addKeywords(colors[d_a],baa)end end end -if(c_a["rules"]~=nil)then -if(c_a["rules"]["rule"]~=nil)then -local d_a=c_a["rules"]["rule"]if(c_a["rules"]["rule"].properties~=nil)then -d_a={c_a["rules"]["rule"]}end -for _aa,aaa in pairs(d_a)do if(da("pattern",aaa)~=nil)then -b_a:addRule(da("pattern",aaa),colors[da("fg",aaa)],colors[da("bg",aaa)])end end end end end,getLines=function(b_a)return -cc end,getLine=function(b_a,c_a)return cc[c_a]end,editLine=function(b_a,c_a,d_a) -cc[c_a]=d_a or cc[c_a]b_a:updateDraw()return b_a end,clear=function(b_a) -cc={""}dc={""}_d={""}db,_c,ac,bc=1,1,1,1;b_a:updateDraw()return b_a end,addLine=function(b_a,c_a,d_a) -if( -c_a~=nil)then if(#cc==1)and(cc[1]=="")then cc[1]=c_a -dc[1]=ba[b_a.bgColor]:rep(c_a:len())_d[1]=ba[b_a.fgColor]:rep(c_a:len()) -return b_a end -if(d_a~=nil)then -table.insert(cc,d_a,c_a) -table.insert(dc,d_a,ba[b_a.bgColor]:rep(c_a:len())) -table.insert(_d,ba[b_a.fgColor]:rep(c_a:len()))else table.insert(cc,c_a) -table.insert(dc,ba[b_a.bgColor]:rep(c_a:len())) -table.insert(_d,ba[b_a.fgColor]:rep(c_a:len()))end end;b_a:updateDraw()return b_a end,addKeywords=function(b_a,c_a,d_a)if( -ad[c_a]==nil)then ad[c_a]={}end;for _aa,aaa in pairs(d_a)do -table.insert(ad[c_a],aaa)end;b_a:updateDraw()return b_a end,addRule=function(b_a,c_a,d_a,_aa) -table.insert(bd,{c_a,d_a,_aa})b_a:updateDraw()return b_a end,editRule=function(b_a,c_a,d_a,_aa)for aaa,baa in -pairs(bd)do -if(baa[1]==c_a)then bd[aaa][2]=d_a;bd[aaa][3]=_aa end end;b_a:updateDraw()return b_a end,removeRule=function(b_a,c_a) -for d_a,_aa in -pairs(bd)do if(_aa[1]==c_a)then table.remove(bd,d_a)end end;b_a:updateDraw()return b_a end,setKeywords=function(b_a,c_a,d_a) -ad[c_a]=d_a;b_a:updateDraw()return b_a end,removeLine=function(b_a,c_a)table.remove(cc,c_a or -#cc) -if(#cc<=0)then table.insert(cc,"")end;b_a:updateDraw()return b_a end,getTextCursor=function(b_a)return -ac,bc end,getFocusHandler=function(b_a)bb.getFocusHandler(b_a) -if(b_a.parent~=nil)then -local c_a,d_a=b_a:getAnchorPosition()if(b_a.parent~=nil)then -b_a.parent:setCursor(true,c_a+ac-_c,d_a+bc-db,b_a.fgColor)end end end,loseFocusHandler=function(b_a) -bb.loseFocusHandler(b_a) -if(b_a.parent~=nil)then b_a.parent:setCursor(false)end end,keyHandler=function(b_a,c_a) -if -(bb.keyHandler(b_a,event,c_a))then local d_a,_aa=b_a:getAnchorPosition()local aaa,baa=b_a:getSize() -if(c_a== -keys.backspace)then -if(cc[bc]=="")then -if(bc>1)then table.remove(cc,bc) -table.remove(_d,bc)table.remove(dc,bc)ac=cc[bc-1]:len()+1;_c= -ac-aaa+1;if(_c<1)then _c=1 end;bc=bc-1 end elseif(ac<=1)then -if(bc>1)then ac=cc[bc-1]:len()+1;_c=ac-aaa+1 -if(_c<1)then _c=1 end;cc[bc-1]=cc[bc-1]..cc[bc] -_d[bc-1]=_d[bc-1].._d[bc]dc[bc-1]=dc[bc-1]..dc[bc]table.remove(cc,bc) -table.remove(_d,bc)table.remove(dc,bc)bc=bc-1 end else -cc[bc]=cc[bc]:sub(1,ac-2)..cc[bc]:sub(ac,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-2).._d[bc]:sub(ac,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-2)..dc[bc]:sub(ac,dc[bc]:len())if(ac>1)then ac=ac-1 end -if(_c>1)then if(ac<_c)then _c=_c-1 end end end;if(bccc[bc]:len())then -if(cc[bc+1]~=nil)then cc[bc]=cc[bc].. -cc[bc+1]table.remove(cc,bc+1) -table.remove(dc,bc+1)table.remove(_d,bc+1)end else -cc[bc]=cc[bc]:sub(1,ac-1)..cc[bc]:sub(ac+1,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-1).._d[bc]:sub(ac+1,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-1)..dc[bc]:sub(ac+1,dc[bc]:len())end;dd(b_a)end -if(c_a==keys.enter)then -table.insert(cc,bc+1,cc[bc]:sub(ac,cc[bc]:len())) -table.insert(_d,bc+1,_d[bc]:sub(ac,_d[bc]:len())) -table.insert(dc,bc+1,dc[bc]:sub(ac,dc[bc]:len()))cc[bc]=cc[bc]:sub(1,ac-1) -_d[bc]=_d[bc]:sub(1,ac-1)dc[bc]=dc[bc]:sub(1,ac-1)bc=bc+1;ac=1;_c=1;if(bc-db>=baa)then -db=db+1 end;b_a:setValue("")end -if(c_a==keys.up)then -if(bc>1)then bc=bc-1;if(ac>cc[bc]:len()+1)then ac= -cc[bc]:len()+1 end;if(_c>1)then if(ac<_c)then _c=ac-aaa+1;if(_c<1)then -_c=1 end end end;if(db>1)then if( -bccc[bc]:len()+1)then ac= -cc[bc]:len()+1 end;if(_c>1)then if(ac<_c)then _c=ac-aaa+1;if(_c<1)then -_c=1 end end end;if(bc>= -db+baa)then db=db+1 end end end -if(c_a==keys.right)then ac=ac+1;if(bc<#cc)then if(ac>cc[bc]:len()+1)then ac=1 -bc=bc+1 end elseif(ac>cc[bc]:len())then -ac=cc[bc]:len()+1 end;if(ac<1)then ac=1 end;if -(ac<_c)or(ac>=aaa+_c)then _c=ac-aaa+1 end -if(_c<1)then _c=1 end end -if(c_a==keys.left)then ac=ac-1;if(ac>=1)then -if(ac<_c)or(ac>=aaa+_c)then _c=ac end end -if(bc>1)then if(ac<1)then bc=bc-1 -ac=cc[bc]:len()+1;_c=ac-aaa+1 end end;if(ac<1)then ac=1 end;if(_c<1)then _c=1 end end;local caa= -(ac<=cc[bc]:len()and ac-1 or cc[bc]:len())- (_c-1)if(caa> -b_a.x+aaa-1)then caa=b_a.x+aaa-1 end;local daa=( -bc-db=aaa+_c)then _c=_c+1 end;dd(b_a) -b_a:setValue("")local caa= -(ac<=cc[bc]:len()and ac-1 or cc[bc]:len())- (_c-1)if(caa> -b_a.x+aaa-1)then caa=b_a.x+aaa-1 end;local daa=( -bc-dbcaa+d_a- (aaa+1)+_c)and(caacc[bc]:len())then -ac=cc[bc]:len()+1 end -if(ac<_c)then _c=ac-1;if(_c<1)then _c=1 end end;if(b_a.parent~=nil)then -b_a.parent:setCursor(true,caa+ac-_c,daa+bc-db,b_a.fgColor)end;b_a:updateDraw()end end;return true end end,scrollHandler=function(b_a,c_a,d_a,_aa) -if -(bb.scrollHandler(b_a,c_a,d_a,_aa))then -local aaa,baa=b_a:getAbsolutePosition(b_a:getAnchorPosition())local caa,daa=b_a:getAnchorPosition()local _ba,aba=b_a:getSize() -db=db+c_a;if(db>#cc- (aba-1))then db=#cc- (aba-1)end -if(db<1)then db=1 end -if(b_a.parent~=nil)then -if - -(aaa+ac-_c>=aaa and aaa+ac-_c=baa and baa+bc-dbcc[bc]:len())then ac= -cc[bc]:len()+1 end -if(ac<_c)then _c=ac-1;if(_c<1)then _c=1 end end end;if(b_a.parent~=nil)then -b_a.parent:setCursor(true,caa+ac-_c,daa+bc-db,b_a.fgColor)end;return true end end,eventHandler=function(b_a,c_a,d_a,_aa,aaa,baa) -if -(bb.eventHandler(b_a,c_a,d_a,_aa,aaa,baa))then -if(c_a=="paste")then -if(b_a:isFocused())then local caa,daa=b_a:getSize() -cc[bc]= -cc[bc]:sub(1,ac-1)..d_a..cc[bc]:sub(ac,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-1).. -ba[b_a.fgColor]:rep(d_a:len()).._d[bc]:sub(ac,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-1).. -ba[b_a.bgColor]:rep(d_a:len())..dc[bc]:sub(ac,dc[bc]:len())ac=ac+d_a:len()if(ac>=caa+_c)then _c=(ac+1)-caa end -local _ba,aba=b_a:getAnchorPosition() -b_a.parent:setCursor(true,_ba+ac-_c,aba+bc-db,b_a.fgColor)dd(b_a)b_a:updateDraw()end end end end,draw=function(b_a) -if -(bb.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize() -for n=1,aaa do local baa=""local caa=""local daa=""if(cc[n+db-1]~=nil)then baa=cc[n+db-1] -daa=_d[n+db-1]caa=dc[n+db-1]end -baa=baa:sub(_c,_aa+_c-1)caa=caa:sub(_c,_aa+_c-1) -daa=daa:sub(_c,_aa+_c-1)local _ba=_aa-baa:len()if(_ba<0)then _ba=0 end -baa=baa.._b(b_a.bgSymbol,_ba)caa=caa.._b(ba[b_a.bgColor],_ba)daa=daa.. -_b(ba[b_a.fgColor],_ba) -b_a.parent:setText(c_a,d_a+n-1,baa)b_a.parent:setBG(c_a,d_a+n-1,caa)b_a.parent:setFG(c_a, -d_a+n-1,daa)end;if(b_a:isFocused())then local baa,caa=b_a:getAnchorPosition() -b_a.parent:setCursor(true, -baa+ac-_c,caa+bc-db,b_a.fgColor)end end end end,init=function(b_a) -b_a.bgColor=b_a.parent:getTheme("TextfieldBG")b_a.fgColor=b_a.parent:getTheme("TextfieldText") -b_a.parent:addEvent("mouse_click",b_a)b_a.parent:addEvent("mouse_scroll",b_a) -b_a.parent:addEvent("mouse_drag",b_a)b_a.parent:addEvent("key",b_a) -b_a.parent:addEvent("char",b_a)b_a.parent:addEvent("other_event",b_a)end}return setmetatable(a_a,bb)end -end; -project['objects']['Thread'] = function(...)local b=require("utils").getValueFromXML -return -function(c)local d;local _a="Thread"local aa;local ba -local ca=false -local da=function(_b,ab) -if(ab:sub(1,1)=="#")then -local bb=_b:getBaseFrame():getDeepObject(ab:sub(2,ab:len())) -if(bb~=nil)and(bb.internalObjetCall~=nil)then return(function() -bb:internalObjetCall()end)end else return _b:getBaseFrame():getVariable(ab)end;return _b end -d={name=c,getType=function(_b)return _a end,getZIndex=function(_b)return 1 end,getName=function(_b)return _b.name end,getBaseFrame=function(_b)if -(_b.parent~=nil)then return _b.parent:getBaseFrame()end -return _b end,setValuesByXMLData=function(_b,ab)local bb;if(b("thread",ab)~=nil)then -bb=da(_b,b("thread",ab))end -if(b("start",ab)~=nil)then if -(b("start",ab))and(bb~=nil)then _b:start(bb)end end;return _b end,start=function(_b,ab) -if( -ab==nil)then error("Function provided to thread is nil")end;aa=ab;ba=coroutine.create(aa)ca=true -local bb,cb=coroutine.resume(ba)if not(bb)then if(cb~="Terminated")then -error("Thread Error Occurred - "..cb)end end -_b.parent:addEvent("other_event",_b)return _b end,getStatus=function(_b,ab)if( -ba~=nil)then return coroutine.status(ba)end;return nil end,stop=function(_b,ab) -ca=false;_b.parent:removeEvent("other_event",_b)return _b end,eventHandler=function(_b,ab,bb,cb,db) -if -(ca)then -if(coroutine.status(ba)~="dead")then -local _c,ac=coroutine.resume(ba,ab,bb,cb,db)if not(_c)then if(ac~="Terminated")then -error("Thread Error Occurred - "..ac)end end else -ca=false end end end}d.__index=d;return d end -end; -project['objects']['Timer'] = function(...)local c=require("basaltEvent") -local d=require("utils").getValueFromXML -return -function(_a)local aa="Timer"local ba=0;local ca=0;local da=0;local _b;local ab=c()local bb=false -local cb=function(_c,ac,bc) -local cc=function(dc) -if(dc:sub(1,1)=="#")then -local _d=_c:getBaseFrame():getDeepObject(dc:sub(2,dc:len())) -if(_d~=nil)and(_d.internalObjetCall~=nil)then ac(_c,function() -_d:internalObjetCall()end)end else -ac(_c,_c:getBaseFrame():getVariable(dc))end end;if(type(bc)=="string")then cc(bc)elseif(type(bc)=="table")then -for dc,_d in pairs(bc)do cc(_d)end end;return _c end -local db={name=_a,getType=function(_c)return aa end,setValuesByXMLData=function(_c,ac) -if(d("time",ac)~=nil)then ba=d("time",ac)end;if(d("repeat",ac)~=nil)then ca=d("repeat",ac)end -if( -d("start",ac)~=nil)then if(d("start",ac))then _c:start()end end;if(d("onCall",ac)~=nil)then -cb(_c,_c.onCall,d("onCall",ac))end;return _c end,getBaseFrame=function(_c) -if( -_c.parent~=nil)then return _c.parent:getBaseFrame()end;return _c end,getZIndex=function(_c)return 1 end,getName=function(_c) -return _c.name end,setTime=function(_c,ac,bc)ba=ac or 0;ca=bc or 1;return _c end,start=function(_c)if(bb)then -os.cancelTimer(_b)end;da=ca;_b=os.startTimer(ba)bb=true -_c.parent:addEvent("other_event",_c)return _c end,isActive=function(_c)return bb end,cancel=function(_c)if( -_b~=nil)then os.cancelTimer(_b)end;bb=false -_c.parent:removeEvent("other_event",_c)return _c end,onCall=function(_c,ac) -ab:registerEvent("timed_event",ac)return _c end,eventHandler=function(_c,ac,bc) -if -ac=="timer"and bc==_b and bb then ab:sendEvent("timed_event",_c) -if(da>=1)then da=da-1;if(da>=1)then -_b=os.startTimer(ba)end elseif(da==-1)then _b=os.startTimer(ba)end end end}db.__index=db;return db end -end; -project['libraries']['basaltDraw'] = function(...)local d=require("tHex")local _a,aa=string.sub,string.rep -return -function(ba) -local ca=ba or term.current()local da;local _b,ab=ca.getSize()local bb={}local cb={}local db={}local _c={}local ac={}local bc={}local cc -local dc={}local function _d()cc=aa(" ",_b) -for n=0,15 do local a_a=2 ^n;local b_a=d[a_a]dc[a_a]=aa(b_a,_b)end end;_d() -local function ad()_d()local a_a=cc -local b_a=dc[colors.white]local c_a=dc[colors.black] -for currentY=1,ab do -bb[currentY]=_a( -bb[currentY]==nil and a_a or -bb[currentY]..a_a:sub(1,_b-bb[currentY]:len()),1,_b) -db[currentY]=_a(db[currentY]==nil and b_a or db[currentY]..b_a:sub(1,_b- -db[currentY]:len()),1,_b) -cb[currentY]=_a(cb[currentY]==nil and c_a or cb[currentY]..c_a:sub(1,_b- -cb[currentY]:len()),1,_b)end end;ad() -local function bd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if -(a_a+c_a:len()>0)and(a_a<=_b)then local d_a=bb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1 -local caa=_b-a_a+1;c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -bb[b_a]=_aa end end end -local function cd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=cb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then -c_a=_a(c_a,1 -a_a+1,_b-a_a+1)elseif(aaa>_b)then c_a=_a(c_a,1,_b-a_a+1)end -if(a_a>1)then _aa=_a(d_a,1,a_a-1)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -cb[b_a]=_aa end end end -local function dd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=db[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1;local caa=_b-a_a+1 -c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -db[b_a]=_aa end end end -local __a={setSize=function(a_a,b_a)_b,ab=a_a,b_a;ad()end,setMirror=function(a_a)da=a_a end,setBG=function(a_a,b_a,c_a)cd(a_a,b_a,c_a)end,setText=function(a_a,b_a,c_a) -bd(a_a,b_a,c_a)end,setFG=function(a_a,b_a,c_a)dd(a_a,b_a,c_a)end,drawBackgroundBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -cd(a_a,b_a+ (n-1),aa(d[_aa],c_a))end end,drawForegroundBox=function(a_a,b_a,c_a,d_a,_aa) -for n=1,d_a do dd(a_a,b_a+ -(n-1),aa(d[_aa],c_a))end end,drawTextBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -bd(a_a,b_a+ (n-1),aa(_aa,c_a))end end,writeText=function(a_a,b_a,c_a,d_a,_aa) -if(c_a~=nil)then -bd(a_a,b_a,c_a)if(d_a~=nil)and(d_a~=false)then -cd(a_a,b_a,aa(d[d_a],c_a:len()))end;if(_aa~=nil)and(_aa~=false)then -dd(a_a,b_a,aa(d[_aa],c_a:len()))end end end,update=function() -local a_a,b_a=ca.getCursorPos()local c_a=false -if(ca.getCursorBlink~=nil)then c_a=ca.getCursorBlink()end;ca.setCursorBlink(false)if(da~=nil)then -ca.setCursorBlink(false)end -for n=1,ab do ca.setCursorPos(1,n) -ca.blit(bb[n],db[n],cb[n])if(da~=nil)then da.setCursorPos(1,n) -da.blit(bb[n],db[n],cb[n])end end;ca.setBackgroundColor(colors.black) -ca.setCursorBlink(c_a)ca.setCursorPos(a_a,b_a) -if(da~=nil)then -da.setBackgroundColor(colors.black)da.setCursorBlink(c_a)da.setCursorPos(a_a,b_a)end end,setTerm=function(a_a) -ca=a_a end}return __a end -end; -project['libraries']['basaltEvent'] = function(...) -return -function()local a={}local b={} -local c={registerEvent=function(d,_a,aa)if(a[_a]==nil)then a[_a]={}b[_a]=1 end -a[_a][b[_a] ]=aa;b[_a]=b[_a]+1;return b[_a]-1 end,removeEvent=function(d,_a,aa)a[_a][aa[_a] ]= -nil end,sendEvent=function(d,_a,...)local aa -if(a[_a]~=nil)then for ba,ca in pairs(a[_a])do local da=ca(...)if(da== -false)then aa=da end end end;return aa end}c.__index=c;return c end -end; -project['libraries']['basaltLogs'] = function(...)local _a=""local aa="basaltLog.txt"local ba="Debug" -fs.delete(_a~=""and _a.."/"..aa or aa) -local ca={__call=function(da,_b,ab)if(_b==nil)then return end -local bb=_a~=""and _a.."/"..aa or aa -local cb=fs.open(bb,fs.exists(bb)and"a"or"w") -cb.writeLine("[Basalt][".. (ab and ab or ba).."]: "..tostring(_b))cb.close()end}return setmetatable({},ca) -end; -project['libraries']['bigfont'] = function(...)local ba=require("tHex") -local ca={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{"000110000110110000110010101000000010000000100101","000000110110000000000010101000000010000000100101","000000000000000000000000000000000000000000000000","100010110100000010000110110000010100000100000110","000000110000000010110110000110000000000000110000","000000000000000000000000000000000000000000000000","000000110110000010000000100000100000000000000010","000000000110110100010000000010000000000000000100","000000000000000000000000000000000000000000000000","010000000000100110000000000000000000000110010000","000000000000000000000000000010000000010110000000","000000000000000000000000000000000000000000000000","011110110000000100100010110000000100000000000000","000000000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110000110110000000000000000000010100100010000000","000010000000000000110110000000000100010010000000","000000000000000000000000000000000000000000000000","010110010110100110110110010000000100000110110110","000000000000000000000110000000000110000000000000","000000000000000000000000000000000000000000000000","010100010110110000000000000000110000000010000000","110110000000000000110000110110100000000010000000","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","100100100100100100100100100100100100100100100100","000000110100110110000010000011110000000000011000","000000000100000000000010000011000110000000001000","000000000000000000000000000000000000000000000000","010000100100000000000000000100000000010010110000","000000000000000000000000000000110110110110110000","000000000000000000000000000000000000000000000000","110110110110110110000000110110110110110110110110","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","000000000000110110000110010000000000000000010010","000010000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110110110110000000000000","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110000000000000000010000","000000000000000000000000100000000000000110000110","000000000000000000000000000000000000000000000000"}}local da={}local _b={} -do local cb=0;local db=#ca[1]local _c=#ca[1][1] -for i=1,db,3 do -for j=1,_c,3 do -local ac=string.char(cb)local bc={}bc[1]=ca[1][i]:sub(j,j+2) -bc[2]=ca[1][i+1]:sub(j,j+2)bc[3]=ca[1][i+2]:sub(j,j+2)local cc={}cc[1]=ca[2][i]:sub(j, -j+2)cc[2]=ca[2][i+1]:sub(j,j+2)cc[3]=ca[2][ -i+2]:sub(j,j+2)_b[ac]={bc,cc}cb=cb+1 end end;da[1]=_b end -local function ab(cb,db)local _c={["0"]="1",["1"]="0"}if cb<=#da then return true end -for f=#da+1,cb do local ac={}local bc=da[ -f-1] -for char=0,255 do local cc=string.char(char)local dc={}local _d={} -local ad=bc[cc][1]local bd=bc[cc][2] -for i=1,#ad do local cd,dd,__a,a_a,b_a,c_a={},{},{},{},{},{} -for j=1,#ad[1]do -local d_a=_b[ad[i]:sub(j,j)][1]table.insert(cd,d_a[1])table.insert(dd,d_a[2]) -table.insert(__a,d_a[3])local _aa=_b[ad[i]:sub(j,j)][2] -if -bd[i]:sub(j,j)=="1"then -table.insert(a_a,(_aa[1]:gsub("[01]",_c))) -table.insert(b_a,(_aa[2]:gsub("[01]",_c))) -table.insert(c_a,(_aa[3]:gsub("[01]",_c)))else table.insert(a_a,_aa[1]) -table.insert(b_a,_aa[2])table.insert(c_a,_aa[3])end end;table.insert(dc,table.concat(cd)) -table.insert(dc,table.concat(dd))table.insert(dc,table.concat(__a)) -table.insert(_d,table.concat(a_a))table.insert(_d,table.concat(b_a)) -table.insert(_d,table.concat(c_a))end;ac[cc]={dc,_d}if db then db="Font"..f.."Yeld"..char -os.queueEvent(db)os.pullEvent(db)end end;da[f]=ac end;return true end -local function bb(cb,db,_c,ac,bc) -if not type(db)=="string"then error("Not a String",3)end -local cc=type(_c)=="string"and _c:sub(1,1)or ba[_c]or -error("Wrong Front Color",3) -local dc=type(ac)=="string"and ac:sub(1,1)or ba[ac]or -error("Wrong Back Color",3)if(da[cb]==nil)then ab(3,false)end;local _d=da[cb]or -error("Wrong font size selected",3)if db==""then -return{{""},{""},{""}}end;local ad={} -for c_a in db:gmatch('.')do table.insert(ad,c_a)end;local bd={}local cd=#_d[ad[1] ][1] -for nLine=1,cd do local c_a={} -for i=1,#ad do c_a[i]=_d[ad[i] ]and -_d[ad[i] ][1][nLine]or""end;bd[nLine]=table.concat(c_a)end;local dd={}local __a={}local a_a={["0"]=cc,["1"]=dc}local b_a={["0"]=dc,["1"]=cc} -for nLine=1,cd do -local c_a={}local d_a={} -for i=1,#ad do -local _aa=_d[ad[i] ]and _d[ad[i] ][2][nLine]or"" -c_a[i]=_aa:gsub("[01]", -bc and{["0"]=_c:sub(i,i),["1"]=ac:sub(i,i)}or a_a) -d_a[i]=_aa:gsub("[01]", -bc and{["0"]=ac:sub(i,i),["1"]=_c:sub(i,i)}or b_a)end;dd[nLine]=table.concat(c_a) -__a[nLine]=table.concat(d_a)end;return{bd,dd,__a}end;return bb -end; -project['libraries']['geometricPoints'] = function(...) -local function _a(da,_b,ab,bb)local cb={}if da==ab and _b==bb then return{x=da,y=ab}end -local db=math.min(da,ab)local _c,ac,bc;if db==da then ac,_c,bc=_b,ab,bb else ac,_c,bc=bb,da,_b end;local cc,dc=_c-db, -bc-ac -if cc>math.abs(dc)then local _d=ac;local ad=dc/cc;for x=db,_c do table.insert(cb,{x=x,y=math.floor( -_d+0.5)}) -_d=_d+ad end else local _d,ad=db,cc/dc -if bc>=ac then for y=ac,bc do table.insert(cb,{x=math.floor( -_d+0.5),y=y})_d=_d+ -ad end else for y=ac,bc,-1 do -table.insert(cb,{x=math.floor(_d+0.5),y=y})_d=_d-ad end end end;return cb end -local function aa(da,_b,ab)local bb={}for x=-ab,ab+1 do -local cb=math.floor(math.sqrt(ab*ab-x*x)) -for y=-cb,cb+1 do table.insert(bb,{x=da+x,y=_b+y})end end;return bb end -local function ba(da,_b,ab,bb,cb)local db,_c=math.ceil(math.floor(ab-0.5)/2),math.ceil( -math.floor(bb-0.5)/2)local ac,bc=0,_c -local cc=( ( -_c*_c)- (db*db*_c)+ (0.25 *db*db))local dc=2 *_c^2 *ac;local _d=2 *db^2 *bc;local ad={} -while dc<_d do -table.insert(ad,{x=ac+da,y=bc+_b})table.insert(ad,{x=-ac+da,y=bc+_b})table.insert(ad,{x=ac+ -da,y=-bc+_b}) -table.insert(ad,{x=-ac+da,y=-bc+_b})if cb then -for y=-bc+_b+1,bc+_b-1 do table.insert(ad,{x=ac+da,y=y})table.insert(ad,{x= --ac+da,y=y})end end -if cc<0 then ac=ac+1 -dc=dc+2 *_c^2;cc=cc+dc+_c^2 else ac,bc=ac+1,bc-1;dc=dc+2 *_c^2 -_d=_d-2 *db^2;cc=cc+dc-_d+_c^2 end end -local bd=( ( (_c*_c)* ( (ac+0.5)* (ac+0.5)))+ -( (db*db)* ( (bc-1)* (bc-1)))- (db*db*_c*_c)) -while bc>=0 do table.insert(ad,{x=ac+da,y=bc+_b})table.insert(ad,{x=- -ac+da,y=bc+_b}) -table.insert(ad,{x=ac+da,y=-bc+_b})table.insert(ad,{x=-ac+da,y=-bc+_b}) -if cb then for y=-bc+_b, -bc+_b do table.insert(ad,{x=ac+da,y=y}) -table.insert(ad,{x=-ac+da,y=y})end end -if bd>0 then bc=bc-1;_d=_d-2 *db^2;bd=bd+db^2 -_d else bc=bc-1;ac=ac+1;_d=_d-2 * -db^2;dc=dc+2 *_c^2;bd=bd+dc-_d+db^2 end end;return ad end;local function ca(da,_b,ab,bb)return ba(da,_b,ab,ab,bb)end -return -{circle=function(da,_b,ab,bb) -return ca(da,_b,ab,bb)end,rectangle=function(da,_b,ab,bb,cb)local db={} -if(cb)then for y=_b,bb do for x=da,ab do -table.insert(db,{x=x,y=y})end end else for y=_b,bb do -for x=da,ab do if -(x==da)or(x==ab)or(y==_b)or(y==bb)then -table.insert(db,{x=x,y=y})end end end end;return db end,triangle=function(da,_b,ab,bb,cb,db,_c) -local -function ac(dc,_d,ad,bd,cd,dd,__a)local a_a=(dd-_d)/ (__a-ad)local b_a=(dd-bd)/ (__a-cd)local c_a=math.ceil( -ad-0.5) -local d_a=math.ceil(__a-0.5)-1 -for y=c_a,d_a do local _aa=a_a* (y+0.5 -ad)+_d -local aaa=b_a* (y+0.5 -cd)+bd;local baa=math.ceil(_aa-0.5)local caa=math.ceil(aaa-0.5)for x=baa,caa do -table.insert(dc,{x=x,y=y})end end end -local function bc(dc,_d,ad,bd,cd,dd,__a)local a_a=(bd-_d)/ (cd-ad)local b_a=(dd-_d)/ (__a-ad) -local c_a=math.ceil(ad-0.5)local d_a=math.ceil(__a-0.5)-1 -for y=c_a,d_a do -local _aa=a_a* (y+0.5 -ad)+_d;local aaa=b_a* (y+0.5 -ad)+_d -local baa=math.ceil(_aa-0.5)local caa=math.ceil(aaa-0.5)for x=baa,caa do -table.insert(dc,{x=x,y=y})end end end;local cc={} -if(_c)then if bb<_b then da,_b,ab,bb=ab,bb,da,_b end;if db",">") -_a=string.gsub(_a,"\"",""") -_a=string.gsub(_a,"([^%w%&%;%p%\t% ])",function(aa) -return string.format("&#x%X;",string.byte(aa))end)return _a end -function d:FromXmlString(_a) -_a=string.gsub(_a,"&#x([%x]+)%;",function(aa) -return string.char(tonumber(aa,16))end) -_a=string.gsub(_a,"&#([0-9]+)%;",function(aa)return string.char(tonumber(aa,10))end)_a=string.gsub(_a,""","\"") -_a=string.gsub(_a,"'","'")_a=string.gsub(_a,">",">") -_a=string.gsub(_a,"<","<")_a=string.gsub(_a,"&","&")return _a end;function d:ParseArgs(_a,aa) -string.gsub(aa,"(%w+)=([\"'])(.-)%2",function(ba,ca,da) -_a:addProperty(ba,self:FromXmlString(da))end)end -function d:ParseXmlText(_a) -local aa={}local ba=c()table.insert(aa,ba)local ca,da,_b,ab,bb;local cb,db=1,1 -while true do -ca,db,da,_b,ab,bb=string.find(_a,"<(%/?)([%w_:]+)(.-)(%/?)>",cb)if not ca then break end;local ac=string.sub(_a,cb,ca-1) -if not -string.find(ac,"^%s*$")then -local bc=(ba:value()or"")..self:FromXmlString(ac)aa[#aa]:setValue(bc)end -if bb=="/"then local bc=c(_b)self:ParseArgs(bc,ab)ba:addChild(bc)elseif -da==""then local bc=c(_b)self:ParseArgs(bc,ab)table.insert(aa,bc) -ba=bc else local bc=table.remove(aa)ba=aa[#aa]if#aa<1 then -error("XmlParser: nothing to close with ".._b)end;if bc:name()~=_b then -error("XmlParser: trying to close "..bc.name.. -" with ".._b)end;ba:addChild(bc)end;cb=db+1 end;local _c=string.sub(_a,cb)if#aa>1 then -error("XmlParser: unclosed "..aa[#aa]:name())end;return ba end -function d:loadFile(_a,aa)if not aa then aa=system.ResourceDirectory end -local ba=system.pathForFile(_a,aa)local ca,da=io.open(ba,"r") -if ca and not da then local _b=ca:read("*a") -io.close(ca)return self:ParseXmlText(_b),nil else print(da)return nil end end;return d -end; -project['libraries']['process'] = function(...)local d={}local _a={}local aa=0 -function _a:new(ba,ca,...)local da={...} -local _b=setmetatable({path=ba},{__index=self})_b.window=ca;_b.processId=aa -_b.coroutine=coroutine.create(function() -shell.execute(ba,table.unpack(da))end)d[aa]=_b;aa=aa+1;return _b end -function _a:resume(ba,...)term.redirect(self.window) -if(self.filter~=nil)then if -(ba~=self.filter)then return end;self.filter=nil end;local ca,da=coroutine.resume(self.coroutine,ba,...) -self.window=term.current()if ca then self.filter=da else error(da)end end -function _a:isDead() -if(self.coroutine~=nil)then -if -(coroutine.status(self.coroutine)=="dead")then table.remove(d,self.processId)return true end else return true end;return false end -function _a:getStatus()if(self.coroutine~=nil)then -return coroutine.status(self.coroutine)end;return nil end -function _a:start()coroutine.resume(self.coroutine)end;return _a -end; -project['libraries']['tHex'] = function(...) -return -{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"} -end; -project['libraries']['utils'] = function(...) -local b=function(c,d)if d==nil then d="%s"end;local _a={}for aa in string.gmatch(c,"([^"..d.."]+)")do -table.insert(_a,aa)end;return _a end -return -{getTextHorizontalAlign=function(c,d,_a,aa)c=string.sub(c,1,d)local ba=d-string.len(c) -if(_a=="right")then c=string.rep( -aa or" ",ba)..c elseif(_a=="center")then -c=string.rep(aa or" ",math.floor( -ba/2))..c.. -string.rep(aa or" ",math.floor(ba/2)) -c=c.. (string.len(c)baa[x])then table.insert(baa,x,abc)break end else -table.insert(baa,abc)end end;if(#baa<=0)then table.insert(baa,abc)end;aaa[abc]={}end;_bc.parent=caa;if(_bc.init~=nil)then _bc:init()end -table.insert(aaa[abc],_bc)return _bc end -local function bdb(_bc,abc) -for bbc,cbc in pairs(daa)do -for dbc,_cc in pairs(cbc)do -for acc,bcc in pairs(_cc)do -if(bcc==abc)then -table.remove(daa[bbc][dbc],acc)if(_bc.parent~=nil)then if(ad(daa[event])<=0)then -_bc.parent:removeEvent(bbc,_bc)end end end end end end end -local function cdb(_bc)for abc,bbc in pairs(aaa)do -for cbc,dbc in pairs(bbc)do if(dbc==_bc)then table.remove(aaa[abc],cbc) -bdb(caa,_bc)return true end end end -return false end;local function ddb(_bc,abc,bbc) -for cbc,dbc in pairs(daa[abc])do for _cc,acc in pairs(dbc)do -if(acc:getName()==bbc)then return acc end end end end -local function __c(_bc,abc,bbc) -local cbc=bbc:getZIndex()if(daa[abc]==nil)then daa[abc]={}end;if(_ba[abc]==nil)then -_ba[abc]={}end -if(ddb(_bc,abc,bbc.name)~=nil)then return nil end -if(_bc.parent~=nil)then _bc.parent:addEvent(abc,_bc)end;cab[abc]=true -if(daa[abc][cbc]==nil)then -for x=1,#_ba[abc]+1 do -if -(_ba[abc][x]~=nil)then if(cbc==_ba[abc][x])then break end;if(cbc>_ba[abc][x])then -table.insert(_ba[abc],x,cbc)break end else -table.insert(_ba[abc],cbc)end end -if(#_ba[abc]<=0)then table.insert(_ba[abc],cbc)end;daa[abc][cbc]={}end;table.insert(daa[abc][cbc],bbc)return bbc end -local function a_c(_bc,abc,bbc) -if(daa[abc]~=nil)then -for cbc,dbc in pairs(daa[abc])do -for _cc,acc in pairs(dbc)do -if(acc==bbc)then -table.remove(daa[abc][cbc],_cc)if(#daa[abc][cbc]<=0)then daa[abc][cbc]=nil -if(_bc.parent~=nil)then if( -ad(daa[abc])<=0)then cab[abc]=false -_bc.parent:removeEvent(abc,_bc)end end end;return -true end end end end;return false end -local function b_c(_bc)local abc,bbc=pcall(load("return ".._bc)) -if not(abc)then error(_bc.. -" is not a valid dynamic code")end;return load("return ".._bc)()end -local function c_c(_bc,abc,bbc)for cbc,dbc in pairs(cba)do -if(dbc[2]==bbc)and(dbc[4]==abc)then return dbc end end;dba=dba+1 -cba[dba]={0,bbc,{},abc,dba}return cba[dba]end -local function d_c(_bc,abc)local bbc={}local cbc={}for dbc in abc:gmatch("%a+%.x")do local _cc=dbc:gsub("%.x","") -if -(_cc~="self")and(_cc~="parent")then table.insert(bbc,_cc)end end -for dbc in -abc:gmatch("%w+%.y")do local _cc=dbc:gsub("%.y","")if(_cc~="self")and(_cc~="parent")then -table.insert(bbc,_cc)end end;for dbc in abc:gmatch("%a+%.w")do local _cc=dbc:gsub("%.w","") -if(_cc~="self")and -(_cc~="parent")then table.insert(bbc,_cc)end end -for dbc in -abc:gmatch("%a+%.h")do local _cc=dbc:gsub("%.h","")if(_cc~="self")and(_cc~="parent")then -table.insert(bbc,_cc)end end -for dbc,_cc in pairs(bbc)do cbc[_cc]=dcb(_cc)if(cbc[_cc]==nil)then -error("Dynamic Values - unable to find object ".._cc)end end;cbc["self"]=_bc;cbc["parent"]=_bc:getParent()return cbc end -local function _ac(_bc,abc)local bbc=_bc;for cbc in _bc:gmatch("%w+%.x")do -bbc=bbc:gsub(cbc,abc[cbc:gsub("%.x","")]:getX())end;for cbc in _bc:gmatch("%w+%.y")do -bbc=bbc:gsub(cbc,abc[cbc:gsub("%.y","")]:getY())end;for cbc in _bc:gmatch("%w+%.w")do -bbc=bbc:gsub(cbc,abc[cbc:gsub("%.w","")]:getWidth())end;for cbc in _bc:gmatch("%w+%.h")do -bbc=bbc:gsub(cbc,abc[cbc:gsub("%.h","")]:getHeight())end;return bbc end -local function aac(_bc) -if(#cba>0)then -for n=1,dba do -if(cba[n]~=nil)then local abc;if(#cba[n][3]<=0)then -cba[n][3]=d_c(cba[n][4],cba[n][2])end -abc=_ac(cba[n][2],cba[n][3])cba[n][1]=b_c(abc)if(cba[n][4]:getType()=="Frame")then -cba[n][4]:recalculateDynamicValues()end end end -for abc,bbc in pairs(baa)do if(aaa[bbc]~=nil)then -for cbc,dbc in pairs(aaa[bbc])do if(dbc.eventHandler~=nil)then -dbc:eventHandler("dynamicValueEvent",_bc)end end end end end end;local function bac(_bc)return cba[_bc][1]end -local function cac(_bc) -for abc,bbc in pairs(aaa)do -for cbc,dbc in pairs(bbc)do -if -(dbc.getHeight~=nil)and(dbc.getY~=nil)then -local _cc,acc=dbc:getHeight(),dbc:getY()if(_cc+acc-_bc:getHeight()>bda)then -bda=dd(_cc+acc-_bc:getHeight(),0)end end end end end;local function dac(_bc) -if(d_b~=c_b)then if(d_b~=nil)then d_b:loseFocusHandler()end;if -(c_b~=nil)then c_b:getFocusHandler()end;d_b=c_b end end -caa={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",addEvent=__c,removeEvent=a_c,removeEvents=bdb,getEvent=ddb,newDynamicValue=c_c,recalculateDynamicValues=aac,getDynamicValue=bac,getType=function(_bc)return -_aa end,setFocusedObject=function(_bc,abc)c_b=abc;return _bc end,getVariable=function(_bc,abc) -return c_a.getVariable(abc)end,setSize=function(_bc,abc,bbc,cbc)d_a.setSize(_bc,abc,bbc,cbc)if -(_bc.parent==nil)then dab=_c(_ca)end -for dbc,_cc in pairs(baa)do -if(aaa[_cc]~=nil)then for acc,bcc in pairs(aaa[_cc])do -if( -bcc.eventHandler~=nil)then bcc:eventHandler("basalt_resize",bcc,_bc)end end end end;_bc:recalculateDynamicValues()_ab=false;return _bc end,setTheme=function(_bc,abc,bbc) -if( -type(abc)=="table")then bba=abc elseif(type(abc)=="string")then bba[abc]=bbc end;_bc:updateDraw()return _bc end,getTheme=function(_bc,abc) -return -bba[abc]or(_bc.parent~=nil and _bc.parent:getTheme(abc)or -c_a.getTheme(abc))end,setPosition=function(_bc,abc,bbc,cbc) -d_a.setPosition(_bc,abc,bbc,cbc) -for dbc,_cc in pairs(baa)do if(aaa[_cc]~=nil)then -for acc,bcc in pairs(aaa[_cc])do if(bcc.eventHandler~=nil)then -bcc:eventHandler("basalt_reposition",bcc,_bc)end end end end;_bc:recalculateDynamicValues()return _bc end,getBasaltInstance=function(_bc)return -c_a end,setOffset=function(_bc,abc,bbc) -dbb=abc~=nil and -math.floor(abc<0 and math.abs(abc)or-abc)or dbb -_cb=bbc~=nil and -math.floor(bbc<0 and math.abs(bbc)or-bbc)or _cb;_bc:updateDraw()return _bc end,getOffsetInternal=function(_bc)return -dbb,_cb end,getOffset=function(_bc) -return dbb<0 and math.abs(dbb)or-dbb, -_cb<0 and math.abs(_cb)or-_cb end,removeFocusedObject=function(_bc)c_b=nil;return _bc end,getFocusedObject=function(_bc) -return d_b end,setCursor=function(_bc,abc,bbc,cbc,dbc) -if(_bc.parent~=nil)then local _cc,acc=_bc:getAnchorPosition() -_bc.parent:setCursor( -abc or false,(bbc or 0)+_cc-1,(cbc or 0)+acc-1,dbc or cbb)else -local _cc,acc=_bc:getAbsolutePosition(_bc:getAnchorPosition(_bc:getX(),_bc:getY(),true))_bb=abc or false;if(bbc~=nil)then abb=_cc+bbc-1 end;if(cbc~=nil)then bbb=acc+ -cbc-1 end;cbb=dbc or cbb;if(_bb)then -_ca.setTextColor(cbb)_ca.setCursorPos(abb,bbb)_ca.setCursorBlink(_bb)else -_ca.setCursorBlink(false)end end;return _bc end,setMovable=function(_bc,abc) -if( -_bc.parent~=nil)then a_b=abc or not a_b -_bc.parent:addEvent("mouse_click",_bc)cab["mouse_click"]=true -_bc.parent:addEvent("mouse_up",_bc)cab["mouse_up"]=true -_bc.parent:addEvent("mouse_drag",_bc)cab["mouse_drag"]=true end;return _bc end,setScrollable=function(_bc,abc)ada=( -abc or abc==nil)and true or false -if( -_bc.parent~=nil)then _bc.parent:addEvent("mouse_scroll",_bc)end;cab["mouse_scroll"]=true;return _bc end,setScrollAmount=function(_bc,abc)bda= -abc or bda;aab=false;return _bc end,getScrollAmount=function(_bc)return -aab and bda or cac(_bc)end,show=function(_bc)d_a.show(_bc) -if(_bc.parent==nil)then -c_a.setActiveFrame(_bc)if(bca)then c_a.setMonitorFrame(aca,_bc)else -c_a.setMainFrame(_bc)end end;return _bc end,hide=function(_bc) -d_a.hide(_bc) -if(_bc.parent==nil)then if(activeFrame==_bc)then activeFrame=nil end;if(bca)then -if( -c_a.getMonitorFrame(aca)==_bc)then c_a.setActiveFrame(nil)end else -if(c_a.getMainFrame()==_bc)then c_a.setMainFrame(nil)end end end;return _bc end,addLayout=function(_bc,abc) -if( -abc~=nil)then -if(fs.exists(abc))then local bbc=fs.open(abc,"r") -local cbc=bc:ParseXmlText(bbc.readAll())bbc.close()acb={}_bc:setValuesByXMLData(cbc)end end;return _bc end,getLastLayout=function(_bc)return -acb end,addLayoutFromString=function(_bc,abc)if(abc~=nil)then local bbc=bc:ParseXmlText(abc) -_bc:setValuesByXMLData(bbc)end;return _bc end,setValuesByXMLData=function(_bc,abc) -d_a.setValuesByXMLData(_bc,abc)if(_d("movable",abc)~=nil)then if(_d("movable",abc))then -_bc:setMovable(true)end end;if( -_d("scrollable",abc)~=nil)then -if(_d("scrollable",abc))then _bc:setScrollable(true)end end;if -(_d("monitor",abc)~=nil)then -_bc:setMonitor(_d("monitor",abc)):show()end;if(_d("mirror",abc)~=nil)then -_bc:setMirror(_d("mirror",abc))end -if(_d("bar",abc)~=nil)then if(_d("bar",abc))then -_bc:showBar(true)else _bc:showBar(false)end end -if(_d("barText",abc)~=nil)then _bc.barText=_d("barText",abc)end;if(_d("barBG",abc)~=nil)then -_bc.barBackground=colors[_d("barBG",abc)]end;if(_d("barFG",abc)~=nil)then -_bc.barTextcolor=colors[_d("barFG",abc)]end;if(_d("barAlign",abc)~=nil)then -_bc.barTextAlign=_d("barAlign",abc)end;if(_d("layout",abc)~=nil)then -_bc:addLayout(_d("layout",abc))end;if(_d("xOffset",abc)~=nil)then -_bc:setOffset(_d("xOffset",abc),_cb)end;if(_d("yOffset",abc)~=nil)then -_bc:setOffset(_cb,_d("yOffset",abc))end;if(_d("scrollAmount",abc)~=nil)then -_bc:setScrollAmount(_d("scrollAmount",abc))end;local bbc=abc:children() -for cbc,dbc in -pairs(bbc)do if(dbc.___name~="animation")then -local _cc=dbc.___name:gsub("^%l",string.upper) -if(db[_cc]~=nil)then ccb(dbc,_bc["add".._cc],_bc)end end end;ccb(abc["frame"],_bc.addFrame,_bc) -ccb(abc["animation"],_bc.addAnimation,_bc)return _bc end,showBar=function(_bc,abc)_bc.barActive= -abc or not _bc.barActive;_bc:updateDraw() -return _bc end,setBar=function(_bc,abc,bbc,cbc)_bc.barText=abc or""_bc.barBackground= -bbc or _bc.barBackground -_bc.barTextcolor=cbc or _bc.barTextcolor;_bc:updateDraw()return _bc end,setBarTextAlign=function(_bc,abc)_bc.barTextAlign= -abc or"left"_bc:updateDraw()return _bc end,setMirror=function(_bc,abc)if( -_bc.parent~=nil)then -error("Frame has to be a base frame in order to attach a mirror.")end;__b=abc;if(mirror~=nil)then -dab.setMirror(mirror)end;cda=true;return _bc end,removeMirror=function(_bc)mirror= -nil;cda=false;dab.setMirror(nil)return _bc end,setMonitor=function(_bc,abc) -if( -abc~=nil)and(abc~=false)then -if -(peripheral.getType(abc)=="monitor")then _ca=peripheral.wrap(abc)cca=true end -if(_bc.parent~=nil)then _bc.parent:removeObject(_bc)end;bca=true;c_a.setMonitorFrame(abc,_bc)else _ca=parentTerminal -bca=false;if(c_a.getMonitorFrame(aca)==_bc)then -c_a.setMonitorFrame(aca,nil)end end;dab=_c(_ca)_bc:setSize(_ca.getSize())_ab=true -aca=abc or nil;_bc:updateDraw()return _bc end,loseFocusHandler=function(_bc) -d_a.loseFocusHandler(_bc)if(d_b~=nil)then d_b:loseFocusHandler()d_b=nil end end,getFocusHandler=function(_bc) -d_a.getFocusHandler(_bc) -if(_bc.parent~=nil)then -if(a_b)then _bc.parent:removeEvents(_bc) -_bc.parent:removeObject(_bc)_bc.parent:addObject(_bc)for abc,bbc in pairs(cab)do if(bbc)then -_bc.parent:addEvent(abc,_bc)end end -_bc:updateDraw()end end;if(d_b~=nil)then d_b:getFocusHandler()end end,eventHandler=function(_bc,abc,bbc,cbc,dbc,_cc) -d_a.eventHandler(_bc,abc,bbc,cbc,dbc,_cc) -if(daa["other_event"]~=nil)then -for acc,bcc in ipairs(_ba["other_event"])do -if( -daa["other_event"][bcc]~=nil)then for ccc,dcc in dc(daa["other_event"][bcc])do -if -(dcc.eventHandler~=nil)then if(dcc:eventHandler(abc,bbc,cbc,dbc,_cc))then return true end end end end end end;if(_ab)and not(bca)then -if(_bc.parent==nil)then if(abc=="term_resize")then -_bc:setSize(_ca.getSize())_ab=true end end end -if(bca)then -if(_ab)then if -(abc=="monitor_resize")and(bbc==aca)then _bc:setSize(_ca.getSize()) -_ab=true;_bc:updateDraw()end end -if(abc=="peripheral")and(bbc==aca)then if -(peripheral.getType(aca)=="monitor")then cca=true;_ca=peripheral.wrap(aca)dab=_c(_ca) -_bc:updateDraw()end end -if(abc=="peripheral_detach")and(bbc==aca)then cca=false end end -if(cda)then if(peripheral.getType(__b)=="monitor")then dda=true -dab.setMirror(peripheral.wrap(__b))end;if(abc=="peripheral_detach")and -(bbc==__b)then cca=false end -if -(abc=="monitor_touch")and(__b==bbc)then _bc:mouseHandler(1,cbc,dbc,true)end end -if(abc=="terminate")and(_bc.parent==nil)then c_a.stop()end end,mouseHandler=function(_bc,abc,bbc,cbc) -if -(d_a.mouseHandler(_bc,abc,bbc,cbc))then -if(daa["mouse_click"]~=nil)then _bc:setCursor(false) -for dbc,_cc in -ipairs(_ba["mouse_click"])do -if(daa["mouse_click"][_cc]~=nil)then -for acc,bcc in -dc(daa["mouse_click"][_cc])do if(bcc.mouseHandler~=nil)then -if(bcc:mouseHandler(abc,bbc,cbc))then dac(_bc)return true end end end end end end -if(a_b)then -local dbc,_cc=_bc:getAbsolutePosition(_bc:getAnchorPosition())if -(bbc>=dbc)and(bbc<=dbc+_bc:getWidth()-1)and(cbc==_cc)then b_b=true;dca=dbc-bbc -_da=yOff and 1 or 0 end end;_bc:removeFocusedObject()dac(_bc)return true end;return false end,mouseUpHandler=function(_bc,abc,bbc,cbc)if -(b_b)then b_b=false end -if(d_a.mouseUpHandler(_bc,abc,bbc,cbc))then -if -(daa["mouse_up"]~=nil)then -for dbc,_cc in ipairs(_ba["mouse_up"])do -if(daa["mouse_up"][_cc]~=nil)then -for acc,bcc in -dc(daa["mouse_up"][_cc])do if(bcc.mouseUpHandler~=nil)then -if(bcc:mouseUpHandler(abc,bbc,cbc))then dac(_bc)return true end end end end end end;dac(_bc)return true end;return false end,scrollHandler=function(_bc,abc,bbc,cbc) -if -(d_a.scrollHandler(_bc,abc,bbc,cbc))then -if(daa["mouse_scroll"]~=nil)then -for _cc,acc in pairs(_ba["mouse_scroll"])do -if( -daa["mouse_scroll"][acc]~=nil)then -for bcc,ccc in dc(daa["mouse_scroll"][acc])do if(ccc.scrollHandler~= -nil)then -if(ccc:scrollHandler(abc,bbc,cbc))then dac(_bc)return true end end end end end end;local dbc=_cb -if(ada)then cac(_bc)if(abc>0)or(abc<0)then -_cb=dd(cd(_cb-abc,0),-bda)_bc:updateDraw()end end;_bc:removeFocusedObject()dac(_bc) -if(_cb==dbc)then return false end;return true end;return false end,dragHandler=function(_bc,abc,bbc,cbc) -if -(b_b)then local dbc,_cc=_bc.parent:getOffsetInternal()dbc=dbc<0 and -math.abs(dbc)or-dbc;_cc= -_cc<0 and math.abs(_cc)or-_cc;local acc=1;local bcc=1;if(_bc.parent~=nil)then -acc,bcc=_bc.parent:getAbsolutePosition(_bc.parent:getAnchorPosition())end -_bc:setPosition( -bbc+dca- (acc-1)+dbc,cbc+_da- (bcc-1)+_cc)_bc:updateDraw()return true end -if(daa["mouse_drag"]~=nil)then -for dbc,_cc in ipairs(_ba["mouse_drag"])do -if( -daa["mouse_drag"][_cc]~=nil)then -for acc,bcc in dc(daa["mouse_drag"][_cc])do if -(bcc.dragHandler~=nil)then -if(bcc:dragHandler(abc,bbc,cbc))then dac(_bc)return true end end end end end end;dac(_bc)d_a.dragHandler(_bc,abc,bbc,cbc)return false end,keyHandler=function(_bc,abc,bbc) -if -(_bc:isFocused())or(_bc.parent==nil)then -local cbc=_bc:getEventSystem():sendEvent("key",_bc,"key",abc)if(cbc==false)then return false end -if(daa["key"]~=nil)then -for dbc,_cc in pairs(_ba["key"])do -if( -daa["key"][_cc]~=nil)then -for acc,bcc in dc(daa["key"][_cc])do if(bcc.keyHandler~=nil)then if -(bcc:keyHandler(abc,bbc))then return true end end end end end end end;return false end,keyUpHandler=function(_bc,abc) -if -(_bc:isFocused())or(_bc.parent==nil)then -local bbc=_bc:getEventSystem():sendEvent("key_up",_bc,"key_up",abc)if(bbc==false)then return false end -if(daa["key_up"]~=nil)then -for cbc,dbc in -pairs(_ba["key_up"])do -if(daa["key_up"][dbc]~=nil)then for _cc,acc in dc(daa["key_up"][dbc])do -if( -acc.keyUpHandler~=nil)then if(acc:keyUpHandler(abc))then return true end end end end end end end;return false end,charHandler=function(_bc,abc) -if -(_bc:isFocused())or(_bc.parent==nil)then -local bbc=_bc:getEventSystem():sendEvent("char",_bc,"char",abc)if(bbc==false)then return false end -if(daa["char"]~=nil)then -for cbc,dbc in -pairs(_ba["char"])do -if(daa["char"][dbc]~=nil)then for _cc,acc in dc(daa["char"][dbc])do -if -(acc.charHandler~=nil)then if(acc:charHandler(abc))then return true end end end end end end end;return false end,setText=function(_bc,abc,bbc,cbc) -local dbc,_cc=_bc:getAnchorPosition() -if(bbc>=1)and(bbc<=_bc:getHeight())then -if(_bc.parent~=nil)then -_bc.parent:setText(dd( -abc+ (dbc-1),dbc),_cc+bbc-1,bd(cbc,dd(1 -abc+1,1),dd( -_bc:getWidth()-abc+1,1)))else -dab.setText(dd(abc+ (dbc-1),dbc),_cc+bbc-1,bd(cbc,dd(1 -abc+1,1),dd( -_bc:getWidth()-abc+1,1)))end end end,setBG=function(_bc,abc,bbc,cbc) -local dbc,_cc=_bc:getAnchorPosition() -if(bbc>=1)and(bbc<=_bc:getHeight())then -if(_bc.parent~=nil)then -_bc.parent:setBG(dd( -abc+ (dbc-1),dbc),_cc+bbc-1,bd(cbc,dd(1 -abc+1,1),dd( -_bc:getWidth()-abc+1,1)))else -dab.setBG(dd(abc+ (dbc-1),dbc),_cc+bbc-1,bd(cbc,dd(1 -abc+1,1),dd( -_bc:getWidth()-abc+1,1)))end end end,setFG=function(_bc,abc,bbc,cbc) -local dbc,_cc=_bc:getAnchorPosition() -if(bbc>=1)and(bbc<=_bc:getHeight())then -if(_bc.parent~=nil)then -_bc.parent:setFG(dd( -abc+ (dbc-1),dbc),_cc+bbc-1,bd(cbc,dd(1 -abc+1,1),dd( -_bc:getWidth()-abc+1,1)))else -dab.setFG(dd(abc+ (dbc-1),dbc),_cc+bbc-1,bd(cbc,dd(1 -abc+1,1),dd( -_bc:getWidth()-abc+1,1)))end end end,writeText=function(_bc,abc,bbc,cbc,dbc,_cc) -local acc,bcc=_bc:getAnchorPosition() -if(bbc>=1)and(bbc<=_bc:getHeight())then -if(_bc.parent~=nil)then -_bc.parent:writeText(dd( -abc+ (acc-1),acc),bcc+bbc-1,bd(cbc,dd(1 -abc+1,1), -_bc:getWidth()-abc+1),dbc,_cc)else -dab.writeText(dd(abc+ (acc-1),acc),bcc+bbc-1,bd(cbc,dd(1 -abc+1,1),dd( -_bc:getWidth()-abc+1,1)),dbc,_cc)end end end,drawBackgroundBox=function(_bc,abc,bbc,cbc,dbc,_cc) -local acc,bcc=_bc:getAnchorPosition() -dbc=(bbc<1 and( -dbc+bbc>_bc:getHeight()and _bc:getHeight()or dbc+bbc-1)or( -dbc+ -bbc>_bc:getHeight()and _bc:getHeight()-bbc+1 or dbc)) -cbc=(abc<1 and(cbc+abc>_bc:getWidth()and _bc:getWidth()or cbc+ -abc-1)or( - -cbc+abc>_bc:getWidth()and _bc:getWidth()-abc+1 or cbc)) -if(_bc.parent~=nil)then -_bc.parent:drawBackgroundBox(dd(abc+ (acc-1),acc),dd(bbc+ (bcc-1),bcc),cbc,dbc,_cc)else -dab.drawBackgroundBox(dd(abc+ (acc-1),acc),dd(bbc+ (bcc-1),bcc),cbc,dbc,_cc)end end,drawTextBox=function(_bc,abc,bbc,cbc,dbc,_cc) -local acc,bcc=_bc:getAnchorPosition() -dbc=(bbc<1 and( -dbc+bbc>_bc:getHeight()and _bc:getHeight()or dbc+bbc-1)or( -dbc+ -bbc>_bc:getHeight()and _bc:getHeight()-bbc+1 or dbc)) -cbc=(abc<1 and(cbc+abc>_bc:getWidth()and _bc:getWidth()or cbc+ -abc-1)or( - -cbc+abc>_bc:getWidth()and _bc:getWidth()-abc+1 or cbc)) -if(_bc.parent~=nil)then -_bc.parent:drawTextBox(dd(abc+ (acc-1),acc),dd(bbc+ (bcc-1),bcc),cbc,dbc,bd(_cc,1,1))else -dab.drawTextBox(dd(abc+ (acc-1),acc),dd(bbc+ (bcc-1),bcc),cbc,dbc,bd(_cc,1,1))end end,drawForegroundBox=function(_bc,abc,bbc,cbc,dbc,_cc) -local acc,bcc=_bc:getAnchorPosition() -dbc=(bbc<1 and( -dbc+bbc>_bc:getHeight()and _bc:getHeight()or dbc+bbc-1)or( -dbc+ -bbc>_bc:getHeight()and _bc:getHeight()-bbc+1 or dbc)) -cbc=(abc<1 and(cbc+abc>_bc:getWidth()and _bc:getWidth()or cbc+ -abc-1)or( - -cbc+abc>_bc:getWidth()and _bc:getWidth()-abc+1 or cbc)) -if(_bc.parent~=nil)then -_bc.parent:drawForegroundBox(dd(abc+ (acc-1),acc),dd(bbc+ (bcc-1),bcc),cbc,dbc,_cc)else -dab.drawForegroundBox(dd(abc+ (acc-1),acc),dd(bbc+ (bcc-1),bcc),cbc,dbc,_cc)end end,draw=function(_bc,abc)if -(bca)and not(cca)then return false end -if(_bc.parent==nil)then if(_bc:getDraw()== -false)then return false end end -if(d_a.draw(_bc))then -local bbc,cbc=_bc:getAbsolutePosition(_bc:getAnchorPosition())local dbc,_cc=_bc:getAnchorPosition()local acc,bcc=_bc:getSize() -if( -_bc.parent==nil)then -if(_bc.bgColor~=false)then -dab.drawBackgroundBox(dbc,_cc,acc,bcc,_bc.bgColor)dab.drawTextBox(dbc,_cc,acc,bcc," ")end;if(_bc.fgColor~=false)then -dab.drawForegroundBox(dbc,_cc,acc,bcc,_bc.fgColor)end end -if(_bc.barActive)then -if(_bc.parent~=nil)then -_bc.parent:writeText(dbc,_cc,ac.getTextHorizontalAlign(_bc.barText,acc,_bc.barTextAlign),_bc.barBackground,_bc.barTextcolor)else -dab.writeText(dbc,_cc,ac.getTextHorizontalAlign(_bc.barText,acc,_bc.barTextAlign),_bc.barBackground,_bc.barTextcolor)end -if(_bc:getBorder("left"))then -if(_bc.parent~=nil)then -_bc.parent:drawBackgroundBox(dbc-1,_cc,1,1,_bc.barBackground)if(_bc.bgColor~=false)then -_bc.parent:drawBackgroundBox(dbc-1,_cc+1,1,bcc-1,_bc.bgColor)end end end -if(_bc:getBorder("top"))then if(_bc.parent~=nil)then -_bc.parent:drawBackgroundBox(dbc-1,_cc-1,acc+1,1,_bc.barBackground)end end end;for ccc,dcc in dc(baa)do -if(aaa[dcc]~=nil)then for _dc,adc in pairs(aaa[dcc])do -if(adc.draw~=nil)then adc:draw()end end end end end end,updateTerm=function(_bc)if -(bca)and not(cca)then return false end;dab.update()end,addObject=function(_bc,abc)return -adb(abc)end,removeObject=function(_bc,abc)return cdb(abc)end,getObject=function(_bc,abc)return dcb(abc)end,getDeepObject=function(_bc,abc)return -_db(abc)end,addFrame=function(_bc,abc) -local bbc=c_a.newFrame(abc or cc(),_bc,nil,c_a)return adb(bbc)end,init=function(_bc) -if not(bab)then -if(a_a~=nil)then -d_a.width,d_a.height=a_a:getSize() -_bc:setBackground(a_a:getTheme("FrameBG")) -_bc:setForeground(a_a:getTheme("FrameText"))else d_a.width,d_a.height=_ca.getSize() -_bc:setBackground(c_a.getTheme("BasaltBG")) -_bc:setForeground(c_a.getTheme("BasaltText"))end;bab=true end end} -for _bc,abc in pairs(db)do caa["add".._bc]=function(bbc,cbc) -return adb(abc(cbc or cc(),bbc))end end;setmetatable(caa,d_a)return caa end -end; -project['default']['loadObjects'] = function(...)local d={}if(packaged)then -for ba,ca in pairs(getProject("objects"))do d[ba]=ca()end;return d end -local _a=table.pack(...)local aa=fs.getDir(_a[2]or"Basalt")if(aa==nil)then -error("Unable to find directory ".. -_a[2].." please report this bug to our discord.")end;for ba,ca in -pairs(fs.list(fs.combine(aa,"objects")))do -if(ca~="example.lua")then local da=ca:gsub(".lua","")d[da]=require(da)end end;return d -end; -project['default']['Object'] = function(...)local aa=require("basaltEvent")local ba=require("utils") -local ca=ba.splitString;local da=ba.numberFromString;local _b=ba.getValueFromXML -return -function(ab)local bb="Object"local cb={}local db=1 -local _c;local ac="topLeft"local bc=false;local cc=true;local dc=false;local _d=false -local ad={left=false,right=false,top=false,bottom=false}local bd=colors.black;local cd=true;local dd=false;local __a,a_a,b_a,c_a=0,0,0,0;local d_a=true;local _aa={} -local aaa=aa() -cb={x=1,y=1,width=1,height=1,bgColor=colors.black,bgSymbol=" ",bgSymbolColor=colors.black,fgColor=colors.white,transparentColor=false,name=ab or"Object",parent=nil,show=function(baa)cc=true -baa:updateDraw()return baa end,hide=function(baa)cc=false;baa:updateDraw()return baa end,enable=function(baa) -cd=true;return baa end,disable=function(baa)cd=false;return baa end,generateXMLEventFunction=function(baa,caa,daa) -local _ba=function(aba) -if -(aba:sub(1,1)=="#")then -local bba=baa:getBaseFrame():getDeepObject(aba:sub(2,aba:len())) -if(bba~=nil)and(bba.internalObjetCall~=nil)then caa(baa,function() -bba:internalObjetCall()end)end else -caa(baa,baa:getBaseFrame():getVariable(aba))end end;if(type(daa)=="string")then _ba(daa)elseif(type(daa)=="table")then -for aba,bba in pairs(daa)do _ba(bba)end end;return baa end,setValuesByXMLData=function(baa,caa) -local daa=baa:getBaseFrame()if(_b("x",caa)~=nil)then -baa:setPosition(_b("x",caa),baa.y)end;if(_b("y",caa)~=nil)then -baa:setPosition(baa.x,_b("y",caa))end;if(_b("width",caa)~=nil)then -baa:setSize(_b("width",caa),baa.height)end;if(_b("height",caa)~=nil)then -baa:setSize(baa.width,_b("height",caa))end;if(_b("bg",caa)~=nil)then -baa:setBackground(colors[_b("bg",caa)])end;if(_b("fg",caa)~=nil)then -baa:setForeground(colors[_b("fg",caa)])end;if(_b("value",caa)~=nil)then -baa:setValue(colors[_b("value",caa)])end -if(_b("visible",caa)~=nil)then if -(_b("visible",caa))then baa:show()else baa:hide()end end -if(_b("enabled",caa)~=nil)then if(_b("enabled",caa))then baa:enable()else -baa:disable()end end;if(_b("zIndex",caa)~=nil)then -baa:setZIndex(_b("zIndex",caa))end;if(_b("anchor",caa)~=nil)then -baa:setAnchor(_b("anchor",caa))end;if(_b("shadowColor",caa)~=nil)then -baa:setShadow(colors[_b("shadowColor",caa)])end;if(_b("border",caa)~=nil)then -baa:setBorder(colors[_b("border",caa)])end;if(_b("borderLeft",caa)~=nil)then -ad["left"]=_b("borderLeft",caa)end;if(_b("borderTop",caa)~=nil)then -ad["top"]=_b("borderTop",caa)end;if(_b("borderRight",caa)~=nil)then -ad["right"]=_b("borderRight",caa)end;if(_b("borderBottom",caa)~=nil)then -ad["bottom"]=_b("borderBottom",caa)end;if(_b("borderColor",caa)~=nil)then -baa:setBorder(colors[_b("borderColor",caa)])end;if -(_b("ignoreOffset",caa)~=nil)then -if(_b("ignoreOffset",caa))then baa:ignoreOffset(true)end end;if -(_b("onClick",caa)~=nil)then -baa:generateXMLEventFunction(baa.onClick,_b("onClick",caa))end;if -(_b("onClickUp",caa)~=nil)then -baa:generateXMLEventFunction(baa.onClickUp,_b("onClickUp",caa))end;if -(_b("onScroll",caa)~=nil)then -baa:generateXMLEventFunction(baa.onScroll,_b("onScroll",caa))end;if -(_b("onDrag",caa)~=nil)then -baa:generateXMLEventFunction(baa.onDrag,_b("onDrag",caa))end;if(_b("onKey",caa)~=nil)then -baa:generateXMLEventFunction(baa.onKey,_b("onKey",caa))end;if(_b("onKeyUp",caa)~=nil)then -baa:generateXMLEventFunction(baa.onKeyUp,_b("onKeyUp",caa))end;if -(_b("onChange",caa)~=nil)then -baa:generateXMLEventFunction(baa.onChange,_b("onChange",caa))end;if -(_b("onResize",caa)~=nil)then -baa:generateXMLEventFunction(baa.onResize,_b("onResize",caa))end;if -(_b("onReposition",caa)~=nil)then -baa:generateXMLEventFunction(baa.onReposition,_b("onReposition",caa))end;if -(_b("onEvent",caa)~=nil)then -baa:generateXMLEventFunction(baa.onEvent,_b("onEvent",caa))end;if -(_b("onGetFocus",caa)~=nil)then -baa:generateXMLEventFunction(baa.onGetFocus,_b("onGetFocus",caa))end;if -(_b("onLoseFocus",caa)~=nil)then -baa:generateXMLEventFunction(baa.onLoseFocus,_b("onLoseFocus",caa))end -baa:updateDraw()return baa end,isVisible=function(baa)return -cc end,setFocus=function(baa)if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;return baa end,setZIndex=function(baa,caa) -db=caa -if(baa.parent~=nil)then baa.parent:removeObject(baa) -baa.parent:addObject(baa)baa:updateEventHandlers()end;return baa end,updateEventHandlers=function(baa) -for caa,daa in -pairs(_aa)do if(daa)then baa.parent:addEvent(caa,baa)end end end,getZIndex=function(baa)return db end,getType=function(baa)return bb end,getName=function(baa)return -baa.name end,remove=function(baa)if(baa.parent~=nil)then -baa.parent:removeObject(baa)end;baa:updateDraw()return baa end,setParent=function(baa,caa) -if( -caa.getType~=nil and caa:getType()=="Frame")then -baa:remove()caa:addObject(baa)if(baa.draw)then baa:show()end end;return baa end,setValue=function(baa,caa) -if( -_c~=caa)then _c=caa;baa:updateDraw()baa:valueChangedHandler()end;return baa end,getValue=function(baa)return _c end,getDraw=function(baa)return -d_a end,updateDraw=function(baa,caa)d_a=caa;if(caa==nil)then d_a=true end;if(d_a)then if(baa.parent~=nil)then -baa.parent:updateDraw()end end;return baa end,getEventSystem=function(baa)return -aaa end,getParent=function(baa)return baa.parent end,setPosition=function(baa,caa,daa,_ba) -if(type(caa)=="number")then baa.x= -_ba and baa:getX()+caa or caa end;if(type(daa)=="number")then -baa.y=_ba and baa:getY()+daa or daa end -if(baa.parent~=nil)then if(type(caa)=="string")then -baa.x=baa.parent:newDynamicValue(baa,caa)end;if(type(daa)=="string")then -baa.y=baa.parent:newDynamicValue(baa,daa)end -baa.parent:recalculateDynamicValues()end;aaa:sendEvent("basalt_reposition",baa) -baa:updateDraw()return baa end,getX=function(baa)return - -type(baa.x)=="number"and baa.x or math.floor(baa.x[1]+0.5)end,getY=function(baa)return - -type(baa.y)=="number"and baa.y or math.floor(baa.y[1]+0.5)end,getPosition=function(baa)return -baa:getX(),baa:getY()end,getVisibility=function(baa)return cc end,setVisibility=function(baa,caa) -cc=caa or not cc;baa:updateDraw()return baa end,setSize=function(baa,caa,daa,_ba)if(type(caa)== -"number")then -baa.width=_ba and baa.width+caa or caa end -if(type(daa)=="number")then baa.height=_ba and -baa.height+daa or daa end -if(baa.parent~=nil)then if(type(caa)=="string")then -baa.width=baa.parent:newDynamicValue(baa,caa)end;if(type(daa)=="string")then -baa.height=baa.parent:newDynamicValue(baa,daa)end -baa.parent:recalculateDynamicValues()end;aaa:sendEvent("basalt_resize",baa) -baa:updateDraw()return baa end,getHeight=function(baa) -return -type(baa.height)=="number"and baa.height or -math.floor(baa.height[1]+0.5)end,getWidth=function(baa)return - -type(baa.width)=="number"and baa.width or math.floor(baa.width[1]+0.5)end,getSize=function(baa)return -baa:getWidth(),baa:getHeight()end,calculateDynamicValues=function(baa) -if( -type(baa.width)=="table")then baa.width:calculate()end -if(type(baa.height)=="table")then baa.height:calculate()end -if(type(baa.x)=="table")then baa.x:calculate()end -if(type(baa.y)=="table")then baa.y:calculate()end;baa:updateDraw()return baa end,setBackground=function(baa,caa,daa,_ba)baa.bgColor= -caa or false -baa.bgSymbol=daa or(baa.bgColor~=false and baa.bgSymbol or -false)baa.bgSymbolColor=_ba or baa.bgSymbolColor -baa:updateDraw()return baa end,setTransparent=function(baa,caa)baa.transparentColor= -caa or false;baa.bgSymbol=false;baa.bgSymbolColor=false -baa:updateDraw()return baa end,getBackground=function(baa)return -baa.bgColor end,setForeground=function(baa,caa)baa.fgColor=caa or false -baa:updateDraw()return baa end,getForeground=function(baa)return baa.fgColor end,setShadow=function(baa,caa)if( -caa==false)then _d=false else bd=caa;_d=true end -baa:updateDraw()return baa end,isShadowActive=function(baa)return _d end,setBorder=function(baa,...) -if( -...~=nil)then local caa={...} -for daa,_ba in pairs(caa)do if(_ba=="left")or(#caa==1)then -ad["left"]=caa[1]end;if(_ba=="top")or(#caa==1)then -ad["top"]=caa[1]end;if(_ba=="right")or(#caa==1)then -ad["right"]=caa[1]end;if(_ba=="bottom")or(#caa==1)then -ad["bottom"]=caa[1]end end end;baa:updateDraw()return baa end,getBorder=function(baa,caa)if( -caa=="left")then return borderLeft end -if(caa=="top")then return borderTop end;if(caa=="right")then return borderRight end;if(caa=="bottom")then -return borderBottom end end,draw=function(baa) -if -(cc)then -if(baa.parent~=nil)then local caa,daa=baa:getAnchorPosition() -local _ba,aba=baa:getSize()local bba,cba=baa.parent:getSize() -if(caa+_ba<1)or(caa>bba)or(daa+ -aba<1)or(daa>cba)then return false end;if(baa.transparentColor~=false)then -baa.parent:drawForegroundBox(caa,daa,_ba,aba,baa.transparentColor)end;if(baa.bgColor~=false)then -baa.parent:drawBackgroundBox(caa,daa,_ba,aba,baa.bgColor)end -if(baa.bgSymbol~=false)then -baa.parent:drawTextBox(caa,daa,_ba,aba,baa.bgSymbol)if(baa.bgSymbol~=" ")then -baa.parent:drawForegroundBox(caa,daa,_ba,aba,baa.bgSymbolColor)end end -if(_d)then -baa.parent:drawBackgroundBox(caa+1,daa+aba,_ba,1,bd) -baa.parent:drawBackgroundBox(caa+_ba,daa+1,1,aba,bd) -baa.parent:drawForegroundBox(caa+1,daa+aba,_ba,1,bd) -baa.parent:drawForegroundBox(caa+_ba,daa+1,1,aba,bd)end -if(ad["left"]~=false)then -baa.parent:drawTextBox(caa-1,daa,1,aba,"\149") -baa.parent:drawBackgroundBox(caa-1,daa,1,aba,ad["left"]) -baa.parent:drawForegroundBox(caa-1,daa,1,aba,baa.parent.bgColor)end -if(ad["left"]~=false)and(ad["top"]~=false)then baa.parent:drawTextBox( -caa-1,daa-1,1,1,"\151")baa.parent:drawBackgroundBox( -caa-1,daa-1,1,1,ad["left"]) -baa.parent:drawForegroundBox( -caa-1,daa-1,1,1,baa.parent.bgColor)end -if(ad["top"]~=false)then -baa.parent:drawTextBox(caa,daa-1,_ba,1,"\131") -baa.parent:drawBackgroundBox(caa,daa-1,_ba,1,ad["top"]) -baa.parent:drawForegroundBox(caa,daa-1,_ba,1,baa.parent.bgColor)end -if(ad["top"]~=false)and(ad["right"]~=false)then baa.parent:drawTextBox( -caa+_ba,daa-1,1,1,"\148") -baa.parent:drawForegroundBox( -caa+_ba,daa-1,1,1,ad["right"])end;if(ad["right"]~=false)then -baa.parent:drawTextBox(caa+_ba,daa,1,aba,"\149") -baa.parent:drawForegroundBox(caa+_ba,daa,1,aba,ad["right"])end -if( -ad["right"]~=false)and(ad["bottom"]~=false)then baa.parent:drawTextBox( -caa+_ba,daa+aba,1,1,"\129") -baa.parent:drawForegroundBox( -caa+_ba,daa+aba,1,1,ad["right"])end;if(ad["bottom"]~=false)then -baa.parent:drawTextBox(caa,daa+aba,_ba,1,"\131") -baa.parent:drawForegroundBox(caa,daa+aba,_ba,1,ad["bottom"])end -if( -ad["bottom"]~=false)and(ad["left"]~=false)then baa.parent:drawTextBox( -caa-1,daa+aba,1,1,"\130") -baa.parent:drawForegroundBox( -caa-1,daa+aba,1,1,ad["left"])end end;d_a=false;return true end;return false end,getAbsolutePosition=function(baa,caa,daa) -if( -caa==nil)or(daa==nil)then caa,daa=baa:getAnchorPosition()end -if(baa.parent~=nil)then -local _ba,aba=baa.parent:getAbsolutePosition()caa=_ba+caa-1;daa=aba+daa-1 end;return caa,daa end,getAnchorPosition=function(baa,caa,daa,_ba)if( -caa==nil)then caa=baa:getX()end -if(daa==nil)then daa=baa:getY()end -if(baa.parent~=nil)then local aba,bba=baa.parent:getSize() -if(ac=="top")then caa=math.floor( -aba/2)+caa-1 elseif(ac=="topRight")then -caa=aba+caa-1 elseif(ac=="right")then caa=aba+caa-1 -daa=math.floor(bba/2)+daa-1 elseif(ac=="bottomRight")then caa=aba+caa-1;daa=bba+daa-1 elseif(ac=="bottom")then caa=math.floor( -aba/2)+caa-1;daa=bba+daa-1 elseif(ac== -"bottomLeft")then daa=bba+daa-1 elseif(ac=="left")then -daa=math.floor(bba/2)+daa-1 elseif(ac=="center")then caa=math.floor(aba/2)+caa-1;daa=math.floor( -bba/2)+daa-1 end;local cba,dba=baa.parent:getOffsetInternal()if not(bc or _ba)then return caa+ -cba,daa+dba end end;return caa,daa end,ignoreOffset=function(baa,caa) -bc=caa;if(caa==nil)then bc=true end;return baa end,getBaseFrame=function(baa) -if( -baa.parent~=nil)then return baa.parent:getBaseFrame()end;return baa end,setAnchor=function(baa,caa)ac=caa -baa:updateDraw()return baa end,getAnchor=function(baa)return ac end,onChange=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("value_changed",daa)end end;return baa end,onClick=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("mouse_click",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true end;return -baa end,onClickUp=function(baa,...)for caa,daa in -pairs(table.pack(...))do -if(type(daa)=="function")then baa:registerEvent("mouse_up",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_up",baa)_aa["mouse_up"]=true end;return baa end,onScroll=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("mouse_scroll",daa)end end -if(baa.parent~=nil)then -baa.parent:addEvent("mouse_scroll",baa)_aa["mouse_scroll"]=true end;return baa end,onDrag=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("mouse_drag",daa)end end -if(baa.parent~=nil)then -baa.parent:addEvent("mouse_drag",baa)_aa["mouse_drag"]=true -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true -baa.parent:addEvent("mouse_up",baa)_aa["mouse_up"]=true end;return baa end,onEvent=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("other_event",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)_aa["other_event"]=true end;return -baa end,onKey=function(baa,...) -if -(cd)then for caa,daa in pairs(table.pack(...))do -if(type(daa)=="function")then -baa:registerEvent("key",daa)baa:registerEvent("char",daa)end end -if -(baa.parent~=nil)then baa.parent:addEvent("key",baa) -baa.parent:addEvent("char",baa)_aa["key"]=true;_aa["char"]=true end end;return baa end,onResize=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("basalt_resize",daa)end end;return baa end,onReposition=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("basalt_reposition",daa)end end;return baa end,onKeyUp=function(baa,...)for caa,daa in -pairs(table.pack(...))do -if(type(daa)=="function")then baa:registerEvent("key_up",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("key_up",baa)_aa["key_up"]=true end;return baa end,isFocused=function(baa)if( -baa.parent~=nil)then -return baa.parent:getFocusedObject()==baa end;return false end,onGetFocus=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("get_focus",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true end;return -baa end,onLoseFocus=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("lose_focus",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true end;return -baa end,registerEvent=function(baa,caa,daa)return -aaa:registerEvent(caa,daa)end,removeEvent=function(baa,caa,daa) -return aaa:removeEvent(caa,daa)end,sendEvent=function(baa,caa,...)return aaa:sendEvent(caa,baa,...)end,isCoordsInObject=function(baa,caa,daa) -if -(cc)and(cd)then -local _ba,aba=baa:getAbsolutePosition(baa:getAnchorPosition())local bba,cba=baa:getSize() -if -(_ba<=caa)and(_ba+bba>caa)and(aba<=daa)and(aba+cba>daa)then return true end end;return false end,mouseHandler=function(baa,caa,daa,_ba,aba) -if -(baa:isCoordsInObject(daa,_ba))then -local bba=aaa:sendEvent("mouse_click",baa,"mouse_click",caa,daa,_ba,aba)if(bba==false)then return false end;if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;dd=true;__a,a_a=daa,_ba;return true end;return false end,mouseUpHandler=function(baa,caa,daa,_ba) -dd=false -if(baa:isCoordsInObject(daa,_ba))then -local aba=aaa:sendEvent("mouse_up",baa,"mouse_up",caa,daa,_ba)if(aba==false)then return false end;return true end;return false end,dragHandler=function(baa,caa,daa,_ba) -if -(dd)then local aba,bba,cba,dba=0,0,1,1 -if(baa.parent~=nil)then -aba,bba=baa.parent:getOffsetInternal()aba=aba<0 and math.abs(aba)or-aba;bba=bba<0 and -math.abs(bba)or-bba -cba,dba=baa.parent:getAbsolutePosition(baa.parent:getAnchorPosition())end -local _ca,aca=daa+b_a- (cba-1)+aba,_ba+c_a- (dba-1)+bba -local bca=aaa:sendEvent("mouse_drag",baa,caa,_ca,aca,__a-daa,a_a-_ba,daa,_ba) -local cca,dca=baa:getAbsolutePosition(baa:getAnchorPosition())__a,a_a=daa,_ba;if(bca~=nil)then return bca end;if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;return true end -if(baa:isCoordsInObject(daa,_ba))then -local aba,bba=baa:getAbsolutePosition(baa:getAnchorPosition())__a,a_a=daa,_ba;b_a,c_a=aba-daa,bba-_ba end;return false end,scrollHandler=function(baa,caa,daa,_ba) -if -(baa:isCoordsInObject(daa,_ba))then -local aba=aaa:sendEvent("mouse_scroll",baa,"mouse_scroll",caa,daa,_ba)if(aba==false)then return false end;if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;return true end;return false end,keyHandler=function(baa,caa,daa)if -(cd)and(cc)then -if(baa:isFocused())then -local _ba=aaa:sendEvent("key",baa,"key",caa,daa)if(_ba==false)then return false end;return true end end;return -false end,keyUpHandler=function(baa,caa)if -(cd)and(cc)then -if(baa:isFocused())then -local daa=aaa:sendEvent("key_up",baa,"key_up",caa)if(daa==false)then return false end;return true end end;return -false end,charHandler=function(baa,caa)if -(cd)and(cc)then -if(baa:isFocused())then -local daa=aaa:sendEvent("char",baa,"char",caa)if(daa==false)then return false end;return true end end -return false end,valueChangedHandler=function(baa) -aaa:sendEvent("value_changed",baa,_c)end,eventHandler=function(baa,caa,daa,_ba,aba,bba) -local cba=aaa:sendEvent("other_event",baa,caa,daa,_ba,aba,bba)if(cba~=nil)then return cba end;return true end,getFocusHandler=function(baa) -local caa=aaa:sendEvent("get_focus",baa)if(caa~=nil)then return caa end;return true end,loseFocusHandler=function(baa) -dd=false;local caa=aaa:sendEvent("lose_focus",baa) -if(caa~=nil)then return caa end;return true end,init=function(baa) -if -(baa.parent~=nil)then for caa,daa in pairs(_aa)do -if(daa)then baa.parent:addEvent(caa,baa)end end end;if not(dc)then dc=true;return true end end}cb.__index=cb;return cb end -end; -project['default']['theme'] = function(...) -return -{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=false,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green,LabelBG=false,LabelText=colors.black} -end; -local baa=require("basaltEvent")() -local caa=require("Frame")local daa=require("theme")local _ba=require("utils") -local aba=require("basaltLogs")local bba=_ba.uuid;local cba=_ba.createText;local dba=term.current()local _ca="1.6.0" -local aca=true -local bca=fs.getDir(table.pack(...)[2]or"")local cca,dca,_da,ada,bda={},{},{},{},{}local cda,dda,__b,a_b;local b_b={}if not term.isColor or -not term.isColor()then -error('Basalt requires an advanced (golden) computer to run.',0)end;local function c_b()a_b=false -dba.clear()dba.setCursorPos(1,1)end;local d_b=function(cbb,dbb) -ada[cbb]=dbb end -local _ab=function(cbb)return ada[cbb]end;local aab=function(cbb)daa=cbb end -local bab=function(cbb)return daa[cbb]end -local cab={getMainFrame=function()return cda end,setVariable=d_b,getVariable=_ab,getTheme=bab,setMainFrame=function(cbb)cda=cbb end,getActiveFrame=function()return dda end,setActiveFrame=function(cbb)dda=cbb end,getFocusedObject=function()return -__b end,setFocusedObject=function(cbb)__b=cbb end,getMonitorFrame=function(cbb)return _da[cbb]end,setMonitorFrame=function(cbb,dbb)if(cda==dbb)then -cda=nil end;_da[cbb]=dbb end,getBaseTerm=function()return dba end,stop=c_b,newFrame=caa,getDirectory=function()return -bca end} -local dab=function(cbb)dba.clear()dba.setBackgroundColor(colors.black) -dba.setTextColor(colors.red)local dbb,_cb=dba.getSize() -if(b_b.logging)then aba(cbb,"Error")end;local acb=cba("Basalt error: "..cbb,dbb)local bcb=1;for ccb,dcb in pairs(acb)do -dba.setCursorPos(1,bcb)dba.write(dcb)bcb=bcb+1 end;dba.setCursorPos(1, -bcb+1)a_b=false end -local function _bb(cbb,dbb,_cb,acb,bcb) -if(#bda>0)then local ccb={} -for n=1,#bda do -if(bda[n]~=nil)then -if -(coroutine.status(bda[n])=="suspended")then -local dcb,_db=coroutine.resume(bda[n],cbb,dbb,_cb,acb,bcb)if not(dcb)then dab(_db)end else table.insert(ccb,n)end end end -for n=1,#ccb do table.remove(bda,ccb[n]- (n-1))end end end -local function abb()if(a_b==false)then return end;if(cda~=nil)then cda:draw() -cda:updateTerm()end -for cbb,dbb in pairs(_da)do dbb:draw()dbb:updateTerm()end end -local function bbb(cbb,dbb,_cb,acb,bcb)if -(baa:sendEvent("basaltEventCycle",cbb,dbb,_cb,acb,bcb)==false)then return end -if(cda~=nil)then -if(cbb=="mouse_click")then -cda:mouseHandler(dbb,_cb,acb,false)dda=cda elseif(cbb=="mouse_drag")then cda:dragHandler(dbb,_cb,acb,bcb) -dda=cda elseif(cbb=="mouse_up")then cda:mouseUpHandler(dbb,_cb,acb,bcb)dda=cda elseif(cbb== -"mouse_scroll")then cda:scrollHandler(dbb,_cb,acb,bcb)dda=cda end end -if(cbb=="monitor_touch")then if(_da[dbb]~=nil)then -_da[dbb]:mouseHandler(1,_cb,acb,true)dda=_da[dbb]end end -if(cbb=="char")then if(dda~=nil)then dda:charHandler(dbb)end end;if(cbb=="key_up")then if(dda~=nil)then dda:keyUpHandler(dbb)end -cca[dbb]=false end -if(cbb=="key")then if(dda~=nil)then -dda:keyHandler(dbb,_cb)end;cca[dbb]=true end -if(cbb=="terminate")then if(dda~=nil)then dda:eventHandler(cbb) -if(a_b==false)then return end end end -if - - - -(cbb~="mouse_click")and(cbb~="mouse_up")and(cbb~="mouse_scroll")and(cbb~="mouse_drag")and(cbb~="key")and(cbb~="key_up")and(cbb~= -"char")and(cbb~="terminate")then -for ccb,dcb in pairs(dca)do dcb:eventHandler(cbb,dbb,_cb,acb,bcb)end end;_bb(cbb,dbb,_cb,acb,bcb)abb()end -b_b={logging=false,setTheme=aab,getTheme=bab,drawFrames=abb,getVersion=function()return _ca end,setVariable=d_b,getVariable=_ab,setBaseTerm=function(cbb)dba=cbb end,log=function(...)aba(...)end,autoUpdate=function(cbb) -a_b=cbb;if(cbb==nil)then a_b=true end;local function dbb()abb()while a_b do -bbb(os.pullEventRaw())end end -local _cb,acb=xpcall(dbb,debug.traceback)if not(_cb)then dab(acb)return end end,update=function(cbb,dbb,_cb,acb,bcb) -if( -cbb~=nil)then -local ccb,dcb=xpcall(bbb,debug.traceback,cbb,dbb,_cb,acb,bcb)if not(ccb)then dab(dcb)return end end end,stop=c_b,stopUpdate=c_b,isKeyDown=function(cbb)if( -cca[cbb]==nil)then return false end;return cca[cbb]end,getFrame=function(cbb)for dbb,_cb in -pairs(dca)do if(_cb.name==cbb)then return _cb end end end,getActiveFrame=function()return -dda end,setActiveFrame=function(cbb) -if(cbb:getType()=="Frame")then dda=cbb;return true end;return false end,onEvent=function(...) -for cbb,dbb in -pairs(table.pack(...))do if(type(dbb)=="function")then -baa:registerEvent("basaltEventCycle",dbb)end end end,schedule=function(cbb) -assert(cbb~= -"function","Schedule needs a function in order to work!")return -function(...)local dbb=coroutine.create(cbb) -local _cb,acb=coroutine.resume(dbb,...)if(_cb)then table.insert(bda,dbb)else dab(acb)end end end,createFrame=function(cbb)cbb= -cbb or bba() -for _cb,acb in pairs(dca)do if(acb.name==cbb)then return nil end end;local dbb=caa(cbb,nil,nil,cab)dbb:init() -table.insert(dca,dbb)if -(cda==nil)and(dbb:getName()~="basaltDebuggingFrame")then dbb:show()end;return dbb end,removeFrame=function(cbb)dca[cbb]= -nil end,setProjectDir=function(cbb)bca=cbb end,debug=function(...)local cbb={...}if(cda==nil)then -print(...)return end;if(cda.name~="basaltDebuggingFrame")then -if -(cda~=b_b.debugFrame)then b_b.debugLabel:setParent(cda)end end;local dbb=""for _cb,acb in pairs(cbb)do -dbb=dbb.. -tostring(acb).. (#cbb~=_cb and", "or"")end -b_b.debugLabel:setText("[Debug] "..dbb)for _cb,acb in pairs(cba(dbb,b_b.debugList:getWidth()))do -b_b.debugList:addItem(acb)end -if( -b_b.debugList:getItemCount()>50)then b_b.debugList:removeItem(1)end -b_b.debugList:setValue(b_b.debugList:getItem(b_b.debugList:getItemCount()))if -(b_b.debugList.getItemCount()>b_b.debugList:getHeight())then -b_b.debugList:setOffset(b_b.debugList:getItemCount()- -b_b.debugList:getHeight())end -b_b.debugLabel:show()end} -b_b.debugFrame=b_b.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) -b_b.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if( -b_b.oldFrame~=nil)then b_b.oldFrame:show()end end):setBackground(colors.red):show() -b_b.debugList=b_b.debugFrame:addList("debugList"):setSize("parent.w - 2","parent.h - 3"):setPosition(2,3):setScrollable(true):show() -b_b.debugLabel=b_b.debugFrame:addLabel("debugLabel"):onClick(function() -b_b.oldFrame=cda;b_b.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return b_b \ No newline at end of file diff --git a/docs/docs1_6/versions/basalt-1.6.2.lua b/docs/docs1_6/versions/basalt-1.6.2.lua deleted file mode 100644 index 0101ced..0000000 --- a/docs/docs1_6/versions/basalt-1.6.2.lua +++ /dev/null @@ -1,2790 +0,0 @@ -local project = {} -local packaged = true -local baseRequire = require -local require = function(path) - for _,v in pairs(project)do - for name,b in pairs(v)do - if(name==path)then - return b() - end - end - end - return baseRequire(path); -end -local getProject = function(subDir) - if(subDir~=nil)then - return project[subDir] - end - return project -end -project['objects'] = {}project['libraries'] = {}project['default'] = {}project['objects']['Animation'] = function(...)local cc=require("utils").getValueFromXML -local dc=require("basaltEvent")local _d,ad,bd,cd=math.floor,math.sin,math.cos,math.pi;local dd=function(_ba,aba,bba)return -_ba+ (aba-_ba)*bba end -local __a=function(_ba)return _ba end;local a_a=function(_ba)return 1 -_ba end -local b_a=function(_ba)return _ba*_ba*_ba end -local c_a=function(_ba)return a_a(b_a(a_a(_ba)))end -local d_a=function(_ba)return dd(b_a(_ba),c_a(_ba),_ba)end;local _aa=function(_ba)return ad((_ba*cd)/2)end -local aaa=function(_ba)return a_a(bd(( -_ba*cd)/2))end -local baa=function(_ba)return- (bd(cd*x)-1)/2 end -local caa={linear=__a,lerp=dd,flip=a_a,easeIn=b_a,easeOut=c_a,easeInOut=d_a,easeOutSine=_aa,easeInSine=aaa,easeInOutSine=baa}local daa={} -return -function(_ba)local aba={}local bba="Animation"local cba;local dba={}local _ca=0;local aca=false;local bca=1;local cca=false -local dca=dc()local _da=0;local ada;local bda=false;local cda=false;local dda="easeOut"local __b;local function a_b(_ab)for aab,bab in pairs(_ab)do -bab(aba,dba[bca].t,bca)end end -local function b_b(_ab)if(bca==1)then -_ab:animationStartHandler()end;if(dba[bca]~=nil)then a_b(dba[bca].f) -_ca=dba[bca].t end;bca=bca+1 -if(dba[bca]==nil)then if(cca)then bca=1;_ca=0 else -_ab:animationDoneHandler()return end end;if(dba[bca].t>0)then -cba=os.startTimer(dba[bca].t-_ca)else b_b(_ab)end end -local function c_b(_ab,aab)for n=1,#dba do -if(dba[n].t==_ab)then table.insert(dba[n].f,aab)return end end -for n=1,#dba do -if(dba[n].t>_ab)then if -(dba[n-1]~=nil)then if(dba[n-1].t<_ab)then -table.insert(dba,n-1,{t=_ab,f={aab}})return end else -table.insert(dba,n,{t=_ab,f={aab}})return end end end -if(#dba<=0)then table.insert(dba,1,{t=_ab,f={aab}})return elseif( -dba[#dba].t<_ab)then table.insert(dba,{t=_ab,f={aab}})end end -local function d_b(_ab,aab,bab,cab,dab,_bb,abb,bbb)local cbb=__b;local dbb,_cb;local acb=""if(cbb.parent~=nil)then -acb=cbb.parent:getName()end;acb=acb..cbb:getName() -c_b(cab+0.05,function() -if -(abb~=nil)then if(daa[abb]==nil)then daa[abb]={}end;if(daa[abb][acb]~=nil)then -if( -daa[abb][acb]~=bbb)then daa[abb][acb]:cancel()end end;daa[abb][acb]=bbb end;dbb,_cb=dab(cbb)end) -for n=0.05,bab+0.01,0.05 do -c_b(cab+n,function() -local bcb=math.floor(caa.lerp(dbb,_ab,caa[dda](n/bab))+0.5) -local ccb=math.floor(caa.lerp(_cb,aab,caa[dda](n/bab))+0.5)_bb(cbb,bcb,ccb) -if(abb~=nil)then if(n>=bab-0.01)then if(daa[abb][acb]==bbb)then daa[abb][acb]= -nil end end end end)end end -aba={name=_ba,getType=function(_ab)return bba end,getBaseFrame=function(_ab)if(_ab.parent~=nil)then -return _ab.parent:getBaseFrame()end;return _ab end,setMode=function(_ab,aab) -dda=aab;return _ab end,generateXMLEventFunction=function(_ab,aab,bab) -local cab=function(dab) -if(dab:sub(1,1)=="#")then -local _bb=_ab:getBaseFrame():getDeepObject(dab:sub(2,dab:len())) -if(_bb~=nil)and(_bb.internalObjetCall~=nil)then aab(_ab,function() -_bb:internalObjetCall()end)end else -aab(_ab,_ab:getBaseFrame():getVariable(dab))end end;if(type(bab)=="string")then cab(bab)elseif(type(bab)=="table")then -for dab,_bb in pairs(bab)do cab(_bb)end end;return _ab end,setValuesByXMLData=function(_ab,aab)bda= -cc("loop",aab)==true and true or false -if( -cc("object",aab)~=nil)then -local bab=_ab:getBaseFrame():getDeepObject(cc("object",aab))if(bab==nil)then -bab=_ab:getBaseFrame():getVariable(cc("object",aab))end -if(bab~=nil)then _ab:setObject(bab)end end -if(aab["move"]~=nil)then local bab=cc("x",aab["move"]) -local cab=cc("y",aab["move"])local dab=cc("duration",aab["move"]) -local _bb=cc("time",aab["move"])_ab:move(bab,cab,dab,_bb)end -if(aab["size"]~=nil)then local bab=cc("width",aab["size"]) -local cab=cc("height",aab["size"])local dab=cc("duration",aab["size"]) -local _bb=cc("time",aab["size"])_ab:size(bab,cab,dab,_bb)end -if(aab["offset"]~=nil)then local bab=cc("x",aab["offset"]) -local cab=cc("y",aab["offset"])local dab=cc("duration",aab["offset"]) -local _bb=cc("time",aab["offset"])_ab:offset(bab,cab,dab,_bb)end -if(aab["textColor"]~=nil)then -local bab=cc("duration",aab["textColor"])local cab=cc("time",aab["textColor"])local dab={} -local _bb=aab["textColor"]["color"] -if(_bb~=nil)then if(_bb.properties~=nil)then _bb={_bb}end;for abb,bbb in pairs(_bb)do -table.insert(dab,colors[bbb:value()])end end;if(bab~=nil)and(#dab>0)then -_ab:changeTextColor(bab,cab or 0,table.unpack(dab))end end -if(aab["background"]~=nil)then -local bab=cc("duration",aab["background"])local cab=cc("time",aab["background"])local dab={} -local _bb=aab["background"]["color"] -if(_bb~=nil)then if(_bb.properties~=nil)then _bb={_bb}end;for abb,bbb in pairs(_bb)do -table.insert(dab,colors[bbb:value()])end end;if(bab~=nil)and(#dab>0)then -_ab:changeBackground(bab,cab or 0,table.unpack(dab))end end -if(aab["text"]~=nil)then local bab=cc("duration",aab["text"]) -local cab=cc("time",aab["text"])local dab={}local _bb=aab["text"]["text"] -if(_bb~=nil)then if(_bb.properties~=nil)then -_bb={_bb}end;for abb,bbb in pairs(_bb)do -table.insert(dab,bbb:value())end end;if(bab~=nil)and(#dab>0)then -_ab:changeText(bab,cab or 0,table.unpack(dab))end end;if(cc("onDone",aab)~=nil)then -_ab:generateXMLEventFunction(_ab.onDone,cc("onDone",aab))end;if(cc("onStart",aab)~=nil)then -_ab:generateXMLEventFunction(_ab.onDone,cc("onStart",aab))end -if -(cc("autoDestroy",aab)~=nil)then if(cc("autoDestroy",aab))then cda=true end end;dda=cc("mode",aab)or dda -if(cc("play",aab)~=nil)then if -(cc("play",aab))then _ab:play(bda)end end;return _ab end,getZIndex=function(_ab)return -1 end,getName=function(_ab)return _ab.name end,setObject=function(_ab,aab)__b=aab;return _ab end,move=function(_ab,aab,bab,cab,dab,_bb)__b= -_bb or __b -d_b(aab,bab,cab,dab or 0,__b.getPosition,__b.setPosition,"position",_ab)return _ab end,offset=function(_ab,aab,bab,cab,dab,_bb)__b= -_bb or __b -d_b(aab,bab,cab,dab or 0,__b.getOffset,__b.setOffset,"offset",_ab)return _ab end,size=function(_ab,aab,bab,cab,dab,_bb)__b=_bb or -__b -d_b(aab,bab,cab,dab or 0,__b.getSize,__b.setSize,"size",_ab)return _ab end,changeText=function(_ab,aab,bab,...) -local cab={...}bab=bab or 0;__b=obj or __b;for n=1,#cab do -c_b(bab+n* (aab/#cab),function() -__b.setText(__b,cab[n])end)end;return _ab end,changeBackground=function(_ab,aab,bab,...) -local cab={...}bab=bab or 0;__b=obj or __b;for n=1,#cab do -c_b(bab+n* (aab/#cab),function() -__b.setBackground(__b,cab[n])end)end;return _ab end,changeTextColor=function(_ab,aab,bab,...) -local cab={...}bab=bab or 0;__b=obj or __b;for n=1,#cab do -c_b(bab+n* (aab/#cab),function() -__b.setForeground(__b,cab[n])end)end;return _ab end,add=function(_ab,aab,bab) -ada=aab -c_b((bab or _da)+ -(dba[#dba]~=nil and dba[#dba].t or 0),aab)return _ab end,wait=function(_ab,aab)_da=aab;return _ab end,rep=function(_ab,aab) -if( -ada~=nil)then for n=1,aab or 1 do -c_b((wait or _da)+ -(dba[#dba]~=nil and dba[#dba].t or 0),ada)end end;return _ab end,onDone=function(_ab,aab) -dca:registerEvent("animation_done",aab)return _ab end,onStart=function(_ab,aab) -dca:registerEvent("animation_start",aab)return _ab end,setAutoDestroy=function(_ab,aab) -cda=aab~=nil and aab or true;return _ab end,animationDoneHandler=function(_ab) -dca:sendEvent("animation_done",_ab)_ab.parent:removeEvent("other_event",_ab)if(cda)then -_ab.parent:removeObject(_ab)_ab=nil end end,animationStartHandler=function(_ab) -dca:sendEvent("animation_start",_ab)end,clear=function(_ab)dba={}ada=nil;_da=0;bca=1;_ca=0;cca=false;return _ab end,play=function(_ab,aab) -_ab:cancel()aca=true;cca=aab and true or false;bca=1;_ca=0 -if(dba[bca]~=nil)then -if( -dba[bca].t>0)then cba=os.startTimer(dba[bca].t)else b_b(_ab)end else _ab:animationDoneHandler()end;_ab.parent:addEvent("other_event",_ab)return _ab end,cancel=function(_ab)if( -cba~=nil)then os.cancelTimer(cba)cca=false end -aca=false;_ab.parent:removeEvent("other_event",_ab)return _ab end,internalObjetCall=function(_ab) -_ab:play(bda)end,eventHandler=function(_ab,aab,bab)if(aca)then -if(aab=="timer")and(bab==cba)then if(dba[bca]~=nil)then -b_b(_ab)else _ab:animationDoneHandler()end end end end}aba.__index=aba;return aba end -end; -project['objects']['Button'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=aa.getValueFromXML;local ca=require("tHex") -return -function(da)local _b=_a(da)local ab="Button"local bb="center" -local cb="center"_b:setZIndex(5)_b:setValue("Button")_b.width=12 -_b.height=3 -local db={init=function(_c)_c.bgColor=_c.parent:getTheme("ButtonBG") -_c.fgColor=_c.parent:getTheme("ButtonText")end,getType=function(_c)return ab end,setHorizontalAlign=function(_c,ac)bb=ac -_c:updateDraw()return _c end,setVerticalAlign=function(_c,ac)cb=ac;_c:updateDraw()return _c end,setText=function(_c,ac) -_b:setValue(ac)_c:updateDraw()return _c end,setValuesByXMLData=function(_c,ac) -_b.setValuesByXMLData(_c,ac) -if(ba("text",ac)~=nil)then _c:setText(ba("text",ac))end;if(ba("horizontalAlign",ac)~=nil)then -bb=ba("horizontalAlign",ac)end;if(ba("verticalAlign",ac)~=nil)then -cb=ba("verticalAlign",ac)end;return _c end,draw=function(_c) -if -(_b.draw(_c))then -if(_c.parent~=nil)then local ac,bc=_c:getAnchorPosition() -local cc,dc=_c:getSize()local _d=aa.getTextVerticalAlign(dc,cb) -for n=1,dc do -if(n==_d)then -_c.parent:setText(ac,bc+ (n-1),aa.getTextHorizontalAlign(_c:getValue(),cc,bb)) -_c.parent:setFG(ac,bc+ (n-1),aa.getTextHorizontalAlign(ca[_c.fgColor]:rep(_c:getValue():len()),cc,bb))end end end end end}return setmetatable(db,_b)end -end; -project['objects']['Checkbox'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Checkbox"ca:setZIndex(5)ca:setValue(false) -ca.width=1;ca.height=1;local _b="\42" -local ab={getType=function(bb)return da end,setSymbol=function(bb,cb)_b=cb;bb:updateDraw()return bb end,mouseHandler=function(bb,cb,db,_c) -if -(ca.mouseHandler(bb,cb,db,_c))then -if(cb==1)then if -(bb:getValue()~=true)and(bb:getValue()~=false)then bb:setValue(false)else -bb:setValue(not bb:getValue())end -bb:updateDraw()return true end end;return false end,touchHandler=function(bb,cb,db)return -bb:mouseHandler(1,cb,db)end,setValuesByXMLData=function(bb,cb) -ca.setValuesByXMLData(bb,cb) -if(aa("checked",cb)~=nil)then if(aa("checked",cb))then bb:setValue(true)else -bb:setValue(false)end end;return bb end,draw=function(bb) -if -(ca.draw(bb))then -if(bb.parent~=nil)then local cb,db=bb:getAnchorPosition() -local _c,ac=bb:getSize()local bc=_a.getTextVerticalAlign(ac,"center")if -(bb.bgColor~=false)then -bb.parent:drawBackgroundBox(cb,db,_c,ac,bb.bgColor)end -for n=1,ac do -if(n==bc)then -if(bb:getValue()==true)then -bb.parent:writeText(cb, -db+ (n-1),_a.getTextHorizontalAlign(_b,_c,"center"),bb.bgColor,bb.fgColor)else -bb.parent:writeText(cb,db+ (n-1),_a.getTextHorizontalAlign(" ",_c,"center"),bb.bgColor,bb.fgColor)end end end end end end,init=function(bb) -ca.init(bb)bb.bgColor=bb.parent:getTheme("CheckboxBG") -bb.fgColor=bb.parent:getTheme("CheckboxText")bb.parent:addEvent("mouse_click",bb)end}return setmetatable(ab,ca)end -end; -project['objects']['Dropdown'] = function(...)local d=require("Object")local _a=require("utils") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Dropdown"ca.width=12;ca.height=1;ca:setZIndex(6) -local _b={}local ab;local bb;local cb=true;local db="left"local _c=0;local ac=16;local bc=6;local cc="\16"local dc="\31"local _d=false -local ad={getType=function(bd) -return da end,setValuesByXMLData=function(bd,cd)ca.setValuesByXMLData(bd,cd) -if -(aa("selectionBG",cd)~=nil)then ab=colors[aa("selectionBG",cd)]end;if(aa("selectionFG",cd)~=nil)then -bb=colors[aa("selectionFG",cd)]end;if(aa("dropdownWidth",cd)~=nil)then -ac=aa("dropdownWidth",cd)end;if(aa("dropdownHeight",cd)~=nil)then -bc=aa("dropdownHeight",cd)end;if(aa("offset",cd)~=nil)then -_c=aa("offset",cd)end -if(cd["item"]~=nil)then local dd=cd["item"]if -(dd.properties~=nil)then dd={dd}end;for __a,a_a in pairs(dd)do -bd:addItem(aa("text",a_a),colors[aa("bg",a_a)],colors[aa("fg",a_a)])end end end,setOffset=function(bd,cd) -_c=cd;bd:updateDraw()return bd end,getOffset=function(bd)return _c end,addItem=function(bd,cd,dd,__a,...) -table.insert(_b,{text=cd,bgCol= -dd or bd.bgColor,fgCol=__a or bd.fgColor,args={...}})bd:updateDraw()return bd end,getAll=function(bd)return -_b end,removeItem=function(bd,cd)table.remove(_b,cd)bd:updateDraw()return bd end,getItem=function(bd,cd)return -_b[cd]end,getItemIndex=function(bd)local cd=bd:getValue()for dd,__a in pairs(_b)do -if(__a==cd)then return dd end end end,clear=function(bd) -_b={}bd:setValue({})bd:updateDraw()return bd end,getItemCount=function(bd)return -#_b end,editItem=function(bd,cd,dd,__a,a_a,...)table.remove(_b,cd) -table.insert(_b,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol= -a_a or bd.fgColor,args={...}})bd:updateDraw()return bd end,selectItem=function(bd,cd)bd:setValue( -_b[cd]or{})bd:updateDraw()return bd end,setSelectedItem=function(bd,cd,dd,__a)ab= -cd or bd.bgColor;bb=dd or bd.fgColor;cb=__a -bd:updateDraw()return bd end,setDropdownSize=function(bd,cd,dd)ac,bc=cd,dd -bd:updateDraw()return bd end,mouseHandler=function(bd,cd,dd,__a) -if(_d)then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition()) -if(cd==1)then -if(#_b>0)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if -(a_a<=dd)and(a_a+ac>dd)and(b_a+n==__a)then bd:setValue(_b[n+_c])bd:updateDraw() -local c_a=bd:getEventSystem():sendEvent("mouse_click",bd,"mouse_click",dir,dd,__a)if(c_a==false)then return c_a end;return true end end end end end end -if(ca.mouseHandler(bd,cd,dd,__a))then _d=(not _d)bd:updateDraw()return true else if(_d)then -bd:updateDraw()_d=false end;return false end end,mouseUpHandler=function(bd,cd,dd,__a) -if -(_d)then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition()) -if(cd==1)then -if(#_b>0)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if -(a_a<=dd)and(a_a+ac>dd)and(b_a+n==__a)then _d=false;bd:updateDraw() -local c_a=bd:getEventSystem():sendEvent("mouse_up",bd,"mouse_up",dir,dd,__a)if(c_a==false)then return c_a end;return true end end end end end end end,scrollHandler=function(bd,cd,dd,__a) -if -(_d)and(bd:isFocused())then _c=_c+cd;if(_c<0)then _c=0 end;if(cd==1)then -if(#_b>bc)then if -(_c>#_b-bc)then _c=#_b-bc end else _c=math.min(#_b-1,0)end end -local a_a=bd:getEventSystem():sendEvent("mouse_scroll",bd,"mouse_scroll",cd,dd,__a)if(a_a==false)then return a_a end;bd:updateDraw()return true end end,draw=function(bd) -if -(ca.draw(bd))then local cd,dd=bd:getAnchorPosition()local __a,a_a=bd:getSize() -if -(bd.parent~=nil)then if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=bd:getValue() -local c_a=_a.getTextHorizontalAlign(( -b_a~=nil and b_a.text or""),__a,db):sub(1, -__a-1).. (_d and dc or cc) -bd.parent:writeText(cd,dd,c_a,bd.bgColor,bd.fgColor) -if(_d)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if(_b[n+_c]==b_a)then -if(cb)then -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+ -_c].text,ac,db),ab,bb)else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end end end end end end end,init=function(bd) -bd.bgColor=bd.parent:getTheme("DropdownBG")bd.fgColor=bd.parent:getTheme("DropdownText") -ab=bd.parent:getTheme("SelectionBG")bb=bd.parent:getTheme("SelectionText")if(bd.parent~=nil)then -bd.parent:addEvent("mouse_click",bd)bd.parent:addEvent("mouse_up",bd) -bd.parent:addEvent("mouse_scroll",bd)end end}return setmetatable(ad,ca)end -end; -project['objects']['Graphic'] = function(...)local da=require("Object")local _b=require("geometricPoints") -local ab=require("tHex")local bb=require("utils").getValueFromXML -local cb,db,_c,ac=string.sub,string.len,math.max,math.min -return -function(bc)local cc=da(bc)local dc="Graphic"cc:setZIndex(2)local _d={}local ad={}local bd={} -local cd=false;local dd,__a=0,0;local a_a=false;local b_a,c_a;local d_a,_aa=40,15;local aaa=false;local baa={}for n=1,16 do baa[string.byte("0123456789abcdef",n,n)]= -2 ^ (n-1)end -local function caa(dba)local _ca={}for i=1, -#dba do _ca[i]=dba:sub(i,i)end;return _ca end -local function daa(dba,_ca,aca,bca,cca) -if(_ca>=1)and(_ca<=bca)then -if(dba+db(cca)>0)and(dba<=aca)then -local dca=ad[_ca]local _da;local ada=dba+#cca-1 -if(dba<1)then -cca=cb(cca,1 -dba+1,aca-dba+1)elseif(ada>aca)then cca=cb(cca,1,aca-dba+1)end -if(dba>1)then _da=cb(dca,1,dba-1)..cca else _da=cca end;if ada -ad[y]:len())then ad[y]=ad[y].. -(ab[cc.bgColor]):rep(dba-ad[y]:len())else -ad[y]=ad[y]:sub(1,dba)end else -ad[y]=(ab[cc.bgColor]):rep(dba)end end end;_ba() -local function aba() -local function dba(b_b,c_b)local d_b={}for x=1,c_b:len()do -d_b[x]=baa[string.byte(c_b,x,x)]or 0 end;table.insert(b_b,d_b)end -function parseImage(b_b)if type(b_b)~="string"then -error("bad argument #1 (expected string, got "..type(b_b)..")")end;local c_b={}for d_b in -(b_b.."\n"):gmatch("(.-)\n")do dba(c_b,d_b)end;return c_b end;local _ca=""for y=1,#ad do -if(y==#ad)then _ca=_ca..ad[y]else _ca=_ca..ad[y].."\n"end end;local aca=parseImage(_ca) -local bca={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local cca,dca,_da={},{},{}for i=0,15 do dca[2 ^i]=i end -do local b_b="0123456789abcdef" -for i=1,16 do cca[b_b:sub(i,i)]= -i-1;cca[i-1]=b_b:sub(i,i) -_da[b_b:sub(i,i)]=2 ^ (i-1)_da[2 ^ (i-1)]=b_b:sub(i,i)local c_b=bca[i-1]for i=1,#c_b do -c_b[i]=2 ^c_b[i]end end end -local function ada(b_b)local c_b=bca[dca[b_b[#b_b][1] ] ] -for j=1,#c_b do local d_b=c_b[j]for i=1, -#b_b-1 do if b_b[i][1]==d_b then return i end end end;return 1 end -local function bda(b_b,c_b) -if not c_b then local _ab={}c_b={}for i=1,6 do local aab=b_b[i]local bab=c_b[aab] -c_b[aab],_ab[i]=bab and(bab+1)or 1,aab end;b_b=_ab end;local d_b={}for _ab,aab in pairs(c_b)do d_b[#d_b+1]={_ab,aab}end -if# -d_b>1 then -while#d_b>2 do -table.sort(d_b,function(_bb,abb)return _bb[2]>abb[2]end)local aab,bab=ada(d_b),#d_b;local cab,dab=d_b[bab][1],d_b[aab][1]for i=1,6 do -if b_b[i]== -cab then b_b[i]=dab;d_b[aab][2]=d_b[aab][2]+1 end end;d_b[bab]=nil end;local _ab=128;for i=1,#b_b-1 do -if b_b[i]~=b_b[6]then _ab=_ab+2 ^ (i-1)end end;return string.char(_ab),_da[d_b[1][1]==b_b[6]and -d_b[2][1]or d_b[1][1] ], -_da[b_b[6] ]else -return"\128",_da[b_b[1] ],_da[b_b[1] ]end end -local cda,dda,__b,a_b={{},{},{}},0,#aca+#aca%3,cc.bgColor or colors.black -for i=1,#aca do if#aca[i]>dda then dda=#aca[i]end end -for y=0,__b-1,3 do local b_b,c_b,d_b,_ab={},{},{},1 -for x=0,dda-1,2 do local aab,bab={},{} -for yy=1,3 do -for xx=1,2 do -aab[#aab+1]= -(aca[y+yy]and aca[y+yy][ -x+xx])and(aca[y+yy][x+xx]==0 and a_b or aca[y+yy][ -x+xx])or a_b;bab[aab[#aab] ]= -bab[aab[#aab] ]and(bab[aab[#aab] ]+1)or 1 end end;b_b[_ab],c_b[_ab],d_b[_ab]=bda(aab,bab)_ab=_ab+1 end -cda[1][#cda[1]+1],cda[2][#cda[2]+1],cda[3][#cda[3]+1]=table.concat(b_b),table.concat(c_b),table.concat(d_b)end;cda.width,cda.height=#cda[1][1],#cda[1]bd=cda end -local function bba()local dba,_ca=d_a,_aa;if(cd)then dba=dba*2;_ca=_ca*3 end;for aca,bca in pairs(_d)do -for cca,dca in -pairs(bca[1])do daa(dca.x,dca.y,dba,_ca,bca[2])end end;if(cd)then aba()end end -local cba={init=function(dba)dba.bgColor=dba.parent:getTheme("GraphicBG")end,getType=function(dba)return -dc end,setSize=function(dba,_ca,aca,bca)cc.setSize(dba,_ca,aca,bca)if not(aaa)then d_a=_ca -_aa=aca;_ba()end;bba()return dba end,setOffset=function(dba,_ca,aca)dd= -_ca or dd;__a=aca or __a;return dba end,setCanvasSize=function(dba,_ca,aca) -d_a,_aa=_ca,aca;aaa=true;_ba()return dba end,clearCanvas=function(dba)_d={}ad={}_ba()end,getOffset=function(dba)return -dd,__a end,setValuesByXMLData=function(dba,_ca)cc.setValuesByXMLData(dba,_ca) -if( -bb("text",_ca)~=nil)then dba:setText(bb("text",_ca))end;if(bb("xOffset",_ca)~=nil)then -dba:setOffset(bb("xOffset",_ca),__a)end;if(bb("yOffset",_ca)~=nil)then -dba:setOffset(dd,bb("yOffset",_ca))end;if(bb("wCanvas",_ca)~=nil)then -d_a=bb("wCanvas",_ca)end;if(bb("hCanvas",_ca)~=nil)then -_aa=bb("hCanvas",_ca)end;if(bb("shrink",_ca)~=nil)then if(bb("shrink",_ca))then -dba:shrink()end end -if -(bb("dragable",_ca)~=nil)then if(bb("dragable",_ca))then a_a=true end end -if(_ca["ellipse"]~=nil)then local aca=_ca["ellipse"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=bb("radius",cca)local ada=bb("radius2",cca)local bda=bb("x",cca)local cda=bb("y",cca) -local dda=bb("filled",cca)dba:addEllipse(dca,_da,ada,bda,cda,dda)end end -if(_ca["circle"]~=nil)then local aca=_ca["circle"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("radius",cca))local ada=tonumber(bb("x",cca)) -local bda=tonumber(bb("y",cca))local cda=bb("filled",cca) -dba:addCircle(dca,_da,ada,bda,cda)end end -if(_ca["line"]~=nil)then local aca=_ca["line"] -if(aca.properties~=nil)then aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("x",cca))local ada=tonumber(bb("x2",cca)) -local bda=tonumber(bb("y",cca))local cda=tonumber(bb("y2",cca)) -dba:addLine(dca,_da,bda,ada,cda)end end -if(_ca["rectangle"]~=nil)then local aca=_ca["rectangle"]if -(aca.properties~=nil)then aca={aca}end -for bca,cca in pairs(aca)do -local dca=colors[bb("color",cca)]local _da=tonumber(bb("x",cca)) -local ada=tonumber(bb("x2",cca))local bda=tonumber(bb("y",cca)) -local cda=tonumber(bb("y2",cca)) -local dda=bb("filled",cca)=="true"and true or false;dba:addRectangle(dca,_da,bda,ada,cda,dda)end end -if(_ca["triangle"]~=nil)then local aca=_ca["triangle"]if(aca.properties~=nil)then -aca={aca}end -for bca,cca in pairs(aca)do local dca=colors[bb("color",cca)] -local _da=tonumber(bb("x",cca))local ada=tonumber(bb("x2",cca)) -local bda=tonumber(bb("x2",cca))local cda=tonumber(bb("y",cca)) -local dda=tonumber(bb("y2",cca))local __b=tonumber(bb("y3",cca))local a_b=bb("filled",cca) -dba:addTriangle(dca,_da,cda,ada,dda,bda,__b,a_b)end end;return dba end,addCircle=function(dba,_ca,aca,bca,cca,dca) -local _da=ab[_ca] -table.insert(_d,{_b.circle(bca or 1,cca or 1,aca,dca),ab[_ca]})bba()return dba end,addEllipse=function(dba,_ca,aca,bca,cca,dca,_da) -table.insert(_d,{_b.ellipse( -cca or 1,dca or 1,aca,bca,_da),ab[_ca]})bba()return dba end,addLine=function(dba,_ca,aca,bca,cca,dca) -table.insert(_d,{_b.line( -aca or 1,bca or 1,cca or 1,dca or 1),ab[_ca]})bba()return dba end,addTriangle=function(dba,_ca,aca,bca,cca,dca,_da,ada,bda) -table.insert(_d,{_b.triangle( -aca or 1,bca or 1,cca or 1,dca or 1,_da or 1,ada or 1,bda),ab[_ca]})bba()return dba end,addRectangle=function(dba,_ca,aca,bca,cca,dca,_da) -table.insert(_d,{_b.rectangle( -aca or 1,bca or 1,cca or 1,dca or 1,_da),ab[_ca]})bba()return dba end,shrink=function(dba) -cd=true;_ba()aba()return dba end,setDragable=function(dba,_ca) -a_a=_ca==true and true or false;return dba end,mouseHandler=function(dba,_ca,aca,bca,cca) -if(cc.mouseHandler(dba,_ca,aca,bca,cca))then -if -(a_a)then if(_ca=="mouse_click")then b_a,c_a=bca,cca end -if(_ca=="mouse_drag")then if -(b_a~=nil)and(c_a~=nil)then -dd=_c(ac(dd+b_a-bca,d_a-dba:getWidth()),0)b_a=bca -__a=_c(ac(__a+c_a-cca,_aa-dba:getHeight()),0)c_a=cca end end end;return true end;return false end,draw=function(dba) -if -(cc.draw(dba))then -if(dba.parent~=nil)then local _ca,aca=dba:getAnchorPosition() -local bca,cca=dba:getSize()if(dba.bgColor~=false)then -dba.parent:drawBackgroundBox(_ca,aca,bca,cca,dba.bgColor)end -if(cd)then local dca,_da,ada=bd[1],bd[2],bd[3] -for i=1,bd.height -do local bda,cda=_ca+dd,aca+i-1 +__a -if -(cda>aca-1)and(cda<=aca+cca-1)and(bda<=bca+_ca)then local dda=dca[i]local __b,a_b,b_b=_c(bda,_ca),_c(1 -bda+1,1),ac( -bca- (bda-_ca),bca) -if -type(dda)=="string"then dba.parent:setText(__b,cda,cb(dda,a_b,b_b)) -dba.parent:setFG(__b,cda,cb(_da[i],a_b,b_b)) -dba.parent:setBG(__b,cda,cb(ada[i],a_b,b_b))elseif type(dda)=="table"then -dba.parent:setText(__b,cda,cb(dda[2],a_b,b_b)) -dba.parent:setFG(__b,cda,cb(_da[i],a_b,b_b)) -dba.parent:setBG(__b,cda,cb(ada[i],a_b,b_b))end end end else -for i=1,#ad do local dca,_da=_ca+dd,aca+i-1 +__a -if -(_da>aca-1)and(_da<=aca+cca-1)and(dca<=bca+_ca)then local ada,bda,cda=_c(dca,_ca),_c(1 -dca+1,1),ac(bca- -(dca-_ca),bca) -dba.parent:setBG(ada,_da,cb(ad[i],bda,cda))end end end end;dba:setVisualChanged(false)end end}return setmetatable(cba,cc)end -end; -project['objects']['Image'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Image"aa:setZIndex(2)local ca;local da;local _b=false -local function ab() -local cb={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local db,_c,ac={},{},{}for i=0,15 do _c[2 ^i]=i end -do local cd="0123456789abcdef" -for i=1,16 do db[cd:sub(i,i)]= -i-1;db[i-1]=cd:sub(i,i) -ac[cd:sub(i,i)]=2 ^ (i-1)ac[2 ^ (i-1)]=cd:sub(i,i)local dd=cb[i-1]for i=1,#dd do -dd[i]=2 ^dd[i]end end end -local function bc(cd)local dd=cb[_c[cd[#cd][1] ] ] -for j=1,#dd do local __a=dd[j]for i=1,#cd-1 do if -cd[i][1]==__a then return i end end end;return 1 end -local function cc(cd,dd) -if not dd then local a_a={}dd={}for i=1,6 do local b_a=cd[i]local c_a=dd[b_a] -dd[b_a],a_a[i]=c_a and(c_a+1)or 1,b_a end;cd=a_a end;local __a={}for a_a,b_a in pairs(dd)do __a[#__a+1]={a_a,b_a}end -if -#__a>1 then -while#__a>2 do -table.sort(__a,function(aaa,baa)return aaa[2]>baa[2]end)local b_a,c_a=bc(__a),#__a;local d_a,_aa=__a[c_a][1],__a[b_a][1]for i=1,6 do -if -cd[i]==d_a then cd[i]=_aa;__a[b_a][2]=__a[b_a][2]+1 end end;__a[c_a]=nil end;local a_a=128 -for i=1,#cd-1 do if cd[i]~=cd[6]then a_a=a_a+2 ^ (i-1)end end -return string.char(a_a),ac[__a[1][1]==cd[6]and __a[2][1]or -__a[1][1] ],ac[cd[6] ]else return"\128",ac[cd[1] ],ac[cd[1] ]end end -local dc,_d,ad,bd={{},{},{}},0,#ca+#ca%3,aa.bgColor or colors.black;for i=1,#ca do if#ca[i]>_d then _d=#ca[i]end end -for y=0,ad-1,3 do -local cd,dd,__a,a_a={},{},{},1 -for x=0,_d-1,2 do local b_a,c_a={},{} -for yy=1,3 do -for xx=1,2 do -b_a[#b_a+1]=(ca[y+yy]and ca[y+yy][x+xx])and -(ca[y+ -yy][x+xx]==0 and bd or ca[y+yy][x+xx])or bd;c_a[b_a[#b_a] ]= -c_a[b_a[#b_a] ]and(c_a[b_a[#b_a] ]+1)or 1 end end;cd[a_a],dd[a_a],__a[a_a]=cc(b_a,c_a)a_a=a_a+1 end -dc[1][#dc[1]+1],dc[2][#dc[2]+1],dc[3][#dc[3]+1]=table.concat(cd),table.concat(dd),table.concat(__a)end;dc.width,dc.height=#dc[1][1],#dc[1]da=dc end -local bb={init=function(cb)cb.bgColor=cb.parent:getTheme("ImageBG")end,getType=function(cb)return -ba end,loadImage=function(cb,db)ca=paintutils.loadImage(db)_b=false -cb:updateDraw()return cb end,shrink=function(cb)ab()_b=true -cb:updateDraw()return cb end,setValuesByXMLData=function(cb,db)aa.setValuesByXMLData(cb,db) -if( -d("shrink",db)~=nil)then if(d("shrink",db))then cb:shrink()end end -if(d("path",db)~=nil)then cb:loadImage(d("path",db))end;return cb end,draw=function(cb) -if -(aa.draw(cb))then -if(cb.parent~=nil)then -if(ca~=nil)then local db,_c=cb:getAnchorPosition() -local ac,bc=cb:getSize() -if(_b)then local cc,dc,_d=da[1],da[2],da[3] -for i=1,da.height do local ad=cc[i] -if type(ad)=="string"then cb.parent:setText(db, -_c+i-1,ad) -cb.parent:setFG(db,_c+i-1,dc[i])cb.parent:setBG(db,_c+i-1,_d[i])elseif -type(ad)=="table"then cb.parent:setText(db,_c+i-1,ad[2])cb.parent:setFG(db,_c+ -i-1,dc[i]) -cb.parent:setBG(db,_c+i-1,_d[i])end end else -for yPos=1,math.min(#ca,bc)do local cc=ca[yPos] -for xPos=1,math.min(#cc,ac)do if cc[xPos]>0 then -cb.parent:drawBackgroundBox( -db+xPos-1,_c+yPos-1,1,1,cc[xPos])end end end end end end end end}return setmetatable(bb,aa)end -end; -project['objects']['Input'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=require("basaltLogs")local ca=aa.getValueFromXML -return -function(da)local _b=_a(da)local ab="Input"local bb="text"local cb=0 -_b:setZIndex(5)_b:setValue("")_b.width=10;_b.height=1;local db=1;local _c=1;local ac=""local bc;local cc -local dc=ac;local _d=false -local ad={getType=function(bd)return ab end,setInputType=function(bd,cd)if(cd=="password")or(cd=="number")or -(cd=="text")then bb=cd end -bd:updateDraw()return bd end,setDefaultText=function(bd,cd,dd,__a)ac=cd -bc=__a or bc;cc=dd or cc;if(bd:isFocused())then dc=""else dc=ac end -bd:updateDraw()return bd end,getInputType=function(bd)return bb end,setValue=function(bd,cd) -_b.setValue(bd,tostring(cd)) -if not(_d)then -if(bd:isFocused())then db=tostring(cd):len()+1;_c=math.max(1, -db-bd:getWidth()+1) -local dd,__a=bd:getAnchorPosition() -bd.parent:setCursor(true,dd+db-_c,__a+math.floor(bd:getHeight()/2),bd.fgColor)end end;bd:updateDraw()return bd end,getValue=function(bd) -local cd=_b.getValue(bd)return bb=="number"and tonumber(cd)or cd end,setInputLimit=function(bd,cd)cb= -tonumber(cd)or cb;bd:updateDraw()return bd end,getInputLimit=function(bd)return -cb end,setValuesByXMLData=function(bd,cd)_b.setValuesByXMLData(bd,cd)local dd,__a;if( -ca("defaultBG",cd)~=nil)then dd=ca("defaultBG",cd)end;if( -ca("defaultFG",cd)~=nil)then __a=ca("defaultFG",cd)end;if( -ca("default",cd)~=nil)then -bd:setDefaultText(ca("default",cd),__a~=nil and colors[__a],dd~=nil and -colors[dd])end -if -(ca("limit",cd)~=nil)then bd:setInputLimit(ca("limit",cd))end -if(ca("type",cd)~=nil)then bd:setInputType(ca("type",cd))end;return bd end,getFocusHandler=function(bd) -_b.getFocusHandler(bd) -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition()dc=""if(ac~="")then -bd:updateDraw()end -bd.parent:setCursor(true,cd+db-_c,dd+math.max(math.ceil( -bd:getHeight()/2 -1,1)),bd.fgColor)end end,loseFocusHandler=function(bd) -_b.loseFocusHandler(bd)if(bd.parent~=nil)then dc=ac;if(ac~="")then bd:updateDraw()end -bd.parent:setCursor(false)end end,keyHandler=function(bd,cd) -if -(_b.keyHandler(bd,cd))then local dd,__a=bd:getSize()_d=true -if(cd==keys.backspace)then -local aaa=tostring(_b.getValue())if(db>1)then -bd:setValue(aaa:sub(1,db-2)..aaa:sub(db,aaa:len()))if(db>1)then db=db-1 end -if(_c>1)then if(db<_c)then _c=_c-1 end end end end;if(cd==keys.enter)then if(bd.parent~=nil)then end end -if(cd== -keys.right)then -local aaa=tostring(_b.getValue()):len()db=db+1;if(db>aaa)then db=aaa+1 end;if(db<1)then db=1 end;if -(db<_c)or(db>=dd+_c)then _c=db-dd+1 end;if(_c<1)then _c=1 end end -if(cd==keys.left)then db=db-1;if(db>=1)then -if(db<_c)or(db>=dd+_c)then _c=db end end;if(db<1)then db=1 end;if(_c<1)then _c=1 end end;local a_a,b_a=bd:getAnchorPosition() -local c_a=tostring(_b.getValue()) -local d_a=(db<=c_a:len()and db-1 or c_a:len())- (_c-1)local _aa=bd:getX()if(d_a>_aa+dd-1)then d_a=_aa+dd-1 end;if( -bd.parent~=nil)then -bd.parent:setCursor(true,a_a+d_a,b_a+ -math.max(math.ceil(__a/2 -1,1)),bd.fgColor)end -bd:updateDraw()_d=false;return true end;return false end,charHandler=function(bd,cd) -if -(_b.charHandler(bd,cd))then _d=true;local dd,__a=bd:getSize()local a_a=_b.getValue() -if(a_a:len()=dd+_c)then _c=_c+1 end end;local b_a,c_a=bd:getAnchorPosition() -local d_a=tostring(_b.getValue()) -local _aa=(db<=d_a:len()and db-1 or d_a:len())- (_c-1)local aaa=bd:getX()if(_aa>aaa+dd-1)then _aa=aaa+dd-1 end;if( -bd.parent~=nil)then -bd.parent:setCursor(true,b_a+_aa,c_a+ -math.max(math.ceil(__a/2 -1,1)),bd.fgColor)end;_d=false -bd:updateDraw()return true end;return false end,mouseHandler=function(bd,cd,dd,__a) -if -(_b.mouseHandler(bd,cd,dd,__a))then local a_a,b_a=bd:getAnchorPosition() -local c_a,d_a=bd:getAbsolutePosition(a_a,b_a)local _aa,aaa=bd:getSize()db=dd-c_a+_c;local baa=_b.getValue()if(db> -baa:len())then db=baa:len()+1 end;if(db<_c)then _c=db-1 -if(_c<1)then _c=1 end end -bd.parent:setCursor(true,a_a+db-_c,b_a+ -math.max(math.ceil(aaa/2 -1,1)),bd.fgColor)return true end end,dragHandler=function(bd,cd,dd,__a,a_a,b_a) -if -(bd:isFocused())then if(bd:isCoordsInObject(dd,__a))then -if(_b.dragHandler(bd,cd,dd,__a,a_a,b_a))then return true end end -bd.parent:removeFocusedObject()end end,eventHandler=function(bd,cd,dd,__a,a_a,b_a) -if -(_b.eventHandler(bd,cd,dd,__a,a_a,b_a))then -if(cd=="paste")then -if(bd:isFocused())then local c_a=_b.getValue() -local d_a,_aa=bd:getSize()_d=true -if(bb=="number")then local aba=c_a -if(dd==".")or(tonumber(dd)~=nil)then -bd:setValue(c_a:sub(1, -db-1)..dd..c_a:sub(db,c_a:len()))db=db+dd:len()end -if(tonumber(_b.getValue())==nil)then bd:setValue(aba)end else -bd:setValue(c_a:sub(1,db-1)..dd..c_a:sub(db,c_a:len()))db=db+dd:len()end;if(db>=d_a+_c)then _c=(db+1)-d_a end -local aaa,baa=bd:getAnchorPosition()local caa=tostring(_b.getValue()) -local daa=( -db<=caa:len()and db-1 or caa:len())- (_c-1)local _ba=bd:getX() -if(daa>_ba+d_a-1)then daa=_ba+d_a-1 end;if(bd.parent~=nil)then -bd.parent:setCursor(true,aaa+daa,baa+ -math.max(math.ceil(_aa/2 -1,1)),bd.fgColor)end -bd:updateDraw()_d=false end end end end,draw=function(bd) -if -(_b.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()local b_a=aa.getTextVerticalAlign(a_a,"center")if -(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end -for n=1,a_a do -if(n==b_a)then -local c_a=tostring(_b.getValue())local d_a=bd.bgColor;local _aa=bd.fgColor;local aaa;if(c_a:len()<=0)then aaa=dc;d_a=bc or d_a;_aa= -cc or _aa end;aaa=dc -if(c_a~="")then aaa=c_a end;aaa=aaa:sub(_c,__a+_c-1)local baa=__a-aaa:len()if(baa<0)then -baa=0 end;if(bb=="password")and(c_a~="")then -aaa=string.rep("*",aaa:len())end -aaa=aaa..string.rep(bd.bgSymbol,baa)bd.parent:writeText(cd,dd+ (n-1),aaa,d_a,_aa)end end;if(bd:isFocused())then -bd.parent:setCursor(true,cd+db-_c,dd+ -math.floor(bd:getHeight()/2),bd.fgColor)end end end end,init=function(bd) -bd.bgColor=bd.parent:getTheme("InputBG")bd.fgColor=bd.parent:getTheme("InputText") -if -(bd.parent~=nil)then bd.parent:addEvent("mouse_click",bd) -bd.parent:addEvent("key",bd)bd.parent:addEvent("char",bd) -bd.parent:addEvent("other_event",bd)bd.parent:addEvent("mouse_drag",bd)end end}return setmetatable(ad,_b)end -end; -project['objects']['Label'] = function(...)local ba=require("Object")local ca=require("utils") -local da=ca.getValueFromXML;local _b=ca.createText;local ab=require("tHex")local bb=require("bigfont") -return -function(cb) -local db=ba(cb)local _c="Label"db:setZIndex(3)local ac=true;db:setValue("Label") -db.width=5;local bc="left"local cc="top"local dc=0;local _d,ad=false,false -local bd={getType=function(cd)return _c end,setText=function(cd,dd) -dd=tostring(dd)db:setValue(dd)if(ac)then cd.width=dd:len()end -cd:updateDraw()return cd end,setBackground=function(cd,dd) -db.setBackground(cd,dd)ad=true;cd:updateDraw()return cd end,setForeground=function(cd,dd) -db.setForeground(cd,dd)_d=true;cd:updateDraw()return cd end,setTextAlign=function(cd,dd,__a) -bc=dd or bc;cc=__a or cc;cd:updateDraw()return cd end,setFontSize=function(cd,dd)if( -dd>0)and(dd<=4)then dc=dd-1 or 0 end -cd:updateDraw()return cd end,getFontSize=function(cd)return dc+1 end,setValuesByXMLData=function(cd,dd) -db.setValuesByXMLData(cd,dd) -if(da("text",dd)~=nil)then cd:setText(da("text",dd))end -if(da("verticalAlign",dd)~=nil)then cc=da("verticalAlign",dd)end;if(da("horizontalAlign",dd)~=nil)then -bc=da("horizontalAlign",dd)end;if(da("font",dd)~=nil)then -cd:setFontSize(da("font",dd))end;return cd end,setSize=function(cd,dd,__a,a_a) -db.setSize(cd,dd,__a,a_a)ac=false;cd:updateDraw()return cd end,draw=function(cd) -if -(db.draw(cd))then -if(cd.parent~=nil)then local dd,__a=cd:getAnchorPosition() -local a_a,b_a=cd:getSize()local c_a=ca.getTextVerticalAlign(b_a,cc) -if(dc==0)then -if not(ac)then -local d_a=_b(cd:getValue(),cd:getWidth())for _aa,aaa in pairs(d_a)do -cd.parent:writeText(dd,__a+_aa-1,aaa,cd.bgColor,cd.fgColor)end else -cd.parent:writeText(dd,__a,cd:getValue(),cd.bgColor,cd.fgColor)end else -local d_a=bb(dc,cd:getValue(),cd.fgColor,cd.bgColor or colors.lightGray) -if(ac)then cd:setSize(#d_a[1][1],#d_a[1]-1)end;local _aa,aaa=cd.parent:getSize() -local baa,caa=#d_a[1][1],#d_a[1] -dd=dd or math.floor((_aa-baa)/2)+1 -__a=__a or math.floor((aaa-caa)/2)+1 -for i=1,caa do cd.parent:setFG(dd,__a+i-2,d_a[2][i])cd.parent:setBG(dd, -__a+i-2,d_a[3][i])cd.parent:setText(dd, -__a+i-2,d_a[1][i])end end end end end,init=function(cd) -if -(db.init(cd))then cd.bgColor=cd.parent:getTheme("LabelBG") -cd.fgColor=cd.parent:getTheme("LabelText") -if -(cd.parent.bgColor==colors.black)and(cd.fgColor==colors.black)then cd.fgColor=colors.lightGray end end end}return setmetatable(bd,db)end -end; -project['objects']['List'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="List"ca.width=16;ca.height=6;ca:setZIndex(5)local _b={} -local ab;local bb;local cb=true;local db="left"local _c=0;local ac=true -local bc={getType=function(cc)return da end,addItem=function(cc,dc,_d,ad,...) -table.insert(_b,{text=dc,bgCol=_d or cc.bgColor,fgCol= -ad or cc.fgColor,args={...}})if(#_b==1)then cc:setValue(_b[1])end -cc:updateDraw()return cc end,setOffset=function(cc,dc) -_c=dc;cc:updateDraw()return cc end,getOffset=function(cc)return _c end,removeItem=function(cc,dc) -table.remove(_b,dc)cc:updateDraw()return cc end,getItem=function(cc,dc)return _b[dc]end,getAll=function(cc)return -_b end,getItemIndex=function(cc)local dc=cc:getValue() -for _d,ad in pairs(_b)do if(ad==dc)then return _d end end end,clear=function(cc)_b={}cc:setValue({}) -cc:updateDraw()return cc end,getItemCount=function(cc)return#_b end,editItem=function(cc,dc,_d,ad,bd,...) -table.remove(_b,dc) -table.insert(_b,dc,{text=_d,bgCol=ad or cc.bgColor,fgCol=bd or cc.fgColor,args={...}})cc:updateDraw()return cc end,selectItem=function(cc,dc)cc:setValue( -_b[dc]or{})cc:updateDraw()return cc end,setSelectedItem=function(cc,dc,_d,ad)ab= -dc or cc.bgColor;bb=_d or cc.fgColor -cb=ad~=nil and ad or true;cc:updateDraw()return cc end,setScrollable=function(cc,dc) -ac=dc;if(dc==nil)then ac=true end;cc:updateDraw()return cc end,setValuesByXMLData=function(cc,dc) -ca.setValuesByXMLData(cc,dc)if(aa("selectionBG",dc)~=nil)then -ab=colors[aa("selectionBG",dc)]end;if(aa("selectionFG",dc)~=nil)then -bb=colors[aa("selectionFG",dc)]end;if(aa("scrollable",dc)~=nil)then -if -(aa("scrollable",dc))then cc:setScrollable(true)else cc:setScrollable(false)end end;if -(aa("offset",dc)~=nil)then _c=aa("offset",dc)end -if(dc["item"]~=nil)then -local _d=dc["item"]if(_d.properties~=nil)then _d={_d}end;for ad,bd in pairs(_d)do -cc:addItem(aa("text",bd),colors[aa("bg",bd)],colors[aa("fg",bd)])end end;return cc end,scrollHandler=function(cc,dc,_d,ad) -if -(ca.scrollHandler(cc,dc,_d,ad))then -if(ac)then local bd,cd=cc:getSize()_c=_c+dc;if(_c<0)then _c=0 end;if(dc>=1)then -if(#_b>cd)then if -(_c>#_b-cd)then _c=#_b-cd end;if(_c>=#_b)then _c=#_b-1 end else _c=_c-1 end end -cc:updateDraw()end;return true end;return false end,mouseHandler=function(cc,dc,_d,ad) -if -(ca.mouseHandler(cc,dc,_d,ad))then -local bd,cd=cc:getAbsolutePosition(cc:getAnchorPosition())local dd,__a=cc:getSize() -if(#_b>0)then for n=1,__a do -if(_b[n+_c]~=nil)then if -(bd<=_d)and(bd+dd>_d)and(cd+n-1 ==ad)then cc:setValue(_b[n+_c]) -cc:updateDraw()end end end end;return true end;return false end,dragHandler=function(cc,dc,_d,ad)return -cc:mouseHandler(dc,_d,ad)end,touchHandler=function(cc,dc,_d) -return cc:mouseHandler(1,dc,_d)end,draw=function(cc) -if(ca.draw(cc))then -if(cc.parent~=nil)then -local dc,_d=cc:getAnchorPosition()local ad,bd=cc:getSize()if(cc.bgColor~=false)then -cc.parent:drawBackgroundBox(dc,_d,ad,bd,cc.bgColor)end -for n=1,bd do -if(_b[n+_c]~=nil)then -if(_b[n+_c]== -cc:getValue())then -if(cb)then -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),ab,bb)else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end end end end end end,init=function(cc) -cc.bgColor=cc.parent:getTheme("ListBG")cc.fgColor=cc.parent:getTheme("ListText") -ab=cc.parent:getTheme("SelectionBG")bb=cc.parent:getTheme("SelectionText") -cc.parent:addEvent("mouse_click",cc)cc.parent:addEvent("mouse_drag",cc) -cc.parent:addEvent("mouse_scroll",cc)end}return setmetatable(bc,ca)end -end; -project['objects']['Menubar'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=aa.getValueFromXML;local ca=require("tHex") -return -function(da)local _b=_a(da)local ab="Menubar"local bb={}_b.width=30 -_b.height=1;_b:setZIndex(5)local cb={}local db;local _c;local ac=true;local bc="left"local cc=0;local dc=1 -local _d=false -local function ad()local bd=0;local cd=0;local dd=bb:getWidth() -for n=1,#cb do if(cd+cb[n].text:len()+ -dc*2 >dd)then -if(cddd)then cc=dd end;bd:updateDraw() -return bd end,getOffset=function(bd)return cc end,setScrollable=function(bd,cd) -_d=cd;if(cd==nil)then _d=true end;return bd end,setValuesByXMLData=function(bd,cd) -_b.setValuesByXMLData(bd,cd)if(ba("selectionBG",cd)~=nil)then -db=colors[ba("selectionBG",cd)]end;if(ba("selectionFG",cd)~=nil)then -_c=colors[ba("selectionFG",cd)]end;if(ba("scrollable",cd)~=nil)then -if -(ba("scrollable",cd))then bd:setScrollable(true)else bd:setScrollable(false)end end -if -(ba("offset",cd)~=nil)then bd:setOffset(ba("offset",cd))end;if(ba("space",cd)~=nil)then dc=ba("space",cd)end -if( -cd["item"]~=nil)then local dd=cd["item"]if(dd.properties~=nil)then dd={dd}end;for __a,a_a in -pairs(dd)do -bd:addItem(ba("text",a_a),colors[ba("bg",a_a)],colors[ba("fg",a_a)])end end;return bd end,removeItem=function(bd,cd) -table.remove(cb,cd)bd:updateDraw()return bd end,getItem=function(bd,cd)return cb[cd]end,getItemCount=function(bd)return -#cb end,editItem=function(bd,cd,dd,__a,a_a,...)table.remove(cb,cd) -table.insert(cb,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol= -a_a or bd.fgColor,args={...}})bd:updateDraw()return bd end,selectItem=function(bd,cd)bd:setValue( -cb[cd]or{})bd:updateDraw()return bd end,setSelectedItem=function(bd,cd,dd,__a)db= -cd or bd.bgColor;_c=dd or bd.fgColor;ac=__a -bd:updateDraw()return bd end,mouseHandler=function(bd,cd,dd,__a) -if -(_b.mouseHandler(bd,cd,dd,__a))then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition())local c_a,d_a=bd:getSize()local _aa=0 -for n=1,#cb do -if(cb[n]~=nil)then -if -(a_a+_aa<=dd+cc)and(a_a+_aa+ -cb[n].text:len()+ (dc*2)>dd+cc)and(b_a==__a)then bd:setValue(cb[n]) -bd:getEventSystem():sendEvent(event,bd,event,0,dd,__a,cb[n])end;_aa=_aa+cb[n].text:len()+dc*2 end end;bd:updateDraw()return true end;return false end,scrollHandler=function(bd,cd,dd,__a) -if -(_b.scrollHandler(bd,cd,dd,__a))then if(_d)then cc=cc+cd;if(cc<0)then cc=0 end;local a_a=ad()if(cc>a_a)then cc=a_a end -bd:updateDraw()end;return true end;return false end,draw=function(bd) -if -(_b.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=""local c_a=""local d_a="" -for _aa,aaa in pairs(cb)do -local baa= -(" "):rep(dc)..aaa.text.. (" "):rep(dc)b_a=b_a..baa -if(aaa==bd:getValue())then c_a=c_a.. -ca[db or aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[_c or aaa.FgCol or -bd.fgColor]:rep(baa:len())else c_a=c_a.. -ca[aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[aaa.FgCol or bd.fgColor]:rep(baa:len())end end -bd.parent:setText(cd,dd,b_a:sub(cc+1,__a+cc)) -bd.parent:setBG(cd,dd,c_a:sub(cc+1,__a+cc)) -bd.parent:setFG(cd,dd,d_a:sub(cc+1,__a+cc))end end end,init=function(bd) -bd.bgColor=bd.parent:getTheme("MenubarBG")bd.fgColor=bd.parent:getTheme("MenubarText") -db=bd.parent:getTheme("SelectionBG")_c=bd.parent:getTheme("SelectionText") -bd.parent:addEvent("mouse_click",bd)bd.parent:addEvent("mouse_scroll",bd)end}return setmetatable(bb,_b)end -end; -project['objects']['Pane'] = function(...)local c=require("Object")local d=require("basaltLogs") -return -function(_a)local aa=c(_a) -local ba="Pane" -local ca={getType=function(da)return ba end,setBackground=function(da,_b,ab,bb)aa.setBackground(da,_b,ab,bb)return da end,init=function(da)if -(aa.init(da))then da.bgColor=da.parent:getTheme("PaneBG") -da.fgColor=da.parent:getTheme("PaneBG")end end}return setmetatable(ca,aa)end -end; -project['objects']['Program'] = function(...)local ba=require("Object")local ca=require("tHex") -local da=require("process")local _b=require("utils").getValueFromXML -local ab=require("basaltLogs")local bb=string.sub -return -function(cb,db)local _c=ba(cb)local ac="Program"_c:setZIndex(5)local bc;local cc -local function dc(b_a,c_a,d_a,_aa,aaa) -local baa,caa=1,1;local daa,_ba=colors.black,colors.white;local aba=false;local bba=false;local cba={}local dba={} -local _ca={}local aca={}local bca;local cca={}for i=0,15 do local aab=2 ^i -aca[aab]={db:getBasaltInstance().getBaseTerm().getPaletteColour(aab)}end;local function dca() -bca=(" "):rep(d_a) -for n=0,15 do local aab=2 ^n;local bab=ca[aab]cca[aab]=bab:rep(d_a)end end -local function _da()dca()local aab=bca -local bab=cca[colors.white]local cab=cca[colors.black] -for n=1,_aa do -cba[n]=bb(cba[n]==nil and aab or cba[n]..aab:sub(1, -d_a-cba[n]:len()),1,d_a) -_ca[n]=bb(_ca[n]==nil and bab or _ca[n].. -bab:sub(1,d_a-_ca[n]:len()),1,d_a) -dba[n]=bb(dba[n]==nil and cab or dba[n].. -cab:sub(1,d_a-dba[n]:len()),1,d_a)end;_c.updateDraw(_c)end;_da()local function ada()if -baa>=1 and caa>=1 and baa<=d_a and caa<=_aa then else end end -local function bda(aab,bab,cab) -local dab=baa;local _bb=dab+#aab-1 -if caa>=1 and caa<=_aa then -if dab<=d_a and _bb>=1 then -if dab==1 and _bb== -d_a then cba[caa]=aab;_ca[caa]=bab;dba[caa]=cab else local abb,bbb,cbb -if dab<1 then local _db= -1 -dab+1;local adb=d_a-dab+1;abb=bb(aab,_db,adb) -bbb=bb(bab,_db,adb)cbb=bb(cab,_db,adb)elseif _bb>d_a then local _db=d_a-dab+1;abb=bb(aab,1,_db) -bbb=bb(bab,1,_db)cbb=bb(cab,1,_db)else abb=aab;bbb=bab;cbb=cab end;local dbb=cba[caa]local _cb=_ca[caa]local acb=dba[caa]local bcb,ccb,dcb -if dab>1 then local _db=dab-1;bcb= -bb(dbb,1,_db)..abb;ccb=bb(_cb,1,_db)..bbb -dcb=bb(acb,1,_db)..cbb else bcb=abb;ccb=bbb;dcb=cbb end -if _bb=1 and _bb<=_aa then -cba[newY]=cba[_bb]dba[newY]=dba[_bb]_ca[newY]=_ca[_bb]else cba[newY]=bab -_ca[newY]=cab;dba[newY]=dab end end end;if(bba)then ada()end end,isColor=function()return -db:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return -db:getBasaltInstance().getBaseTerm().isColor()end,write=function(aab) -aab=tostring(aab)if(bba)then -bda(aab,ca[_ba]:rep(aab:len()),ca[daa]:rep(aab:len()))end end,clearLine=function() -if -(bba)then cda(1,caa,(" "):rep(d_a)) -dda(1,caa,ca[daa]:rep(d_a))__b(1,caa,ca[_ba]:rep(d_a))end;if(bba)then ada()end end,clear=function() -for n=1,_aa -do cda(1,n,(" "):rep(d_a)) -dda(1,n,ca[daa]:rep(d_a))__b(1,n,ca[_ba]:rep(d_a))end;if(bba)then ada()end end,blit=function(aab,bab,cab)if -type(aab)~="string"then -error("bad argument #1 (expected string, got "..type(aab)..")",2)end;if type(bab)~="string"then -error( -"bad argument #2 (expected string, got "..type(bab)..")",2)end;if type(cab)~="string"then -error( -"bad argument #3 (expected string, got "..type(cab)..")",2)end -if -#bab~=#aab or#cab~=#aab then error("Arguments must be the same length",2)end;if(bba)then bda(aab,bab,cab)end end}return _ab end;_c.width=30;_c.height=12;local _d=dc(1,1,_c.width,_c.height)local ad -local bd=false;local cd={} -local function dd(b_a)local c_a,d_a=_d.getCursorPos() -local _aa,aaa=b_a:getAnchorPosition()local baa,caa=b_a:getSize() -if(_aa+c_a-1 >=1 and -_aa+c_a-1 <=_aa+baa-1 and d_a+aaa-1 >=1 and -d_a+aaa-1 <=aaa+caa-1)then -b_a.parent:setCursor(_d.getCursorBlink(), -_aa+c_a-1,d_a+aaa-1,_d.getTextColor())end end -local function __a(b_a,c_a,d_a,_aa,aaa)if(ad==nil)then return false end -if not(ad:isDead())then if not(bd)then -local baa,caa=b_a:getAbsolutePosition(b_a:getAnchorPosition( -nil,nil,true))ad:resume(c_a,d_a,_aa-baa+1,aaa-caa+1) -dd(b_a)end end end -local function a_a(b_a,c_a,d_a,_aa)if(ad==nil)then return false end -if not(ad:isDead())then if not(bd)then if(b_a.draw)then -ad:resume(c_a,d_a,_aa)dd(b_a)end end end end -bc={getType=function(b_a)return ac end,show=function(b_a)_c.show(b_a) -_d.setBackgroundColor(b_a.bgColor)_d.setTextColor(b_a.fgColor) -_d.basalt_setVisible(true)return b_a end,hide=function(b_a) -_c.hide(b_a)_d.basalt_setVisible(false)return b_a end,setPosition=function(b_a,c_a,d_a,_aa) -_c.setPosition(b_a,c_a,d_a,_aa) -_d.basalt_reposition(b_a:getAnchorPosition())return b_a end,setValuesByXMLData=function(b_a,c_a) -_c.setValuesByXMLData(b_a,c_a)if(_b("path",c_a)~=nil)then cc=_b("path",c_a)end -if( -_b("execute",c_a)~=nil)then if(_b("execute",c_a))then -if(cc~=nil)then b_a:execute(cc)end end end end,getBasaltWindow=function()return -_d end,getBasaltProcess=function()return ad end,setSize=function(b_a,c_a,d_a,_aa)_c.setSize(b_a,c_a,d_a,_aa) -_d.basalt_resize(b_a:getWidth(),b_a:getHeight())return b_a end,getStatus=function(b_a)if(ad~=nil)then return -ad:getStatus()end;return"inactive"end,execute=function(b_a,c_a,...)cc= -c_a or cc;ad=da:new(cc,_d,...) -_d.setBackgroundColor(colors.black)_d.setTextColor(colors.white)_d.clear() -_d.setCursorPos(1,1)_d.setBackgroundColor(b_a.bgColor) -_d.setTextColor(b_a.fgColor)_d.basalt_setVisible(true)ad:resume()bd=false -if -(b_a.parent~=nil)then b_a.parent:addEvent("mouse_click",b_a) -b_a.parent:addEvent("mouse_up",b_a)b_a.parent:addEvent("mouse_drag",b_a) -b_a.parent:addEvent("mouse_scroll",b_a)b_a.parent:addEvent("key",b_a) -b_a.parent:addEvent("key_up",b_a)b_a.parent:addEvent("char",b_a) -b_a.parent:addEvent("other_event",b_a)end;return b_a end,stop=function(b_a)if( -ad~=nil)then -if not(ad:isDead())then ad:resume("terminate")if(ad:isDead())then -if( -b_a.parent~=nil)then b_a.parent:setCursor(false)end end end end -b_a.parent:removeEvents(b_a)return b_a end,pause=function(b_a,c_a)bd= -c_a or(not bd) -if(ad~=nil)then if not(ad:isDead())then if not(bd)then -b_a:injectEvents(cd)cd={}end end end;return b_a end,isPaused=function(b_a)return -bd end,injectEvent=function(b_a,c_a,d_a,_aa,aaa,baa,caa) -if(ad~=nil)then -if not(ad:isDead())then if(bd==false)or(caa)then -ad:resume(c_a,d_a,_aa,aaa,baa)else -table.insert(cd,{event=c_a,args={d_a,_aa,aaa,baa}})end end end;return b_a end,getQueuedEvents=function(b_a)return -cd end,updateQueuedEvents=function(b_a,c_a)cd=c_a or cd;return b_a end,injectEvents=function(b_a,c_a)if(ad~=nil)then -if not -(ad:isDead())then for d_a,_aa in pairs(c_a)do -ad:resume(_aa.event,table.unpack(_aa.args))end end end;return b_a end,mouseHandler=function(b_a,c_a,d_a,_aa) -if -(_c.mouseHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_click",c_a,d_a,_aa)return true end;return false end,mouseUpHandler=function(b_a,c_a,d_a,_aa) -if -(_c.mouseUpHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_up",c_a,d_a,_aa)return true end;return false end,scrollHandler=function(b_a,c_a,d_a,_aa) -if -(_c.scrollHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_scroll",c_a,d_a,_aa)return true end;return false end,dragHandler=function(b_a,c_a,d_a,_aa) -if -(_c.dragHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_drag",c_a,d_a,_aa)return true end;return false end,keyHandler=function(b_a,c_a,d_a)if -(_c.keyHandler(b_a,c_a,d_a))then a_a(b_a,"key",c_a,d_a)return true end;return -false end,keyUpHandler=function(b_a,c_a)if -(_c.keyUpHandler(b_a,c_a))then a_a(b_a,"key_up",c_a)return true end -return false end,charHandler=function(b_a,c_a)if -(_c.charHandler(b_a,c_a))then a_a(b_a,"char",c_a)return true end -return false end,getFocusHandler=function(b_a) -_c.getFocusHandler(b_a) -if(ad~=nil)then -if not(ad:isDead())then -if not(bd)then -if(b_a.parent~=nil)then -local c_a,d_a=_d.getCursorPos()local _aa,aaa=b_a:getAnchorPosition() -if(b_a.parent~=nil)then -local baa,caa=b_a:getSize() -if -(_aa+c_a-1 >=1 and _aa+c_a-1 <=_aa+baa-1 and -d_a+aaa-1 >=1 and d_a+aaa-1 <=aaa+caa-1)then -b_a.parent:setCursor(_d.getCursorBlink(),_aa+c_a-1,d_a+aaa-1,_d.getTextColor())end end end end end end end,loseFocusHandler=function(b_a) -_c.loseFocusHandler(b_a) -if(ad~=nil)then if not(ad:isDead())then if(b_a.parent~=nil)then -b_a.parent:setCursor(false)end end end end,eventHandler=function(b_a,c_a,d_a,_aa,aaa,baa) -if -(_c.eventHandler(b_a,c_a,d_a,_aa,aaa,baa))then if(ad==nil)then return end -if(c_a=="dynamicValueEvent")then local caa,daa=_d.getSize() -local _ba,aba=b_a:getSize() -if(caa~=_ba)or(daa~=aba)then _d.basalt_resize(_ba,aba)if not -(ad:isDead())then ad:resume("term_resize")end end -_d.basalt_reposition(b_a:getAnchorPosition())end -if not(ad:isDead())then -if not(bd)then if(c_a~="terminate")then -ad:resume(c_a,d_a,_aa,aaa,baa)end -if(b_a:isFocused())then -local caa,daa=b_a:getAnchorPosition()local _ba,aba=_d.getCursorPos() -if(b_a.parent~=nil)then -local bba,cba=b_a:getSize() -if -(caa+_ba-1 >=1 and caa+_ba-1 <=caa+bba-1 and -aba+daa-1 >=1 and aba+daa-1 <=daa+cba-1)then -b_a.parent:setCursor(_d.getCursorBlink(),caa+_ba-1,aba+daa-1,_d.getTextColor())end end;if(c_a=="terminate")then ab(b_a:isFocused())ad:resume(c_a) -b_a.parent:setCursor(false)return true end end else -table.insert(cd,{event=c_a,args={d_a,_aa,aaa,baa}})end end;return false end end,draw=function(b_a) -if -(_c.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize()_d.basalt_reposition(c_a,d_a)_d.basalt_update()end end end,init=function(b_a) -b_a.bgColor=b_a.parent:getTheme("ProgramBG")end}return setmetatable(bc,_c)end -end; -project['objects']['Progressbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Progressbar"local ca=0;aa:setZIndex(5) -aa:setValue(false)aa.width=25;aa.height=1;local da;local _b=""local ab=colors.white;local bb=""local cb=0 -local db={init=function(_c) -_c.bgColor=_c.parent:getTheme("ProgressbarBG")_c.fgColor=_c.parent:getTheme("ProgressbarText") -da=_c.parent:getTheme("ProgressbarActiveBG")end,getType=function(_c)return -ba end,setValuesByXMLData=function(_c,ac)aa.setValuesByXMLData(_c,ac)if(d("direction",ac)~= -nil)then cb=d("direction",ac)end -if( -d("progressColor",ac)~=nil)then da=colors[d("progressColor",ac)]end -if(d("progressSymbol",ac)~=nil)then _b=d("progressSymbol",ac)end;if(d("backgroundSymbol",ac)~=nil)then -bb=d("backgroundSymbol",ac)end -if -(d("progressSymbolColor",ac)~=nil)then ab=colors[d("progressSymbolColor",ac)]end;if(d("onDone",ac)~=nil)then -_c:generateXMLEventFunction(_c.onProgressDone,d("onDone",ac))end;return _c end,setDirection=function(_c,ac) -cb=ac;_c:updateDraw()return _c end,setProgressBar=function(_c,ac,bc,cc)da=ac or da -_b=bc or _b;ab=cc or ab;_c:updateDraw()return _c end,setBackgroundSymbol=function(_c,ac) -bb=ac:sub(1,1)_c:updateDraw()return _c end,setProgress=function(_c,ac)if -(ac>=0)and(ac<=100)and(ca~=ac)then ca=ac;_c:setValue(ca)if(ca==100)then -_c:progressDoneHandler()end end -_c:updateDraw()return _c end,getProgress=function(_c)return -ca end,onProgressDone=function(_c,ac)_c:registerEvent("progress_done",ac) -return _c end,progressDoneHandler=function(_c) -_c:sendEvent("progress_done",_c)end,draw=function(_c) -if(aa.draw(_c))then -if(_c.parent~=nil)then -local ac,bc=_c:getAnchorPosition()local cc,dc=_c:getSize()if(_c.bgColor~=false)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc,_c.bgColor)end;if(bb~="")then -_c.parent:drawTextBox(ac,bc,cc,dc,bb)end;if(_c.fgColor~=false)then -_c.parent:drawForegroundBox(ac,bc,cc,dc,_c.fgColor)end -if(cb==1)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc,cc,dc/100 *ca,ab) -_c.parent:drawTextBox(ac,bc,cc,dc/100 *ca,_b)elseif(cb==2)then -_c.parent:drawBackgroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc,dc/ -100 *ca,ab) -_c.parent:drawTextBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,_b)elseif(cb==3)then -_c.parent:drawBackgroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac+math.ceil(cc-cc/100 *ca),bc,cc/100 * -ca,dc,_b)else -_c.parent:drawBackgroundBox(ac,bc,cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac,bc,cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac,bc,cc/100 *ca,dc,_b)end end end end}return setmetatable(db,aa)end -end; -project['objects']['Radio'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Radio"ca.width=8;ca:setZIndex(5)local _b={}local ab;local bb;local cb -local db;local _c;local ac;local bc=true;local cc="\7"local dc="left" -local _d={getType=function(ad)return da end,setValuesByXMLData=function(ad,bd) -ca.setValuesByXMLData(ad,bd)if(aa("selectionBG",bd)~=nil)then -ab=colors[aa("selectionBG",bd)]end;if(aa("selectionFG",bd)~=nil)then -bb=colors[aa("selectionFG",bd)]end;if(aa("boxBG",bd)~=nil)then -cb=colors[aa("boxBG",bd)]end;if(aa("inactiveBoxBG",bd)~=nil)then -_c=colors[aa("inactiveBoxBG",bd)]end;if(aa("inactiveBoxFG",bd)~=nil)then -ac=colors[aa("inactiveBoxFG",bd)]end;if(aa("boxFG",bd)~=nil)then -db=colors[aa("boxFG",bd)]end;if(aa("symbol",bd)~=nil)then -cc=aa("symbol",bd)end -if(bd["item"]~=nil)then local cd=bd["item"]if -(cd.properties~=nil)then cd={cd}end;for dd,__a in pairs(cd)do -ad:addItem(aa("text",__a),aa("x",__a),aa("y",__a),colors[aa("bg",__a)],colors[aa("fg",__a)])end end;return ad end,addItem=function(ad,bd,cd,dd,__a,a_a,...) -table.insert(_b,{x= -cd or 1,y=dd or 1,text=bd,bgCol=__a or ad.bgColor,fgCol=a_a or ad.fgColor,args={...}})if(#_b==1)then ad:setValue(_b[1])end -ad:updateDraw()return ad end,getAll=function(ad)return -_b end,removeItem=function(ad,bd)table.remove(_b,bd)ad:updateDraw()return ad end,getItem=function(ad,bd)return -_b[bd]end,getItemIndex=function(ad)local bd=ad:getValue()for cd,dd in pairs(_b)do -if(dd==bd)then return cd end end end,clear=function(ad) -_b={}ad:setValue({})ad:updateDraw()return ad end,getItemCount=function(ad)return -#_b end,editItem=function(ad,bd,cd,dd,__a,a_a,b_a,...)table.remove(_b,bd) -table.insert(_b,bd,{x=dd or 1,y=__a or 1,text=cd,bgCol=a_a or -ad.bgColor,fgCol=b_a or ad.fgColor,args={...}})ad:updateDraw()return ad end,selectItem=function(ad,bd)ad:setValue( -_b[bd]or{})ad:updateDraw()return ad end,setActiveSymbol=function(ad,bd) -cc=bd:sub(1,1)ad:updateDraw()return ad end,setSelectedItem=function(ad,bd,cd,dd,__a,a_a)ab=bd or ab -bb=cd or bb;cb=dd or cb;db=__a or db;bc=a_a~=nil and a_a or true -ad:updateDraw()return ad end,mouseHandler=function(ad,bd,cd,dd) -if(#_b> -0)then -local __a,a_a=ad:getAbsolutePosition(ad:getAnchorPosition()) -for b_a,c_a in pairs(_b)do -if(__a+c_a.x-1 <=cd)and( -__a+c_a.x-1 +c_a.text:len()+1 >=cd)and( -a_a+c_a.y-1 ==dd)then ad:setValue(c_a) -local d_a=ad:getEventSystem():sendEvent("mouse_click",ad,"mouse_click",bd,cd,dd)if(d_a==false)then return d_a end;if(ad.parent~=nil)then -ad.parent:setFocusedObject(ad)end;ad:updateDraw()return true end end end;return false end,draw=function(ad) -if( -ad.parent~=nil)then local bd,cd=ad:getAnchorPosition() -for dd,__a in pairs(_b)do -if -(__a==ad:getValue())then if(dc=="left")then -ad.parent:writeText(__a.x+bd-1,__a.y+cd-1,cc,cb,db) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,ab,bb)end else -ad.parent:drawBackgroundBox( -__a.x+bd-1,__a.y+cd-1,1,1,_c or ad.bgColor) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,__a.bgCol,__a.fgCol)end end;return true end end,init=function(ad) -ad.bgColor=ad.parent:getTheme("MenubarBG")ad.fgColor=ad.parent:getTheme("MenubarFG") -ab=ad.parent:getTheme("SelectionBG")bb=ad.parent:getTheme("SelectionText") -cb=ad.parent:getTheme("MenubarBG")db=ad.parent:getTheme("MenubarText") -ad.parent:addEvent("mouse_click",ad)end}return setmetatable(_d,ca)end -end; -project['objects']['Scrollbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Scrollbar"aa.width=1;aa.height=8;aa:setValue(1) -aa:setZIndex(2)local ca="vertical"local da=" "local _b;local ab="\127"local bb=aa.height;local cb=1;local db=1 -local function _c(bc,cc,dc,_d) -local ad,bd=bc:getAbsolutePosition(bc:getAnchorPosition())local cd,dd=bc:getSize() -if(ca=="horizontal")then for _index=0,cd do -if -(ad+_index==dc)and(bd<=_d)and(bd+dd>_d)then -cb=math.min(_index+1,cd- (db-1))bc:setValue(bb/cd* (cb))bc:updateDraw()end end end -if(ca=="vertical")then for _index=0,dd do -if -(bd+_index==_d)and(ad<=dc)and(ad+cd>dc)then cb=math.min(_index+1,dd- (db-1)) -bc:setValue(bb/dd* (cb))bc:updateDraw()end end end end -local ac={getType=function(bc)return ba end,setSymbol=function(bc,cc)da=cc:sub(1,1)bc:updateDraw()return bc end,setValuesByXMLData=function(bc,cc) -aa.setValuesByXMLData(bc,cc) -if(d("maxValue",cc)~=nil)then bb=d("maxValue",cc)end;if(d("backgroundSymbol",cc)~=nil)then -ab=d("backgroundSymbol",cc):sub(1,1)end;if(d("symbol",cc)~=nil)then -da=d("symbol",cc):sub(1,1)end;if(d("barType",cc)~=nil)then -ca=d("barType",cc):lower()end;if(d("symbolSize",cc)~=nil)then -bc:setSymbolSize(d("symbolSize",cc))end;if(d("symbolColor",cc)~=nil)then -_b=colors[d("symbolColor",cc)]end;if(d("index",cc)~=nil)then -bc:setIndex(d("index",cc))end end,setIndex=function(bc,cc) -cb=cc;if(cb<1)then cb=1 end;local dc,_d=bc:getSize() -cb=math.min(cb,(ca=="vertical"and _d or -dc)- (db-1)) -bc:setValue(bb/ (ca=="vertical"and _d or dc)*cb)bc:updateDraw()return bc end,getIndex=function(bc)return -cb end,setSymbolSize=function(bc,cc)db=tonumber(cc)or 1;local dc,_d=bc:getSize() -if(ca== -"vertical")then -bc:setValue(cb-1 * (bb/ (_d- (db-1)))- -(bb/ (_d- (db-1))))elseif(ca=="horizontal")then -bc:setValue(cb-1 * (bb/ (dc- (db-1)))- (bb/ (dc- -(db-1))))end;bc:updateDraw()return bc end,setMaxValue=function(bc,cc) -bb=cc;bc:updateDraw()return bc end,setBackgroundSymbol=function(bc,cc) -ab=string.sub(cc,1,1)bc:updateDraw()return bc end,setSymbolColor=function(bc,cc)_b=cc -bc:updateDraw()return bc end,setBarType=function(bc,cc)ca=cc:lower()bc:updateDraw() -return bc end,mouseHandler=function(bc,cc,dc,_d)if(aa.mouseHandler(bc,cc,dc,_d))then -_c(bc,cc,dc,_d)return true end;return false end,dragHandler=function(bc,cc,dc,_d)if -(aa.dragHandler(bc,cc,dc,_d))then _c(bc,cc,dc,_d)return true end;return false end,scrollHandler=function(bc,cc,dc,_d) -if -(aa.scrollHandler(bc,cc,dc,_d))then local ad,bd=bc:getSize()cb=cb+cc;if(cb<1)then cb=1 end -cb=math.min(cb,( -ca=="vertical"and bd or ad)- (db-1)) -bc:setValue(bb/ (ca=="vertical"and bd or ad)*cb)bc:updateDraw()end end,draw=function(bc) -if -(aa.draw(bc))then -if(bc.parent~=nil)then local cc,dc=bc:getAnchorPosition() -local _d,ad=bc:getSize() -if(ca=="horizontal")then -bc.parent:writeText(cc,dc,ab:rep(cb-1),bc.bgColor,bc.fgColor) -bc.parent:writeText(cc+cb-1,dc,da:rep(db),_b,_b) -bc.parent:writeText(cc+cb+db-1,dc,ab:rep(_d- (cb+db-1)),bc.bgColor,bc.fgColor)end -if(ca=="vertical")then -for n=0,ad-1 do -if(cb==n+1)then for curIndexOffset=0,math.min(db-1,ad)do -bc.parent:writeText(cc,dc+n+curIndexOffset,da,_b,_b)end else if -(n+1 cb-1 +db)then -bc.parent:writeText(cc,dc+n,ab,bc.bgColor,bc.fgColor)end end end end end end end,init=function(bc) -bc.bgColor=bc.parent:getTheme("ScrollbarBG")bc.fgColor=bc.parent:getTheme("ScrollbarText") -_b=bc.parent:getTheme("ScrollbarSymbolColor")bc.parent:addEvent("mouse_click",bc) -bc.parent:addEvent("mouse_drag",bc)bc.parent:addEvent("mouse_scroll",bc)end}return setmetatable(ac,aa)end -end; -project['objects']['Slider'] = function(...)local d=require("Object")local _a=require("basaltLogs") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Slider"ca.width=8;ca.height=1;ca:setValue(1) -local _b="horizontal"local ab=" "local bb;local cb="\140"local db=ca.width;local _c=1;local ac=1 -local function bc(dc,_d,ad,bd) -local cd,dd=dc:getAbsolutePosition(dc:getAnchorPosition())local __a,a_a=dc:getSize() -if(_b=="horizontal")then for _index=0,__a do -if -(cd+_index==ad)and(dd<=bd)and(dd+a_a>bd)then -_c=math.min(_index+1,__a- (ac-1))dc:setValue(db/__a* (_c))dc:updateDraw()end end end -if(_b=="vertical")then for _index=0,a_a do -if -(dd+_index==bd)and(cd<=ad)and(cd+__a>ad)then _c=math.min(_index+1,a_a- (ac-1)) -dc:setValue(db/a_a* (_c))dc:updateDraw()end end end end -local cc={getType=function(dc)return da end,setSymbol=function(dc,_d)ab=_d:sub(1,1)dc:updateDraw()return dc end,setValuesByXMLData=function(dc,_d) -ca.setValuesByXMLData(dc,_d) -if(aa("maxValue",_d)~=nil)then db=aa("maxValue",_d)end;if(aa("backgroundSymbol",_d)~=nil)then -cb=aa("backgroundSymbol",_d):sub(1,1)end;if(aa("barType",_d)~=nil)then -_b=aa("barType",_d):lower()end;if(aa("symbol",_d)~=nil)then -ab=aa("symbol",_d):sub(1,1)end;if(aa("symbolSize",_d)~=nil)then -dc:setSymbolSize(aa("symbolSize",_d))end;if(aa("symbolColor",_d)~=nil)then -bb=colors[aa("symbolColor",_d)]end;if(aa("index",_d)~=nil)then -dc:setIndex(aa("index",_d))end end,setIndex=function(dc,_d) -_c=_d;if(_c<1)then _c=1 end;local ad,bd=dc:getSize() -_c=math.min(_c,(_b=="vertical"and bd or -ad)- (ac-1)) -dc:setValue(db/ (_b=="vertical"and bd or ad)*_c)dc:updateDraw()return dc end,getIndex=function(dc)return -_c end,setSymbolSize=function(dc,_d)ac=tonumber(_d)or 1 -if(_b=="vertical")then -dc:setValue(_c-1 * (db/ -(h- (ac-1)))- (db/ (h- (ac-1))))elseif(_b=="horizontal")then -dc:setValue(_c-1 * (db/ (w- (ac-1)))- (db/ -(w- (ac-1))))end;dc:updateDraw()return dc end,setMaxValue=function(dc,_d) -db=_d;return dc end,setBackgroundSymbol=function(dc,_d)cb=string.sub(_d,1,1) -dc:updateDraw()return dc end,setSymbolColor=function(dc,_d)bb=_d;dc:updateDraw()return dc end,setBarType=function(dc,_d) -_b=_d:lower()dc:updateDraw()return dc end,mouseHandler=function(dc,_d,ad,bd)if -(ca.mouseHandler(dc,_d,ad,bd))then bc(dc,_d,ad,bd)return true end;return false end,dragHandler=function(dc,_d,ad,bd)if -(ca.dragHandler(dc,_d,ad,bd))then bc(dc,_d,ad,bd)return true end;return false end,scrollHandler=function(dc,_d,ad,bd) -if -(ca.scrollHandler(dc,_d,ad,bd))then local cd,dd=dc:getSize()_c=_c+_d;if(_c<1)then _c=1 end -_c=math.min(_c,( -_b=="vertical"and dd or cd)- (ac-1)) -dc:setValue(db/ (_b=="vertical"and dd or cd)*_c)dc:updateDraw()return true end;return false end,draw=function(dc) -if -(ca.draw(dc))then -if(dc.parent~=nil)then local _d,ad=dc:getAnchorPosition() -local bd,cd=dc:getSize() -if(_b=="horizontal")then -dc.parent:writeText(_d,ad,cb:rep(_c-1),dc.bgColor,dc.fgColor) -dc.parent:writeText(_d+_c-1,ad,ab:rep(ac),bb,bb) -dc.parent:writeText(_d+_c+ac-1,ad,cb:rep(bd- (_c+ac-1)),dc.bgColor,dc.fgColor)end -if(_b=="vertical")then -for n=0,cd-1 do -if(_c==n+1)then for curIndexOffset=0,math.min(ac-1,cd)do -dc.parent:writeText(_d,ad+n+curIndexOffset,ab,bb,bb)end else if -(n+1 <_c)or(n+1 >_c-1 +ac)then -dc.parent:writeText(_d,ad+n,cb,dc.bgColor,dc.fgColor)end end end end end end end,init=function(dc) -dc.bgColor=dc.parent:getTheme("SliderBG")dc.fgColor=dc.parent:getTheme("SliderText") -bb=dc.parent:getTheme("SliderSymbolColor")dc.parent:addEvent("mouse_click",dc) -dc.parent:addEvent("mouse_drag",dc)dc.parent:addEvent("mouse_scroll",dc)end}return setmetatable(cc,ca)end -end; -project['objects']['Switch'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Switch"aa.width=2;aa.height=1 -aa.bgColor=colors.lightGray;aa.fgColor=colors.gray;aa:setValue(false)aa:setZIndex(5) -local ca=colors.black;local da=colors.red;local _b=colors.green -local ab={getType=function(bb)return ba end,setSymbolColor=function(bb,cb)ca=cb -bb:updateDraw()return bb end,setActiveBackground=function(bb,cb)_b=cb;bb:updateDraw()return bb end,setInactiveBackground=function(bb,cb) -da=cb;bb:updateDraw()return bb end,setValuesByXMLData=function(bb,cb) -aa.setValuesByXMLData(bb,cb)if(d("inactiveBG",cb)~=nil)then -da=colors[d("inactiveBG",cb)]end;if(d("activeBG",cb)~=nil)then -_b=colors[d("activeBG",cb)]end;if(d("symbolColor",cb)~=nil)then -ca=colors[d("symbolColor",cb)]end end,mouseHandler=function(bb,cb,db,_c) -if -(aa.mouseHandler(bb,cb,db,_c))then -local ac,bc=bb:getAbsolutePosition(bb:getAnchorPosition())bb:setValue(not bb:getValue()) -bb:updateDraw()return true end end,draw=function(bb) -if -(aa.draw(bb))then -if(bb.parent~=nil)then local cb,db=bb:getAnchorPosition() -local _c,ac=bb:getSize() -bb.parent:drawBackgroundBox(cb,db,_c,ac,bb.bgColor) -if(bb:getValue())then -bb.parent:drawBackgroundBox(cb,db,1,ac,_b)bb.parent:drawBackgroundBox(cb+1,db,1,ac,ca)else -bb.parent:drawBackgroundBox(cb,db,1,ac,ca)bb.parent:drawBackgroundBox(cb+1,db,1,ac,da)end end end end,init=function(bb) -bb.bgColor=bb.parent:getTheme("SwitchBG")bb.fgColor=bb.parent:getTheme("SwitchText") -ca=bb.parent:getTheme("SwitchBGSymbol")da=bb.parent:getTheme("SwitchInactive") -_b=bb.parent:getTheme("SwitchActive")bb.parent:addEvent("mouse_click",bb)end}return setmetatable(ab,aa)end -end; -project['objects']['Textfield'] = function(...)local aa=require("Object")local ba=require("tHex") -local ca=require("basaltLogs")local da=require("utils").getValueFromXML;local _b=string.rep -return -function(ab) -local bb=aa(ab)local cb="Textfield"local db,_c,ac,bc=1,1,1,1;local cc={""}local dc={""}local _d={""}local ad={}local bd={} -bb.width=30;bb.height=12;bb:setZIndex(5) -local function cd(b_a,c_a)local d_a={} -if(b_a:len()>0)then -for _aa in -string.gmatch(b_a,c_a)do local aaa,baa=string.find(b_a,_aa) -if(aaa~=nil)and(baa~=nil)then -table.insert(d_a,aaa)table.insert(d_a,baa) -local caa=string.sub(b_a,1,(aaa-1))local daa=string.sub(b_a,baa+1,b_a:len())b_a=caa.. -(":"):rep(_aa:len())..daa end end end;return d_a end -local function dd(b_a,c_a)c_a=c_a or bc -local d_a=ba[b_a.fgColor]:rep(_d[c_a]:len()) -local _aa=ba[b_a.bgColor]:rep(dc[c_a]:len()) -for aaa,baa in pairs(bd)do local caa=cd(cc[c_a],baa[1]) -if(#caa>0)then -for x=1,#caa/2 do local daa=x*2 -1;if( -baa[2]~=nil)then -d_a=d_a:sub(1,caa[daa]-1)..ba[baa[2] ]:rep(caa[daa+1]- -(caa[daa]-1)).. -d_a:sub(caa[daa+1]+1,d_a:len())end;if -(baa[3]~=nil)then -_aa=_aa:sub(1,caa[daa]-1).. - -ba[baa[3] ]:rep(caa[daa+1]- (caa[daa]-1)).._aa:sub(caa[daa+1]+1,_aa:len())end end end end -for aaa,baa in pairs(ad)do -for caa,daa in pairs(baa)do local _ba=cd(cc[c_a],daa) -if(#_ba>0)then for x=1,#_ba/2 do local aba=x*2 -1 -d_a=d_a:sub(1, -_ba[aba]-1).. - -ba[aaa]:rep(_ba[aba+1]- (_ba[aba]-1))..d_a:sub(_ba[aba+1]+1,d_a:len())end end end end;_d[c_a]=d_a;dc[c_a]=_aa;b_a:updateDraw()end;local function __a(b_a)for n=1,#cc do dd(b_a,n)end end -local a_a={getType=function(b_a)return cb end,setBackground=function(b_a,c_a) -bb.setBackground(b_a,c_a)__a(b_a)return b_a end,setForeground=function(b_a,c_a) -bb.setForeground(b_a,c_a)__a(b_a)return b_a end,setValuesByXMLData=function(b_a,c_a) -bb.setValuesByXMLData(b_a,c_a) -if(c_a["lines"]~=nil)then local d_a=c_a["lines"]["line"]if -(d_a.properties~=nil)then d_a={d_a}end;for _aa,aaa in pairs(d_a)do -b_a:addLine(aaa:value())end end -if(c_a["keywords"]~=nil)then -for d_a,_aa in pairs(c_a["keywords"])do -if(colors[d_a]~=nil)then -local aaa=_aa;if(aaa.properties~=nil)then aaa={aaa}end;local baa={} -for caa,daa in pairs(aaa)do -local _ba=daa["keyword"]if(daa["keyword"].properties~=nil)then -_ba={daa["keyword"]}end;for aba,bba in pairs(_ba)do -table.insert(baa,bba:value())end end;b_a:addKeywords(colors[d_a],baa)end end end -if(c_a["rules"]~=nil)then -if(c_a["rules"]["rule"]~=nil)then -local d_a=c_a["rules"]["rule"]if(c_a["rules"]["rule"].properties~=nil)then -d_a={c_a["rules"]["rule"]}end -for _aa,aaa in pairs(d_a)do if(da("pattern",aaa)~=nil)then -b_a:addRule(da("pattern",aaa),colors[da("fg",aaa)],colors[da("bg",aaa)])end end end end end,getLines=function(b_a)return -cc end,getLine=function(b_a,c_a)return cc[c_a]end,editLine=function(b_a,c_a,d_a) -cc[c_a]=d_a or cc[c_a]b_a:updateDraw()return b_a end,clear=function(b_a) -cc={""}dc={""}_d={""}db,_c,ac,bc=1,1,1,1;b_a:updateDraw()return b_a end,addLine=function(b_a,c_a,d_a) -if( -c_a~=nil)then if(#cc==1)and(cc[1]=="")then cc[1]=c_a -dc[1]=ba[b_a.bgColor]:rep(c_a:len())_d[1]=ba[b_a.fgColor]:rep(c_a:len()) -return b_a end -if(d_a~=nil)then -table.insert(cc,d_a,c_a) -table.insert(dc,d_a,ba[b_a.bgColor]:rep(c_a:len())) -table.insert(_d,ba[b_a.fgColor]:rep(c_a:len()))else table.insert(cc,c_a) -table.insert(dc,ba[b_a.bgColor]:rep(c_a:len())) -table.insert(_d,ba[b_a.fgColor]:rep(c_a:len()))end end;b_a:updateDraw()return b_a end,addKeywords=function(b_a,c_a,d_a)if( -ad[c_a]==nil)then ad[c_a]={}end;for _aa,aaa in pairs(d_a)do -table.insert(ad[c_a],aaa)end;b_a:updateDraw()return b_a end,addRule=function(b_a,c_a,d_a,_aa) -table.insert(bd,{c_a,d_a,_aa})b_a:updateDraw()return b_a end,editRule=function(b_a,c_a,d_a,_aa)for aaa,baa in -pairs(bd)do -if(baa[1]==c_a)then bd[aaa][2]=d_a;bd[aaa][3]=_aa end end;b_a:updateDraw()return b_a end,removeRule=function(b_a,c_a) -for d_a,_aa in -pairs(bd)do if(_aa[1]==c_a)then table.remove(bd,d_a)end end;b_a:updateDraw()return b_a end,setKeywords=function(b_a,c_a,d_a) -ad[c_a]=d_a;b_a:updateDraw()return b_a end,removeLine=function(b_a,c_a)table.remove(cc,c_a or -#cc) -if(#cc<=0)then table.insert(cc,"")end;b_a:updateDraw()return b_a end,getTextCursor=function(b_a)return -ac,bc end,getFocusHandler=function(b_a)bb.getFocusHandler(b_a) -if(b_a.parent~=nil)then -local c_a,d_a=b_a:getAnchorPosition()if(b_a.parent~=nil)then -b_a.parent:setCursor(true,c_a+ac-_c,d_a+bc-db,b_a.fgColor)end end end,loseFocusHandler=function(b_a) -bb.loseFocusHandler(b_a) -if(b_a.parent~=nil)then b_a.parent:setCursor(false)end end,keyHandler=function(b_a,c_a) -if -(bb.keyHandler(b_a,event,c_a))then local d_a,_aa=b_a:getAnchorPosition()local aaa,baa=b_a:getSize() -if(c_a== -keys.backspace)then -if(cc[bc]=="")then -if(bc>1)then table.remove(cc,bc) -table.remove(_d,bc)table.remove(dc,bc)ac=cc[bc-1]:len()+1;_c= -ac-aaa+1;if(_c<1)then _c=1 end;bc=bc-1 end elseif(ac<=1)then -if(bc>1)then ac=cc[bc-1]:len()+1;_c=ac-aaa+1 -if(_c<1)then _c=1 end;cc[bc-1]=cc[bc-1]..cc[bc] -_d[bc-1]=_d[bc-1].._d[bc]dc[bc-1]=dc[bc-1]..dc[bc]table.remove(cc,bc) -table.remove(_d,bc)table.remove(dc,bc)bc=bc-1 end else -cc[bc]=cc[bc]:sub(1,ac-2)..cc[bc]:sub(ac,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-2).._d[bc]:sub(ac,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-2)..dc[bc]:sub(ac,dc[bc]:len())if(ac>1)then ac=ac-1 end -if(_c>1)then if(ac<_c)then _c=_c-1 end end end;if(bccc[bc]:len())then -if(cc[bc+1]~=nil)then cc[bc]=cc[bc].. -cc[bc+1]table.remove(cc,bc+1) -table.remove(dc,bc+1)table.remove(_d,bc+1)end else -cc[bc]=cc[bc]:sub(1,ac-1)..cc[bc]:sub(ac+1,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-1).._d[bc]:sub(ac+1,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-1)..dc[bc]:sub(ac+1,dc[bc]:len())end;dd(b_a)end -if(c_a==keys.enter)then -table.insert(cc,bc+1,cc[bc]:sub(ac,cc[bc]:len())) -table.insert(_d,bc+1,_d[bc]:sub(ac,_d[bc]:len())) -table.insert(dc,bc+1,dc[bc]:sub(ac,dc[bc]:len()))cc[bc]=cc[bc]:sub(1,ac-1) -_d[bc]=_d[bc]:sub(1,ac-1)dc[bc]=dc[bc]:sub(1,ac-1)bc=bc+1;ac=1;_c=1;if(bc-db>=baa)then -db=db+1 end;b_a:setValue("")end -if(c_a==keys.up)then -if(bc>1)then bc=bc-1;if(ac>cc[bc]:len()+1)then ac= -cc[bc]:len()+1 end;if(_c>1)then if(ac<_c)then _c=ac-aaa+1;if(_c<1)then -_c=1 end end end;if(db>1)then if( -bccc[bc]:len()+1)then ac= -cc[bc]:len()+1 end;if(_c>1)then if(ac<_c)then _c=ac-aaa+1;if(_c<1)then -_c=1 end end end;if(bc>= -db+baa)then db=db+1 end end end -if(c_a==keys.right)then ac=ac+1;if(bc<#cc)then if(ac>cc[bc]:len()+1)then ac=1 -bc=bc+1 end elseif(ac>cc[bc]:len())then -ac=cc[bc]:len()+1 end;if(ac<1)then ac=1 end;if -(ac<_c)or(ac>=aaa+_c)then _c=ac-aaa+1 end -if(_c<1)then _c=1 end end -if(c_a==keys.left)then ac=ac-1;if(ac>=1)then -if(ac<_c)or(ac>=aaa+_c)then _c=ac end end -if(bc>1)then if(ac<1)then bc=bc-1 -ac=cc[bc]:len()+1;_c=ac-aaa+1 end end;if(ac<1)then ac=1 end;if(_c<1)then _c=1 end end;local caa= -(ac<=cc[bc]:len()and ac-1 or cc[bc]:len())- (_c-1)if(caa> -b_a.x+aaa-1)then caa=b_a.x+aaa-1 end;local daa=( -bc-db=aaa+_c)then _c=_c+1 end;dd(b_a) -b_a:setValue("")local caa= -(ac<=cc[bc]:len()and ac-1 or cc[bc]:len())- (_c-1)if(caa> -b_a.x+aaa-1)then caa=b_a.x+aaa-1 end;local daa=( -bc-dbcaa+d_a- (aaa+1)+_c)and(caacc[bc]:len())then -ac=cc[bc]:len()+1 end -if(ac<_c)then _c=ac-1;if(_c<1)then _c=1 end end;if(b_a.parent~=nil)then -b_a.parent:setCursor(true,caa+ac-_c,daa+bc-db,b_a.fgColor)end;b_a:updateDraw()end end;return true end end,scrollHandler=function(b_a,c_a,d_a,_aa) -if -(bb.scrollHandler(b_a,c_a,d_a,_aa))then -local aaa,baa=b_a:getAbsolutePosition(b_a:getAnchorPosition())local caa,daa=b_a:getAnchorPosition()local _ba,aba=b_a:getSize() -db=db+c_a;if(db>#cc- (aba-1))then db=#cc- (aba-1)end -if(db<1)then db=1 end -if(b_a.parent~=nil)then -if - -(aaa+ac-_c>=aaa and aaa+ac-_c=baa and baa+bc-dbcc[bc]:len())then ac= -cc[bc]:len()+1 end -if(ac<_c)then _c=ac-1;if(_c<1)then _c=1 end end end;if(b_a.parent~=nil)then -b_a.parent:setCursor(true,caa+ac-_c,daa+bc-db,b_a.fgColor)end;return true end end,eventHandler=function(b_a,c_a,d_a,_aa,aaa,baa) -if -(bb.eventHandler(b_a,c_a,d_a,_aa,aaa,baa))then -if(c_a=="paste")then -if(b_a:isFocused())then local caa,daa=b_a:getSize() -cc[bc]= -cc[bc]:sub(1,ac-1)..d_a..cc[bc]:sub(ac,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-1).. -ba[b_a.fgColor]:rep(d_a:len()).._d[bc]:sub(ac,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-1).. -ba[b_a.bgColor]:rep(d_a:len())..dc[bc]:sub(ac,dc[bc]:len())ac=ac+d_a:len()if(ac>=caa+_c)then _c=(ac+1)-caa end -local _ba,aba=b_a:getAnchorPosition() -b_a.parent:setCursor(true,_ba+ac-_c,aba+bc-db,b_a.fgColor)dd(b_a)b_a:updateDraw()end end end end,draw=function(b_a) -if -(bb.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize() -for n=1,aaa do local baa=""local caa=""local daa=""if(cc[n+db-1]~=nil)then baa=cc[n+db-1] -daa=_d[n+db-1]caa=dc[n+db-1]end -baa=baa:sub(_c,_aa+_c-1)caa=caa:sub(_c,_aa+_c-1) -daa=daa:sub(_c,_aa+_c-1)local _ba=_aa-baa:len()if(_ba<0)then _ba=0 end -baa=baa.._b(b_a.bgSymbol,_ba)caa=caa.._b(ba[b_a.bgColor],_ba)daa=daa.. -_b(ba[b_a.fgColor],_ba) -b_a.parent:setText(c_a,d_a+n-1,baa)b_a.parent:setBG(c_a,d_a+n-1,caa)b_a.parent:setFG(c_a, -d_a+n-1,daa)end;if(b_a:isFocused())then local baa,caa=b_a:getAnchorPosition() -b_a.parent:setCursor(true, -baa+ac-_c,caa+bc-db,b_a.fgColor)end end end end,init=function(b_a) -b_a.bgColor=b_a.parent:getTheme("TextfieldBG")b_a.fgColor=b_a.parent:getTheme("TextfieldText") -b_a.parent:addEvent("mouse_click",b_a)b_a.parent:addEvent("mouse_scroll",b_a) -b_a.parent:addEvent("mouse_drag",b_a)b_a.parent:addEvent("key",b_a) -b_a.parent:addEvent("char",b_a)b_a.parent:addEvent("other_event",b_a)end}return setmetatable(a_a,bb)end -end; -project['objects']['Thread'] = function(...)local b=require("utils").getValueFromXML -return -function(c)local d;local _a="Thread"local aa;local ba -local ca=false -local da=function(_b,ab) -if(ab:sub(1,1)=="#")then -local bb=_b:getBaseFrame():getDeepObject(ab:sub(2,ab:len())) -if(bb~=nil)and(bb.internalObjetCall~=nil)then return(function() -bb:internalObjetCall()end)end else return _b:getBaseFrame():getVariable(ab)end;return _b end -d={name=c,getType=function(_b)return _a end,getZIndex=function(_b)return 1 end,getName=function(_b)return _b.name end,getBaseFrame=function(_b)if -(_b.parent~=nil)then return _b.parent:getBaseFrame()end -return _b end,setValuesByXMLData=function(_b,ab)local bb;if(b("thread",ab)~=nil)then -bb=da(_b,b("thread",ab))end -if(b("start",ab)~=nil)then if -(b("start",ab))and(bb~=nil)then _b:start(bb)end end;return _b end,start=function(_b,ab) -if( -ab==nil)then error("Function provided to thread is nil")end;aa=ab;ba=coroutine.create(aa)ca=true -local bb,cb=coroutine.resume(ba)if not(bb)then if(cb~="Terminated")then -error("Thread Error Occurred - "..cb)end end -_b.parent:addEvent("other_event",_b)return _b end,getStatus=function(_b,ab)if( -ba~=nil)then return coroutine.status(ba)end;return nil end,stop=function(_b,ab) -ca=false;_b.parent:removeEvent("other_event",_b)return _b end,eventHandler=function(_b,ab,bb,cb,db) -if -(ca)then -if(coroutine.status(ba)~="dead")then -local _c,ac=coroutine.resume(ba,ab,bb,cb,db)if not(_c)then if(ac~="Terminated")then -error("Thread Error Occurred - "..ac)end end else -ca=false end end end}d.__index=d;return d end -end; -project['objects']['Timer'] = function(...)local c=require("basaltEvent") -local d=require("utils").getValueFromXML -return -function(_a)local aa="Timer"local ba=0;local ca=0;local da=0;local _b;local ab=c()local bb=false -local cb=function(_c,ac,bc) -local cc=function(dc) -if(dc:sub(1,1)=="#")then -local _d=_c:getBaseFrame():getDeepObject(dc:sub(2,dc:len())) -if(_d~=nil)and(_d.internalObjetCall~=nil)then ac(_c,function() -_d:internalObjetCall()end)end else -ac(_c,_c:getBaseFrame():getVariable(dc))end end;if(type(bc)=="string")then cc(bc)elseif(type(bc)=="table")then -for dc,_d in pairs(bc)do cc(_d)end end;return _c end -local db={name=_a,getType=function(_c)return aa end,setValuesByXMLData=function(_c,ac) -if(d("time",ac)~=nil)then ba=d("time",ac)end;if(d("repeat",ac)~=nil)then ca=d("repeat",ac)end -if( -d("start",ac)~=nil)then if(d("start",ac))then _c:start()end end;if(d("onCall",ac)~=nil)then -cb(_c,_c.onCall,d("onCall",ac))end;return _c end,getBaseFrame=function(_c) -if( -_c.parent~=nil)then return _c.parent:getBaseFrame()end;return _c end,getZIndex=function(_c)return 1 end,getName=function(_c) -return _c.name end,setTime=function(_c,ac,bc)ba=ac or 0;ca=bc or 1;return _c end,start=function(_c)if(bb)then -os.cancelTimer(_b)end;da=ca;_b=os.startTimer(ba)bb=true -_c.parent:addEvent("other_event",_c)return _c end,isActive=function(_c)return bb end,cancel=function(_c)if( -_b~=nil)then os.cancelTimer(_b)end;bb=false -_c.parent:removeEvent("other_event",_c)return _c end,onCall=function(_c,ac) -ab:registerEvent("timed_event",ac)return _c end,eventHandler=function(_c,ac,bc) -if -ac=="timer"and bc==_b and bb then ab:sendEvent("timed_event",_c) -if(da>=1)then da=da-1;if(da>=1)then -_b=os.startTimer(ba)end elseif(da==-1)then _b=os.startTimer(ba)end end end}db.__index=db;return db end -end; -project['libraries']['basaltDraw'] = function(...)local d=require("tHex")local _a,aa=string.sub,string.rep -return -function(ba) -local ca=ba or term.current()local da;local _b,ab=ca.getSize()local bb={}local cb={}local db={}local _c={}local ac={}local bc={}local cc -local dc={}local function _d()cc=aa(" ",_b) -for n=0,15 do local a_a=2 ^n;local b_a=d[a_a]dc[a_a]=aa(b_a,_b)end end;_d() -local function ad()_d()local a_a=cc -local b_a=dc[colors.white]local c_a=dc[colors.black] -for currentY=1,ab do -bb[currentY]=_a( -bb[currentY]==nil and a_a or -bb[currentY]..a_a:sub(1,_b-bb[currentY]:len()),1,_b) -db[currentY]=_a(db[currentY]==nil and b_a or db[currentY]..b_a:sub(1,_b- -db[currentY]:len()),1,_b) -cb[currentY]=_a(cb[currentY]==nil and c_a or cb[currentY]..c_a:sub(1,_b- -cb[currentY]:len()),1,_b)end end;ad() -local function bd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if -(a_a+c_a:len()>0)and(a_a<=_b)then local d_a=bb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1 -local caa=_b-a_a+1;c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -bb[b_a]=_aa end end end -local function cd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=cb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then -c_a=_a(c_a,1 -a_a+1,_b-a_a+1)elseif(aaa>_b)then c_a=_a(c_a,1,_b-a_a+1)end -if(a_a>1)then _aa=_a(d_a,1,a_a-1)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -cb[b_a]=_aa end end end -local function dd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=db[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1;local caa=_b-a_a+1 -c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -db[b_a]=_aa end end end -local __a={setSize=function(a_a,b_a)_b,ab=a_a,b_a;ad()end,setMirror=function(a_a)da=a_a end,setBG=function(a_a,b_a,c_a)cd(a_a,b_a,c_a)end,setText=function(a_a,b_a,c_a) -bd(a_a,b_a,c_a)end,setFG=function(a_a,b_a,c_a)dd(a_a,b_a,c_a)end,drawBackgroundBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -cd(a_a,b_a+ (n-1),aa(d[_aa],c_a))end end,drawForegroundBox=function(a_a,b_a,c_a,d_a,_aa) -for n=1,d_a do dd(a_a,b_a+ -(n-1),aa(d[_aa],c_a))end end,drawTextBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -bd(a_a,b_a+ (n-1),aa(_aa,c_a))end end,writeText=function(a_a,b_a,c_a,d_a,_aa) -if(c_a~=nil)then -bd(a_a,b_a,c_a)if(d_a~=nil)and(d_a~=false)then -cd(a_a,b_a,aa(d[d_a],c_a:len()))end;if(_aa~=nil)and(_aa~=false)then -dd(a_a,b_a,aa(d[_aa],c_a:len()))end end end,update=function() -local a_a,b_a=ca.getCursorPos()local c_a=false -if(ca.getCursorBlink~=nil)then c_a=ca.getCursorBlink()end;ca.setCursorBlink(false)if(da~=nil)then -da.setCursorBlink(false)end -for n=1,ab do ca.setCursorPos(1,n) -ca.blit(bb[n],db[n],cb[n])if(da~=nil)then da.setCursorPos(1,n) -da.blit(bb[n],db[n],cb[n])end end;ca.setBackgroundColor(colors.black) -ca.setCursorBlink(c_a)ca.setCursorPos(a_a,b_a) -if(da~=nil)then -da.setBackgroundColor(colors.black)da.setCursorBlink(c_a)da.setCursorPos(a_a,b_a)end end,setTerm=function(a_a) -ca=a_a end}return __a end -end; -project['libraries']['basaltEvent'] = function(...) -return -function()local a={}local b={} -local c={registerEvent=function(d,_a,aa)if(a[_a]==nil)then a[_a]={}b[_a]=1 end -a[_a][b[_a] ]=aa;b[_a]=b[_a]+1;return b[_a]-1 end,removeEvent=function(d,_a,aa)a[_a][aa[_a] ]= -nil end,sendEvent=function(d,_a,...)local aa -if(a[_a]~=nil)then for ba,ca in pairs(a[_a])do local da=ca(...)if(da== -false)then aa=da end end end;return aa end}c.__index=c;return c end -end; -project['libraries']['basaltLogs'] = function(...)local _a=""local aa="basaltLog.txt"local ba="Debug" -fs.delete(_a~=""and _a.."/"..aa or aa) -local ca={__call=function(da,_b,ab)if(_b==nil)then return end -local bb=_a~=""and _a.."/"..aa or aa -local cb=fs.open(bb,fs.exists(bb)and"a"or"w") -cb.writeLine("[Basalt][".. (ab and ab or ba).."]: "..tostring(_b))cb.close()end}return setmetatable({},ca) -end; -project['libraries']['basaltMon'] = function(...) -local aa={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local ba,ca,da,_b=type,string.len,string.rep,string.sub -return -function(ab)local bb={} -for _aa,aaa in pairs(ab)do -bb[_aa]={} -for baa,caa in pairs(aaa)do local daa=peripheral.wrap(caa)if(daa==nil)then -error("Unable to find monitor "..caa)end;bb[_aa][baa]=daa -bb[_aa][baa].name=caa end end;local cb,db,_c,ac,bc,cc,dc,_d=1,1,1,1,0,0,0,0;local ad,bd=false,1 -local cd,dd=colors.white,colors.black -local function __a()local _aa,aaa=0,0 -for baa,caa in pairs(bb)do local daa,_ba=0,0 -for aba,bba in pairs(caa)do local cba,dba=bba.getSize() -daa=daa+cba;_ba=dba>_ba and dba or _ba end;_aa=_aa>daa and _aa or daa;aaa=aaa+_ba end;dc,_d=_aa,aaa end;__a() -local function a_a()local _aa=0;local aaa,baa=0,0 -for caa,daa in pairs(bb)do local _ba=0;local aba=0 -for bba,cba in pairs(daa)do -local dba,_ca=cba.getSize()if(cb-_ba>=1)and(cb-_ba<=dba)then aaa=bba end;cba.setCursorPos( -cb-_ba,db-_aa)_ba=_ba+dba -if(aba<_ca)then aba=_ca end end;if(db-_aa>=1)and(db-_aa<=aba)then baa=caa end -_aa=_aa+aba end;_c,ac=aaa,baa end;a_a() -local function b_a(_aa,...)local aaa={...}return -function()for baa,caa in pairs(bb)do for daa,_ba in pairs(caa)do -_ba[_aa](table.unpack(aaa))end end end end -local function c_a()b_a("setCursorBlink",false)() -if not(ad)then return end;if(bb[ac]==nil)then return end;local _aa=bb[ac][_c] -if(_aa==nil)then return end;_aa.setCursorBlink(ad)end -local function d_a(_aa,aaa,baa)if(bb[ac]==nil)then return end;local caa=bb[ac][_c] -if(caa==nil)then return end;caa.blit(_aa,aaa,baa)local daa,_ba=caa.getSize() -if -(ca(_aa)+cb>daa)then local aba=bb[ac][_c+1]if(aba~=nil)then aba.blit(_aa,aaa,baa)_c=_c+1;cb=cb+ -ca(_aa)end end;a_a()end -return -{clear=b_a("clear"),setCursorBlink=function(_aa)ad=_aa;c_a()end,getCursorBlink=function()return ad end,getCursorPos=function()return cb,db end,setCursorPos=function(_aa,aaa) -cb,db=_aa,aaa;a_a()c_a()end,setTextScale=function(_aa) -b_a("setTextScale",_aa)()__a()a_a()bd=_aa end,getTextScale=function()return bd end,blit=function(_aa,aaa,baa) -d_a(_aa,aaa,baa)end,write=function(_aa)_aa=tostring(_aa)local aaa=ca(_aa) -d_a(_aa,da(aa[cd],aaa),da(aa[dd],aaa))end,getSize=function()return dc,_d end,setBackgroundColor=function(_aa) -b_a("setBackgroundColor",_aa)()dd=_aa end,setTextColor=function(_aa) -b_a("setTextColor",_aa)()cd=_aa end,calculateClick=function(_aa,aaa,baa)local caa=0 -for daa,_ba in pairs(bb)do local aba=0;local bba=0 -for cba,dba in pairs(_ba)do -local _ca,aca=dba.getSize()if(dba.name==_aa)then return aaa+aba,baa+caa end -aba=aba+_ca;if(aca>bba)then bba=aca end end;caa=caa+bba end;return aaa,baa end}end -end; -project['libraries']['bigfont'] = function(...)local ba=require("tHex") -local ca={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{"000110000110110000110010101000000010000000100101","000000110110000000000010101000000010000000100101","000000000000000000000000000000000000000000000000","100010110100000010000110110000010100000100000110","000000110000000010110110000110000000000000110000","000000000000000000000000000000000000000000000000","000000110110000010000000100000100000000000000010","000000000110110100010000000010000000000000000100","000000000000000000000000000000000000000000000000","010000000000100110000000000000000000000110010000","000000000000000000000000000010000000010110000000","000000000000000000000000000000000000000000000000","011110110000000100100010110000000100000000000000","000000000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110000110110000000000000000000010100100010000000","000010000000000000110110000000000100010010000000","000000000000000000000000000000000000000000000000","010110010110100110110110010000000100000110110110","000000000000000000000110000000000110000000000000","000000000000000000000000000000000000000000000000","010100010110110000000000000000110000000010000000","110110000000000000110000110110100000000010000000","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","100100100100100100100100100100100100100100100100","000000110100110110000010000011110000000000011000","000000000100000000000010000011000110000000001000","000000000000000000000000000000000000000000000000","010000100100000000000000000100000000010010110000","000000000000000000000000000000110110110110110000","000000000000000000000000000000000000000000000000","110110110110110110000000110110110110110110110110","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","000000000000110110000110010000000000000000010010","000010000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110110110110000000000000","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110000000000000000010000","000000000000000000000000100000000000000110000110","000000000000000000000000000000000000000000000000"}}local da={}local _b={} -do local cb=0;local db=#ca[1]local _c=#ca[1][1] -for i=1,db,3 do -for j=1,_c,3 do -local ac=string.char(cb)local bc={}bc[1]=ca[1][i]:sub(j,j+2) -bc[2]=ca[1][i+1]:sub(j,j+2)bc[3]=ca[1][i+2]:sub(j,j+2)local cc={}cc[1]=ca[2][i]:sub(j, -j+2)cc[2]=ca[2][i+1]:sub(j,j+2)cc[3]=ca[2][ -i+2]:sub(j,j+2)_b[ac]={bc,cc}cb=cb+1 end end;da[1]=_b end -local function ab(cb,db)local _c={["0"]="1",["1"]="0"}if cb<=#da then return true end -for f=#da+1,cb do local ac={}local bc=da[ -f-1] -for char=0,255 do local cc=string.char(char)local dc={}local _d={} -local ad=bc[cc][1]local bd=bc[cc][2] -for i=1,#ad do local cd,dd,__a,a_a,b_a,c_a={},{},{},{},{},{} -for j=1,#ad[1]do -local d_a=_b[ad[i]:sub(j,j)][1]table.insert(cd,d_a[1])table.insert(dd,d_a[2]) -table.insert(__a,d_a[3])local _aa=_b[ad[i]:sub(j,j)][2] -if -bd[i]:sub(j,j)=="1"then -table.insert(a_a,(_aa[1]:gsub("[01]",_c))) -table.insert(b_a,(_aa[2]:gsub("[01]",_c))) -table.insert(c_a,(_aa[3]:gsub("[01]",_c)))else table.insert(a_a,_aa[1]) -table.insert(b_a,_aa[2])table.insert(c_a,_aa[3])end end;table.insert(dc,table.concat(cd)) -table.insert(dc,table.concat(dd))table.insert(dc,table.concat(__a)) -table.insert(_d,table.concat(a_a))table.insert(_d,table.concat(b_a)) -table.insert(_d,table.concat(c_a))end;ac[cc]={dc,_d}if db then db="Font"..f.."Yeld"..char -os.queueEvent(db)os.pullEvent(db)end end;da[f]=ac end;return true end -local function bb(cb,db,_c,ac,bc) -if not type(db)=="string"then error("Not a String",3)end -local cc=type(_c)=="string"and _c:sub(1,1)or ba[_c]or -error("Wrong Front Color",3) -local dc=type(ac)=="string"and ac:sub(1,1)or ba[ac]or -error("Wrong Back Color",3)if(da[cb]==nil)then ab(3,false)end;local _d=da[cb]or -error("Wrong font size selected",3)if db==""then -return{{""},{""},{""}}end;local ad={} -for c_a in db:gmatch('.')do table.insert(ad,c_a)end;local bd={}local cd=#_d[ad[1] ][1] -for nLine=1,cd do local c_a={} -for i=1,#ad do c_a[i]=_d[ad[i] ]and -_d[ad[i] ][1][nLine]or""end;bd[nLine]=table.concat(c_a)end;local dd={}local __a={}local a_a={["0"]=cc,["1"]=dc}local b_a={["0"]=dc,["1"]=cc} -for nLine=1,cd do -local c_a={}local d_a={} -for i=1,#ad do -local _aa=_d[ad[i] ]and _d[ad[i] ][2][nLine]or"" -c_a[i]=_aa:gsub("[01]", -bc and{["0"]=_c:sub(i,i),["1"]=ac:sub(i,i)}or a_a) -d_a[i]=_aa:gsub("[01]", -bc and{["0"]=ac:sub(i,i),["1"]=_c:sub(i,i)}or b_a)end;dd[nLine]=table.concat(c_a) -__a[nLine]=table.concat(d_a)end;return{bd,dd,__a}end;return bb -end; -project['libraries']['geometricPoints'] = function(...) -local function _a(da,_b,ab,bb)local cb={}if da==ab and _b==bb then return{x=da,y=ab}end -local db=math.min(da,ab)local _c,ac,bc;if db==da then ac,_c,bc=_b,ab,bb else ac,_c,bc=bb,da,_b end;local cc,dc=_c-db, -bc-ac -if cc>math.abs(dc)then local _d=ac;local ad=dc/cc;for x=db,_c do table.insert(cb,{x=x,y=math.floor( -_d+0.5)}) -_d=_d+ad end else local _d,ad=db,cc/dc -if bc>=ac then for y=ac,bc do table.insert(cb,{x=math.floor( -_d+0.5),y=y})_d=_d+ -ad end else for y=ac,bc,-1 do -table.insert(cb,{x=math.floor(_d+0.5),y=y})_d=_d-ad end end end;return cb end -local function aa(da,_b,ab)local bb={}for x=-ab,ab+1 do -local cb=math.floor(math.sqrt(ab*ab-x*x)) -for y=-cb,cb+1 do table.insert(bb,{x=da+x,y=_b+y})end end;return bb end -local function ba(da,_b,ab,bb,cb)local db,_c=math.ceil(math.floor(ab-0.5)/2),math.ceil( -math.floor(bb-0.5)/2)local ac,bc=0,_c -local cc=( ( -_c*_c)- (db*db*_c)+ (0.25 *db*db))local dc=2 *_c^2 *ac;local _d=2 *db^2 *bc;local ad={} -while dc<_d do -table.insert(ad,{x=ac+da,y=bc+_b})table.insert(ad,{x=-ac+da,y=bc+_b})table.insert(ad,{x=ac+ -da,y=-bc+_b}) -table.insert(ad,{x=-ac+da,y=-bc+_b})if cb then -for y=-bc+_b+1,bc+_b-1 do table.insert(ad,{x=ac+da,y=y})table.insert(ad,{x= --ac+da,y=y})end end -if cc<0 then ac=ac+1 -dc=dc+2 *_c^2;cc=cc+dc+_c^2 else ac,bc=ac+1,bc-1;dc=dc+2 *_c^2 -_d=_d-2 *db^2;cc=cc+dc-_d+_c^2 end end -local bd=( ( (_c*_c)* ( (ac+0.5)* (ac+0.5)))+ -( (db*db)* ( (bc-1)* (bc-1)))- (db*db*_c*_c)) -while bc>=0 do table.insert(ad,{x=ac+da,y=bc+_b})table.insert(ad,{x=- -ac+da,y=bc+_b}) -table.insert(ad,{x=ac+da,y=-bc+_b})table.insert(ad,{x=-ac+da,y=-bc+_b}) -if cb then for y=-bc+_b, -bc+_b do table.insert(ad,{x=ac+da,y=y}) -table.insert(ad,{x=-ac+da,y=y})end end -if bd>0 then bc=bc-1;_d=_d-2 *db^2;bd=bd+db^2 -_d else bc=bc-1;ac=ac+1;_d=_d-2 * -db^2;dc=dc+2 *_c^2;bd=bd+dc-_d+db^2 end end;return ad end;local function ca(da,_b,ab,bb)return ba(da,_b,ab,ab,bb)end -return -{circle=function(da,_b,ab,bb) -return ca(da,_b,ab,bb)end,rectangle=function(da,_b,ab,bb,cb)local db={} -if(cb)then for y=_b,bb do for x=da,ab do -table.insert(db,{x=x,y=y})end end else for y=_b,bb do -for x=da,ab do if -(x==da)or(x==ab)or(y==_b)or(y==bb)then -table.insert(db,{x=x,y=y})end end end end;return db end,triangle=function(da,_b,ab,bb,cb,db,_c) -local -function ac(dc,_d,ad,bd,cd,dd,__a)local a_a=(dd-_d)/ (__a-ad)local b_a=(dd-bd)/ (__a-cd)local c_a=math.ceil( -ad-0.5) -local d_a=math.ceil(__a-0.5)-1 -for y=c_a,d_a do local _aa=a_a* (y+0.5 -ad)+_d -local aaa=b_a* (y+0.5 -cd)+bd;local baa=math.ceil(_aa-0.5)local caa=math.ceil(aaa-0.5)for x=baa,caa do -table.insert(dc,{x=x,y=y})end end end -local function bc(dc,_d,ad,bd,cd,dd,__a)local a_a=(bd-_d)/ (cd-ad)local b_a=(dd-_d)/ (__a-ad) -local c_a=math.ceil(ad-0.5)local d_a=math.ceil(__a-0.5)-1 -for y=c_a,d_a do -local _aa=a_a* (y+0.5 -ad)+_d;local aaa=b_a* (y+0.5 -ad)+_d -local baa=math.ceil(_aa-0.5)local caa=math.ceil(aaa-0.5)for x=baa,caa do -table.insert(dc,{x=x,y=y})end end end;local cc={} -if(_c)then if bb<_b then da,_b,ab,bb=ab,bb,da,_b end;if db",">") -_a=string.gsub(_a,"\"",""") -_a=string.gsub(_a,"([^%w%&%;%p%\t% ])",function(aa) -return string.format("&#x%X;",string.byte(aa))end)return _a end -function d:FromXmlString(_a) -_a=string.gsub(_a,"&#x([%x]+)%;",function(aa) -return string.char(tonumber(aa,16))end) -_a=string.gsub(_a,"&#([0-9]+)%;",function(aa)return string.char(tonumber(aa,10))end)_a=string.gsub(_a,""","\"") -_a=string.gsub(_a,"'","'")_a=string.gsub(_a,">",">") -_a=string.gsub(_a,"<","<")_a=string.gsub(_a,"&","&")return _a end;function d:ParseArgs(_a,aa) -string.gsub(aa,"(%w+)=([\"'])(.-)%2",function(ba,ca,da) -_a:addProperty(ba,self:FromXmlString(da))end)end -function d:ParseXmlText(_a) -local aa={}local ba=c()table.insert(aa,ba)local ca,da,_b,ab,bb;local cb,db=1,1 -while true do -ca,db,da,_b,ab,bb=string.find(_a,"<(%/?)([%w_:]+)(.-)(%/?)>",cb)if not ca then break end;local ac=string.sub(_a,cb,ca-1) -if not -string.find(ac,"^%s*$")then -local bc=(ba:value()or"")..self:FromXmlString(ac)aa[#aa]:setValue(bc)end -if bb=="/"then local bc=c(_b)self:ParseArgs(bc,ab)ba:addChild(bc)elseif -da==""then local bc=c(_b)self:ParseArgs(bc,ab)table.insert(aa,bc) -ba=bc else local bc=table.remove(aa)ba=aa[#aa]if#aa<1 then -error("XmlParser: nothing to close with ".._b)end;if bc:name()~=_b then -error("XmlParser: trying to close "..bc.name.. -" with ".._b)end;ba:addChild(bc)end;cb=db+1 end;local _c=string.sub(_a,cb)if#aa>1 then -error("XmlParser: unclosed "..aa[#aa]:name())end;return ba end -function d:loadFile(_a,aa)if not aa then aa=system.ResourceDirectory end -local ba=system.pathForFile(_a,aa)local ca,da=io.open(ba,"r") -if ca and not da then local _b=ca:read("*a") -io.close(ca)return self:ParseXmlText(_b),nil else print(da)return nil end end;return d -end; -project['libraries']['process'] = function(...)local d={}local _a={}local aa=0 -function _a:new(ba,ca,...)local da={...} -local _b=setmetatable({path=ba},{__index=self})_b.window=ca;_b.processId=aa -if(type(ba)=="string")then -_b.coroutine=coroutine.create(function() -shell.execute(ba,table.unpack(da))end)elseif(type(ba)=="function")then -_b.coroutine=coroutine.create(function() -ba(table.unpack(da))end)else return end;d[aa]=_b;aa=aa+1;return _b end -function _a:resume(ba,...)term.redirect(self.window) -if(self.filter~=nil)then if -(ba~=self.filter)then return end;self.filter=nil end;local ca,da=coroutine.resume(self.coroutine,ba,...)if ca then -self.filter=da else error(da)end end -function _a:isDead() -if(self.coroutine~=nil)then -if -(coroutine.status(self.coroutine)=="dead")then table.remove(d,self.processId)return true end else return true end;return false end -function _a:getStatus()if(self.coroutine~=nil)then -return coroutine.status(self.coroutine)end;return nil end -function _a:start()coroutine.resume(self.coroutine)end;return _a -end; -project['libraries']['tHex'] = function(...) -return -{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"} -end; -project['libraries']['utils'] = function(...) -local b=function(c,d)if d==nil then d="%s"end;local _a={}for aa in string.gmatch(c,"([^"..d.."]+)")do -table.insert(_a,aa)end;return _a end -return -{getTextHorizontalAlign=function(c,d,_a,aa)c=string.sub(c,1,d)local ba=d-string.len(c) -if(_a=="right")then c=string.rep( -aa or" ",ba)..c elseif(_a=="center")then -c=string.rep(aa or" ",math.floor( -ba/2))..c.. -string.rep(aa or" ",math.floor(ba/2)) -c=c.. (string.len(c)daa[x])then table.insert(daa,x,dbc)break end else -table.insert(daa,dbc)end end;if(#daa<=0)then table.insert(daa,dbc)end;caa[dbc]={}end;cbc.parent=_ba;if(cbc.init~=nil)then cbc:init()end -table.insert(caa[dbc],cbc)return cbc end -local function __c(cbc,dbc) -for _cc,acc in pairs(aba)do -for bcc,ccc in pairs(acc)do -for dcc,_dc in pairs(ccc)do -if(_dc==dbc)then -table.remove(aba[_cc][bcc],dcc)if(cbc.parent~=nil)then if(cd(aba[_cc])<=0)then -cbc.parent:removeEvent(_cc,cbc)end end end end end end end -local function a_c(cbc,dbc) -for _cc,acc in pairs(caa)do -for bcc,ccc in pairs(acc)do -if(type(dbc)=="string")then -if(ccc:getName()==dbc)then -table.remove(caa[_cc],bcc)__c(_ba,ccc)cbc:updateDraw()return true end else if(ccc==dbc)then table.remove(caa[_cc],bcc)__c(_ba,ccc) -cbc:updateDraw()return true end end end end;return false end;local function b_c(cbc,dbc,_cc) -for acc,bcc in pairs(aba[dbc])do for ccc,dcc in pairs(bcc)do -if(dcc:getName()==_cc)then return dcc end end end end -local function c_c(cbc,dbc,_cc) -local acc=_cc:getZIndex()if(aba[dbc]==nil)then aba[dbc]={}end;if(bba[dbc]==nil)then -bba[dbc]={}end -if(b_c(cbc,dbc,_cc.name)~=nil)then return nil end -if(cbc.parent~=nil)then cbc.parent:addEvent(dbc,cbc)end;abb[dbc]=true -if(aba[dbc][acc]==nil)then -for x=1,#bba[dbc]+1 do -if -(bba[dbc][x]~=nil)then if(acc==bba[dbc][x])then break end;if(acc>bba[dbc][x])then -table.insert(bba[dbc],x,acc)break end else -table.insert(bba[dbc],acc)end end -if(#bba[dbc]<=0)then table.insert(bba[dbc],acc)end;aba[dbc][acc]={}end;table.insert(aba[dbc][acc],_cc)return _cc end -local function d_c(cbc,dbc,_cc) -if(aba[dbc]~=nil)then -for acc,bcc in pairs(aba[dbc])do -for ccc,dcc in pairs(bcc)do -if(dcc==_cc)then -table.remove(aba[dbc][acc],ccc)if(#aba[dbc][acc]<=0)then aba[dbc][acc]=nil -if(cbc.parent~=nil)then if( -cd(aba[dbc])<=0)then abb[dbc]=false -cbc.parent:removeEvent(dbc,cbc)end end end;return -true end end end end;return false end -local function _ac(cbc)local dbc,_cc=pcall(load("return "..cbc)) -if not(dbc)then error(cbc.. -" is not a valid dynamic code")end;return load("return "..cbc)()end -local function aac(cbc,dbc,_cc)for acc,bcc in pairs(_ca)do -if(bcc[2]==_cc)and(bcc[4]==dbc)then return bcc end end;aca=aca+1 -_ca[aca]={0,_cc,{},dbc,aca}return _ca[aca]end -local function bac(cbc,dbc)local _cc={}local acc={}for bcc in dbc:gmatch("%a+%.x")do local ccc=bcc:gsub("%.x","") -if -(ccc~="self")and(ccc~="parent")then table.insert(_cc,ccc)end end -for bcc in -dbc:gmatch("%w+%.y")do local ccc=bcc:gsub("%.y","")if(ccc~="self")and(ccc~="parent")then -table.insert(_cc,ccc)end end;for bcc in dbc:gmatch("%a+%.w")do local ccc=bcc:gsub("%.w","") -if(ccc~="self")and -(ccc~="parent")then table.insert(_cc,ccc)end end -for bcc in -dbc:gmatch("%a+%.h")do local ccc=bcc:gsub("%.h","")if(ccc~="self")and(ccc~="parent")then -table.insert(_cc,ccc)end end -for bcc,ccc in pairs(_cc)do acc[ccc]=bdb(ccc)if(acc[ccc]==nil)then -error("Dynamic Values - unable to find object "..ccc)end end;acc["self"]=cbc;acc["parent"]=cbc:getParent()return acc end -local function cac(cbc,dbc)local _cc=cbc;for acc in cbc:gmatch("%w+%.x")do -_cc=_cc:gsub(acc,dbc[acc:gsub("%.x","")]:getX())end;for acc in cbc:gmatch("%w+%.y")do -_cc=_cc:gsub(acc,dbc[acc:gsub("%.y","")]:getY())end;for acc in cbc:gmatch("%w+%.w")do -_cc=_cc:gsub(acc,dbc[acc:gsub("%.w","")]:getWidth())end;for acc in cbc:gmatch("%w+%.h")do -_cc=_cc:gsub(acc,dbc[acc:gsub("%.h","")]:getHeight())end;return _cc end -local function dac(cbc) -if(#_ca>0)then -for n=1,aca do -if(_ca[n]~=nil)then local dbc;if(#_ca[n][3]<=0)then -_ca[n][3]=bac(_ca[n][4],_ca[n][2])end -dbc=cac(_ca[n][2],_ca[n][3])_ca[n][1]=_ac(dbc)if(_ca[n][4]:getType()=="Frame")then -_ca[n][4]:recalculateDynamicValues()end end end -for dbc,_cc in pairs(daa)do if(caa[_cc]~=nil)then -for acc,bcc in pairs(caa[_cc])do if(bcc.eventHandler~=nil)then -bcc:eventHandler("dynamicValueEvent",cbc)end end end end end end;local function _bc(cbc)return _ca[cbc][1]end -local function abc(cbc) -for dbc,_cc in pairs(caa)do -for acc,bcc in pairs(_cc)do -if -(bcc.getHeight~=nil)and(bcc.getY~=nil)then -local ccc,dcc=bcc:getHeight(),bcc:getY()if(ccc+dcc-cbc:getHeight()>__b)then -__b=a_a(ccc+dcc-cbc:getHeight(),0)end end end end end;local function bbc(cbc) -if(bab~=aab)then if(bab~=nil)then bab:loseFocusHandler()end;if -(aab~=nil)then aab:getFocusHandler()end;bab=aab end end -_ba={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",addEvent=c_c,removeEvent=d_c,removeEvents=__c,getEvent=b_c,newDynamicValue=aac,recalculateDynamicValues=dac,getDynamicValue=_bc,getType=function(cbc)return -baa end,setFocusedObject=function(cbc,dbc)aab=dbc;bbc(cbc)return cbc end,getVariable=function(cbc,dbc)return -_aa.getVariable(dbc)end,setSize=function(cbc,dbc,_cc,acc) -aaa.setSize(cbc,dbc,_cc,acc)if(cbc.parent==nil)then bbb=ac(bca)end -for bcc,ccc in pairs(daa)do if(caa[ccc]~=nil)then -for dcc,_dc in -pairs(caa[ccc])do if(_dc.eventHandler~=nil)then -_dc:eventHandler("basalt_resize",_dc,cbc)end end end end;cbc:recalculateDynamicValues()cab=false;return cbc end,setTheme=function(cbc,dbc,_cc) -if( -type(dbc)=="table")then dba=dbc elseif(type(dbc)=="string")then dba[dbc]=_cc end;cbc:updateDraw()return cbc end,getTheme=function(cbc,dbc) -return -dba[dbc]or(cbc.parent~=nil and cbc.parent:getTheme(dbc)or -_aa.getTheme(dbc))end,setPosition=function(cbc,dbc,_cc,acc) -aaa.setPosition(cbc,dbc,_cc,acc) -for bcc,ccc in pairs(daa)do if(caa[ccc]~=nil)then -for dcc,_dc in pairs(caa[ccc])do if(_dc.eventHandler~=nil)then -_dc:eventHandler("basalt_reposition",_dc,cbc)end end end end;cbc:recalculateDynamicValues()return cbc end,getBasaltInstance=function(cbc)return -_aa end,setOffset=function(cbc,dbc,_cc) -bcb=dbc~=nil and -math.floor(dbc<0 and math.abs(dbc)or-dbc)or bcb -ccb=_cc~=nil and -math.floor(_cc<0 and math.abs(_cc)or-_cc)or ccb;cbc:updateDraw()return cbc end,getOffsetInternal=function(cbc)return -bcb,ccb end,getOffset=function(cbc) -return bcb<0 and math.abs(bcb)or-bcb, -ccb<0 and math.abs(ccb)or-ccb end,removeFocusedObject=function(cbc)aab=nil;bbc(cbc)return cbc end,getFocusedObject=function(cbc)return -bab end,setCursor=function(cbc,dbc,_cc,acc,bcc) -if(cbc.parent~=nil)then -local ccc,dcc=cbc:getAnchorPosition() -cbc.parent:setCursor(dbc or false,(_cc or 0)+ccc-1,(acc or 0)+dcc-1, -bcc or acb)else -local ccc,dcc=cbc:getAbsolutePosition(cbc:getAnchorPosition(cbc:getX(),cbc:getY(),true))cbb=dbc or false;if(_cc~=nil)then dbb=ccc+_cc-1 end;if(acc~=nil)then _cb=dcc+ -acc-1 end;acb=bcc or acb;if(cbb)then -bca.setTextColor(acb)bca.setCursorPos(dbb,_cb)bca.setCursorBlink(cbb)else -bca.setCursorBlink(false)end end;return cbc end,setMovable=function(cbc,dbc) -if( -cbc.parent~=nil)then d_b=dbc or not d_b -cbc.parent:addEvent("mouse_click",cbc)abb["mouse_click"]=true -cbc.parent:addEvent("mouse_up",cbc)abb["mouse_up"]=true -cbc.parent:addEvent("mouse_drag",cbc)abb["mouse_drag"]=true end;return cbc end,setScrollable=function(cbc,dbc)dda=( -dbc or dbc==nil)and true or false -if( -cbc.parent~=nil)then cbc.parent:addEvent("mouse_scroll",cbc)end;abb["mouse_scroll"]=true;return cbc end,setScrollAmount=function(cbc,dbc)__b= -dbc or __b;dab=false;return cbc end,getScrollAmount=function(cbc)return -dab and __b or abc(cbc)end,show=function(cbc)aaa.show(cbc) -if(cbc.parent==nil)then -_aa.setActiveFrame(cbc) -if(dca)and not(_da)then _aa.setMonitorFrame(cca,cbc)elseif(_da)then -_aa.setMonitorFrame(cbc:getName(),cbc,cca)else _aa.setMainFrame(cbc)end end;return cbc end,hide=function(cbc) -aaa.hide(cbc) -if(cbc.parent==nil)then if(activeFrame==cbc)then activeFrame=nil end -if(dca)and -not(_da)then if(_aa.getMonitorFrame(cca)==cbc)then -_aa.setActiveFrame(nil)end elseif(_da)then -if( -_aa.getMonitorFrame(cbc:getName())==cbc)then _aa.setActiveFrame(nil)end else -if(_aa.getMainFrame()==cbc)then _aa.setMainFrame(nil)end end end;return cbc end,addLayout=function(cbc,dbc) -if( -dbc~=nil)then -if(fs.exists(dbc))then local _cc=fs.open(dbc,"r") -local acc=cc:ParseXmlText(_cc.readAll())_cc.close()dcb={}cbc:setValuesByXMLData(acc)end end;return cbc end,getLastLayout=function(cbc)return -dcb end,addLayoutFromString=function(cbc,dbc)if(dbc~=nil)then local _cc=cc:ParseXmlText(dbc) -cbc:setValuesByXMLData(_cc)end;return cbc end,setValuesByXMLData=function(cbc,dbc) -aaa.setValuesByXMLData(cbc,dbc)if(bd("movable",dbc)~=nil)then if(bd("movable",dbc))then -cbc:setMovable(true)end end;if( -bd("scrollable",dbc)~=nil)then -if(bd("scrollable",dbc))then cbc:setScrollable(true)end end;if -(bd("monitor",dbc)~=nil)then -cbc:setMonitor(bd("monitor",dbc)):show()end;if(bd("mirror",dbc)~=nil)then -cbc:setMirror(bd("mirror",dbc))end -if(bd("bar",dbc)~=nil)then if(bd("bar",dbc))then -cbc:showBar(true)else cbc:showBar(false)end end -if(bd("barText",dbc)~=nil)then cbc.barText=bd("barText",dbc)end;if(bd("barBG",dbc)~=nil)then -cbc.barBackground=colors[bd("barBG",dbc)]end;if(bd("barFG",dbc)~=nil)then -cbc.barTextcolor=colors[bd("barFG",dbc)]end;if(bd("barAlign",dbc)~=nil)then -cbc.barTextAlign=bd("barAlign",dbc)end;if(bd("layout",dbc)~=nil)then -cbc:addLayout(bd("layout",dbc))end;if(bd("xOffset",dbc)~=nil)then -cbc:setOffset(bd("xOffset",dbc),ccb)end;if(bd("yOffset",dbc)~=nil)then -cbc:setOffset(ccb,bd("yOffset",dbc))end;if(bd("scrollAmount",dbc)~=nil)then -cbc:setScrollAmount(bd("scrollAmount",dbc))end;local _cc=dbc:children() -for acc,bcc in -pairs(_cc)do if(bcc.___name~="animation")then -local ccc=bcc.___name:gsub("^%l",string.upper) -if(_c[ccc]~=nil)then adb(bcc,cbc["add"..ccc],cbc)end end end;adb(dbc["frame"],cbc.addFrame,cbc) -adb(dbc["animation"],cbc.addAnimation,cbc)return cbc end,showBar=function(cbc,dbc)cbc.barActive= -dbc or not cbc.barActive;cbc:updateDraw() -return cbc end,setBar=function(cbc,dbc,_cc,acc)cbc.barText=dbc or""cbc.barBackground= -_cc or cbc.barBackground -cbc.barTextcolor=acc or cbc.barTextcolor;cbc:updateDraw()return cbc end,setBarTextAlign=function(cbc,dbc)cbc.barTextAlign= -dbc or"left"cbc:updateDraw()return cbc end,setMirror=function(cbc,dbc)if( -cbc.parent~=nil)then -error("Frame has to be a base frame in order to attach a mirror.")end;c_b=dbc;if(mirror~=nil)then -bbb.setMirror(mirror)end;a_b=true;return cbc end,removeMirror=function(cbc)mirror= -nil;a_b=false;bbb.setMirror(nil)return cbc end,setMonitorScale=function(cbc,dbc)if -(dca)then bca.setTextScale(dbc)end;return cbc end,setMonitor=function(cbc,dbc,_cc) -if( -dbc~=nil)and(dbc~=false)then -if(type(dbc)=="string")then -if( -peripheral.getType(dbc)=="monitor")then bca=peripheral.wrap(dbc)ada=true end -if(cbc.parent~=nil)then cbc.parent:removeObject(cbc)end;dca=true;_aa.setMonitorFrame(dbc,cbc)elseif(type(dbc)=="table")then -bca=dc(dbc)ada=true;dca=true;_da=true -_aa.setMonitorFrame(cbc:getName(),cbc,true)end else bca=parentTerminal;dca=false;_da=false -if(type(cca)=="string")then -if( -_aa.getMonitorFrame(cca)==cbc)then _aa.setMonitorFrame(cca,nil)end else -if(_aa.getMonitorFrame(cbc:getName())==cbc)then _aa.setMonitorFrame(cbc:getName(), -nil)end end end;if(_cc~=nil)then bca.setTextScale(_cc)end;bbb=ac(bca) -cbc:setSize(bca.getSize())cab=true;cca=dbc or nil;cbc:updateDraw()return cbc end,loseFocusHandler=function(cbc) -aaa.loseFocusHandler(cbc)if(bab~=nil)then bab:loseFocusHandler()bab=nil end end,getFocusHandler=function(cbc) -aaa.getFocusHandler(cbc) -if(cbc.parent~=nil)then -if(d_b)then cbc.parent:removeEvents(cbc) -cbc.parent:removeObject(cbc)cbc.parent:addObject(cbc)for dbc,_cc in pairs(abb)do if(_cc)then -cbc.parent:addEvent(dbc,cbc)end end -cbc:updateDraw()end end;if(bab~=nil)then bab:getFocusHandler()end end,eventHandler=function(cbc,dbc,_cc,acc,bcc,ccc) -aaa.eventHandler(cbc,dbc,_cc,acc,bcc,ccc) -if(aba["other_event"]~=nil)then -for dcc,_dc in ipairs(bba["other_event"])do -if( -aba["other_event"][_dc]~=nil)then for adc,bdc in ad(aba["other_event"][_dc])do -if -(bdc.eventHandler~=nil)then if(bdc:eventHandler(dbc,_cc,acc,bcc,ccc))then return true end end end end end end;if(cab)and not(dca)then -if(cbc.parent==nil)then if(dbc=="term_resize")then -cbc:setSize(bca.getSize())cab=true end end end -if(dca)then -if(cab)then -if -(dbc=="monitor_resize")then -if(type(cca)=="string")then cbc:setSize(bca.getSize())elseif( -type(cca)=="table")then -for dcc,_dc in pairs(cca)do for adc,bdc in pairs(_dc)do if(_cc==bdc)then -cbc:setSize(bca.getSize())end end end end;cab=true;cbc:updateDraw()end end -if(dbc=="peripheral")and(_cc==cca)then if -(peripheral.getType(cca)=="monitor")then ada=true;bca=peripheral.wrap(cca)bbb=ac(bca) -cbc:updateDraw()end end -if(dbc=="peripheral_detach")and(_cc==cca)then ada=false end end -if(a_b)then if(peripheral.getType(c_b)=="monitor")then b_b=true -bbb.setMirror(peripheral.wrap(c_b))end;if(dbc=="peripheral_detach")and -(_cc==c_b)then ada=false end -if -(dbc=="monitor_touch")and(c_b==_cc)then cbc:mouseHandler(1,acc,bcc,true)end end -if(dbc=="terminate")and(cbc.parent==nil)then _aa.stop()end end,mouseHandler=function(cbc,dbc,_cc,acc,bcc,ccc) -if -(_da)then if(bca.calculateClick~=nil)then -_cc,acc=bca.calculateClick(ccc,_cc,acc)end end -if(aaa.mouseHandler(cbc,dbc,_cc,acc))then -if(aba["mouse_click"]~=nil)then -cbc:setCursor(false) -for dcc,_dc in ipairs(bba["mouse_click"])do -if -(aba["mouse_click"][_dc]~=nil)then for adc,bdc in ad(aba["mouse_click"][_dc])do -if(bdc.mouseHandler~=nil)then if -(bdc:mouseHandler(dbc,_cc,acc))then bbc(cbc)return true end end end end end end -if(d_b)then -local dcc,_dc=cbc:getAbsolutePosition(cbc:getAnchorPosition())if -(_cc>=dcc)and(_cc<=dcc+cbc:getWidth()-1)and(acc==_dc)then _ab=true;bda=dcc-_cc -cda=yOff and 1 or 0 end end;cbc:removeFocusedObject()return true end;return false end,mouseUpHandler=function(cbc,dbc,_cc,acc)if -(_ab)then _ab=false end -if(aaa.mouseUpHandler(cbc,dbc,_cc,acc))then -if -(aba["mouse_up"]~=nil)then -for bcc,ccc in ipairs(bba["mouse_up"])do -if(aba["mouse_up"][ccc]~=nil)then -for dcc,_dc in -ad(aba["mouse_up"][ccc])do if(_dc.mouseUpHandler~=nil)then -if(_dc:mouseUpHandler(dbc,_cc,acc))then bbc(cbc)return true end end end end end end;bbc(cbc)return true end;return false end,scrollHandler=function(cbc,dbc,_cc,acc) -if -(aaa.scrollHandler(cbc,dbc,_cc,acc))then -if(aba["mouse_scroll"]~=nil)then -for ccc,dcc in pairs(bba["mouse_scroll"])do -if( -aba["mouse_scroll"][dcc]~=nil)then -for _dc,adc in ad(aba["mouse_scroll"][dcc])do if(adc.scrollHandler~= -nil)then -if(adc:scrollHandler(dbc,_cc,acc))then bbc(cbc)return true end end end end end end;local bcc=ccb -if(dda)then abc(cbc)if(dbc>0)or(dbc<0)then -ccb=a_a(__a(ccb-dbc,0),-__b)cbc:updateDraw()end end;cbc:removeFocusedObject()if(ccb==bcc)then return false end -return true end;return false end,dragHandler=function(cbc,dbc,_cc,acc) -if -(_ab)then local bcc,ccc=cbc.parent:getOffsetInternal()bcc=bcc<0 and -math.abs(bcc)or-bcc;ccc= -ccc<0 and math.abs(ccc)or-ccc;local dcc=1;local _dc=1;if(cbc.parent~=nil)then -dcc,_dc=cbc.parent:getAbsolutePosition(cbc.parent:getAnchorPosition())end -cbc:setPosition( -_cc+bda- (dcc-1)+bcc,acc+cda- (_dc-1)+ccc)cbc:updateDraw()return true end -if(cbc:isVisible())and(cbc:isEnabled())then -if -(aba["mouse_drag"]~=nil)then -for bcc,ccc in ipairs(bba["mouse_drag"])do -if -(aba["mouse_drag"][ccc]~=nil)then for dcc,_dc in ad(aba["mouse_drag"][ccc])do -if(_dc.dragHandler~=nil)then if -(_dc:dragHandler(dbc,_cc,acc))then bbc(cbc)return true end end end end end end end;bbc(cbc)aaa.dragHandler(cbc,dbc,_cc,acc)return false end,keyHandler=function(cbc,dbc,_cc) -if -(cbc:isFocused())or(cbc.parent==nil)then -local acc=cbc:getEventSystem():sendEvent("key",cbc,"key",dbc)if(acc==false)then return false end -if(aba["key"]~=nil)then -for bcc,ccc in pairs(bba["key"])do -if( -aba["key"][ccc]~=nil)then -for dcc,_dc in ad(aba["key"][ccc])do if(_dc.keyHandler~=nil)then if -(_dc:keyHandler(dbc,_cc))then return true end end end end end end end;return false end,keyUpHandler=function(cbc,dbc) -if -(cbc:isFocused())or(cbc.parent==nil)then -local _cc=cbc:getEventSystem():sendEvent("key_up",cbc,"key_up",dbc)if(_cc==false)then return false end -if(aba["key_up"]~=nil)then -for acc,bcc in -pairs(bba["key_up"])do -if(aba["key_up"][bcc]~=nil)then for ccc,dcc in ad(aba["key_up"][bcc])do -if( -dcc.keyUpHandler~=nil)then if(dcc:keyUpHandler(dbc))then return true end end end end end end end;return false end,charHandler=function(cbc,dbc) -if -(cbc:isFocused())or(cbc.parent==nil)then -local _cc=cbc:getEventSystem():sendEvent("char",cbc,"char",dbc)if(_cc==false)then return false end -if(aba["char"]~=nil)then -for acc,bcc in -pairs(bba["char"])do -if(aba["char"][bcc]~=nil)then for ccc,dcc in ad(aba["char"][bcc])do -if -(dcc.charHandler~=nil)then if(dcc:charHandler(dbc))then return true end end end end end end end;return false end,setText=function(cbc,dbc,_cc,acc) -local bcc,ccc=cbc:getAnchorPosition() -if(_cc>=1)and(_cc<=cbc:getHeight())then -if(cbc.parent~=nil)then -cbc.parent:setText(a_a( -dbc+ (bcc-1),bcc),ccc+_cc-1,dd(acc,a_a(1 -dbc+1,1),a_a( -cbc:getWidth()-dbc+1,1)))else -bbb.setText(a_a(dbc+ (bcc-1),bcc),ccc+_cc-1,dd(acc,a_a(1 -dbc+1,1),a_a( -cbc:getWidth()-dbc+1,1)))end end end,setBG=function(cbc,dbc,_cc,acc) -local bcc,ccc=cbc:getAnchorPosition() -if(_cc>=1)and(_cc<=cbc:getHeight())then -if(cbc.parent~=nil)then -cbc.parent:setBG(a_a( -dbc+ (bcc-1),bcc),ccc+_cc-1,dd(acc,a_a(1 -dbc+1,1),a_a( -cbc:getWidth()-dbc+1,1)))else -bbb.setBG(a_a(dbc+ (bcc-1),bcc),ccc+_cc-1,dd(acc,a_a(1 -dbc+1,1),a_a( -cbc:getWidth()-dbc+1,1)))end end end,setFG=function(cbc,dbc,_cc,acc) -local bcc,ccc=cbc:getAnchorPosition() -if(_cc>=1)and(_cc<=cbc:getHeight())then -if(cbc.parent~=nil)then -cbc.parent:setFG(a_a( -dbc+ (bcc-1),bcc),ccc+_cc-1,dd(acc,a_a(1 -dbc+1,1),a_a( -cbc:getWidth()-dbc+1,1)))else -bbb.setFG(a_a(dbc+ (bcc-1),bcc),ccc+_cc-1,dd(acc,a_a(1 -dbc+1,1),a_a( -cbc:getWidth()-dbc+1,1)))end end end,writeText=function(cbc,dbc,_cc,acc,bcc,ccc) -local dcc,_dc=cbc:getAnchorPosition() -if(_cc>=1)and(_cc<=cbc:getHeight())then -if(cbc.parent~=nil)then -cbc.parent:writeText(a_a( -dbc+ (dcc-1),dcc),_dc+_cc-1,dd(acc,a_a(1 -dbc+1,1), -cbc:getWidth()-dbc+1),bcc,ccc)else -bbb.writeText(a_a(dbc+ (dcc-1),dcc),_dc+_cc-1,dd(acc,a_a(1 -dbc+1,1),a_a( -cbc:getWidth()-dbc+1,1)),bcc,ccc)end end end,drawBackgroundBox=function(cbc,dbc,_cc,acc,bcc,ccc) -local dcc,_dc=cbc:getAnchorPosition() -bcc=(_cc<1 and( -bcc+_cc>cbc:getHeight()and cbc:getHeight()or bcc+_cc-1)or( -bcc+ -_cc>cbc:getHeight()and cbc:getHeight()-_cc+1 or bcc)) -acc=(dbc<1 and(acc+dbc>cbc:getWidth()and cbc:getWidth()or acc+ -dbc-1)or( - -acc+dbc>cbc:getWidth()and cbc:getWidth()-dbc+1 or acc)) -if(cbc.parent~=nil)then -cbc.parent:drawBackgroundBox(a_a(dbc+ (dcc-1),dcc),a_a(_cc+ (_dc-1),_dc),acc,bcc,ccc)else -bbb.drawBackgroundBox(a_a(dbc+ (dcc-1),dcc),a_a(_cc+ (_dc-1),_dc),acc,bcc,ccc)end end,drawTextBox=function(cbc,dbc,_cc,acc,bcc,ccc) -local dcc,_dc=cbc:getAnchorPosition() -bcc=(_cc<1 and( -bcc+_cc>cbc:getHeight()and cbc:getHeight()or bcc+_cc-1)or( -bcc+ -_cc>cbc:getHeight()and cbc:getHeight()-_cc+1 or bcc)) -acc=(dbc<1 and(acc+dbc>cbc:getWidth()and cbc:getWidth()or acc+ -dbc-1)or( - -acc+dbc>cbc:getWidth()and cbc:getWidth()-dbc+1 or acc)) -if(cbc.parent~=nil)then -cbc.parent:drawTextBox(a_a(dbc+ (dcc-1),dcc),a_a(_cc+ (_dc-1),_dc),acc,bcc,dd(ccc,1,1))else -bbb.drawTextBox(a_a(dbc+ (dcc-1),dcc),a_a(_cc+ (_dc-1),_dc),acc,bcc,dd(ccc,1,1))end end,drawForegroundBox=function(cbc,dbc,_cc,acc,bcc,ccc) -local dcc,_dc=cbc:getAnchorPosition() -bcc=(_cc<1 and( -bcc+_cc>cbc:getHeight()and cbc:getHeight()or bcc+_cc-1)or( -bcc+ -_cc>cbc:getHeight()and cbc:getHeight()-_cc+1 or bcc)) -acc=(dbc<1 and(acc+dbc>cbc:getWidth()and cbc:getWidth()or acc+ -dbc-1)or( - -acc+dbc>cbc:getWidth()and cbc:getWidth()-dbc+1 or acc)) -if(cbc.parent~=nil)then -cbc.parent:drawForegroundBox(a_a(dbc+ (dcc-1),dcc),a_a(_cc+ (_dc-1),_dc),acc,bcc,ccc)else -bbb.drawForegroundBox(a_a(dbc+ (dcc-1),dcc),a_a(_cc+ (_dc-1),_dc),acc,bcc,ccc)end end,draw=function(cbc,dbc)if -(dca)and not(ada)then return false end -if(cbc.parent==nil)then if(cbc:getDraw()== -false)then return false end end -if(aaa.draw(cbc))then -local _cc,acc=cbc:getAbsolutePosition(cbc:getAnchorPosition())local bcc,ccc=cbc:getAnchorPosition()local dcc,_dc=cbc:getSize() -if( -cbc.parent==nil)then -if(cbc.bgColor~=false)then -bbb.drawBackgroundBox(bcc,ccc,dcc,_dc,cbc.bgColor)bbb.drawTextBox(bcc,ccc,dcc,_dc," ")end;if(cbc.fgColor~=false)then -bbb.drawForegroundBox(bcc,ccc,dcc,_dc,cbc.fgColor)end end -if(cbc.barActive)then -if(cbc.parent~=nil)then -cbc.parent:writeText(bcc,ccc,bc.getTextHorizontalAlign(cbc.barText,dcc,cbc.barTextAlign),cbc.barBackground,cbc.barTextcolor)else -bbb.writeText(bcc,ccc,bc.getTextHorizontalAlign(cbc.barText,dcc,cbc.barTextAlign),cbc.barBackground,cbc.barTextcolor)end -if(cbc:getBorder("left"))then -if(cbc.parent~=nil)then -cbc.parent:drawBackgroundBox(bcc-1,ccc,1,1,cbc.barBackground)if(cbc.bgColor~=false)then -cbc.parent:drawBackgroundBox(bcc-1,ccc+1,1,_dc-1,cbc.bgColor)end end end -if(cbc:getBorder("top"))then if(cbc.parent~=nil)then -cbc.parent:drawBackgroundBox(bcc-1,ccc-1,dcc+1,1,cbc.barBackground)end end end;for adc,bdc in ad(daa)do -if(caa[bdc]~=nil)then for cdc,ddc in pairs(caa[bdc])do -if(ddc.draw~=nil)then ddc:draw()end end end end end end,updateTerm=function(cbc)if -(dca)and not(ada)then return false end;bbb.update()end,addObject=function(cbc,dbc)return -ddb(dbc)end,removeObject=a_c,getObject=function(cbc,dbc)return bdb(dbc)end,getDeepObject=function(cbc,dbc)return cdb(dbc)end,addFrame=function(cbc,dbc)local _cc=_aa.newFrame( -dbc or _d(),cbc,nil,_aa)return ddb(_cc)end,init=function(cbc) -if -not(_bb)then -if(c_a~=nil)then aaa.width,aaa.height=c_a:getSize() -cbc:setBackground(c_a:getTheme("FrameBG")) -cbc:setForeground(c_a:getTheme("FrameText"))else aaa.width,aaa.height=bca.getSize() -cbc:setBackground(_aa.getTheme("BasaltBG")) -cbc:setForeground(_aa.getTheme("BasaltText"))end;_bb=true end end} -for cbc,dbc in pairs(_c)do _ba["add"..cbc]=function(_cc,acc) -return ddb(dbc(acc or _d(),_cc))end end;setmetatable(_ba,aaa)return _ba end -end; -project['default']['loadObjects'] = function(...)local d={}if(packaged)then -for ba,ca in pairs(getProject("objects"))do d[ba]=ca()end;return d end -local _a=table.pack(...)local aa=fs.getDir(_a[2]or"Basalt")if(aa==nil)then -error("Unable to find directory ".. -_a[2].." please report this bug to our discord.")end;for ba,ca in -pairs(fs.list(fs.combine(aa,"objects")))do -if(ca~="example.lua")then local da=ca:gsub(".lua","")d[da]=require(da)end end;return d -end; -project['default']['Object'] = function(...)local aa=require("basaltEvent")local ba=require("utils") -local ca=ba.splitString;local da=ba.numberFromString;local _b=ba.getValueFromXML -return -function(ab)local bb="Object"local cb={}local db=1 -local _c;local ac="topLeft"local bc=false;local cc=true;local dc=false;local _d=false -local ad={left=false,right=false,top=false,bottom=false}local bd=colors.black;local cd=true;local dd=false;local __a,a_a,b_a,c_a=0,0,0,0;local d_a=true;local _aa={} -local aaa=aa() -cb={x=1,y=1,width=1,height=1,bgColor=colors.black,bgSymbol=" ",bgSymbolColor=colors.black,fgColor=colors.white,transparentColor=false,name=ab or"Object",parent=nil,show=function(baa)cc=true -baa:updateDraw()return baa end,hide=function(baa)cc=false;baa:updateDraw()return baa end,enable=function(baa) -cd=true;return baa end,disable=function(baa)cd=false;return baa end,isEnabled=function(baa)return cd end,generateXMLEventFunction=function(baa,caa,daa) -local _ba=function(aba) -if( -aba:sub(1,1)=="#")then -local bba=baa:getBaseFrame():getDeepObject(aba:sub(2,aba:len())) -if(bba~=nil)and(bba.internalObjetCall~=nil)then caa(baa,function() -bba:internalObjetCall()end)end else -caa(baa,baa:getBaseFrame():getVariable(aba))end end;if(type(daa)=="string")then _ba(daa)elseif(type(daa)=="table")then -for aba,bba in pairs(daa)do _ba(bba)end end;return baa end,setValuesByXMLData=function(baa,caa) -local daa=baa:getBaseFrame()if(_b("x",caa)~=nil)then -baa:setPosition(_b("x",caa),baa.y)end;if(_b("y",caa)~=nil)then -baa:setPosition(baa.x,_b("y",caa))end;if(_b("width",caa)~=nil)then -baa:setSize(_b("width",caa),baa.height)end;if(_b("height",caa)~=nil)then -baa:setSize(baa.width,_b("height",caa))end;if(_b("bg",caa)~=nil)then -baa:setBackground(colors[_b("bg",caa)])end;if(_b("fg",caa)~=nil)then -baa:setForeground(colors[_b("fg",caa)])end;if(_b("value",caa)~=nil)then -baa:setValue(colors[_b("value",caa)])end -if(_b("visible",caa)~=nil)then if -(_b("visible",caa))then baa:show()else baa:hide()end end -if(_b("enabled",caa)~=nil)then if(_b("enabled",caa))then baa:enable()else -baa:disable()end end;if(_b("zIndex",caa)~=nil)then -baa:setZIndex(_b("zIndex",caa))end;if(_b("anchor",caa)~=nil)then -baa:setAnchor(_b("anchor",caa))end;if(_b("shadowColor",caa)~=nil)then -baa:setShadow(colors[_b("shadowColor",caa)])end;if(_b("border",caa)~=nil)then -baa:setBorder(colors[_b("border",caa)])end;if(_b("borderLeft",caa)~=nil)then -ad["left"]=_b("borderLeft",caa)end;if(_b("borderTop",caa)~=nil)then -ad["top"]=_b("borderTop",caa)end;if(_b("borderRight",caa)~=nil)then -ad["right"]=_b("borderRight",caa)end;if(_b("borderBottom",caa)~=nil)then -ad["bottom"]=_b("borderBottom",caa)end;if(_b("borderColor",caa)~=nil)then -baa:setBorder(colors[_b("borderColor",caa)])end;if -(_b("ignoreOffset",caa)~=nil)then -if(_b("ignoreOffset",caa))then baa:ignoreOffset(true)end end;if -(_b("onClick",caa)~=nil)then -baa:generateXMLEventFunction(baa.onClick,_b("onClick",caa))end;if -(_b("onClickUp",caa)~=nil)then -baa:generateXMLEventFunction(baa.onClickUp,_b("onClickUp",caa))end;if -(_b("onScroll",caa)~=nil)then -baa:generateXMLEventFunction(baa.onScroll,_b("onScroll",caa))end;if -(_b("onDrag",caa)~=nil)then -baa:generateXMLEventFunction(baa.onDrag,_b("onDrag",caa))end;if(_b("onKey",caa)~=nil)then -baa:generateXMLEventFunction(baa.onKey,_b("onKey",caa))end;if(_b("onKeyUp",caa)~=nil)then -baa:generateXMLEventFunction(baa.onKeyUp,_b("onKeyUp",caa))end;if -(_b("onChange",caa)~=nil)then -baa:generateXMLEventFunction(baa.onChange,_b("onChange",caa))end;if -(_b("onResize",caa)~=nil)then -baa:generateXMLEventFunction(baa.onResize,_b("onResize",caa))end;if -(_b("onReposition",caa)~=nil)then -baa:generateXMLEventFunction(baa.onReposition,_b("onReposition",caa))end;if -(_b("onEvent",caa)~=nil)then -baa:generateXMLEventFunction(baa.onEvent,_b("onEvent",caa))end;if -(_b("onGetFocus",caa)~=nil)then -baa:generateXMLEventFunction(baa.onGetFocus,_b("onGetFocus",caa))end;if -(_b("onLoseFocus",caa)~=nil)then -baa:generateXMLEventFunction(baa.onLoseFocus,_b("onLoseFocus",caa))end -baa:updateDraw()return baa end,isVisible=function(baa)return -cc end,setFocus=function(baa)if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;return baa end,setZIndex=function(baa,caa) -db=caa -if(baa.parent~=nil)then baa.parent:removeObject(baa) -baa.parent:addObject(baa)baa:updateEventHandlers()end;return baa end,updateEventHandlers=function(baa) -for caa,daa in -pairs(_aa)do if(daa)then baa.parent:addEvent(caa,baa)end end end,getZIndex=function(baa)return db end,getType=function(baa)return bb end,getName=function(baa)return -baa.name end,remove=function(baa)if(baa.parent~=nil)then -baa.parent:removeObject(baa)end;baa:updateDraw()return baa end,setParent=function(baa,caa) -if( -caa.getType~=nil and caa:getType()=="Frame")then -baa:remove()caa:addObject(baa)if(baa.draw)then baa:show()end end;return baa end,setValue=function(baa,caa) -if( -_c~=caa)then _c=caa;baa:updateDraw()baa:valueChangedHandler()end;return baa end,getValue=function(baa)return _c end,getDraw=function(baa)return -d_a end,updateDraw=function(baa,caa)d_a=caa;if(caa==nil)then d_a=true end;if(d_a)then if(baa.parent~=nil)then -baa.parent:updateDraw()end end;return baa end,getEventSystem=function(baa)return -aaa end,getParent=function(baa)return baa.parent end,setPosition=function(baa,caa,daa,_ba) -if(type(caa)=="number")then baa.x= -_ba and baa:getX()+caa or caa end;if(type(daa)=="number")then -baa.y=_ba and baa:getY()+daa or daa end -if(baa.parent~=nil)then if(type(caa)=="string")then -baa.x=baa.parent:newDynamicValue(baa,caa)end;if(type(daa)=="string")then -baa.y=baa.parent:newDynamicValue(baa,daa)end -baa.parent:recalculateDynamicValues()end;aaa:sendEvent("basalt_reposition",baa) -baa:updateDraw()return baa end,getX=function(baa)return - -type(baa.x)=="number"and baa.x or math.floor(baa.x[1]+0.5)end,getY=function(baa)return - -type(baa.y)=="number"and baa.y or math.floor(baa.y[1]+0.5)end,getPosition=function(baa)return -baa:getX(),baa:getY()end,getVisibility=function(baa)return cc end,setVisibility=function(baa,caa) -cc=caa or not cc;baa:updateDraw()return baa end,setSize=function(baa,caa,daa,_ba)if(type(caa)== -"number")then -baa.width=_ba and baa.width+caa or caa end -if(type(daa)=="number")then baa.height=_ba and -baa.height+daa or daa end -if(baa.parent~=nil)then if(type(caa)=="string")then -baa.width=baa.parent:newDynamicValue(baa,caa)end;if(type(daa)=="string")then -baa.height=baa.parent:newDynamicValue(baa,daa)end -baa.parent:recalculateDynamicValues()end;aaa:sendEvent("basalt_resize",baa) -baa:updateDraw()return baa end,getHeight=function(baa) -return -type(baa.height)=="number"and baa.height or -math.floor(baa.height[1]+0.5)end,getWidth=function(baa)return - -type(baa.width)=="number"and baa.width or math.floor(baa.width[1]+0.5)end,getSize=function(baa)return -baa:getWidth(),baa:getHeight()end,calculateDynamicValues=function(baa) -if( -type(baa.width)=="table")then baa.width:calculate()end -if(type(baa.height)=="table")then baa.height:calculate()end -if(type(baa.x)=="table")then baa.x:calculate()end -if(type(baa.y)=="table")then baa.y:calculate()end;baa:updateDraw()return baa end,setBackground=function(baa,caa,daa,_ba)baa.bgColor= -caa or false -baa.bgSymbol=daa or(baa.bgColor~=false and baa.bgSymbol or -false)baa.bgSymbolColor=_ba or baa.bgSymbolColor -baa:updateDraw()return baa end,setTransparent=function(baa,caa)baa.transparentColor= -caa or false;baa.bgSymbol=false;baa.bgSymbolColor=false -baa:updateDraw()return baa end,getBackground=function(baa)return -baa.bgColor end,setForeground=function(baa,caa)baa.fgColor=caa or false -baa:updateDraw()return baa end,getForeground=function(baa)return baa.fgColor end,setShadow=function(baa,caa)if( -caa==false)then _d=false else bd=caa;_d=true end -baa:updateDraw()return baa end,isShadowActive=function(baa)return _d end,setBorder=function(baa,...) -if( -...~=nil)then local caa={...} -for daa,_ba in pairs(caa)do if(_ba=="left")or(#caa==1)then -ad["left"]=caa[1]end;if(_ba=="top")or(#caa==1)then -ad["top"]=caa[1]end;if(_ba=="right")or(#caa==1)then -ad["right"]=caa[1]end;if(_ba=="bottom")or(#caa==1)then -ad["bottom"]=caa[1]end end end;baa:updateDraw()return baa end,getBorder=function(baa,caa)if( -caa=="left")then return borderLeft end -if(caa=="top")then return borderTop end;if(caa=="right")then return borderRight end;if(caa=="bottom")then -return borderBottom end end,draw=function(baa) -if -(cc)then -if(baa.parent~=nil)then local caa,daa=baa:getAnchorPosition() -local _ba,aba=baa:getSize()local bba,cba=baa.parent:getSize() -if(caa+_ba<1)or(caa>bba)or(daa+ -aba<1)or(daa>cba)then return false end;if(baa.transparentColor~=false)then -baa.parent:drawForegroundBox(caa,daa,_ba,aba,baa.transparentColor)end;if(baa.bgColor~=false)then -baa.parent:drawBackgroundBox(caa,daa,_ba,aba,baa.bgColor)end -if(baa.bgSymbol~=false)then -baa.parent:drawTextBox(caa,daa,_ba,aba,baa.bgSymbol)if(baa.bgSymbol~=" ")then -baa.parent:drawForegroundBox(caa,daa,_ba,aba,baa.bgSymbolColor)end end -if(_d)then -baa.parent:drawBackgroundBox(caa+1,daa+aba,_ba,1,bd) -baa.parent:drawBackgroundBox(caa+_ba,daa+1,1,aba,bd) -baa.parent:drawForegroundBox(caa+1,daa+aba,_ba,1,bd) -baa.parent:drawForegroundBox(caa+_ba,daa+1,1,aba,bd)end -if(ad["left"]~=false)then -baa.parent:drawTextBox(caa-1,daa,1,aba,"\149") -baa.parent:drawBackgroundBox(caa-1,daa,1,aba,baa.bgColor) -baa.parent:drawForegroundBox(caa-1,daa,1,aba,ad["left"])end -if(ad["left"]~=false)and(ad["top"]~=false)then baa.parent:drawTextBox( -caa-1,daa-1,1,1,"\151")baa.parent:drawBackgroundBox( -caa-1,daa-1,1,1,baa.bgColor)baa.parent:drawForegroundBox( -caa-1,daa-1,1,1,ad["left"])end -if(ad["top"]~=false)then -baa.parent:drawTextBox(caa,daa-1,_ba,1,"\131") -baa.parent:drawBackgroundBox(caa,daa-1,_ba,1,baa.bgColor) -baa.parent:drawForegroundBox(caa,daa-1,_ba,1,ad["top"])end -if(ad["top"]~=false)and(ad["right"]~=false)then baa.parent:drawTextBox( -caa+_ba,daa-1,1,1,"\148") -baa.parent:drawForegroundBox( -caa+_ba,daa-1,1,1,baa.bgColor) -baa.parent:drawBackgroundBox(caa+_ba,daa-1,1,1,ad["right"])end -if(ad["right"]~=false)then -baa.parent:drawTextBox(caa+_ba,daa,1,aba,"\149") -baa.parent:drawForegroundBox(caa+_ba,daa,1,aba,baa.bgColor) -baa.parent:drawBackgroundBox(caa+_ba,daa,1,aba,ad["right"])end -if(ad["right"]~=false)and(ad["bottom"]~=false)then baa.parent:drawTextBox( -caa+_ba,daa+aba,1,1,"\133") -baa.parent:drawForegroundBox( -caa+_ba,daa+aba,1,1,baa.bgColor) -baa.parent:drawBackgroundBox(caa+_ba,daa+aba,1,1,ad["right"])end -if(ad["bottom"]~=false)then -baa.parent:drawTextBox(caa,daa+aba,_ba,1,"\143") -baa.parent:drawForegroundBox(caa,daa+aba,_ba,1,baa.bgColor) -baa.parent:drawBackgroundBox(caa,daa+aba,_ba,1,ad["bottom"])end -if(ad["bottom"]~=false)and(ad["left"]~=false)then baa.parent:drawTextBox( -caa-1,daa+aba,1,1,"\138") -baa.parent:drawForegroundBox( -caa-1,daa+aba,1,1,baa.bgColor) -baa.parent:drawBackgroundBox(caa-1,daa+aba,1,1,ad["left"])end end;d_a=false;return true end;return false end,getAbsolutePosition=function(baa,caa,daa) -if( -caa==nil)or(daa==nil)then caa,daa=baa:getAnchorPosition()end -if(baa.parent~=nil)then -local _ba,aba=baa.parent:getAbsolutePosition()caa=_ba+caa-1;daa=aba+daa-1 end;return caa,daa end,getAnchorPosition=function(baa,caa,daa,_ba)if( -caa==nil)then caa=baa:getX()end -if(daa==nil)then daa=baa:getY()end -if(baa.parent~=nil)then local aba,bba=baa.parent:getSize() -if(ac=="top")then caa=math.floor( -aba/2)+caa-1 elseif(ac=="topRight")then -caa=aba+caa-1 elseif(ac=="right")then caa=aba+caa-1 -daa=math.floor(bba/2)+daa-1 elseif(ac=="bottomRight")then caa=aba+caa-1;daa=bba+daa-1 elseif(ac=="bottom")then caa=math.floor( -aba/2)+caa-1;daa=bba+daa-1 elseif(ac== -"bottomLeft")then daa=bba+daa-1 elseif(ac=="left")then -daa=math.floor(bba/2)+daa-1 elseif(ac=="center")then caa=math.floor(aba/2)+caa-1;daa=math.floor( -bba/2)+daa-1 end;local cba,dba=baa.parent:getOffsetInternal()if not(bc or _ba)then return caa+ -cba,daa+dba end end;return caa,daa end,ignoreOffset=function(baa,caa) -bc=caa;if(caa==nil)then bc=true end;return baa end,getBaseFrame=function(baa) -if( -baa.parent~=nil)then return baa.parent:getBaseFrame()end;return baa end,setAnchor=function(baa,caa)ac=caa -baa:updateDraw()return baa end,getAnchor=function(baa)return ac end,onChange=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("value_changed",daa)end end;return baa end,onClick=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("mouse_click",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true end;return -baa end,onClickUp=function(baa,...)for caa,daa in -pairs(table.pack(...))do -if(type(daa)=="function")then baa:registerEvent("mouse_up",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_up",baa)_aa["mouse_up"]=true end;return baa end,onScroll=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("mouse_scroll",daa)end end -if(baa.parent~=nil)then -baa.parent:addEvent("mouse_scroll",baa)_aa["mouse_scroll"]=true end;return baa end,onDrag=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("mouse_drag",daa)end end -if(baa.parent~=nil)then -baa.parent:addEvent("mouse_drag",baa)_aa["mouse_drag"]=true -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true -baa.parent:addEvent("mouse_up",baa)_aa["mouse_up"]=true end;return baa end,onEvent=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("other_event",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)_aa["other_event"]=true end;return -baa end,onKey=function(baa,...) -if -(cd)then for caa,daa in pairs(table.pack(...))do -if(type(daa)=="function")then -baa:registerEvent("key",daa)baa:registerEvent("char",daa)end end -if -(baa.parent~=nil)then baa.parent:addEvent("key",baa) -baa.parent:addEvent("char",baa)_aa["key"]=true;_aa["char"]=true end end;return baa end,onResize=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("basalt_resize",daa)end end;return baa end,onReposition=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("basalt_reposition",daa)end end;return baa end,onKeyUp=function(baa,...)for caa,daa in -pairs(table.pack(...))do -if(type(daa)=="function")then baa:registerEvent("key_up",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("key_up",baa)_aa["key_up"]=true end;return baa end,isFocused=function(baa)if( -baa.parent~=nil)then -return baa.parent:getFocusedObject()==baa end;return false end,onGetFocus=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("get_focus",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true end;return -baa end,onLoseFocus=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("lose_focus",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)_aa["mouse_click"]=true end;return -baa end,registerEvent=function(baa,caa,daa)return -aaa:registerEvent(caa,daa)end,removeEvent=function(baa,caa,daa) -return aaa:removeEvent(caa,daa)end,sendEvent=function(baa,caa,...)return aaa:sendEvent(caa,baa,...)end,isCoordsInObject=function(baa,caa,daa) -if -(cc)and(cd)then -local _ba,aba=baa:getAbsolutePosition(baa:getAnchorPosition())local bba,cba=baa:getSize() -if -(_ba<=caa)and(_ba+bba>caa)and(aba<=daa)and(aba+cba>daa)then return true end end;return false end,mouseHandler=function(baa,caa,daa,_ba,aba) -if -(baa:isCoordsInObject(daa,_ba))then -local bba=aaa:sendEvent("mouse_click",baa,"mouse_click",caa,daa,_ba,aba)if(bba==false)then return false end;if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;dd=true;__a,a_a=daa,_ba;return true end;return false end,mouseUpHandler=function(baa,caa,daa,_ba) -dd=false -if(baa:isCoordsInObject(daa,_ba))then -local aba=aaa:sendEvent("mouse_up",baa,"mouse_up",caa,daa,_ba)if(aba==false)then return false end;return true end;return false end,dragHandler=function(baa,caa,daa,_ba) -if -(dd)then local aba,bba,cba,dba=0,0,1,1 -if(baa.parent~=nil)then -aba,bba=baa.parent:getOffsetInternal()aba=aba<0 and math.abs(aba)or-aba;bba=bba<0 and -math.abs(bba)or-bba -cba,dba=baa.parent:getAbsolutePosition(baa.parent:getAnchorPosition())end -local _ca,aca=daa+b_a- (cba-1)+aba,_ba+c_a- (dba-1)+bba -local bca=aaa:sendEvent("mouse_drag",baa,caa,_ca,aca,__a-daa,a_a-_ba,daa,_ba) -local cca,dca=baa:getAbsolutePosition(baa:getAnchorPosition())__a,a_a=daa,_ba;if(bca~=nil)then return bca end;if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;return true end -if(baa:isCoordsInObject(daa,_ba))then -local aba,bba=baa:getAbsolutePosition(baa:getAnchorPosition())__a,a_a=daa,_ba;b_a,c_a=aba-daa,bba-_ba end;return false end,scrollHandler=function(baa,caa,daa,_ba) -if -(baa:isCoordsInObject(daa,_ba))then -local aba=aaa:sendEvent("mouse_scroll",baa,"mouse_scroll",caa,daa,_ba)if(aba==false)then return false end;if(baa.parent~=nil)then -baa.parent:setFocusedObject(baa)end;return true end;return false end,keyHandler=function(baa,caa,daa)if -(cd)and(cc)then -if(baa:isFocused())then -local _ba=aaa:sendEvent("key",baa,"key",caa,daa)if(_ba==false)then return false end;return true end end;return -false end,keyUpHandler=function(baa,caa)if -(cd)and(cc)then -if(baa:isFocused())then -local daa=aaa:sendEvent("key_up",baa,"key_up",caa)if(daa==false)then return false end;return true end end;return -false end,charHandler=function(baa,caa)if -(cd)and(cc)then -if(baa:isFocused())then -local daa=aaa:sendEvent("char",baa,"char",caa)if(daa==false)then return false end;return true end end -return false end,valueChangedHandler=function(baa) -aaa:sendEvent("value_changed",baa,_c)end,eventHandler=function(baa,caa,daa,_ba,aba,bba) -local cba=aaa:sendEvent("other_event",baa,caa,daa,_ba,aba,bba)if(cba~=nil)then return cba end;return true end,getFocusHandler=function(baa) -local caa=aaa:sendEvent("get_focus",baa)if(caa~=nil)then return caa end;return true end,loseFocusHandler=function(baa) -dd=false;local caa=aaa:sendEvent("lose_focus",baa) -if(caa~=nil)then return caa end;return true end,init=function(baa) -if -(baa.parent~=nil)then for caa,daa in pairs(_aa)do -if(daa)then baa.parent:addEvent(caa,baa)end end end;if not(dc)then dc=true;return true end end}cb.__index=cb;return cb end -end; -project['default']['theme'] = function(...) -return -{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=false,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green,LabelBG=false,LabelText=colors.black} -end; -local daa=require("basaltEvent")() -local _ba=require("Frame")local aba=require("theme")local bba=require("utils") -local cba=require("basaltLogs")local dba=bba.uuid;local _ca=bba.createText;local aca=bba.tableCount -local bca=term.current()local cca="1.6.2"local dca=true -local _da=fs.getDir(table.pack(...)[2]or"")local ada,bda,cda,dda,__b,a_b={},{},{},{},{},{}local b_b,c_b,d_b,_ab;local aab={}if not term.isColor or not -term.isColor()then -error('Basalt requires an advanced (golden) computer to run.',0)end;local function bab()_ab=false -bca.clear()bca.setCursorPos(1,1)end;local cab=function(bcb,ccb) -__b[bcb]=ccb end -local dab=function(bcb)return __b[bcb]end;local _bb=function(bcb)aba=bcb end -local abb=function(bcb)return aba[bcb]end -local bbb={getMainFrame=function()return b_b end,setVariable=cab,getVariable=dab,getTheme=abb,setMainFrame=function(bcb)b_b=bcb end,getActiveFrame=function()return c_b end,setActiveFrame=function(bcb)c_b=bcb end,getFocusedObject=function()return -d_b end,setFocusedObject=function(bcb)d_b=bcb end,getMonitorFrame=function(bcb) -return cda[bcb]or dda[bcb][1]end,setMonitorFrame=function(bcb,ccb,dcb)if(b_b==ccb)then b_b=nil end;if(dcb)then -dda[bcb]={ccb,sides}else cda[bcb]=ccb end -if(ccb==nil)then dda[bcb]=nil end end,getBaseTerm=function() -return bca end,stop=bab,newFrame=_ba,getDirectory=function()return _da end} -local cbb=function(bcb)bca.clear()bca.setBackgroundColor(colors.black) -bca.setTextColor(colors.red)local ccb,dcb=bca.getSize() -if(aab.logging)then cba(bcb,"Error")end;local _db=_ca("Basalt error: "..bcb,ccb)local adb=1;for bdb,cdb in pairs(_db)do -bca.setCursorPos(1,adb)bca.write(cdb)adb=adb+1 end;bca.setCursorPos(1, -adb+1)_ab=false end -local function dbb(bcb,ccb,dcb,_db,adb) -if(#a_b>0)then local bdb={} -for n=1,#a_b do -if(a_b[n]~=nil)then -if -(coroutine.status(a_b[n])=="suspended")then -local cdb,ddb=coroutine.resume(a_b[n],bcb,ccb,dcb,_db,adb)if not(cdb)then cbb(ddb)end else table.insert(bdb,n)end end end -for n=1,#bdb do table.remove(a_b,bdb[n]- (n-1))end end end -local function _cb()if(_ab==false)then return end;if(b_b~=nil)then b_b:draw() -b_b:updateTerm()end -for bcb,ccb in pairs(cda)do ccb:draw()ccb:updateTerm()end -for bcb,ccb in pairs(dda)do ccb[1]:draw()ccb[1]:updateTerm()end end -local function acb(bcb,ccb,dcb,_db,adb)if -(daa:sendEvent("basaltEventCycle",bcb,ccb,dcb,_db,adb)==false)then return end -if(b_b~=nil)then -if(bcb=="mouse_click")then -b_b:mouseHandler(ccb,dcb,_db,false)c_b=b_b elseif(bcb=="mouse_drag")then b_b:dragHandler(ccb,dcb,_db,adb) -c_b=b_b elseif(bcb=="mouse_up")then b_b:mouseUpHandler(ccb,dcb,_db,adb)c_b=b_b elseif(bcb== -"mouse_scroll")then b_b:scrollHandler(ccb,dcb,_db,adb)c_b=b_b end end -if(bcb=="monitor_touch")then if(cda[ccb]~=nil)then -cda[ccb]:mouseHandler(1,dcb,_db,true)c_b=cda[ccb]end -if(aca(dda)>0)then for bdb,cdb in pairs(dda)do -cdb[1]:mouseHandler(1,dcb,_db,true,ccb)end end end -if(bcb=="char")then if(c_b~=nil)then c_b:charHandler(ccb)end end;if(bcb=="key_up")then if(c_b~=nil)then c_b:keyUpHandler(ccb)end -ada[ccb]=false end -if(bcb=="key")then if(c_b~=nil)then -c_b:keyHandler(ccb,dcb)end;ada[ccb]=true end -if(bcb=="terminate")then if(c_b~=nil)then c_b:eventHandler(bcb) -if(_ab==false)then return end end end -if - - - -(bcb~="mouse_click")and(bcb~="mouse_up")and(bcb~="mouse_scroll")and(bcb~="mouse_drag")and(bcb~="key")and(bcb~="key_up")and(bcb~= -"char")and(bcb~="terminate")then -for bdb,cdb in pairs(bda)do cdb:eventHandler(bcb,ccb,dcb,_db,adb)end end;dbb(bcb,ccb,dcb,_db,adb)_cb()end -aab={logging=false,setTheme=_bb,getTheme=abb,drawFrames=_cb,getVersion=function()return cca end,setVariable=cab,getVariable=dab,setBaseTerm=function(bcb)bca=bcb end,log=function(...)cba(...)end,autoUpdate=function(bcb) -_ab=bcb;if(bcb==nil)then _ab=true end;local function ccb()_cb()while _ab do -acb(os.pullEventRaw())end end -local dcb,_db=xpcall(ccb,debug.traceback)if not(dcb)then cbb(_db)return end end,update=function(bcb,ccb,dcb,_db,adb) -if( -bcb~=nil)then -local bdb,cdb=xpcall(acb,debug.traceback,bcb,ccb,dcb,_db,adb)if not(bdb)then cbb(cdb)return end end end,stop=bab,stopUpdate=bab,isKeyDown=function(bcb)if( -ada[bcb]==nil)then return false end;return ada[bcb]end,getFrame=function(bcb)for ccb,dcb in -pairs(bda)do if(dcb.name==bcb)then return dcb end end end,getActiveFrame=function()return -c_b end,setActiveFrame=function(bcb) -if(bcb:getType()=="Frame")then c_b=bcb;return true end;return false end,onEvent=function(...) -for bcb,ccb in -pairs(table.pack(...))do if(type(ccb)=="function")then -daa:registerEvent("basaltEventCycle",ccb)end end end,schedule=function(bcb) -assert(bcb~= -"function","Schedule needs a function in order to work!")return -function(...)local ccb=coroutine.create(bcb) -local dcb,_db=coroutine.resume(ccb,...)if(dcb)then table.insert(a_b,ccb)else cbb(_db)end end end,createFrame=function(bcb)bcb= -bcb or dba() -for dcb,_db in pairs(bda)do if(_db.name==bcb)then return nil end end;local ccb=_ba(bcb,nil,nil,bbb)ccb:init() -table.insert(bda,ccb)if -(b_b==nil)and(ccb:getName()~="basaltDebuggingFrame")then ccb:show()end;return ccb end,removeFrame=function(bcb)bda[bcb]= -nil end,setProjectDir=function(bcb)_da=bcb end,debug=function(...)local bcb={...}if(b_b==nil)then -print(...)return end;if(b_b.name~="basaltDebuggingFrame")then -if -(b_b~=aab.debugFrame)then aab.debugLabel:setParent(b_b)end end;local ccb=""for dcb,_db in pairs(bcb)do -ccb=ccb.. -tostring(_db).. (#bcb~=dcb and", "or"")end -aab.debugLabel:setText("[Debug] "..ccb)for dcb,_db in pairs(_ca(ccb,aab.debugList:getWidth()))do -aab.debugList:addItem(_db)end -if( -aab.debugList:getItemCount()>50)then aab.debugList:removeItem(1)end -aab.debugList:setValue(aab.debugList:getItem(aab.debugList:getItemCount()))if -(aab.debugList.getItemCount()>aab.debugList:getHeight())then -aab.debugList:setOffset(aab.debugList:getItemCount()- -aab.debugList:getHeight())end -aab.debugLabel:show()end} -aab.debugFrame=aab.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) -aab.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if( -aab.oldFrame~=nil)then aab.oldFrame:show()end end):setBackground(colors.red):show() -aab.debugList=aab.debugFrame:addList("debugList"):setSize("parent.w - 2","parent.h - 3"):setPosition(2,3):setScrollable(true):show() -aab.debugLabel=aab.debugFrame:addLabel("debugLabel"):onClick(function() -aab.oldFrame=b_b;aab.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return aab \ No newline at end of file diff --git a/docs/docs1_6/versions/basalt-1.6.3.lua b/docs/docs1_6/versions/basalt-1.6.3.lua deleted file mode 100644 index 2087e5c..0000000 --- a/docs/docs1_6/versions/basalt-1.6.3.lua +++ /dev/null @@ -1,2737 +0,0 @@ -local project = {} -local packaged = true -local baseRequire = require -local require = function(path) - for _,v in pairs(project)do - for name,b in pairs(v)do - if(name==path)then - return b() - end - end - end - return baseRequire(path); -end -local getProject = function(subDir) - if(subDir~=nil)then - return project[subDir] - end - return project -end -project['objects'] = {}project['libraries'] = {}project['default'] = {}project['objects']['Animation'] = function(...)local cda=require("utils").getValueFromXML -local dda=require("basaltEvent") -local __b,a_b,b_b,c_b,d_b,_ab=math.floor,math.sin,math.cos,math.pi,math.sqrt,math.pow -local aab=function(_dc,adc,bdc)return _dc+ (adc-_dc)*bdc end;local bab=function(_dc)return _dc end -local cab=function(_dc)return 1 -_dc end;local dab=function(_dc)return _dc*_dc*_dc end;local _bb=function(_dc)return -cab(dab(cab(_dc)))end;local abb=function(_dc)return -aab(dab(_dc),_bb(_dc),_dc)end;local bbb=function(_dc)return a_b( -(_dc*c_b)/2)end -local cbb=function(_dc)return cab(b_b(( -_dc*c_b)/2))end -local dbb=function(_dc)return- (b_b(c_b*x)-1)/2 end -local _cb=function(_dc)local adc=1.70158;local bdc=adc+1;return bdc*_dc^3 -adc*_dc^2 end;local acb=function(_dc)return _dc^3 end -local bcb=function(_dc)local adc=(2 *c_b)/3;return - -_dc==0 and 0 or(_dc==1 and 1 or(-2 ^ (10 *_dc-10)* -a_b((_dc*10 -10.75)*adc)))end -local function ccb(_dc)return _dc==0 and 0 or 2 ^ (10 *_dc-10)end -local function dcb(_dc)return _dc==0 and 0 or 2 ^ (10 *_dc-10)end -local function _db(_dc)local adc=1.70158;local bdc=adc*1.525;return -_dc<0.5 and( (2 *_dc)^2 * -( (bdc+1)*2 *_dc-bdc))/2 or -( -(2 *_dc-2)^2 * ( (bdc+1)* (_dc*2 -2)+bdc)+2)/2 end;local function adb(_dc)return -_dc<0.5 and 4 *_dc^3 or 1 - (-2 *_dc+2)^3 /2 end -local function bdb(_dc) -local adc=(2 *c_b)/4.5 -return -_dc==0 and 0 or(_dc==1 and 1 or -( -_dc<0.5 and- (2 ^ (20 *_dc-10)* -a_b((20 *_dc-11.125)*adc))/2 or -(2 ^ (-20 *_dc+10)*a_b((20 *_dc-11.125)*adc))/2 +1))end -local function cdb(_dc)return -_dc==0 and 0 or(_dc==1 and 1 or -( -_dc<0.5 and 2 ^ (20 *_dc-10)/2 or(2 -2 ^ (-20 *_dc+10))/2))end;local function ddb(_dc)return -_dc<0.5 and 2 *_dc^2 or 1 - (-2 *_dc+2)^2 /2 end;local function __c(_dc)return -_dc<0.5 and 8 * -_dc^4 or 1 - (-2 *_dc+2)^4 /2 end;local function a_c(_dc)return -_dc<0.5 and 16 * -_dc^5 or 1 - (-2 *_dc+2)^5 /2 end;local function b_c(_dc) -return _dc^2 end;local function c_c(_dc)return _dc^4 end -local function d_c(_dc)return _dc^5 end;local function _ac(_dc)local adc=1.70158;local bdc=adc+1;return -1 +bdc* (_dc-1)^3 +adc* (_dc-1)^2 end;local function aac(_dc)return 1 - -(1 -_dc)^3 end -local function bac(_dc)local adc=(2 *c_b)/3;return - -_dc==0 and 0 or(_dc==1 and 1 or( -2 ^ (-10 *_dc)*a_b((_dc*10 -0.75)*adc)+1))end -local function cac(_dc)return _dc==1 and 1 or 1 -2 ^ (-10 *_dc)end;local function dac(_dc)return 1 - (1 -_dc)* (1 -_dc)end;local function _bc(_dc)return 1 - ( -1 -_dc)^4 end;local function abc(_dc) -return 1 - (1 -_dc)^5 end;local function bbc(_dc) -return 1 -d_b(1 -_ab(_dc,2))end -local function cbc(_dc)return d_b(1 -_ab(_dc-1,2))end -local function dbc(_dc)return - -_dc<0.5 and(1 -d_b(1 -_ab(2 *_dc,2)))/2 or(d_b(1 -_ab(-2 *_dc+2,2))+1)/2 end -local function _cc(_dc)local adc=7.5625;local bdc=2.75 -if(_dc<1 /bdc)then return adc*_dc*_dc elseif(_dc<2 /bdc)then local cdc=_dc- -1.5 /bdc;return adc*cdc*cdc+0.75 elseif(_dc<2.5 /bdc)then local cdc=_dc- -2.25 /bdc;return adc*cdc*cdc+0.9375 else -local cdc=_dc-2.625 /bdc;return adc*cdc*cdc+0.984375 end end;local function acc(_dc)return 1 -_cc(1 -_dc)end;local function bcc(_dc)return -x<0.5 and(1 - -_cc(1 -2 *_dc))/2 or(1 +_cc(2 *_dc-1))/2 end -local ccc={linear=bab,lerp=aab,flip=cab,easeIn=dab,easeInSine=cbb,easeInBack=_cb,easeInCubic=acb,easeInElastic=bcb,easeInExpo=dcb,easeInQuad=b_c,easeInQuart=c_c,easeInQuint=d_c,easeInCirc=bbc,easeInBounce=acc,easeOut=_bb,easeOutSine=bbb,easeOutBack=_ac,easeOutCubic=aac,easeOutElastic=bac,easeOutExpo=cac,easeOutQuad=dac,easeOutQuart=_bc,easeOutQuint=abc,easeOutCirc=cbc,easeOutBounce=_cc,easeInOut=abb,easeInOutSine=dbb,easeInOutBack=_db,easeInOutCubic=adb,easeInOutElastic=bdb,easeInOutExpo=cdb,easeInOutQuad=ddb,easeInOutQuart=__c,easeInOutQuint=a_c,easeInOutCirc=dbc,easeInOutBounce=bcc}local dcc={} -return -function(_dc)local adc={}local bdc="Animation"local cdc;local ddc={}local __d=0;local a_d=false;local b_d=1;local c_d=false -local d_d=dda()local _ad=0;local aad;local bad=false;local cad=false;local dad="easeOut"local _bd;local function abd(_cd)for acd,bcd in pairs(_cd)do -bcd(adc,ddc[b_d].t,b_d)end end -local function bbd(_cd)if(b_d==1)then -_cd:animationStartHandler()end;if(ddc[b_d]~=nil)then abd(ddc[b_d].f) -__d=ddc[b_d].t end;b_d=b_d+1 -if(ddc[b_d]==nil)then if(c_d)then b_d=1;__d=0 else -_cd:animationDoneHandler()return end end;if(ddc[b_d].t>0)then -cdc=os.startTimer(ddc[b_d].t-__d)else bbd(_cd)end end -local function cbd(_cd,acd)for n=1,#ddc do -if(ddc[n].t==_cd)then table.insert(ddc[n].f,acd)return end end -for n=1,#ddc do -if(ddc[n].t>_cd)then if -(ddc[n-1]~=nil)then if(ddc[n-1].t<_cd)then -table.insert(ddc,n-1,{t=_cd,f={acd}})return end else -table.insert(ddc,n,{t=_cd,f={acd}})return end end end -if(#ddc<=0)then table.insert(ddc,1,{t=_cd,f={acd}})return elseif( -ddc[#ddc].t<_cd)then table.insert(ddc,{t=_cd,f={acd}})end end -local function dbd(_cd,acd,bcd,ccd,dcd,_dd,add,bdd)local cdd=_bd;local ddd,___a;local a__a=""if(cdd.parent~=nil)then -a__a=cdd.parent:getName()end;a__a=a__a..cdd:getName() -cbd(ccd+0.05,function() -if( -add~=nil)then if(dcc[add]==nil)then dcc[add]={}end;if -(dcc[add][a__a]~=nil)then if(dcc[add][a__a]~=bdd)then -dcc[add][a__a]:cancel()end end -dcc[add][a__a]=bdd end;ddd,___a=dcd(cdd)end) -for n=0.05,bcd+0.01,0.05 do -cbd(ccd+n,function() -local b__a=math.floor(ccc.lerp(ddd,_cd,ccc[dad](n/bcd))+0.5) -local c__a=math.floor(ccc.lerp(___a,acd,ccc[dad](n/bcd))+0.5)_dd(cdd,b__a,c__a)if(add~=nil)then -if(n>=bcd-0.01)then if -(dcc[add][a__a]==bdd)then dcc[add][a__a]=nil end end end end)end end -adc={name=_dc,getType=function(_cd)return bdc end,getBaseFrame=function(_cd)if(_cd.parent~=nil)then -return _cd.parent:getBaseFrame()end;return _cd end,setMode=function(_cd,acd) -dad=acd;return _cd end,addMode=function(_cd,acd,bcd)ccc[acd]=bcd;return _cd end,generateXMLEventFunction=function(_cd,acd,bcd) -local ccd=function(dcd) -if( -dcd:sub(1,1)=="#")then -local _dd=_cd:getBaseFrame():getDeepObject(dcd:sub(2,dcd:len())) -if(_dd~=nil)and(_dd.internalObjetCall~=nil)then acd(_cd,function() -_dd:internalObjetCall()end)end else -acd(_cd,_cd:getBaseFrame():getVariable(dcd))end end;if(type(bcd)=="string")then ccd(bcd)elseif(type(bcd)=="table")then -for dcd,_dd in pairs(bcd)do ccd(_dd)end end;return _cd end,setValuesByXMLData=function(_cd,acd)bad= -cda("loop",acd)==true and true or false -if( -cda("object",acd)~=nil)then -local bcd=_cd:getBaseFrame():getDeepObject(cda("object",acd))if(bcd==nil)then -bcd=_cd:getBaseFrame():getVariable(cda("object",acd))end -if(bcd~=nil)then _cd:setObject(bcd)end end -if(acd["move"]~=nil)then local bcd=cda("x",acd["move"]) -local ccd=cda("y",acd["move"])local dcd=cda("duration",acd["move"]) -local _dd=cda("time",acd["move"])_cd:move(bcd,ccd,dcd,_dd)end -if(acd["size"]~=nil)then local bcd=cda("width",acd["size"]) -local ccd=cda("height",acd["size"])local dcd=cda("duration",acd["size"]) -local _dd=cda("time",acd["size"])_cd:size(bcd,ccd,dcd,_dd)end -if(acd["offset"]~=nil)then local bcd=cda("x",acd["offset"]) -local ccd=cda("y",acd["offset"])local dcd=cda("duration",acd["offset"]) -local _dd=cda("time",acd["offset"])_cd:offset(bcd,ccd,dcd,_dd)end -if(acd["textColor"]~=nil)then -local bcd=cda("duration",acd["textColor"])local ccd=cda("time",acd["textColor"])local dcd={} -local _dd=acd["textColor"]["color"] -if(_dd~=nil)then if(_dd.properties~=nil)then _dd={_dd}end;for add,bdd in pairs(_dd)do -table.insert(dcd,colors[bdd:value()])end end;if(bcd~=nil)and(#dcd>0)then -_cd:changeTextColor(bcd,ccd or 0,table.unpack(dcd))end end -if(acd["background"]~=nil)then -local bcd=cda("duration",acd["background"])local ccd=cda("time",acd["background"])local dcd={} -local _dd=acd["background"]["color"] -if(_dd~=nil)then if(_dd.properties~=nil)then _dd={_dd}end;for add,bdd in pairs(_dd)do -table.insert(dcd,colors[bdd:value()])end end;if(bcd~=nil)and(#dcd>0)then -_cd:changeBackground(bcd,ccd or 0,table.unpack(dcd))end end -if(acd["text"]~=nil)then local bcd=cda("duration",acd["text"]) -local ccd=cda("time",acd["text"])local dcd={}local _dd=acd["text"]["text"] -if(_dd~=nil)then if(_dd.properties~=nil)then -_dd={_dd}end;for add,bdd in pairs(_dd)do -table.insert(dcd,bdd:value())end end;if(bcd~=nil)and(#dcd>0)then -_cd:changeText(bcd,ccd or 0,table.unpack(dcd))end end;if(cda("onDone",acd)~=nil)then -_cd:generateXMLEventFunction(_cd.onDone,cda("onDone",acd))end;if -(cda("onStart",acd)~=nil)then -_cd:generateXMLEventFunction(_cd.onDone,cda("onStart",acd))end -if -(cda("autoDestroy",acd)~=nil)then if(cda("autoDestroy",acd))then cad=true end end;dad=cda("mode",acd)or dad -if(cda("play",acd)~=nil)then if -(cda("play",acd))then _cd:play(bad)end end;return _cd end,getZIndex=function(_cd)return -1 end,getName=function(_cd)return _cd.name end,setObject=function(_cd,acd)_bd=acd;return _cd end,move=function(_cd,acd,bcd,ccd,dcd,_dd)_bd= -_dd or _bd -dbd(acd,bcd,ccd,dcd or 0,_bd.getPosition,_bd.setPosition,"position",_cd)return _cd end,offset=function(_cd,acd,bcd,ccd,dcd,_dd)_bd= -_dd or _bd -dbd(acd,bcd,ccd,dcd or 0,_bd.getOffset,_bd.setOffset,"offset",_cd)return _cd end,size=function(_cd,acd,bcd,ccd,dcd,_dd)_bd=_dd or -_bd -dbd(acd,bcd,ccd,dcd or 0,_bd.getSize,_bd.setSize,"size",_cd)return _cd end,changeText=function(_cd,acd,bcd,...) -local ccd={...}bcd=bcd or 0;_bd=obj or _bd;for n=1,#ccd do -cbd(bcd+n* (acd/#ccd),function() -_bd.setText(_bd,ccd[n])end)end;return _cd end,changeBackground=function(_cd,acd,bcd,...) -local ccd={...}bcd=bcd or 0;_bd=obj or _bd;for n=1,#ccd do -cbd(bcd+n* (acd/#ccd),function() -_bd.setBackground(_bd,ccd[n])end)end;return _cd end,changeTextColor=function(_cd,acd,bcd,...) -local ccd={...}bcd=bcd or 0;_bd=obj or _bd;for n=1,#ccd do -cbd(bcd+n* (acd/#ccd),function() -_bd.setForeground(_bd,ccd[n])end)end;return _cd end,add=function(_cd,acd,bcd) -aad=acd -cbd((bcd or _ad)+ -(ddc[#ddc]~=nil and ddc[#ddc].t or 0),acd)return _cd end,wait=function(_cd,acd)_ad=acd;return _cd end,rep=function(_cd,acd) -if( -aad~=nil)then for n=1,acd or 1 do -cbd((wait or _ad)+ -(ddc[#ddc]~=nil and ddc[#ddc].t or 0),aad)end end;return _cd end,onDone=function(_cd,acd) -d_d:registerEvent("animation_done",acd)return _cd end,onStart=function(_cd,acd) -d_d:registerEvent("animation_start",acd)return _cd end,setAutoDestroy=function(_cd,acd) -cad=acd~=nil and acd or true;return _cd end,animationDoneHandler=function(_cd) -d_d:sendEvent("animation_done",_cd)_cd.parent:removeEvent("other_event",_cd)if(cad)then -_cd.parent:removeObject(_cd)_cd=nil end end,animationStartHandler=function(_cd) -d_d:sendEvent("animation_start",_cd)end,clear=function(_cd)ddc={}aad=nil;_ad=0;b_d=1;__d=0;c_d=false;return _cd end,play=function(_cd,acd) -_cd:cancel()a_d=true;c_d=acd and true or false;b_d=1;__d=0 -if(ddc[b_d]~=nil)then -if( -ddc[b_d].t>0)then cdc=os.startTimer(ddc[b_d].t)else bbd(_cd)end else _cd:animationDoneHandler()end;_cd.parent:addEvent("other_event",_cd)return _cd end,cancel=function(_cd)if( -cdc~=nil)then os.cancelTimer(cdc)c_d=false end -a_d=false;_cd.parent:removeEvent("other_event",_cd)return _cd end,internalObjetCall=function(_cd) -_cd:play(bad)end,eventHandler=function(_cd,acd,bcd)if(a_d)then -if(acd=="timer")and(bcd==cdc)then if(ddc[b_d]~=nil)then -bbd(_cd)else _cd:animationDoneHandler()end end end end}adc.__index=adc;return adc end -end; -project['objects']['Button'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=aa.getValueFromXML;local ca=require("tHex") -return -function(da)local _b=_a(da)local ab="Button"local bb="center" -local cb="center"_b:setZIndex(5)_b:setValue("Button")_b.width=12 -_b.height=3 -local db={init=function(_c)if(_b.init(_c))then _c.bgColor=_c.parent:getTheme("ButtonBG") -_c.fgColor=_c.parent:getTheme("ButtonText")end end,getType=function(_c)return -ab end,setHorizontalAlign=function(_c,ac)bb=ac;_c:updateDraw()return _c end,setVerticalAlign=function(_c,ac) -cb=ac;_c:updateDraw()return _c end,setText=function(_c,ac) -_b:setValue(ac)_c:updateDraw()return _c end,setValuesByXMLData=function(_c,ac) -_b.setValuesByXMLData(_c,ac) -if(ba("text",ac)~=nil)then _c:setText(ba("text",ac))end;if(ba("horizontalAlign",ac)~=nil)then -bb=ba("horizontalAlign",ac)end;if(ba("verticalAlign",ac)~=nil)then -cb=ba("verticalAlign",ac)end;return _c end,draw=function(_c) -if -(_b.draw(_c))then -if(_c.parent~=nil)then local ac,bc=_c:getAnchorPosition() -local cc,dc=_c:getSize()local _d=aa.getTextVerticalAlign(dc,cb) -for n=1,dc do -if(n==_d)then -_c.parent:setText(ac,bc+ (n-1),aa.getTextHorizontalAlign(_c:getValue(),cc,bb)) -_c.parent:setFG(ac,bc+ (n-1),aa.getTextHorizontalAlign(ca[_c.fgColor]:rep(_c:getValue():len()),cc,bb))end end end end end}return setmetatable(db,_b)end -end; -project['objects']['Checkbox'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Checkbox"ca:setZIndex(5)ca:setValue(false) -ca.width=1;ca.height=1;local _b="\42" -local ab={getType=function(bb)return da end,setSymbol=function(bb,cb)_b=cb;bb:updateDraw()return bb end,mouseHandler=function(bb,cb,db,_c) -if -(ca.mouseHandler(bb,cb,db,_c))then -if(cb==1)then if -(bb:getValue()~=true)and(bb:getValue()~=false)then bb:setValue(false)else -bb:setValue(not bb:getValue())end -bb:updateDraw()return true end end;return false end,touchHandler=function(bb,cb,db)return -bb:mouseHandler(1,cb,db)end,setValuesByXMLData=function(bb,cb) -ca.setValuesByXMLData(bb,cb) -if(aa("checked",cb)~=nil)then if(aa("checked",cb))then bb:setValue(true)else -bb:setValue(false)end end;return bb end,draw=function(bb) -if -(ca.draw(bb))then -if(bb.parent~=nil)then local cb,db=bb:getAnchorPosition() -local _c,ac=bb:getSize()local bc=_a.getTextVerticalAlign(ac,"center")if -(bb.bgColor~=false)then -bb.parent:drawBackgroundBox(cb,db,_c,ac,bb.bgColor)end -for n=1,ac do -if(n==bc)then -if(bb:getValue()==true)then -bb.parent:writeText(cb, -db+ (n-1),_a.getTextHorizontalAlign(_b,_c,"center"),bb.bgColor,bb.fgColor)else -bb.parent:writeText(cb,db+ (n-1),_a.getTextHorizontalAlign(" ",_c,"center"),bb.bgColor,bb.fgColor)end end end end end end,init=function(bb) -bb.parent:addEvent("mouse_click",bb)bb.parent:addEvent("mouse_up",bb) -if(ca.init(bb))then -bb.bgColor=bb.parent:getTheme("CheckboxBG")bb.fgColor=bb.parent:getTheme("CheckboxText")end end}return setmetatable(ab,ca)end -end; -project['objects']['Dropdown'] = function(...)local d=require("Object")local _a=require("utils") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Dropdown"ca.width=12;ca.height=1;ca:setZIndex(6) -local _b={}local ab;local bb;local cb=true;local db="left"local _c=0;local ac=16;local bc=6;local cc="\16"local dc="\31"local _d=false -local ad={getType=function(bd) -return da end,setValuesByXMLData=function(bd,cd)ca.setValuesByXMLData(bd,cd) -if -(aa("selectionBG",cd)~=nil)then ab=colors[aa("selectionBG",cd)]end;if(aa("selectionFG",cd)~=nil)then -bb=colors[aa("selectionFG",cd)]end;if(aa("dropdownWidth",cd)~=nil)then -ac=aa("dropdownWidth",cd)end;if(aa("dropdownHeight",cd)~=nil)then -bc=aa("dropdownHeight",cd)end;if(aa("offset",cd)~=nil)then -_c=aa("offset",cd)end -if(cd["item"]~=nil)then local dd=cd["item"]if -(dd.properties~=nil)then dd={dd}end;for __a,a_a in pairs(dd)do -bd:addItem(aa("text",a_a),colors[aa("bg",a_a)],colors[aa("fg",a_a)])end end end,setOffset=function(bd,cd) -_c=cd;bd:updateDraw()return bd end,getOffset=function(bd)return _c end,addItem=function(bd,cd,dd,__a,...) -table.insert(_b,{text=cd,bgCol= -dd or bd.bgColor,fgCol=__a or bd.fgColor,args={...}})bd:updateDraw()return bd end,getAll=function(bd)return -_b end,removeItem=function(bd,cd)table.remove(_b,cd)bd:updateDraw()return bd end,getItem=function(bd,cd)return -_b[cd]end,getItemIndex=function(bd)local cd=bd:getValue()for dd,__a in pairs(_b)do -if(__a==cd)then return dd end end end,clear=function(bd) -_b={}bd:setValue({})bd:updateDraw()return bd end,getItemCount=function(bd)return -#_b end,editItem=function(bd,cd,dd,__a,a_a,...)table.remove(_b,cd) -table.insert(_b,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol= -a_a or bd.fgColor,args={...}})bd:updateDraw()return bd end,selectItem=function(bd,cd)bd:setValue( -_b[cd]or{})bd:updateDraw()return bd end,setSelectedItem=function(bd,cd,dd,__a)ab= -cd or bd.bgColor;bb=dd or bd.fgColor;cb=__a -bd:updateDraw()return bd end,setDropdownSize=function(bd,cd,dd)ac,bc=cd,dd -bd:updateDraw()return bd end,mouseHandler=function(bd,cd,dd,__a) -if(_d)then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition()) -if(cd==1)then -if(#_b>0)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if -(a_a<=dd)and(a_a+ac>dd)and(b_a+n==__a)then bd:setValue(_b[n+_c])bd:updateDraw() -local c_a=bd:getEventSystem():sendEvent("mouse_click",bd,"mouse_click",dir,dd,__a)if(c_a==false)then return c_a end;return true end end end end end end -if(ca.mouseHandler(bd,cd,dd,__a))then _d=(not _d)bd:updateDraw()return true else if(_d)then -bd:updateDraw()_d=false end;return false end end,mouseUpHandler=function(bd,cd,dd,__a) -if -(_d)then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition()) -if(cd==1)then -if(#_b>0)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if -(a_a<=dd)and(a_a+ac>dd)and(b_a+n==__a)then _d=false;bd:updateDraw() -local c_a=bd:getEventSystem():sendEvent("mouse_up",bd,"mouse_up",dir,dd,__a)if(c_a==false)then return c_a end;return true end end end end end end end,scrollHandler=function(bd,cd,dd,__a) -if -(_d)and(bd:isFocused())then _c=_c+cd;if(_c<0)then _c=0 end;if(cd==1)then -if(#_b>bc)then if -(_c>#_b-bc)then _c=#_b-bc end else _c=math.min(#_b-1,0)end end -local a_a=bd:getEventSystem():sendEvent("mouse_scroll",bd,"mouse_scroll",cd,dd,__a)if(a_a==false)then return a_a end;bd:updateDraw()return true end end,draw=function(bd) -if -(ca.draw(bd))then local cd,dd=bd:getAnchorPosition()local __a,a_a=bd:getSize() -if -(bd.parent~=nil)then if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=bd:getValue() -local c_a=_a.getTextHorizontalAlign(( -b_a~=nil and b_a.text or""),__a,db):sub(1, -__a-1).. (_d and dc or cc) -bd.parent:writeText(cd,dd,c_a,bd.bgColor,bd.fgColor) -if(_d)then -for n=1,bc do -if(_b[n+_c]~=nil)then -if(_b[n+_c]==b_a)then -if(cb)then -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+ -_c].text,ac,db),ab,bb)else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end else -bd.parent:writeText(cd,dd+n,_a.getTextHorizontalAlign(_b[n+_c].text,ac,db),_b[n+ -_c].bgCol,_b[n+_c].fgCol)end end end end end end end,init=function(bd) -bd.parent:addEvent("mouse_click",bd)bd.parent:addEvent("mouse_up",bd) -bd.parent:addEvent("mouse_scroll",bd) -if(ca.init(bd))then -bd.bgColor=bd.parent:getTheme("DropdownBG")bd.fgColor=bd.parent:getTheme("DropdownText") -ab=bd.parent:getTheme("SelectionBG")bb=bd.parent:getTheme("SelectionText")end end}return setmetatable(ad,ca)end -end; -project['objects']['Image'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Image"aa:setZIndex(2)local ca;local da;local _b=false -local function ab() -local cb={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local db,_c,ac={},{},{}for i=0,15 do _c[2 ^i]=i end -do local cd="0123456789abcdef" -for i=1,16 do db[cd:sub(i,i)]= -i-1;db[i-1]=cd:sub(i,i) -ac[cd:sub(i,i)]=2 ^ (i-1)ac[2 ^ (i-1)]=cd:sub(i,i)local dd=cb[i-1]for i=1,#dd do -dd[i]=2 ^dd[i]end end end -local function bc(cd)local dd=cb[_c[cd[#cd][1] ] ] -for j=1,#dd do local __a=dd[j]for i=1,#cd-1 do if -cd[i][1]==__a then return i end end end;return 1 end -local function cc(cd,dd) -if not dd then local a_a={}dd={}for i=1,6 do local b_a=cd[i]local c_a=dd[b_a] -dd[b_a],a_a[i]=c_a and(c_a+1)or 1,b_a end;cd=a_a end;local __a={}for a_a,b_a in pairs(dd)do __a[#__a+1]={a_a,b_a}end -if -#__a>1 then -while#__a>2 do -table.sort(__a,function(aaa,baa)return aaa[2]>baa[2]end)local b_a,c_a=bc(__a),#__a;local d_a,_aa=__a[c_a][1],__a[b_a][1]for i=1,6 do -if -cd[i]==d_a then cd[i]=_aa;__a[b_a][2]=__a[b_a][2]+1 end end;__a[c_a]=nil end;local a_a=128 -for i=1,#cd-1 do if cd[i]~=cd[6]then a_a=a_a+2 ^ (i-1)end end -return string.char(a_a),ac[__a[1][1]==cd[6]and __a[2][1]or -__a[1][1] ],ac[cd[6] ]else return"\128",ac[cd[1] ],ac[cd[1] ]end end -local dc,_d,ad,bd={{},{},{}},0,#ca+#ca%3,aa.bgColor or colors.black;for i=1,#ca do if#ca[i]>_d then _d=#ca[i]end end -for y=0,ad-1,3 do -local cd,dd,__a,a_a={},{},{},1 -for x=0,_d-1,2 do local b_a,c_a={},{} -for yy=1,3 do -for xx=1,2 do -b_a[#b_a+1]=(ca[y+yy]and ca[y+yy][x+xx])and -(ca[y+ -yy][x+xx]==0 and bd or ca[y+yy][x+xx])or bd;c_a[b_a[#b_a] ]= -c_a[b_a[#b_a] ]and(c_a[b_a[#b_a] ]+1)or 1 end end;cd[a_a],dd[a_a],__a[a_a]=cc(b_a,c_a)a_a=a_a+1 end -dc[1][#dc[1]+1],dc[2][#dc[2]+1],dc[3][#dc[3]+1]=table.concat(cd),table.concat(dd),table.concat(__a)end;dc.width,dc.height=#dc[1][1],#dc[1]da=dc end -local bb={init=function(cb)cb.bgColor=cb.parent:getTheme("ImageBG")end,getType=function(cb)return -ba end,loadImage=function(cb,db)ca=paintutils.loadImage(db)_b=false -cb:updateDraw()return cb end,shrink=function(cb)ab()_b=true -cb:updateDraw()return cb end,setValuesByXMLData=function(cb,db)aa.setValuesByXMLData(cb,db) -if( -d("shrink",db)~=nil)then if(d("shrink",db))then cb:shrink()end end -if(d("path",db)~=nil)then cb:loadImage(d("path",db))end;return cb end,draw=function(cb) -if -(aa.draw(cb))then -if(cb.parent~=nil)then -if(ca~=nil)then local db,_c=cb:getAnchorPosition() -local ac,bc=cb:getSize() -if(_b)then local cc,dc,_d=da[1],da[2],da[3] -for i=1,da.height do local ad=cc[i] -if type(ad)=="string"then cb.parent:setText(db, -_c+i-1,ad) -cb.parent:setFG(db,_c+i-1,dc[i])cb.parent:setBG(db,_c+i-1,_d[i])elseif -type(ad)=="table"then cb.parent:setText(db,_c+i-1,ad[2])cb.parent:setFG(db,_c+ -i-1,dc[i]) -cb.parent:setBG(db,_c+i-1,_d[i])end end else -for yPos=1,math.min(#ca,bc)do local cc=ca[yPos] -for xPos=1,math.min(#cc,ac)do if cc[xPos]>0 then -cb.parent:drawBackgroundBox( -db+xPos-1,_c+yPos-1,1,1,cc[xPos])end end end end end end end end}return setmetatable(bb,aa)end -end; -project['objects']['Input'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=require("basaltLogs")local ca=aa.getValueFromXML -return -function(da)local _b=_a(da)local ab="Input"local bb="text"local cb=0 -_b:setZIndex(5)_b:setValue("")_b.width=10;_b.height=1;local db=1;local _c=1;local ac=""local bc;local cc -local dc=ac;local _d=false -local ad={getType=function(bd)return ab end,setInputType=function(bd,cd)if(cd=="password")or(cd=="number")or -(cd=="text")then bb=cd end -bd:updateDraw()return bd end,setDefaultText=function(bd,cd,dd,__a)ac=cd -bc=__a or bc;cc=dd or cc;if(bd:isFocused())then dc=""else dc=ac end -bd:updateDraw()return bd end,getInputType=function(bd)return bb end,setValue=function(bd,cd) -_b.setValue(bd,tostring(cd)) -if not(_d)then -if(bd:isFocused())then db=tostring(cd):len()+1;_c=math.max(1, -db-bd:getWidth()+1) -local dd,__a=bd:getAnchorPosition() -bd.parent:setCursor(true,dd+db-_c,__a+math.floor(bd:getHeight()/2),bd.fgColor)end end;bd:updateDraw()return bd end,getValue=function(bd) -local cd=_b.getValue(bd)return bb=="number"and tonumber(cd)or cd end,setInputLimit=function(bd,cd)cb= -tonumber(cd)or cb;bd:updateDraw()return bd end,getInputLimit=function(bd)return -cb end,setValuesByXMLData=function(bd,cd)_b.setValuesByXMLData(bd,cd)local dd,__a;if( -ca("defaultBG",cd)~=nil)then dd=ca("defaultBG",cd)end;if( -ca("defaultFG",cd)~=nil)then __a=ca("defaultFG",cd)end;if( -ca("default",cd)~=nil)then -bd:setDefaultText(ca("default",cd),__a~=nil and colors[__a],dd~=nil and -colors[dd])end -if -(ca("limit",cd)~=nil)then bd:setInputLimit(ca("limit",cd))end -if(ca("type",cd)~=nil)then bd:setInputType(ca("type",cd))end;return bd end,getFocusHandler=function(bd) -_b.getFocusHandler(bd) -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition()dc=""if(ac~="")then -bd:updateDraw()end -bd.parent:setCursor(true,cd+db-_c,dd+math.max(math.ceil( -bd:getHeight()/2 -1,1)),bd.fgColor)end end,loseFocusHandler=function(bd) -_b.loseFocusHandler(bd)if(bd.parent~=nil)then dc=ac;if(ac~="")then bd:updateDraw()end -bd.parent:setCursor(false)end end,keyHandler=function(bd,cd) -if -(_b.keyHandler(bd,cd))then local dd,__a=bd:getSize()_d=true -if(cd==keys.backspace)then -local aaa=tostring(_b.getValue())if(db>1)then -bd:setValue(aaa:sub(1,db-2)..aaa:sub(db,aaa:len()))if(db>1)then db=db-1 end -if(_c>1)then if(db<_c)then _c=_c-1 end end end end;if(cd==keys.enter)then if(bd.parent~=nil)then end end -if(cd== -keys.right)then -local aaa=tostring(_b.getValue()):len()db=db+1;if(db>aaa)then db=aaa+1 end;if(db<1)then db=1 end;if -(db<_c)or(db>=dd+_c)then _c=db-dd+1 end;if(_c<1)then _c=1 end end -if(cd==keys.left)then db=db-1;if(db>=1)then -if(db<_c)or(db>=dd+_c)then _c=db end end;if(db<1)then db=1 end;if(_c<1)then _c=1 end end;local a_a,b_a=bd:getAnchorPosition() -local c_a=tostring(_b.getValue()) -local d_a=(db<=c_a:len()and db-1 or c_a:len())- (_c-1)local _aa=bd:getX()if(d_a>_aa+dd-1)then d_a=_aa+dd-1 end;if( -bd.parent~=nil)then -bd.parent:setCursor(true,a_a+d_a,b_a+ -math.max(math.ceil(__a/2 -1,1)),bd.fgColor)end -bd:updateDraw()_d=false;return true end;return false end,charHandler=function(bd,cd) -if -(_b.charHandler(bd,cd))then _d=true;local dd,__a=bd:getSize()local a_a=_b.getValue() -if(a_a:len()=dd+_c)then _c=_c+1 end end;local b_a,c_a=bd:getAnchorPosition() -local d_a=tostring(_b.getValue()) -local _aa=(db<=d_a:len()and db-1 or d_a:len())- (_c-1)local aaa=bd:getX()if(_aa>aaa+dd-1)then _aa=aaa+dd-1 end;if( -bd.parent~=nil)then -bd.parent:setCursor(true,b_a+_aa,c_a+ -math.max(math.ceil(__a/2 -1,1)),bd.fgColor)end;_d=false -bd:updateDraw()return true end;return false end,mouseHandler=function(bd,cd,dd,__a) -if -(_b.mouseHandler(bd,cd,dd,__a))then local a_a,b_a=bd:getAnchorPosition() -local c_a,d_a=bd:getAbsolutePosition(a_a,b_a)local _aa,aaa=bd:getSize()db=dd-c_a+_c;local baa=_b.getValue()if(db> -baa:len())then db=baa:len()+1 end;if(db<_c)then _c=db-1 -if(_c<1)then _c=1 end end -bd.parent:setCursor(true,a_a+db-_c,b_a+ -math.max(math.ceil(aaa/2 -1,1)),bd.fgColor)return true end end,dragHandler=function(bd,cd,dd,__a,a_a,b_a) -if -(bd:isFocused())then if(bd:isCoordsInObject(dd,__a))then -if(_b.dragHandler(bd,cd,dd,__a,a_a,b_a))then return true end end -bd.parent:removeFocusedObject()end end,eventHandler=function(bd,cd,dd,__a,a_a,b_a) -if -(_b.eventHandler(bd,cd,dd,__a,a_a,b_a))then -if(cd=="paste")then -if(bd:isFocused())then local c_a=_b.getValue() -local d_a,_aa=bd:getSize()_d=true -if(bb=="number")then local aba=c_a -if(dd==".")or(tonumber(dd)~=nil)then -bd:setValue(c_a:sub(1, -db-1)..dd..c_a:sub(db,c_a:len()))db=db+dd:len()end -if(tonumber(_b.getValue())==nil)then bd:setValue(aba)end else -bd:setValue(c_a:sub(1,db-1)..dd..c_a:sub(db,c_a:len()))db=db+dd:len()end;if(db>=d_a+_c)then _c=(db+1)-d_a end -local aaa,baa=bd:getAnchorPosition()local caa=tostring(_b.getValue()) -local daa=( -db<=caa:len()and db-1 or caa:len())- (_c-1)local _ba=bd:getX() -if(daa>_ba+d_a-1)then daa=_ba+d_a-1 end;if(bd.parent~=nil)then -bd.parent:setCursor(true,aaa+daa,baa+ -math.max(math.ceil(_aa/2 -1,1)),bd.fgColor)end -bd:updateDraw()_d=false end end end end,draw=function(bd) -if -(_b.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()local b_a=aa.getTextVerticalAlign(a_a,"center")if -(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end -for n=1,a_a do -if(n==b_a)then -local c_a=tostring(_b.getValue())local d_a=bd.bgColor;local _aa=bd.fgColor;local aaa;if(c_a:len()<=0)then aaa=dc;d_a=bc or d_a;_aa= -cc or _aa end;aaa=dc -if(c_a~="")then aaa=c_a end;aaa=aaa:sub(_c,__a+_c-1)local baa=__a-aaa:len()if(baa<0)then -baa=0 end;if(bb=="password")and(c_a~="")then -aaa=string.rep("*",aaa:len())end -aaa=aaa..string.rep(bd.bgSymbol,baa)bd.parent:writeText(cd,dd+ (n-1),aaa,d_a,_aa)end end;if(bd:isFocused())then -bd.parent:setCursor(true,cd+db-_c,dd+ -math.floor(bd:getHeight()/2),bd.fgColor)end end end end,init=function(bd) -if( -bd.parent~=nil)then bd.parent:addEvent("mouse_click",bd) -bd.parent:addEvent("key",bd)bd.parent:addEvent("char",bd) -bd.parent:addEvent("other_event",bd)bd.parent:addEvent("mouse_drag",bd)end;if(_b.init(bd))then bd.bgColor=bd.parent:getTheme("InputBG") -bd.fgColor=bd.parent:getTheme("InputText")end end}return setmetatable(ad,_b)end -end; -project['objects']['Label'] = function(...)local ba=require("Object")local ca=require("utils") -local da=ca.getValueFromXML;local _b=ca.createText;local ab=require("tHex")local bb=require("bigfont") -return -function(cb) -local db=ba(cb)local _c="Label"db:setZIndex(3)local ac=true;db:setValue("Label") -db.width=5;local bc="left"local cc="top"local dc=0;local _d,ad=false,false -local bd={getType=function(cd)return _c end,setText=function(cd,dd) -dd=tostring(dd)db:setValue(dd) -if(ac)then -if -(dd:len()+cd:getX()>cd.parent:getWidth())then local __a=cd.parent:getWidth()-cd:getX()db.setSize(cd,__a, -#_b(dd,__a))else -db.setSize(cd,dd:len(),1)end end;cd:updateDraw()return cd end,setBackground=function(cd,dd) -db.setBackground(cd,dd)ad=true;cd:updateDraw()return cd end,setForeground=function(cd,dd) -db.setForeground(cd,dd)_d=true;cd:updateDraw()return cd end,setTextAlign=function(cd,dd,__a) -bc=dd or bc;cc=__a or cc;cd:updateDraw()return cd end,setFontSize=function(cd,dd)if( -dd>0)and(dd<=4)then dc=dd-1 or 0 end -cd:updateDraw()return cd end,getFontSize=function(cd)return dc+1 end,setValuesByXMLData=function(cd,dd) -db.setValuesByXMLData(cd,dd) -if(da("text",dd)~=nil)then cd:setText(da("text",dd))end -if(da("verticalAlign",dd)~=nil)then cc=da("verticalAlign",dd)end;if(da("horizontalAlign",dd)~=nil)then -bc=da("horizontalAlign",dd)end;if(da("font",dd)~=nil)then -cd:setFontSize(da("font",dd))end;return cd end,setSize=function(cd,dd,__a,a_a) -db.setSize(cd,dd,__a,a_a)ac=false;cd:updateDraw()return cd end,eventHandler=function(cd,dd) -if( -dd=="basalt_resize")then -if(ac)then local __a=cd:getValue() -if(__a:len()+cd:getX()> -cd.parent:getWidth())then -local a_a=cd.parent:getWidth()-cd:getX()db.setSize(cd,a_a,#_b(__a,a_a))else -db.setSize(cd,__a:len(),1)end else end end end,draw=function(cd) -if -(db.draw(cd))then -if(cd.parent~=nil)then local dd,__a=cd:getAnchorPosition() -local a_a,b_a=cd:getSize()local c_a=ca.getTextVerticalAlign(b_a,cc) -if(dc==0)then -if not(ac)then -local d_a=_b(cd:getValue(),cd:getWidth()) -for _aa,aaa in pairs(d_a)do if(_aa<=b_a)then -cd.parent:writeText(dd,__a+_aa-1,aaa,cd.bgColor,cd.fgColor)end end else -if(#cd:getValue()+dd>cd.parent:getWidth())then -local d_a=_b(cd:getValue(),cd:getWidth()) -for _aa,aaa in pairs(d_a)do if(_aa<=b_a)then -cd.parent:writeText(dd,__a+_aa-1,aaa,cd.bgColor,cd.fgColor)end end else -cd.parent:writeText(dd,__a,cd:getValue(),cd.bgColor,cd.fgColor)end end else -local d_a=bb(dc,cd:getValue(),cd.fgColor,cd.bgColor or colors.lightGray) -if(ac)then cd:setSize(#d_a[1][1],#d_a[1]-1)end;local _aa,aaa=cd.parent:getSize() -local baa,caa=#d_a[1][1],#d_a[1] -dd=dd or math.floor((_aa-baa)/2)+1 -__a=__a or math.floor((aaa-caa)/2)+1 -for i=1,caa do cd.parent:setFG(dd,__a+i-1,d_a[2][i])cd.parent:setBG(dd, -__a+i-1,d_a[3][i])cd.parent:setText(dd, -__a+i-1,d_a[1][i])end end end end end,init=function(cd) -cd.parent:addEvent("other_event",cd) -if(db.init(cd))then cd.bgColor=cd.parent:getTheme("LabelBG") -cd.fgColor=cd.parent:getTheme("LabelText") -if -(cd.parent.bgColor==colors.black)and(cd.fgColor==colors.black)then cd.fgColor=colors.lightGray end end end}return setmetatable(bd,db)end -end; -project['objects']['List'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="List"ca.width=16;ca.height=6;ca:setZIndex(5)local _b={} -local ab;local bb;local cb=true;local db="left"local _c=0;local ac=true -local bc={getType=function(cc)return da end,addItem=function(cc,dc,_d,ad,...) -table.insert(_b,{text=dc,bgCol=_d or cc.bgColor,fgCol= -ad or cc.fgColor,args={...}})if(#_b==1)then cc:setValue(_b[1])end -cc:updateDraw()return cc end,setOffset=function(cc,dc) -_c=dc;cc:updateDraw()return cc end,getOffset=function(cc)return _c end,removeItem=function(cc,dc) -table.remove(_b,dc)cc:updateDraw()return cc end,getItem=function(cc,dc)return _b[dc]end,getAll=function(cc)return -_b end,getItemIndex=function(cc)local dc=cc:getValue() -for _d,ad in pairs(_b)do if(ad==dc)then return _d end end end,clear=function(cc)_b={}cc:setValue({}) -cc:updateDraw()return cc end,getItemCount=function(cc)return#_b end,editItem=function(cc,dc,_d,ad,bd,...) -table.remove(_b,dc) -table.insert(_b,dc,{text=_d,bgCol=ad or cc.bgColor,fgCol=bd or cc.fgColor,args={...}})cc:updateDraw()return cc end,selectItem=function(cc,dc)cc:setValue( -_b[dc]or{})cc:updateDraw()return cc end,setSelectedItem=function(cc,dc,_d,ad)ab= -dc or cc.bgColor;bb=_d or cc.fgColor -cb=ad~=nil and ad or true;cc:updateDraw()return cc end,setScrollable=function(cc,dc) -ac=dc;if(dc==nil)then ac=true end;cc:updateDraw()return cc end,setValuesByXMLData=function(cc,dc) -ca.setValuesByXMLData(cc,dc)if(aa("selectionBG",dc)~=nil)then -ab=colors[aa("selectionBG",dc)]end;if(aa("selectionFG",dc)~=nil)then -bb=colors[aa("selectionFG",dc)]end;if(aa("scrollable",dc)~=nil)then -if -(aa("scrollable",dc))then cc:setScrollable(true)else cc:setScrollable(false)end end;if -(aa("offset",dc)~=nil)then _c=aa("offset",dc)end -if(dc["item"]~=nil)then -local _d=dc["item"]if(_d.properties~=nil)then _d={_d}end;for ad,bd in pairs(_d)do -cc:addItem(aa("text",bd),colors[aa("bg",bd)],colors[aa("fg",bd)])end end;return cc end,scrollHandler=function(cc,dc,_d,ad) -if -(ca.scrollHandler(cc,dc,_d,ad))then -if(ac)then local bd,cd=cc:getSize()_c=_c+dc;if(_c<0)then _c=0 end;if(dc>=1)then -if(#_b>cd)then if -(_c>#_b-cd)then _c=#_b-cd end;if(_c>=#_b)then _c=#_b-1 end else _c=_c-1 end end -cc:updateDraw()end;return true end;return false end,mouseHandler=function(cc,dc,_d,ad) -if -(ca.mouseHandler(cc,dc,_d,ad))then -local bd,cd=cc:getAbsolutePosition(cc:getAnchorPosition())local dd,__a=cc:getSize() -if(#_b>0)then for n=1,__a do -if(_b[n+_c]~=nil)then if -(bd<=_d)and(bd+dd>_d)and(cd+n-1 ==ad)then cc:setValue(_b[n+_c]) -cc:updateDraw()end end end end;return true end;return false end,dragHandler=function(cc,dc,_d,ad)return -cc:mouseHandler(dc,_d,ad)end,touchHandler=function(cc,dc,_d) -return cc:mouseHandler(1,dc,_d)end,draw=function(cc) -if(ca.draw(cc))then -if(cc.parent~=nil)then -local dc,_d=cc:getAnchorPosition()local ad,bd=cc:getSize()if(cc.bgColor~=false)then -cc.parent:drawBackgroundBox(dc,_d,ad,bd,cc.bgColor)end -for n=1,bd do -if(_b[n+_c]~=nil)then -if(_b[n+_c]== -cc:getValue())then -if(cb)then -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),ab,bb)else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end else -cc.parent:writeText(dc,_d+n-1,_a.getTextHorizontalAlign(_b[n+_c].text,ad,db),_b[ -n+_c].bgCol,_b[n+_c].fgCol)end end end end end end,init=function(cc) -cc.parent:addEvent("mouse_click",cc)cc.parent:addEvent("mouse_drag",cc) -cc.parent:addEvent("mouse_scroll",cc) -if(ca.init(cc))then cc.bgColor=cc.parent:getTheme("ListBG") -cc.fgColor=cc.parent:getTheme("ListText")ab=cc.parent:getTheme("SelectionBG") -bb=cc.parent:getTheme("SelectionText")end end}return setmetatable(bc,ca)end -end; -project['objects']['Menubar'] = function(...)local _a=require("Object")local aa=require("utils") -local ba=aa.getValueFromXML;local ca=require("tHex") -return -function(da)local _b=_a(da)local ab="Menubar"local bb={}_b.width=30 -_b.height=1;_b:setZIndex(5)local cb={}local db;local _c;local ac=true;local bc="left"local cc=0;local dc=1 -local _d=false -local function ad()local bd=0;local cd=0;local dd=bb:getWidth() -for n=1,#cb do if(cd+cb[n].text:len()+ -dc*2 >dd)then -if(cddd)then cc=dd end;bd:updateDraw() -return bd end,getOffset=function(bd)return cc end,setScrollable=function(bd,cd) -_d=cd;if(cd==nil)then _d=true end;return bd end,setValuesByXMLData=function(bd,cd) -_b.setValuesByXMLData(bd,cd)if(ba("selectionBG",cd)~=nil)then -db=colors[ba("selectionBG",cd)]end;if(ba("selectionFG",cd)~=nil)then -_c=colors[ba("selectionFG",cd)]end;if(ba("scrollable",cd)~=nil)then -if -(ba("scrollable",cd))then bd:setScrollable(true)else bd:setScrollable(false)end end -if -(ba("offset",cd)~=nil)then bd:setOffset(ba("offset",cd))end;if(ba("space",cd)~=nil)then dc=ba("space",cd)end -if( -cd["item"]~=nil)then local dd=cd["item"]if(dd.properties~=nil)then dd={dd}end;for __a,a_a in -pairs(dd)do -bd:addItem(ba("text",a_a),colors[ba("bg",a_a)],colors[ba("fg",a_a)])end end;return bd end,removeItem=function(bd,cd) -table.remove(cb,cd)bd:updateDraw()return bd end,getItem=function(bd,cd)return cb[cd]end,getItemCount=function(bd)return -#cb end,editItem=function(bd,cd,dd,__a,a_a,...)table.remove(cb,cd) -table.insert(cb,cd,{text=dd,bgCol=__a or bd.bgColor,fgCol= -a_a or bd.fgColor,args={...}})bd:updateDraw()return bd end,selectItem=function(bd,cd)bd:setValue( -cb[cd]or{})bd:updateDraw()return bd end,setSelectedItem=function(bd,cd,dd,__a)db= -cd or bd.bgColor;_c=dd or bd.fgColor;ac=__a -bd:updateDraw()return bd end,mouseHandler=function(bd,cd,dd,__a) -if -(_b.mouseHandler(bd,cd,dd,__a))then -local a_a,b_a=bd:getAbsolutePosition(bd:getAnchorPosition())local c_a,d_a=bd:getSize()local _aa=0 -for n=1,#cb do -if(cb[n]~=nil)then -if -(a_a+_aa<=dd+cc)and(a_a+_aa+ -cb[n].text:len()+ (dc*2)>dd+cc)and(b_a==__a)then bd:setValue(cb[n]) -bd:getEventSystem():sendEvent(event,bd,event,0,dd,__a,cb[n])end;_aa=_aa+cb[n].text:len()+dc*2 end end;bd:updateDraw()return true end;return false end,scrollHandler=function(bd,cd,dd,__a) -if -(_b.scrollHandler(bd,cd,dd,__a))then if(_d)then cc=cc+cd;if(cc<0)then cc=0 end;local a_a=ad()if(cc>a_a)then cc=a_a end -bd:updateDraw()end;return true end;return false end,draw=function(bd) -if -(_b.draw(bd))then -if(bd.parent~=nil)then local cd,dd=bd:getAnchorPosition() -local __a,a_a=bd:getSize()if(bd.bgColor~=false)then -bd.parent:drawBackgroundBox(cd,dd,__a,a_a,bd.bgColor)end;local b_a=""local c_a=""local d_a="" -for _aa,aaa in pairs(cb)do -local baa= -(" "):rep(dc)..aaa.text.. (" "):rep(dc)b_a=b_a..baa -if(aaa==bd:getValue())then c_a=c_a.. -ca[db or aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[_c or aaa.FgCol or -bd.fgColor]:rep(baa:len())else c_a=c_a.. -ca[aaa.bgCol or bd.bgColor]:rep(baa:len())d_a=d_a.. -ca[aaa.FgCol or bd.fgColor]:rep(baa:len())end end -bd.parent:setText(cd,dd,b_a:sub(cc+1,__a+cc)) -bd.parent:setBG(cd,dd,c_a:sub(cc+1,__a+cc)) -bd.parent:setFG(cd,dd,d_a:sub(cc+1,__a+cc))end end end,init=function(bd) -bd.parent:addEvent("mouse_click",bd)bd.parent:addEvent("mouse_scroll",bd) -if(_b.init(bd))then -bd.bgColor=bd.parent:getTheme("MenubarBG")bd.fgColor=bd.parent:getTheme("MenubarText") -db=bd.parent:getTheme("SelectionBG")_c=bd.parent:getTheme("SelectionText")end end}return setmetatable(bb,_b)end -end; -project['objects']['Pane'] = function(...)local c=require("Object")local d=require("basaltLogs") -return -function(_a)local aa=c(_a) -local ba="Pane" -local ca={getType=function(da)return ba end,setBackground=function(da,_b,ab,bb)aa.setBackground(da,_b,ab,bb)return da end,init=function(da)if -(aa.init(da))then da.bgColor=da.parent:getTheme("PaneBG") -da.fgColor=da.parent:getTheme("PaneBG")end end}return setmetatable(ca,aa)end -end; -project['objects']['Program'] = function(...)local aa=require("Object")local ba=require("tHex") -local ca=require("process")local da=require("utils").getValueFromXML;local _b=string.sub -return -function(ab,bb) -local cb=aa(ab)local db="Program"cb:setZIndex(5)local _c;local ac;local bc={} -local function cc(b_a,c_a,d_a,_aa,aaa)local baa,caa=1,1 -local daa,_ba=colors.black,colors.white;local aba=false;local bba=false;local cba={}local dba={}local _ca={}local aca={}local bca;local cca={}for i=0,15 do local aab=2 ^i -aca[aab]={bb:getBasaltInstance().getBaseTerm().getPaletteColour(aab)}end;local function dca() -bca=(" "):rep(d_a) -for n=0,15 do local aab=2 ^n;local bab=ba[aab]cca[aab]=bab:rep(d_a)end end -local function _da()dca()local aab=bca -local bab=cca[colors.white]local cab=cca[colors.black] -for n=1,_aa do -cba[n]=_b(cba[n]==nil and aab or cba[n]..aab:sub(1, -d_a-cba[n]:len()),1,d_a) -_ca[n]=_b(_ca[n]==nil and bab or _ca[n].. -bab:sub(1,d_a-_ca[n]:len()),1,d_a) -dba[n]=_b(dba[n]==nil and cab or dba[n].. -cab:sub(1,d_a-dba[n]:len()),1,d_a)end;cb.updateDraw(cb)end;_da()local function ada()if -baa>=1 and caa>=1 and baa<=d_a and caa<=_aa then else end end -local function bda(aab,bab,cab) -local dab=baa;local _bb=dab+#aab-1 -if caa>=1 and caa<=_aa then -if dab<=d_a and _bb>=1 then -if dab==1 and _bb== -d_a then cba[caa]=aab;_ca[caa]=bab;dba[caa]=cab else local abb,bbb,cbb -if dab<1 then local _db= -1 -dab+1;local adb=d_a-dab+1;abb=_b(aab,_db,adb) -bbb=_b(bab,_db,adb)cbb=_b(cab,_db,adb)elseif _bb>d_a then local _db=d_a-dab+1;abb=_b(aab,1,_db) -bbb=_b(bab,1,_db)cbb=_b(cab,1,_db)else abb=aab;bbb=bab;cbb=cab end;local dbb=cba[caa]local _cb=_ca[caa]local acb=dba[caa]local bcb,ccb,dcb -if dab>1 then local _db=dab-1;bcb= -_b(dbb,1,_db)..abb;ccb=_b(_cb,1,_db)..bbb -dcb=_b(acb,1,_db)..cbb else bcb=abb;ccb=bbb;dcb=cbb end -if _bb=1 and _bb<=_aa then -cba[newY]=cba[_bb]dba[newY]=dba[_bb]_ca[newY]=_ca[_bb]else cba[newY]=bab -_ca[newY]=cab;dba[newY]=dab end end end;if(bba)then ada()end end,isColor=function()return -bb:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return -bb:getBasaltInstance().getBaseTerm().isColor()end,write=function(aab) -aab=tostring(aab)if(bba)then -bda(aab,ba[_ba]:rep(aab:len()),ba[daa]:rep(aab:len()))end end,clearLine=function() -if -(bba)then cda(1,caa,(" "):rep(d_a)) -dda(1,caa,ba[daa]:rep(d_a))__b(1,caa,ba[_ba]:rep(d_a))end;if(bba)then ada()end end,clear=function() -for n=1,_aa -do cda(1,n,(" "):rep(d_a)) -dda(1,n,ba[daa]:rep(d_a))__b(1,n,ba[_ba]:rep(d_a))end;if(bba)then ada()end end,blit=function(aab,bab,cab)if -type(aab)~="string"then -error("bad argument #1 (expected string, got "..type(aab)..")",2)end;if type(bab)~="string"then -error( -"bad argument #2 (expected string, got "..type(bab)..")",2)end;if type(cab)~="string"then -error( -"bad argument #3 (expected string, got "..type(cab)..")",2)end -if -#bab~=#aab or#cab~=#aab then error("Arguments must be the same length",2)end;if(bba)then bda(aab,bab,cab)end end}return _ab end;cb.width=30;cb.height=12;local dc=cc(1,1,cb.width,cb.height)local _d -local ad=false;local bd={} -local function cd(b_a)local c_a,d_a=dc.getCursorPos() -local _aa,aaa=b_a:getAnchorPosition()local baa,caa=b_a:getSize() -if(_aa+c_a-1 >=1 and -_aa+c_a-1 <=_aa+baa-1 and d_a+aaa-1 >=1 and -d_a+aaa-1 <=aaa+caa-1)then -b_a.parent:setCursor( -b_a:isFocused()and dc.getCursorBlink(),_aa+c_a-1,d_a+aaa-1,dc.getTextColor())end end -local function dd(b_a,c_a,...)local d_a,_aa=_d:resume(c_a,...) -if(d_a==false)and(_aa~=nil)and -(_aa~="Terminated")then -local aaa=b_a:sendEvent("program_error",_aa) -if(aaa~=false)then error("Basalt Program - ".._aa)end end -if(_d:getStatus()=="dead")then b_a:sendEvent("program_done")end end -local function __a(b_a,c_a,d_a,_aa,aaa)if(_d==nil)then return false end -if not(_d:isDead())then -if not(ad)then -local baa,caa=b_a:getAbsolutePosition(b_a:getAnchorPosition( -nil,nil,true))dd(b_a,c_a,d_a,_aa-baa+1,aaa-caa+1)cd(b_a)end end end -local function a_a(b_a,c_a,d_a,_aa)if(_d==nil)then return false end -if not(_d:isDead())then if not(ad)then if(b_a.draw)then -dd(b_a,c_a,d_a,_aa)cd(b_a)end end end end -_c={getType=function(b_a)return db end,show=function(b_a)cb.show(b_a) -dc.setBackgroundColor(b_a.bgColor)dc.setTextColor(b_a.fgColor) -dc.basalt_setVisible(true)return b_a end,hide=function(b_a) -cb.hide(b_a)dc.basalt_setVisible(false)return b_a end,setPosition=function(b_a,c_a,d_a,_aa) -cb.setPosition(b_a,c_a,d_a,_aa) -dc.basalt_reposition(b_a:getAnchorPosition())return b_a end,setValuesByXMLData=function(b_a,c_a) -cb.setValuesByXMLData(b_a,c_a)if(da("path",c_a)~=nil)then ac=da("path",c_a)end -if( -da("execute",c_a)~=nil)then if(da("execute",c_a))then -if(ac~=nil)then b_a:execute(ac)end end end end,getBasaltWindow=function()return -dc end,getBasaltProcess=function()return _d end,setSize=function(b_a,c_a,d_a,_aa)cb.setSize(b_a,c_a,d_a,_aa) -dc.basalt_resize(b_a:getWidth(),b_a:getHeight())return b_a end,getStatus=function(b_a)if(_d~=nil)then return -_d:getStatus()end;return"inactive"end,setEnviroment=function(b_a,c_a)bc= -c_a or{}return b_a end,execute=function(b_a,c_a,...)ac=c_a or ac -_d=ca:new(ac,dc,bc,...)dc.setBackgroundColor(colors.black) -dc.setTextColor(colors.white)dc.clear()dc.setCursorPos(1,1) -dc.setBackgroundColor(b_a.bgColor)dc.setTextColor(b_a.fgColor) -dc.basalt_setVisible(true)dd(b_a)ad=false -if(b_a.parent~=nil)then -b_a.parent:addEvent("mouse_click",b_a)b_a.parent:addEvent("mouse_up",b_a) -b_a.parent:addEvent("mouse_drag",b_a)b_a.parent:addEvent("mouse_scroll",b_a) -b_a.parent:addEvent("key",b_a)b_a.parent:addEvent("key_up",b_a) -b_a.parent:addEvent("char",b_a)b_a.parent:addEvent("other_event",b_a)end;return b_a end,stop=function(b_a) -if( -_d~=nil)then if not(_d:isDead())then dd(b_a,"terminate") -if(_d:isDead())then if -(b_a.parent~=nil)then b_a.parent:setCursor(false)end end end end;b_a.parent:removeEvents(b_a)return b_a end,pause=function(b_a,c_a)ad= -c_a or(not ad) -if(_d~=nil)then if not(_d:isDead())then if not(ad)then -b_a:injectEvents(bd)bd={}end end end;return b_a end,isPaused=function(b_a)return -ad end,injectEvent=function(b_a,c_a,d_a,_aa,aaa,baa,caa) -if(_d~=nil)then -if not(_d:isDead())then if(ad==false)or(caa)then -dd(b_a,c_a,d_a,_aa,aaa,baa)else -table.insert(bd,{event=c_a,args={d_a,_aa,aaa,baa}})end end end;return b_a end,getQueuedEvents=function(b_a)return -bd end,updateQueuedEvents=function(b_a,c_a)bd=c_a or bd;return b_a end,injectEvents=function(b_a,c_a)if(_d~=nil)then -if not -(_d:isDead())then for d_a,_aa in pairs(c_a)do -dd(b_a,_aa.event,table.unpack(_aa.args))end end end;return b_a end,mouseHandler=function(b_a,c_a,d_a,_aa) -if -(cb.mouseHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_click",c_a,d_a,_aa)return true end;return false end,mouseUpHandler=function(b_a,c_a,d_a,_aa) -if -(cb.mouseUpHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_up",c_a,d_a,_aa)return true end;return false end,scrollHandler=function(b_a,c_a,d_a,_aa) -if -(cb.scrollHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_scroll",c_a,d_a,_aa)return true end;return false end,dragHandler=function(b_a,c_a,d_a,_aa) -if -(cb.dragHandler(b_a,c_a,d_a,_aa))then __a(b_a,"mouse_drag",c_a,d_a,_aa)return true end;return false end,keyHandler=function(b_a,c_a,d_a)if -(cb.keyHandler(b_a,c_a,d_a))then a_a(b_a,"key",c_a,d_a)return true end;return -false end,keyUpHandler=function(b_a,c_a)if -(cb.keyUpHandler(b_a,c_a))then a_a(b_a,"key_up",c_a)return true end -return false end,charHandler=function(b_a,c_a)if -(cb.charHandler(b_a,c_a))then a_a(b_a,"char",c_a)return true end -return false end,getFocusHandler=function(b_a) -cb.getFocusHandler(b_a) -if(_d~=nil)then -if not(_d:isDead())then -if not(ad)then -if(b_a.parent~=nil)then -local c_a,d_a=dc.getCursorPos()local _aa,aaa=b_a:getAnchorPosition()local baa,caa=b_a:getSize() -if -( -_aa+c_a-1 >=1 and _aa+c_a-1 <=_aa+baa-1 and -d_a+aaa-1 >=1 and d_a+aaa-1 <=aaa+caa-1)then -b_a.parent:setCursor(dc.getCursorBlink(),_aa+c_a-1,d_a+aaa-1,dc.getTextColor())end end end end end end,loseFocusHandler=function(b_a) -cb.loseFocusHandler(b_a) -if(_d~=nil)then if not(_d:isDead())then if(b_a.parent~=nil)then -b_a.parent:setCursor(false)end end end end,eventHandler=function(b_a,c_a,d_a,_aa,aaa,baa) -if -(cb.eventHandler(b_a,c_a,d_a,_aa,aaa,baa))then if(_d==nil)then return end -if(c_a=="dynamicValueEvent")then local caa,daa=dc.getSize() -local _ba,aba=b_a:getSize() -if(caa~=_ba)or(daa~=aba)then dc.basalt_resize(_ba,aba)if not -(_d:isDead())then dd(b_a,"term_resize")end end -dc.basalt_reposition(b_a:getAnchorPosition())end -if not(_d:isDead())then -if not(ad)then if(c_a~="terminate")then -dd(b_a,c_a,d_a,_aa,aaa,baa)end -if(b_a:isFocused())then -local caa,daa=b_a:getAnchorPosition()local _ba,aba=dc.getCursorPos() -if(b_a.parent~=nil)then -local bba,cba=b_a:getSize() -if -(caa+_ba-1 >=1 and caa+_ba-1 <=caa+bba-1 and -aba+daa-1 >=1 and aba+daa-1 <=daa+cba-1)then -b_a.parent:setCursor(dc.getCursorBlink(),caa+_ba-1,aba+daa-1,dc.getTextColor())end end;if(c_a=="terminate")then dd(b_a,c_a) -b_a.parent:setCursor(false)return true end end else -table.insert(bd,{event=c_a,args={d_a,_aa,aaa,baa}})end end;return false end end,draw=function(b_a) -if -(cb.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=dc.getCursorPos()local baa,caa=b_a:getSize()dc.basalt_reposition(c_a,d_a) -dc.basalt_update() -if -(c_a+_aa-1 >=1 and c_a+_aa-1 <=c_a+baa-1 and -aaa+d_a-1 >=1 and aaa+d_a-1 <=d_a+caa-1)then -b_a.parent:setCursor(b_a:isFocused()and dc.getCursorBlink(), -c_a+_aa-1,aaa+d_a-1,dc.getTextColor())end end end end,onError=function(b_a,...) -for c_a,d_a in -pairs(table.pack(...))do if(type(d_a)=="function")then -b_a:registerEvent("program_error",d_a)end end;if(b_a.parent~=nil)then -b_a.parent:addEvent("other_event",b_a)end;return b_a end,onDone=function(b_a,...) -for c_a,d_a in -pairs(table.pack(...))do if(type(d_a)=="function")then -b_a:registerEvent("program_done",d_a)end end;if(b_a.parent~=nil)then -b_a.parent:addEvent("other_event",b_a)end;return b_a end,init=function(b_a) -if -(cb.init(b_a))then elf.bgColor=b_a.parent:getTheme("ProgramBG")end end}return setmetatable(_c,cb)end -end; -project['objects']['Progressbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Progressbar"local ca=0;aa:setZIndex(5) -aa:setValue(false)aa.width=25;aa.height=1;local da;local _b=""local ab=colors.white;local bb=""local cb=0 -local db={init=function(_c) -if -(aa.init(_c))then _c.bgColor=_c.parent:getTheme("ProgressbarBG") -_c.fgColor=_c.parent:getTheme("ProgressbarText")da=_c.parent:getTheme("ProgressbarActiveBG")end end,getType=function(_c)return -ba end,setValuesByXMLData=function(_c,ac)aa.setValuesByXMLData(_c,ac)if(d("direction",ac)~= -nil)then cb=d("direction",ac)end -if( -d("progressColor",ac)~=nil)then da=colors[d("progressColor",ac)]end -if(d("progressSymbol",ac)~=nil)then _b=d("progressSymbol",ac)end;if(d("backgroundSymbol",ac)~=nil)then -bb=d("backgroundSymbol",ac)end -if -(d("progressSymbolColor",ac)~=nil)then ab=colors[d("progressSymbolColor",ac)]end;if(d("onDone",ac)~=nil)then -_c:generateXMLEventFunction(_c.onProgressDone,d("onDone",ac))end;return _c end,setDirection=function(_c,ac) -cb=ac;_c:updateDraw()return _c end,setProgressBar=function(_c,ac,bc,cc)da=ac or da -_b=bc or _b;ab=cc or ab;_c:updateDraw()return _c end,setBackgroundSymbol=function(_c,ac) -bb=ac:sub(1,1)_c:updateDraw()return _c end,setProgress=function(_c,ac)if -(ac>=0)and(ac<=100)and(ca~=ac)then ca=ac;_c:setValue(ca)if(ca==100)then -_c:progressDoneHandler()end end -_c:updateDraw()return _c end,getProgress=function(_c)return -ca end,onProgressDone=function(_c,ac)_c:registerEvent("progress_done",ac) -return _c end,progressDoneHandler=function(_c) -_c:sendEvent("progress_done",_c)end,draw=function(_c) -if(aa.draw(_c))then -if(_c.parent~=nil)then -local ac,bc=_c:getAnchorPosition()local cc,dc=_c:getSize()if(_c.bgColor~=false)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc,_c.bgColor)end;if(bb~="")then -_c.parent:drawTextBox(ac,bc,cc,dc,bb)end;if(_c.fgColor~=false)then -_c.parent:drawForegroundBox(ac,bc,cc,dc,_c.fgColor)end -if(cb==1)then -_c.parent:drawBackgroundBox(ac,bc,cc,dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc,cc,dc/100 *ca,ab) -_c.parent:drawTextBox(ac,bc,cc,dc/100 *ca,_b)elseif(cb==2)then -_c.parent:drawBackgroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,da) -_c.parent:drawForegroundBox(ac,bc+math.ceil(dc-dc/100 *ca),cc,dc/ -100 *ca,ab) -_c.parent:drawTextBox(ac,bc+math.ceil(dc-dc/100 *ca),cc, -dc/100 *ca,_b)elseif(cb==3)then -_c.parent:drawBackgroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac+math.ceil(cc-cc/100 *ca),bc, -cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac+math.ceil(cc-cc/100 *ca),bc,cc/100 * -ca,dc,_b)else -_c.parent:drawBackgroundBox(ac,bc,cc/100 *ca,dc,da) -_c.parent:drawForegroundBox(ac,bc,cc/100 *ca,dc,ab) -_c.parent:drawTextBox(ac,bc,cc/100 *ca,dc,_b)end end end end}return setmetatable(db,aa)end -end; -project['objects']['Radio'] = function(...)local d=require("Object")local _a=require("utils") -local aa=_a.getValueFromXML -return -function(ba)local ca=d(ba)local da="Radio"ca.width=8;ca:setZIndex(5)local _b={}local ab;local bb;local cb -local db;local _c;local ac;local bc=true;local cc="\7"local dc="left" -local _d={getType=function(ad)return da end,setValuesByXMLData=function(ad,bd) -ca.setValuesByXMLData(ad,bd)if(aa("selectionBG",bd)~=nil)then -ab=colors[aa("selectionBG",bd)]end;if(aa("selectionFG",bd)~=nil)then -bb=colors[aa("selectionFG",bd)]end;if(aa("boxBG",bd)~=nil)then -cb=colors[aa("boxBG",bd)]end;if(aa("inactiveBoxBG",bd)~=nil)then -_c=colors[aa("inactiveBoxBG",bd)]end;if(aa("inactiveBoxFG",bd)~=nil)then -ac=colors[aa("inactiveBoxFG",bd)]end;if(aa("boxFG",bd)~=nil)then -db=colors[aa("boxFG",bd)]end;if(aa("symbol",bd)~=nil)then -cc=aa("symbol",bd)end -if(bd["item"]~=nil)then local cd=bd["item"]if -(cd.properties~=nil)then cd={cd}end;for dd,__a in pairs(cd)do -ad:addItem(aa("text",__a),aa("x",__a),aa("y",__a),colors[aa("bg",__a)],colors[aa("fg",__a)])end end;return ad end,addItem=function(ad,bd,cd,dd,__a,a_a,...) -table.insert(_b,{x= -cd or 1,y=dd or 1,text=bd,bgCol=__a or ad.bgColor,fgCol=a_a or ad.fgColor,args={...}})if(#_b==1)then ad:setValue(_b[1])end -ad:updateDraw()return ad end,getAll=function(ad)return -_b end,removeItem=function(ad,bd)table.remove(_b,bd)ad:updateDraw()return ad end,getItem=function(ad,bd)return -_b[bd]end,getItemIndex=function(ad)local bd=ad:getValue()for cd,dd in pairs(_b)do -if(dd==bd)then return cd end end end,clear=function(ad) -_b={}ad:setValue({})ad:updateDraw()return ad end,getItemCount=function(ad)return -#_b end,editItem=function(ad,bd,cd,dd,__a,a_a,b_a,...)table.remove(_b,bd) -table.insert(_b,bd,{x=dd or 1,y=__a or 1,text=cd,bgCol=a_a or -ad.bgColor,fgCol=b_a or ad.fgColor,args={...}})ad:updateDraw()return ad end,selectItem=function(ad,bd)ad:setValue( -_b[bd]or{})ad:updateDraw()return ad end,setActiveSymbol=function(ad,bd) -cc=bd:sub(1,1)ad:updateDraw()return ad end,setSelectedItem=function(ad,bd,cd,dd,__a,a_a)ab=bd or ab -bb=cd or bb;cb=dd or cb;db=__a or db;bc=a_a~=nil and a_a or true -ad:updateDraw()return ad end,mouseHandler=function(ad,bd,cd,dd) -if(#_b> -0)then -local __a,a_a=ad:getAbsolutePosition(ad:getAnchorPosition()) -for b_a,c_a in pairs(_b)do -if(__a+c_a.x-1 <=cd)and( -__a+c_a.x-1 +c_a.text:len()+1 >=cd)and( -a_a+c_a.y-1 ==dd)then ad:setValue(c_a) -local d_a=ad:getEventSystem():sendEvent("mouse_click",ad,"mouse_click",bd,cd,dd)if(d_a==false)then return d_a end;if(ad.parent~=nil)then -ad.parent:setFocusedObject(ad)end;ad:updateDraw()return true end end end;return false end,draw=function(ad) -if( -ad.parent~=nil)then local bd,cd=ad:getAnchorPosition() -for dd,__a in pairs(_b)do -if -(__a==ad:getValue())then if(dc=="left")then -ad.parent:writeText(__a.x+bd-1,__a.y+cd-1,cc,cb,db) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,ab,bb)end else -ad.parent:drawBackgroundBox( -__a.x+bd-1,__a.y+cd-1,1,1,_c or ad.bgColor) -ad.parent:writeText(__a.x+2 +bd-1,__a.y+cd-1,__a.text,__a.bgCol,__a.fgCol)end end;return true end end,init=function(ad) -ad.parent:addEvent("mouse_click",ad) -if(ca.init(ad))then ad.bgColor=ad.parent:getTheme("MenubarBG") -ad.fgColor=ad.parent:getTheme("MenubarFG")ab=ad.parent:getTheme("SelectionBG") -bb=ad.parent:getTheme("SelectionText")cb=ad.parent:getTheme("MenubarBG") -db=ad.parent:getTheme("MenubarText")end end}return setmetatable(_d,ca)end -end; -project['objects']['Scrollbar'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Scrollbar"aa.width=1;aa.height=8;aa:setValue(1) -aa:setZIndex(2)local ca="vertical"local da=" "local _b;local ab="\127"local bb=aa.height;local cb=1;local db=1 -local function _c(bc,cc,dc,_d) -local ad,bd=bc:getAbsolutePosition(bc:getAnchorPosition())local cd,dd=bc:getSize() -if(ca=="horizontal")then for _index=0,cd do -if -(ad+_index==dc)and(bd<=_d)and(bd+dd>_d)then -cb=math.min(_index+1,cd- (db-1))bc:setValue(bb/cd* (cb))bc:updateDraw()end end end -if(ca=="vertical")then for _index=0,dd do -if -(bd+_index==_d)and(ad<=dc)and(ad+cd>dc)then cb=math.min(_index+1,dd- (db-1)) -bc:setValue(bb/dd* (cb))bc:updateDraw()end end end end -local ac={getType=function(bc)return ba end,setSymbol=function(bc,cc)da=cc:sub(1,1)bc:updateDraw()return bc end,setValuesByXMLData=function(bc,cc) -aa.setValuesByXMLData(bc,cc) -if(d("maxValue",cc)~=nil)then bb=d("maxValue",cc)end;if(d("backgroundSymbol",cc)~=nil)then -ab=d("backgroundSymbol",cc):sub(1,1)end;if(d("symbol",cc)~=nil)then -da=d("symbol",cc):sub(1,1)end;if(d("barType",cc)~=nil)then -ca=d("barType",cc):lower()end;if(d("symbolSize",cc)~=nil)then -bc:setSymbolSize(d("symbolSize",cc))end;if(d("symbolColor",cc)~=nil)then -_b=colors[d("symbolColor",cc)]end;if(d("index",cc)~=nil)then -bc:setIndex(d("index",cc))end end,setIndex=function(bc,cc) -cb=cc;if(cb<1)then cb=1 end;local dc,_d=bc:getSize() -cb=math.min(cb,(ca=="vertical"and _d or -dc)- (db-1)) -bc:setValue(bb/ (ca=="vertical"and _d or dc)*cb)bc:updateDraw()return bc end,getIndex=function(bc)return -cb end,setSymbolSize=function(bc,cc)db=tonumber(cc)or 1;local dc,_d=bc:getSize() -if(ca== -"vertical")then -bc:setValue(cb-1 * (bb/ (_d- (db-1)))- -(bb/ (_d- (db-1))))elseif(ca=="horizontal")then -bc:setValue(cb-1 * (bb/ (dc- (db-1)))- (bb/ (dc- -(db-1))))end;bc:updateDraw()return bc end,setMaxValue=function(bc,cc) -bb=cc;bc:updateDraw()return bc end,setBackgroundSymbol=function(bc,cc) -ab=string.sub(cc,1,1)bc:updateDraw()return bc end,setSymbolColor=function(bc,cc)_b=cc -bc:updateDraw()return bc end,setBarType=function(bc,cc)ca=cc:lower()bc:updateDraw() -return bc end,mouseHandler=function(bc,cc,dc,_d)if(aa.mouseHandler(bc,cc,dc,_d))then -_c(bc,cc,dc,_d)return true end;return false end,dragHandler=function(bc,cc,dc,_d)if -(aa.dragHandler(bc,cc,dc,_d))then _c(bc,cc,dc,_d)return true end;return false end,scrollHandler=function(bc,cc,dc,_d) -if -(aa.scrollHandler(bc,cc,dc,_d))then local ad,bd=bc:getSize()cb=cb+cc;if(cb<1)then cb=1 end -cb=math.min(cb,( -ca=="vertical"and bd or ad)- (db-1)) -bc:setValue(bb/ (ca=="vertical"and bd or ad)*cb)bc:updateDraw()end end,draw=function(bc) -if -(aa.draw(bc))then -if(bc.parent~=nil)then local cc,dc=bc:getAnchorPosition() -local _d,ad=bc:getSize() -if(ca=="horizontal")then -bc.parent:writeText(cc,dc,ab:rep(cb-1),bc.bgColor,bc.fgColor) -bc.parent:writeText(cc+cb-1,dc,da:rep(db),_b,_b) -bc.parent:writeText(cc+cb+db-1,dc,ab:rep(_d- (cb+db-1)),bc.bgColor,bc.fgColor)end -if(ca=="vertical")then -for n=0,ad-1 do -if(cb==n+1)then for curIndexOffset=0,math.min(db-1,ad)do -bc.parent:writeText(cc,dc+n+curIndexOffset,da,_b,_b)end else if -(n+1 cb-1 +db)then -bc.parent:writeText(cc,dc+n,ab,bc.bgColor,bc.fgColor)end end end end end end end,init=function(bc) -bc.parent:addEvent("mouse_click",bc)bc.parent:addEvent("mouse_drag",bc) -bc.parent:addEvent("mouse_scroll",bc) -if(aa.init(bc))then -bc.bgColor=bc.parent:getTheme("ScrollbarBG")bc.fgColor=bc.parent:getTheme("ScrollbarText") -_b=bc.parent:getTheme("ScrollbarSymbolColor")end end}return setmetatable(ac,aa)end -end; -project['objects']['Slider'] = function(...)local d=require("Object")local _a=require("basaltLogs") -local aa=require("utils").getValueFromXML -return -function(ba)local ca=d(ba)local da="Slider"ca.width=8;ca.height=1;ca:setValue(1) -local _b="horizontal"local ab=" "local bb;local cb="\140"local db=ca.width;local _c=1;local ac=1 -local function bc(dc,_d,ad,bd) -local cd,dd=dc:getAbsolutePosition(dc:getAnchorPosition())local __a,a_a=dc:getSize() -if(_b=="horizontal")then for _index=0,__a do -if -(cd+_index==ad)and(dd<=bd)and(dd+a_a>bd)then -_c=math.min(_index+1,__a- (ac-1))dc:setValue(db/__a* (_c))dc:updateDraw()end end end -if(_b=="vertical")then for _index=0,a_a do -if -(dd+_index==bd)and(cd<=ad)and(cd+__a>ad)then _c=math.min(_index+1,a_a- (ac-1)) -dc:setValue(db/a_a* (_c))dc:updateDraw()end end end end -local cc={getType=function(dc)return da end,setSymbol=function(dc,_d)ab=_d:sub(1,1)dc:updateDraw()return dc end,setValuesByXMLData=function(dc,_d) -ca.setValuesByXMLData(dc,_d) -if(aa("maxValue",_d)~=nil)then db=aa("maxValue",_d)end;if(aa("backgroundSymbol",_d)~=nil)then -cb=aa("backgroundSymbol",_d):sub(1,1)end;if(aa("barType",_d)~=nil)then -_b=aa("barType",_d):lower()end;if(aa("symbol",_d)~=nil)then -ab=aa("symbol",_d):sub(1,1)end;if(aa("symbolSize",_d)~=nil)then -dc:setSymbolSize(aa("symbolSize",_d))end;if(aa("symbolColor",_d)~=nil)then -bb=colors[aa("symbolColor",_d)]end;if(aa("index",_d)~=nil)then -dc:setIndex(aa("index",_d))end end,setIndex=function(dc,_d) -_c=_d;if(_c<1)then _c=1 end;local ad,bd=dc:getSize() -_c=math.min(_c,(_b=="vertical"and bd or -ad)- (ac-1)) -dc:setValue(db/ (_b=="vertical"and bd or ad)*_c)dc:updateDraw()return dc end,getIndex=function(dc)return -_c end,setSymbolSize=function(dc,_d)ac=tonumber(_d)or 1 -if(_b=="vertical")then -dc:setValue(_c-1 * (db/ -(h- (ac-1)))- (db/ (h- (ac-1))))elseif(_b=="horizontal")then -dc:setValue(_c-1 * (db/ (w- (ac-1)))- (db/ -(w- (ac-1))))end;dc:updateDraw()return dc end,setMaxValue=function(dc,_d) -db=_d;return dc end,setBackgroundSymbol=function(dc,_d)cb=string.sub(_d,1,1) -dc:updateDraw()return dc end,setSymbolColor=function(dc,_d)bb=_d;dc:updateDraw()return dc end,setBarType=function(dc,_d) -_b=_d:lower()dc:updateDraw()return dc end,mouseHandler=function(dc,_d,ad,bd)if -(ca.mouseHandler(dc,_d,ad,bd))then bc(dc,_d,ad,bd)return true end;return false end,dragHandler=function(dc,_d,ad,bd)if -(ca.dragHandler(dc,_d,ad,bd))then bc(dc,_d,ad,bd)return true end;return false end,scrollHandler=function(dc,_d,ad,bd) -if -(ca.scrollHandler(dc,_d,ad,bd))then local cd,dd=dc:getSize()_c=_c+_d;if(_c<1)then _c=1 end -_c=math.min(_c,( -_b=="vertical"and dd or cd)- (ac-1)) -dc:setValue(db/ (_b=="vertical"and dd or cd)*_c)dc:updateDraw()return true end;return false end,draw=function(dc) -if -(ca.draw(dc))then -if(dc.parent~=nil)then local _d,ad=dc:getAnchorPosition() -local bd,cd=dc:getSize() -if(_b=="horizontal")then -dc.parent:writeText(_d,ad,cb:rep(_c-1),dc.bgColor,dc.fgColor) -dc.parent:writeText(_d+_c-1,ad,ab:rep(ac),bb,bb) -dc.parent:writeText(_d+_c+ac-1,ad,cb:rep(bd- (_c+ac-1)),dc.bgColor,dc.fgColor)end -if(_b=="vertical")then -for n=0,cd-1 do -if(_c==n+1)then for curIndexOffset=0,math.min(ac-1,cd)do -dc.parent:writeText(_d,ad+n+curIndexOffset,ab,bb,bb)end else if -(n+1 <_c)or(n+1 >_c-1 +ac)then -dc.parent:writeText(_d,ad+n,cb,dc.bgColor,dc.fgColor)end end end end end end end,init=function(dc) -dc.parent:addEvent("mouse_click",dc)dc.parent:addEvent("mouse_drag",dc) -dc.parent:addEvent("mouse_scroll",dc) -if(ca.init(dc))then dc.bgColor=dc.parent:getTheme("SliderBG") -dc.fgColor=dc.parent:getTheme("SliderText")bb=dc.parent:getTheme("SliderSymbolColor")end end}return setmetatable(cc,ca)end -end; -project['objects']['Switch'] = function(...)local c=require("Object") -local d=require("utils").getValueFromXML -return -function(_a)local aa=c(_a)local ba="Switch"aa.width=2;aa.height=1 -aa.bgColor=colors.lightGray;aa.fgColor=colors.gray;aa:setValue(false)aa:setZIndex(5) -local ca=colors.black;local da=colors.red;local _b=colors.green -local ab={getType=function(bb)return ba end,setSymbolColor=function(bb,cb)ca=cb -bb:updateDraw()return bb end,setActiveBackground=function(bb,cb)_b=cb;bb:updateDraw()return bb end,setInactiveBackground=function(bb,cb) -da=cb;bb:updateDraw()return bb end,setValuesByXMLData=function(bb,cb) -aa.setValuesByXMLData(bb,cb)if(d("inactiveBG",cb)~=nil)then -da=colors[d("inactiveBG",cb)]end;if(d("activeBG",cb)~=nil)then -_b=colors[d("activeBG",cb)]end;if(d("symbolColor",cb)~=nil)then -ca=colors[d("symbolColor",cb)]end end,mouseHandler=function(bb,cb,db,_c) -if -(aa.mouseHandler(bb,cb,db,_c))then -local ac,bc=bb:getAbsolutePosition(bb:getAnchorPosition())bb:setValue(not bb:getValue()) -bb:updateDraw()return true end end,draw=function(bb) -if -(aa.draw(bb))then -if(bb.parent~=nil)then local cb,db=bb:getAnchorPosition() -local _c,ac=bb:getSize() -bb.parent:drawBackgroundBox(cb,db,_c,ac,bb.bgColor) -if(bb:getValue())then -bb.parent:drawBackgroundBox(cb,db,1,ac,_b)bb.parent:drawBackgroundBox(cb+1,db,1,ac,ca)else -bb.parent:drawBackgroundBox(cb,db,1,ac,ca)bb.parent:drawBackgroundBox(cb+1,db,1,ac,da)end end end end,init=function(bb) -bb.parent:addEvent("mouse_click",bb) -if(aa.init(bb))then bb.bgColor=bb.parent:getTheme("SwitchBG") -bb.fgColor=bb.parent:getTheme("SwitchText")ca=bb.parent:getTheme("SwitchBGSymbol") -da=bb.parent:getTheme("SwitchInactive")_b=bb.parent:getTheme("SwitchActive")end end}return setmetatable(ab,aa)end -end; -project['objects']['Textfield'] = function(...)local aa=require("Object")local ba=require("tHex") -local ca=require("basaltLogs")local da=require("utils").getValueFromXML;local _b=string.rep -return -function(ab) -local bb=aa(ab)local cb="Textfield"local db,_c,ac,bc=1,1,1,1;local cc={""}local dc={""}local _d={""}local ad={}local bd={} -bb.width=30;bb.height=12;bb:setZIndex(5) -local function cd(b_a,c_a)local d_a={} -if(b_a:len()>0)then -for _aa in -string.gmatch(b_a,c_a)do local aaa,baa=string.find(b_a,_aa) -if(aaa~=nil)and(baa~=nil)then -table.insert(d_a,aaa)table.insert(d_a,baa) -local caa=string.sub(b_a,1,(aaa-1))local daa=string.sub(b_a,baa+1,b_a:len())b_a=caa.. -(":"):rep(_aa:len())..daa end end end;return d_a end -local function dd(b_a,c_a)c_a=c_a or bc -local d_a=ba[b_a.fgColor]:rep(_d[c_a]:len()) -local _aa=ba[b_a.bgColor]:rep(dc[c_a]:len()) -for aaa,baa in pairs(bd)do local caa=cd(cc[c_a],baa[1]) -if(#caa>0)then -for x=1,#caa/2 do local daa=x*2 -1;if( -baa[2]~=nil)then -d_a=d_a:sub(1,caa[daa]-1)..ba[baa[2] ]:rep(caa[daa+1]- -(caa[daa]-1)).. -d_a:sub(caa[daa+1]+1,d_a:len())end;if -(baa[3]~=nil)then -_aa=_aa:sub(1,caa[daa]-1).. - -ba[baa[3] ]:rep(caa[daa+1]- (caa[daa]-1)).._aa:sub(caa[daa+1]+1,_aa:len())end end end end -for aaa,baa in pairs(ad)do -for caa,daa in pairs(baa)do local _ba=cd(cc[c_a],daa) -if(#_ba>0)then for x=1,#_ba/2 do local aba=x*2 -1 -d_a=d_a:sub(1, -_ba[aba]-1).. - -ba[aaa]:rep(_ba[aba+1]- (_ba[aba]-1))..d_a:sub(_ba[aba+1]+1,d_a:len())end end end end;_d[c_a]=d_a;dc[c_a]=_aa;b_a:updateDraw()end;local function __a(b_a)for n=1,#cc do dd(b_a,n)end end -local a_a={getType=function(b_a)return cb end,setBackground=function(b_a,c_a) -bb.setBackground(b_a,c_a)__a(b_a)return b_a end,setForeground=function(b_a,c_a) -bb.setForeground(b_a,c_a)__a(b_a)return b_a end,setValuesByXMLData=function(b_a,c_a) -bb.setValuesByXMLData(b_a,c_a) -if(c_a["lines"]~=nil)then local d_a=c_a["lines"]["line"]if -(d_a.properties~=nil)then d_a={d_a}end;for _aa,aaa in pairs(d_a)do -b_a:addLine(aaa:value())end end -if(c_a["keywords"]~=nil)then -for d_a,_aa in pairs(c_a["keywords"])do -if(colors[d_a]~=nil)then -local aaa=_aa;if(aaa.properties~=nil)then aaa={aaa}end;local baa={} -for caa,daa in pairs(aaa)do -local _ba=daa["keyword"]if(daa["keyword"].properties~=nil)then -_ba={daa["keyword"]}end;for aba,bba in pairs(_ba)do -table.insert(baa,bba:value())end end;b_a:addKeywords(colors[d_a],baa)end end end -if(c_a["rules"]~=nil)then -if(c_a["rules"]["rule"]~=nil)then -local d_a=c_a["rules"]["rule"]if(c_a["rules"]["rule"].properties~=nil)then -d_a={c_a["rules"]["rule"]}end -for _aa,aaa in pairs(d_a)do if(da("pattern",aaa)~=nil)then -b_a:addRule(da("pattern",aaa),colors[da("fg",aaa)],colors[da("bg",aaa)])end end end end end,getLines=function(b_a)return -cc end,getLine=function(b_a,c_a)return cc[c_a]end,editLine=function(b_a,c_a,d_a) -cc[c_a]=d_a or cc[c_a]dd(b_a,c_a)b_a:updateDraw()return b_a end,clear=function(b_a) -cc={""}dc={""}_d={""}db,_c,ac,bc=1,1,1,1;b_a:updateDraw()return b_a end,addLine=function(b_a,c_a,d_a) -if( -c_a~=nil)then if(#cc==1)and(cc[1]=="")then cc[1]=c_a -dc[1]=ba[b_a.bgColor]:rep(c_a:len())_d[1]=ba[b_a.fgColor]:rep(c_a:len()) -dd(b_a,1)return b_a end -if( -d_a~=nil)then table.insert(cc,d_a,c_a) -table.insert(dc,d_a,ba[b_a.bgColor]:rep(c_a:len())) -table.insert(_d,d_a,ba[b_a.fgColor]:rep(c_a:len()))else table.insert(cc,c_a) -table.insert(dc,ba[b_a.bgColor]:rep(c_a:len())) -table.insert(_d,ba[b_a.fgColor]:rep(c_a:len()))end end;dd(b_a,d_a or#cc)b_a:updateDraw()return b_a end,addKeywords=function(b_a,c_a,d_a)if( -ad[c_a]==nil)then ad[c_a]={}end;for _aa,aaa in pairs(d_a)do -table.insert(ad[c_a],aaa)end;b_a:updateDraw()return b_a end,addRule=function(b_a,c_a,d_a,_aa) -table.insert(bd,{c_a,d_a,_aa})b_a:updateDraw()return b_a end,editRule=function(b_a,c_a,d_a,_aa)for aaa,baa in -pairs(bd)do -if(baa[1]==c_a)then bd[aaa][2]=d_a;bd[aaa][3]=_aa end end;b_a:updateDraw()return b_a end,removeRule=function(b_a,c_a) -for d_a,_aa in -pairs(bd)do if(_aa[1]==c_a)then table.remove(bd,d_a)end end;b_a:updateDraw()return b_a end,setKeywords=function(b_a,c_a,d_a) -ad[c_a]=d_a;b_a:updateDraw()return b_a end,removeLine=function(b_a,c_a)table.remove(cc,c_a or -#cc) -if(#cc<=0)then table.insert(cc,"")end;b_a:updateDraw()return b_a end,getTextCursor=function(b_a)return -ac,bc end,getFocusHandler=function(b_a)bb.getFocusHandler(b_a) -if(b_a.parent~=nil)then -local c_a,d_a=b_a:getAnchorPosition()if(b_a.parent~=nil)then -b_a.parent:setCursor(true,c_a+ac-_c,d_a+bc-db,b_a.fgColor)end end end,loseFocusHandler=function(b_a) -bb.loseFocusHandler(b_a) -if(b_a.parent~=nil)then b_a.parent:setCursor(false)end end,keyHandler=function(b_a,c_a) -if -(bb.keyHandler(b_a,event,c_a))then local d_a,_aa=b_a:getAnchorPosition()local aaa,baa=b_a:getSize() -if(c_a== -keys.backspace)then -if(cc[bc]=="")then -if(bc>1)then table.remove(cc,bc) -table.remove(_d,bc)table.remove(dc,bc)ac=cc[bc-1]:len()+1;_c= -ac-aaa+1;if(_c<1)then _c=1 end;bc=bc-1 end elseif(ac<=1)then -if(bc>1)then ac=cc[bc-1]:len()+1;_c=ac-aaa+1 -if(_c<1)then _c=1 end;cc[bc-1]=cc[bc-1]..cc[bc] -_d[bc-1]=_d[bc-1].._d[bc]dc[bc-1]=dc[bc-1]..dc[bc]table.remove(cc,bc) -table.remove(_d,bc)table.remove(dc,bc)bc=bc-1 end else -cc[bc]=cc[bc]:sub(1,ac-2)..cc[bc]:sub(ac,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-2).._d[bc]:sub(ac,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-2)..dc[bc]:sub(ac,dc[bc]:len())if(ac>1)then ac=ac-1 end -if(_c>1)then if(ac<_c)then _c=_c-1 end end end;if(bccc[bc]:len())then -if(cc[bc+1]~=nil)then cc[bc]=cc[bc].. -cc[bc+1]table.remove(cc,bc+1) -table.remove(dc,bc+1)table.remove(_d,bc+1)end else -cc[bc]=cc[bc]:sub(1,ac-1)..cc[bc]:sub(ac+1,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-1).._d[bc]:sub(ac+1,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-1)..dc[bc]:sub(ac+1,dc[bc]:len())end;dd(b_a)end -if(c_a==keys.enter)then -table.insert(cc,bc+1,cc[bc]:sub(ac,cc[bc]:len())) -table.insert(_d,bc+1,_d[bc]:sub(ac,_d[bc]:len())) -table.insert(dc,bc+1,dc[bc]:sub(ac,dc[bc]:len()))cc[bc]=cc[bc]:sub(1,ac-1) -_d[bc]=_d[bc]:sub(1,ac-1)dc[bc]=dc[bc]:sub(1,ac-1)bc=bc+1;ac=1;_c=1;if(bc-db>=baa)then -db=db+1 end;b_a:setValue("")end -if(c_a==keys.up)then -if(bc>1)then bc=bc-1;if(ac>cc[bc]:len()+1)then ac= -cc[bc]:len()+1 end;if(_c>1)then if(ac<_c)then _c=ac-aaa+1;if(_c<1)then -_c=1 end end end;if(db>1)then if( -bccc[bc]:len()+1)then ac= -cc[bc]:len()+1 end;if(_c>1)then if(ac<_c)then _c=ac-aaa+1;if(_c<1)then -_c=1 end end end;if(bc>= -db+baa)then db=db+1 end end end -if(c_a==keys.right)then ac=ac+1;if(bc<#cc)then if(ac>cc[bc]:len()+1)then ac=1 -bc=bc+1 end elseif(ac>cc[bc]:len())then -ac=cc[bc]:len()+1 end;if(ac<1)then ac=1 end;if -(ac<_c)or(ac>=aaa+_c)then _c=ac-aaa+1 end -if(_c<1)then _c=1 end end -if(c_a==keys.left)then ac=ac-1;if(ac>=1)then -if(ac<_c)or(ac>=aaa+_c)then _c=ac end end -if(bc>1)then if(ac<1)then bc=bc-1 -ac=cc[bc]:len()+1;_c=ac-aaa+1 end end;if(ac<1)then ac=1 end;if(_c<1)then _c=1 end end;local caa= -(ac<=cc[bc]:len()and ac-1 or cc[bc]:len())- (_c-1)if(caa> -b_a.x+aaa-1)then caa=b_a.x+aaa-1 end;local daa=( -bc-db=aaa+_c)then _c=_c+1 end;dd(b_a) -b_a:setValue("")local caa= -(ac<=cc[bc]:len()and ac-1 or cc[bc]:len())- (_c-1)if(caa> -b_a.x+aaa-1)then caa=b_a.x+aaa-1 end;local daa=( -bc-dbcaa+d_a- (aaa+1)+_c)and(caacc[bc]:len())then -ac=cc[bc]:len()+1 end -if(ac<_c)then _c=ac-1;if(_c<1)then _c=1 end end;if(b_a.parent~=nil)then -b_a.parent:setCursor(true,caa+ac-_c,daa+bc-db,b_a.fgColor)end;b_a:updateDraw()end end;return true end end,scrollHandler=function(b_a,c_a,d_a,_aa) -if -(bb.scrollHandler(b_a,c_a,d_a,_aa))then -local aaa,baa=b_a:getAbsolutePosition(b_a:getAnchorPosition())local caa,daa=b_a:getAnchorPosition()local _ba,aba=b_a:getSize() -db=db+c_a;if(db>#cc- (aba-1))then db=#cc- (aba-1)end -if(db<1)then db=1 end -if(b_a.parent~=nil)then -if - -(aaa+ac-_c>=aaa and aaa+ac-_c=baa and baa+bc-dbcc[bc]:len())then ac= -cc[bc]:len()+1 end -if(ac<_c)then _c=ac-1;if(_c<1)then _c=1 end end end;if(b_a.parent~=nil)then -b_a.parent:setCursor(true,caa+ac-_c,daa+bc-db,b_a.fgColor)end;return true end end,eventHandler=function(b_a,c_a,d_a,_aa,aaa,baa) -if -(bb.eventHandler(b_a,c_a,d_a,_aa,aaa,baa))then -if(c_a=="paste")then -if(b_a:isFocused())then local caa,daa=b_a:getSize() -cc[bc]= -cc[bc]:sub(1,ac-1)..d_a..cc[bc]:sub(ac,cc[bc]:len()) -_d[bc]=_d[bc]:sub(1,ac-1).. -ba[b_a.fgColor]:rep(d_a:len()).._d[bc]:sub(ac,_d[bc]:len()) -dc[bc]=dc[bc]:sub(1,ac-1).. -ba[b_a.bgColor]:rep(d_a:len())..dc[bc]:sub(ac,dc[bc]:len())ac=ac+d_a:len()if(ac>=caa+_c)then _c=(ac+1)-caa end -local _ba,aba=b_a:getAnchorPosition() -b_a.parent:setCursor(true,_ba+ac-_c,aba+bc-db,b_a.fgColor)dd(b_a)b_a:updateDraw()end end end end,draw=function(b_a) -if -(bb.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize() -for n=1,aaa do local baa=""local caa=""local daa=""if(cc[n+db-1]~=nil)then baa=cc[n+db-1] -daa=_d[n+db-1]caa=dc[n+db-1]end -baa=baa:sub(_c,_aa+_c-1)caa=caa:sub(_c,_aa+_c-1) -daa=daa:sub(_c,_aa+_c-1)local _ba=_aa-baa:len()if(_ba<0)then _ba=0 end -baa=baa.._b(b_a.bgSymbol,_ba)caa=caa.._b(ba[b_a.bgColor],_ba)daa=daa.. -_b(ba[b_a.fgColor],_ba) -b_a.parent:setText(c_a,d_a+n-1,baa)b_a.parent:setBG(c_a,d_a+n-1,caa)b_a.parent:setFG(c_a, -d_a+n-1,daa)end;if(b_a:isFocused())then local baa,caa=b_a:getAnchorPosition() -b_a.parent:setCursor(true, -baa+ac-_c,caa+bc-db,b_a.fgColor)end end end end,init=function(b_a) -b_a.parent:addEvent("mouse_click",b_a)b_a.parent:addEvent("mouse_scroll",b_a) -b_a.parent:addEvent("mouse_drag",b_a)b_a.parent:addEvent("key",b_a) -b_a.parent:addEvent("char",b_a)b_a.parent:addEvent("other_event",b_a) -if(bb.init(b_a))then -b_a.bgColor=b_a.parent:getTheme("TextfieldBG")b_a.fgColor=b_a.parent:getTheme("TextfieldText")end end}return setmetatable(a_a,bb)end -end; -project['objects']['Thread'] = function(...)local b=require("utils").getValueFromXML -return -function(c)local d;local _a="Thread"local aa;local ba -local ca=false -local da=function(_b,ab) -if(ab:sub(1,1)=="#")then -local bb=_b:getBaseFrame():getDeepObject(ab:sub(2,ab:len())) -if(bb~=nil)and(bb.internalObjetCall~=nil)then return(function() -bb:internalObjetCall()end)end else return _b:getBaseFrame():getVariable(ab)end;return _b end -d={name=c,getType=function(_b)return _a end,getZIndex=function(_b)return 1 end,getName=function(_b)return _b.name end,getBaseFrame=function(_b)if -(_b.parent~=nil)then return _b.parent:getBaseFrame()end -return _b end,setValuesByXMLData=function(_b,ab)local bb;if(b("thread",ab)~=nil)then -bb=da(_b,b("thread",ab))end -if(b("start",ab)~=nil)then if -(b("start",ab))and(bb~=nil)then _b:start(bb)end end;return _b end,start=function(_b,ab) -if( -ab==nil)then error("Function provided to thread is nil")end;aa=ab;ba=coroutine.create(aa)ca=true -local bb,cb=coroutine.resume(ba)if not(bb)then if(cb~="Terminated")then -error("Thread Error Occurred - "..cb)end end -_b.parent:addEvent("other_event",_b)return _b end,getStatus=function(_b,ab)if( -ba~=nil)then return coroutine.status(ba)end;return nil end,stop=function(_b,ab) -ca=false;_b.parent:removeEvent("other_event",_b)return _b end,eventHandler=function(_b,ab,bb,cb,db) -if -(ca)then -if(coroutine.status(ba)~="dead")then -local _c,ac=coroutine.resume(ba,ab,bb,cb,db)if not(_c)then if(ac~="Terminated")then -error("Thread Error Occurred - "..ac)end end else -ca=false end end end}d.__index=d;return d end -end; -project['objects']['Timer'] = function(...)local c=require("basaltEvent") -local d=require("utils").getValueFromXML -return -function(_a)local aa="Timer"local ba=0;local ca=0;local da=0;local _b;local ab=c()local bb=false -local cb=function(_c,ac,bc) -local cc=function(dc) -if(dc:sub(1,1)=="#")then -local _d=_c:getBaseFrame():getDeepObject(dc:sub(2,dc:len())) -if(_d~=nil)and(_d.internalObjetCall~=nil)then ac(_c,function() -_d:internalObjetCall()end)end else -ac(_c,_c:getBaseFrame():getVariable(dc))end end;if(type(bc)=="string")then cc(bc)elseif(type(bc)=="table")then -for dc,_d in pairs(bc)do cc(_d)end end;return _c end -local db={name=_a,getType=function(_c)return aa end,setValuesByXMLData=function(_c,ac) -if(d("time",ac)~=nil)then ba=d("time",ac)end;if(d("repeat",ac)~=nil)then ca=d("repeat",ac)end -if( -d("start",ac)~=nil)then if(d("start",ac))then _c:start()end end;if(d("onCall",ac)~=nil)then -cb(_c,_c.onCall,d("onCall",ac))end;return _c end,getBaseFrame=function(_c) -if( -_c.parent~=nil)then return _c.parent:getBaseFrame()end;return _c end,getZIndex=function(_c)return 1 end,getName=function(_c) -return _c.name end,setTime=function(_c,ac,bc)ba=ac or 0;ca=bc or 1;return _c end,start=function(_c)if(bb)then -os.cancelTimer(_b)end;da=ca;_b=os.startTimer(ba)bb=true -_c.parent:addEvent("other_event",_c)return _c end,isActive=function(_c)return bb end,cancel=function(_c)if( -_b~=nil)then os.cancelTimer(_b)end;bb=false -_c.parent:removeEvent("other_event",_c)return _c end,onCall=function(_c,ac) -ab:registerEvent("timed_event",ac)return _c end,eventHandler=function(_c,ac,bc) -if -ac=="timer"and bc==_b and bb then ab:sendEvent("timed_event",_c) -if(da>=1)then da=da-1;if(da>=1)then -_b=os.startTimer(ba)end elseif(da==-1)then _b=os.startTimer(ba)end end end}db.__index=db;return db end -end; -project['libraries']['basaltDraw'] = function(...)local d=require("tHex")local _a,aa=string.sub,string.rep -return -function(ba) -local ca=ba or term.current()local da;local _b,ab=ca.getSize()local bb={}local cb={}local db={}local _c={}local ac={}local bc={}local cc -local dc={}local function _d()cc=aa(" ",_b) -for n=0,15 do local a_a=2 ^n;local b_a=d[a_a]dc[a_a]=aa(b_a,_b)end end;_d() -local function ad()_d()local a_a=cc -local b_a=dc[colors.white]local c_a=dc[colors.black] -for currentY=1,ab do -bb[currentY]=_a( -bb[currentY]==nil and a_a or -bb[currentY]..a_a:sub(1,_b-bb[currentY]:len()),1,_b) -db[currentY]=_a(db[currentY]==nil and b_a or db[currentY]..b_a:sub(1,_b- -db[currentY]:len()),1,_b) -cb[currentY]=_a(cb[currentY]==nil and c_a or cb[currentY]..c_a:sub(1,_b- -cb[currentY]:len()),1,_b)end end;ad() -local function bd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if -(a_a+c_a:len()>0)and(a_a<=_b)then local d_a=bb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1 -local caa=_b-a_a+1;c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -bb[b_a]=_aa end end end -local function cd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=cb[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then -c_a=_a(c_a,1 -a_a+1,_b-a_a+1)elseif(aaa>_b)then c_a=_a(c_a,1,_b-a_a+1)end -if(a_a>1)then _aa=_a(d_a,1,a_a-1)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -cb[b_a]=_aa end end end -local function dd(a_a,b_a,c_a) -if(b_a>=1)and(b_a<=ab)then -if(a_a+c_a:len()>0)and(a_a<=_b)then -local d_a=db[b_a]local _aa;local aaa=a_a+#c_a-1 -if(a_a<1)then local baa=1 -a_a+1;local caa=_b-a_a+1 -c_a=_a(c_a,baa,caa)elseif(aaa>_b)then local baa=_b-a_a+1;c_a=_a(c_a,1,baa)end -if(a_a>1)then local baa=a_a-1;_aa=_a(d_a,1,baa)..c_a else _aa=c_a end;if aaa<_b then _aa=_aa.._a(d_a,aaa+1,_b)end -db[b_a]=_aa end end end -local __a={setSize=function(a_a,b_a)_b,ab=a_a,b_a;ad()end,setMirror=function(a_a)da=a_a end,setBG=function(a_a,b_a,c_a)cd(a_a,b_a,c_a)end,setText=function(a_a,b_a,c_a) -bd(a_a,b_a,c_a)end,setFG=function(a_a,b_a,c_a)dd(a_a,b_a,c_a)end,drawBackgroundBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -cd(a_a,b_a+ (n-1),aa(d[_aa],c_a))end end,drawForegroundBox=function(a_a,b_a,c_a,d_a,_aa) -for n=1,d_a do dd(a_a,b_a+ -(n-1),aa(d[_aa],c_a))end end,drawTextBox=function(a_a,b_a,c_a,d_a,_aa)for n=1,d_a do -bd(a_a,b_a+ (n-1),aa(_aa,c_a))end end,writeText=function(a_a,b_a,c_a,d_a,_aa) -if(c_a~=nil)then -bd(a_a,b_a,c_a)if(d_a~=nil)and(d_a~=false)then -cd(a_a,b_a,aa(d[d_a],c_a:len()))end;if(_aa~=nil)and(_aa~=false)then -dd(a_a,b_a,aa(d[_aa],c_a:len()))end end end,update=function() -local a_a,b_a=ca.getCursorPos()local c_a=false -if(ca.getCursorBlink~=nil)then c_a=ca.getCursorBlink()end;ca.setCursorBlink(false)if(da~=nil)then -da.setCursorBlink(false)end -for n=1,ab do ca.setCursorPos(1,n) -ca.blit(bb[n],db[n],cb[n])if(da~=nil)then da.setCursorPos(1,n) -da.blit(bb[n],db[n],cb[n])end end;ca.setBackgroundColor(colors.black) -ca.setCursorBlink(c_a)ca.setCursorPos(a_a,b_a) -if(da~=nil)then -da.setBackgroundColor(colors.black)da.setCursorBlink(c_a)da.setCursorPos(a_a,b_a)end end,setTerm=function(a_a) -ca=a_a end}return __a end -end; -project['libraries']['basaltEvent'] = function(...) -return -function()local a={}local b={} -local c={registerEvent=function(d,_a,aa)if(a[_a]==nil)then a[_a]={}b[_a]=1 end -a[_a][b[_a] ]=aa;b[_a]=b[_a]+1;return b[_a]-1 end,removeEvent=function(d,_a,aa)a[_a][aa[_a] ]= -nil end,sendEvent=function(d,_a,...)local aa -if(a[_a]~=nil)then for ba,ca in pairs(a[_a])do local da=ca(...)if(da== -false)then aa=da end end end;return aa end}c.__index=c;return c end -end; -project['libraries']['basaltLogs'] = function(...)local _a=""local aa="basaltLog.txt"local ba="Debug" -fs.delete(_a~=""and _a.."/"..aa or aa) -local ca={__call=function(da,_b,ab)if(_b==nil)then return end -local bb=_a~=""and _a.."/"..aa or aa -local cb=fs.open(bb,fs.exists(bb)and"a"or"w") -cb.writeLine("[Basalt][".. (ab and ab or ba).."]: "..tostring(_b))cb.close()end}return setmetatable({},ca) -end; -project['libraries']['basaltMon'] = function(...) -local aa={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local ba,ca,da,_b=type,string.len,string.rep,string.sub -return -function(ab)local bb={} -for _aa,aaa in pairs(ab)do -bb[_aa]={} -for baa,caa in pairs(aaa)do local daa=peripheral.wrap(caa)if(daa==nil)then -error("Unable to find monitor "..caa)end;bb[_aa][baa]=daa -bb[_aa][baa].name=caa end end;local cb,db,_c,ac,bc,cc,dc,_d=1,1,1,1,0,0,0,0;local ad,bd=false,1 -local cd,dd=colors.white,colors.black -local function __a()local _aa,aaa=0,0 -for baa,caa in pairs(bb)do local daa,_ba=0,0 -for aba,bba in pairs(caa)do local cba,dba=bba.getSize() -daa=daa+cba;_ba=dba>_ba and dba or _ba end;_aa=_aa>daa and _aa or daa;aaa=aaa+_ba end;dc,_d=_aa,aaa end;__a() -local function a_a()local _aa=0;local aaa,baa=0,0 -for caa,daa in pairs(bb)do local _ba=0;local aba=0 -for bba,cba in pairs(daa)do -local dba,_ca=cba.getSize()if(cb-_ba>=1)and(cb-_ba<=dba)then aaa=bba end;cba.setCursorPos( -cb-_ba,db-_aa)_ba=_ba+dba -if(aba<_ca)then aba=_ca end end;if(db-_aa>=1)and(db-_aa<=aba)then baa=caa end -_aa=_aa+aba end;_c,ac=aaa,baa end;a_a() -local function b_a(_aa,...)local aaa={...}return -function()for baa,caa in pairs(bb)do for daa,_ba in pairs(caa)do -_ba[_aa](table.unpack(aaa))end end end end -local function c_a()b_a("setCursorBlink",false)() -if not(ad)then return end;if(bb[ac]==nil)then return end;local _aa=bb[ac][_c] -if(_aa==nil)then return end;_aa.setCursorBlink(ad)end -local function d_a(_aa,aaa,baa)if(bb[ac]==nil)then return end;local caa=bb[ac][_c] -if(caa==nil)then return end;caa.blit(_aa,aaa,baa)local daa,_ba=caa.getSize() -if -(ca(_aa)+cb>daa)then local aba=bb[ac][_c+1]if(aba~=nil)then aba.blit(_aa,aaa,baa)_c=_c+1;cb=cb+ -ca(_aa)end end;a_a()end -return -{clear=b_a("clear"),setCursorBlink=function(_aa)ad=_aa;c_a()end,getCursorBlink=function()return ad end,getCursorPos=function()return cb,db end,setCursorPos=function(_aa,aaa) -cb,db=_aa,aaa;a_a()c_a()end,setTextScale=function(_aa) -b_a("setTextScale",_aa)()__a()a_a()bd=_aa end,getTextScale=function()return bd end,blit=function(_aa,aaa,baa) -d_a(_aa,aaa,baa)end,write=function(_aa)_aa=tostring(_aa)local aaa=ca(_aa) -d_a(_aa,da(aa[cd],aaa),da(aa[dd],aaa))end,getSize=function()return dc,_d end,setBackgroundColor=function(_aa) -b_a("setBackgroundColor",_aa)()dd=_aa end,setTextColor=function(_aa) -b_a("setTextColor",_aa)()cd=_aa end,calculateClick=function(_aa,aaa,baa)local caa=0 -for daa,_ba in pairs(bb)do local aba=0;local bba=0 -for cba,dba in pairs(_ba)do -local _ca,aca=dba.getSize()if(dba.name==_aa)then return aaa+aba,baa+caa end -aba=aba+_ca;if(aca>bba)then bba=aca end end;caa=caa+bba end;return aaa,baa end}end -end; -project['libraries']['bigfont'] = function(...)local ba=require("tHex") -local ca={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{"000110000110110000110010101000000010000000100101","000000110110000000000010101000000010000000100101","000000000000000000000000000000000000000000000000","100010110100000010000110110000010100000100000110","000000110000000010110110000110000000000000110000","000000000000000000000000000000000000000000000000","000000110110000010000000100000100000000000000010","000000000110110100010000000010000000000000000100","000000000000000000000000000000000000000000000000","010000000000100110000000000000000000000110010000","000000000000000000000000000010000000010110000000","000000000000000000000000000000000000000000000000","011110110000000100100010110000000100000000000000","000000000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110000110110000000000000000000010100100010000000","000010000000000000110110000000000100010010000000","000000000000000000000000000000000000000000000000","010110010110100110110110010000000100000110110110","000000000000000000000110000000000110000000000000","000000000000000000000000000000000000000000000000","010100010110110000000000000000110000000010000000","110110000000000000110000110110100000000010000000","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","100100100100100100100100100100100100100100100100","000000110100110110000010000011110000000000011000","000000000100000000000010000011000110000000001000","000000000000000000000000000000000000000000000000","010000100100000000000000000100000000010010110000","000000000000000000000000000000110110110110110000","000000000000000000000000000000000000000000000000","110110110110110110000000110110110110110110110110","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","000000000000110110000110010000000000000000010010","000010000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110110110110000000000000","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110000000000000000010000","000000000000000000000000100000000000000110000110","000000000000000000000000000000000000000000000000"}}local da={}local _b={} -do local cb=0;local db=#ca[1]local _c=#ca[1][1] -for i=1,db,3 do -for j=1,_c,3 do -local ac=string.char(cb)local bc={}bc[1]=ca[1][i]:sub(j,j+2) -bc[2]=ca[1][i+1]:sub(j,j+2)bc[3]=ca[1][i+2]:sub(j,j+2)local cc={}cc[1]=ca[2][i]:sub(j, -j+2)cc[2]=ca[2][i+1]:sub(j,j+2)cc[3]=ca[2][ -i+2]:sub(j,j+2)_b[ac]={bc,cc}cb=cb+1 end end;da[1]=_b end -local function ab(cb,db)local _c={["0"]="1",["1"]="0"}if cb<=#da then return true end -for f=#da+1,cb do local ac={}local bc=da[ -f-1] -for char=0,255 do local cc=string.char(char)local dc={}local _d={} -local ad=bc[cc][1]local bd=bc[cc][2] -for i=1,#ad do local cd,dd,__a,a_a,b_a,c_a={},{},{},{},{},{} -for j=1,#ad[1]do -local d_a=_b[ad[i]:sub(j,j)][1]table.insert(cd,d_a[1])table.insert(dd,d_a[2]) -table.insert(__a,d_a[3])local _aa=_b[ad[i]:sub(j,j)][2] -if -bd[i]:sub(j,j)=="1"then -table.insert(a_a,(_aa[1]:gsub("[01]",_c))) -table.insert(b_a,(_aa[2]:gsub("[01]",_c))) -table.insert(c_a,(_aa[3]:gsub("[01]",_c)))else table.insert(a_a,_aa[1]) -table.insert(b_a,_aa[2])table.insert(c_a,_aa[3])end end;table.insert(dc,table.concat(cd)) -table.insert(dc,table.concat(dd))table.insert(dc,table.concat(__a)) -table.insert(_d,table.concat(a_a))table.insert(_d,table.concat(b_a)) -table.insert(_d,table.concat(c_a))end;ac[cc]={dc,_d}if db then db="Font"..f.."Yeld"..char -os.queueEvent(db)os.pullEvent(db)end end;da[f]=ac end;return true end -local function bb(cb,db,_c,ac,bc) -if not type(db)=="string"then error("Not a String",3)end -local cc=type(_c)=="string"and _c:sub(1,1)or ba[_c]or -error("Wrong Front Color",3) -local dc=type(ac)=="string"and ac:sub(1,1)or ba[ac]or -error("Wrong Back Color",3)if(da[cb]==nil)then ab(3,false)end;local _d=da[cb]or -error("Wrong font size selected",3)if db==""then -return{{""},{""},{""}}end;local ad={} -for c_a in db:gmatch('.')do table.insert(ad,c_a)end;local bd={}local cd=#_d[ad[1] ][1] -for nLine=1,cd do local c_a={} -for i=1,#ad do c_a[i]=_d[ad[i] ]and -_d[ad[i] ][1][nLine]or""end;bd[nLine]=table.concat(c_a)end;local dd={}local __a={}local a_a={["0"]=cc,["1"]=dc}local b_a={["0"]=dc,["1"]=cc} -for nLine=1,cd do -local c_a={}local d_a={} -for i=1,#ad do -local _aa=_d[ad[i] ]and _d[ad[i] ][2][nLine]or"" -c_a[i]=_aa:gsub("[01]", -bc and{["0"]=_c:sub(i,i),["1"]=ac:sub(i,i)}or a_a) -d_a[i]=_aa:gsub("[01]", -bc and{["0"]=ac:sub(i,i),["1"]=_c:sub(i,i)}or b_a)end;dd[nLine]=table.concat(c_a) -__a[nLine]=table.concat(d_a)end;return{bd,dd,__a}end;return bb -end; -project['libraries']['layout'] = function(...) -local function c(_a)local aa={}aa.___value=nil;aa.___name=_a;aa.___children={}aa.___props={}function aa:value()return -self.___value end -function aa:setValue(ba)self.___value=ba end;function aa:name()return self.___name end -function aa:setName(ba)self.___name=ba end;function aa:children()return self.___children end;function aa:numChildren()return -#self.___children end -function aa:addChild(ba) -if self[ba:name()]~=nil then -if -type(self[ba:name()].name)=="function"then local ca={} -table.insert(ca,self[ba:name()])self[ba:name()]=ca end;table.insert(self[ba:name()],ba)else -self[ba:name()]=ba end;table.insert(self.___children,ba)end;function aa:properties()return self.___props end;function aa:numProperties() -return#self.___props end -function aa:addProperty(ba,ca)local da="@"..ba -if self[da]~=nil then if -type(self[da])=="string"then local _b={}table.insert(_b,self[da]) -self[da]=_b end -table.insert(self[da],ca)else self[da]=ca end -table.insert(self.___props,{name=ba,value=self[ba]})end;return aa end;local d={} -function d:ToXmlString(_a)_a=string.gsub(_a,"&","&") -_a=string.gsub(_a,"<","<")_a=string.gsub(_a,">",">") -_a=string.gsub(_a,"\"",""") -_a=string.gsub(_a,"([^%w%&%;%p%\t% ])",function(aa) -return string.format("&#x%X;",string.byte(aa))end)return _a end -function d:FromXmlString(_a) -_a=string.gsub(_a,"&#x([%x]+)%;",function(aa) -return string.char(tonumber(aa,16))end) -_a=string.gsub(_a,"&#([0-9]+)%;",function(aa)return string.char(tonumber(aa,10))end)_a=string.gsub(_a,""","\"") -_a=string.gsub(_a,"'","'")_a=string.gsub(_a,">",">") -_a=string.gsub(_a,"<","<")_a=string.gsub(_a,"&","&")return _a end;function d:ParseArgs(_a,aa) -string.gsub(aa,"(%w+)=([\"'])(.-)%2",function(ba,ca,da) -_a:addProperty(ba,self:FromXmlString(da))end)end -function d:ParseXmlText(_a) -local aa={}local ba=c()table.insert(aa,ba)local ca,da,_b,ab,bb;local cb,db=1,1 -while true do -ca,db,da,_b,ab,bb=string.find(_a,"<(%/?)([%w_:]+)(.-)(%/?)>",cb)if not ca then break end;local ac=string.sub(_a,cb,ca-1) -if not -string.find(ac,"^%s*$")then -local bc=(ba:value()or"")..self:FromXmlString(ac)aa[#aa]:setValue(bc)end -if bb=="/"then local bc=c(_b)self:ParseArgs(bc,ab)ba:addChild(bc)elseif -da==""then local bc=c(_b)self:ParseArgs(bc,ab)table.insert(aa,bc) -ba=bc else local bc=table.remove(aa)ba=aa[#aa]if#aa<1 then -error("XmlParser: nothing to close with ".._b)end;if bc:name()~=_b then -error("XmlParser: trying to close "..bc.name.. -" with ".._b)end;ba:addChild(bc)end;cb=db+1 end;local _c=string.sub(_a,cb)if#aa>1 then -error("XmlParser: unclosed "..aa[#aa]:name())end;return ba end -function d:loadFile(_a,aa)if not aa then aa=system.ResourceDirectory end -local ba=system.pathForFile(_a,aa)local ca,da=io.open(ba,"r") -if ca and not da then local _b=ca:read("*a") -io.close(ca)return self:ParseXmlText(_b),nil else print(da)return nil end end;return d -end; -project['libraries']['module'] = function(...)return -function(a)local b,c=pcall(require,a)return b and c or nil end -end; -project['libraries']['process'] = function(...)local d={}local _a={}local aa=0 -function _a:new(ba,ca,...)local da={...} -local _b=setmetatable({path=ba},{__index=self})_b.window=ca;_b.processId=aa -if(type(ba)=="string")then -_b.coroutine=coroutine.create(function() -shell.execute(ba,table.unpack(da))end)elseif(type(ba)=="function")then -_b.coroutine=coroutine.create(function() -ba(table.unpack(da))end)else return end;d[aa]=_b;aa=aa+1;return _b end -function _a:resume(ba,...)term.redirect(self.window) -if(self.filter~=nil)then if -(ba~=self.filter)then return end;self.filter=nil end;local ca,da=coroutine.resume(self.coroutine,ba,...)if ca then -self.filter=da else error(da)end end -function _a:isDead() -if(self.coroutine~=nil)then -if -(coroutine.status(self.coroutine)=="dead")then table.remove(d,self.processId)return true end else return true end;return false end -function _a:getStatus()if(self.coroutine~=nil)then -return coroutine.status(self.coroutine)end;return nil end -function _a:start()coroutine.resume(self.coroutine)end;return _a -end; -project['libraries']['tHex'] = function(...) -return -{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"} -end; -project['libraries']['utils'] = function(...) -local b=function(c,d)if d==nil then d="%s"end;local _a={}for aa in string.gmatch(c,"([^"..d.."]+)")do -table.insert(_a,aa)end;return _a end -return -{getTextHorizontalAlign=function(c,d,_a,aa)c=string.sub(c,1,d)local ba=d-string.len(c) -if(_a=="right")then c=string.rep( -aa or" ",ba)..c elseif(_a=="center")then -c=string.rep(aa or" ",math.floor( -ba/2))..c.. -string.rep(aa or" ",math.floor(ba/2)) -c=c.. (string.len(c)aba[x])then table.insert(aba,x,_cc)break end else -table.insert(aba,_cc)end end;if(#aba<=0)then table.insert(aba,_cc)end;_ba[_cc]={}end;dbc.parent=bba;if(dbc.init~=nil)then dbc:init()end -table.insert(_ba[_cc],dbc)return dbc end -local function b_c(dbc,_cc) -for acc,bcc in pairs(cba)do -for ccc,dcc in pairs(bcc)do -for _dc,adc in pairs(dcc)do -if(adc==_cc)then -table.remove(cba[acc][ccc],_dc)if(dbc.parent~=nil)then if(__a(cba[acc])<=0)then -dbc.parent:removeEvent(acc,dbc)end end end end end end end -local function c_c(dbc,_cc) -for acc,bcc in pairs(_ba)do -for ccc,dcc in pairs(bcc)do -if(type(_cc)=="string")then -if(dcc:getName()==_cc)then -table.remove(_ba[acc],ccc)b_c(bba,dcc)dbc:updateDraw()return true end else if(dcc==_cc)then table.remove(_ba[acc],ccc)b_c(bba,dcc) -dbc:updateDraw()return true end end end end;return false end;local function d_c(dbc,_cc,acc) -for bcc,ccc in pairs(cba[_cc])do for dcc,_dc in pairs(ccc)do -if(_dc:getName()==acc)then return _dc end end end end -local function _ac(dbc,_cc,acc) -local bcc=acc:getZIndex()if(cba[_cc]==nil)then cba[_cc]={}end;if(dba[_cc]==nil)then -dba[_cc]={}end -if(d_c(dbc,_cc,acc.name)~=nil)then return nil end -if(dbc.parent~=nil)then dbc.parent:addEvent(_cc,dbc)end;cbb[_cc]=true -if(cba[_cc][bcc]==nil)then -for x=1,#dba[_cc]+1 do -if -(dba[_cc][x]~=nil)then if(bcc==dba[_cc][x])then break end;if(bcc>dba[_cc][x])then -table.insert(dba[_cc],x,bcc)break end else -table.insert(dba[_cc],bcc)end end -if(#dba[_cc]<=0)then table.insert(dba[_cc],bcc)end;cba[_cc][bcc]={}end;table.insert(cba[_cc][bcc],acc)return acc end -local function aac(dbc,_cc,acc) -if(cba[_cc]~=nil)then -for bcc,ccc in pairs(cba[_cc])do -for dcc,_dc in pairs(ccc)do -if(_dc==acc)then -table.remove(cba[_cc][bcc],dcc) -if(#cba[_cc][bcc]<=0)then cba[_cc][bcc]=nil -if(dbc.parent~=nil)then if( -__a(cba[_cc])<=0)then cbb[_cc]=false -dbc.parent:removeEvent(_cc,dbc)end end end;return true end end end end;return false end -local function bac(dbc)local _cc,acc=pcall(load("return "..dbc)) -if not(_cc)then error(dbc.. -" is not a valid dynamic code")end;return load("return "..dbc)()end -local function cac(dbc,_cc,acc)for bcc,ccc in pairs(bca)do -if(ccc[2]==acc)and(ccc[4]==_cc)then return ccc end end;cca=cca+1 -bca[cca]={0,acc,{},_cc,cca}return bca[cca]end -local function dac(dbc,_cc)local acc={}local bcc={}for ccc in _cc:gmatch("%a+%.x")do local dcc=ccc:gsub("%.x","") -if -(dcc~="self")and(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%w+%.y")do local dcc=ccc:gsub("%.y","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end;for ccc in _cc:gmatch("%a+%.w")do local dcc=ccc:gsub("%.w","") -if(dcc~="self")and -(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%a+%.h")do local dcc=ccc:gsub("%.h","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end -for ccc,dcc in pairs(acc)do bcc[dcc]=ddb(dcc)if(bcc[dcc]==nil)then -error("Dynamic Values - unable to find object "..dcc)end end;bcc["self"]=dbc;bcc["parent"]=dbc:getParent()return bcc end -local function _bc(dbc,_cc)local acc=dbc;for bcc in dbc:gmatch("%w+%.x")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.x","")]:getX())end;for bcc in dbc:gmatch("%w+%.y")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.y","")]:getY())end;for bcc in dbc:gmatch("%w+%.w")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.w","")]:getWidth())end;for bcc in dbc:gmatch("%w+%.h")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.h","")]:getHeight())end;return acc end -local function abc(dbc) -if(#bca>0)then -for n=1,cca do -if(bca[n]~=nil)then local _cc;if(#bca[n][3]<=0)then -bca[n][3]=dac(bca[n][4],bca[n][2])end -_cc=_bc(bca[n][2],bca[n][3])bca[n][1]=bac(_cc)if(bca[n][4]:getType()=="Frame")then -bca[n][4]:recalculateDynamicValues()end end end -for _cc,acc in pairs(aba)do if(_ba[acc]~=nil)then -for bcc,ccc in pairs(_ba[acc])do if(ccc.eventHandler~=nil)then -ccc:eventHandler("dynamicValueEvent",dbc)end end end end end end;local function bbc(dbc)return bca[dbc][1]end -local function cbc(dbc) -for _cc,acc in pairs(_ba)do -for bcc,ccc in pairs(acc)do -if -(ccc.getHeight~=nil)and(ccc.getY~=nil)then -local dcc,_dc=ccc:getHeight(),ccc:getY()if(dcc+_dc-dbc:getHeight()>b_b)then -b_b=c_a(dcc+_dc-dbc:getHeight(),0)end end end end end -bba={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",addEvent=_ac,removeEvent=aac,removeEvents=b_c,getEvent=d_c,newDynamicValue=cac,recalculateDynamicValues=abc,getDynamicValue=bbc,getType=function(dbc)return daa end,setFocusedObject=function(dbc,_cc) -if(dab~=_cc)then if -(dab~=nil)then dab:loseFocusHandler()end;if(_cc~=nil)then -_cc:getFocusHandler()end;dab=_cc end;return dbc end,getVariable=function(dbc,_cc)return -baa.getVariable(_cc)end,setSize=function(dbc,_cc,acc,bcc) -caa.setSize(dbc,_cc,acc,bcc)if(dbc.parent==nil)then dbb=cc(dca)end -for ccc,dcc in pairs(aba)do if(_ba[dcc]~=nil)then -for _dc,adc in -pairs(_ba[dcc])do if(adc.eventHandler~=nil)then -adc:eventHandler("basalt_resize",adc,dbc)end end end end;dbc:recalculateDynamicValues()_bb=false;return dbc end,setTheme=function(dbc,_cc,acc) -if( -type(_cc)=="table")then aca=_cc elseif(type(_cc)=="string")then aca[_cc]=acc end;dbc:updateDraw()return dbc end,getTheme=function(dbc,_cc) -return -aca[_cc]or(dbc.parent~=nil and dbc.parent:getTheme(_cc)or -baa.getTheme(_cc))end,setPosition=function(dbc,_cc,acc,bcc) -caa.setPosition(dbc,_cc,acc,bcc) -for ccc,dcc in pairs(aba)do if(_ba[dcc]~=nil)then -for _dc,adc in pairs(_ba[dcc])do if(adc.eventHandler~=nil)then -adc:eventHandler("basalt_reposition",adc,dbc)end end end end;dbc:recalculateDynamicValues()return dbc end,getBasaltInstance=function(dbc)return -baa end,setOffset=function(dbc,_cc,acc) -dcb=_cc~=nil and -math.floor(_cc<0 and math.abs(_cc)or-_cc)or dcb -_db=acc~=nil and -math.floor(acc<0 and math.abs(acc)or-acc)or _db;dbc:updateDraw()return dbc end,getOffsetInternal=function(dbc)return -dcb,_db end,getOffset=function(dbc) -return dcb<0 and math.abs(dcb)or-dcb, -_db<0 and math.abs(_db)or-_db end,removeFocusedObject=function(dbc)if(dab~=nil)then -dab:loseFocusHandler()end;dab=nil;return dbc end,getFocusedObject=function(dbc) -return dab end,setCursor=function(dbc,_cc,acc,bcc,ccc) -if(dbc.parent~=nil)then local dcc,_dc=dbc:getAnchorPosition() -dbc.parent:setCursor( -_cc or false,(acc or 0)+dcc-1,(bcc or 0)+_dc-1,ccc or ccb)else -local dcc,_dc=dbc:getAbsolutePosition(dbc:getAnchorPosition(dbc:getX(),dbc:getY(),true))_cb=_cc or false;if(acc~=nil)then acb=dcc+acc-1 end;if(bcc~=nil)then bcb=_dc+ -bcc-1 end;ccb=ccc or ccb;if(_cb)then -dca.setTextColor(ccb)dca.setCursorPos(acb,bcb)dca.setCursorBlink(_cb)else -dca.setCursorBlink(false)end end;return dbc end,setMovable=function(dbc,_cc) -if( -dbc.parent~=nil)then aab=_cc or not aab -dbc.parent:addEvent("mouse_click",dbc)cbb["mouse_click"]=true -dbc.parent:addEvent("mouse_up",dbc)cbb["mouse_up"]=true -dbc.parent:addEvent("mouse_drag",dbc)cbb["mouse_drag"]=true end;return dbc end,setScrollable=function(dbc,_cc)a_b=( -_cc or _cc==nil)and true or false -if( -dbc.parent~=nil)then dbc.parent:addEvent("mouse_scroll",dbc)end;cbb["mouse_scroll"]=true;return dbc end,setScrollAmount=function(dbc,_cc)b_b= -_cc or b_b;abb=false;return dbc end,getScrollAmount=function(dbc)return abb and cbc(dbc)or -b_b end,show=function(dbc)caa.show(dbc) -if(dbc.parent== -nil)then baa.setActiveFrame(dbc)if(ada)and not(bda)then -baa.setMonitorFrame(_da,dbc)elseif(bda)then baa.setMonitorFrame(dbc:getName(),dbc,_da)else -baa.setMainFrame(dbc)end end;return dbc end,hide=function(dbc) -caa.hide(dbc) -if(dbc.parent==nil)then if(activeFrame==dbc)then activeFrame=nil end -if(ada)and -not(bda)then if(baa.getMonitorFrame(_da)==dbc)then -baa.setActiveFrame(nil)end elseif(bda)then -if( -baa.getMonitorFrame(dbc:getName())==dbc)then baa.setActiveFrame(nil)end else -if(baa.getMainFrame()==dbc)then baa.setMainFrame(nil)end end end;return dbc end,addLayout=function(dbc,_cc) -if( -_cc~=nil)then -if(fs.exists(_cc))then local acc=fs.open(_cc,"r") -local bcc=_d:ParseXmlText(acc.readAll())acc.close()adb={}dbc:setValuesByXMLData(bcc)end end;return dbc end,getLastLayout=function(dbc)return -adb end,addLayoutFromString=function(dbc,_cc)if(_cc~=nil)then local acc=_d:ParseXmlText(_cc) -dbc:setValuesByXMLData(acc)end;return dbc end,setValuesByXMLData=function(dbc,_cc) -caa.setValuesByXMLData(dbc,_cc)if(dd("movable",_cc)~=nil)then if(dd("movable",_cc))then -dbc:setMovable(true)end end;if( -dd("scrollable",_cc)~=nil)then -if(dd("scrollable",_cc))then dbc:setScrollable(true)end end;if -(dd("monitor",_cc)~=nil)then -dbc:setMonitor(dd("monitor",_cc)):show()end;if(dd("mirror",_cc)~=nil)then -dbc:setMirror(dd("mirror",_cc))end -if(dd("bar",_cc)~=nil)then if(dd("bar",_cc))then -dbc:showBar(true)else dbc:showBar(false)end end -if(dd("barText",_cc)~=nil)then dbc.barText=dd("barText",_cc)end;if(dd("barBG",_cc)~=nil)then -dbc.barBackground=colors[dd("barBG",_cc)]end;if(dd("barFG",_cc)~=nil)then -dbc.barTextcolor=colors[dd("barFG",_cc)]end;if(dd("barAlign",_cc)~=nil)then -dbc.barTextAlign=dd("barAlign",_cc)end;if(dd("layout",_cc)~=nil)then -dbc:addLayout(dd("layout",_cc))end;if(dd("xOffset",_cc)~=nil)then -dbc:setOffset(dd("xOffset",_cc),_db)end;if(dd("yOffset",_cc)~=nil)then -dbc:setOffset(_db,dd("yOffset",_cc))end;if(dd("scrollAmount",_cc)~=nil)then -dbc:setScrollAmount(dd("scrollAmount",_cc))end;local acc=_cc:children() -for bcc,ccc in -pairs(acc)do if(ccc.___name~="animation")then -local dcc=ccc.___name:gsub("^%l",string.upper) -if(bc[dcc]~=nil)then cdb(ccc,dbc["add"..dcc],dbc)end end end;cdb(_cc["frame"],dbc.addFrame,dbc) -cdb(_cc["animation"],dbc.addAnimation,dbc)return dbc end,showBar=function(dbc,_cc)dbc.barActive= -_cc or not dbc.barActive;dbc:updateDraw() -return dbc end,setBar=function(dbc,_cc,acc,bcc)dbc.barText=_cc or""dbc.barBackground= -acc or dbc.barBackground -dbc.barTextcolor=bcc or dbc.barTextcolor;dbc:updateDraw()return dbc end,setBarTextAlign=function(dbc,_cc)dbc.barTextAlign= -_cc or"left"dbc:updateDraw()return dbc end,setMirror=function(dbc,_cc)if( -dbc.parent~=nil)then -error("Frame has to be a base frame in order to attach a mirror.")end;_ab=_cc;if(mirror~=nil)then -dbb.setMirror(mirror)end;c_b=true;return dbc end,removeMirror=function(dbc)mirror= -nil;c_b=false;dbb.setMirror(nil)return dbc end,setMonitorScale=function(dbc,_cc)if -(ada)then dca.setTextScale(_cc)end;return dbc end,setMonitor=function(dbc,_cc,acc) -if( -_cc~=nil)and(_cc~=false)then -if(type(_cc)=="string")then -if( -peripheral.getType(_cc)=="monitor")then dca=peripheral.wrap(_cc)cda=true end -if(dbc.parent~=nil)then dbc.parent:removeObject(dbc)end;ada=true;baa.setMonitorFrame(_cc,dbc)elseif(type(_cc)=="table")then -dca=ad(_cc)cda=true;ada=true;bda=true -baa.setMonitorFrame(dbc:getName(),dbc,true)end else dca=parentTerminal;ada=false;bda=false -if(type(_da)=="string")then -if( -baa.getMonitorFrame(_da)==dbc)then baa.setMonitorFrame(_da,nil)end else -if(baa.getMonitorFrame(dbc:getName())==dbc)then baa.setMonitorFrame(dbc:getName(), -nil)end end end;if(acc~=nil)then dca.setTextScale(acc)end;dbb=cc(dca) -dbc:setSize(dca.getSize())_bb=true;_da=_cc or nil;dbc:updateDraw()return dbc end,loseFocusHandler=function(dbc) -caa.loseFocusHandler(dbc)if(dab~=nil)then dab:loseFocusHandler()dab=nil end end,getFocusHandler=function(dbc) -caa.getFocusHandler(dbc) -if(dbc.parent~=nil)then -if(aab)then dbc.parent:removeEvents(dbc) -dbc.parent:removeObject(dbc)dbc.parent:addObject(dbc)for _cc,acc in pairs(cbb)do if(acc)then -dbc.parent:addEvent(_cc,dbc)end end -dbc:updateDraw()end end;if(dab~=nil)then dab:getFocusHandler()end end,eventHandler=function(dbc,_cc,...) -caa.eventHandler(dbc,_cc,...) -if(cba["other_event"]~=nil)then -for acc,bcc in ipairs(dba["other_event"])do -if( -cba["other_event"][bcc]~=nil)then for ccc,dcc in cd(cba["other_event"][bcc])do -if -(dcc.eventHandler~=nil)then if(dcc:eventHandler(_cc,...))then return true end end end end end end;if(_bb)and not(ada)then -if(dbc.parent==nil)then if(_cc=="term_resize")then -dbc:setSize(dca.getSize())_bb=true end end end -if(ada)then -if(_bb)then -if -(_cc=="monitor_resize")then -if(type(_da)=="string")then dbc:setSize(dca.getSize())elseif( -type(_da)=="table")then -for acc,bcc in pairs(_da)do for ccc,dcc in pairs(bcc)do if(p1 ==dcc)then -dbc:setSize(dca.getSize())end end end end;_bb=true;dbc:updateDraw()end end -if(_cc=="peripheral")and(p1 ==_da)then if -(peripheral.getType(_da)=="monitor")then cda=true;dca=peripheral.wrap(_da)dbb=cc(dca) -dbc:updateDraw()end end -if(_cc=="peripheral_detach")and(p1 ==_da)then cda=false end end -if(c_b)then if(peripheral.getType(_ab)=="monitor")then d_b=true -dbb.setMirror(peripheral.wrap(_ab))end;if(_cc=="peripheral_detach")and -(p1 ==_ab)then cda=false end -if -(_cc=="monitor_touch")and(_ab==p1)then dbc:mouseHandler(1,p2,p3,true)end end -if(_cc=="terminate")and(dbc.parent==nil)then baa.stop()end end,mouseHandler=function(dbc,_cc,acc,bcc,ccc,dcc) -if -(bda)then if(dca.calculateClick~=nil)then -acc,bcc=dca.calculateClick(dcc,acc,bcc)end end -if(caa.mouseHandler(dbc,_cc,acc,bcc))then -if(cba["mouse_click"]~=nil)then -dbc:setCursor(false) -for _dc,adc in ipairs(dba["mouse_click"])do -if -(cba["mouse_click"][adc]~=nil)then for bdc,cdc in cd(cba["mouse_click"][adc])do -if(cdc.mouseHandler~=nil)then if -(cdc:mouseHandler(_cc,acc,bcc))then return true end end end end end end -if(aab)then -local _dc,adc=dbc:getAbsolutePosition(dbc:getAnchorPosition())if -(acc>=_dc)and(acc<=_dc+dbc:getWidth()-1)and(bcc==adc)then bab=true;dda=_dc-acc -__b=yOff and 1 or 0 end end;dbc:removeFocusedObject()return true end;return false end,mouseUpHandler=function(dbc,_cc,acc,bcc)if -(bab)then bab=false end -if(caa.mouseUpHandler(dbc,_cc,acc,bcc))then -if -(cba["mouse_up"]~=nil)then -for ccc,dcc in ipairs(dba["mouse_up"])do -if(cba["mouse_up"][dcc]~=nil)then -for _dc,adc in -cd(cba["mouse_up"][dcc])do if(adc.mouseUpHandler~=nil)then -if(adc:mouseUpHandler(_cc,acc,bcc))then return true end end end end end end;return true end;return false end,scrollHandler=function(dbc,_cc,acc,bcc) -if -(caa.scrollHandler(dbc,_cc,acc,bcc))then -if(cba["mouse_scroll"]~=nil)then -for dcc,_dc in pairs(dba["mouse_scroll"])do -if( -cba["mouse_scroll"][_dc]~=nil)then -for adc,bdc in cd(cba["mouse_scroll"][_dc])do if(bdc.scrollHandler~= -nil)then -if(bdc:scrollHandler(_cc,acc,bcc))then return true end end end end end end;local ccc=_db -if(a_b)then cbc(dbc)if(_cc>0)or(_cc<0)then -_db=c_a(b_a(_db-_cc,0),-b_b)dbc:updateDraw()end end;dbc:removeFocusedObject()if(_db==ccc)then return false end -return true end;return false end,hoverHandler=function(dbc,_cc,acc,bcc) -if -(caa.hoverHandler(dbc,_cc,acc,bcc))then -if(cba["mouse_move"]~=nil)then -for ccc,dcc in pairs(dba["mouse_move"])do -if( -cba["mouse_move"][dcc]~=nil)then for _dc,adc in cd(cba["mouse_move"][dcc])do -if -(adc.hoverHandler~=nil)then if(adc:hoverHandler(_cc,acc,bcc))then return true end end end end end end end;return false end,dragHandler=function(dbc,_cc,acc,bcc) -if -(bab)then local ccc,dcc=dbc.parent:getOffsetInternal()ccc=ccc<0 and -math.abs(ccc)or-ccc;dcc= -dcc<0 and math.abs(dcc)or-dcc;local _dc=1;local adc=1;if(dbc.parent~=nil)then -_dc,adc=dbc.parent:getAbsolutePosition(dbc.parent:getAnchorPosition())end -dbc:setPosition( -acc+dda- (_dc-1)+ccc,bcc+__b- (adc-1)+dcc)dbc:updateDraw()return true end -if(dbc:isVisible())and(dbc:isEnabled())then -if -(cba["mouse_drag"]~=nil)then -for ccc,dcc in ipairs(dba["mouse_drag"])do -if -(cba["mouse_drag"][dcc]~=nil)then for _dc,adc in cd(cba["mouse_drag"][dcc])do -if(adc.dragHandler~=nil)then if -(adc:dragHandler(_cc,acc,bcc))then return true end end end end end end end;caa.dragHandler(dbc,_cc,acc,bcc)return false end,keyHandler=function(dbc,_cc,acc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local bcc=dbc:getEventSystem():sendEvent("key",dbc,"key",_cc)if(bcc==false)then return false end -if(cba["key"]~=nil)then -for ccc,dcc in pairs(dba["key"])do -if( -cba["key"][dcc]~=nil)then -for _dc,adc in cd(cba["key"][dcc])do if(adc.keyHandler~=nil)then if -(adc:keyHandler(_cc,acc))then return true end end end end end end end;return false end,keyUpHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("key_up",dbc,"key_up",_cc)if(acc==false)then return false end -if(cba["key_up"]~=nil)then -for bcc,ccc in -pairs(dba["key_up"])do -if(cba["key_up"][ccc]~=nil)then for dcc,_dc in cd(cba["key_up"][ccc])do -if( -_dc.keyUpHandler~=nil)then if(_dc:keyUpHandler(_cc))then return true end end end end end end end;return false end,charHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("char",dbc,"char",_cc)if(acc==false)then return false end -if(cba["char"]~=nil)then -for bcc,ccc in -pairs(dba["char"])do -if(cba["char"][ccc]~=nil)then for dcc,_dc in cd(cba["char"][ccc])do -if -(_dc.charHandler~=nil)then if(_dc:charHandler(_cc))then return true end end end end end end end;return false end,setText=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setText(c_a( -_cc+ (ccc-1),ccc),dcc+acc-1,a_a(bcc,c_a(1 -_cc+1,1),c_a(dbc:getWidth()- -_cc+1,1)))else -dbb.setText(c_a(_cc+ (ccc-1),ccc),dcc+acc-1,a_a(bcc,c_a(1 -_cc+1,1),c_a( -dbc:getWidth()-_cc+1,1)))end end end,setBG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setBG(c_a( -_cc+ (ccc-1),ccc),dcc+acc-1,a_a(bcc,c_a(1 -_cc+1,1),c_a(dbc:getWidth()- -_cc+1,1)))else -dbb.setBG(c_a(_cc+ (ccc-1),ccc),dcc+acc-1,a_a(bcc,c_a(1 -_cc+1,1),c_a( -dbc:getWidth()-_cc+1,1)))end end end,setFG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setFG(c_a( -_cc+ (ccc-1),ccc),dcc+acc-1,a_a(bcc,c_a(1 -_cc+1,1),c_a(dbc:getWidth()- -_cc+1,1)))else -dbb.setFG(c_a(_cc+ (ccc-1),ccc),dcc+acc-1,a_a(bcc,c_a(1 -_cc+1,1),c_a( -dbc:getWidth()-_cc+1,1)))end end end,writeText=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:writeText(c_a( -_cc+ (_dc-1),_dc),adc+acc-1,a_a(bcc,c_a(1 -_cc+1,1), -dbc:getWidth()-_cc+1),ccc,dcc)else -dbb.writeText(c_a(_cc+ (_dc-1),_dc),adc+acc-1,a_a(bcc,c_a(1 -_cc+1,1),c_a( -dbc:getWidth()-_cc+1,1)),ccc,dcc)end end end,blit=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -local bdc=dbc:getWidth() -if(dbc.parent~=nil)then -bcc=a_a(bcc,c_a(1 -_cc+1,1),bdc-_cc+1)ccc=a_a(ccc,c_a(1 -_cc+1,1),bdc-_cc+1)dcc=a_a(dcc,c_a( -1 -_cc+1,1),bdc-_cc+1) -dbc.parent:blit(c_a( -_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)else -bcc=a_a(bcc,c_a(1 -_cc+1,1),c_a(bdc-_cc+1,1)) -ccc=a_a(ccc,c_a(1 -_cc+1,1),c_a(bdc-_cc+1,1)) -dcc=a_a(dcc,c_a(1 -_cc+1,1),c_a(bdc-_cc+1,1)) -dbb.blit(c_a(_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)end end end,drawBackgroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(c_a(_cc+ (_dc-1),_dc),c_a(acc+ (adc-1),adc),bcc,ccc,dcc)else -dbb.drawBackgroundBox(c_a(_cc+ (_dc-1),_dc),c_a(acc+ (adc-1),adc),bcc,ccc,dcc)end end,drawTextBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawTextBox(c_a(_cc+ (_dc-1),_dc),c_a(acc+ (adc-1),adc),bcc,ccc,a_a(dcc,1,1))else -dbb.drawTextBox(c_a(_cc+ (_dc-1),_dc),c_a(acc+ (adc-1),adc),bcc,ccc,a_a(dcc,1,1))end end,drawForegroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawForegroundBox(c_a(_cc+ (_dc-1),_dc),c_a(acc+ (adc-1),adc),bcc,ccc,dcc)else -dbb.drawForegroundBox(c_a(_cc+ (_dc-1),_dc),c_a(acc+ (adc-1),adc),bcc,ccc,dcc)end end,draw=function(dbc,_cc)if -(ada)and not(cda)then return false end -if(dbc.parent==nil)then if(dbc:getDraw()== -false)then return false end end -if(caa.draw(dbc))then -local acc,bcc=dbc:getAbsolutePosition(dbc:getAnchorPosition())local ccc,dcc=dbc:getAnchorPosition()local _dc,adc=dbc:getSize() -if( -dbc.parent==nil)then -if(dbc.bgColor~=false)then -dbb.drawBackgroundBox(ccc,dcc,_dc,adc,dbc.bgColor)dbb.drawTextBox(ccc,dcc,_dc,adc," ")end;if(dbc.fgColor~=false)then -dbb.drawForegroundBox(ccc,dcc,_dc,adc,dbc.fgColor)end end -if(dbc.barActive)then -if(dbc.parent~=nil)then -dbc.parent:writeText(ccc,dcc,dc.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)else -dbb.writeText(ccc,dcc,dc.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)end -if(dbc:getBorder("left"))then -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc,1,1,dbc.barBackground)if(dbc.bgColor~=false)then -dbc.parent:drawBackgroundBox(ccc-1,dcc+1,1,adc-1,dbc.bgColor)end end end -if(dbc:getBorder("top"))then if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc-1,_dc+1,1,dbc.barBackground)end end end;for bdc,cdc in cd(aba)do -if(_ba[cdc]~=nil)then for ddc,__d in pairs(_ba[cdc])do -if(__d.draw~=nil)then __d:draw()end end end end end end,updateTerm=function(dbc)if -(ada)and not(cda)then return false end;dbb.update()end,addObject=function(dbc,_cc)return -a_c(_cc)end,removeObject=c_c,getObject=function(dbc,_cc)return ddb(_cc)end,getDeepObject=function(dbc,_cc)return __c(_cc)end,addFrame=function(dbc,_cc)local acc=baa.newFrame( -_cc or bd(),dbc,nil,baa)return a_c(acc)end,init=function(dbc) -if -not(bbb)then -if(_aa~=nil)then caa.width,caa.height=_aa:getSize() -dbc:setBackground(_aa:getTheme("FrameBG")) -dbc:setForeground(_aa:getTheme("FrameText"))else caa.width,caa.height=dca.getSize() -dbc:setBackground(baa.getTheme("BasaltBG")) -dbc:setForeground(baa.getTheme("BasaltText"))end;bbb=true end end} -for dbc,_cc in pairs(bc)do bba["add"..dbc]=function(acc,bcc) -return a_c(_cc(bcc or bd(),acc))end end;setmetatable(bba,caa)return bba end -end; -project['default']['loadObjects'] = function(...)local d={}if(packaged)then -for ba,ca in pairs(getProject("objects"))do d[ba]=ca()end;return d end -local _a=table.pack(...)local aa=fs.getDir(_a[2]or"Basalt")if(aa==nil)then -error("Unable to find directory ".. -_a[2].." please report this bug to our discord.")end;for ba,ca in -pairs(fs.list(fs.combine(aa,"objects")))do -if(ca~="example.lua")then local da=ca:gsub(".lua","")d[da]=require(da)end end;return d -end; -project['default']['Object'] = function(...)local aa=require("basaltEvent")local ba=require("utils") -local ca=ba.splitString;local da=ba.numberFromString;local _b=ba.getValueFromXML -return -function(ab)local bb="Object"local cb={}local db=1 -local _c;local ac="topLeft"local bc=false;local cc=true;local dc=false;local _d=false;local ad=false;local bd=false -local cd={left=false,right=false,top=false,bottom=false}local dd=colors.black;local __a=true;local a_a=false;local b_a,c_a,d_a,_aa=0,0,0,0;local aaa=true;local baa={} -local caa=aa() -cb={x=1,y=1,width=1,height=1,bgColor=colors.black,bgSymbol=" ",bgSymbolColor=colors.black,fgColor=colors.white,transparentColor=false,name=ab or"Object",parent=nil,show=function(daa)cc=true -daa:updateDraw()return daa end,hide=function(daa)cc=false;daa:updateDraw()return daa end,enable=function(daa) -__a=true;return daa end,disable=function(daa)__a=false;return daa end,isEnabled=function(daa)return __a end,generateXMLEventFunction=function(daa,_ba,aba) -local bba=function(cba) -if( -cba:sub(1,1)=="#")then -local dba=daa:getBaseFrame():getDeepObject(cba:sub(2,cba:len())) -if(dba~=nil)and(dba.internalObjetCall~=nil)then _ba(daa,function() -dba:internalObjetCall()end)end else -_ba(daa,daa:getBaseFrame():getVariable(cba))end end;if(type(aba)=="string")then bba(aba)elseif(type(aba)=="table")then -for cba,dba in pairs(aba)do bba(dba)end end;return daa end,setValuesByXMLData=function(daa,_ba) -local aba=daa:getBaseFrame()if(_b("x",_ba)~=nil)then -daa:setPosition(_b("x",_ba),daa.y)end;if(_b("y",_ba)~=nil)then -daa:setPosition(daa.x,_b("y",_ba))end;if(_b("width",_ba)~=nil)then -daa:setSize(_b("width",_ba),daa.height)end;if(_b("height",_ba)~=nil)then -daa:setSize(daa.width,_b("height",_ba))end;if(_b("bg",_ba)~=nil)then -daa:setBackground(colors[_b("bg",_ba)])end;if(_b("fg",_ba)~=nil)then -daa:setForeground(colors[_b("fg",_ba)])end;if(_b("value",_ba)~=nil)then -daa:setValue(colors[_b("value",_ba)])end -if(_b("visible",_ba)~=nil)then if -(_b("visible",_ba))then daa:show()else daa:hide()end end -if(_b("enabled",_ba)~=nil)then if(_b("enabled",_ba))then daa:enable()else -daa:disable()end end;if(_b("zIndex",_ba)~=nil)then -daa:setZIndex(_b("zIndex",_ba))end;if(_b("anchor",_ba)~=nil)then -daa:setAnchor(_b("anchor",_ba))end;if(_b("shadowColor",_ba)~=nil)then -daa:setShadow(colors[_b("shadowColor",_ba)])end;if(_b("border",_ba)~=nil)then -daa:setBorder(colors[_b("border",_ba)])end;if(_b("borderLeft",_ba)~=nil)then -cd["left"]=_b("borderLeft",_ba)end;if(_b("borderTop",_ba)~=nil)then -cd["top"]=_b("borderTop",_ba)end;if(_b("borderRight",_ba)~=nil)then -cd["right"]=_b("borderRight",_ba)end;if(_b("borderBottom",_ba)~=nil)then -cd["bottom"]=_b("borderBottom",_ba)end;if(_b("borderColor",_ba)~=nil)then -daa:setBorder(colors[_b("borderColor",_ba)])end;if -(_b("ignoreOffset",_ba)~=nil)then -if(_b("ignoreOffset",_ba))then daa:ignoreOffset(true)end end;if -(_b("onClick",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onClick,_b("onClick",_ba))end;if -(_b("onClickUp",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onClickUp,_b("onClickUp",_ba))end;if -(_b("onScroll",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onScroll,_b("onScroll",_ba))end;if -(_b("onDrag",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onDrag,_b("onDrag",_ba))end;if(_b("onHover",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onHover,_b("onHover",_ba))end;if -(_b("onLeave",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onLeave,_b("onLeave",_ba))end;if(_b("onKey",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onKey,_b("onKey",_ba))end;if(_b("onKeyUp",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onKeyUp,_b("onKeyUp",_ba))end;if -(_b("onChange",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onChange,_b("onChange",_ba))end;if -(_b("onResize",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onResize,_b("onResize",_ba))end;if -(_b("onReposition",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onReposition,_b("onReposition",_ba))end;if -(_b("onEvent",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onEvent,_b("onEvent",_ba))end;if -(_b("onGetFocus",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onGetFocus,_b("onGetFocus",_ba))end;if -(_b("onLoseFocus",_ba)~=nil)then -daa:generateXMLEventFunction(daa.onLoseFocus,_b("onLoseFocus",_ba))end -daa:updateDraw()return daa end,isVisible=function(daa)return -cc end,setFocus=function(daa)if(daa.parent~=nil)then -daa.parent:setFocusedObject(daa)end;return daa end,setZIndex=function(daa,_ba) -db=_ba -if(daa.parent~=nil)then daa.parent:removeObject(daa) -daa.parent:addObject(daa)daa:updateEventHandlers()end;return daa end,updateEventHandlers=function(daa) -for _ba,aba in -pairs(baa)do if(aba)then daa.parent:addEvent(_ba,daa)end end end,getZIndex=function(daa)return db end,getType=function(daa)return bb end,getName=function(daa)return -daa.name end,remove=function(daa)if(daa.parent~=nil)then -daa.parent:removeObject(daa)end;daa:updateDraw()return daa end,setParent=function(daa,_ba) -if( -_ba.getType~=nil and _ba:getType()=="Frame")then -daa:remove()_ba:addObject(daa)if(daa.draw)then daa:show()end end;return daa end,setValue=function(daa,_ba) -if( -_c~=_ba)then _c=_ba;daa:updateDraw()daa:valueChangedHandler()end;return daa end,getValue=function(daa)return _c end,getDraw=function(daa)return -aaa end,updateDraw=function(daa,_ba)aaa=_ba;if(_ba==nil)then aaa=true end;if(aaa)then if(daa.parent~=nil)then -daa.parent:updateDraw()end end;return daa end,getEventSystem=function(daa)return -caa end,getParent=function(daa)return daa.parent end,setPosition=function(daa,_ba,aba,bba) -if(type(_ba)=="number")then daa.x= -bba and daa:getX()+_ba or _ba end;if(type(aba)=="number")then -daa.y=bba and daa:getY()+aba or aba end -if(daa.parent~=nil)then if(type(_ba)=="string")then -daa.x=daa.parent:newDynamicValue(daa,_ba)end;if(type(aba)=="string")then -daa.y=daa.parent:newDynamicValue(daa,aba)end -daa.parent:recalculateDynamicValues()end;caa:sendEvent("basalt_reposition",daa) -daa:updateDraw()return daa end,getX=function(daa)return - -type(daa.x)=="number"and daa.x or math.floor(daa.x[1]+0.5)end,getY=function(daa)return - -type(daa.y)=="number"and daa.y or math.floor(daa.y[1]+0.5)end,getPosition=function(daa)return -daa:getX(),daa:getY()end,getVisibility=function(daa)return cc end,setVisibility=function(daa,_ba) -cc=_ba or not cc;daa:updateDraw()return daa end,setSize=function(daa,_ba,aba,bba)if(type(_ba)== -"number")then -daa.width=bba and daa:getWidth()+_ba or _ba end -if(type(aba)=="number")then daa.height=bba and -daa:getHeight()+aba or aba end -if(daa.parent~=nil)then if(type(_ba)=="string")then -daa.width=daa.parent:newDynamicValue(daa,_ba)end;if(type(aba)=="string")then -daa.height=daa.parent:newDynamicValue(daa,aba)end -daa.parent:recalculateDynamicValues()end;caa:sendEvent("basalt_resize",daa) -daa:updateDraw()return daa end,getHeight=function(daa) -return -type(daa.height)=="number"and daa.height or -math.floor(daa.height[1]+0.5)end,getWidth=function(daa)return - -type(daa.width)=="number"and daa.width or math.floor(daa.width[1]+0.5)end,getSize=function(daa)return -daa:getWidth(),daa:getHeight()end,calculateDynamicValues=function(daa) -if( -type(daa.width)=="table")then daa.width:calculate()end -if(type(daa.height)=="table")then daa.height:calculate()end -if(type(daa.x)=="table")then daa.x:calculate()end -if(type(daa.y)=="table")then daa.y:calculate()end;daa:updateDraw()return daa end,setBackground=function(daa,_ba,aba,bba)daa.bgColor= -_ba or false -daa.bgSymbol=aba or(daa.bgColor~=false and daa.bgSymbol or -false)daa.bgSymbolColor=bba or daa.bgSymbolColor -daa:updateDraw()return daa end,setTransparent=function(daa,_ba)daa.transparentColor= -_ba or false;daa.bgSymbol=false;daa.bgSymbolColor=false -daa:updateDraw()return daa end,getBackground=function(daa)return -daa.bgColor end,setForeground=function(daa,_ba)daa.fgColor=_ba or false -daa:updateDraw()return daa end,getForeground=function(daa)return daa.fgColor end,setShadow=function(daa,_ba)if( -_ba==false)then bd=false else dd=_ba;bd=true end -daa:updateDraw()return daa end,isShadowActive=function(daa)return bd end,setBorder=function(daa,...) -if( -...~=nil)then local _ba={...} -for aba,bba in pairs(_ba)do if(bba=="left")or(#_ba==1)then -cd["left"]=_ba[1]end;if(bba=="top")or(#_ba==1)then -cd["top"]=_ba[1]end;if(bba=="right")or(#_ba==1)then -cd["right"]=_ba[1]end;if(bba=="bottom")or(#_ba==1)then -cd["bottom"]=_ba[1]end end end;daa:updateDraw()return daa end,getBorder=function(daa,_ba)if( -_ba=="left")then return borderLeft end -if(_ba=="top")then return borderTop end;if(_ba=="right")then return borderRight end;if(_ba=="bottom")then -return borderBottom end end,draw=function(daa) -if -(cc)then -if(daa.parent~=nil)then local _ba,aba=daa:getAnchorPosition() -local bba,cba=daa:getSize()local dba,_ca=daa.parent:getSize() -if(_ba+bba<1)or(_ba>dba)or(aba+ -cba<1)or(aba>_ca)then return false end;if(daa.transparentColor~=false)then -daa.parent:drawForegroundBox(_ba,aba,bba,cba,daa.transparentColor)end;if(daa.bgColor~=false)then -daa.parent:drawBackgroundBox(_ba,aba,bba,cba,daa.bgColor)end -if(daa.bgSymbol~=false)then -daa.parent:drawTextBox(_ba,aba,bba,cba,daa.bgSymbol)if(daa.bgSymbol~=" ")then -daa.parent:drawForegroundBox(_ba,aba,bba,cba,daa.bgSymbolColor)end end -if(bd)then -daa.parent:drawBackgroundBox(_ba+1,aba+cba,bba,1,dd) -daa.parent:drawBackgroundBox(_ba+bba,aba+1,1,cba,dd) -daa.parent:drawForegroundBox(_ba+1,aba+cba,bba,1,dd) -daa.parent:drawForegroundBox(_ba+bba,aba+1,1,cba,dd)end;local aca=daa.bgColor -if(cd["left"]~=false)then -daa.parent:drawTextBox(_ba,aba,1,cba,"\149")if(aca~=false)then -daa.parent:drawBackgroundBox(_ba,aba,1,cba,daa.bgColor)end -daa.parent:drawForegroundBox(_ba,aba,1,cba,cd["left"])end -if(cd["top"]~=false)then -daa.parent:drawTextBox(_ba,aba,bba,1,"\131")if(aca~=false)then -daa.parent:drawBackgroundBox(_ba,aba,bba,1,daa.bgColor)end -daa.parent:drawForegroundBox(_ba,aba,bba,1,cd["top"])end -if(cd["left"]~=false)and(cd["top"]~=false)then -daa.parent:drawTextBox(_ba,aba,1,1,"\151")if(aca~=false)then -daa.parent:drawBackgroundBox(_ba,aba,1,1,daa.bgColor)end -daa.parent:drawForegroundBox(_ba,aba,1,1,cd["left"])end -if(cd["right"]~=false)then -daa.parent:drawTextBox(_ba+bba-1,aba,1,cba,"\149")if(aca~=false)then -daa.parent:drawForegroundBox(_ba+bba-1,aba,1,cba,daa.bgColor)end -daa.parent:drawBackgroundBox(_ba+bba-1,aba,1,cba,cd["right"])end -if(cd["bottom"]~=false)then -daa.parent:drawTextBox(_ba,aba+cba-1,bba,1,"\143")if(aca~=false)then -daa.parent:drawForegroundBox(_ba,aba+cba-1,bba,1,daa.bgColor)end -daa.parent:drawBackgroundBox(_ba,aba+cba-1,bba,1,cd["bottom"])end -if(cd["top"]~=false)and(cd["right"]~=false)then daa.parent:drawTextBox( -_ba+bba-1,aba,1,1,"\148")if -(aca~=false)then -daa.parent:drawForegroundBox(_ba+bba-1,aba,1,1,daa.bgColor)end -daa.parent:drawBackgroundBox(_ba+bba-1,aba,1,1,cd["right"])end -if(cd["right"]~=false)and(cd["bottom"]~=false)then -daa.parent:drawTextBox( -_ba+bba-1,aba+cba-1,1,1,"\133")if(aca~=false)then -daa.parent:drawForegroundBox(_ba+bba-1,aba+cba-1,1,1,daa.bgColor)end -daa.parent:drawBackgroundBox(_ba+bba-1, -aba+cba-1,1,1,cd["right"])end -if(cd["bottom"]~=false)and(cd["left"]~=false)then daa.parent:drawTextBox(_ba, -aba+cba-1,1,1,"\138")if(aca~=false)then -daa.parent:drawForegroundBox( -_ba-1,aba+cba-1,1,1,daa.bgColor)end -daa.parent:drawBackgroundBox(_ba,aba+cba-1,1,1,cd["left"])end end;aaa=false;return true end;return false end,getAbsolutePosition=function(daa,_ba,aba) -if( -_ba==nil)or(aba==nil)then _ba,aba=daa:getAnchorPosition()end -if(daa.parent~=nil)then -local bba,cba=daa.parent:getAbsolutePosition()_ba=bba+_ba-1;aba=cba+aba-1 end;return _ba,aba end,getAnchorPosition=function(daa,_ba,aba,bba)if( -_ba==nil)then _ba=daa:getX()end -if(aba==nil)then aba=daa:getY()end -if(daa.parent~=nil)then local cba,dba=daa.parent:getSize() -if(ac=="top")then _ba=math.floor( -cba/2)+_ba-1 elseif(ac=="topRight")then -_ba=cba+_ba-1 elseif(ac=="right")then _ba=cba+_ba-1 -aba=math.floor(dba/2)+aba-1 elseif(ac=="bottomRight")then _ba=cba+_ba-1;aba=dba+aba-1 elseif(ac=="bottom")then _ba=math.floor( -cba/2)+_ba-1;aba=dba+aba-1 elseif(ac== -"bottomLeft")then aba=dba+aba-1 elseif(ac=="left")then -aba=math.floor(dba/2)+aba-1 elseif(ac=="center")then _ba=math.floor(cba/2)+_ba-1;aba=math.floor( -dba/2)+aba-1 end;local _ca,aca=daa.parent:getOffsetInternal()if not(bc or bba)then return _ba+ -_ca,aba+aca end end;return _ba,aba end,ignoreOffset=function(daa,_ba) -bc=_ba;if(_ba==nil)then bc=true end;return daa end,getBaseFrame=function(daa) -if( -daa.parent~=nil)then return daa.parent:getBaseFrame()end;return daa end,setAnchor=function(daa,_ba)ac=_ba -daa:updateDraw()return daa end,getAnchor=function(daa)return ac end,onChange=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("value_changed",aba)end end;return daa end,onClick=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_click",aba)end end -if(daa.parent~=nil)then -daa.parent:addEvent("mouse_click",daa)baa["mouse_click"]=true -daa.parent:addEvent("mouse_up",daa)baa["mouse_up"]=true end;return daa end,onClickUp=function(daa,...)for _ba,aba in -pairs(table.pack(...))do -if(type(aba)=="function")then daa:registerEvent("mouse_up",aba)end end -if(daa.parent~=nil)then -daa.parent:addEvent("mouse_click",daa)baa["mouse_click"]=true -daa.parent:addEvent("mouse_up",daa)baa["mouse_up"]=true end;return daa end,onRelease=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_release",aba)end end -if(daa.parent~=nil)then -daa.parent:addEvent("mouse_click",daa)baa["mouse_click"]=true -daa.parent:addEvent("mouse_up",daa)baa["mouse_up"]=true end;return daa end,onScroll=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_scroll",aba)end end -if(daa.parent~=nil)then -daa.parent:addEvent("mouse_scroll",daa)baa["mouse_scroll"]=true end;return daa end,onHover=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_hover",aba)end end;if(daa.parent~=nil)then -daa.parent:addEvent("mouse_move",daa)baa["mouse_move"]=true end -return daa end,onLeave=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_leave",aba)end end;if(daa.parent~=nil)then -daa.parent:addEvent("mouse_move",daa)baa["mouse_move"]=true end -return daa end,onDrag=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("mouse_drag",aba)end end -if(daa.parent~=nil)then -daa.parent:addEvent("mouse_drag",daa)baa["mouse_drag"]=true -daa.parent:addEvent("mouse_click",daa)baa["mouse_click"]=true -daa.parent:addEvent("mouse_up",daa)baa["mouse_up"]=true end;return daa end,onEvent=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("other_event",aba)end end;if(daa.parent~=nil)then -daa.parent:addEvent("other_event",daa)baa["other_event"]=true end;return -daa end,onKey=function(daa,...) -if -(__a)then -for _ba,aba in pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("key",aba)end end;if(daa.parent~=nil)then daa.parent:addEvent("key",daa) -baa["key"]=true end end;return daa end,onChar=function(daa,...) -if -(__a)then -for _ba,aba in pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("char",aba)end end;if(daa.parent~=nil)then daa.parent:addEvent("char",daa) -baa["char"]=true end end;return daa end,onResize=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("basalt_resize",aba)end end;return daa end,onReposition=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("basalt_reposition",aba)end end;return daa end,onKeyUp=function(daa,...)for _ba,aba in -pairs(table.pack(...))do -if(type(aba)=="function")then daa:registerEvent("key_up",aba)end end;if(daa.parent~=nil)then -daa.parent:addEvent("key_up",daa)baa["key_up"]=true end;return daa end,isFocused=function(daa)if( -daa.parent~=nil)then -return daa.parent:getFocusedObject()==daa end;return false end,onGetFocus=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("get_focus",aba)end end;if(daa.parent~=nil)then -daa.parent:addEvent("mouse_click",daa)baa["mouse_click"]=true end;return -daa end,onLoseFocus=function(daa,...) -for _ba,aba in -pairs(table.pack(...))do if(type(aba)=="function")then -daa:registerEvent("lose_focus",aba)end end;if(daa.parent~=nil)then -daa.parent:addEvent("mouse_click",daa)baa["mouse_click"]=true end;return -daa end,registerEvent=function(daa,_ba,aba)return -caa:registerEvent(_ba,aba)end,removeEvent=function(daa,_ba,aba) -return caa:removeEvent(_ba,aba)end,sendEvent=function(daa,_ba,...)return caa:sendEvent(_ba,daa,...)end,isCoordsInObject=function(daa,_ba,aba) -if -(cc)and(__a)then if(_ba==nil)or(aba==nil)then return false end -local bba,cba=daa:getAbsolutePosition()local dba,_ca=daa:getSize() -if -(bba<=_ba)and(bba+dba>_ba)and(cba<=aba)and(cba+_ca>aba)then return true end end;return false end,mouseHandler=function(daa,_ba,aba,bba,cba) -if -(daa:isCoordsInObject(aba,bba))then local dba,_ca=daa:getAbsolutePosition() -local aca=caa:sendEvent("mouse_click",daa,"mouse_click",_ba,aba- -(dba-1),bba- (_ca-1),cba)if(aca==false)then return false end;if(daa.parent~=nil)then -daa.parent:setFocusedObject(daa)end;ad=true;a_a=true;b_a,c_a=aba,bba;return true end;return false end,mouseUpHandler=function(daa,_ba,aba,bba) -a_a=false -if(ad)then local cba,dba=daa:getAbsolutePosition() -local _ca=caa:sendEvent("mouse_release",daa,"mouse_release",_ba,aba- ( -cba-1),bba- (dba-1))ad=false end -if(daa:isCoordsInObject(aba,bba))then local cba,dba=daa:getAbsolutePosition() -local _ca=caa:sendEvent("mouse_up",daa,"mouse_up",_ba, -aba- (cba-1),bba- (dba-1))if(_ca==false)then return false end;return true end;return false end,dragHandler=function(daa,_ba,aba,bba) -if -(a_a)then local cba,dba=daa:getAbsolutePosition() -local _ca=caa:sendEvent("mouse_drag",daa,"mouse_drag",_ba,aba- (cba-1), -bba- (dba-1),b_a-aba,c_a-bba,aba,bba)b_a,c_a=aba,bba;if(_ca~=nil)then return _ca end;if(daa.parent~=nil)then -daa.parent:setFocusedObject(daa)end;return true end -if(daa:isCoordsInObject(aba,bba))then -local cba,dba=daa:getAbsolutePosition(daa:getAnchorPosition())b_a,c_a=aba,bba;d_a,_aa=cba-aba,dba-bba end;return false end,scrollHandler=function(daa,_ba,aba,bba) -if -(daa:isCoordsInObject(aba,bba))then local cba,dba=daa:getAbsolutePosition() -local _ca=caa:sendEvent("mouse_scroll",daa,"mouse_scroll",_ba,aba- -(cba-1),bba- (dba-1))if(_ca==false)then return false end;if(daa.parent~=nil)then -daa.parent:setFocusedObject(daa)end;return true end;return false end,hoverHandler=function(daa,_ba,aba,bba) -if -(daa:isCoordsInObject(_ba,aba))then -local cba=caa:sendEvent("mouse_hover",daa,"mouse_hover",_ba,aba,bba)if(cba==false)then return false end;_d=true;return true end -if(_d)then -local cba=caa:sendEvent("mouse_leave",daa,"mouse_leave",_ba,aba,bba)if(cba==false)then return false end;_d=false end;return false end,keyHandler=function(daa,_ba,aba)if -(__a)and(cc)then -if(daa:isFocused())then -local bba=caa:sendEvent("key",daa,"key",_ba,aba)if(bba==false)then return false end;return true end end;return -false end,keyUpHandler=function(daa,_ba)if -(__a)and(cc)then -if(daa:isFocused())then -local aba=caa:sendEvent("key_up",daa,"key_up",_ba)if(aba==false)then return false end;return true end end;return -false end,charHandler=function(daa,_ba)if -(__a)and(cc)then -if(daa:isFocused())then -local aba=caa:sendEvent("char",daa,"char",_ba)if(aba==false)then return false end;return true end end -return false end,valueChangedHandler=function(daa) -caa:sendEvent("value_changed",daa,_c)end,eventHandler=function(daa,_ba,aba,bba,cba,dba) -local _ca=caa:sendEvent("other_event",daa,_ba,aba,bba,cba,dba)if(_ca~=nil)then return _ca end;return true end,getFocusHandler=function(daa) -local _ba=caa:sendEvent("get_focus",daa)if(_ba~=nil)then return _ba end;return true end,loseFocusHandler=function(daa) -a_a=false;local _ba=caa:sendEvent("lose_focus",daa) -if(_ba~=nil)then return _ba end;return true end,init=function(daa) -if -(daa.parent~=nil)then for _ba,aba in pairs(baa)do -if(aba)then daa.parent:addEvent(_ba,daa)end end end;if not(dc)then dc=true;return true end;return false end}cb.__index=cb;return cb end -end; -project['default']['theme'] = function(...) -return -{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=false,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green,LabelBG=false,LabelText=colors.black} -end; -local cda=require("basaltEvent")() -local dda=require("Frame")local __b=require("theme")local a_b=require("utils") -local b_b=require("basaltLogs")local c_b=a_b.uuid;local d_b=a_b.createText;local _ab=a_b.tableCount;local aab=300;local bab=50 -local cab=term.current()local dab="1.6.2" -local _bb=fs.getDir(table.pack(...)[2]or"")local abb,bbb,cbb,dbb,_cb,acb={},{},{},{},{},{}local bcb,ccb,dcb,_db;local adb={}if not term.isColor or not -term.isColor()then -error('Basalt requires an advanced (golden) computer to run.',0)end;local function bdb()_db=false -cab.clear()cab.setCursorPos(1,1)end -local cdb=function(_dc) -cab.clear()cab.setBackgroundColor(colors.black) -cab.setTextColor(colors.red)local adc,bdc=cab.getSize() -if(adb.logging)then b_b(_dc,"Error")end;local cdc=d_b("Basalt error: ".._dc,adc)local ddc=1;for __d,a_d in pairs(cdc)do -cab.setCursorPos(1,ddc)cab.write(a_d)ddc=ddc+1 end;cab.setCursorPos(1, -ddc+1)_db=false end -local function ddb(_dc) -assert(_dc~="function","Schedule needs a function in order to work!")return -function(...)local adc=coroutine.create(_dc) -local bdc,cdc=coroutine.resume(adc,...)if(bdc)then table.insert(acb,adc)else cdb(cdc)end end end;local __c=function(_dc,adc)_cb[_dc]=adc end -local a_c=function(_dc)return _cb[_dc]end;local b_c=function(_dc)__b=_dc end -local c_c=function(_dc)return __b[_dc]end -local d_c={getMainFrame=function()return bcb end,setVariable=__c,getVariable=a_c,getTheme=c_c,setMainFrame=function(_dc)bcb=_dc end,getActiveFrame=function()return ccb end,setActiveFrame=function(_dc)ccb=_dc end,getFocusedObject=function()return -dcb end,setFocusedObject=function(_dc)dcb=_dc end,getMonitorFrame=function(_dc) -return cbb[_dc]or dbb[_dc][1]end,setMonitorFrame=function(_dc,adc,bdc)if(bcb==adc)then bcb=nil end;if(bdc)then -dbb[_dc]={adc,sides}else cbb[_dc]=adc end -if(adc==nil)then dbb[_dc]=nil end end,getBaseTerm=function() -return cab end,schedule=ddb,stop=bdb,newFrame=dda,getDirectory=function()return _bb end} -local function _ac(_dc,adc,bdc,cdc,ddc) -if(#acb>0)then local __d={} -for n=1,#acb do -if(acb[n]~=nil)then -if -(coroutine.status(acb[n])=="suspended")then -local a_d,b_d=coroutine.resume(acb[n],_dc,adc,bdc,cdc,ddc)if not(a_d)then cdb(b_d)end else table.insert(__d,n)end end end -for n=1,#__d do table.remove(acb,__d[n]- (n-1))end end end -local function aac()if(_db==false)then return end;if(bcb~=nil)then bcb:draw() -bcb:updateTerm()end -for _dc,adc in pairs(cbb)do adc:draw()adc:updateTerm()end -for _dc,adc in pairs(dbb)do adc[1]:draw()adc[1]:updateTerm()end end;local bac,cac,dac=nil,nil,nil;local _bc=nil -local function abc(_dc,adc,bdc)bac,cac,dac=bac,adc,bdc;if(_bc==nil)then -_bc=os.startTimer(aab/1000)end end -local function bbc()_bc=nil;bcb:hoverHandler(cac,dac,bac)ccb=bcb end;local cbc,dbc,_cc=nil,nil,nil;local acc=nil;local function bcc()acc=nil;bcb:dragHandler(cbc,dbc,_cc) -ccb=bcb end;local function ccc(_dc,adc,bdc)cbc,dbc,_cc=_dc,adc,bdc -if(bab<50)then bcc()else if -(acc==nil)then acc=os.startTimer(bab/1000)end end end -local function dcc(_dc,adc,bdc,cdc,ddc) -if( -cda:sendEvent("basaltEventCycle",_dc,adc,bdc,cdc,ddc)==false)then return end -if(bcb~=nil)then -if(_dc=="mouse_click")then -bcb:mouseHandler(adc,bdc,cdc,false)ccb=bcb elseif(_dc=="mouse_drag")then ccc(adc,bdc,cdc)elseif(_dc=="mouse_up")then -bcb:mouseUpHandler(adc,bdc,cdc,ddc)ccb=bcb elseif(_dc=="mouse_scroll")then -bcb:scrollHandler(adc,bdc,cdc,ddc)ccb=bcb elseif(_dc=="mouse_move")then abc(adc,bdc,cdc)end end -if(_dc=="monitor_touch")then if(cbb[adc]~=nil)then -cbb[adc]:mouseHandler(1,bdc,cdc,true)ccb=cbb[adc]end -if(_ab(dbb)>0)then for __d,a_d in pairs(dbb)do -a_d[1]:mouseHandler(1,bdc,cdc,true,adc)end end end -if(_dc=="char")then if(ccb~=nil)then ccb:charHandler(adc)end end;if(_dc=="key_up")then if(ccb~=nil)then ccb:keyUpHandler(adc)end -abb[adc]=false end -if(_dc=="key")then if(ccb~=nil)then -ccb:keyHandler(adc,bdc)end;abb[adc]=true end -if(_dc=="terminate")then if(ccb~=nil)then ccb:eventHandler(_dc) -if(_db==false)then return end end end -if - - - - -(_dc~="mouse_click")and(_dc~="mouse_up")and(_dc~="mouse_scroll")and(_dc~="mouse_drag")and -(_dc~="mouse_move")and(_dc~="key")and(_dc~="key_up")and(_dc~="char")and(_dc~="terminate")then -if(_dc=="timer")and(adc==_bc)then bbc()elseif(_dc=="timer")and(adc==acc)then -bcc()else -for __d,a_d in pairs(bbb)do a_d:eventHandler(_dc,adc,bdc,cdc,ddc)end end end;_ac(_dc,adc,bdc,cdc,ddc)aac()end -adb={logging=false,setTheme=b_c,getTheme=c_c,drawFrames=aac,getVersion=function()return dab end,setVariable=__c,getVariable=a_c,setBaseTerm=function(_dc)cab=_dc end,log=function(...)b_b(...)end,setMouseMoveThrottle=function(_dc) -if -(_HOST:find("CraftOS%-PC"))then if(config.get("mouse_move_throttle")~=10)then -config.set("mouse_move_throttle",10)end -if(_dc<100)then aab=100 else aab=_dc end;return true end;return false end,setMouseDragThrottle=function(_dc)if( -_dc<=0)then bab=0 else acc=nil;bab=_dc end end,autoUpdate=function(_dc) -_db=_dc;if(_dc==nil)then _db=true end;local function adc()aac()while _db do -dcc(os.pullEventRaw())end end -local bdc,cdc=xpcall(adc,debug.traceback)if not(bdc)then cdb(cdc)return end end,update=function(_dc,adc,bdc,cdc,ddc) -if( -_dc~=nil)then -local __d,a_d=xpcall(dcc,debug.traceback,_dc,adc,bdc,cdc,ddc)if not(__d)then cdb(a_d)return end end end,stop=bdb,stopUpdate=bdb,isKeyDown=function(_dc)if( -abb[_dc]==nil)then return false end;return abb[_dc]end,getFrame=function(_dc)for adc,bdc in -pairs(bbb)do if(bdc.name==_dc)then return bdc end end end,getActiveFrame=function()return -ccb end,setActiveFrame=function(_dc) -if(_dc:getType()=="Frame")then ccb=_dc;return true end;return false end,onEvent=function(...) -for _dc,adc in -pairs(table.pack(...))do if(type(adc)=="function")then -cda:registerEvent("basaltEventCycle",adc)end end end,schedule=ddb,createFrame=function(_dc)_dc=_dc or -c_b() -for bdc,cdc in pairs(bbb)do if(cdc.name==_dc)then return nil end end;local adc=dda(_dc,nil,nil,d_c)adc:init() -table.insert(bbb,adc)if -(bcb==nil)and(adc:getName()~="basaltDebuggingFrame")then adc:show()end;return adc end,removeFrame=function(_dc)bbb[_dc]= -nil end,setProjectDir=function(_dc)_bb=_dc end,debug=function(...)local _dc={...}if(bcb==nil)then -print(...)return end;if(bcb.name~="basaltDebuggingFrame")then -if -(bcb~=adb.debugFrame)then adb.debugLabel:setParent(bcb)end end;local adc=""for bdc,cdc in pairs(_dc)do -adc=adc.. -tostring(cdc).. (#_dc~=bdc and", "or"")end -adb.debugLabel:setText("[Debug] "..adc)for bdc,cdc in pairs(d_b(adc,adb.debugList:getWidth()))do -adb.debugList:addItem(cdc)end -if( -adb.debugList:getItemCount()>50)then adb.debugList:removeItem(1)end -adb.debugList:setValue(adb.debugList:getItem(adb.debugList:getItemCount()))if -(adb.debugList.getItemCount()>adb.debugList:getHeight())then -adb.debugList:setOffset(adb.debugList:getItemCount()- -adb.debugList:getHeight())end -adb.debugLabel:show()end} -adb.debugFrame=adb.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) -adb.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if( -adb.oldFrame~=nil)then adb.oldFrame:show()end end):setBackground(colors.red):show() -adb.debugList=adb.debugFrame:addList("debugList"):setSize("parent.w - 2","parent.h - 3"):setPosition(2,3):setScrollable(true):show() -adb.debugLabel=adb.debugFrame:addLabel("debugLabel"):onClick(function() -adb.oldFrame=bcb;adb.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return adb \ No newline at end of file diff --git a/docs/docs1_6/versions/basalt-1.6.4.lua b/docs/docs1_6/versions/basalt-1.6.4.lua deleted file mode 100644 index df1be83..0000000 --- a/docs/docs1_6/versions/basalt-1.6.4.lua +++ /dev/null @@ -1,3066 +0,0 @@ -local aa={}local ba=true;local ca=require -local da=function(ab) -for bb,cb in pairs(aa)do -if(type(cb)=="table")then for db,_c in pairs(cb)do if(db==ab)then -return _c()end end else if(bb==ab)then return cb()end end end;return ca(ab)end -local _b=function(ab)if(ab~=nil)then return aa[ab]end;return aa end -aa["main"]=function(...)local ab=da("basaltEvent")()local bb=da("Frame") -local cb=da("theme")local db=da("utils")local _c=da("basaltLogs")local ac=db.uuid -local bc=db.createText;local cc=db.tableCount;local dc=300;local _d=50;local ad=term.current()local bd="1.6.4"local cd=fs.getDir( -table.pack(...)[2]or"") -local dd,__a,a_a,b_a,c_a,d_a={},{},{},{},{},{}local _aa,aaa,baa,caa;local daa={}if -not term.isColor or not term.isColor()then -error('Basalt requires an advanced (golden) computer to run.',0)end;local _ba={} -for dab,_bb in -pairs(colors)do if(type(_bb)=="number")then -_ba[dab]={ad.getPaletteColor(_bb)}end end -local function aba()caa=false;ad.clear()ad.setCursorPos(1,1) -for dab,_bb in pairs(colors)do if(type(_bb)== -"number")then -ad.setPaletteColor(_bb,colors.packRGB(table.unpack(_ba[dab])))end end end -local function bba(dab)ad.clear()ad.setBackgroundColor(colors.black) -ad.setTextColor(colors.red)local _bb,abb=ad.getSize()if(daa.logging)then _c(dab,"Error")end;local bbb=bc( -"Basalt error: "..dab,_bb)local cbb=1;for dbb,_cb in pairs(bbb)do -ad.setCursorPos(1,cbb)ad.write(_cb)cbb=cbb+1 end;ad.setCursorPos(1, -cbb+1)caa=false end -local function cba(dab) -assert(dab~="function","Schedule needs a function in order to work!")return -function(...)local _bb=coroutine.create(dab) -local abb,bbb=coroutine.resume(_bb,...)if(abb)then table.insert(d_a,_bb)else bba(bbb)end end end;local dba=function(dab,_bb)c_a[dab]=_bb end -local _ca=function(dab)return c_a[dab]end;local aca=function(dab)cb=dab end -local bca=function(dab)return cb[dab]end -local cca={getDynamicValueEventSetting=function()return daa.dynamicValueEvents end,getMainFrame=function()return _aa end,setVariable=dba,getVariable=_ca,getTheme=bca,setMainFrame=function(dab) -_aa=dab end,getActiveFrame=function()return aaa end,setActiveFrame=function(dab)aaa=dab end,getFocusedObject=function()return baa end,setFocusedObject=function(dab)baa=dab end,getMonitorFrame=function(dab)return -a_a[dab]or b_a[dab][1]end,setMonitorFrame=function(dab,_bb,abb)if(_aa==_bb)then -_aa=nil end -if(abb)then b_a[dab]={_bb,sides}else a_a[dab]=_bb end;if(_bb==nil)then b_a[dab]=nil end end,getBaseTerm=function()return -ad end,schedule=cba,stop=aba,newFrame=bb,getDirectory=function()return cd end} -local function dca(dab,_bb,abb,bbb,cbb) -if(#d_a>0)then local dbb={} -for n=1,#d_a do -if(d_a[n]~=nil)then -if -(coroutine.status(d_a[n])=="suspended")then -local _cb,acb=coroutine.resume(d_a[n],dab,_bb,abb,bbb,cbb)if not(_cb)then bba(acb)end else table.insert(dbb,n)end end end -for n=1,#dbb do table.remove(d_a,dbb[n]- (n-1))end end end -local function _da()if(caa==false)then return end;if(_aa~=nil)then _aa:draw() -_aa:updateTerm()end -for dab,_bb in pairs(a_a)do _bb:draw()_bb:updateTerm()end -for dab,_bb in pairs(b_a)do _bb[1]:draw()_bb[1]:updateTerm()end end;local ada,bda,cda=nil,nil,nil;local dda=nil -local function __b(dab,_bb,abb,bbb)ada,bda,cda=_bb,abb,bbb;if(dda==nil)then -dda=os.startTimer(dc/1000)end end -local function a_b()dda=nil;_aa:hoverHandler(bda,cda,ada)aaa=_aa end;local b_b,c_b,d_b=nil,nil,nil;local _ab=nil;local function aab()_ab=nil;_aa:dragHandler(b_b,c_b,d_b) -aaa=_aa end;local function bab(dab,_bb,abb,bbb)b_b,c_b,d_b=_bb,abb,bbb -if(_d<50)then aab()else if(_ab==nil)then _ab=os.startTimer( -_d/1000)end end end -local function cab(dab,...) -local _bb={...} -if(ab:sendEvent("basaltEventCycle",dab,...)==false)then return end;if(dab=="terminate")then daa.stop()end -if(_aa~=nil)then -local abb={mouse_click=_aa.mouseHandler,mouse_up=_aa.mouseUpHandler,mouse_scroll=_aa.scrollHandler,mouse_drag=bab,mouse_move=__b}local bbb=abb[dab]if(bbb~=nil)then bbb(_aa,...)_da()return end end -if(dab=="monitor_touch")then if(a_a[p1]~=nil)then -a_a[p1]:mouseHandler(1,_bb[2],_bb[3],true)aaa=a_a[p1]end -if(cc(b_a)>0)then for abb,bbb in pairs(b_a)do -bbb[1]:mouseHandler(1,_bb[2],_bb[3],true,_bb[1])end end;_da()return end -if(aaa~=nil)then -local abb={char=aaa.charHandler,key=aaa.keyHandler,key_up=aaa.keyUpHandler}local bbb=abb[dab] -if(bbb~=nil)then if(dab=="key")then dd[_bb[1]]=true elseif(dab=="key_up")then -dd[_bb[1]]=false end;bbb(aaa,...)_da()return end end -if(dab=="timer")and(_bb[1]==dda)then a_b()elseif -(dab=="timer")and(_bb[1]==_ab)then aab()else -for abb,bbb in pairs(__a)do bbb:eventHandler(dab,...)end end;dca(dab,...)_da()end -daa={logging=false,dynamicValueEvents=false,setTheme=aca,getTheme=bca,drawFrames=_da,getVersion=function()return bd end,setVariable=dba,getVariable=_ca,setBaseTerm=function(dab)ad=dab end,log=function(...)_c(...)end,setMouseMoveThrottle=function(dab) -if -(_HOST:find("CraftOS%-PC"))then if(config.get("mouse_move_throttle")~=10)then -config.set("mouse_move_throttle",10)end -if(dab<100)then dc=100 else dc=dab end;return true end;return false end,setMouseDragThrottle=function(dab)if( -dab<=0)then _d=0 else _ab=nil;_d=dab end end,autoUpdate=function(dab) -caa=dab;if(dab==nil)then caa=true end;local function _bb()_da()while caa do -cab(os.pullEventRaw())end end -local abb,bbb=xpcall(_bb,debug.traceback)if not(abb)then bba(bbb)return end end,update=function(dab,...)if( -dab~=nil)then local _bb,abb=xpcall(cab,debug.traceback,dab,...)if not(_bb)then -bba(abb)return end end end,stop=aba,stopUpdate=aba,isKeyDown=function(dab)if( -dd[dab]==nil)then return false end;return dd[dab]end,getFrame=function(dab)for _bb,abb in -pairs(__a)do if(abb.name==dab)then return abb end end end,getActiveFrame=function()return -aaa end,setActiveFrame=function(dab) -if(dab:getType()=="Frame")then aaa=dab;return true end;return false end,onEvent=function(...) -for dab,_bb in -pairs(table.pack(...))do if(type(_bb)=="function")then -ab:registerEvent("basaltEventCycle",_bb)end end end,schedule=cba,createFrame=function(dab) -dab=dab or ac() -for abb,bbb in pairs(__a)do if(bbb.name==dab)then return nil end end;local _bb=bb(dab,nil,nil,cca)_bb:init() -table.insert(__a,_bb)if -(_aa==nil)and(_bb:getName()~="basaltDebuggingFrame")then _bb:show()end;return _bb end,removeFrame=function(dab)__a[dab]= -nil end,setProjectDir=function(dab)cd=dab end,debug=function(...)local dab={...}if(_aa==nil)then print(...) -return end -if(_aa.name~="basaltDebuggingFrame")then if(_aa~=daa.debugFrame)then -daa.debugLabel:setParent(_aa)end end;local _bb="" -for abb,bbb in pairs(dab)do _bb=_bb.. -tostring(bbb).. (#dab~=abb and", "or"")end;daa.debugLabel:setText("[Debug] ".._bb) -for abb,bbb in -pairs(bc(_bb,daa.debugList:getWidth()))do daa.debugList:addItem(bbb)end;if(daa.debugList:getItemCount()>50)then -daa.debugList:removeItem(1)end -daa.debugList:setValue(daa.debugList:getItem(daa.debugList:getItemCount()))if -(daa.debugList.getItemCount()>daa.debugList:getHeight())then -daa.debugList:setOffset(daa.debugList:getItemCount()- -daa.debugList:getHeight())end -daa.debugLabel:show()end} -daa.debugFrame=daa.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) -daa.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if( -daa.oldFrame~=nil)then daa.oldFrame:show()end end):setBackground(colors.red):show() -daa.debugList=daa.debugFrame:addList("debugList"):setSize("parent.w - 2","parent.h - 3"):setPosition(2,3):setScrollable(true):show() -daa.debugLabel=daa.debugFrame:addLabel("debugLabel"):onClick(function() -daa.oldFrame=_aa;daa.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return daa end -aa["Object"]=function(...)local ab=da("basaltEvent")local bb=da("utils") -local cb=da("module")local db=cb("images")local _c=bb.splitString;local ac=bb.numberFromString -local bc=bb.getValueFromXML;local cc,dc=table.unpack,string.sub -return -function(_d)local ad="Object"local bd={}local cd=1;local dd -local __a="topLeft"local a_a=false;local b_a=true;local c_a=false;local d_a=false;local _aa=false;local aaa=false -local baa={left=false,right=false,top=false,bottom=false}local caa=colors.black;local daa=true;local _ba=false;local aba,bba,cba,dba=0,0,0,0;local _ca;local aca;local bca=1;local cca -local dca;local _da=true;local ada=true;local bda={}local cda=ab() -bd={x=1,y=1,width=1,height=1,bgColor=colors.black,bgSymbol=" ",bgSymbolColor=colors.black,fgColor=colors.white,transparentColor=false,name=_d or"Object",parent= -nil,show=function(dda)b_a=true;dda:updateDraw()return dda end,hide=function(dda)b_a=false -dda:updateDraw()return dda end,enable=function(dda)daa=true;return dda end,disable=function(dda)daa=false -return dda end,isEnabled=function(dda)return daa end,generateXMLEventFunction=function(dda,__b,a_b) -local b_b=function(c_b) -if(c_b:sub(1,1)=="#")then -local d_b=dda:getBaseFrame():getDeepObject(c_b:sub(2,c_b:len())) -if(d_b~=nil)and(d_b.internalObjetCall~=nil)then __b(dda,function() -d_b:internalObjetCall()end)end else -__b(dda,dda:getBaseFrame():getVariable(c_b))end end;if(type(a_b)=="string")then b_b(a_b)elseif(type(a_b)=="table")then -for c_b,d_b in pairs(a_b)do b_b(d_b)end end;return dda end,setValuesByXMLData=function(dda,__b) -local a_b=dda:getBaseFrame()if(bc("x",__b)~=nil)then -dda:setPosition(bc("x",__b),dda:getY())end;if(bc("y",__b)~=nil)then -dda:setPosition(dda:getX(),bc("y",__b))end;if(bc("width",__b)~=nil)then -dda:setSize(bc("width",__b),dda.height)end;if(bc("height",__b)~=nil)then -dda:setSize(dda.width,bc("height",__b))end;if(bc("bg",__b)~=nil)then -dda:setBackground(colors[bc("bg",__b)])end;if(bc("fg",__b)~=nil)then -dda:setForeground(colors[bc("fg",__b)])end;if(bc("value",__b)~=nil)then -dda:setValue(colors[bc("value",__b)])end -if(bc("visible",__b)~=nil)then if -(bc("visible",__b))then dda:show()else dda:hide()end end -if(bc("enabled",__b)~=nil)then if(bc("enabled",__b))then dda:enable()else -dda:disable()end end;if(bc("zIndex",__b)~=nil)then -dda:setZIndex(bc("zIndex",__b))end;if(bc("anchor",__b)~=nil)then -dda:setAnchor(bc("anchor",__b))end;if(bc("shadowColor",__b)~=nil)then -dda:setShadow(colors[bc("shadowColor",__b)])end;if(bc("border",__b)~=nil)then -dda:setBorder(colors[bc("border",__b)])end;if(bc("borderLeft",__b)~=nil)then -baa["left"]=bc("borderLeft",__b)end;if(bc("borderTop",__b)~=nil)then -baa["top"]=bc("borderTop",__b)end;if(bc("borderRight",__b)~=nil)then -baa["right"]=bc("borderRight",__b)end;if(bc("borderBottom",__b)~=nil)then -baa["bottom"]=bc("borderBottom",__b)end;if(bc("borderColor",__b)~=nil)then -dda:setBorder(colors[bc("borderColor",__b)])end;if -(bc("ignoreOffset",__b)~=nil)then -if(bc("ignoreOffset",__b))then dda:ignoreOffset(true)end end;if -(bc("onClick",__b)~=nil)then -dda:generateXMLEventFunction(dda.onClick,bc("onClick",__b))end;if -(bc("onClickUp",__b)~=nil)then -dda:generateXMLEventFunction(dda.onClickUp,bc("onClickUp",__b))end;if -(bc("onScroll",__b)~=nil)then -dda:generateXMLEventFunction(dda.onScroll,bc("onScroll",__b))end;if -(bc("onDrag",__b)~=nil)then -dda:generateXMLEventFunction(dda.onDrag,bc("onDrag",__b))end;if(bc("onHover",__b)~=nil)then -dda:generateXMLEventFunction(dda.onHover,bc("onHover",__b))end;if -(bc("onLeave",__b)~=nil)then -dda:generateXMLEventFunction(dda.onLeave,bc("onLeave",__b))end;if(bc("onKey",__b)~=nil)then -dda:generateXMLEventFunction(dda.onKey,bc("onKey",__b))end;if(bc("onKeyUp",__b)~=nil)then -dda:generateXMLEventFunction(dda.onKeyUp,bc("onKeyUp",__b))end;if -(bc("onChange",__b)~=nil)then -dda:generateXMLEventFunction(dda.onChange,bc("onChange",__b))end;if -(bc("onResize",__b)~=nil)then -dda:generateXMLEventFunction(dda.onResize,bc("onResize",__b))end;if -(bc("onReposition",__b)~=nil)then -dda:generateXMLEventFunction(dda.onReposition,bc("onReposition",__b))end;if -(bc("onEvent",__b)~=nil)then -dda:generateXMLEventFunction(dda.onEvent,bc("onEvent",__b))end;if -(bc("onGetFocus",__b)~=nil)then -dda:generateXMLEventFunction(dda.onGetFocus,bc("onGetFocus",__b))end;if -(bc("onLoseFocus",__b)~=nil)then -dda:generateXMLEventFunction(dda.onLoseFocus,bc("onLoseFocus",__b))end -dda:updateDraw()return dda end,isVisible=function(dda)return -b_a end,setFocus=function(dda)if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return dda end,setZIndex=function(dda,__b) -cd=__b -if(dda.parent~=nil)then dda.parent:removeObject(dda) -dda.parent:addObject(dda)dda:updateEventHandlers()end;return dda end,updateEventHandlers=function(dda) -for __b,a_b in -pairs(bda)do if(a_b)then dda.parent:addEvent(__b,dda)end end end,getZIndex=function(dda)return cd end,getType=function(dda)return ad end,getName=function(dda)return -dda.name end,remove=function(dda)if(dda.parent~=nil)then -dda.parent:removeObject(dda)end;dda:updateDraw()return dda end,setParent=function(dda,__b) -if( -__b.getType~=nil and __b:getType()=="Frame")then -dda:remove()__b:addObject(dda)if(dda.draw)then dda:show()end end;return dda end,setValue=function(dda,__b,a_b)if( -dd~=__b)then dd=__b;dda:updateDraw()if(a_b~=false)then -dda:valueChangedHandler()end end -return dda end,getValue=function(dda)return dd end,getDraw=function(dda)return -ada end,updateDraw=function(dda,__b)ada=__b;if(__b==nil)then ada=true end;if(ada)then if(dda.parent~=nil)then -dda.parent:updateDraw()end end;return dda end,getEventSystem=function(dda)return -cda end,getParent=function(dda)return dda.parent end,setPosition=function(dda,__b,a_b,b_b) -if(type(__b)=="number")then dda.x= -b_b and dda:getX()+__b or __b end;if(type(a_b)=="number")then -dda.y=b_b and dda:getY()+a_b or a_b end -if(dda.parent~=nil)then if(type(__b)=="string")then -dda.x=dda.parent:newDynamicValue(dda,__b)end;if(type(a_b)=="string")then -dda.y=dda.parent:newDynamicValue(dda,a_b)end -dda.parent:recalculateDynamicValues()end;dda:customEventHandler("basalt_reposition") -dda:updateDraw()return dda end,getX=function(dda)return - -type(dda.x)=="number"and dda.x or math.floor(dda.x[1]+0.5)end,getY=function(dda)return - -type(dda.y)=="number"and dda.y or math.floor(dda.y[1]+0.5)end,getPosition=function(dda)return -dda:getX(),dda:getY()end,getVisibility=function(dda)return b_a end,setVisibility=function(dda,__b) -b_a=__b or not b_a;dda:updateDraw()return dda end,setSize=function(dda,__b,a_b,b_b)if(type(__b)== -"number")then -dda.width=b_b and dda:getWidth()+__b or __b end -if(type(a_b)=="number")then dda.height=b_b and -dda:getHeight()+a_b or a_b end -if(dda.parent~=nil)then if(type(__b)=="string")then -dda.width=dda.parent:newDynamicValue(dda,__b)end;if(type(a_b)=="string")then -dda.height=dda.parent:newDynamicValue(dda,a_b)end -dda.parent:recalculateDynamicValues()end;if(_ca~=nil)and(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]end -dda:customEventHandler("basalt_resize")dda:updateDraw()return dda end,getHeight=function(dda) -return -type(dda.height)=="number"and dda.height or -math.floor(dda.height[1]+0.5)end,getWidth=function(dda)return - -type(dda.width)=="number"and dda.width or math.floor(dda.width[1]+0.5)end,getSize=function(dda)return -dda:getWidth(),dda:getHeight()end,calculateDynamicValues=function(dda) -if( -type(dda.width)=="table")then dda.width:calculate()end -if(type(dda.height)=="table")then dda.height:calculate()end -if(type(dda.x)=="table")then dda.x:calculate()end -if(type(dda.y)=="table")then dda.y:calculate()end;dda:updateDraw()return dda end,setBackground=function(dda,__b,a_b,b_b)dda.bgColor= -__b or false -dda.bgSymbol=a_b or(dda.bgColor~=false and dda.bgSymbol or -false)dda.bgSymbolColor=b_b or dda.bgSymbolColor -dda:updateDraw()return dda end,setTexture=function(dda,__b,a_b,b_b)if( -type(__b)=="string")then _ca=db.loadImageAsBimg(__b)elseif(type(__b)=="table")then -_ca=__b end -if(_ca.animated)then local c_b=_ca[bca].duration or -_ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)dda.parent:addEvent("other_event",dda) -bda["other_event"]=true end;_da=b_b==false and false or true;bca=1 -dca=a_b or"normal"if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[1]else aca=_ca[1]end -dda:updateDraw()return dda end,setTransparent=function(dda,__b)dda.transparentColor= -__b or false;if(__b~=false)then dda.bgSymbol=false -dda.bgSymbolColor=false end;dda:updateDraw()return dda end,getBackground=function(dda)return -dda.bgColor end,setForeground=function(dda,__b)dda.fgColor=__b or false -dda:updateDraw()return dda end,getForeground=function(dda)return dda.fgColor end,setShadow=function(dda,__b)if( -__b==false)then aaa=false else caa=__b;aaa=true end -dda:updateDraw()return dda end,isShadowActive=function(dda)return aaa end,setBorder=function(dda,...) -if( -...~=nil)then local __b={...} -for a_b,b_b in pairs(__b)do if(b_b=="left")or(#__b==1)then -baa["left"]=__b[1]end;if(b_b=="top")or(#__b==1)then -baa["top"]=__b[1]end;if(b_b=="right")or(#__b==1)then -baa["right"]=__b[1]end;if(b_b=="bottom")or(#__b==1)then -baa["bottom"]=__b[1]end end end;dda:updateDraw()return dda end,getBorder=function(dda,__b)if( -__b=="left")then return borderLeft end -if(__b=="top")then return borderTop end;if(__b=="right")then return borderRight end;if(__b=="bottom")then -return borderBottom end end,draw=function(dda) -if -(b_a)then -if(dda.parent~=nil)then local __b,a_b=dda:getAnchorPosition() -local b_b,c_b=dda:getSize()local d_b,_ab=dda.parent:getSize() -if(__b+b_b<1)or(__b>d_b)or(a_b+ -c_b<1)or(a_b>_ab)then return false end;if(dda.transparentColor~=false)then -dda.parent:drawForegroundBox(__b,a_b,b_b,c_b,dda.transparentColor)end;if(dda.bgColor~=false)then -dda.parent:drawBackgroundBox(__b,a_b,b_b,c_b,dda.bgColor)end -if(dda.bgSymbol~=false)then -dda.parent:drawTextBox(__b,a_b,b_b,c_b,dda.bgSymbol)if(dda.bgSymbol~=" ")then -dda.parent:drawForegroundBox(__b,a_b,b_b,c_b,dda.bgSymbolColor)end end -if(aca~=nil)then -if(dca=="center")then local bab,cab=#aca[1][1],#aca -local dab=bab__b)and(c_b<=a_b)and(c_b+_ab>a_b)then return true end end;return false end,mouseHandler=function(dda,__b,a_b,b_b,c_b) -if -(dda:isCoordsInObject(a_b,b_b))then local d_b,_ab=dda:getAbsolutePosition() -local aab=cda:sendEvent("mouse_click",dda,"mouse_click",__b,a_b- -(d_b-1),b_b- (_ab-1),a_b,b_b,c_b)if(aab==false)then return false end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;_aa=true;_ba=true;aba,bba=a_b,b_b;return true end;return false end,mouseUpHandler=function(dda,__b,a_b,b_b) -_ba=false -if(_aa)then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_release",dda,"mouse_release",__b,a_b- ( -c_b-1),b_b- (d_b-1),a_b,b_b)_aa=false end -if(dda:isCoordsInObject(a_b,b_b))then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_up",dda,"mouse_up",__b, -a_b- (c_b-1),b_b- (d_b-1),a_b,b_b)if(_ab==false)then return false end;return true end;return false end,dragHandler=function(dda,__b,a_b,b_b) -if -(_ba)then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_drag",dda,"mouse_drag",__b,a_b- (c_b-1), -b_b- (d_b-1),aba-a_b,bba-b_b,a_b,b_b)aba,bba=a_b,b_b;if(_ab~=nil)then return _ab end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return true end -if(dda:isCoordsInObject(a_b,b_b))then -local c_b,d_b=dda:getAbsolutePosition(dda:getAnchorPosition())aba,bba=a_b,b_b;cba,dba=c_b-a_b,d_b-b_b end;return false end,scrollHandler=function(dda,__b,a_b,b_b) -if -(dda:isCoordsInObject(a_b,b_b))then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_scroll",dda,"mouse_scroll",__b,a_b- -(c_b-1),b_b- (d_b-1))if(_ab==false)then return false end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return true end;return false end,hoverHandler=function(dda,__b,a_b,b_b) -if -(dda:isCoordsInObject(__b,a_b))then -local c_b=cda:sendEvent("mouse_hover",dda,"mouse_hover",__b,a_b,b_b)if(c_b==false)then return false end;d_a=true;return true end -if(d_a)then -local c_b=cda:sendEvent("mouse_leave",dda,"mouse_leave",__b,a_b,b_b)if(c_b==false)then return false end;d_a=false end;return false end,keyHandler=function(dda,__b,a_b)if -(daa)and(b_a)then -if(dda:isFocused())then -local b_b=cda:sendEvent("key",dda,"key",__b,a_b)if(b_b==false)then return false end;return true end end;return -false end,keyUpHandler=function(dda,__b)if -(daa)and(b_a)then -if(dda:isFocused())then -local a_b=cda:sendEvent("key_up",dda,"key_up",__b)if(a_b==false)then return false end;return true end end;return -false end,charHandler=function(dda,__b)if -(daa)and(b_a)then -if(dda:isFocused())then -local a_b=cda:sendEvent("char",dda,"char",__b)if(a_b==false)then return false end;return true end end;return -false end,valueChangedHandler=function(dda) -cda:sendEvent("value_changed",dda,dd)end,eventHandler=function(dda,__b,...)local a_b={...} -if -(__b=="timer")and(a_b[1]==cca)then -if(_ca[bca+1]~=nil)then bca=bca+1;if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]else aca=_ca[bca]end;local c_b=_ca[bca].duration or -_ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)else -if(_da)then bca=1;if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[1]else aca=_ca[1]end;local c_b= -_ca[1].duration or _ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)end end;dda:updateDraw()end;local b_b=cda:sendEvent("other_event",dda,__b,...)if(b_b~=nil)then -return b_b end end,customEventHandler=function(dda,__b,...) -if -( -_ca~=nil)and(dca=="stretch")and(__b=="basalt_resize")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]dda:updateDraw()end;local a_b=cda:sendEvent("custom_event",dda,__b,...)if(a_b~=nil)then -return a_b end;return true end,getFocusHandler=function(dda) -local __b=cda:sendEvent("get_focus",dda)if(__b~=nil)then return __b end;return true end,loseFocusHandler=function(dda) -_ba=false;local __b=cda:sendEvent("lose_focus",dda) -if(__b~=nil)then return __b end;return true end,init=function(dda) -if -(dda.parent~=nil)then for __b,a_b in pairs(bda)do -if(a_b)then dda.parent:addEvent(__b,dda)end end end;if not(c_a)then c_a=true;return true end;return false end}bd.__index=bd;return bd end end -aa["theme"]=function(...) -return -{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=false,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green,LabelBG=false,LabelText=colors.black,GraphBG=colors.gray,GraphText=colors.black}end -aa["Frame"]=function(...)local ab=da("module")local bb=da("Object") -local cb=da("loadObjects")local db=da("basaltDraw")local _c=da("utils")local ac=ab("layout") -local bc=ab("basaltMon")local cc=_c.uuid;local dc=_c.rpairs;local _d=_c.getValueFromXML;local ad=_c.tableCount -local bd,cd,dd=string.sub,math.min,math.max -return -function(__a,a_a,b_a,c_a)local d_a=bb(__a)local _aa="Frame"local aaa={}local baa={}local caa={}local daa={}local _ba={}local aba={} -local bba={}local cba={}local dba=0;local _ca=b_a or term.current()local aca=""local bca=false -local cca=false;local dca=false;local _da=0;local ada=0;local bda=false;local cda=0;local dda=false;local __b=false;local a_b=""local b_b=false -local c_b=false;local d_b;local _ab;local aab=true;local bab=true;local cab=false;local dab={}local _bb={} -d_a:setZIndex(10)local abb=db(_ca)local bbb=false;local cbb=1;local dbb=1;local _cb=colors.white;local acb,bcb=0,0;local ccb={} -local function dcb(dbc,_cc)if(_cc~= -nil)then _cc:setValuesByXMLData(dbc)end end -local function _db(dbc,_cc,acc) -if(dbc~=nil)then if(dbc.properties~=nil)then dbc={dbc}end;for bcc,ccc in pairs(dbc)do local dcc=_cc(acc, -ccc["@id"]or cc()) -table.insert(ccb,dcc)dcb(ccc,dcc)end end end -local function adb(dbc)if(type(dbc)~="string")then dbc=dbc.name end;for _cc,acc in pairs(aaa)do -for bcc,ccc in -pairs(acc)do if(ccc:getName()==dbc)then return ccc end end end end -local function bdb(dbc)local _cc=adb(dbc)if(_cc~=nil)then return _cc end -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do if( -dcc:getType()=="Frame")then local _dc=dcc:getDeepObject(dbc) -if(_dc~=nil)then return _dc end end end end end -local function cdb(dbc)local _cc=dbc:getZIndex() -if(adb(dbc.name)~=nil)then return nil end -if(aaa[_cc]==nil)then -for x=1,#baa+1 do if(baa[x]~=nil)then if(_cc==baa[x])then break end;if -(_cc>baa[x])then table.insert(baa,x,_cc)break end else -table.insert(baa,_cc)end end;if(#baa<=0)then table.insert(baa,_cc)end;aaa[_cc]={}end;dbc.parent=caa;if(dbc.init~=nil)then dbc:init()end -table.insert(aaa[_cc],dbc)return dbc end -local function ddb(dbc,_cc) -for acc,bcc in pairs(daa)do -for ccc,dcc in pairs(bcc)do -for _dc,adc in pairs(dcc)do -if(adc==_cc)then -table.remove(daa[acc][ccc],_dc)if(dbc.parent~=nil)then if(ad(daa[acc])<=0)then -dbc.parent:removeEvent(acc,dbc)end end end end end end end -local function __c(dbc,_cc) -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if(type(_cc)=="string")then -if(dcc:getName()==_cc)then -table.remove(aaa[acc],ccc)ddb(caa,dcc)dbc:updateDraw()return true end else if(dcc==_cc)then table.remove(aaa[acc],ccc)ddb(caa,dcc) -dbc:updateDraw()return true end end end end;return false end;local function a_c(dbc,_cc,acc) -for bcc,ccc in pairs(daa[_cc])do for dcc,_dc in pairs(ccc)do -if(_dc:getName()==acc)then return _dc end end end end -local function b_c(dbc,_cc,acc) -local bcc=acc:getZIndex()if(daa[_cc]==nil)then daa[_cc]={}end;if(_ba[_cc]==nil)then -_ba[_cc]={}end -if(a_c(dbc,_cc,acc.name)~=nil)then return nil end -if(dbc.parent~=nil)then dbc.parent:addEvent(_cc,dbc)end;dab[_cc]=true -if(daa[_cc][bcc]==nil)then -for x=1,#_ba[_cc]+1 do -if -(_ba[_cc][x]~=nil)then if(bcc==_ba[_cc][x])then break end;if(bcc>_ba[_cc][x])then -table.insert(_ba[_cc],x,bcc)break end else -table.insert(_ba[_cc],bcc)end end -if(#_ba[_cc]<=0)then table.insert(_ba[_cc],bcc)end;daa[_cc][bcc]={}end;table.insert(daa[_cc][bcc],acc)return acc end -local function c_c(dbc,_cc,acc) -if(daa[_cc]~=nil)then -for bcc,ccc in pairs(daa[_cc])do -for dcc,_dc in pairs(ccc)do -if(_dc==acc)then -table.remove(daa[_cc][bcc],dcc)if(#daa[_cc][bcc]<=0)then daa[_cc][bcc]=nil -if(dbc.parent~=nil)then if( -ad(daa[_cc])<=0)then dab[_cc]=false -dbc.parent:removeEvent(_cc,dbc)end end end;return -true end end end end;return false end;local d_c=math -local function _ac(dbc) -local _cc,acc=pcall(load("return "..dbc,"",nil,{math=d_c}))if not(_cc)then -error(dbc.." is not a valid dynamic code")end;return acc end -local function aac(dbc,_cc,acc)for bcc,ccc in pairs(cba)do -if(ccc[2]==acc)and(ccc[4]==_cc)then return ccc end end;dba=dba+1 -cba[dba]={0,acc,{},_cc,dba}return cba[dba]end -local function bac(dbc,_cc)local acc={}local bcc={}for ccc in _cc:gmatch("%a+%.x")do local dcc=ccc:gsub("%.x","") -if -(dcc~="self")and(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%w+%.y")do local dcc=ccc:gsub("%.y","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end;for ccc in _cc:gmatch("%a+%.w")do local dcc=ccc:gsub("%.w","") -if(dcc~="self")and -(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%a+%.h")do local dcc=ccc:gsub("%.h","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end -for ccc,dcc in pairs(acc)do bcc[dcc]=adb(dcc)if(bcc[dcc]==nil)then -error("Dynamic Values - unable to find object "..dcc)end end;bcc["self"]=dbc;bcc["parent"]=dbc:getParent()return bcc end -local function cac(dbc,_cc)local acc=dbc;for bcc in dbc:gmatch("%w+%.x")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.x","")]:getX())end;for bcc in dbc:gmatch("%w+%.y")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.y","")]:getY())end;for bcc in dbc:gmatch("%w+%.w")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.w","")]:getWidth())end;for bcc in dbc:gmatch("%w+%.h")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.h","")]:getHeight())end;return acc end -local function dac(dbc) -if(#cba>0)then -for n=1,dba do -if(cba[n]~=nil)then local _cc;if(#cba[n][3]<=0)then -cba[n][3]=bac(cba[n][4],cba[n][2])end -_cc=cac(cba[n][2],cba[n][3])cba[n][1]=_ac(_cc)if(cba[n][4]:getType()=="Frame")then -cba[n][4]:recalculateDynamicValues()end end end -for _cc,acc in pairs(baa)do -if(aaa[acc]~=nil)then -for bcc,ccc in pairs(aaa[acc])do -if -(c_a.getDynamicValueEventSetting())then if(ccc.eventHandler~=nil)then -ccc:eventHandler("basalt_dynamicvalue",dbc)end end;if(ccc.customEventHandler~=nil)then -ccc:customEventHandler("basalt_resize",dbc)end end end end end end;local function _bc(dbc)return cba[dbc][1]end -local function abc(dbc)local _cc=0 -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if( -dcc.getHeight~=nil)and(dcc.getY~=nil)then -if -(dcc:getType()=="Dropdown")then local _dc,adc=dcc:getHeight(),dcc:getY() -local bdc,cdc=dcc:getDropdownSize()_dc=_dc+cdc-1 -if(_dc+adc-dbc:getHeight()>=_cc)then _cc=dd( -_dc+adc-dbc:getHeight(),0)end else local _dc,adc=dcc:getHeight(),dcc:getY()if( -_dc+adc-dbc:getHeight()>=_cc)then -_cc=dd(_dc+adc-dbc:getHeight(),0)end end end end end;return _cc end -local function bbc(dbc)local _cc=0 -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if -(dcc.getWidth~=nil)and(dcc.getX~=nil)then local _dc,adc=dcc:getWidth(),dcc:getX()if( -_dc+adc-dbc:getWidth()>=_cc)then -_cc=dd(_dc+adc-dbc:getWidth(),0)end end end end;return _cc end;local function cbc(dbc)if(bab)then cda=abc(dbc)end end -caa={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",addEvent=b_c,removeEvent=c_c,removeEvents=ddb,getEvent=a_c,newDynamicValue=aac,recalculateDynamicValues=dac,getDynamicValue=_bc,getType=function(dbc)return -_aa end,setZIndex=function(dbc,_cc)d_a.setZIndex(dbc,_cc)for acc,bcc in pairs(dab)do if(bcc)then -dbc.parent:addEvent(acc,dbc)end end;return dbc end,setFocusedObject=function(dbc,_cc) -if( -_ab~=_cc)then if(_ab~=nil)then -if(adb(_ab)~=nil)then _ab:loseFocusHandler()end end;if(_cc~=nil)then if(adb(_cc)~=nil)then -_cc:getFocusHandler()end end;_ab=_cc end;return dbc end,getVariable=function(dbc,_cc)return -c_a.getVariable(_cc)end,setSize=function(dbc,_cc,acc,bcc) -d_a.setSize(dbc,_cc,acc,bcc)if(dbc.parent==nil)then abb=db(_ca)end -for ccc,dcc in pairs(baa)do if(aaa[dcc]~=nil)then -for _dc,adc in -pairs(aaa[dcc])do if(adc.customEventHandler~=nil)then -adc:customEventHandler("basalt_resize",dbc)end end end end;dbc:recalculateDynamicValues()aab=false;return dbc end,setTheme=function(dbc,_cc,acc) -if( -type(_cc)=="table")then bba=_cc elseif(type(_cc)=="string")then bba[_cc]=acc end;dbc:updateDraw()return dbc end,getTheme=function(dbc,_cc) -return -bba[_cc]or(dbc.parent~=nil and dbc.parent:getTheme(_cc)or -c_a.getTheme(_cc))end,getThemeColor=function(dbc,_cc)return -_cc~=nil and _bb[_cc]or _bb end,setThemeColor=function(dbc,_cc,...) -if -(dbc.parent==nil)then -if(dbc==c_a.getActiveFrame())then -if(type(_cc)=="string")then _bb[_cc]=... -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],...)elseif(type(_cc)=="table")then -for acc,bcc in pairs(_cc)do _bb[acc]=bcc -if(type(bcc)=="number")then -_ca.setPaletteColor( -type(acc)=="number"and acc or colors[acc],bcc)else local ccc,dcc,_dc=table.unpack(bcc) -_ca.setPaletteColor( -type(acc)=="number"and acc or colors[acc],ccc,dcc,_dc)end end end end end;return dbc end,setPosition=function(dbc,_cc,acc,bcc) -d_a.setPosition(dbc,_cc,acc,bcc)dbc:recalculateDynamicValues()return dbc end,getBasaltInstance=function(dbc)return -c_a end,setOffset=function(dbc,_cc,acc) -acb=_cc~=nil and -d_c.floor(_cc<0 and d_c.abs(_cc)or-_cc)or acb -bcb=acc~=nil and -d_c.floor(acc<0 and d_c.abs(acc)or-acc)or bcb;dbc:updateDraw()return dbc end,getOffsetInternal=function(dbc)return -acb,bcb end,getOffset=function(dbc)return acb<0 and d_c.abs(acb)or-acb,bcb<0 and -d_c.abs(bcb)or-bcb end,removeFocusedObject=function(dbc)if( -_ab~=nil)then -if(adb(_ab)~=nil)then _ab:loseFocusHandler()end end;_ab=nil;return dbc end,getFocusedObject=function(dbc)return -_ab end,setCursor=function(dbc,_cc,acc,bcc,ccc) -if(dbc.parent~=nil)then -local dcc,_dc=dbc:getAnchorPosition() -dbc.parent:setCursor(_cc or false,(acc or 0)+dcc-1,(bcc or 0)+_dc-1, -ccc or _cb)else -local dcc,_dc=dbc:getAbsolutePosition(dbc:getAnchorPosition(dbc:getX(),dbc:getY(),true))bbb=_cc or false;if(acc~=nil)then cbb=dcc+acc-1 end;if(bcc~=nil)then dbb=_dc+ -bcc-1 end;_cb=ccc or _cb;if(bbb)then -_ca.setTextColor(_cb)_ca.setCursorPos(cbb,dbb)_ca.setCursorBlink(bbb)else -_ca.setCursorBlink(false)end end;return dbc end,setMovable=function(dbc,_cc) -if( -dbc.parent~=nil)then b_b=_cc or not b_b -dbc.parent:addEvent("mouse_click",dbc)dab["mouse_click"]=true -dbc.parent:addEvent("mouse_up",dbc)dab["mouse_up"]=true -dbc.parent:addEvent("mouse_drag",dbc)dab["mouse_drag"]=true end;return dbc end,setScrollable=function(dbc,_cc)bda=( -_cc or _cc==nil)and true or false -if( -dbc.parent~=nil)then dbc.parent:addEvent("mouse_scroll",dbc)end;dab["mouse_scroll"]=true;return dbc end,setScrollAmount=function(dbc,_cc)cda= -_cc or cda;bab=false;return dbc end,getScrollAmount=function(dbc)return bab and cbc(dbc)or -cda end,getCalculatedVerticalScroll=abc,getCalculatedHorizontalScroll=bbc,show=function(dbc)d_a.show(dbc) -if( -dbc.parent==nil)then c_a.setActiveFrame(dbc) -for _cc,acc in pairs(colors)do if -(type(acc)=="number")then -_ca.setPaletteColor(acc,colors.packRGB(term.nativePaletteColor((acc))))end end -for _cc,acc in pairs(_bb)do -if(type(acc)=="number")then -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],acc)else local bcc,ccc,dcc=table.unpack(acc) -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],bcc,ccc,dcc)end end -if(bca)and not(cca)then c_a.setMonitorFrame(aca,dbc)elseif(cca)then -c_a.setMonitorFrame(dbc:getName(),dbc,aca)else c_a.setMainFrame(dbc)end end;return dbc end,hide=function(dbc) -d_a.hide(dbc) -if(dbc.parent==nil)then if(activeFrame==dbc)then activeFrame=nil end -if(bca)and -not(cca)then if(c_a.getMonitorFrame(aca)==dbc)then -c_a.setActiveFrame(nil)end elseif(cca)then -if( -c_a.getMonitorFrame(dbc:getName())==dbc)then c_a.setActiveFrame(nil)end else -if(c_a.getMainFrame()==dbc)then c_a.setMainFrame(nil)end end end;return dbc end,addLayout=function(dbc,_cc) -if( -_cc~=nil)then -if(fs.exists(_cc))then local acc=fs.open(_cc,"r") -local bcc=ac:ParseXmlText(acc.readAll())acc.close()ccb={}dbc:setValuesByXMLData(bcc)end end;return dbc end,getLastLayout=function(dbc)return -ccb end,addLayoutFromString=function(dbc,_cc)if(_cc~=nil)then local acc=ac:ParseXmlText(_cc) -dbc:setValuesByXMLData(acc)end;return dbc end,setValuesByXMLData=function(dbc,_cc) -d_a.setValuesByXMLData(dbc,_cc)if(_d("movable",_cc)~=nil)then if(_d("movable",_cc))then -dbc:setMovable(true)end end;if( -_d("scrollable",_cc)~=nil)then -if(_d("scrollable",_cc))then dbc:setScrollable(true)end end;if -(_d("monitor",_cc)~=nil)then -dbc:setMonitor(_d("monitor",_cc)):show()end;if(_d("mirror",_cc)~=nil)then -dbc:setMirror(_d("mirror",_cc))end -if(_d("bar",_cc)~=nil)then if(_d("bar",_cc))then -dbc:showBar(true)else dbc:showBar(false)end end -if(_d("barText",_cc)~=nil)then dbc.barText=_d("barText",_cc)end;if(_d("barBG",_cc)~=nil)then -dbc.barBackground=colors[_d("barBG",_cc)]end;if(_d("barFG",_cc)~=nil)then -dbc.barTextcolor=colors[_d("barFG",_cc)]end;if(_d("barAlign",_cc)~=nil)then -dbc.barTextAlign=_d("barAlign",_cc)end;if(_d("layout",_cc)~=nil)then -dbc:addLayout(_d("layout",_cc))end;if(_d("xOffset",_cc)~=nil)then -dbc:setOffset(_d("xOffset",_cc),bcb)end;if(_d("yOffset",_cc)~=nil)then -dbc:setOffset(bcb,_d("yOffset",_cc))end;if(_d("scrollAmount",_cc)~=nil)then -dbc:setScrollAmount(_d("scrollAmount",_cc))end;local acc=_cc:children() -for bcc,ccc in -pairs(acc)do if(ccc.___name~="animation")then -local dcc=ccc.___name:gsub("^%l",string.upper) -if(cb[dcc]~=nil)then _db(ccc,dbc["add"..dcc],dbc)end end end;_db(_cc["frame"],dbc.addFrame,dbc) -_db(_cc["animation"],dbc.addAnimation,dbc)return dbc end,showBar=function(dbc,_cc)dbc.barActive= -_cc or not dbc.barActive;dbc:updateDraw() -return dbc end,setBar=function(dbc,_cc,acc,bcc)dbc.barText=_cc or""dbc.barBackground= -acc or dbc.barBackground -dbc.barTextcolor=bcc or dbc.barTextcolor;dbc:updateDraw()return dbc end,setBarTextAlign=function(dbc,_cc)dbc.barTextAlign= -_cc or"left"dbc:updateDraw()return dbc end,setMirror=function(dbc,_cc)if( -dbc.parent~=nil)then -error("Frame has to be a base frame in order to attach a mirror.")end;a_b=_cc;if(mirror~=nil)then -abb.setMirror(mirror)end;dda=true;return dbc end,removeMirror=function(dbc)mirror= -nil;dda=false;abb.setMirror(nil)return dbc end,setMonitorScale=function(dbc,_cc)if -(bca)then _ca.setTextScale(_cc)end;return dbc end,setMonitor=function(dbc,_cc,acc) -if( -_cc~=nil)and(_cc~=false)then -if(type(_cc)=="string")then -if( -peripheral.getType(_cc)=="monitor")then _ca=peripheral.wrap(_cc)dca=true end -if(dbc.parent~=nil)then dbc.parent:removeObject(dbc)end;bca=true;c_a.setMonitorFrame(_cc,dbc)elseif(type(_cc)=="table")then -_ca=bc(_cc)dca=true;bca=true;cca=true -c_a.setMonitorFrame(dbc:getName(),dbc,true)end else _ca=parentTerminal;bca=false;cca=false -if(type(aca)=="string")then -if( -c_a.getMonitorFrame(aca)==dbc)then c_a.setMonitorFrame(aca,nil)end else -if(c_a.getMonitorFrame(dbc:getName())==dbc)then c_a.setMonitorFrame(dbc:getName(), -nil)end end end;if(acc~=nil)then _ca.setTextScale(acc)end;abb=db(_ca) -dbc:setSize(_ca.getSize())aab=true;aca=_cc or nil;dbc:updateDraw()return dbc end,loseFocusHandler=function(dbc) -d_a.loseFocusHandler(dbc)if(_ab~=nil)then _ab:loseFocusHandler()_ab=nil end end,getFocusHandler=function(dbc) -d_a.getFocusHandler(dbc) -if(dbc.parent~=nil)then -if(b_b)then dbc.parent:removeEvents(dbc) -dbc.parent:removeObject(dbc)dbc.parent:addObject(dbc)for _cc,acc in pairs(dab)do if(acc)then -dbc.parent:addEvent(_cc,dbc)end end -dbc:updateDraw()end end;if(_ab~=nil)then _ab:getFocusHandler()end end,eventHandler=function(dbc,_cc,...) -d_a.eventHandler(dbc,_cc,...) -if(daa["other_event"]~=nil)then -for acc,bcc in ipairs(_ba["other_event"])do -if( -daa["other_event"][bcc]~=nil)then for ccc,dcc in dc(daa["other_event"][bcc])do -if -(dcc.eventHandler~=nil)then if(dcc:eventHandler(_cc,...))then return true end end end end end end;if(aab)and not(bca)then -if(dbc.parent==nil)then if(_cc=="term_resize")then -dbc:setSize(_ca.getSize())aab=true end end end -if(bca)then -if(aab)then -if -(_cc=="monitor_resize")then -if(type(aca)=="string")then dbc:setSize(_ca.getSize())elseif( -type(aca)=="table")then -for acc,bcc in pairs(aca)do for ccc,dcc in pairs(bcc)do if(p1 ==dcc)then -dbc:setSize(_ca.getSize())end end end end;aab=true;dbc:updateDraw()end end -if(_cc=="peripheral")and(p1 ==aca)then if -(peripheral.getType(aca)=="monitor")then dca=true;_ca=peripheral.wrap(aca)abb=db(_ca) -dbc:updateDraw()end end -if(_cc=="peripheral_detach")and(p1 ==aca)then dca=false end end -if(dda)then if(peripheral.getType(a_b)=="monitor")then __b=true -abb.setMirror(peripheral.wrap(a_b))end;if(_cc=="peripheral_detach")and -(p1 ==a_b)then dca=false end -if -(_cc=="monitor_touch")and(a_b==p1)then dbc:mouseHandler(1,p2,p3,true)end end end,mouseHandler=function(dbc,_cc,acc,bcc,ccc,dcc) -if -(cca)then if(_ca.calculateClick~=nil)then -acc,bcc=_ca.calculateClick(dcc,acc,bcc)end end -if(d_a.mouseHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_click"]~=nil)then -dbc:setCursor(false) -for _dc,adc in ipairs(_ba["mouse_click"])do -if -(daa["mouse_click"][adc]~=nil)then for bdc,cdc in dc(daa["mouse_click"][adc])do -if(cdc.mouseHandler~=nil)then if -(cdc:mouseHandler(_cc,acc,bcc))then return true end end end end end end -if(b_b)then -local _dc,adc=dbc:getAbsolutePosition(dbc:getAnchorPosition())if -(acc>=_dc)and(acc<=_dc+dbc:getWidth()-1)and(bcc==adc)then c_b=true;_da=_dc-acc -ada=yOff and 1 or 0 end end;dbc:removeFocusedObject()return true end;return false end,mouseUpHandler=function(dbc,_cc,acc,bcc)if -(c_b)then c_b=false end -if(d_a.mouseUpHandler(dbc,_cc,acc,bcc))then -if -(daa["mouse_up"]~=nil)then -for ccc,dcc in ipairs(_ba["mouse_up"])do -if(daa["mouse_up"][dcc]~=nil)then -for _dc,adc in -dc(daa["mouse_up"][dcc])do if(adc.mouseUpHandler~=nil)then -if(adc:mouseUpHandler(_cc,acc,bcc))then return true end end end end end end;return true end;return false end,scrollHandler=function(dbc,_cc,acc,bcc) -if -(d_a.scrollHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_scroll"]~=nil)then -for dcc,_dc in pairs(_ba["mouse_scroll"])do -if( -daa["mouse_scroll"][_dc]~=nil)then -for adc,bdc in dc(daa["mouse_scroll"][_dc])do if(bdc.scrollHandler~= -nil)then -if(bdc:scrollHandler(_cc,acc,bcc))then return true end end end end end end;local ccc=bcb -if(bda)then cbc(dbc)if(_cc>0)or(_cc<0)then -bcb=dd(cd(bcb-_cc,0),-cda)dbc:updateDraw()end end;if(bcb==ccc)then return false end;dbc:removeFocusedObject() -return true end;return false end,hoverHandler=function(dbc,_cc,acc,bcc) -if -(d_a.hoverHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_move"]~=nil)then -for ccc,dcc in pairs(_ba["mouse_move"])do -if( -daa["mouse_move"][dcc]~=nil)then for _dc,adc in dc(daa["mouse_move"][dcc])do -if -(adc.hoverHandler~=nil)then if(adc:hoverHandler(_cc,acc,bcc))then return true end end end end end end end;return false end,dragHandler=function(dbc,_cc,acc,bcc) -if -(c_b)then local ccc,dcc=dbc.parent:getOffsetInternal()ccc=ccc<0 and -d_c.abs(ccc)or-ccc;dcc=dcc<0 and d_c.abs(dcc)or- -dcc;local _dc=1;local adc=1;if(dbc.parent~=nil)then -_dc,adc=dbc.parent:getAbsolutePosition(dbc.parent:getAnchorPosition())end -dbc:setPosition( -acc+_da- (_dc-1)+ccc,bcc+ada- (adc-1)+dcc)dbc:updateDraw()return true end -if(dbc:isVisible())and(dbc:isEnabled())then -if -(daa["mouse_drag"]~=nil)then -for ccc,dcc in ipairs(_ba["mouse_drag"])do -if -(daa["mouse_drag"][dcc]~=nil)then for _dc,adc in dc(daa["mouse_drag"][dcc])do -if(adc.dragHandler~=nil)then if -(adc:dragHandler(_cc,acc,bcc))then return true end end end end end end end;d_a.dragHandler(dbc,_cc,acc,bcc)return false end,keyHandler=function(dbc,_cc,acc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local bcc=dbc:getEventSystem():sendEvent("key",dbc,"key",_cc)if(bcc==false)then return false end -if(daa["key"]~=nil)then -for ccc,dcc in pairs(_ba["key"])do -if( -daa["key"][dcc]~=nil)then -for _dc,adc in dc(daa["key"][dcc])do if(adc.keyHandler~=nil)then if -(adc:keyHandler(_cc,acc))then return true end end end end end end end;return false end,keyUpHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("key_up",dbc,"key_up",_cc)if(acc==false)then return false end -if(daa["key_up"]~=nil)then -for bcc,ccc in -pairs(_ba["key_up"])do -if(daa["key_up"][ccc]~=nil)then for dcc,_dc in dc(daa["key_up"][ccc])do -if( -_dc.keyUpHandler~=nil)then if(_dc:keyUpHandler(_cc))then return true end end end end end end end;return false end,charHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("char",dbc,"char",_cc)if(acc==false)then return false end -if(daa["char"]~=nil)then -for bcc,ccc in -pairs(_ba["char"])do -if(daa["char"][ccc]~=nil)then for dcc,_dc in dc(daa["char"][ccc])do -if -(_dc.charHandler~=nil)then if(_dc:charHandler(_cc))then return true end end end end end end end;return false end,setText=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setText(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setText(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,setBG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setBG(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setBG(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,setFG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setFG(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setFG(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,writeText=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:writeText(dd( -_cc+ (_dc-1),_dc),adc+acc-1,bd(bcc,dd(1 -_cc+1,1), -dbc:getWidth()-_cc+1),ccc,dcc)else -abb.writeText(dd(_cc+ (_dc-1),_dc),adc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)),ccc,dcc)end end end,blit=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -local bdc=dbc:getWidth() -if(dbc.parent~=nil)then -bcc=bd(bcc,dd(1 -_cc+1,1),bdc-_cc+1)ccc=bd(ccc,dd(1 -_cc+1,1),bdc-_cc+1)dcc=bd(dcc,dd( -1 -_cc+1,1),bdc-_cc+1) -dbc.parent:blit(dd( -_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)else -bcc=bd(bcc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -ccc=bd(ccc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -dcc=bd(dcc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -abb.blit(dd(_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)end end end,drawBackgroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)else -abb.drawBackgroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)end end,drawTextBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawTextBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,bd(dcc,1,1))else -abb.drawTextBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,bd(dcc,1,1))end end,drawForegroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawForegroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)else -abb.drawForegroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)end end,draw=function(dbc,_cc)if -(bca)and not(dca)then return false end -if(dbc.parent==nil)then if(dbc:getDraw()== -false)then return false end end -if(d_a.draw(dbc))then -local acc,bcc=dbc:getAbsolutePosition(dbc:getAnchorPosition())local ccc,dcc=dbc:getAnchorPosition()local _dc,adc=dbc:getSize() -if( -dbc.parent==nil)then -if(dbc.bgColor~=false)then -abb.drawBackgroundBox(ccc,dcc,_dc,adc,dbc.bgColor)abb.drawTextBox(ccc,dcc,_dc,adc," ")end;if(dbc.fgColor~=false)then -abb.drawForegroundBox(ccc,dcc,_dc,adc,dbc.fgColor)end end -if(dbc.barActive)then -if(dbc.parent~=nil)then -dbc.parent:writeText(ccc,dcc,_c.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)else -abb.writeText(ccc,dcc,_c.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)end -if(dbc:getBorder("left"))then -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc,1,1,dbc.barBackground)if(dbc.bgColor~=false)then -dbc.parent:drawBackgroundBox(ccc-1,dcc+1,1,adc-1,dbc.bgColor)end end end -if(dbc:getBorder("top"))then if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc-1,_dc+1,1,dbc.barBackground)end end end;for bdc,cdc in dc(baa)do -if(aaa[cdc]~=nil)then for ddc,__d in pairs(aaa[cdc])do -if(__d.draw~=nil)then __d:draw()end end end end end end,updateTerm=function(dbc)if -(bca)and not(dca)then return false end;abb.update()end,addObject=function(dbc,_cc)return -cdb(_cc)end,removeObject=__c,getObject=function(dbc,_cc)return adb(_cc)end,getDeepObject=function(dbc,_cc)return bdb(_cc)end,addFrame=function(dbc,_cc)local acc=c_a.newFrame( -_cc or cc(),dbc,nil,c_a)return cdb(acc)end,init=function(dbc) -if -not(cab)then -if(a_a~=nil)then d_a.width,d_a.height=a_a:getSize() -dbc:setBackground(a_a:getTheme("FrameBG")) -dbc:setForeground(a_a:getTheme("FrameText"))else d_a.width,d_a.height=_ca.getSize() -dbc:setBackground(c_a.getTheme("BasaltBG")) -dbc:setForeground(c_a.getTheme("BasaltText"))end;cab=true end end} -for dbc,_cc in pairs(cb)do caa["add"..dbc]=function(acc,bcc) -return cdb(_cc(bcc or cc(),acc))end end;setmetatable(caa,d_a)return caa end end -aa["loadObjects"]=function(...)local ab={}if(ba)then -for db,_c in pairs(_b("objects"))do ab[db]=_c()end;return ab end;local bb=table.pack(...)local cb=fs.getDir( -bb[2]or"Basalt")if(cb==nil)then -error("Unable to find directory "..bb[2].. -" please report this bug to our discord.")end;for db,_c in -pairs(fs.list(fs.combine(cb,"objects")))do -if(_c~="example.lua")then local ac=_c:gsub(".lua","")ab[ac]=da(ac)end end;return ab end -aa["module"]=function(...)return -function(ab)local bb,cb=pcall(da,ab)return bb and cb or nil end end;aa["objects"]={} -aa["objects"]["Checkbox"]=function(...)local ab=da("Object") -local bb=da("utils")local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="Checkbox"_c:setZIndex(5) -_c:setValue(false)_c.width=1;_c.height=1;local bc="\42" -local cc={getType=function(dc)return ac end,setSymbol=function(dc,_d)bc=_d -dc:updateDraw()return dc end,mouseHandler=function(dc,_d,ad,bd) -if(_c.mouseHandler(dc,_d,ad,bd))then -if(_d==1)then -if( -dc:getValue()~=true)and(dc:getValue()~=false)then -dc:setValue(false)else dc:setValue(not dc:getValue())end;dc:updateDraw()return true end end;return false end,touchHandler=function(dc,_d,ad)return -dc:mouseHandler(1,_d,ad)end,setValuesByXMLData=function(dc,_d) -_c.setValuesByXMLData(dc,_d) -if(cb("checked",_d)~=nil)then if(cb("checked",_d))then dc:setValue(true)else -dc:setValue(false)end end;return dc end,draw=function(dc) -if -(_c.draw(dc))then -if(dc.parent~=nil)then local _d,ad=dc:getAnchorPosition() -local bd,cd=dc:getSize()local dd=bb.getTextVerticalAlign(cd,"center")if -(dc.bgColor~=false)then -dc.parent:drawBackgroundBox(_d,ad,bd,cd,dc.bgColor)end -for n=1,cd do -if(n==dd)then -if(dc:getValue()==true)then -dc.parent:writeText(_d, -ad+ (n-1),bb.getTextHorizontalAlign(bc,bd,"center"),dc.bgColor,dc.fgColor)else -dc.parent:writeText(_d,ad+ (n-1),bb.getTextHorizontalAlign(" ",bd,"center"),dc.bgColor,dc.fgColor)end end end end end end,init=function(dc) -dc.parent:addEvent("mouse_click",dc)dc.parent:addEvent("mouse_up",dc) -if(_c.init(dc))then -dc.bgColor=dc.parent:getTheme("CheckboxBG")dc.fgColor=dc.parent:getTheme("CheckboxText")end end}return setmetatable(cc,_c)end end -aa["objects"]["Menubar"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=da("tHex") -return -function(_c)local ac=ab(_c)local bc="Menubar"local cc={}ac.width=30;ac.height=1 -ac:setZIndex(5)local dc={}local _d;local ad;local bd=true;local cd="left"local dd=0;local __a=1;local a_a=false -local function b_a()local c_a=0;local d_a=0 -local _aa=cc:getWidth() -for n=1,#dc do if(d_a+dc[n].text:len()+__a*2 >_aa)then -if( -d_a<_aa)then -c_a=c_a+ (dc[n].text:len()+__a*2 - (_aa-d_a))else c_a=c_a+dc[n].text:len()+__a*2 end end;d_a= -d_a+dc[n].text:len()+__a*2 end;return c_a end -cc={getType=function(c_a)return bc end,addItem=function(c_a,d_a,_aa,aaa,...) -table.insert(dc,{text=tostring(d_a),bgCol=_aa or c_a.bgColor,fgCol=aaa or c_a.fgColor,args={...}})if(#dc==1)then c_a:setValue(dc[1])end -c_a:updateDraw()return c_a end,getAll=function(c_a)return -dc end,getItemIndex=function(c_a)local d_a=c_a:getValue()for _aa,aaa in pairs(dc)do -if(aaa==d_a)then return _aa end end end,clear=function(c_a) -dc={}c_a:setValue({},false)c_a:updateDraw()return c_a end,setSpace=function(c_a,d_a)__a= -d_a or __a;c_a:updateDraw()return c_a end,setOffset=function(c_a,d_a)dd= -d_a or 0;if(dd<0)then dd=0 end;local _aa=b_a()if(dd>_aa)then dd=_aa end -c_a:updateDraw()return c_a end,getOffset=function(c_a)return dd end,setScrollable=function(c_a,d_a) -a_a=d_a;if(d_a==nil)then a_a=true end;return c_a end,setValuesByXMLData=function(c_a,d_a) -ac.setValuesByXMLData(c_a,d_a)if(cb("selectionBG",d_a)~=nil)then -_d=colors[cb("selectionBG",d_a)]end;if(cb("selectionFG",d_a)~=nil)then -ad=colors[cb("selectionFG",d_a)]end;if(cb("scrollable",d_a)~=nil)then -if -(cb("scrollable",d_a))then c_a:setScrollable(true)else c_a:setScrollable(false)end end -if( -cb("offset",d_a)~=nil)then c_a:setOffset(cb("offset",d_a))end -if(cb("space",d_a)~=nil)then __a=cb("space",d_a)end -if(d_a["item"]~=nil)then local _aa=d_a["item"] -if(_aa.properties~=nil)then _aa={_aa}end;for aaa,baa in pairs(_aa)do -c_a:addItem(cb("text",baa),colors[cb("bg",baa)],colors[cb("fg",baa)])end end;return c_a end,removeItem=function(c_a,d_a) -table.remove(dc,d_a)c_a:updateDraw()return c_a end,getItem=function(c_a,d_a) -return dc[d_a]end,getItemCount=function(c_a)return#dc end,editItem=function(c_a,d_a,_aa,aaa,baa,...)table.remove(dc,d_a) -table.insert(dc,d_a,{text=_aa,bgCol= -aaa or c_a.bgColor,fgCol=baa or c_a.fgColor,args={...}})c_a:updateDraw()return c_a end,selectItem=function(c_a,d_a)c_a:setValue( -dc[d_a]or{},false)c_a:updateDraw()return c_a end,setSelectedItem=function(c_a,d_a,_aa,aaa)_d= -d_a or c_a.bgColor;ad=_aa or c_a.fgColor;bd=aaa -c_a:updateDraw()return c_a end,mouseHandler=function(c_a,d_a,_aa,aaa) -if -(ac.mouseHandler(c_a,d_a,_aa,aaa))then -local baa,caa=c_a:getAbsolutePosition(c_a:getAnchorPosition())local daa,_ba=c_a:getSize()local aba=0 -for n=1,#dc do -if(dc[n]~=nil)then -if -(baa+aba<=_aa+dd)and(baa+aba+ -dc[n].text:len()+ (__a*2)>_aa+dd)and(caa==aaa)then -c_a:setValue(dc[n]) -c_a:getEventSystem():sendEvent(event,c_a,event,0,_aa,aaa,dc[n])end;aba=aba+dc[n].text:len()+__a*2 end end;c_a:updateDraw()return true end;return false end,scrollHandler=function(c_a,d_a,_aa,aaa) -if -(ac.scrollHandler(c_a,d_a,_aa,aaa))then if(a_a)then dd=dd+d_a;if(dd<0)then dd=0 end;local baa=b_a()if(dd>baa)then dd=baa end -c_a:updateDraw()end;return true end;return false end,draw=function(c_a) -if -(ac.draw(c_a))then -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -local aaa,baa=c_a:getSize()if(c_a.bgColor~=false)then -c_a.parent:drawBackgroundBox(d_a,_aa,aaa,baa,c_a.bgColor)end;local caa=""local daa=""local _ba="" -for aba,bba in pairs(dc)do -local cba= -(" "):rep(__a)..bba.text.. (" "):rep(__a)caa=caa..cba -if(bba==c_a:getValue())then daa=daa.. -db[_d or bba.bgCol or c_a.bgColor]:rep(cba:len())_ba=_ba.. -db[ -ad or bba.FgCol or c_a.fgColor]:rep(cba:len())else daa=daa.. -db[bba.bgCol or c_a.bgColor]:rep(cba:len())_ba=_ba.. -db[bba.FgCol or c_a.fgColor]:rep(cba:len())end end -c_a.parent:setText(d_a,_aa,caa:sub(dd+1,aaa+dd)) -c_a.parent:setBG(d_a,_aa,daa:sub(dd+1,aaa+dd)) -c_a.parent:setFG(d_a,_aa,_ba:sub(dd+1,aaa+dd))end end end,init=function(c_a) -c_a.parent:addEvent("mouse_click",c_a)c_a.parent:addEvent("mouse_scroll",c_a) -if -(ac.init(c_a))then c_a.bgColor=c_a.parent:getTheme("MenubarBG") -c_a.fgColor=c_a.parent:getTheme("MenubarText")_d=c_a.parent:getTheme("SelectionBG") -ad=c_a.parent:getTheme("SelectionText")end end}return setmetatable(cc,ac)end end -aa["objects"]["Button"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=da("tHex") -return -function(_c)local ac=ab(_c)local bc="Button"local cc="center"local dc="center" -ac:setZIndex(5)ac:setValue("Button")ac.width=12;ac.height=3 -local _d={init=function(ad) -if(ac.init(ad))then -ad.bgColor=ad.parent:getTheme("ButtonBG")ad.fgColor=ad.parent:getTheme("ButtonText")end end,getType=function(ad)return bc end,setHorizontalAlign=function(ad,bd) -cc=bd;ad:updateDraw()return ad end,setVerticalAlign=function(ad,bd)dc=bd -ad:updateDraw()return ad end,setText=function(ad,bd)ac:setValue(bd)ad:updateDraw()return -ad end,setValuesByXMLData=function(ad,bd)ac.setValuesByXMLData(ad,bd) -if( -cb("text",bd)~=nil)then ad:setText(cb("text",bd))end;if(cb("horizontalAlign",bd)~=nil)then -cc=cb("horizontalAlign",bd)end;if(cb("verticalAlign",bd)~=nil)then -dc=cb("verticalAlign",bd)end;return ad end,draw=function(ad) -if -(ac.draw(ad))then -if(ad.parent~=nil)then local bd,cd=ad:getAnchorPosition() -local dd,__a=ad:getSize()local a_a=bb.getTextVerticalAlign(__a,dc) -for n=1,__a do -if(n==a_a)then -local b_a=ad:getValue() -ad.parent:setText(bd+ (dd/2 -b_a:len()/2),cd+ (n-1),bb.getTextHorizontalAlign(b_a,b_a:len(),cc)) -ad.parent:setFG(bd+ (dd/2 -b_a:len()/2),cd+ (n-1),bb.getTextHorizontalAlign(db[ad.fgColor]:rep(b_a:len()),b_a:len(),cc))end end end end end}return setmetatable(_d,ac)end end -aa["objects"]["Animation"]=function(...)local ab=da("utils").getValueFromXML -local bb=da("basaltEvent") -local cb,db,_c,ac,bc,cc=math.floor,math.sin,math.cos,math.pi,math.sqrt,math.pow -local dc=function(cab,dab,_bb)return cab+ (dab-cab)*_bb end;local _d=function(cab)return cab end -local ad=function(cab)return 1 -cab end;local bd=function(cab)return cab*cab*cab end;local cd=function(cab)return -ad(bd(ad(cab)))end;local dd=function(cab)return -dc(bd(cab),cd(cab),cab)end;local __a=function(cab)return -db((cab*ac)/2)end;local a_a=function(cab)return -ad(_c((cab*ac)/2))end;local b_a=function(cab)return -- (_c(ac*x)-1)/2 end -local c_a=function(cab) -local dab=1.70158;local _bb=dab+1;return _bb*cab^3 -dab*cab^2 end;local d_a=function(cab)return cab^3 end -local _aa=function(cab)local dab=(2 *ac)/3;return - -cab==0 and 0 or(cab==1 and 1 or(-2 ^ (10 *cab-10)* -db((cab*10 -10.75)*dab)))end -local function aaa(cab)return cab==0 and 0 or 2 ^ (10 *cab-10)end -local function baa(cab)return cab==0 and 0 or 2 ^ (10 *cab-10)end -local function caa(cab)local dab=1.70158;local _bb=dab*1.525;return -cab<0.5 and( (2 *cab)^2 * -( (_bb+1)*2 *cab-_bb))/2 or -( -(2 *cab-2)^2 * ( (_bb+1)* (cab*2 -2)+_bb)+2)/2 end;local function daa(cab)return -cab<0.5 and 4 *cab^3 or 1 - (-2 *cab+2)^3 /2 end -local function _ba(cab) -local dab=(2 *ac)/4.5 -return -cab==0 and 0 or(cab==1 and 1 or -( -cab<0.5 and- (2 ^ (20 *cab-10)* -db((20 *cab-11.125)*dab))/2 or -(2 ^ (-20 *cab+10)*db((20 *cab-11.125)*dab))/2 +1))end -local function aba(cab)return -cab==0 and 0 or(cab==1 and 1 or -( -cab<0.5 and 2 ^ (20 *cab-10)/2 or(2 -2 ^ (-20 *cab+10))/2))end;local function bba(cab)return -cab<0.5 and 2 *cab^2 or 1 - (-2 *cab+2)^2 /2 end;local function cba(cab)return -cab<0.5 and 8 * -cab^4 or 1 - (-2 *cab+2)^4 /2 end;local function dba(cab)return -cab<0.5 and 16 * -cab^5 or 1 - (-2 *cab+2)^5 /2 end;local function _ca(cab) -return cab^2 end;local function aca(cab)return cab^4 end -local function bca(cab)return cab^5 end;local function cca(cab)local dab=1.70158;local _bb=dab+1;return -1 +_bb* (cab-1)^3 +dab* (cab-1)^2 end;local function dca(cab)return 1 - -(1 -cab)^3 end -local function _da(cab)local dab=(2 *ac)/3;return - -cab==0 and 0 or(cab==1 and 1 or( -2 ^ (-10 *cab)*db((cab*10 -0.75)*dab)+1))end -local function ada(cab)return cab==1 and 1 or 1 -2 ^ (-10 *cab)end;local function bda(cab)return 1 - (1 -cab)* (1 -cab)end;local function cda(cab)return 1 - ( -1 -cab)^4 end;local function dda(cab) -return 1 - (1 -cab)^5 end -local function __b(cab)return 1 -bc(1 -cc(cab,2))end;local function a_b(cab)return bc(1 -cc(cab-1,2))end -local function b_b(cab)return - -cab<0.5 and(1 -bc( -1 -cc(2 *cab,2)))/2 or(bc(1 -cc(-2 *cab+2,2))+1)/2 end -local function c_b(cab)local dab=7.5625;local _bb=2.75 -if(cab<1 /_bb)then return dab*cab*cab elseif(cab<2 /_bb)then local abb=cab- -1.5 /_bb;return dab*abb*abb+0.75 elseif(cab<2.5 /_bb)then local abb=cab- -2.25 /_bb;return dab*abb*abb+0.9375 else -local abb=cab-2.625 /_bb;return dab*abb*abb+0.984375 end end;local function d_b(cab)return 1 -c_b(1 -cab)end;local function _ab(cab)return -x<0.5 and(1 - -c_b(1 -2 *cab))/2 or(1 +c_b(2 *cab-1))/2 end -local aab={linear=_d,lerp=dc,flip=ad,easeIn=bd,easeInSine=a_a,easeInBack=c_a,easeInCubic=d_a,easeInElastic=_aa,easeInExpo=baa,easeInQuad=_ca,easeInQuart=aca,easeInQuint=bca,easeInCirc=__b,easeInBounce=d_b,easeOut=cd,easeOutSine=__a,easeOutBack=cca,easeOutCubic=dca,easeOutElastic=_da,easeOutExpo=ada,easeOutQuad=bda,easeOutQuart=cda,easeOutQuint=dda,easeOutCirc=a_b,easeOutBounce=c_b,easeInOut=dd,easeInOutSine=b_a,easeInOutBack=caa,easeInOutCubic=daa,easeInOutElastic=_ba,easeInOutExpo=aba,easeInOutQuad=bba,easeInOutQuart=cba,easeInOutQuint=dba,easeInOutCirc=b_b,easeInOutBounce=_ab}local bab={} -return -function(cab)local dab={}local _bb="Animation"local abb;local bbb={}local cbb=0;local dbb=false;local _cb=1;local acb=false -local bcb=bb()local ccb=0;local dcb;local _db=false;local adb=false;local bdb="easeOut"local cdb;local function ddb(c_c)for d_c,_ac in pairs(c_c)do -_ac(dab,bbb[_cb].t,_cb)end end -local function __c(c_c)if(_cb==1)then -c_c:animationStartHandler()end;if(bbb[_cb]~=nil)then ddb(bbb[_cb].f) -cbb=bbb[_cb].t end;_cb=_cb+1 -if(bbb[_cb]==nil)then if(acb)then _cb=1;cbb=0 else -c_c:animationDoneHandler()return end end;if(bbb[_cb].t>0)then -abb=os.startTimer(bbb[_cb].t-cbb)else __c(c_c)end end -local function a_c(c_c,d_c)for n=1,#bbb do -if(bbb[n].t==c_c)then table.insert(bbb[n].f,d_c)return end end -for n=1,#bbb do -if(bbb[n].t>c_c)then if -(bbb[n-1]~=nil)then if(bbb[n-1].t=_ac-0.01)then if(bab[dac][dbc]==_bc)then bab[dac][dbc]= -nil end end end end)end end -dab={name=cab,getType=function(c_c)return _bb end,getBaseFrame=function(c_c)if(c_c.parent~=nil)then -return c_c.parent:getBaseFrame()end;return c_c end,setMode=function(c_c,d_c) -bdb=d_c;return c_c end,addMode=function(c_c,d_c,_ac)aab[d_c]=_ac;return c_c end,generateXMLEventFunction=function(c_c,d_c,_ac) -local aac=function(bac) -if( -bac:sub(1,1)=="#")then -local cac=c_c:getBaseFrame():getDeepObject(bac:sub(2,bac:len())) -if(cac~=nil)and(cac.internalObjetCall~=nil)then d_c(c_c,function() -cac:internalObjetCall()end)end else -d_c(c_c,c_c:getBaseFrame():getVariable(bac))end end;if(type(_ac)=="string")then aac(_ac)elseif(type(_ac)=="table")then -for bac,cac in pairs(_ac)do aac(cac)end end;return c_c end,setValuesByXMLData=function(c_c,d_c)_db= -ab("loop",d_c)==true and true or false -if( -ab("object",d_c)~=nil)then -local _ac=c_c:getBaseFrame():getDeepObject(ab("object",d_c))if(_ac==nil)then -_ac=c_c:getBaseFrame():getVariable(ab("object",d_c))end -if(_ac~=nil)then c_c:setObject(_ac)end end -if(d_c["move"]~=nil)then local _ac=ab("x",d_c["move"]) -local aac=ab("y",d_c["move"])local bac=ab("duration",d_c["move"]) -local cac=ab("time",d_c["move"])c_c:move(_ac,aac,bac,cac)end -if(d_c["size"]~=nil)then local _ac=ab("width",d_c["size"]) -local aac=ab("height",d_c["size"])local bac=ab("duration",d_c["size"]) -local cac=ab("time",d_c["size"])c_c:size(_ac,aac,bac,cac)end -if(d_c["offset"]~=nil)then local _ac=ab("x",d_c["offset"]) -local aac=ab("y",d_c["offset"])local bac=ab("duration",d_c["offset"]) -local cac=ab("time",d_c["offset"])c_c:offset(_ac,aac,bac,cac)end -if(d_c["textColor"]~=nil)then -local _ac=ab("duration",d_c["textColor"])local aac=ab("time",d_c["textColor"])local bac={} -local cac=d_c["textColor"]["color"] -if(cac~=nil)then if(cac.properties~=nil)then cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,colors[_bc:value()])end end;if(_ac~=nil)and(#bac>0)then -c_c:changeTextColor(_ac,aac or 0,table.unpack(bac))end end -if(d_c["background"]~=nil)then -local _ac=ab("duration",d_c["background"])local aac=ab("time",d_c["background"])local bac={} -local cac=d_c["background"]["color"] -if(cac~=nil)then if(cac.properties~=nil)then cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,colors[_bc:value()])end end;if(_ac~=nil)and(#bac>0)then -c_c:changeBackground(_ac,aac or 0,table.unpack(bac))end end -if(d_c["text"]~=nil)then local _ac=ab("duration",d_c["text"]) -local aac=ab("time",d_c["text"])local bac={}local cac=d_c["text"]["text"] -if(cac~=nil)then if(cac.properties~=nil)then -cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,_bc:value())end end;if(_ac~=nil)and(#bac>0)then -c_c:changeText(_ac,aac or 0,table.unpack(bac))end end;if(ab("onDone",d_c)~=nil)then -c_c:generateXMLEventFunction(c_c.onDone,ab("onDone",d_c))end;if(ab("onStart",d_c)~=nil)then -c_c:generateXMLEventFunction(c_c.onDone,ab("onStart",d_c))end -if -(ab("autoDestroy",d_c)~=nil)then if(ab("autoDestroy",d_c))then adb=true end end;bdb=ab("mode",d_c)or bdb -if(ab("play",d_c)~=nil)then if -(ab("play",d_c))then c_c:play(_db)end end;return c_c end,getZIndex=function(c_c)return -1 end,getName=function(c_c)return c_c.name end,setObject=function(c_c,d_c)cdb=d_c;return c_c end,move=function(c_c,d_c,_ac,aac,bac,cac)cdb= -cac or cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getPosition,cdb.setPosition,"position",c_c)return c_c end,offset=function(c_c,d_c,_ac,aac,bac,cac)cdb= -cac or cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getOffset,cdb.setOffset,"offset",c_c)return c_c end,size=function(c_c,d_c,_ac,aac,bac,cac)cdb=cac or -cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getSize,cdb.setSize,"size",c_c)return c_c end,changeText=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setText(cdb,aac[n])end)end;return c_c end,changeBackground=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setBackground(cdb,aac[n])end)end;return c_c end,changeTextColor=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setForeground(cdb,aac[n])end)end;return c_c end,add=function(c_c,d_c,_ac) -dcb=d_c -a_c((_ac or ccb)+ -(bbb[#bbb]~=nil and bbb[#bbb].t or 0),d_c)return c_c end,wait=function(c_c,d_c)ccb=d_c;return c_c end,rep=function(c_c,d_c) -if( -dcb~=nil)then for n=1,d_c or 1 do -a_c((wait or ccb)+ -(bbb[#bbb]~=nil and bbb[#bbb].t or 0),dcb)end end;return c_c end,onDone=function(c_c,d_c) -bcb:registerEvent("animation_done",d_c)return c_c end,onStart=function(c_c,d_c) -bcb:registerEvent("animation_start",d_c)return c_c end,setAutoDestroy=function(c_c,d_c) -adb=d_c~=nil and d_c or true;return c_c end,animationDoneHandler=function(c_c) -bcb:sendEvent("animation_done",c_c)c_c.parent:removeEvent("other_event",c_c)if(adb)then -c_c.parent:removeObject(c_c)c_c=nil end end,animationStartHandler=function(c_c) -bcb:sendEvent("animation_start",c_c)end,clear=function(c_c)bbb={}dcb=nil;ccb=0;_cb=1;cbb=0;acb=false;return c_c end,play=function(c_c,d_c) -c_c:cancel()dbb=true;acb=d_c and true or false;_cb=1;cbb=0 -if(bbb[_cb]~=nil)then -if( -bbb[_cb].t>0)then abb=os.startTimer(bbb[_cb].t)else __c(c_c)end else c_c:animationDoneHandler()end;c_c.parent:addEvent("other_event",c_c)return c_c end,cancel=function(c_c)if( -abb~=nil)then os.cancelTimer(abb)acb=false end -dbb=false;c_c.parent:removeEvent("other_event",c_c)return c_c end,internalObjetCall=function(c_c) -c_c:play(_db)end,eventHandler=function(c_c,d_c,_ac)if(dbb)then -if(d_c=="timer")and(_ac==abb)then if(bbb[_cb]~=nil)then -__c(c_c)else c_c:animationDoneHandler()end end end end}dab.__index=dab;return dab end end -aa["objects"]["List"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="List"_c.width=16;_c.height=6;_c:setZIndex(5)local bc={} -local cc;local dc;local _d=true;local ad="left"local bd=0;local cd=true -local dd={getType=function(__a)return ac end,addItem=function(__a,a_a,b_a,c_a,...) -table.insert(bc,{text=a_a,bgCol=b_a or __a.bgColor,fgCol= -c_a or __a.fgColor,args={...}})if(#bc<=1)then __a:setValue(bc[1],false)end -__a:updateDraw()return __a end,setOffset=function(__a,a_a) -bd=a_a;__a:updateDraw()return __a end,getOffset=function(__a)return bd end,removeItem=function(__a,a_a) -table.remove(bc,a_a)__a:updateDraw()return __a end,getItem=function(__a,a_a) -return bc[a_a]end,getAll=function(__a)return bc end,getItemIndex=function(__a)local a_a=__a:getValue()for b_a,c_a in pairs(bc)do if -(c_a==a_a)then return b_a end end end,clear=function(__a) -bc={}__a:setValue({},false)__a:updateDraw()return __a end,getItemCount=function(__a)return -#bc end,editItem=function(__a,a_a,b_a,c_a,d_a,...)table.remove(bc,a_a) -table.insert(bc,a_a,{text=b_a,bgCol=c_a or __a.bgColor,fgCol= -d_a or __a.fgColor,args={...}})__a:updateDraw()return __a end,selectItem=function(__a,a_a)__a:setValue( -bc[a_a]or{},false)__a:updateDraw()return __a end,setSelectedItem=function(__a,a_a,b_a,c_a)cc= -a_a or __a.bgColor;dc=b_a or __a.fgColor;_d=c_a~=nil and c_a or -true;__a:updateDraw()return __a end,setScrollable=function(__a,a_a) -cd=a_a;if(a_a==nil)then cd=true end;__a:updateDraw()return __a end,setValuesByXMLData=function(__a,a_a) -_c.setValuesByXMLData(__a,a_a)if(cb("selectionBG",a_a)~=nil)then -cc=colors[cb("selectionBG",a_a)]end;if(cb("selectionFG",a_a)~=nil)then -dc=colors[cb("selectionFG",a_a)]end;if(cb("scrollable",a_a)~=nil)then -if -(cb("scrollable",a_a))then __a:setScrollable(true)else __a:setScrollable(false)end end;if( -cb("offset",a_a)~=nil)then bd=cb("offset",a_a)end -if(a_a["item"]~= -nil)then local b_a=a_a["item"] -if(b_a.properties~=nil)then b_a={b_a}end;for c_a,d_a in pairs(b_a)do -__a:addItem(cb("text",d_a),colors[cb("bg",d_a)],colors[cb("fg",d_a)])end end;return __a end,scrollHandler=function(__a,a_a,b_a,c_a) -if -(_c.scrollHandler(__a,a_a,b_a,c_a))then -if(cd)then local d_a,_aa=__a:getSize()bd=bd+a_a;if(bd<0)then bd=0 end -if(a_a>=1)then if(#bc>_aa)then if(bd> -#bc-_aa)then bd=#bc-_aa end;if(bd>=#bc)then bd=#bc-1 end else bd= -bd-1 end end;__a:updateDraw()end;return true end;return false end,mouseHandler=function(__a,a_a,b_a,c_a) -if -(_c.mouseHandler(__a,a_a,b_a,c_a))then -local d_a,_aa=__a:getAbsolutePosition(__a:getAnchorPosition())local aaa,baa=__a:getSize() -if(#bc>0)then for n=1,baa do -if(bc[n+bd]~=nil)then if(d_a<=b_a)and -(d_a+aaa>b_a)and(_aa+n-1 ==c_a)then -__a:setValue(bc[n+bd])__a:updateDraw()end end end end;return true end;return false end,dragHandler=function(__a,a_a,b_a,c_a)return -__a:mouseHandler(a_a,b_a,c_a)end,touchHandler=function(__a,a_a,b_a)return -__a:mouseHandler(1,a_a,b_a)end,draw=function(__a) -if(_c.draw(__a))then -if -(__a.parent~=nil)then local a_a,b_a=__a:getAnchorPosition()local c_a,d_a=__a:getSize()if( -__a.bgColor~=false)then -__a.parent:drawBackgroundBox(a_a,b_a,c_a,d_a,__a.bgColor)end -for n=1,d_a do -if(bc[n+bd]~=nil)then -if(bc[n+bd]== -__a:getValue())then -if(_d)then -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),cc,dc)else -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end else -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end end end end end end,init=function(__a) -__a.parent:addEvent("mouse_click",__a)__a.parent:addEvent("mouse_drag",__a) -__a.parent:addEvent("mouse_scroll",__a) -if(_c.init(__a))then __a.bgColor=__a.parent:getTheme("ListBG") -__a.fgColor=__a.parent:getTheme("ListText")cc=__a.parent:getTheme("SelectionBG") -dc=__a.parent:getTheme("SelectionText")end end}return setmetatable(dd,_c)end end -aa["objects"]["Graphic"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("utils").getValueFromXML;local db=da("bimg")local _c=da("images") -local ac,bc,cc,dc=string.sub,string.len,math.max,math.min -return -function(_d)local ad=ab(_d)local bd="Graphic"local cd=db()local dd=cd.getFrameObject(1)local __a -local a_a=1;ad:setZIndex(5)local b_a,c_a=0,0 -local d_a={getType=function(_aa)return bd end,setOffset=function(_aa,aaa,baa,caa) -if(caa)then -b_a=b_a+aaa or 0;c_a=c_a+baa or 0 else b_a=aaa or b_a;c_a=baa or c_a end;_aa:updateDraw()return _aa end,getOffset=function(_aa)return -b_a,c_a end,setValuesByXMLData=function(_aa,aaa)ad.setValuesByXMLData(_aa,aaa)return _aa end,selectFrame=function(_aa,aaa)if( -cd.getFrameObject(aaa)==nil)then cd.addFrame(aaa)end -dd=cd.getFrameObject(aaa)__a=dd.getImage(aaa)a_a=aaa;_aa:updateDraw()end,addFrame=function(_aa,aaa) -cd.addFrame(aaa)return _aa end,getFrameMetadata=function(_aa,aaa,baa)return cd.getFrameData(aaa,baa)end,setFrameMetadata=function(_aa,aaa,baa,caa) -cd.setFrameData(aaa,baa,caa)return _aa end,getMetadata=function(_aa,aaa)return cd.getMetadata(aaa)end,setMetadata=function(_aa,aaa,baa)return -cd.setMetadata(aaa,baa)end,getFrame=function(_aa,aaa)return cd.getFrame(aaa)end,getFrameObject=function(_aa,aaa)return -cd.getFrameObject(aaa)end,removeFrame=function(_aa,aaa)cd.removeFrame(aaa)return _aa end,moveFrame=function(_aa,aaa,baa) -cd.moveFrame(aaa,baa)return _aa end,getFrames=function(_aa)return cd.getFrames()end,getFrameCount=function(_aa)return -#cd.getFrames()end,getSelectedFrame=function(_aa)return a_a end,blit=function(_aa,aaa,baa,caa,daa,_ba) -x=daa or x;y=_ba or y;dd.blit(aaa,baa,caa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setText=function(_aa,aaa,baa,caa) -x=baa or x;y=caa or y;dd.text(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setBg=function(_aa,aaa,baa,caa)x=baa or x;y= -caa or y;dd.bg(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setFg=function(_aa,aaa,baa,caa)x=baa or x;y=caa or -y;dd.fg(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,getImageSize=function(_aa) -return cd.getSize()end,setImageSize=function(_aa,aaa,baa)cd.setSize(aaa,baa)__a=dd.getImage() -_aa:updateDraw()return _aa end,resizeImage=function(_aa,aaa,baa) -local caa=_c.resizeBIMG(cd.createBimg(),aaa,baa)cd=db(caa)a_a=1;dd=cd.getFrameObject(1)__a=dd.getImage() -_aa:updateDraw()return _aa end,loadImage=function(_aa,aaa) -if -(fs.exists(aaa))then local baa=_c.loadBIMG(aaa)cd=db(baa)a_a=1 -dd=cd.getFrameObject(1)__a=dd.getImage()_aa:updateDraw()end;return _aa end,clear=function(_aa) -cd=db()__a=nil;_aa:updateDraw()return _aa end,getImage=function(_aa)return -cd.createBimg()end,draw=function(_aa) -if(ad.draw(_aa))then -if(_aa.parent~=nil)then -local aaa,baa=_aa:getAnchorPosition()local caa,daa=_aa:getSize() -if(__a~=nil)then -for _ba,aba in pairs(__a)do if -(_ba<=daa-c_a)and(_ba+c_a>=1)then -_aa.parent:blit(aaa+b_a,baa+_ba-1 +c_a,aba[1],aba[2],aba[3])end end end end end end,init=function(_aa) -if -(ad.init(_aa))then _aa.bgColor=_aa.parent:getTheme("GraphicBG")end end}return setmetatable(d_a,ad)end end -aa["objects"]["Image"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML;local cb=da("images")local db,_c=table.unpack,string.sub -return -function(ac)local bc=ab(ac) -local cc="Image"bc:setZIndex(2)local dc;local _d;local ad=1;local bd=false;local cd;local dd=false;bc.width=24 -bc.height=8 -local function __a(b_a) -if(dc~=nil)then local c_a={} -for d_a,_aa in pairs(colors)do if(type(_aa)=="number")then -c_a[d_a]={term.nativePaletteColor(_aa)}end end;if(dc.palette~=nil)then -for d_a,_aa in pairs(dc.palette)do c_a[d_a]=tonumber(_aa)end end -if(dc[b_a]~=nil)and -(dc[b_a].palette~=nil)then for d_a,_aa in pairs(dc[b_a].palette)do -c_a[d_a]=tonumber(_aa)end end;return c_a end end -local a_a={init=function(b_a)if(bc.init(b_a))then -b_a.bgColor=b_a.parent:getTheme("ImageBG")end end,getType=function(b_a)return -cc end,loadImage=function(b_a,c_a,d_a)if not(fs.exists(c_a))then -error("No valid path: "..c_a)end;dc=cb.loadImageAsBimg(c_a,d_a) -ad=1;_d=dc;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()return b_a end,setImage=function(b_a,c_a) -dc=c_a;_d=dc;ad=1;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()return b_a end,usePalette=function(b_a,c_a)dd= -c_a~=nil and c_a or true;return b_a end,play=function(b_a,c_a) -if(dc.animated)then -local d_a= -dc[ad].duration or dc.secondsPerFrame or 0.2;b_a.parent:addEvent("other_event",b_a) -cd=os.startTimer(d_a)bd=c_a or false end;return b_a end,selectFrame=function(b_a,c_a)if( -dc[c_a]~=nil)then ad=c_a;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()end end,eventHandler=function(b_a,c_a,d_a,...) -bc.eventHandler(b_a,c_a,d_a,...) -if(c_a=="timer")then -if(d_a==cd)then -if(dc[ad+1]~=nil)then ad=ad+1;local _aa= -dc[ad].duration or dc.secondsPerFrame or 0.2 -cd=os.startTimer(_aa)else -if(bd)then ad=1 -local _aa=dc[ad].duration or dc.secondsPerFrame or 0.2;cd=os.startTimer(_aa)end end;b_a:updateDraw()end end end,getMetadata=function(b_a,c_a)return -dc[c_a]end,getImageSize=function(b_a)return dc.width,dc.height end,resizeImage=function(b_a,c_a,d_a) -_d=cb.resizeBIMG(dc,c_a,d_a)b_a:updateDraw()return b_a end,setValuesByXMLData=function(b_a,c_a) -bc.setValuesByXMLData(b_a,c_a) -if(bb("path",c_a)~=nil)then b_a:loadImage(bb("path",c_a))end;return b_a end,draw=function(b_a) -if -(bc.draw(b_a))then -if(_d~=nil)then if(dd)then -b_a:getBaseFrame():setThemeColor(__a(ad))end;local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize() -for baa,caa in ipairs(_d[ad])do local daa,_ba,aba=db(caa)daa=_c(daa,1,_aa) -_ba=_c(_ba,1,_aa)aba=_c(aba,1,_aa) -b_a.parent:blit(c_a,d_a+baa-1,daa,_ba,aba)if(baa==aaa)then break end end end end end}return setmetatable(a_a,bc)end end -aa["objects"]["Input"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=da("basaltLogs")local db=bb.getValueFromXML -return -function(_c)local ac=ab(_c)local bc="Input"local cc="text"local dc=0 -ac:setZIndex(5)ac:setValue("")ac.width=10;ac.height=1;local _d=1;local ad=1;local bd=""local cd;local dd -local __a=bd;local a_a=false -local b_a={getType=function(c_a)return bc end,setInputType=function(c_a,d_a)if(d_a=="password")or(d_a=="number")or(d_a== -"text")then cc=d_a end -c_a:updateDraw()return c_a end,setDefaultText=function(c_a,d_a,_aa,aaa)bd=d_a -cd=aaa or cd;dd=_aa or dd;if(c_a:isFocused())then __a=""else __a=bd end -c_a:updateDraw()return c_a end,getInputType=function(c_a) -return cc end,setValue=function(c_a,d_a)ac.setValue(c_a,tostring(d_a)) -if not(a_a)then _d= -tostring(d_a):len()+1 -ad=math.max(1,_d-c_a:getWidth()+1)if(c_a:isFocused())then local _aa,aaa=c_a:getAnchorPosition() -c_a.parent:setCursor(true, -_aa+_d-ad,aaa+math.floor(c_a:getHeight()/2),c_a.fgColor)end end;c_a:updateDraw()return c_a end,getValue=function(c_a) -local d_a=ac.getValue(c_a) -return cc=="number"and tonumber(d_a)or d_a end,setInputLimit=function(c_a,d_a) -dc=tonumber(d_a)or dc;c_a:updateDraw()return c_a end,getInputLimit=function(c_a)return dc end,setValuesByXMLData=function(c_a,d_a) -ac.setValuesByXMLData(c_a,d_a)local _aa,aaa -if(db("defaultBG",d_a)~=nil)then _aa=db("defaultBG",d_a)end -if(db("defaultFG",d_a)~=nil)then aaa=db("defaultFG",d_a)end;if(db("default",d_a)~=nil)then -c_a:setDefaultText(db("default",d_a),aaa~=nil and colors[aaa], -_aa~=nil and colors[_aa])end -if(db("limit",d_a)~= -nil)then c_a:setInputLimit(db("limit",d_a))end;if(db("type",d_a)~=nil)then -c_a:setInputType(db("type",d_a))end;return c_a end,getFocusHandler=function(c_a) -ac.getFocusHandler(c_a) -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition()__a=""if(bd~="")then -c_a:updateDraw()end -c_a.parent:setCursor(true,d_a+_d-ad,_aa+math.max(math.ceil( -c_a:getHeight()/2 -1,1)),c_a.fgColor)end end,loseFocusHandler=function(c_a) -ac.loseFocusHandler(c_a)if(c_a.parent~=nil)then __a=bd;if(bd~="")then c_a:updateDraw()end -c_a.parent:setCursor(false)end end,keyHandler=function(c_a,d_a) -if -(ac.keyHandler(c_a,d_a))then local _aa,aaa=c_a:getSize()a_a=true -if(d_a==keys.backspace)then -local bba=tostring(ac.getValue())if(_d>1)then -c_a:setValue(bba:sub(1,_d-2)..bba:sub(_d,bba:len()))if(_d>1)then _d=_d-1 end -if(ad>1)then if(_dbba)then _d=bba+1 end;if(_d<1)then _d=1 end;if -(_d=_aa+ad)then ad=_d-_aa+1 end;if(ad<1)then ad=1 end end -if(d_a==keys.left)then _d=_d-1;if(_d>=1)then -if(_d=_aa+ad)then ad=_d end end;if(_d<1)then _d=1 end;if(ad<1)then ad=1 end end;local baa,caa=c_a:getAnchorPosition() -local daa=tostring(ac.getValue()) -local _ba=(_d<=daa:len()and _d-1 or daa:len())- (ad-1)local aba=c_a:getX() -if(_ba>aba+_aa-1)then _ba=aba+_aa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,baa+_ba,caa+ -math.max(math.ceil(aaa/2 -1,1)),c_a.fgColor)end -c_a:updateDraw()a_a=false;return true end;return false end,charHandler=function(c_a,d_a) -if -(ac.charHandler(c_a,d_a))then a_a=true;local _aa,aaa=c_a:getSize()local baa=ac.getValue() -if( -baa:len()0)then -if( -tonumber(ac.getValue())==nil)then c_a:setValue(cba)_d=_d-1 end end end else -c_a:setValue(baa:sub(1,_d-1)..d_a..baa:sub(_d,baa:len()))_d=_d+1 end;if(_d>=_aa+ad)then ad=ad+1 end end;local caa,daa=c_a:getAnchorPosition() -local _ba=tostring(ac.getValue()) -local aba=(_d<=_ba:len()and _d-1 or _ba:len())- (ad-1)local bba=c_a:getX() -if(aba>bba+_aa-1)then aba=bba+_aa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,caa+aba,daa+ -math.max(math.ceil(aaa/2 -1,1)),c_a.fgColor)end;a_a=false -c_a:updateDraw()return true end;return false end,mouseHandler=function(c_a,d_a,_aa,aaa) -if -(ac.mouseHandler(c_a,d_a,_aa,aaa))then local baa,caa=c_a:getAnchorPosition() -local daa,_ba=c_a:getAbsolutePosition(baa,caa)local aba,bba=c_a:getSize()_d=_aa-daa+ad;local cba=ac.getValue()if(_d> -cba:len())then _d=cba:len()+1 end;if(_d=baa+ad)then ad=(_d+1)-baa end -local daa,_ba=c_a:getAnchorPosition()local aba=tostring(ac.getValue()) -local bba=( -_d<=aba:len()and _d-1 or aba:len())- (ad-1)local cba=c_a:getX() -if(bba>cba+baa-1)then bba=cba+baa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,daa+bba,_ba+ -math.max(math.ceil(caa/2 -1,1)),c_a.fgColor)end -c_a:updateDraw()a_a=false end end end,draw=function(c_a) -if -(ac.draw(c_a))then -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -local aaa,baa=c_a:getSize()local caa=bb.getTextVerticalAlign(baa,"center")if -(c_a.bgColor~=false)then -c_a.parent:drawBackgroundBox(d_a,_aa,aaa,baa,c_a.bgColor)end -for n=1,baa do -if(n==caa)then -local daa=tostring(ac.getValue())local _ba=c_a.bgColor;local aba=c_a.fgColor;local bba;if(daa:len()<=0)then bba=__a -_ba=cd or _ba;aba=dd or aba end;bba=__a -if(daa~="")then bba=daa end;bba=bba:sub(ad,aaa+ad-1)local cba=aaa-bba:len()if(cba<0)then -cba=0 end;if(cc=="password")and(daa~="")then -bba=string.rep("*",bba:len())end -bba=bba..string.rep(c_a.bgSymbol,cba) -c_a.parent:writeText(d_a,_aa+ (n-1),bba,_ba,aba)end end;if(c_a:isFocused())then -c_a.parent:setCursor(true,d_a+_d-ad,_aa+ -math.floor(c_a:getHeight()/2),c_a.fgColor)end end end end,init=function(c_a) -if( -c_a.parent~=nil)then c_a.parent:addEvent("mouse_click",c_a) -c_a.parent:addEvent("key",c_a)c_a.parent:addEvent("char",c_a) -c_a.parent:addEvent("other_event",c_a)c_a.parent:addEvent("mouse_drag",c_a)end -if(ac.init(c_a))then -c_a.bgColor=c_a.parent:getTheme("InputBG")c_a.fgColor=c_a.parent:getTheme("InputText")end end}return setmetatable(b_a,ac)end end -aa["objects"]["Label"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=bb.createText;local _c=da("tHex")local ac=da("bigfont") -return -function(bc)local cc=ab(bc) -local dc="Label"cc:setZIndex(3)local _d=true;cc:setValue("Label")cc.width=5 -local ad="left"local bd="top"local cd=0;local dd,__a=false,false -local a_a={getType=function(b_a)return dc end,setText=function(b_a,c_a)c_a=tostring(c_a) -cc:setValue(c_a) -if(_d)then local d_a=b_a.parent:getOffset() -if( -c_a:len()+b_a:getX()>b_a.parent:getWidth()+d_a)then local _aa= -b_a.parent:getWidth()+d_a-b_a:getX()cc.setSize(b_a,_aa, -#db(c_a,_aa))else -cc.setSize(b_a,c_a:len(),1)end end;b_a:updateDraw()return b_a end,setBackground=function(b_a,c_a) -cc.setBackground(b_a,c_a)__a=true;b_a:updateDraw()return b_a end,setForeground=function(b_a,c_a) -cc.setForeground(b_a,c_a)dd=true;b_a:updateDraw()return b_a end,setTextAlign=function(b_a,c_a,d_a)ad= -c_a or ad;bd=d_a or bd;b_a:updateDraw()return b_a end,setFontSize=function(b_a,c_a)if( -c_a>0)and(c_a<=4)then cd=c_a-1 or 0 end -b_a:updateDraw()return b_a end,getFontSize=function(b_a)return cd+1 end,setValuesByXMLData=function(b_a,c_a) -cc.setValuesByXMLData(b_a,c_a) -if(cb("text",c_a)~=nil)then b_a:setText(cb("text",c_a))end -if(cb("verticalAlign",c_a)~=nil)then bd=cb("verticalAlign",c_a)end;if(cb("horizontalAlign",c_a)~=nil)then -ad=cb("horizontalAlign",c_a)end;if(cb("font",c_a)~=nil)then -b_a:setFontSize(cb("font",c_a))end;return b_a end,setSize=function(b_a,c_a,d_a,_aa) -cc.setSize(b_a,c_a,d_a,_aa)_d=false;b_a:updateDraw()return b_a end,eventHandler=function(b_a,c_a) -if( -c_a=="basalt_resize")then -if(_d)then local d_a=b_a:getValue() -if( -d_a:len()+b_a:getX()>b_a.parent:getWidth())then local _aa= -b_a.parent:getWidth()-b_a:getX() -cc.setSize(b_a,_aa,#db(d_a,_aa))else cc.setSize(b_a,d_a:len(),1)end else end end end,draw=function(b_a) -if -(cc.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize()local baa=bb.getTextVerticalAlign(aaa,bd) -if(cd==0)then -if not(_d)then -local caa=db(b_a:getValue(),b_a:getWidth()) -for daa,_ba in pairs(caa)do if(daa<=aaa)then -b_a.parent:writeText(c_a,d_a+daa-1,_ba,b_a.bgColor,b_a.fgColor)end end else -if -(#b_a:getValue()+c_a>b_a.parent:getWidth())then local caa=db(b_a:getValue(),b_a:getWidth()) -for daa,_ba in -pairs(caa)do if(daa<=aaa)then -b_a.parent:writeText(c_a,d_a+daa-1,_ba,b_a.bgColor,b_a.fgColor)end end else -b_a.parent:writeText(c_a,d_a,b_a:getValue(),b_a.bgColor,b_a.fgColor)end end else -local caa=ac(cd,b_a:getValue(),b_a.fgColor,b_a.bgColor or colors.lightGray) -if(_d)then b_a:setSize(#caa[1][1],#caa[1]-1)end;local daa,_ba=b_a.parent:getSize() -local aba,bba=#caa[1][1],#caa[1] -c_a=c_a or math.floor((daa-aba)/2)+1 -d_a=d_a or math.floor((_ba-bba)/2)+1 -for i=1,bba do -b_a.parent:setFG(c_a,d_a+i-1,caa[2][i])b_a.parent:setBG(c_a,d_a+i-1,caa[3][i])b_a.parent:setText(c_a, -d_a+i-1,caa[1][i])end end end end end,init=function(b_a) -b_a.parent:addEvent("other_event",b_a) -if(cc.init(b_a))then -b_a.bgColor=b_a.parent:getTheme("LabelBG")b_a.fgColor=b_a.parent:getTheme("LabelText") -if -( -b_a.parent.bgColor==colors.black)and(b_a.fgColor==colors.black)then b_a.fgColor=colors.lightGray end end end}return setmetatable(a_a,cc)end end -aa["objects"]["Dropdown"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=da("utils").getValueFromXML -return -function(db)local _c=ab(db)local ac="Dropdown"_c.width=12;_c.height=1;_c:setZIndex(6) -local bc={}local cc;local dc;local _d=true;local ad="left"local bd=0;local cd=16;local dd=6;local __a="\16"local a_a="\31"local b_a=false -local c_a={getType=function(d_a)return -ac end,setValuesByXMLData=function(d_a,_aa)_c.setValuesByXMLData(d_a,_aa) -if( -cb("selectionBG",_aa)~=nil)then cc=colors[cb("selectionBG",_aa)]end;if(cb("selectionFG",_aa)~=nil)then -dc=colors[cb("selectionFG",_aa)]end;if(cb("dropdownWidth",_aa)~=nil)then -cd=cb("dropdownWidth",_aa)end;if(cb("dropdownHeight",_aa)~=nil)then -dd=cb("dropdownHeight",_aa)end;if(cb("offset",_aa)~=nil)then -bd=cb("offset",_aa)end -if(_aa["item"]~=nil)then local aaa=_aa["item"]if( -aaa.properties~=nil)then aaa={aaa}end;for baa,caa in pairs(aaa)do -d_a:addItem(cb("text",caa),colors[cb("bg",caa)],colors[cb("fg",caa)])end end end,setOffset=function(d_a,_aa) -bd=_aa;d_a:updateDraw()return d_a end,getOffset=function(d_a)return bd end,addItem=function(d_a,_aa,aaa,baa,...) -table.insert(bc,{text=_aa,bgCol= -aaa or d_a.bgColor,fgCol=baa or d_a.fgColor,args={...}})d_a:updateDraw()return d_a end,getAll=function(d_a)return -bc end,removeItem=function(d_a,_aa)table.remove(bc,_aa)d_a:updateDraw() -return d_a end,getItem=function(d_a,_aa)return bc[_aa]end,getItemIndex=function(d_a) -local _aa=d_a:getValue()for aaa,baa in pairs(bc)do if(baa==_aa)then return aaa end end end,clear=function(d_a) -bc={}d_a:setValue({},false)d_a:updateDraw()return d_a end,getItemCount=function(d_a)return -#bc end,editItem=function(d_a,_aa,aaa,baa,caa,...)table.remove(bc,_aa) -table.insert(bc,_aa,{text=aaa,bgCol=baa or d_a.bgColor,fgCol= -caa or d_a.fgColor,args={...}})d_a:updateDraw()return d_a end,selectItem=function(d_a,_aa)d_a:setValue( -bc[_aa]or{},false)d_a:updateDraw()return d_a end,setSelectedItem=function(d_a,_aa,aaa,baa)cc= -_aa or d_a.bgColor;dc=aaa or d_a.fgColor -_d=baa~=nil and baa;d_a:updateDraw()return d_a end,setDropdownSize=function(d_a,_aa,aaa) -cd,dd=_aa,aaa;d_a:updateDraw()return d_a end,getDropdownSize=function(d_a)return cd,dd end,mouseHandler=function(d_a,_aa,aaa,baa) -if -(b_a)then -local caa,daa=d_a:getAbsolutePosition(d_a:getAnchorPosition()) -if(_aa==1)then -if(#bc>0)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(caa<=aaa)and(caa+cd>aaa)and -(daa+n==baa)then d_a:setValue(bc[n+bd]) -d_a:updateDraw() -local _ba=d_a:getEventSystem():sendEvent("mouse_click",d_a,"mouse_click",dir,aaa,baa)if(_ba==false)then return _ba end;return true end end end end end end -if(_c.mouseHandler(d_a,_aa,aaa,baa))then b_a=(not b_a)d_a:updateDraw() -return true else if(b_a)then d_a:updateDraw()b_a=false end;return false end end,mouseUpHandler=function(d_a,_aa,aaa,baa) -if -(b_a)then -local caa,daa=d_a:getAbsolutePosition(d_a:getAnchorPosition()) -if(_aa==1)then -if(#bc>0)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(caa<=aaa)and(caa+cd>aaa)and -(daa+n==baa)then b_a=false;d_a:updateDraw() -local _ba=d_a:getEventSystem():sendEvent("mouse_up",d_a,"mouse_up",dir,aaa,baa)if(_ba==false)then return _ba end;return true end end end end end end end,scrollHandler=function(d_a,_aa,aaa,baa) -if -(b_a)and(d_a:isFocused())then bd=bd+_aa;if(bd<0)then bd=0 end;if(_aa==1)then -if(#bc>dd)then if(bd> -#bc-dd)then bd=#bc-dd end else bd=math.min(#bc-1,0)end end -local caa=d_a:getEventSystem():sendEvent("mouse_scroll",d_a,"mouse_scroll",_aa,aaa,baa)if(caa==false)then return caa end;d_a:updateDraw()return true end end,draw=function(d_a) -if -(_c.draw(d_a))then local _aa,aaa=d_a:getAnchorPosition()local baa,caa=d_a:getSize() -if( -d_a.parent~=nil)then if(d_a.bgColor~=false)then -d_a.parent:drawBackgroundBox(_aa,aaa,baa,caa,d_a.bgColor)end;local daa=d_a:getValue() -local _ba=bb.getTextHorizontalAlign(( -daa~=nil and daa.text or""),baa,ad):sub(1, -baa-1).. (b_a and a_a or __a) -d_a.parent:writeText(_aa,aaa,_ba,d_a.bgColor,d_a.fgColor) -if(b_a)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(bc[n+bd]==daa)then -if(_d)then -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[ -n+bd].text,cd,ad),cc,dc)else -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[n+bd].text,cd,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end else -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[n+bd].text,cd,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end end end end end end end,init=function(d_a) -d_a.parent:addEvent("mouse_click",d_a)d_a.parent:addEvent("mouse_up",d_a) -d_a.parent:addEvent("mouse_scroll",d_a) -if(_c.init(d_a))then -d_a.bgColor=d_a.parent:getTheme("DropdownBG")d_a.fgColor=d_a.parent:getTheme("DropdownText") -cc=d_a.parent:getTheme("SelectionBG")dc=d_a.parent:getTheme("SelectionText")end end}return setmetatable(c_a,_c)end end -aa["objects"]["Pane"]=function(...)local ab=da("Object")local bb=da("basaltLogs") -return -function(cb) -local db=ab(cb)local _c="Pane" -local ac={getType=function(bc)return _c end,setBackground=function(bc,cc,dc,_d)db.setBackground(bc,cc,dc,_d) -return bc end,init=function(bc) -if(db.init(bc))then -bc.bgColor=bc.parent:getTheme("PaneBG")bc.fgColor=bc.parent:getTheme("PaneBG")end end}return setmetatable(ac,db)end end -aa["objects"]["Progressbar"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Progressbar"local ac=0;db:setZIndex(5) -db:setValue(false)db.width=25;db.height=1;local bc;local cc=""local dc=colors.white;local _d=""local ad=0 -local bd={init=function(cd) -if -(db.init(cd))then cd.bgColor=cd.parent:getTheme("ProgressbarBG") -cd.fgColor=cd.parent:getTheme("ProgressbarText")bc=cd.parent:getTheme("ProgressbarActiveBG")end end,getType=function(cd)return -_c end,setValuesByXMLData=function(cd,dd)db.setValuesByXMLData(cd,dd)if(bb("direction",dd)~= -nil)then ad=bb("direction",dd)end -if( -bb("progressColor",dd)~=nil)then bc=colors[bb("progressColor",dd)]end -if(bb("progressSymbol",dd)~=nil)then cc=bb("progressSymbol",dd)end;if(bb("backgroundSymbol",dd)~=nil)then -_d=bb("backgroundSymbol",dd)end -if -(bb("progressSymbolColor",dd)~=nil)then dc=colors[bb("progressSymbolColor",dd)]end;if(bb("onDone",dd)~=nil)then -cd:generateXMLEventFunction(cd.onProgressDone,bb("onDone",dd))end;return cd end,setDirection=function(cd,dd) -ad=dd;cd:updateDraw()return cd end,setProgressBar=function(cd,dd,__a,a_a)bc=dd or bc -cc=__a or cc;dc=a_a or dc;cd:updateDraw()return cd end,setBackgroundSymbol=function(cd,dd) -_d=dd:sub(1,1)cd:updateDraw()return cd end,setProgress=function(cd,dd)if -(dd>=0)and(dd<=100)and(ac~=dd)then ac=dd;cd:setValue(ac)if(ac==100)then -cd:progressDoneHandler()end end -cd:updateDraw()return cd end,getProgress=function(cd)return -ac end,onProgressDone=function(cd,dd)cd:registerEvent("progress_done",dd) -return cd end,progressDoneHandler=function(cd) -cd:sendEvent("progress_done",cd)end,draw=function(cd) -if(db.draw(cd))then -if(cd.parent~=nil)then -local dd,__a=cd:getAnchorPosition()local a_a,b_a=cd:getSize()if(cd.bgColor~=false)then -cd.parent:drawBackgroundBox(dd,__a,a_a,b_a,cd.bgColor)end;if(_d~="")then -cd.parent:drawTextBox(dd,__a,a_a,b_a,_d)end;if(cd.fgColor~=false)then -cd.parent:drawForegroundBox(dd,__a,a_a,b_a,cd.fgColor)end -if(ad==1)then cd.parent:drawBackgroundBox(dd,__a,a_a, -b_a/100 *ac,bc)cd.parent:drawForegroundBox(dd,__a,a_a, -b_a/100 *ac,dc)cd.parent:drawTextBox(dd,__a,a_a, -b_a/100 *ac,cc)elseif(ad==2)then -cd.parent:drawBackgroundBox(dd, -__a+math.ceil(b_a-b_a/100 *ac),a_a,b_a/100 *ac,bc) -cd.parent:drawForegroundBox(dd,__a+math.ceil(b_a-b_a/100 *ac),a_a, -b_a/100 *ac,dc) -cd.parent:drawTextBox(dd,__a+math.ceil(b_a-b_a/100 *ac),a_a, -b_a/100 *ac,cc)elseif(ad==3)then -cd.parent:drawBackgroundBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,bc) -cd.parent:drawForegroundBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,dc) -cd.parent:drawTextBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,cc)else -cd.parent:drawBackgroundBox(dd,__a,a_a/100 *ac,b_a,bc) -cd.parent:drawForegroundBox(dd,__a,a_a/100 *ac,b_a,dc) -cd.parent:drawTextBox(dd,__a,a_a/100 *ac,b_a,cc)end end end end}return setmetatable(bd,db)end end -aa["objects"]["Program"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("process")local db=da("utils").getValueFromXML;local _c=string.sub -return -function(ac,bc)local cc=ab(ac) -local dc="Program"cc:setZIndex(5)local _d;local ad;local bd={} -local function cd(baa,caa,daa,_ba,aba)local bba,cba=1,1 -local dba,_ca=colors.black,colors.white;local aca=false;local bca=false;local cca={}local dca={}local _da={}local ada={}local bda;local cda={}for i=0,15 do local abb=2 ^i -ada[abb]={bc:getBasaltInstance().getBaseTerm().getPaletteColour(abb)}end;local function dda() -bda=(" "):rep(daa) -for n=0,15 do local abb=2 ^n;local bbb=bb[abb]cda[abb]=bbb:rep(daa)end end -local function __b()dda()local abb=bda -local bbb=cda[colors.white]local cbb=cda[colors.black] -for n=1,_ba do -cca[n]=_c(cca[n]==nil and abb or cca[n]..abb:sub(1, -daa-cca[n]:len()),1,daa) -_da[n]=_c(_da[n]==nil and bbb or _da[n].. -bbb:sub(1,daa-_da[n]:len()),1,daa) -dca[n]=_c(dca[n]==nil and cbb or dca[n].. -cbb:sub(1,daa-dca[n]:len()),1,daa)end;cc.updateDraw(cc)end;__b()local function a_b()if -bba>=1 and cba>=1 and bba<=daa and cba<=_ba then else end end -local function b_b(abb,bbb,cbb) -local dbb=bba;local _cb=dbb+#abb-1 -if cba>=1 and cba<=_ba then -if dbb<=daa and _cb>=1 then -if dbb==1 and _cb== -daa then cca[cba]=abb;_da[cba]=bbb;dca[cba]=cbb else local acb,bcb,ccb -if dbb<1 then local __c= -1 -dbb+1;local a_c=daa-dbb+1;acb=_c(abb,__c,a_c) -bcb=_c(bbb,__c,a_c)ccb=_c(cbb,__c,a_c)elseif _cb>daa then local __c=daa-dbb+1;acb=_c(abb,1,__c) -bcb=_c(bbb,1,__c)ccb=_c(cbb,1,__c)else acb=abb;bcb=bbb;ccb=cbb end;local dcb=cca[cba]local _db=_da[cba]local adb=dca[cba]local bdb,cdb,ddb -if dbb>1 then local __c=dbb-1;bdb= -_c(dcb,1,__c)..acb;cdb=_c(_db,1,__c)..bcb -ddb=_c(adb,1,__c)..ccb else bdb=acb;cdb=bcb;ddb=ccb end -if _cb=1 and _cb<=_ba then -cca[newY]=cca[_cb]dca[newY]=dca[_cb]_da[newY]=_da[_cb]else cca[newY]=bbb -_da[newY]=cbb;dca[newY]=dbb end end end;if(bca)then a_b()end end,isColor=function()return -bc:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return -bc:getBasaltInstance().getBaseTerm().isColor()end,write=function(abb) -abb=tostring(abb)if(bca)then -b_b(abb,bb[_ca]:rep(abb:len()),bb[dba]:rep(abb:len()))end end,clearLine=function() -if -(bca)then c_b(1,cba,(" "):rep(daa)) -d_b(1,cba,bb[dba]:rep(daa))_ab(1,cba,bb[_ca]:rep(daa))end;if(bca)then a_b()end end,clear=function() -for n=1,_ba -do c_b(1,n,(" "):rep(daa)) -d_b(1,n,bb[dba]:rep(daa))_ab(1,n,bb[_ca]:rep(daa))end;if(bca)then a_b()end end,blit=function(abb,bbb,cbb)if -type(abb)~="string"then -error("bad argument #1 (expected string, got "..type(abb)..")",2)end;if type(bbb)~="string"then -error( -"bad argument #2 (expected string, got "..type(bbb)..")",2)end;if type(cbb)~="string"then -error( -"bad argument #3 (expected string, got "..type(cbb)..")",2)end -if -#bbb~=#abb or#cbb~=#abb then error("Arguments must be the same length",2)end;if(bca)then b_b(abb,bbb,cbb)end end}return _bb end;cc.width=30;cc.height=12;local dd=cd(1,1,cc.width,cc.height)local __a -local a_a=false;local b_a={} -local function c_a(baa)local caa,daa=dd.getCursorPos() -local _ba,aba=baa:getAnchorPosition()local bba,cba=baa:getSize() -if(_ba+caa-1 >=1 and -_ba+caa-1 <=_ba+bba-1 and daa+aba-1 >=1 and -daa+aba-1 <=aba+cba-1)then -baa.parent:setCursor( -baa:isFocused()and dd.getCursorBlink(),_ba+caa-1,daa+aba-1,dd.getTextColor())end end -local function d_a(baa,caa,...)local daa,_ba=__a:resume(caa,...) -if(daa==false)and(_ba~=nil)and -(_ba~="Terminated")then -local aba=baa:sendEvent("program_error",_ba) -if(aba~=false)then error("Basalt Program - ".._ba)end end -if(__a:getStatus()=="dead")then baa:sendEvent("program_done")end end -local function _aa(baa,caa,daa,_ba,aba)if(__a==nil)then return false end -if not(__a:isDead())then if not(a_a)then -local bba,cba=baa:getAbsolutePosition(baa:getAnchorPosition( -nil,nil,true))d_a(baa,caa,daa,_ba-bba+1,aba-cba+1) -c_a(baa)end end end -local function aaa(baa,caa,daa,_ba)if(__a==nil)then return false end -if not(__a:isDead())then if not(a_a)then if(baa.draw)then -d_a(baa,caa,daa,_ba)c_a(baa)end end end end -_d={getType=function(baa)return dc end,show=function(baa)cc.show(baa) -dd.setBackgroundColor(baa.bgColor)dd.setTextColor(baa.fgColor) -dd.basalt_setVisible(true)return baa end,hide=function(baa) -cc.hide(baa)dd.basalt_setVisible(false)return baa end,setPosition=function(baa,caa,daa,_ba) -cc.setPosition(baa,caa,daa,_ba) -dd.basalt_reposition(baa:getAnchorPosition())return baa end,setValuesByXMLData=function(baa,caa) -cc.setValuesByXMLData(baa,caa)if(db("path",caa)~=nil)then ad=db("path",caa)end -if( -db("execute",caa)~=nil)then if(db("execute",caa))then -if(ad~=nil)then baa:execute(ad)end end end end,getBasaltWindow=function()return -dd end,getBasaltProcess=function()return __a end,setSize=function(baa,caa,daa,_ba)cc.setSize(baa,caa,daa,_ba) -dd.basalt_resize(baa:getWidth(),baa:getHeight())return baa end,getStatus=function(baa)if(__a~=nil)then return -__a:getStatus()end;return"inactive"end,setEnviroment=function(baa,caa)bd= -caa or{}return baa end,execute=function(baa,caa,...)ad=caa or ad -__a=cb:new(ad,dd,bd,...)dd.setBackgroundColor(colors.black) -dd.setTextColor(colors.white)dd.clear()dd.setCursorPos(1,1) -dd.setBackgroundColor(baa.bgColor)dd.setTextColor(baa.fgColor) -dd.basalt_setVisible(true)d_a(baa)a_a=false -if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)baa.parent:addEvent("mouse_up",baa) -baa.parent:addEvent("mouse_drag",baa)baa.parent:addEvent("mouse_scroll",baa) -baa.parent:addEvent("key",baa)baa.parent:addEvent("key_up",baa) -baa.parent:addEvent("char",baa)baa.parent:addEvent("other_event",baa)end;return baa end,stop=function(baa) -if( -__a~=nil)then -if not(__a:isDead())then d_a(baa,"terminate")if(__a:isDead())then -if( -baa.parent~=nil)then baa.parent:setCursor(false)end end end end;baa.parent:removeEvents(baa)return baa end,pause=function(baa,caa)a_a= -caa or(not a_a) -if(__a~=nil)then if not(__a:isDead())then if not(a_a)then -baa:injectEvents(b_a)b_a={}end end end;return baa end,isPaused=function(baa)return -a_a end,injectEvent=function(baa,caa,daa,_ba,aba,bba,cba) -if(__a~=nil)then -if not(__a:isDead())then if(a_a==false)or(cba)then -d_a(baa,caa,daa,_ba,aba,bba)else -table.insert(b_a,{event=caa,args={daa,_ba,aba,bba}})end end end;return baa end,getQueuedEvents=function(baa)return -b_a end,updateQueuedEvents=function(baa,caa)b_a=caa or b_a;return baa end,injectEvents=function(baa,caa)if(__a~=nil)then -if not -(__a:isDead())then for daa,_ba in pairs(caa)do -d_a(baa,_ba.event,table.unpack(_ba.args))end end end;return baa end,mouseHandler=function(baa,caa,daa,_ba) -if -(cc.mouseHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_click",caa,daa,_ba)return true end;return false end,mouseUpHandler=function(baa,caa,daa,_ba) -if -(cc.mouseUpHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_up",caa,daa,_ba)return true end;return false end,scrollHandler=function(baa,caa,daa,_ba) -if -(cc.scrollHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_scroll",caa,daa,_ba)return true end;return false end,dragHandler=function(baa,caa,daa,_ba) -if -(cc.dragHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_drag",caa,daa,_ba)return true end;return false end,keyHandler=function(baa,caa,daa)if -(cc.keyHandler(baa,caa,daa))then aaa(baa,"key",caa,daa)return true end;return -false end,keyUpHandler=function(baa,caa)if -(cc.keyUpHandler(baa,caa))then aaa(baa,"key_up",caa)return true end -return false end,charHandler=function(baa,caa)if -(cc.charHandler(baa,caa))then aaa(baa,"char",caa)return true end -return false end,getFocusHandler=function(baa) -cc.getFocusHandler(baa) -if(__a~=nil)then -if not(__a:isDead())then -if not(a_a)then -if(baa.parent~=nil)then -local caa,daa=dd.getCursorPos()local _ba,aba=baa:getAnchorPosition()local bba,cba=baa:getSize() -if -( -_ba+caa-1 >=1 and _ba+caa-1 <=_ba+bba-1 and -daa+aba-1 >=1 and daa+aba-1 <=aba+cba-1)then -baa.parent:setCursor(dd.getCursorBlink(),_ba+caa-1,daa+aba-1,dd.getTextColor())end end end end end end,loseFocusHandler=function(baa) -cc.loseFocusHandler(baa) -if(__a~=nil)then if not(__a:isDead())then if(baa.parent~=nil)then -baa.parent:setCursor(false)end end end end,eventHandler=function(baa,caa,daa,_ba,aba,bba) -if -(cc.eventHandler(baa,caa,daa,_ba,aba,bba))then if(__a==nil)then return end -if(caa=="dynamicValueEvent")then local cba,dba=dd.getSize() -local _ca,aca=baa:getSize() -if(cba~=_ca)or(dba~=aca)then dd.basalt_resize(_ca,aca)if not -(__a:isDead())then d_a(baa,"term_resize")end end -dd.basalt_reposition(baa:getAnchorPosition())end -if not(__a:isDead())then -if not(a_a)then if(caa~="terminate")then -d_a(baa,caa,daa,_ba,aba,bba)end -if(baa:isFocused())then -local cba,dba=baa:getAnchorPosition()local _ca,aca=dd.getCursorPos() -if(baa.parent~=nil)then -local bca,cca=baa:getSize() -if -(cba+_ca-1 >=1 and cba+_ca-1 <=cba+bca-1 and -aca+dba-1 >=1 and aca+dba-1 <=dba+cca-1)then -baa.parent:setCursor(dd.getCursorBlink(),cba+_ca-1,aca+dba-1,dd.getTextColor())end end;if(caa=="terminate")then d_a(baa,caa) -baa.parent:setCursor(false)return true end end else -table.insert(b_a,{event=caa,args={daa,_ba,aba,bba}})end end;return false end end,draw=function(baa) -if -(cc.draw(baa))then -if(baa.parent~=nil)then local caa,daa=baa:getAnchorPosition() -local _ba,aba=dd.getCursorPos()local bba,cba=baa:getSize()dd.basalt_reposition(caa,daa) -dd.basalt_update() -if -(caa+_ba-1 >=1 and caa+_ba-1 <=caa+bba-1 and -aba+daa-1 >=1 and aba+daa-1 <=daa+cba-1)then -baa.parent:setCursor(baa:isFocused()and dd.getCursorBlink(), -caa+_ba-1,aba+daa-1,dd.getTextColor())end end end end,onError=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("program_error",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)end;return baa end,onDone=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("program_done",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)end;return baa end,init=function(baa) -if -(cc.init(baa))then baa.bgColor=baa.parent:getTheme("ProgramBG")end end}return setmetatable(_d,cc)end end -aa["objects"]["Scrollbar"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Scrollbar"db.width=1;db.height=8;db:setValue(1) -db:setZIndex(2)local ac="vertical"local bc=" "local cc;local dc="\127"local _d=db.height;local ad=1;local bd=1 -local function cd(__a,a_a,b_a,c_a) -local d_a,_aa=__a:getAbsolutePosition(__a:getAnchorPosition())local aaa,baa=__a:getSize() -if(ac=="horizontal")then -for _index=0,aaa do -if -(d_a+_index==b_a)and(_aa<=c_a)and(_aa+baa>c_a)then -ad=math.min(_index+1,aaa- (bd-1))__a:setValue(_d/aaa* (ad))__a:updateDraw()end end end -if(ac=="vertical")then -for _index=0,baa do -if -(_aa+_index==c_a)and(d_a<=b_a)and(d_a+aaa>b_a)then ad=math.min(_index+1,baa- (bd-1)) -__a:setValue(_d/baa* (ad))__a:updateDraw()end end end end -local dd={getType=function(__a)return _c end,setSymbol=function(__a,a_a)bc=a_a:sub(1,1)__a:updateDraw()return __a end,setValuesByXMLData=function(__a,a_a) -db.setValuesByXMLData(__a,a_a) -if(bb("maxValue",a_a)~=nil)then _d=bb("maxValue",a_a)end;if(bb("backgroundSymbol",a_a)~=nil)then -dc=bb("backgroundSymbol",a_a):sub(1,1)end;if(bb("symbol",a_a)~=nil)then -bc=bb("symbol",a_a):sub(1,1)end;if(bb("barType",a_a)~=nil)then -ac=bb("barType",a_a):lower()end;if(bb("symbolSize",a_a)~=nil)then -__a:setSymbolSize(bb("symbolSize",a_a))end;if(bb("symbolColor",a_a)~=nil)then -cc=colors[bb("symbolColor",a_a)]end;if(bb("index",a_a)~=nil)then -__a:setIndex(bb("index",a_a))end end,setIndex=function(__a,a_a) -ad=a_a;if(ad<1)then ad=1 end;local b_a,c_a=__a:getSize() -ad=math.min(ad,( -ac=="vertical"and c_a or b_a)- (bd-1)) -__a:setValue(_d/ (ac=="vertical"and c_a or b_a)*ad)__a:updateDraw()return __a end,getIndex=function(__a)return -ad end,setSymbolSize=function(__a,a_a)bd=tonumber(a_a)or 1 -local b_a,c_a=__a:getSize() -if(ac=="vertical")then -__a:setValue(ad-1 * (_d/ (c_a- (bd-1)))- (_d/ (c_a- -(bd-1))))elseif(ac=="horizontal")then -__a:setValue(ad-1 * (_d/ (b_a- (bd-1)))- (_d/ (b_a- ( -bd-1))))end;__a:updateDraw()return __a end,setMaxValue=function(__a,a_a) -_d=a_a;__a:updateDraw()return __a end,setBackgroundSymbol=function(__a,a_a) -dc=string.sub(a_a,1,1)__a:updateDraw()return __a end,setSymbolColor=function(__a,a_a)cc=a_a -__a:updateDraw()return __a end,setBarType=function(__a,a_a)ac=a_a:lower() -__a:updateDraw()return __a end,mouseHandler=function(__a,a_a,b_a,c_a)if(db.mouseHandler(__a,a_a,b_a,c_a))then -cd(__a,a_a,b_a,c_a)return true end;return false end,dragHandler=function(__a,a_a,b_a,c_a)if -(db.dragHandler(__a,a_a,b_a,c_a))then cd(__a,a_a,b_a,c_a)return true end -return false end,scrollHandler=function(__a,a_a,b_a,c_a) -if -(db.scrollHandler(__a,a_a,b_a,c_a))then local d_a,_aa=__a:getSize()ad=ad+a_a;if(ad<1)then ad=1 end -ad=math.min(ad,( -ac=="vertical"and _aa or d_a)- (bd-1)) -__a:setValue(_d/ (ac=="vertical"and _aa or d_a)*ad)__a:updateDraw()end end,draw=function(__a) -if -(db.draw(__a))then -if(__a.parent~=nil)then local a_a,b_a=__a:getAnchorPosition() -local c_a,d_a=__a:getSize() -if(ac=="horizontal")then -__a.parent:writeText(a_a,b_a,dc:rep(ad-1),__a.bgColor,__a.fgColor) -__a.parent:writeText(a_a+ad-1,b_a,bc:rep(bd),cc,cc) -__a.parent:writeText(a_a+ad+bd-1,b_a,dc:rep(c_a- (ad+bd-1)),__a.bgColor,__a.fgColor)end -if(ac=="vertical")then -for n=0,d_a-1 do -if(ad==n+1)then -for curIndexOffset=0,math.min(bd-1,d_a)do __a.parent:writeText(a_a,b_a+n+ -curIndexOffset,bc,cc,cc)end else if(n+1 ad-1 +bd)then -__a.parent:writeText(a_a,b_a+n,dc,__a.bgColor,__a.fgColor)end end end end end end end,init=function(__a) -__a.parent:addEvent("mouse_click",__a)__a.parent:addEvent("mouse_drag",__a) -__a.parent:addEvent("mouse_scroll",__a) -if(db.init(__a))then -__a.bgColor=__a.parent:getTheme("ScrollbarBG")__a.fgColor=__a.parent:getTheme("ScrollbarText") -cc=__a.parent:getTheme("ScrollbarSymbolColor")end end}return setmetatable(dd,db)end end -aa["objects"]["Radio"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="Radio"_c.width=8;_c:setZIndex(5)local bc={}local cc;local dc -local _d;local ad;local bd;local cd;local dd=true;local __a="\7"local a_a="left" -local b_a={getType=function(c_a)return ac end,setValuesByXMLData=function(c_a,d_a) -_c.setValuesByXMLData(c_a,d_a)if(cb("selectionBG",d_a)~=nil)then -cc=colors[cb("selectionBG",d_a)]end;if(cb("selectionFG",d_a)~=nil)then -dc=colors[cb("selectionFG",d_a)]end;if(cb("boxBG",d_a)~=nil)then -_d=colors[cb("boxBG",d_a)]end;if(cb("inactiveBoxBG",d_a)~=nil)then -bd=colors[cb("inactiveBoxBG",d_a)]end;if(cb("inactiveBoxFG",d_a)~=nil)then -cd=colors[cb("inactiveBoxFG",d_a)]end;if(cb("boxFG",d_a)~=nil)then -ad=colors[cb("boxFG",d_a)]end;if(cb("symbol",d_a)~=nil)then -__a=cb("symbol",d_a)end -if(d_a["item"]~=nil)then local _aa=d_a["item"]if( -_aa.properties~=nil)then _aa={_aa}end;for aaa,baa in pairs(_aa)do -c_a:addItem(cb("text",baa),cb("x",baa),cb("y",baa),colors[cb("bg",baa)],colors[cb("fg",baa)])end end;return c_a end,addItem=function(c_a,d_a,_aa,aaa,baa,caa,...) -table.insert(bc,{x= -_aa or 1,y=aaa or 1,text=d_a,bgCol=baa or c_a.bgColor,fgCol=caa or c_a.fgColor,args={...}})if(#bc==1)then c_a:setValue(bc[1])end -c_a:updateDraw()return c_a end,getAll=function(c_a)return -bc end,removeItem=function(c_a,d_a)table.remove(bc,d_a)c_a:updateDraw() -return c_a end,getItem=function(c_a,d_a)return bc[d_a]end,getItemIndex=function(c_a) -local d_a=c_a:getValue()for _aa,aaa in pairs(bc)do if(aaa==d_a)then return _aa end end end,clear=function(c_a) -bc={}c_a:setValue({},false)c_a:updateDraw()return c_a end,getItemCount=function(c_a)return -#bc end,editItem=function(c_a,d_a,_aa,aaa,baa,caa,daa,...)table.remove(bc,d_a) -table.insert(bc,d_a,{x=aaa or 1,y=baa or 1,text=_aa,bgCol= -caa or c_a.bgColor,fgCol=daa or c_a.fgColor,args={...}})c_a:updateDraw()return c_a end,selectItem=function(c_a,d_a)c_a:setValue( -bc[d_a]or{},false)c_a:updateDraw()return c_a end,setActiveSymbol=function(c_a,d_a) -__a=d_a:sub(1,1)c_a:updateDraw()return c_a end,setSelectedItem=function(c_a,d_a,_aa,aaa,baa,caa) -cc=d_a or cc;dc=_aa or dc;_d=aaa or _d;ad=baa or ad -dd=caa~=nil and caa or true;c_a:updateDraw()return c_a end,mouseHandler=function(c_a,d_a,_aa,aaa) -if( -#bc>0)then -local baa,caa=c_a:getAbsolutePosition(c_a:getAnchorPosition()) -for daa,_ba in pairs(bc)do -if(baa+_ba.x-1 <=_aa)and( -baa+_ba.x-1 +_ba.text:len()+1 >=_aa)and( -caa+_ba.y-1 ==aaa)then -c_a:setValue(_ba) -local aba=c_a:getEventSystem():sendEvent("mouse_click",c_a,"mouse_click",d_a,_aa,aaa)if(aba==false)then return aba end;if(c_a.parent~=nil)then -c_a.parent:setFocusedObject(c_a)end;c_a:updateDraw()return true end end end;return false end,draw=function(c_a) -if( -c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -for aaa,baa in pairs(bc)do -if(baa== -c_a:getValue())then if(a_a=="left")then -c_a.parent:writeText(baa.x+d_a-1,baa.y+_aa-1,__a,_d,ad) -c_a.parent:writeText(baa.x+2 +d_a-1,baa.y+_aa-1,baa.text,cc,dc)end else -c_a.parent:drawBackgroundBox( -baa.x+d_a-1,baa.y+_aa-1,1,1,bd or c_a.bgColor) -c_a.parent:writeText(baa.x+2 +d_a-1,baa.y+_aa-1,baa.text,baa.bgCol,baa.fgCol)end end;return true end end,init=function(c_a) -c_a.parent:addEvent("mouse_click",c_a) -if(_c.init(c_a))then -c_a.bgColor=c_a.parent:getTheme("MenubarBG")c_a.fgColor=c_a.parent:getTheme("MenubarFG") -cc=c_a.parent:getTheme("SelectionBG")dc=c_a.parent:getTheme("SelectionText") -_d=c_a.parent:getTheme("MenubarBG")ad=c_a.parent:getTheme("MenubarText")end end}return setmetatable(b_a,_c)end end -aa["objects"]["Slider"]=function(...)local ab=da("Object") -local bb=da("basaltLogs")local cb=da("utils").getValueFromXML -return -function(db)local _c=ab(db)local ac="Slider" -_c.width=8;_c.height=1;_c:setValue(1)local bc="horizontal"local cc=" "local dc;local _d="\140" -local ad=_c.width;local bd=1;local cd=1 -local function dd(a_a,b_a,c_a,d_a) -local _aa,aaa=a_a:getAbsolutePosition(a_a:getAnchorPosition())local baa,caa=a_a:getSize() -if(bc=="horizontal")then -for _index=0,baa do -if -(_aa+_index==c_a)and(aaa<=d_a)and(aaa+caa>d_a)then -bd=math.min(_index+1,baa- (cd-1))a_a:setValue(ad/baa* (bd))a_a:updateDraw()end end end -if(bc=="vertical")then -for _index=0,caa do -if -(aaa+_index==d_a)and(_aa<=c_a)and(_aa+baa>c_a)then bd=math.min(_index+1,caa- (cd-1)) -a_a:setValue(ad/caa* (bd))a_a:updateDraw()end end end end -local __a={getType=function(a_a)return ac end,setSymbol=function(a_a,b_a)cc=b_a:sub(1,1)a_a:updateDraw()return a_a end,setValuesByXMLData=function(a_a,b_a) -_c.setValuesByXMLData(a_a,b_a) -if(cb("maxValue",b_a)~=nil)then ad=cb("maxValue",b_a)end;if(cb("backgroundSymbol",b_a)~=nil)then -_d=cb("backgroundSymbol",b_a):sub(1,1)end;if(cb("barType",b_a)~=nil)then -bc=cb("barType",b_a):lower()end;if(cb("symbol",b_a)~=nil)then -cc=cb("symbol",b_a):sub(1,1)end;if(cb("symbolSize",b_a)~=nil)then -a_a:setSymbolSize(cb("symbolSize",b_a))end;if(cb("symbolColor",b_a)~=nil)then -dc=colors[cb("symbolColor",b_a)]end;if(cb("index",b_a)~=nil)then -a_a:setIndex(cb("index",b_a))end end,setIndex=function(a_a,b_a) -bd=b_a;if(bd<1)then bd=1 end;local c_a,d_a=a_a:getSize() -bd=math.min(bd,( -bc=="vertical"and d_a or c_a)- (cd-1)) -a_a:setValue(ad/ (bc=="vertical"and d_a or c_a)*bd)a_a:updateDraw()return a_a end,getIndex=function(a_a)return -bd end,setSymbolSize=function(a_a,b_a)cd=tonumber(b_a)or 1 -if(bc=="vertical")then -a_a:setValue(bd-1 * (ad/ (h- (cd- -1)))- (ad/ (h- (cd-1))))elseif(bc=="horizontal")then -a_a:setValue(bd-1 * (ad/ (w- (cd-1)))- (ad/ -(w- (cd-1))))end;a_a:updateDraw()return a_a end,setMaxValue=function(a_a,b_a) -ad=b_a;return a_a end,setBackgroundSymbol=function(a_a,b_a)_d=string.sub(b_a,1,1) -a_a:updateDraw()return a_a end,setSymbolColor=function(a_a,b_a)dc=b_a;a_a:updateDraw() -return a_a end,setBarType=function(a_a,b_a)bc=b_a:lower()a_a:updateDraw() -return a_a end,mouseHandler=function(a_a,b_a,c_a,d_a)if(_c.mouseHandler(a_a,b_a,c_a,d_a))then -dd(a_a,b_a,c_a,d_a)return true end;return false end,dragHandler=function(a_a,b_a,c_a,d_a)if -(_c.dragHandler(a_a,b_a,c_a,d_a))then dd(a_a,b_a,c_a,d_a)return true end -return false end,scrollHandler=function(a_a,b_a,c_a,d_a) -if -(_c.scrollHandler(a_a,b_a,c_a,d_a))then local _aa,aaa=a_a:getSize()bd=bd+b_a;if(bd<1)then bd=1 end -bd=math.min(bd,( -bc=="vertical"and aaa or _aa)- (cd-1)) -a_a:setValue(ad/ (bc=="vertical"and aaa or _aa)*bd)a_a:updateDraw()return true end;return false end,draw=function(a_a) -if -(_c.draw(a_a))then -if(a_a.parent~=nil)then local b_a,c_a=a_a:getAnchorPosition() -local d_a,_aa=a_a:getSize() -if(bc=="horizontal")then -a_a.parent:writeText(b_a,c_a,_d:rep(bd-1),a_a.bgColor,a_a.fgColor) -a_a.parent:writeText(b_a+bd-1,c_a,cc:rep(cd),dc,dc) -a_a.parent:writeText(b_a+bd+cd-1,c_a,_d:rep(d_a- (bd+cd-1)),a_a.bgColor,a_a.fgColor)end -if(bc=="vertical")then -for n=0,_aa-1 do -if(bd==n+1)then -for curIndexOffset=0,math.min(cd-1,_aa)do a_a.parent:writeText(b_a,c_a+n+ -curIndexOffset,cc,dc,dc)end else if(n+1 bd-1 +cd)then -a_a.parent:writeText(b_a,c_a+n,_d,a_a.bgColor,a_a.fgColor)end end end end end end end,init=function(a_a) -a_a.parent:addEvent("mouse_click",a_a)a_a.parent:addEvent("mouse_drag",a_a) -a_a.parent:addEvent("mouse_scroll",a_a) -if(_c.init(a_a))then -a_a.bgColor=a_a.parent:getTheme("SliderBG")a_a.fgColor=a_a.parent:getTheme("SliderText") -dc=a_a.parent:getTheme("SliderSymbolColor")end end}return setmetatable(__a,_c)end end -aa["objects"]["Switch"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Switch"db.width=2;db.height=1 -db.bgColor=colors.lightGray;db.fgColor=colors.gray;db:setValue(false)db:setZIndex(5) -local ac=colors.black;local bc=colors.red;local cc=colors.green -local dc={getType=function(_d)return _c end,setSymbolColor=function(_d,ad)ac=ad -_d:updateDraw()return _d end,setActiveBackground=function(_d,ad)cc=ad;_d:updateDraw()return _d end,setInactiveBackground=function(_d,ad) -bc=ad;_d:updateDraw()return _d end,setValuesByXMLData=function(_d,ad) -db.setValuesByXMLData(_d,ad)if(bb("inactiveBG",ad)~=nil)then -bc=colors[bb("inactiveBG",ad)]end;if(bb("activeBG",ad)~=nil)then -cc=colors[bb("activeBG",ad)]end;if(bb("symbolColor",ad)~=nil)then -ac=colors[bb("symbolColor",ad)]end end,mouseHandler=function(_d,ad,bd,cd) -if -(db.mouseHandler(_d,ad,bd,cd))then -local dd,__a=_d:getAbsolutePosition(_d:getAnchorPosition())_d:setValue(not _d:getValue()) -_d:updateDraw()return true end end,draw=function(_d) -if -(db.draw(_d))then -if(_d.parent~=nil)then local ad,bd=_d:getAnchorPosition() -local cd,dd=_d:getSize() -_d.parent:drawBackgroundBox(ad,bd,cd,dd,_d.bgColor) -if(_d:getValue())then -_d.parent:drawBackgroundBox(ad,bd,1,dd,cc)_d.parent:drawBackgroundBox(ad+1,bd,1,dd,ac)else -_d.parent:drawBackgroundBox(ad,bd,1,dd,ac)_d.parent:drawBackgroundBox(ad+1,bd,1,dd,bc)end end end end,init=function(_d) -_d.parent:addEvent("mouse_click",_d) -if(db.init(_d))then _d.bgColor=_d.parent:getTheme("SwitchBG") -_d.fgColor=_d.parent:getTheme("SwitchText")ac=_d.parent:getTheme("SwitchBGSymbol") -bc=_d.parent:getTheme("SwitchInactive")cc=_d.parent:getTheme("SwitchActive")end end}return setmetatable(dc,db)end end -aa["objects"]["Textfield"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("utils").getValueFromXML;local db=da("basaltLogs") -local _c,ac,bc,cc,dc=string.rep,string.find,string.gmatch,string.sub,string.len -return -function(_d)local ad=ab(_d)local bd="Textfield"local cd,dd,__a,a_a=1,1,1,1;local b_a={" "}local c_a={""}local d_a={""} -local _aa={}local aaa={}local baa,caa,daa,_ba;local aba,bba=colors.lightBlue,colors.black;ad.width=30 -ad.height=12;ad:setZIndex(5)local function cba() -if -(baa~=nil)and(caa~=nil)and(daa~=nil)and(_ba~=nil)then return true end;return false end -local function dba()local ada,bda,cda,dda -if -(cba())then if(baa>caa)then ada,bda=caa,baa else ada,bda=baa,caa end;if(daa>_ba)then -cda,dda=_ba,daa else cda,dda=daa,_ba end end;return ada,bda,cda,dda end;local function _ca()end -local function aca(ada)local bda,cda,dda,__b=dba(ada) -for n=__b,dda,-1 do -if(n==dda)or(n==__b)then local a_b=b_a[n] -local b_b=c_a[n]local c_b=d_a[n] -if(n==dda)and(n==__b)then a_b=a_b:sub(1,bda-1).. -a_b:sub(cda+1,a_b:len())b_b=b_b:sub(1,bda-1).. -b_b:sub(cda+1,b_b:len())c_b=c_b:sub(1,bda-1).. -c_b:sub(cda+1,c_b:len())elseif(n==bda)then -a_b=a_b:sub(1,bda)b_b=b_b:sub(1,bda)c_b=c_b:sub(1,bda)elseif(n==dda)then -a_b=a_b:sub(cda,a_b:len())b_b=b_b:sub(cda,b_b:len()) -c_b=c_b:sub(cda,c_b:len())end;b_a[n]=a_b;c_a[n]=b_b;d_a[n]=c_b else table.remove(b_a,n) -table.remove(c_a,n)table.remove(d_a,n)end end;__a,a_a=baa,daa;baa,caa,daa,_ba=nil,nil,nil,nil;return ada end -local function bca(ada,bda)local cda={} -if(ada:len()>0)then -for dda in bc(ada,bda)do local __b,a_b=ac(ada,dda) -if -(__b~=nil)and(a_b~=nil)then table.insert(cda,__b)table.insert(cda,a_b) -local b_b=cc(ada,1,(__b-1))local c_b=cc(ada,a_b+1,ada:len())ada=b_b.. (":"):rep(dda:len()).. -c_b end end end;return cda end -local function cca(ada,bda)bda=bda or a_a -local cda=bb[ada.fgColor]:rep(d_a[bda]:len()) -local dda=bb[ada.bgColor]:rep(c_a[bda]:len()) -for __b,a_b in pairs(aaa)do local b_b=bca(b_a[bda],a_b[1]) -if(#b_b>0)then -for x=1,#b_b/2 do -local c_b=x*2 -1;if(a_b[2]~=nil)then -cda=cda:sub(1,b_b[c_b]-1)..bb[a_b[2]]:rep(b_b[c_b+1]- ( -b_b[c_b]-1)).. -cda:sub(b_b[c_b+1]+1,cda:len())end;if -(a_b[3]~=nil)then -dda=dda:sub(1,b_b[c_b]-1).. - -bb[a_b[3]]:rep(b_b[c_b+1]- (b_b[c_b]-1))..dda:sub(b_b[c_b+1]+1,dda:len())end end end end -for __b,a_b in pairs(_aa)do -for b_b,c_b in pairs(a_b)do local d_b=bca(b_a[bda],c_b) -if(#d_b>0)then for x=1,#d_b/2 do -local _ab=x*2 -1 -cda=cda:sub(1,d_b[_ab]-1).. - -bb[__b]:rep(d_b[_ab+1]- (d_b[_ab]-1))..cda:sub(d_b[_ab+1]+1,cda:len())end end end end;d_a[bda]=cda;c_a[bda]=dda;ada:updateDraw()end;local function dca(ada)for n=1,#b_a do cca(ada,n)end end -local _da={getType=function(ada)return bd end,setBackground=function(ada,bda) -ad.setBackground(ada,bda)dca(ada)return ada end,setForeground=function(ada,bda) -ad.setForeground(ada,bda)dca(ada)return ada end,setValuesByXMLData=function(ada,bda) -ad.setValuesByXMLData(ada,bda) -if(bda["lines"]~=nil)then local cda=bda["lines"]["line"]if -(cda.properties~=nil)then cda={cda}end;for dda,__b in pairs(cda)do -ada:addLine(__b:value())end end -if(bda["keywords"]~=nil)then -for cda,dda in pairs(bda["keywords"])do -if(colors[cda]~=nil)then -local __b=dda;if(__b.properties~=nil)then __b={__b}end;local a_b={} -for b_b,c_b in pairs(__b)do -local d_b=c_b["keyword"]if(c_b["keyword"].properties~=nil)then -d_b={c_b["keyword"]}end;for _ab,aab in pairs(d_b)do -table.insert(a_b,aab:value())end end;ada:addKeywords(colors[cda],a_b)end end end -if(bda["rules"]~=nil)then -if(bda["rules"]["rule"]~=nil)then -local cda=bda["rules"]["rule"]if(bda["rules"]["rule"].properties~=nil)then -cda={bda["rules"]["rule"]}end -for dda,__b in pairs(cda)do if(cb("pattern",__b)~=nil)then -ada:addRule(cb("pattern",__b),colors[cb("fg",__b)],colors[cb("bg",__b)])end end end end end,getLines=function(ada)return -b_a end,getLine=function(ada,bda)return b_a[bda]end,editLine=function(ada,bda,cda) -b_a[bda]=cda or b_a[bda]cca(ada,bda)ada:updateDraw()return ada end,clear=function(ada) -b_a={" "}c_a={""}d_a={""}baa,caa,daa,_ba=nil,nil,nil,nil;cd,dd,__a,a_a=1,1,1,1 -ada:updateDraw()return ada end,addLine=function(ada,bda,cda) -if -(bda~=nil)then -if(#b_a==1)and(b_a[1]=="")then b_a[1]=bda -c_a[1]=bb[ada.bgColor]:rep(bda:len())d_a[1]=bb[ada.fgColor]:rep(bda:len()) -cca(ada,1)return ada end -if(cda~=nil)then table.insert(b_a,cda,bda) -table.insert(c_a,cda,bb[ada.bgColor]:rep(bda:len())) -table.insert(d_a,cda,bb[ada.fgColor]:rep(bda:len()))else table.insert(b_a,bda) -table.insert(c_a,bb[ada.bgColor]:rep(bda:len())) -table.insert(d_a,bb[ada.fgColor]:rep(bda:len()))end end;cca(ada,cda or#b_a)ada:updateDraw()return ada end,addKeywords=function(ada,bda,cda)if( -_aa[bda]==nil)then _aa[bda]={}end;for dda,__b in pairs(cda)do -table.insert(_aa[bda],__b)end;ada:updateDraw()return ada end,addRule=function(ada,bda,cda,dda) -table.insert(aaa,{bda,cda,dda})ada:updateDraw()return ada end,editRule=function(ada,bda,cda,dda)for __b,a_b in -pairs(aaa)do -if(a_b[1]==bda)then aaa[__b][2]=cda;aaa[__b][3]=dda end end;ada:updateDraw()return ada end,removeRule=function(ada,bda) -for cda,dda in -pairs(aaa)do if(dda[1]==bda)then table.remove(aaa,cda)end end;ada:updateDraw()return ada end,setKeywords=function(ada,bda,cda) -_aa[bda]=cda;ada:updateDraw()return ada end,removeLine=function(ada,bda) -if(#b_a>1)then table.remove(b_a, -bda or#b_a) -table.remove(c_a,bda or#c_a)table.remove(d_a,bda or#d_a)else b_a={" "}c_a={""}d_a={""}end;ada:updateDraw()return ada end,getTextCursor=function(ada)return -__a,a_a end,getFocusHandler=function(ada)ad.getFocusHandler(ada) -if(ada.parent~=nil)then -local bda,cda=ada:getAnchorPosition()if(ada.parent~=nil)then -ada.parent:setCursor(true,bda+__a-dd,cda+a_a-cd,ada.fgColor)end end end,loseFocusHandler=function(ada) -ad.loseFocusHandler(ada) -if(ada.parent~=nil)then ada.parent:setCursor(false)end end,keyHandler=function(ada,bda) -if -(ad.keyHandler(ada,event,bda))then local cda,dda=ada:getAnchorPosition()local __b,a_b=ada:getSize() -if(bda== -keys.backspace)then -if(b_a[a_a]=="")then -if(a_a>1)then table.remove(b_a,a_a) -table.remove(d_a,a_a)table.remove(c_a,a_a) -__a=b_a[a_a-1]:len()+1;dd=__a-__b+1;if(dd<1)then dd=1 end;a_a=a_a-1 end elseif(__a<=1)then -if(a_a>1)then __a=b_a[a_a-1]:len()+1 -dd=__a-__b+1;if(dd<1)then dd=1 end;b_a[a_a-1]=b_a[a_a-1]..b_a[a_a]d_a[ -a_a-1]=d_a[a_a-1]..d_a[a_a]c_a[a_a-1]=c_a[a_a-1].. -c_a[a_a]table.remove(b_a,a_a) -table.remove(d_a,a_a)table.remove(c_a,a_a)a_a=a_a-1 end else b_a[a_a]=b_a[a_a]:sub(1,__a-2).. -b_a[a_a]:sub(__a,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-2)..d_a[a_a]:sub(__a,d_a[a_a]:len())c_a[a_a]=c_a[a_a]:sub(1,__a-2).. -c_a[a_a]:sub(__a,c_a[a_a]:len())if(__a>1)then -__a=__a-1 end;if(dd>1)then if(__ab_a[a_a]:len())then -if( -b_a[a_a+1]~=nil)then b_a[a_a]=b_a[a_a]..b_a[a_a+1] -table.remove(b_a,a_a+1)table.remove(c_a,a_a+1)table.remove(d_a,a_a+1)end else b_a[a_a]=b_a[a_a]:sub(1,__a-1).. -b_a[a_a]:sub(__a+1,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-1)..d_a[a_a]:sub(__a+1,d_a[a_a]:len())c_a[a_a]=c_a[a_a]:sub(1,__a-1).. -c_a[a_a]:sub(__a+1,c_a[a_a]:len())end end;cca(ada)end -if(bda==keys.enter)then -table.insert(b_a,a_a+1,b_a[a_a]:sub(__a,b_a[a_a]:len())) -table.insert(d_a,a_a+1,d_a[a_a]:sub(__a,d_a[a_a]:len())) -table.insert(c_a,a_a+1,c_a[a_a]:sub(__a,c_a[a_a]:len()))b_a[a_a]=b_a[a_a]:sub(1,__a-1) -d_a[a_a]=d_a[a_a]:sub(1,__a-1)c_a[a_a]=c_a[a_a]:sub(1,__a-1)a_a=a_a+1;__a=1;dd=1;if(a_a-cd>= -a_b)then cd=cd+1 end;ada:setValue("")end -if(bda==keys.up)then -if(a_a>1)then a_a=a_a-1;if(__a>b_a[a_a]:len()+1)then __a= -b_a[a_a]:len()+1 end -if(dd>1)then if(__a1)then if(a_ab_a[a_a]:len()+1)then __a=b_a[a_a]:len()+1 end -if(dd>1)then if -(__a=cd+a_b)then cd=cd+1 end end end -if(bda==keys.right)then __a=__a+1 -if(a_a<#b_a)then if -(__a>b_a[a_a]:len()+1)then __a=1;a_a=a_a+1 end elseif(__a>b_a[a_a]:len())then __a= -b_a[a_a]:len()+1 end;if(__a<1)then __a=1 end -if(__a=__b+dd)then dd=__a-__b+1 end;if(dd<1)then dd=1 end end -if(bda==keys.left)then __a=__a-1;if(__a>=1)then -if(__a=__b+dd)then dd=__a end end -if(a_a>1)then if(__a<1)then a_a=a_a-1 -__a=b_a[a_a]:len()+1;dd=__a-__b+1 end end;if(__a<1)then __a=1 end;if(dd<1)then dd=1 end end -if not -( (cda+__a-dd>=cda and cda+__a-dd=dda and dda+a_a-cd -ada:getX()+__b-1)then b_b=ada:getX()+__b-1 end -local c_b=(a_a-cd=__b+dd)then dd=dd+1 end;cca(ada) -ada:setValue("") -if not -( (cda+__a-dd>=cda and cda+__a-dd=dda and dda+a_a-cd -ada:getX()+__b-1)then b_b=ada:getX()+__b-1 end -local c_b=(a_a-cdb_b+cda- (__b+1)+dd)and(b_bb_a[a_a]:len())then __a= -b_a[a_a]:len()+1;caa=__a end;if(__a#b_a- (_ab-1))then cd=#b_a- (_ab-1)end;if -(cd<1)then cd=1 end -if - -(__b+__a-dd>=__b and __b+__a-dd<__b+d_b)and(c_b+a_a-cd>=c_b and c_b+a_a-cd -b_a[a_a]:len())then __a=b_a[a_a]:len()+1;baa=__a end;if(__ab_a[_ba]:len())then caa= -b_a[_ba]:len()+1 end;if(baa==caa)and(daa==_ba)then baa,caa,daa,_ba= -nil,nil,nil,nil end -ada:updateDraw()end;return true end end,eventHandler=function(ada,bda,cda,dda,__b,a_b) -if -(ad.eventHandler(ada,bda,cda,dda,__b,a_b))then -if(bda=="paste")then -if(ada:isFocused())then local b_b,c_b=ada:getSize()b_a[a_a]=b_a[a_a]:sub(1, -__a-1).. -cda..b_a[a_a]:sub(__a,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-1)..bb[ada.fgColor]:rep(cda:len()).. -d_a[a_a]:sub(__a,d_a[a_a]:len()) -c_a[a_a]=c_a[a_a]:sub(1,__a-1).. - -bb[ada.bgColor]:rep(cda:len())..c_a[a_a]:sub(__a,c_a[a_a]:len())__a=__a+cda:len() -if(__a>=b_b+dd)then dd=(__a+1)-b_b end;local d_b,_ab=ada:getAnchorPosition() -ada.parent:setCursor(true,d_b+__a-dd,_ab+ -a_a-cd,ada.fgColor)cca(ada)ada:updateDraw()end end end end,draw=function(ada) -if -(ad.draw(ada))then -if(ada.parent~=nil)then local bda,cda=ada:getAnchorPosition() -local dda,__b=ada:getSize() -for n=1,__b do local a_b=""local b_b=""local c_b="" -if(b_a[n+cd-1]~=nil)then a_b=b_a[n+cd-1]c_b=d_a[ -n+cd-1]b_b=c_a[n+cd-1]end;a_b=a_b:sub(dd,dda+dd-1) -b_b=b_b:sub(dd,dda+dd-1)c_b=c_b:sub(dd,dda+dd-1)local d_b=dda-a_b:len()if(d_b<0)then -d_b=0 end;a_b=a_b.._c(ada.bgSymbol,d_b)b_b=b_b.. -_c(bb[ada.bgColor],d_b) -c_b=c_b.._c(bb[ada.fgColor],d_b)ada.parent:setText(bda,cda+n-1,a_b)ada.parent:setBG(bda, -cda+n-1,b_b) -ada.parent:setFG(bda,cda+n-1,c_b)end -if -(baa~=nil)and(caa~=nil)and(daa~=nil)and(_ba~=nil)then local a_b,b_b,c_b,d_b=dba(ada) -for n=c_b,d_b do local _ab=b_a[n]:len()local aab=0 -if -(n==c_b)and(n==d_b)then aab=a_b-1;_ab=_ab- (a_b-1)- (_ab-b_b)elseif(n==d_b)then -_ab=_ab- (_ab-b_b)elseif(n==c_b)then _ab=_ab- (a_b-1)aab=a_b-1 end -ada.parent:setBG(bda+aab,cda+n-1,_c(bb[aba],_ab)) -ada.parent:setFG(bda+aab,cda+n-1,_c(bb[bba],_ab))end end -if(ada:isFocused())then local a_b,b_b=ada:getAnchorPosition()end end end end,init=function(ada) -ada.parent:addEvent("mouse_click",ada)ada.parent:addEvent("mouse_up",ada) -ada.parent:addEvent("mouse_scroll",ada)ada.parent:addEvent("mouse_drag",ada) -ada.parent:addEvent("key",ada)ada.parent:addEvent("char",ada) -ada.parent:addEvent("other_event",ada) -if(ad.init(ada))then -ada.bgColor=ada.parent:getTheme("TextfieldBG")ada.fgColor=ada.parent:getTheme("TextfieldText")end end}return setmetatable(_da,ad)end end -aa["objects"]["Timer"]=function(...)local ab=da("basaltEvent") -local bb=da("utils").getValueFromXML -return -function(cb)local db="Timer"local _c=0;local ac=0;local bc=0;local cc;local dc=ab()local _d=false -local ad=function(cd,dd,__a) -local a_a=function(b_a) -if(b_a:sub(1,1)=="#")then -local c_a=cd:getBaseFrame():getDeepObject(b_a:sub(2,b_a:len())) -if(c_a~=nil)and(c_a.internalObjetCall~=nil)then dd(cd,function() -c_a:internalObjetCall()end)end else -dd(cd,cd:getBaseFrame():getVariable(b_a))end end;if(type(__a)=="string")then a_a(__a)elseif(type(__a)=="table")then -for b_a,c_a in pairs(__a)do a_a(c_a)end end;return cd end -local bd={name=cb,getType=function(cd)return db end,setValuesByXMLData=function(cd,dd) -if(bb("time",dd)~=nil)then _c=bb("time",dd)end;if(bb("repeat",dd)~=nil)then ac=bb("repeat",dd)end -if( -bb("start",dd)~=nil)then if(bb("start",dd))then cd:start()end end;if(bb("onCall",dd)~=nil)then -ad(cd,cd.onCall,bb("onCall",dd))end;return cd end,getBaseFrame=function(cd) -if( -cd.parent~=nil)then return cd.parent:getBaseFrame()end;return cd end,getZIndex=function(cd)return 1 end,getName=function(cd) -return cd.name end,setTime=function(cd,dd,__a)_c=dd or 0;ac=__a or 1;return cd end,start=function(cd)if(_d)then -os.cancelTimer(cc)end;bc=ac;cc=os.startTimer(_c)_d=true -cd.parent:addEvent("other_event",cd)return cd end,isActive=function(cd)return _d end,cancel=function(cd)if( -cc~=nil)then os.cancelTimer(cc)end;_d=false -cd.parent:removeEvent("other_event",cd)return cd end,onCall=function(cd,dd) -dc:registerEvent("timed_event",dd)return cd end,eventHandler=function(cd,dd,__a) -if -dd=="timer"and __a==cc and _d then dc:sendEvent("timed_event",cd) -if(bc>=1)then bc=bc-1;if(bc>=1)then -cc=os.startTimer(_c)end elseif(bc==-1)then cc=os.startTimer(_c)end end end}bd.__index=bd;return bd end end -aa["objects"]["Thread"]=function(...)local ab=da("utils").getValueFromXML -return -function(bb)local cb -local db="Thread"local _c;local ac;local bc=false;local cc -local dc=function(_d,ad) -if(ad:sub(1,1)=="#")then -local bd=_d:getBaseFrame():getDeepObject(ad:sub(2,ad:len())) -if(bd~=nil)and(bd.internalObjetCall~=nil)then return(function() -bd:internalObjetCall()end)end else return _d:getBaseFrame():getVariable(ad)end;return _d end -cb={name=bb,getType=function(_d)return db end,getZIndex=function(_d)return 1 end,getName=function(_d)return _d.name end,getBaseFrame=function(_d)if -(_d.parent~=nil)then return _d.parent:getBaseFrame()end -return _d end,setValuesByXMLData=function(_d,ad)local bd;if(ab("thread",ad)~=nil)then -bd=dc(_d,ab("thread",ad))end -if(ab("start",ad)~=nil)then if -(ab("start",ad))and(bd~=nil)then _d:start(bd)end end;return _d end,start=function(_d,ad) -if( -ad==nil)then error("Function provided to thread is nil")end;_c=ad;ac=coroutine.create(_c)bc=true;cc=nil -local bd,cd=coroutine.resume(ac)cc=cd;if not(bd)then if(cd~="Terminated")then -error("Thread Error Occurred - "..cd)end end -_d.parent:addEvent("mouse_click",_d)_d.parent:addEvent("mouse_up",_d) -_d.parent:addEvent("mouse_scroll",_d)_d.parent:addEvent("mouse_drag",_d) -_d.parent:addEvent("key",_d)_d.parent:addEvent("key_up",_d) -_d.parent:addEvent("char",_d)_d.parent:addEvent("other_event",_d)return _d end,getStatus=function(_d,ad)if( -ac~=nil)then return coroutine.status(ac)end;return nil end,stop=function(_d,ad) -bc=false;_d.parent:removeEvent("mouse_click",_d) -_d.parent:removeEvent("mouse_up",_d)_d.parent:removeEvent("mouse_scroll",_d) -_d.parent:removeEvent("mouse_drag",_d)_d.parent:removeEvent("key",_d) -_d.parent:removeEvent("key_up",_d)_d.parent:removeEvent("char",_d) -_d.parent:removeEvent("other_event",_d)return _d end,mouseHandler=function(_d,...) -_d:eventHandler("mouse_click",...)end,mouseUpHandler=function(_d,...)_d:eventHandler("mouse_up",...)end,mouseScrollHandler=function(_d,...) -_d:eventHandler("mouse_scroll",...)end,mouseDragHandler=function(_d,...) -_d:eventHandler("mouse_drag",...)end,mouseMoveHandler=function(_d,...) -_d:eventHandler("mouse_move",...)end,keyHandler=function(_d,...)_d:eventHandler("key",...)end,keyUpHandler=function(_d,...) -_d:eventHandler("key_up",...)end,charHandler=function(_d,...)_d:eventHandler("char",...)end,eventHandler=function(_d,ad,...) -if -(bc)then -if(coroutine.status(ac)=="suspended")then if(cc~=nil)then if(ad~=cc)then return end;cc= -nil end -local bd,cd=coroutine.resume(ac,ad,...)cc=cd;if not(bd)then if(cd~="Terminated")then -error("Thread Error Occurred - "..cd)end end else -_d:stop()end end end}cb.__index=cb;return cb end end;aa["libraries"]={} -aa["libraries"]["basaltDraw"]=function(...) -local ab=da("tHex")local bb,cb=string.sub,string.rep -return -function(db)local _c=db or term.current() -local ac;local bc,cc=_c.getSize()local dc={}local _d={}local ad={}local bd={}local cd={}local dd={}local __a;local a_a={}local function b_a() -__a=cb(" ",bc) -for n=0,15 do local daa=2 ^n;local _ba=ab[daa]a_a[daa]=cb(_ba,bc)end end;b_a() -local function c_a()b_a()local daa=__a -local _ba=a_a[colors.white]local aba=a_a[colors.black] -for currentY=1,cc do -dc[currentY]=bb( -dc[currentY]==nil and daa or -dc[currentY]..daa:sub(1,bc-dc[currentY]:len()),1,bc) -ad[currentY]=bb(ad[currentY]==nil and _ba or ad[currentY].._ba:sub(1,bc- -ad[currentY]:len()),1,bc) -_d[currentY]=bb(_d[currentY]==nil and aba or _d[currentY]..aba:sub(1,bc- -_d[currentY]:len()),1,bc)end end;c_a() -local function d_a(daa,_ba,aba) -if(_ba>=1)and(_ba<=cc)then -if -(daa+aba:len()>0)and(daa<=bc)then local bba=dc[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then local _ca=1 -daa+1 -local aca=bc-daa+1;aba=bb(aba,_ca,aca)elseif(dba>bc)then local _ca=bc-daa+1;aba=bb(aba,1,_ca)end -if(daa>1)then local _ca=daa-1;cba=bb(bba,1,_ca)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if(daa+aba:len()>0)and(daa<=bc)then -local bba=_d[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then -aba=bb(aba,1 -daa+1,bc-daa+1)elseif(dba>bc)then aba=bb(aba,1,bc-daa+1)end -if(daa>1)then cba=bb(bba,1,daa-1)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if(daa+aba:len()>0)and(daa<=bc)then -local bba=ad[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then local _ca=1 -daa+1;local aca=bc-daa+1 -aba=bb(aba,_ca,aca)elseif(dba>bc)then local _ca=bc-daa+1;aba=bb(aba,1,_ca)end -if(daa>1)then local _ca=daa-1;cba=bb(bba,1,_ca)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if( -daa+aba:len()>0)and(daa<=bc)then local dba=dc[_ba]local _ca=ad[_ba]local aca=_d[_ba] -local bca,cca,dca;local _da=daa+#aba-1 -if(daa<1)then local ada=1 -daa+1;local bda=bc-daa+1 -aba=bb(aba,ada,bda)bba=bb(bba,ada,bda)cba=bb(cba,ada,bda)elseif(_da>bc)then local ada=bc-daa+1 -aba=bb(aba,1,ada)bba=bb(bba,1,ada)cba=bb(cba,1,ada)end -if(daa>1)then local ada=daa-1;bca=bb(dba,1,ada)..aba -cca=bb(_ca,1,ada)..bba;dca=bb(aca,1,ada)..cba else bca=aba;cca=bba;dca=cba end -if _da_ca and dca or _ca end;_ba=_ba>dba and _ba or dba;aba=aba+_ca end;dd,__a=_ba,aba end;_aa() -local function aaa()local _ba=0;local aba,bba=0,0 -for cba,dba in pairs(bc)do local _ca=0;local aca=0 -for bca,cca in pairs(dba)do -local dca,_da=cca.getSize()if(cc-_ca>=1)and(cc-_ca<=dca)then aba=bca end;cca.setCursorPos( -cc-_ca,dc-_ba)_ca=_ca+dca -if(aca<_da)then aca=_da end end;if(dc-_ba>=1)and(dc-_ba<=aca)then bba=cba end -_ba=_ba+aca end;_d,ad=aba,bba end;aaa() -local function baa(_ba,...)local aba={...}return -function()for bba,cba in pairs(bc)do for dba,_ca in pairs(cba)do -_ca[_ba](table.unpack(aba))end end end end -local function caa()baa("setCursorBlink",false)() -if not(a_a)then return end;if(bc[ad]==nil)then return end;local _ba=bc[ad][_d] -if(_ba==nil)then return end;_ba.setCursorBlink(a_a)end -local function daa(_ba,aba,bba)if(bc[ad]==nil)then return end;local cba=bc[ad][_d] -if(cba==nil)then return end;cba.blit(_ba,aba,bba)local dba,_ca=cba.getSize() -if -(cb(_ba)+cc>dba)then local aca=bc[ad][_d+1]if(aca~=nil)then aca.blit(_ba,aba,bba)_d=_d+1;cc=cc+ -cb(_ba)end end;aaa()end -return -{clear=baa("clear"),setCursorBlink=function(_ba)a_a=_ba;caa()end,getCursorBlink=function()return a_a end,getCursorPos=function()return cc,dc end,setCursorPos=function(_ba,aba) -cc,dc=_ba,aba;aaa()caa()end,setTextScale=function(_ba) -baa("setTextScale",_ba)()_aa()aaa()b_a=_ba end,getTextScale=function()return b_a end,blit=function(_ba,aba,bba) -daa(_ba,aba,bba)end,write=function(_ba)_ba=tostring(_ba)local aba=cb(_ba) -daa(_ba,db(ab[c_a],aba),db(ab[d_a],aba))end,getSize=function()return dd,__a end,setBackgroundColor=function(_ba) -baa("setBackgroundColor",_ba)()d_a=_ba end,setTextColor=function(_ba) -baa("setTextColor",_ba)()c_a=_ba end,calculateClick=function(_ba,aba,bba)local cba=0 -for dba,_ca in pairs(bc)do local aca=0;local bca=0 -for cca,dca in pairs(_ca)do -local _da,ada=dca.getSize()if(dca.name==_ba)then return aba+aca,bba+cba end -aca=aca+_da;if(ada>bca)then bca=ada end end;cba=cba+bca end;return aba,bba end}end end -aa["libraries"]["basaltLogs"]=function(...)local ab=""local bb="basaltLog.txt"local cb="Debug" -fs.delete( -ab~=""and ab.."/"..bb or bb) -local db={__call=function(_c,ac,bc)if(ac==nil)then return end -local cc=ab~=""and ab.."/"..bb or bb -local dc=fs.open(cc,fs.exists(cc)and"a"or"w") -dc.writeLine("[Basalt][".. (bc and bc or cb).."]: "..tostring(ac))dc.close()end}return setmetatable({},db)end -aa["libraries"]["bimg"]=function(...)local ab,bb=string.sub,string.rep -local function cb(db,_c)local ac,bc=0,0 -local cc,dc,_d={},{},{}local ad,bd=1,1;local cd={} -local function dd() -for y=1,bc do if(cc[y]==nil)then cc[y]=bb(" ",ac)else cc[y]=cc[y].. -bb(" ",ac-#cc[y])end;if -(dc[y]==nil)then dc[y]=bb("0",ac)else -dc[y]=dc[y]..bb("0",ac-#dc[y])end -if(_d[y]==nil)then _d[y]=bb("f",ac)else _d[y]= -_d[y]..bb("f",ac-#_d[y])end end end -local __a=function(d_a,_aa,aaa)ad=_aa or ad;bd=aaa or bd -if(cc[bd]==nil)then cc[bd]=bb(" ",ad-1)..d_a.. -bb(" ",ac- (#d_a+ad))else cc[bd]= -ab(cc[bd],1,ad-1).. -bb(" ",ad-#cc[bd])..d_a..ab(cc[bd],ad+#d_a,ac)end;if(#cc[bd]>ac)then ac=#cc[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local a_a=function(d_a,_aa,aaa)ad=_aa or ad;bd=aaa or bd -if(_d[bd]==nil)then _d[bd]=bb("f",ad-1)..d_a.. -bb("f",ac- (#d_a+ad))else _d[bd]= -ab(_d[bd],1,ad-1).. -bb("f",ad-#_d[bd])..d_a..ab(_d[bd],ad+#d_a,ac)end;if(#_d[bd]>ac)then ac=#_d[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local b_a=function(d_a,_aa,aaa)ad=_aa or ad;bd=aaa or bd -if(dc[bd]==nil)then dc[bd]=bb("0",ad-1)..d_a.. -bb("0",ac- (#d_a+ad))else dc[bd]= -ab(dc[bd],1,ad-1).. -bb("0",ad-#dc[bd])..d_a..ab(dc[bd],ad+#d_a,ac)end;if(#dc[bd]>ac)then ac=#dc[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local function c_a(d_a)cd={}cc,dc,_d={},{},{} -for _aa,aaa in pairs(db)do if(type(_aa)=="string")then cd[_aa]=aaa else -cc[_aa],dc[_aa],_d[_aa]=aaa[1],aaa[2],aaa[3]end end;_c.updateSize(ac,bc)end;if(db~=nil)then ac=#db[1][1]bc=#db;c_a(db)end -return -{recalculateSize=dd,setFrame=c_a,getFrame=function()local d_a={} -for _aa,aaa in -pairs(cc)do table.insert(d_a,{aaa,dc[_aa],_d[_aa]})end;for _aa,aaa in pairs(cd)do d_a[_aa]=aaa end;return d_a,ac,bc end,getImage=function() -local d_a={}for _aa,aaa in pairs(cc)do -table.insert(d_a,{aaa,dc[_aa],_d[_aa]})end;return d_a end,setFrameData=function(d_a,_aa) -if( -_aa~=nil)then cd[d_a]=_aa else if(type(d_a)=="table")then cd=d_a end end end,setFrameImage=function(d_a) -for _aa,aaa in pairs(d_a.t)do -cc[_aa]=d_a.t[_aa]dc[_aa]=d_a.fg[_aa]_d[_aa]=d_a.bg[_aa]end end,getFrameImage=function() -return{t=cc,fg=dc,bg=_d}end,getFrameData=function(d_a)return(d_a~=nil and cd[d_a]or cd)end,blit=function(d_a,_aa,aaa,baa,caa) -__a(d_a,baa,caa)b_a(_aa,baa,caa)a_a(aaa,baa,caa)end,text=__a,fg=b_a,bg=a_a,getSize=function()return -ac,bc end,setSize=function(d_a,_aa)local aaa,baa,caa={},{},{} -for _y=1,_aa do -if(cc[_y]~=nil)then aaa[_y]=ab(cc[_y],1,d_a)..bb(" ", -d_a-ac)else aaa[_y]=bb(" ",d_a)end;if(dc[_y]~=nil)then -baa[_y]=ab(dc[_y],1,d_a)..bb("0",d_a-ac)else baa[_y]=bb("0",d_a)end;if -(_d[_y]~=nil)then caa[_y]=ab(_d[_y],1,d_a)..bb("f",d_a-ac)else -caa[_y]=bb("f",d_a)end end;cc,dc,_d=aaa,baa,caa;ac,bc=d_a,_aa end}end -return -function(db)local _c={} -local ac={creator="Bimg Library by NyoriE",date=os.date("!%Y-%m-%dT%TZ")}local bc,cc=0,0;local dc={} -local function _d(cd,dd)cd=cd or#_c+1 -table.insert(_c,cd,cb(dd,dc))if(dd==nil)then _c[cd].setSize(bc,cc)end end;local function ad(cd)table.remove(_c,cd or#_c)end -local function bd(cd,dd) -local __a=_c[cd] -if(__a~=nil)then local a_a=cd+dd;if(a_a>=1)and(a_a<=#_c)then table.remove(_c,cd) -table.insert(_c,a_a,__a)end end end -dc={updateSize=function(cd,dd,__a)local a_a=__a==true and true or false -if(cd>bc)then a_a=true;bc=cd end;if(dd>cc)then a_a=true;cc=dd end -if(a_a)then for b_a,c_a in pairs(_c)do c_a.setSize(bc,cc) -c_a.recalculateSize()end end end,text=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.text(dd,__a,a_a)end,fg=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.fg(dd,__a,a_a)end,bg=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.bg(dd,__a,a_a)end,blit=function(cd,dd,__a,a_a,b_a,c_a) -local d_a=_c[cd]if(d_a==nil)then d_a=_d(cd)end;d_a.blit(dd,__a,a_a,b_a,c_a)end,setSize=function(cd,dd) -bc=cd;cc=dd;for __a,a_a in pairs(_c)do a_a.setSize(cd,dd)end end,getFrame=function(cd)if( -_c[cd]~=nil)then return _c[cd].getFrame()end end,getFrameObjects=function()return -_c end,getFrames=function()local cd={}for dd,__a in pairs(_c)do local a_a=__a.getFrame() -table.insert(cd,a_a)end;return cd end,getFrameObject=function(cd)return -_c[cd]end,addFrame=function(cd)local dd=cb()if(#_c<=1)then -if(ac.animated==nil)then ac.animated=true end -if(ac.secondsPerFrame==nil)then ac.secondsPerFrame=0.2 end end;_d(cd)return dd end,removeFrame=function(cd) -ad(cd) -if(#_c<=1)then if(ac.animated==nil)then ac.animated=true end;if -(ac.secondsPerFrame==nil)then ac.secondsPerFrame=0.2 end end end,moveFrame=bd,setFrameData=function(cd,dd,__a) -if( -_c[cd]~=nil)then _c[cd].setFrameData(dd,__a)end end,getFrameData=function(cd,dd)return _c[cd]~=nil and -_c[cd].getFrameData(dd)end,getSize=function()return -bc,cc end,setAnimation=function(cd)ac.animation=cd end,setMetadata=function(cd,dd)if(dd~=nil)then ac[cd]=dd else if( -type(cd)=="table")then ac=cd end end end,getMetadata=function(cd)return -cd~=nil and ac[cd]or ac end,createBimg=function() -local cd={} -for dd,__a in pairs(_c)do local a_a=__a.getFrame()table.insert(cd,a_a)end;for dd,__a in pairs(ac)do cd[dd]=__a end;cd.width=bc;cd.height=cc;return cd end} -if(db~=nil)then for cd,dd in pairs(db)do -if(type(cd)=="string")then ac[cd]=dd else _d(cd,dd)end end -if -(ac.width==nil)or(ac.height==nil)then for cd,dd in pairs(_c)do local __a,a_a=dd.getSize()if(__a>bc)then __a=bc end -if(a_a>cc)then a_a=cc end end -dc.updateSize(bc,cc,true)end else _d(1)end;return dc end end -aa["libraries"]["basaltEvent"]=function(...) -return -function()local ab={}local bb={} -local cb={registerEvent=function(db,_c,ac)if(ab[_c]==nil)then ab[_c]={} -bb[_c]=1 end;ab[_c][bb[_c]]=ac;bb[_c]=bb[_c]+1;return -bb[_c]-1 end,removeEvent=function(db,_c,ac)ab[_c][ac[_c]]= -nil end,sendEvent=function(db,_c,...)local ac -if(ab[_c]~=nil)then for bc,cc in pairs(ab[_c])do -local dc=cc(...)if(dc==false)then ac=dc end end end;return ac end}cb.__index=cb;return cb end end -aa["libraries"]["bigfont"]=function(...)local ab=da("tHex") -local bb={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{"000110000110110000110010101000000010000000100101","000000110110000000000010101000000010000000100101","000000000000000000000000000000000000000000000000","100010110100000010000110110000010100000100000110","000000110000000010110110000110000000000000110000","000000000000000000000000000000000000000000000000","000000110110000010000000100000100000000000000010","000000000110110100010000000010000000000000000100","000000000000000000000000000000000000000000000000","010000000000100110000000000000000000000110010000","000000000000000000000000000010000000010110000000","000000000000000000000000000000000000000000000000","011110110000000100100010110000000100000000000000","000000000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110000110110000000000000000000010100100010000000","000010000000000000110110000000000100010010000000","000000000000000000000000000000000000000000000000","010110010110100110110110010000000100000110110110","000000000000000000000110000000000110000000000000","000000000000000000000000000000000000000000000000","010100010110110000000000000000110000000010000000","110110000000000000110000110110100000000010000000","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","100100100100100100100100100100100100100100100100","000000110100110110000010000011110000000000011000","000000000100000000000010000011000110000000001000","000000000000000000000000000000000000000000000000","010000100100000000000000000100000000010010110000","000000000000000000000000000000110110110110110000","000000000000000000000000000000000000000000000000","110110110110110110000000110110110110110110110110","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","000000000000110110000110010000000000000000010010","000010000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110110110110000000000000","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110000000000000000010000","000000000000000000000000100000000000000110000110","000000000000000000000000000000000000000000000000"}}local cb={}local db={} -do local bc=0;local cc=#bb[1]local dc=#bb[1][1] -for i=1,cc,3 do -for j=1,dc,3 do -local _d=string.char(bc)local ad={}ad[1]=bb[1][i]:sub(j,j+2) -ad[2]=bb[1][i+1]:sub(j,j+2)ad[3]=bb[1][i+2]:sub(j,j+2)local bd={}bd[1]=bb[2][i]:sub(j, -j+2)bd[2]=bb[2][i+1]:sub(j,j+2)bd[3]=bb[2][ -i+2]:sub(j,j+2)db[_d]={ad,bd}bc=bc+1 end end;cb[1]=db end -local function _c(bc,cc)local dc={["0"]="1",["1"]="0"}if bc<=#cb then return true end -for f=#cb+1,bc do local _d={}local ad=cb[ -f-1] -for char=0,255 do local bd=string.char(char)local cd={}local dd={} -local __a=ad[bd][1]local a_a=ad[bd][2] -for i=1,#__a do local b_a,c_a,d_a,_aa,aaa,baa={},{},{},{},{},{} -for j=1,#__a[1]do -local caa=db[__a[i]:sub(j,j)][1]table.insert(b_a,caa[1]) -table.insert(c_a,caa[2])table.insert(d_a,caa[3]) -local daa=db[__a[i]:sub(j,j)][2] -if a_a[i]:sub(j,j)=="1"then -table.insert(_aa,(daa[1]:gsub("[01]",dc))) -table.insert(aaa,(daa[2]:gsub("[01]",dc))) -table.insert(baa,(daa[3]:gsub("[01]",dc)))else table.insert(_aa,daa[1]) -table.insert(aaa,daa[2])table.insert(baa,daa[3])end end;table.insert(cd,table.concat(b_a)) -table.insert(cd,table.concat(c_a))table.insert(cd,table.concat(d_a)) -table.insert(dd,table.concat(_aa))table.insert(dd,table.concat(aaa)) -table.insert(dd,table.concat(baa))end;_d[bd]={cd,dd}if cc then cc="Font"..f.."Yeld"..char -os.queueEvent(cc)os.pullEvent(cc)end end;cb[f]=_d end;return true end -local function ac(bc,cc,dc,_d,ad) -if not type(cc)=="string"then error("Not a String",3)end -local bd=type(dc)=="string"and dc:sub(1,1)or ab[dc]or -error("Wrong Front Color",3) -local cd=type(_d)=="string"and _d:sub(1,1)or ab[_d]or -error("Wrong Back Color",3)if(cb[bc]==nil)then _c(3,false)end;local dd=cb[bc]or -error("Wrong font size selected",3)if cc==""then -return{{""},{""},{""}}end;local __a={} -for baa in cc:gmatch('.')do table.insert(__a,baa)end;local a_a={}local b_a=#dd[__a[1]][1] -for nLine=1,b_a do local baa={} -for i=1,#__a do baa[i]=dd[__a[i]]and -dd[__a[i]][1][nLine]or""end;a_a[nLine]=table.concat(baa)end;local c_a={}local d_a={}local _aa={["0"]=bd,["1"]=cd}local aaa={["0"]=cd,["1"]=bd} -for nLine=1,b_a do -local baa={}local caa={} -for i=1,#__a do -local daa=dd[__a[i]]and dd[__a[i]][2][nLine]or"" -baa[i]=daa:gsub("[01]", -ad and{["0"]=dc:sub(i,i),["1"]=_d:sub(i,i)}or _aa) -caa[i]=daa:gsub("[01]", -ad and{["0"]=_d:sub(i,i),["1"]=dc:sub(i,i)}or aaa)end;c_a[nLine]=table.concat(baa) -d_a[nLine]=table.concat(caa)end;return{a_a,c_a,d_a}end;return ac end -aa["libraries"]["layout"]=function(...) -local function ab(cb)local db={}db.___value=nil;db.___name=cb -db.___children={}db.___props={}function db:value()return self.___value end;function db:setValue(_c) -self.___value=_c end;function db:name()return self.___name end;function db:setName(_c) -self.___name=_c end;function db:children()return self.___children end;function db:numChildren()return -#self.___children end -function db:addChild(_c) -if -self[_c:name()]~=nil then if -type(self[_c:name()].name)=="function"then local ac={}table.insert(ac,self[_c:name()]) -self[_c:name()]=ac end -table.insert(self[_c:name()],_c)else self[_c:name()]=_c end;table.insert(self.___children,_c)end;function db:properties()return self.___props end;function db:numProperties() -return#self.___props end -function db:addProperty(_c,ac)local bc="@".._c -if self[bc]~=nil then if -type(self[bc])=="string"then local cc={}table.insert(cc,self[bc]) -self[bc]=cc end -table.insert(self[bc],ac)else self[bc]=ac end -table.insert(self.___props,{name=_c,value=self[_c]})end;return db end;local bb={} -function bb:ToXmlString(cb)cb=string.gsub(cb,"&","&") -cb=string.gsub(cb,"<","<")cb=string.gsub(cb,">",">") -cb=string.gsub(cb,"\"",""") -cb=string.gsub(cb,"([^%w%&%;%p%\t% ])",function(db) -return string.format("&#x%X;",string.byte(db))end)return cb end -function bb:FromXmlString(cb) -cb=string.gsub(cb,"&#x([%x]+)%;",function(db) -return string.char(tonumber(db,16))end) -cb=string.gsub(cb,"&#([0-9]+)%;",function(db)return string.char(tonumber(db,10))end)cb=string.gsub(cb,""","\"") -cb=string.gsub(cb,"'","'")cb=string.gsub(cb,">",">") -cb=string.gsub(cb,"<","<")cb=string.gsub(cb,"&","&")return cb end;function bb:ParseArgs(cb,db) -string.gsub(db,"(%w+)=([\"'])(.-)%2",function(_c,ac,bc) -cb:addProperty(_c,self:FromXmlString(bc))end)end -function bb:ParseXmlText(cb) -local db={}local _c=ab()table.insert(db,_c)local ac,bc,cc,dc,_d;local ad,bd=1,1 -while true do -ac,bd,bc,cc,dc,_d=string.find(cb,"<(%/?)([%w_:]+)(.-)(%/?)>",ad)if not ac then break end;local dd=string.sub(cb,ad,ac-1) -if not -string.find(dd,"^%s*$")then -local __a=(_c:value()or"")..self:FromXmlString(dd)db[#db]:setValue(__a)end -if _d=="/"then local __a=ab(cc)self:ParseArgs(__a,dc) -_c:addChild(__a)elseif bc==""then local __a=ab(cc)self:ParseArgs(__a,dc) -table.insert(db,__a)_c=__a else local __a=table.remove(db)_c=db[#db] -if#db<1 then error("XmlParser: nothing to close with ".. -cc)end;if __a:name()~=cc then -error("XmlParser: trying to close "..__a.name.." with "..cc)end;_c:addChild(__a)end;ad=bd+1 end;local cd=string.sub(cb,ad)if#db>1 then -error("XmlParser: unclosed "..db[#db]:name())end;return _c end -function bb:loadFile(cb,db)if not db then db=system.ResourceDirectory end -local _c=system.pathForFile(cb,db)local ac,bc=io.open(_c,"r") -if ac and not bc then local cc=ac:read("*a") -io.close(ac)return self:ParseXmlText(cc),nil else print(bc)return nil end end;return bb end -aa["libraries"]["images"]=function(...)local ab,bb=string.sub,math.floor;local function cb(ad)return -{[1]={{},{},paintutils.loadImage(ad)}},"bimg"end;local function db(ad)return -paintutils.loadImage(ad),"nfp"end -local function _c(ad) -local bd=fs.open(ad,"rb")local cd=textutils.unserialize(bd.readAll()) -bd.close()if(cd~=nil)then return cd,"bimg"end end;local function ac(ad)end;local function bc(ad)end;local function cc(ad,bd) -if(bd==nil)then if(ad:find(".bimg"))then return _c(ad)elseif -(ad:find(".bbf"))then return ac(ad)else return db(ad)end end end -local function dc(ad,bd)if( -bd==nil)then -if(ad:find(".bimg"))then return _c(ad)elseif(ad:find(".bbf"))then return bc(ad)else return cb(ad)end end end -local function _d(ad,bd,cd) -local dd,__a=ad.width or#ad[1][1][1],ad.height or#ad[1]local a_a={} -for b_a,c_a in pairs(ad)do -if(type(b_a)=="number")then local d_a={} -for y=1,cd do local _aa,aaa,baa="","","" -local caa=bb(y/cd*__a+0.5) -if(c_a[caa]~=nil)then -for x=1,bd do local daa=bb(x/bd*dd+0.5)_aa=_aa.. -ab(c_a[caa][1],daa,daa) -aaa=aaa..ab(c_a[caa][2],daa,daa)baa=baa..ab(c_a[caa][3],daa,daa)end;table.insert(d_a,{_aa,aaa,baa})end end;table.insert(a_a,b_a,d_a)else a_a[b_a]=c_a end end;a_a.width=bd;a_a.height=cd;return a_a end -return{loadNFP=db,loadBIMG=_c,loadImage=cc,resizeBIMG=_d,loadImageAsBimg=dc}end -aa["libraries"]["module"]=function(...)return function(ab)local bb,cb=pcall(da,ab) -return bb and cb or nil end end -aa["libraries"]["process"]=function(...)local ab={}local bb={}local cb=0 -local db=dofile("rom/modules/main/cc/require.lua").make -function bb:new(_c,ac,bc,...)local cc={...} -local dc=setmetatable({path=_c},{__index=self})dc.window=ac;ac.current=term.current;ac.redirect=term.redirect -dc.processId=cb -if(type(_c)=="string")then -dc.coroutine=coroutine.create(function() -local _d=shell.resolveProgram(_c)local ad=setmetatable(bc,{__index=_ENV})ad.shell=shell -ad.basaltProgram=true;ad.arg={[0]=_c,table.unpack(cc)} -ad.require,ad.package=db(ad,fs.getDir(_d)) -if(fs.exists(_d))then local bd=fs.open(_d,"r")local cd=bd.readAll() -bd.close()local dd=load(cd,_c,"bt",ad)if(dd~=nil)then return dd()end end end)elseif(type(_c)=="function")then -dc.coroutine=coroutine.create(function() -_c(table.unpack(cc))end)else return end;ab[cb]=dc;cb=cb+1;return dc end -function bb:resume(_c,...)local ac=term.current()term.redirect(self.window) -if( -self.filter~=nil)then if(_c~=self.filter)then return end;self.filter=nil end;local bc,cc=coroutine.resume(self.coroutine,_c,...)if bc then -self.filter=cc else printError(cc)end;term.redirect(ac) -return bc,cc end -function bb:isDead() -if(self.coroutine~=nil)then -if -(coroutine.status(self.coroutine)=="dead")then table.remove(ab,self.processId)return true end else return true end;return false end -function bb:getStatus()if(self.coroutine~=nil)then -return coroutine.status(self.coroutine)end;return nil end -function bb:start()coroutine.resume(self.coroutine)end;return bb end -aa["libraries"]["tHex"]=function(...) -return -{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}end -aa["libraries"]["utils"]=function(...)local ab=string.sub -local bb=function(dc,_d)if _d==nil then _d="%s"end -local ad={}for bd in string.gmatch(dc,"([^".._d.."]+)")do -table.insert(ad,bd)end;return ad end -local cb={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local db,_c,ac={},{},{}for i=0,15 do _c[2 ^i]=i end -do local dc="0123456789abcdef" -for i=1,16 do db[dc:sub(i,i)]= -i-1;db[i-1]=dc:sub(i,i) -ac[dc:sub(i,i)]=2 ^ (i-1)ac[2 ^ (i-1)]=dc:sub(i,i)local _d=cb[i-1]for i=1,#_d do -_d[i]=2 ^_d[i]end end end -local function bc(dc)local _d=cb[_c[dc[#dc][1]]] -for j=1,#_d do local ad=_d[j]for i=1,#dc-1 do if -dc[i][1]==ad then return i end end end;return 1 end -local function cc(dc,_d) -if not _d then local bd={}_d={}for i=1,6 do local cd=dc[i]local dd=_d[cd] -_d[cd],bd[i]=dd and(dd+1)or 1,cd end;dc=bd end;local ad={}for bd,cd in pairs(_d)do ad[#ad+1]={bd,cd}end -if#ad>1 then -while#ad>2 do -table.sort(ad,function(b_a,c_a)return -b_a[2]>c_a[2]end)local cd,dd=bc(ad),#ad;local __a,a_a=ad[dd][1],ad[cd][1] -for i=1,6 do if dc[i]==__a then -dc[i]=a_a;ad[cd][2]=ad[cd][2]+1 end end;ad[dd]=nil end;local bd=128 -for i=1,#dc-1 do if dc[i]~=dc[6]then bd=bd+2 ^ (i-1)end end;return string.char(bd), -ac[ad[1][1]==dc[6]and ad[2][1]or ad[1][1]],ac[dc[6]]else -return"\128",ac[dc[1]],ac[dc[1]]end end -return -{getTextHorizontalAlign=function(dc,_d,ad,bd)dc=string.sub(dc,1,_d)local cd=_d-string.len(dc) -if -(ad=="right")then dc=string.rep(bd or" ",cd)..dc elseif(ad=="center")then -dc=string.rep( -bd or" ",math.floor(cd/2))..dc.. -string.rep(bd or" ",math.floor(cd/2)) -dc=dc.. (string.len(dc)<_d and(bd or" ")or"")else dc=dc..string.rep(bd or" ",cd)end;return dc end,getTextVerticalAlign=function(dc,_d) -local ad=0 -if(_d=="center")then ad=math.ceil(dc/2)if(ad<1)then ad=1 end end;if(_d=="bottom")then ad=dc end;if(ad<1)then ad=1 end;return ad end,rpairs=function(dc)return function(_d,ad)ad= -ad-1;if ad~=0 then return ad,_d[ad]end end,dc, -#dc+1 end,tableCount=function(dc) -local _d=0;if(dc~=nil)then for ad,bd in pairs(dc)do _d=_d+1 end end;return _d end,splitString=bb,createText=function(dc,_d) -local ad=bb(dc,"\n")local bd={} -for cd,dd in pairs(ad)do local __a=""local a_a=bb(dd," ") -for b_a,c_a in pairs(a_a)do -if(#__a+#c_a<=_d)then __a= -__a==""and c_a or __a.." "..c_a;if(b_a==#a_a)then -table.insert(bd,__a)end else table.insert(bd,__a)__a=c_a:sub(1,_d)if( -b_a==#a_a)then table.insert(bd,__a)end end end end;return bd end,getValueFromXML=function(dc,_d) -local ad;if(type(_d)~="table")then return end;if(_d[dc]~=nil)then -if -(type(_d[dc])=="table")then if(_d[dc].value~=nil)then ad=_d[dc]:value()end end end;if(ad==nil)then -ad=_d["@"..dc]end;if(ad=="true")then ad=true elseif(ad=="false")then ad=false elseif(tonumber(ad)~=nil)then -ad=tonumber(ad)end;return ad end,numberFromString=function(dc)return load( -"return "..dc)()end,uuid=function() -local dc=math.random -local function _d()local ad='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'return -string.gsub(ad,'[xy]',function(bd)local cd= -(bd=='x')and dc(0,0xf)or dc(8,0xb) -return string.format('%x',cd)end)end;return _d()end,array=function(dc,_d)return -load( -"return {".. -("nil,"):rep(dc).. ("[0]=nil,"):rep(_d).."}")()end,shrink=function(dc,_d)local ad,bd,cd,dd={{},{},{}},0, -#dc+#dc%3,_d or colours.black;for i=1,#dc do if#dc[i]> -bd then bd=#dc[i]end end -for y=0,cd-1,3 do -local __a,a_a,b_a,c_a={},{},{},1 -for x=0,bd-1,2 do local d_a,_aa={},{} -for yy=1,3 do -for xx=1,2 do -d_a[#d_a+1]=(dc[y+yy]and dc[y+yy][x+xx])and -(dc[y+ -yy][x+xx]==0 and dd or dc[y+yy][x+xx])or dd;_aa[d_a[#d_a]]= -_aa[d_a[#d_a]]and(_aa[d_a[#d_a]]+1)or 1 end end;__a[c_a],a_a[c_a],b_a[c_a]=cc(d_a,_aa)c_a=c_a+1 end -ad[1][#ad[1]+1],ad[2][#ad[2]+1],ad[3][#ad[3]+1]=table.concat(__a),table.concat(a_a),table.concat(b_a)end;ad.width,ad.height=#ad[1][1],#ad[1]return ad end}end;return aa["main"]() \ No newline at end of file diff --git a/docs/docs1_6/versions/basalt.lua b/docs/docs1_6/versions/basalt.lua deleted file mode 100644 index c6c1b29..0000000 --- a/docs/docs1_6/versions/basalt.lua +++ /dev/null @@ -1,3083 +0,0 @@ -local aa={}local ba=true;local ca=require -local da=function(ab) -for bb,cb in pairs(aa)do -if(type(cb)=="table")then for db,_c in pairs(cb)do if(db==ab)then -return _c()end end else if(bb==ab)then return cb()end end end;return ca(ab)end -local _b=function(ab)if(ab~=nil)then return aa[ab]end;return aa end -aa["module"]=function(...)return -function(ab)local bb,cb=pcall(da,ab)return bb and cb or nil end end -aa["loadObjects"]=function(...)local ab={}if(ba)then -for db,_c in pairs(_b("objects"))do ab[db]=_c()end;return ab end;local bb=table.pack(...)local cb=fs.getDir( -bb[2]or"Basalt")if(cb==nil)then -error("Unable to find directory "..bb[2].. -" please report this bug to our discord.")end;for db,_c in -pairs(fs.list(fs.combine(cb,"objects")))do -if(_c~="example.lua")then local ac=_c:gsub(".lua","")ab[ac]=da(ac)end end;return ab end -aa["main"]=function(...)local ab=da("basaltEvent")()local bb=da("Frame") -local cb=da("theme")local db=da("utils")local _c=da("basaltLogs")local ac=db.uuid -local bc=db.createText;local cc=db.tableCount;local dc=300;local _d=50;local ad=term.current()local bd="1.6.5"local cd=fs.getDir( -table.pack(...)[2]or"") -local dd,__a,a_a,b_a,c_a,d_a={},{},{},{},{},{}local _aa,aaa,baa,caa;local daa={}if -not term.isColor or not term.isColor()then -error('Basalt requires an advanced (golden) computer to run.',0)end;local _ba={} -for dab,_bb in -pairs(colors)do if(type(_bb)=="number")then -_ba[dab]={ad.getPaletteColor(_bb)}end end -local function aba()caa=false;ad.clear()ad.setCursorPos(1,1) -for dab,_bb in pairs(colors)do if(type(_bb)== -"number")then -ad.setPaletteColor(_bb,colors.packRGB(table.unpack(_ba[dab])))end end end -local function bba(dab)ad.clear()ad.setBackgroundColor(colors.black) -ad.setTextColor(colors.red)local _bb,abb=ad.getSize()if(daa.logging)then _c(dab,"Error")end;local bbb=bc( -"Basalt error: "..dab,_bb)local cbb=1;for dbb,_cb in pairs(bbb)do -ad.setCursorPos(1,cbb)ad.write(_cb)cbb=cbb+1 end;ad.setCursorPos(1, -cbb+1)caa=false end -local function cba(dab) -assert(dab~="function","Schedule needs a function in order to work!") -return function(...)local _bb=coroutine.create(dab) -local abb,bbb=coroutine.resume(_bb,...) -if(abb)then table.insert(d_a,{_bb,bbb})else bba(bbb)end end end;local dba=function(dab,_bb)c_a[dab]=_bb end -local _ca=function(dab)return c_a[dab]end;local aca=function(dab)cb=dab end -local bca=function(dab)return cb[dab]end -local cca={getDynamicValueEventSetting=function()return daa.dynamicValueEvents end,getMainFrame=function()return _aa end,setVariable=dba,getVariable=_ca,getTheme=bca,setMainFrame=function(dab) -_aa=dab end,getActiveFrame=function()return aaa end,setActiveFrame=function(dab)aaa=dab end,getFocusedObject=function()return baa end,setFocusedObject=function(dab)baa=dab end,getMonitorFrame=function(dab)return -a_a[dab]or b_a[dab][1]end,setMonitorFrame=function(dab,_bb,abb)if(_aa==_bb)then -_aa=nil end -if(abb)then b_a[dab]={_bb,sides}else a_a[dab]=_bb end;if(_bb==nil)then b_a[dab]=nil end end,getBaseTerm=function()return -ad end,schedule=cba,stop=aba,newFrame=bb,getDirectory=function()return cd end} -local function dca(dab,...) -if(#d_a>0)then local _bb={} -for n=1,#d_a do -if(d_a[n]~=nil)then -if -(coroutine.status(d_a[n][1])=="suspended")then -if(d_a[n][2]~=nil)then -if(d_a[n][2]==dab)then -local abb,bbb=coroutine.resume(d_a[n][1],dab,...)d_a[n][2]=bbb;if not(abb)then bba(bbb)end end else local abb,bbb=coroutine.resume(d_a[n][1],dab,...) -d_a[n][2]=bbb;if not(abb)then bba(bbb)end end else table.insert(_bb,n)end end end -for n=1,#_bb do table.remove(d_a,_bb[n]- (n-1))end end end -local function _da()if(caa==false)then return end;if(_aa~=nil)then _aa:draw() -_aa:updateTerm()end -for dab,_bb in pairs(a_a)do _bb:draw()_bb:updateTerm()end -for dab,_bb in pairs(b_a)do _bb[1]:draw()_bb[1]:updateTerm()end end;local ada,bda,cda=nil,nil,nil;local dda=nil -local function __b(dab,_bb,abb,bbb)ada,bda,cda=_bb,abb,bbb;if(dda==nil)then -dda=os.startTimer(dc/1000)end end -local function a_b()dda=nil;_aa:hoverHandler(bda,cda,ada)aaa=_aa end;local b_b,c_b,d_b=nil,nil,nil;local _ab=nil;local function aab()_ab=nil;_aa:dragHandler(b_b,c_b,d_b) -aaa=_aa end;local function bab(dab,_bb,abb,bbb)b_b,c_b,d_b=_bb,abb,bbb -if(_d<50)then aab()else if(_ab==nil)then _ab=os.startTimer( -_d/1000)end end end -local function cab(dab,...) -local _bb={...} -if(ab:sendEvent("basaltEventCycle",dab,...)==false)then return end;if(dab=="terminate")then daa.stop()end -if(_aa~=nil)then -local abb={mouse_click=_aa.mouseHandler,mouse_up=_aa.mouseUpHandler,mouse_scroll=_aa.scrollHandler,mouse_drag=bab,mouse_move=__b}local bbb=abb[dab] -if(bbb~=nil)then bbb(_aa,...)dca(dab,...)_da()return end end -if(dab=="monitor_touch")then if(a_a[_bb[1]]~=nil)then -a_a[_bb[1]]:mouseHandler(1,_bb[2],_bb[3],true)aaa=a_a[_bb[1]]end -if -(cc(b_a)>0)then for abb,bbb in pairs(b_a)do -bbb[1]:mouseHandler(1,_bb[2],_bb[3],true,_bb[1])end end;dca(dab,...)_da()return end -if(aaa~=nil)then -local abb={char=aaa.charHandler,key=aaa.keyHandler,key_up=aaa.keyUpHandler}local bbb=abb[dab]if(bbb~=nil)then if(dab=="key")then dd[_bb[1]]=true elseif(dab=="key_up")then -dd[_bb[1]]=false end;bbb(aaa,...)dca(dab,...) -_da()return end end -if(dab=="timer")and(_bb[1]==dda)then a_b()elseif -(dab=="timer")and(_bb[1]==_ab)then aab()else -for abb,bbb in pairs(__a)do bbb:eventHandler(dab,...)end end;dca(dab,...)_da()end -daa={logging=false,dynamicValueEvents=false,setTheme=aca,getTheme=bca,drawFrames=_da,getVersion=function()return bd end,setVariable=dba,getVariable=_ca,setBaseTerm=function(dab)ad=dab end,log=function(...)_c(...)end,setMouseMoveThrottle=function(dab) -if -(_HOST:find("CraftOS%-PC"))then if(config.get("mouse_move_throttle")~=10)then -config.set("mouse_move_throttle",10)end -if(dab<100)then dc=100 else dc=dab end;return true end;return false end,setMouseDragThrottle=function(dab)if( -dab<=0)then _d=0 else _ab=nil;_d=dab end end,autoUpdate=function(dab) -caa=dab;if(dab==nil)then caa=true end;local function _bb()_da()while caa do -cab(os.pullEventRaw())end end -local abb,bbb=xpcall(_bb,debug.traceback)if not(abb)then bba(bbb)return end end,update=function(dab,...)if( -dab~=nil)then local _bb,abb=xpcall(cab,debug.traceback,dab,...)if not(_bb)then -bba(abb)return end end end,stop=aba,stopUpdate=aba,isKeyDown=function(dab)if( -dd[dab]==nil)then return false end;return dd[dab]end,getFrame=function(dab)for _bb,abb in -pairs(__a)do if(abb.name==dab)then return abb end end end,getActiveFrame=function()return -aaa end,setActiveFrame=function(dab) -if(dab:getType()=="Frame")then aaa=dab;return true end;return false end,onEvent=function(...) -for dab,_bb in -pairs(table.pack(...))do if(type(_bb)=="function")then -ab:registerEvent("basaltEventCycle",_bb)end end end,schedule=cba,createFrame=function(dab) -dab=dab or ac() -for abb,bbb in pairs(__a)do if(bbb.name==dab)then return nil end end;local _bb=bb(dab,nil,nil,cca)_bb:init() -table.insert(__a,_bb)if -(_aa==nil)and(_bb:getName()~="basaltDebuggingFrame")then _bb:show()end;return _bb end,removeFrame=function(dab)__a[dab]= -nil end,setProjectDir=function(dab)cd=dab end,debug=function(...)local dab={...}if(_aa==nil)then print(...) -return end -if(_aa.name~="basaltDebuggingFrame")then if(_aa~=daa.debugFrame)then -daa.debugLabel:setParent(_aa)end end;local _bb="" -for abb,bbb in pairs(dab)do _bb=_bb.. -tostring(bbb).. (#dab~=abb and", "or"")end;daa.debugLabel:setText("[Debug] ".._bb) -for abb,bbb in -pairs(bc(_bb,daa.debugList:getWidth()))do daa.debugList:addItem(bbb)end;if(daa.debugList:getItemCount()>50)then -daa.debugList:removeItem(1)end -daa.debugList:setValue(daa.debugList:getItem(daa.debugList:getItemCount()))if -(daa.debugList.getItemCount()>daa.debugList:getHeight())then -daa.debugList:setOffset(daa.debugList:getItemCount()- -daa.debugList:getHeight())end -daa.debugLabel:show()end} -daa.debugFrame=daa.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) -daa.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if( -daa.oldFrame~=nil)then daa.oldFrame:show()end end):setBackground(colors.red):show() -daa.debugList=daa.debugFrame:addList("debugList"):setSize("parent.w - 2","parent.h - 3"):setPosition(2,3):setScrollable(true):show() -daa.debugLabel=daa.debugFrame:addLabel("debugLabel"):onClick(function() -daa.oldFrame=_aa;daa.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return daa end -aa["theme"]=function(...) -return -{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=false,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green,LabelBG=false,LabelText=colors.black,GraphBG=colors.gray,GraphText=colors.black}end -aa["Frame"]=function(...)local ab=da("module")local bb=da("Object") -local cb=da("loadObjects")local db=da("basaltDraw")local _c=da("utils")local ac=ab("layout") -local bc=ab("basaltMon")local cc=_c.uuid;local dc=_c.rpairs;local _d=_c.getValueFromXML;local ad=_c.tableCount -local bd,cd,dd=string.sub,math.min,math.max -return -function(__a,a_a,b_a,c_a)local d_a=bb(__a)local _aa="Frame"local aaa={}local baa={}local caa={}local daa={}local _ba={}local aba={} -local bba={}local cba={}local dba=0;local _ca=b_a or term.current()local aca=""local bca=false -local cca=false;local dca=false;local _da=0;local ada=0;local bda=false;local cda=0;local dda=false;local __b=false;local a_b=""local b_b=false -local c_b=false;local d_b;local _ab;local aab=true;local bab=true;local cab=false;local dab={}local _bb={} -d_a:setZIndex(10)local abb=db(_ca)local bbb=false;local cbb=1;local dbb=1;local _cb=colors.white;local acb,bcb=0,0;local ccb={} -local function dcb(dbc,_cc)if(_cc~= -nil)then _cc:setValuesByXMLData(dbc)end end -local function _db(dbc,_cc,acc) -if(dbc~=nil)then if(dbc.properties~=nil)then dbc={dbc}end;for bcc,ccc in pairs(dbc)do local dcc=_cc(acc, -ccc["@id"]or cc()) -table.insert(ccb,dcc)dcb(ccc,dcc)end end end -local function adb(dbc)if(type(dbc)~="string")then dbc=dbc.name end;for _cc,acc in pairs(aaa)do -for bcc,ccc in -pairs(acc)do if(ccc:getName()==dbc)then return ccc end end end end -local function bdb(dbc)local _cc=adb(dbc)if(_cc~=nil)then return _cc end -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do if( -dcc:getType()=="Frame")then local _dc=dcc:getDeepObject(dbc) -if(_dc~=nil)then return _dc end end end end end -local function cdb(dbc)local _cc=dbc:getZIndex() -if(adb(dbc.name)~=nil)then return nil end -if(aaa[_cc]==nil)then -for x=1,#baa+1 do if(baa[x]~=nil)then if(_cc==baa[x])then break end;if -(_cc>baa[x])then table.insert(baa,x,_cc)break end else -table.insert(baa,_cc)end end;if(#baa<=0)then table.insert(baa,_cc)end;aaa[_cc]={}end;dbc.parent=caa;if(dbc.init~=nil)then dbc:init()end -table.insert(aaa[_cc],dbc)return dbc end -local function ddb(dbc,_cc) -for acc,bcc in pairs(daa)do -for ccc,dcc in pairs(bcc)do -for _dc,adc in pairs(dcc)do -if(adc==_cc)then -table.remove(daa[acc][ccc],_dc)if(dbc.parent~=nil)then if(ad(daa[acc])<=0)then -dbc.parent:removeEvent(acc,dbc)end end end end end end end -local function __c(dbc,_cc) -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if(type(_cc)=="string")then -if(dcc:getName()==_cc)then -table.remove(aaa[acc],ccc)ddb(caa,dcc)dbc:updateDraw()return true end else if(dcc==_cc)then table.remove(aaa[acc],ccc)ddb(caa,dcc) -dbc:updateDraw()return true end end end end;return false end;local function a_c(dbc,_cc,acc) -for bcc,ccc in pairs(daa[_cc])do for dcc,_dc in pairs(ccc)do -if(_dc:getName()==acc)then return _dc end end end end -local function b_c(dbc,_cc,acc) -local bcc=acc:getZIndex()if(daa[_cc]==nil)then daa[_cc]={}end;if(_ba[_cc]==nil)then -_ba[_cc]={}end -if(a_c(dbc,_cc,acc.name)~=nil)then return nil end -if(dbc.parent~=nil)then dbc.parent:addEvent(_cc,dbc)end;dab[_cc]=true -if(daa[_cc][bcc]==nil)then -for x=1,#_ba[_cc]+1 do -if -(_ba[_cc][x]~=nil)then if(bcc==_ba[_cc][x])then break end;if(bcc>_ba[_cc][x])then -table.insert(_ba[_cc],x,bcc)break end else -table.insert(_ba[_cc],bcc)end end -if(#_ba[_cc]<=0)then table.insert(_ba[_cc],bcc)end;daa[_cc][bcc]={}end;table.insert(daa[_cc][bcc],acc)return acc end -local function c_c(dbc,_cc,acc) -if(daa[_cc]~=nil)then -for bcc,ccc in pairs(daa[_cc])do -for dcc,_dc in pairs(ccc)do -if(_dc==acc)then -table.remove(daa[_cc][bcc],dcc)if(#daa[_cc][bcc]<=0)then daa[_cc][bcc]=nil -if(dbc.parent~=nil)then if( -ad(daa[_cc])<=0)then dab[_cc]=false -dbc.parent:removeEvent(_cc,dbc)end end end;return -true end end end end;return false end;local d_c=math -local function _ac(dbc) -local _cc,acc=pcall(load("return "..dbc,"",nil,{math=d_c}))if not(_cc)then -error(dbc.." is not a valid dynamic code")end;return acc end -local function aac(dbc,_cc,acc)for bcc,ccc in pairs(cba)do -if(ccc[2]==acc)and(ccc[4]==_cc)then return ccc end end;dba=dba+1 -cba[dba]={0,acc,{},_cc,dba}return cba[dba]end -local function bac(dbc,_cc)local acc={}local bcc={}for ccc in _cc:gmatch("%a+%.x")do local dcc=ccc:gsub("%.x","") -if -(dcc~="self")and(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%w+%.y")do local dcc=ccc:gsub("%.y","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end;for ccc in _cc:gmatch("%a+%.w")do local dcc=ccc:gsub("%.w","") -if(dcc~="self")and -(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%a+%.h")do local dcc=ccc:gsub("%.h","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end -for ccc,dcc in pairs(acc)do bcc[dcc]=adb(dcc)if(bcc[dcc]==nil)then -error("Dynamic Values - unable to find object "..dcc)end end;bcc["self"]=dbc;bcc["parent"]=dbc:getParent()return bcc end -local function cac(dbc,_cc)local acc=dbc;for bcc in dbc:gmatch("%w+%.x")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.x","")]:getX())end;for bcc in dbc:gmatch("%w+%.y")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.y","")]:getY())end;for bcc in dbc:gmatch("%w+%.w")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.w","")]:getWidth())end;for bcc in dbc:gmatch("%w+%.h")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.h","")]:getHeight())end;return acc end -local function dac(dbc) -if(#cba>0)then -for n=1,dba do -if(cba[n]~=nil)then local _cc;if(#cba[n][3]<=0)then -cba[n][3]=bac(cba[n][4],cba[n][2])end -_cc=cac(cba[n][2],cba[n][3])cba[n][1]=_ac(_cc)if(cba[n][4]:getType()=="Frame")then -cba[n][4]:recalculateDynamicValues()end end end -for _cc,acc in pairs(baa)do -if(aaa[acc]~=nil)then -for bcc,ccc in pairs(aaa[acc])do -if -(c_a.getDynamicValueEventSetting())then if(ccc.eventHandler~=nil)then -ccc:eventHandler("basalt_dynamicvalue",dbc)end end;if(ccc.customEventHandler~=nil)then -ccc:customEventHandler("basalt_resize",dbc)end end end end end end;local function _bc(dbc)return cba[dbc][1]end -local function abc(dbc)local _cc=0 -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if( -dcc.getHeight~=nil)and(dcc.getY~=nil)then -if -(dcc:getType()=="Dropdown")then local _dc,adc=dcc:getHeight(),dcc:getY() -local bdc,cdc=dcc:getDropdownSize()_dc=_dc+cdc-1 -if(_dc+adc-dbc:getHeight()>=_cc)then _cc=dd( -_dc+adc-dbc:getHeight(),0)end else local _dc,adc=dcc:getHeight(),dcc:getY()if( -_dc+adc-dbc:getHeight()>=_cc)then -_cc=dd(_dc+adc-dbc:getHeight(),0)end end end end end;return _cc end -local function bbc(dbc)local _cc=0 -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if -(dcc.getWidth~=nil)and(dcc.getX~=nil)then local _dc,adc=dcc:getWidth(),dcc:getX()if( -_dc+adc-dbc:getWidth()>=_cc)then -_cc=dd(_dc+adc-dbc:getWidth(),0)end end end end;return _cc end;local function cbc(dbc)if(bab)then cda=abc(dbc)end end -caa={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",addEvent=b_c,removeEvent=c_c,removeEvents=ddb,getEvent=a_c,newDynamicValue=aac,recalculateDynamicValues=dac,getDynamicValue=_bc,getType=function(dbc)return -_aa end,setZIndex=function(dbc,_cc)d_a.setZIndex(dbc,_cc)for acc,bcc in pairs(dab)do if(bcc)then -dbc.parent:addEvent(acc,dbc)end end;return dbc end,setFocusedObject=function(dbc,_cc) -if( -_ab~=_cc)then if(_ab~=nil)then -if(adb(_ab)~=nil)then _ab:loseFocusHandler()end end;if(_cc~=nil)then if(adb(_cc)~=nil)then -_cc:getFocusHandler()end end;_ab=_cc end;return dbc end,getVariable=function(dbc,_cc)return -c_a.getVariable(_cc)end,setSize=function(dbc,_cc,acc,bcc) -d_a.setSize(dbc,_cc,acc,bcc)if(dbc.parent==nil)then abb=db(_ca)end -for ccc,dcc in pairs(baa)do if(aaa[dcc]~=nil)then -for _dc,adc in -pairs(aaa[dcc])do if(adc.customEventHandler~=nil)then -adc:customEventHandler("basalt_resize",dbc)end end end end;dbc:recalculateDynamicValues()aab=false;return dbc end,setTheme=function(dbc,_cc,acc) -if( -type(_cc)=="table")then bba=_cc elseif(type(_cc)=="string")then bba[_cc]=acc end;dbc:updateDraw()return dbc end,getTheme=function(dbc,_cc) -return -bba[_cc]or(dbc.parent~=nil and dbc.parent:getTheme(_cc)or -c_a.getTheme(_cc))end,getThemeColor=function(dbc,_cc)return -_cc~=nil and _bb[_cc]or _bb end,setThemeColor=function(dbc,_cc,...) -if -(dbc.parent==nil)then -if(dbc==c_a.getActiveFrame())then -if(type(_cc)=="string")then _bb[_cc]=... -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],...)elseif(type(_cc)=="table")then -for acc,bcc in pairs(_cc)do _bb[acc]=bcc -if(type(bcc)=="number")then -_ca.setPaletteColor( -type(acc)=="number"and acc or colors[acc],bcc)else local ccc,dcc,_dc=table.unpack(bcc) -_ca.setPaletteColor( -type(acc)=="number"and acc or colors[acc],ccc,dcc,_dc)end end end end end;return dbc end,setPosition=function(dbc,_cc,acc,bcc) -d_a.setPosition(dbc,_cc,acc,bcc)dbc:recalculateDynamicValues()return dbc end,getBasaltInstance=function(dbc)return -c_a end,setOffset=function(dbc,_cc,acc) -acb=_cc~=nil and -d_c.floor(_cc<0 and d_c.abs(_cc)or-_cc)or acb -bcb=acc~=nil and -d_c.floor(acc<0 and d_c.abs(acc)or-acc)or bcb;dbc:updateDraw()return dbc end,getOffsetInternal=function(dbc)return -acb,bcb end,getOffset=function(dbc)return acb<0 and d_c.abs(acb)or-acb,bcb<0 and -d_c.abs(bcb)or-bcb end,removeFocusedObject=function(dbc)if( -_ab~=nil)then -if(adb(_ab)~=nil)then _ab:loseFocusHandler()end end;_ab=nil;return dbc end,getFocusedObject=function(dbc)return -_ab end,setCursor=function(dbc,_cc,acc,bcc,ccc) -if(dbc.parent~=nil)then -local dcc,_dc=dbc:getAnchorPosition() -dbc.parent:setCursor(_cc or false,(acc or 0)+dcc-1,(bcc or 0)+_dc-1, -ccc or _cb)else -local dcc,_dc=dbc:getAbsolutePosition(dbc:getAnchorPosition(dbc:getX(),dbc:getY(),true))bbb=_cc or false;if(acc~=nil)then cbb=dcc+acc-1 end;if(bcc~=nil)then dbb=_dc+ -bcc-1 end;_cb=ccc or _cb;if(bbb)then -_ca.setTextColor(_cb)_ca.setCursorPos(cbb,dbb)_ca.setCursorBlink(bbb)else -_ca.setCursorBlink(false)end end;return dbc end,setMovable=function(dbc,_cc) -if( -dbc.parent~=nil)then b_b=_cc or not b_b -dbc.parent:addEvent("mouse_click",dbc)dab["mouse_click"]=true -dbc.parent:addEvent("mouse_up",dbc)dab["mouse_up"]=true -dbc.parent:addEvent("mouse_drag",dbc)dab["mouse_drag"]=true end;return dbc end,setScrollable=function(dbc,_cc)bda=( -_cc or _cc==nil)and true or false -if( -dbc.parent~=nil)then dbc.parent:addEvent("mouse_scroll",dbc)end;dab["mouse_scroll"]=true;return dbc end,setScrollAmount=function(dbc,_cc)cda= -_cc or cda;bab=false;return dbc end,getScrollAmount=function(dbc)return bab and cbc(dbc)or -cda end,getCalculatedVerticalScroll=abc,getCalculatedHorizontalScroll=bbc,show=function(dbc)d_a.show(dbc) -if( -dbc.parent==nil)then c_a.setActiveFrame(dbc) -for _cc,acc in pairs(colors)do if -(type(acc)=="number")then -_ca.setPaletteColor(acc,colors.packRGB(term.nativePaletteColor((acc))))end end -for _cc,acc in pairs(_bb)do -if(type(acc)=="number")then -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],acc)else local bcc,ccc,dcc=table.unpack(acc) -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],bcc,ccc,dcc)end end -if(bca)and not(cca)then c_a.setMonitorFrame(aca,dbc)elseif(cca)then -c_a.setMonitorFrame(dbc:getName(),dbc,aca)else c_a.setMainFrame(dbc)end end;return dbc end,hide=function(dbc) -d_a.hide(dbc) -if(dbc.parent==nil)then if(activeFrame==dbc)then activeFrame=nil end -if(bca)and -not(cca)then if(c_a.getMonitorFrame(aca)==dbc)then -c_a.setActiveFrame(nil)end elseif(cca)then -if( -c_a.getMonitorFrame(dbc:getName())==dbc)then c_a.setActiveFrame(nil)end else -if(c_a.getMainFrame()==dbc)then c_a.setMainFrame(nil)end end end;return dbc end,addLayout=function(dbc,_cc) -if( -_cc~=nil)then -if(fs.exists(_cc))then local acc=fs.open(_cc,"r") -local bcc=ac:ParseXmlText(acc.readAll())acc.close()ccb={}dbc:setValuesByXMLData(bcc)end end;return dbc end,getLastLayout=function(dbc)return -ccb end,addLayoutFromString=function(dbc,_cc)if(_cc~=nil)then local acc=ac:ParseXmlText(_cc) -dbc:setValuesByXMLData(acc)end;return dbc end,setValuesByXMLData=function(dbc,_cc) -d_a.setValuesByXMLData(dbc,_cc)if(_d("movable",_cc)~=nil)then if(_d("movable",_cc))then -dbc:setMovable(true)end end;if( -_d("scrollable",_cc)~=nil)then -if(_d("scrollable",_cc))then dbc:setScrollable(true)end end;if -(_d("monitor",_cc)~=nil)then -dbc:setMonitor(_d("monitor",_cc)):show()end;if(_d("mirror",_cc)~=nil)then -dbc:setMirror(_d("mirror",_cc))end -if(_d("bar",_cc)~=nil)then if(_d("bar",_cc))then -dbc:showBar(true)else dbc:showBar(false)end end -if(_d("barText",_cc)~=nil)then dbc.barText=_d("barText",_cc)end;if(_d("barBG",_cc)~=nil)then -dbc.barBackground=colors[_d("barBG",_cc)]end;if(_d("barFG",_cc)~=nil)then -dbc.barTextcolor=colors[_d("barFG",_cc)]end;if(_d("barAlign",_cc)~=nil)then -dbc.barTextAlign=_d("barAlign",_cc)end;if(_d("layout",_cc)~=nil)then -dbc:addLayout(_d("layout",_cc))end;if(_d("xOffset",_cc)~=nil)then -dbc:setOffset(_d("xOffset",_cc),bcb)end;if(_d("yOffset",_cc)~=nil)then -dbc:setOffset(bcb,_d("yOffset",_cc))end;if(_d("scrollAmount",_cc)~=nil)then -dbc:setScrollAmount(_d("scrollAmount",_cc))end;local acc=_cc:children() -for bcc,ccc in -pairs(acc)do if(ccc.___name~="animation")then -local dcc=ccc.___name:gsub("^%l",string.upper) -if(cb[dcc]~=nil)then _db(ccc,dbc["add"..dcc],dbc)end end end;_db(_cc["frame"],dbc.addFrame,dbc) -_db(_cc["animation"],dbc.addAnimation,dbc)return dbc end,showBar=function(dbc,_cc)dbc.barActive= -_cc or not dbc.barActive;dbc:updateDraw() -return dbc end,setBar=function(dbc,_cc,acc,bcc)dbc.barText=_cc or""dbc.barBackground= -acc or dbc.barBackground -dbc.barTextcolor=bcc or dbc.barTextcolor;dbc:updateDraw()return dbc end,setBarTextAlign=function(dbc,_cc)dbc.barTextAlign= -_cc or"left"dbc:updateDraw()return dbc end,setMirror=function(dbc,_cc)if( -dbc.parent~=nil)then -error("Frame has to be a base frame in order to attach a mirror.")end;a_b=_cc;if(mirror~=nil)then -abb.setMirror(mirror)end;dda=true;return dbc end,removeMirror=function(dbc)mirror= -nil;dda=false;abb.setMirror(nil)return dbc end,setMonitorScale=function(dbc,_cc)if -(bca)then _ca.setTextScale(_cc)end;return dbc end,setMonitor=function(dbc,_cc,acc) -if( -_cc~=nil)and(_cc~=false)then -if(type(_cc)=="string")then -if( -peripheral.getType(_cc)=="monitor")then _ca=peripheral.wrap(_cc)dca=true end -if(dbc.parent~=nil)then dbc.parent:removeObject(dbc)end;bca=true;c_a.setMonitorFrame(_cc,dbc)elseif(type(_cc)=="table")then -_ca=bc(_cc)dca=true;bca=true;cca=true -c_a.setMonitorFrame(dbc:getName(),dbc,true)end else _ca=parentTerminal;bca=false;cca=false -if(type(aca)=="string")then -if( -c_a.getMonitorFrame(aca)==dbc)then c_a.setMonitorFrame(aca,nil)end else -if(c_a.getMonitorFrame(dbc:getName())==dbc)then c_a.setMonitorFrame(dbc:getName(), -nil)end end end;if(acc~=nil)then _ca.setTextScale(acc)end;abb=db(_ca) -dbc:setSize(_ca.getSize())aab=true;aca=_cc or nil;dbc:updateDraw()return dbc end,loseFocusHandler=function(dbc) -d_a.loseFocusHandler(dbc)if(_ab~=nil)then _ab:loseFocusHandler()_ab=nil end end,getFocusHandler=function(dbc) -d_a.getFocusHandler(dbc) -if(dbc.parent~=nil)then -if(b_b)then dbc.parent:removeEvents(dbc) -dbc.parent:removeObject(dbc)dbc.parent:addObject(dbc)for _cc,acc in pairs(dab)do if(acc)then -dbc.parent:addEvent(_cc,dbc)end end -dbc:updateDraw()end end;if(_ab~=nil)then _ab:getFocusHandler()end end,eventHandler=function(dbc,_cc,...) -d_a.eventHandler(dbc,_cc,...) -if(daa["other_event"]~=nil)then -for acc,bcc in ipairs(_ba["other_event"])do if( -daa["other_event"][bcc]~=nil)then -for ccc,dcc in dc(daa["other_event"][bcc])do if -(dcc.eventHandler~=nil)then dcc:eventHandler(_cc,...)end end end end end -if(aab)and not(bca)then if(dbc.parent==nil)then -if(_cc=="term_resize")then -dbc:sendEvent("basalt_resize",dbc,_cc,...)dbc:setSize(_ca.getSize())aab=true end end end -if(bca)then -if(aab)then -if(_cc=="monitor_resize")then -if(type(aca)=="string")then -dbc:setSize(_ca.getSize())elseif(type(aca)=="table")then -for acc,bcc in pairs(aca)do for ccc,dcc in pairs(bcc)do if(p1 ==dcc)then -dbc:setSize(_ca.getSize())end end end end;aab=true;dbc:updateDraw()end end -if(_cc=="peripheral")and(p1 ==aca)then if -(peripheral.getType(aca)=="monitor")then dca=true;_ca=peripheral.wrap(aca)abb=db(_ca) -dbc:updateDraw()end end -if(_cc=="peripheral_detach")and(p1 ==aca)then dca=false end end -if(dda)then if(peripheral.getType(a_b)=="monitor")then __b=true -abb.setMirror(peripheral.wrap(a_b))end;if(_cc=="peripheral_detach")and -(p1 ==a_b)then dca=false end -if -(_cc=="monitor_touch")and(a_b==p1)then dbc:mouseHandler(1,p2,p3,true)end end end,mouseHandler=function(dbc,_cc,acc,bcc,ccc,dcc) -if -(cca)then if(_ca.calculateClick~=nil)then -acc,bcc=_ca.calculateClick(dcc,acc,bcc)end end -if(d_a.mouseHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_click"]~=nil)then -dbc:setCursor(false) -for _dc,adc in ipairs(_ba["mouse_click"])do -if -(daa["mouse_click"][adc]~=nil)then for bdc,cdc in dc(daa["mouse_click"][adc])do -if(cdc.mouseHandler~=nil)then if -(cdc:mouseHandler(_cc,acc,bcc))then return true end end end end end end -if(b_b)then -local _dc,adc=dbc:getAbsolutePosition(dbc:getAnchorPosition())if -(acc>=_dc)and(acc<=_dc+dbc:getWidth()-1)and(bcc==adc)then c_b=true;_da=_dc-acc -ada=yOff and 1 or 0 end end;dbc:removeFocusedObject()return true end;return false end,mouseUpHandler=function(dbc,_cc,acc,bcc)if -(c_b)then c_b=false end -if(d_a.mouseUpHandler(dbc,_cc,acc,bcc))then -if -(daa["mouse_up"]~=nil)then -for ccc,dcc in ipairs(_ba["mouse_up"])do -if(daa["mouse_up"][dcc]~=nil)then -for _dc,adc in -dc(daa["mouse_up"][dcc])do if(adc.mouseUpHandler~=nil)then -if(adc:mouseUpHandler(_cc,acc,bcc))then return true end end end end end end;return true end;return false end,scrollHandler=function(dbc,_cc,acc,bcc) -if -(d_a.scrollHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_scroll"]~=nil)then -for dcc,_dc in pairs(_ba["mouse_scroll"])do -if( -daa["mouse_scroll"][_dc]~=nil)then -for adc,bdc in dc(daa["mouse_scroll"][_dc])do if(bdc.scrollHandler~= -nil)then -if(bdc:scrollHandler(_cc,acc,bcc))then return true end end end end end end;local ccc=bcb -if(bda)then cbc(dbc)if(_cc>0)or(_cc<0)then -bcb=dd(cd(bcb-_cc,0),-cda)dbc:updateDraw()end end;if(bcb==ccc)then return false end;dbc:removeFocusedObject() -return true end;return false end,hoverHandler=function(dbc,_cc,acc,bcc) -if -(d_a.hoverHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_move"]~=nil)then -for ccc,dcc in pairs(_ba["mouse_move"])do -if( -daa["mouse_move"][dcc]~=nil)then for _dc,adc in dc(daa["mouse_move"][dcc])do -if -(adc.hoverHandler~=nil)then if(adc:hoverHandler(_cc,acc,bcc))then return true end end end end end end end;return false end,dragHandler=function(dbc,_cc,acc,bcc) -if -(c_b)then local ccc,dcc=dbc.parent:getOffsetInternal()ccc=ccc<0 and -d_c.abs(ccc)or-ccc;dcc=dcc<0 and d_c.abs(dcc)or- -dcc;local _dc=1;local adc=1;if(dbc.parent~=nil)then -_dc,adc=dbc.parent:getAbsolutePosition(dbc.parent:getAnchorPosition())end -dbc:setPosition( -acc+_da- (_dc-1)+ccc,bcc+ada- (adc-1)+dcc)dbc:updateDraw()return true end -if(dbc:isVisible())and(dbc:isEnabled())then -if -(daa["mouse_drag"]~=nil)then -for ccc,dcc in ipairs(_ba["mouse_drag"])do -if -(daa["mouse_drag"][dcc]~=nil)then for _dc,adc in dc(daa["mouse_drag"][dcc])do -if(adc.dragHandler~=nil)then if -(adc:dragHandler(_cc,acc,bcc))then return true end end end end end end end;d_a.dragHandler(dbc,_cc,acc,bcc)return false end,keyHandler=function(dbc,_cc,acc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local bcc=dbc:getEventSystem():sendEvent("key",dbc,"key",_cc)if(bcc==false)then return false end -if(daa["key"]~=nil)then -for ccc,dcc in pairs(_ba["key"])do -if( -daa["key"][dcc]~=nil)then -for _dc,adc in dc(daa["key"][dcc])do if(adc.keyHandler~=nil)then if -(adc:keyHandler(_cc,acc))then return true end end end end end end end;return false end,keyUpHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("key_up",dbc,"key_up",_cc)if(acc==false)then return false end -if(daa["key_up"]~=nil)then -for bcc,ccc in -pairs(_ba["key_up"])do -if(daa["key_up"][ccc]~=nil)then for dcc,_dc in dc(daa["key_up"][ccc])do -if( -_dc.keyUpHandler~=nil)then if(_dc:keyUpHandler(_cc))then return true end end end end end end end;return false end,charHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("char",dbc,"char",_cc)if(acc==false)then return false end -if(daa["char"]~=nil)then -for bcc,ccc in -pairs(_ba["char"])do -if(daa["char"][ccc]~=nil)then for dcc,_dc in dc(daa["char"][ccc])do -if -(_dc.charHandler~=nil)then if(_dc:charHandler(_cc))then return true end end end end end end end;return false end,setText=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setText(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setText(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,setBG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setBG(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setBG(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,setFG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setFG(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setFG(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,writeText=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:writeText(dd( -_cc+ (_dc-1),_dc),adc+acc-1,bd(bcc,dd(1 -_cc+1,1), -dbc:getWidth()-_cc+1),ccc,dcc)else -abb.writeText(dd(_cc+ (_dc-1),_dc),adc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)),ccc,dcc)end end end,blit=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -local bdc=dbc:getWidth() -if(dbc.parent~=nil)then -bcc=bd(bcc,dd(1 -_cc+1,1),bdc-_cc+1)ccc=bd(ccc,dd(1 -_cc+1,1),bdc-_cc+1)dcc=bd(dcc,dd( -1 -_cc+1,1),bdc-_cc+1) -dbc.parent:blit(dd( -_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)else -bcc=bd(bcc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -ccc=bd(ccc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -dcc=bd(dcc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -abb.blit(dd(_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)end end end,drawBackgroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)else -abb.drawBackgroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)end end,drawTextBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawTextBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,bd(dcc,1,1))else -abb.drawTextBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,bd(dcc,1,1))end end,drawForegroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawForegroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)else -abb.drawForegroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)end end,draw=function(dbc,_cc)if -(bca)and not(dca)then return false end -if(dbc.parent==nil)then if(dbc:getDraw()== -false)then return false end end -if(d_a.draw(dbc))then -local acc,bcc=dbc:getAbsolutePosition(dbc:getAnchorPosition())local ccc,dcc=dbc:getAnchorPosition()local _dc,adc=dbc:getSize() -if( -dbc.parent==nil)then -if(dbc.bgColor~=false)then -abb.drawBackgroundBox(ccc,dcc,_dc,adc,dbc.bgColor)abb.drawTextBox(ccc,dcc,_dc,adc," ")end;if(dbc.fgColor~=false)then -abb.drawForegroundBox(ccc,dcc,_dc,adc,dbc.fgColor)end end -if(dbc.barActive)then -if(dbc.parent~=nil)then -dbc.parent:writeText(ccc,dcc,_c.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)else -abb.writeText(ccc,dcc,_c.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)end -if(dbc:getBorder("left"))then -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc,1,1,dbc.barBackground)if(dbc.bgColor~=false)then -dbc.parent:drawBackgroundBox(ccc-1,dcc+1,1,adc-1,dbc.bgColor)end end end -if(dbc:getBorder("top"))then if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc-1,_dc+1,1,dbc.barBackground)end end end;for bdc,cdc in dc(baa)do -if(aaa[cdc]~=nil)then for ddc,__d in pairs(aaa[cdc])do -if(__d.draw~=nil)then __d:draw()end end end end end end,updateTerm=function(dbc)if -(bca)and not(dca)then return false end;abb.update()end,addObject=function(dbc,_cc)return -cdb(_cc)end,removeObject=__c,getObject=function(dbc,_cc)return adb(_cc)end,getDeepObject=function(dbc,_cc)return bdb(_cc)end,addFrame=function(dbc,_cc)local acc=c_a.newFrame( -_cc or cc(),dbc,nil,c_a)return cdb(acc)end,init=function(dbc) -if -not(cab)then -if(a_a~=nil)then d_a.width,d_a.height=a_a:getSize() -dbc:setBackground(a_a:getTheme("FrameBG")) -dbc:setForeground(a_a:getTheme("FrameText"))else d_a.width,d_a.height=_ca.getSize() -dbc:setBackground(c_a.getTheme("BasaltBG")) -dbc:setForeground(c_a.getTheme("BasaltText"))end;cab=true end end} -for dbc,_cc in pairs(cb)do caa["add"..dbc]=function(acc,bcc) -return cdb(_cc(bcc or cc(),acc))end end;setmetatable(caa,d_a)return caa end end -aa["Object"]=function(...)local ab=da("basaltEvent")local bb=da("utils") -local cb=da("module")local db=cb("images")local _c=bb.splitString;local ac=bb.numberFromString -local bc=bb.getValueFromXML;local cc,dc=table.unpack,string.sub -return -function(_d)local ad="Object"local bd={}local cd=1;local dd -local __a="topLeft"local a_a=false;local b_a=true;local c_a=false;local d_a=false;local _aa=false;local aaa=false -local baa={left=false,right=false,top=false,bottom=false}local caa=colors.black;local daa=true;local _ba=false;local aba,bba,cba,dba=0,0,0,0;local _ca;local aca;local bca=1;local cca -local dca;local _da=true;local ada=true;local bda={}local cda=ab() -bd={x=1,y=1,width=1,height=1,bgColor=colors.black,bgSymbol=" ",bgSymbolColor=colors.black,fgColor=colors.white,transparentColor=false,name=_d or"Object",parent= -nil,show=function(dda)b_a=true;dda:updateDraw()return dda end,hide=function(dda)b_a=false -dda:updateDraw()return dda end,enable=function(dda)daa=true;return dda end,disable=function(dda)daa=false -return dda end,isEnabled=function(dda)return daa end,generateXMLEventFunction=function(dda,__b,a_b) -local b_b=function(c_b) -if(c_b:sub(1,1)=="#")then -local d_b=dda:getBaseFrame():getDeepObject(c_b:sub(2,c_b:len())) -if(d_b~=nil)and(d_b.internalObjetCall~=nil)then __b(dda,function() -d_b:internalObjetCall()end)end else -__b(dda,dda:getBaseFrame():getVariable(c_b))end end;if(type(a_b)=="string")then b_b(a_b)elseif(type(a_b)=="table")then -for c_b,d_b in pairs(a_b)do b_b(d_b)end end;return dda end,setValuesByXMLData=function(dda,__b) -local a_b=dda:getBaseFrame()local b_b,c_b,d_b -if(bc("texture",__b)~=nil)then b_b=bc("texture",__b)end;if(bc("mode",__b)~=nil)then c_b=bc("mode",__b)end -if( -bc("texturePlay",__b)~=nil)then d_b=bc("texturePlay",__b)end;local _ab,aab;if(bc("x",__b)~=nil)then _ab=bc("x",__b)end;if( -bc("y",__b)~=nil)then aab=bc("y",__b)end;if -(_ab~=nil)or(aab~=nil)then dda:setPosition(_ab,aab)end;local bab,cab;if( -bc("width",__b)~=nil)then bab=bc("width",__b)end;if( -bc("height",__b)~=nil)then cab=bc("height",__b)end;if(bab~=nil)or( -cab~=nil)then dda:setSize(bab,cab)end;if( -bc("bg",__b)~=nil)then -dda:setBackground(colors[bc("bg",__b)])end;if(bc("bgSymbol",__b)~=nil)then -dda:setBackground(dda.bgColor,bc("bgSymbol",__b))end;if -(bc("bgSymbolColor",__b)~=nil)then -dda:setBackground(dda.bgColor,dda.bgSymbol,colors[bc("bgSymbolColor",__b)])end -if -(bc("fg",__b)~=nil)then dda:setForeground(colors[bc("fg",__b)])end;if(bc("value",__b)~=nil)then -dda:setValue(colors[bc("value",__b)])end -if(bc("visible",__b)~=nil)then if -(bc("visible",__b))then dda:show()else dda:hide()end end -if(bc("enabled",__b)~=nil)then if(bc("enabled",__b))then dda:enable()else -dda:disable()end end;if(bc("zIndex",__b)~=nil)then -dda:setZIndex(bc("zIndex",__b))end;if(bc("anchor",__b)~=nil)then -dda:setAnchor(bc("anchor",__b))end;if(bc("shadowColor",__b)~=nil)then -dda:setShadow(colors[bc("shadowColor",__b)])end;if(bc("border",__b)~=nil)then -dda:setBorder(colors[bc("border",__b)])end;if(bc("borderLeft",__b)~=nil)then -baa["left"]=bc("borderLeft",__b)end;if(bc("borderTop",__b)~=nil)then -baa["top"]=bc("borderTop",__b)end;if(bc("borderRight",__b)~=nil)then -baa["right"]=bc("borderRight",__b)end;if(bc("borderBottom",__b)~=nil)then -baa["bottom"]=bc("borderBottom",__b)end;if(bc("borderColor",__b)~=nil)then -dda:setBorder(colors[bc("borderColor",__b)])end;if -(bc("ignoreOffset",__b)~=nil)then -if(bc("ignoreOffset",__b))then dda:ignoreOffset(true)end end;if -(bc("onClick",__b)~=nil)then -dda:generateXMLEventFunction(dda.onClick,bc("onClick",__b))end;if -(bc("onClickUp",__b)~=nil)then -dda:generateXMLEventFunction(dda.onClickUp,bc("onClickUp",__b))end;if -(bc("onScroll",__b)~=nil)then -dda:generateXMLEventFunction(dda.onScroll,bc("onScroll",__b))end;if -(bc("onDrag",__b)~=nil)then -dda:generateXMLEventFunction(dda.onDrag,bc("onDrag",__b))end;if(bc("onHover",__b)~=nil)then -dda:generateXMLEventFunction(dda.onHover,bc("onHover",__b))end;if -(bc("onLeave",__b)~=nil)then -dda:generateXMLEventFunction(dda.onLeave,bc("onLeave",__b))end;if(bc("onKey",__b)~=nil)then -dda:generateXMLEventFunction(dda.onKey,bc("onKey",__b))end;if(bc("onKeyUp",__b)~=nil)then -dda:generateXMLEventFunction(dda.onKeyUp,bc("onKeyUp",__b))end;if -(bc("onChange",__b)~=nil)then -dda:generateXMLEventFunction(dda.onChange,bc("onChange",__b))end;if -(bc("onResize",__b)~=nil)then -dda:generateXMLEventFunction(dda.onResize,bc("onResize",__b))end;if -(bc("onReposition",__b)~=nil)then -dda:generateXMLEventFunction(dda.onReposition,bc("onReposition",__b))end;if -(bc("onEvent",__b)~=nil)then -dda:generateXMLEventFunction(dda.onEvent,bc("onEvent",__b))end;if -(bc("onGetFocus",__b)~=nil)then -dda:generateXMLEventFunction(dda.onGetFocus,bc("onGetFocus",__b))end;if -(bc("onLoseFocus",__b)~=nil)then -dda:generateXMLEventFunction(dda.onLoseFocus,bc("onLoseFocus",__b))end;if(b_b~=nil)then -dda:setTexture(b_b,c_b,d_b)end;dda:updateDraw()return dda end,isVisible=function(dda)return -b_a end,setFocus=function(dda)if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return dda end,setZIndex=function(dda,__b) -cd=__b -if(dda.parent~=nil)then dda.parent:removeObject(dda) -dda.parent:addObject(dda)dda:updateEventHandlers()end;return dda end,updateEventHandlers=function(dda) -for __b,a_b in -pairs(bda)do if(a_b)then dda.parent:addEvent(__b,dda)end end end,getZIndex=function(dda)return cd end,getType=function(dda)return ad end,getName=function(dda)return -dda.name end,remove=function(dda)if(dda.parent~=nil)then -dda.parent:removeObject(dda)end;dda:updateDraw()return dda end,setParent=function(dda,__b) -if( -__b.getType~=nil and __b:getType()=="Frame")then -dda:remove()__b:addObject(dda)if(dda.draw)then dda:show()end end;return dda end,setValue=function(dda,__b,a_b)if( -dd~=__b)then dd=__b;dda:updateDraw()if(a_b~=false)then -dda:valueChangedHandler()end end -return dda end,getValue=function(dda)return dd end,getDraw=function(dda)return -ada end,updateDraw=function(dda,__b)ada=__b;if(__b==nil)then ada=true end;if(ada)then if(dda.parent~=nil)then -dda.parent:updateDraw()end end;return dda end,getEventSystem=function(dda)return -cda end,getParent=function(dda)return dda.parent end,setPosition=function(dda,__b,a_b,b_b) -if(type(__b)=="number")then dda.x= -b_b and dda:getX()+__b or __b end;if(type(a_b)=="number")then -dda.y=b_b and dda:getY()+a_b or a_b end -if(dda.parent~=nil)then if(type(__b)=="string")then -dda.x=dda.parent:newDynamicValue(dda,__b)end;if(type(a_b)=="string")then -dda.y=dda.parent:newDynamicValue(dda,a_b)end -dda.parent:recalculateDynamicValues()end;dda:customEventHandler("basalt_reposition") -dda:updateDraw()return dda end,getX=function(dda)return - -type(dda.x)=="number"and dda.x or math.floor(dda.x[1]+0.5)end,getY=function(dda)return - -type(dda.y)=="number"and dda.y or math.floor(dda.y[1]+0.5)end,getPosition=function(dda)return -dda:getX(),dda:getY()end,getVisibility=function(dda)return b_a end,setVisibility=function(dda,__b) -b_a=__b or not b_a;dda:updateDraw()return dda end,setSize=function(dda,__b,a_b,b_b)if(type(__b)== -"number")then -dda.width=b_b and dda:getWidth()+__b or __b end -if(type(a_b)=="number")then dda.height=b_b and -dda:getHeight()+a_b or a_b end -if(dda.parent~=nil)then if(type(__b)=="string")then -dda.width=dda.parent:newDynamicValue(dda,__b)end;if(type(a_b)=="string")then -dda.height=dda.parent:newDynamicValue(dda,a_b)end -dda.parent:recalculateDynamicValues()end;if(_ca~=nil)and(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]end -dda:customEventHandler("basalt_resize")dda:updateDraw()return dda end,getHeight=function(dda) -return -type(dda.height)=="number"and dda.height or -math.floor(dda.height[1]+0.5)end,getWidth=function(dda)return - -type(dda.width)=="number"and dda.width or math.floor(dda.width[1]+0.5)end,getSize=function(dda)return -dda:getWidth(),dda:getHeight()end,calculateDynamicValues=function(dda) -if( -type(dda.width)=="table")then dda.width:calculate()end -if(type(dda.height)=="table")then dda.height:calculate()end -if(type(dda.x)=="table")then dda.x:calculate()end -if(type(dda.y)=="table")then dda.y:calculate()end;dda:updateDraw()return dda end,setBackground=function(dda,__b,a_b,b_b)dda.bgColor= -__b or false -dda.bgSymbol=a_b or(dda.bgColor~=false and dda.bgSymbol or -false)dda.bgSymbolColor=b_b or dda.bgSymbolColor -dda:updateDraw()return dda end,setTexture=function(dda,__b,a_b,b_b)if( -type(__b)=="string")then _ca=db.loadImageAsBimg(__b)elseif(type(__b)=="table")then -_ca=__b end -if(_ca.animated)then local c_b=_ca[bca].duration or -_ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)dda.parent:addEvent("other_event",dda) -bda["other_event"]=true end;_da=b_b==false and false or true;bca=1 -dca=a_b or"normal"if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[1]else aca=_ca[1]end -dda:updateDraw()return dda end,setTransparent=function(dda,__b)dda.transparentColor= -__b or false;if(__b~=false)then dda.bgSymbol=false -dda.bgSymbolColor=false end;dda:updateDraw()return dda end,getBackground=function(dda)return -dda.bgColor end,setForeground=function(dda,__b)dda.fgColor=__b or false -dda:updateDraw()return dda end,getForeground=function(dda)return dda.fgColor end,setShadow=function(dda,__b)if( -__b==false)then aaa=false else caa=__b;aaa=true end -dda:updateDraw()return dda end,isShadowActive=function(dda)return aaa end,setBorder=function(dda,...) -if( -...~=nil)then local __b={...} -for a_b,b_b in pairs(__b)do if(b_b=="left")or(#__b==1)then -baa["left"]=__b[1]end;if(b_b=="top")or(#__b==1)then -baa["top"]=__b[1]end;if(b_b=="right")or(#__b==1)then -baa["right"]=__b[1]end;if(b_b=="bottom")or(#__b==1)then -baa["bottom"]=__b[1]end end end;dda:updateDraw()return dda end,getBorder=function(dda,__b)if( -__b=="left")then return borderLeft end -if(__b=="top")then return borderTop end;if(__b=="right")then return borderRight end;if(__b=="bottom")then -return borderBottom end end,draw=function(dda) -if -(b_a)then -if(dda.parent~=nil)then local __b,a_b=dda:getAnchorPosition() -local b_b,c_b=dda:getSize()local d_b,_ab=dda.parent:getSize() -if(__b+b_b<1)or(__b>d_b)or(a_b+ -c_b<1)or(a_b>_ab)then return false end;if(dda.transparentColor~=false)then -dda.parent:drawForegroundBox(__b,a_b,b_b,c_b,dda.transparentColor)end;if(dda.bgColor~=false)then -dda.parent:drawBackgroundBox(__b,a_b,b_b,c_b,dda.bgColor)end -if(dda.bgSymbol~=false)then -dda.parent:drawTextBox(__b,a_b,b_b,c_b,dda.bgSymbol)if(dda.bgSymbol~=" ")then -dda.parent:drawForegroundBox(__b,a_b,b_b,c_b,dda.bgSymbolColor)end end -if(aca~=nil)then -if(dca=="center")then local bab,cab=#aca[1][1],#aca -local dab=bab__b)and(c_b<=a_b)and(c_b+_ab>a_b)then return true end end;return false end,mouseHandler=function(dda,__b,a_b,b_b,c_b) -if -(dda:isCoordsInObject(a_b,b_b))then local d_b,_ab=dda:getAbsolutePosition() -local aab=cda:sendEvent("mouse_click",dda,"mouse_click",__b,a_b- -(d_b-1),b_b- (_ab-1),a_b,b_b,c_b)if(aab==false)then return false end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;_aa=true;_ba=true;aba,bba=a_b,b_b;return true end;return false end,mouseUpHandler=function(dda,__b,a_b,b_b) -_ba=false -if(_aa)then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_release",dda,"mouse_release",__b,a_b- ( -c_b-1),b_b- (d_b-1),a_b,b_b)_aa=false end -if(dda:isCoordsInObject(a_b,b_b))then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_up",dda,"mouse_up",__b, -a_b- (c_b-1),b_b- (d_b-1),a_b,b_b)if(_ab==false)then return false end;return true end;return false end,dragHandler=function(dda,__b,a_b,b_b) -if -(_ba)then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_drag",dda,"mouse_drag",__b,a_b- (c_b-1), -b_b- (d_b-1),aba-a_b,bba-b_b,a_b,b_b)aba,bba=a_b,b_b;if(_ab~=nil)then return _ab end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return true end -if(dda:isCoordsInObject(a_b,b_b))then -local c_b,d_b=dda:getAbsolutePosition(dda:getAnchorPosition())aba,bba=a_b,b_b;cba,dba=c_b-a_b,d_b-b_b end;return false end,scrollHandler=function(dda,__b,a_b,b_b) -if -(dda:isCoordsInObject(a_b,b_b))then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_scroll",dda,"mouse_scroll",__b,a_b- -(c_b-1),b_b- (d_b-1))if(_ab==false)then return false end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return true end;return false end,hoverHandler=function(dda,__b,a_b,b_b) -if -(dda:isCoordsInObject(__b,a_b))then -local c_b=cda:sendEvent("mouse_hover",dda,"mouse_hover",__b,a_b,b_b)if(c_b==false)then return false end;d_a=true;return true end -if(d_a)then -local c_b=cda:sendEvent("mouse_leave",dda,"mouse_leave",__b,a_b,b_b)if(c_b==false)then return false end;d_a=false end;return false end,keyHandler=function(dda,__b,a_b)if -(daa)and(b_a)then -if(dda:isFocused())then -local b_b=cda:sendEvent("key",dda,"key",__b,a_b)if(b_b==false)then return false end;return true end end;return -false end,keyUpHandler=function(dda,__b)if -(daa)and(b_a)then -if(dda:isFocused())then -local a_b=cda:sendEvent("key_up",dda,"key_up",__b)if(a_b==false)then return false end;return true end end;return -false end,charHandler=function(dda,__b)if -(daa)and(b_a)then -if(dda:isFocused())then -local a_b=cda:sendEvent("char",dda,"char",__b)if(a_b==false)then return false end;return true end end;return -false end,valueChangedHandler=function(dda) -cda:sendEvent("value_changed",dda,dd)end,eventHandler=function(dda,__b,...)local a_b={...} -if -(__b=="timer")and(a_b[1]==cca)then -if(_ca[bca+1]~=nil)then bca=bca+1;if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]else aca=_ca[bca]end;local c_b=_ca[bca].duration or -_ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)else -if(_da)then bca=1;if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[1]else aca=_ca[1]end;local c_b= -_ca[1].duration or _ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)end end;dda:updateDraw()end;local b_b=cda:sendEvent("other_event",dda,__b,...)if(b_b~=nil)then -return b_b end end,customEventHandler=function(dda,__b,...) -if -( -_ca~=nil)and(dca=="stretch")and(__b=="basalt_resize")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]dda:updateDraw()end;local a_b=cda:sendEvent("custom_event",dda,__b,...)if(a_b~=nil)then -return a_b end;return true end,getFocusHandler=function(dda) -local __b=cda:sendEvent("get_focus",dda)if(__b~=nil)then return __b end;return true end,loseFocusHandler=function(dda) -_ba=false;local __b=cda:sendEvent("lose_focus",dda) -if(__b~=nil)then return __b end;return true end,init=function(dda) -if -(dda.parent~=nil)then for __b,a_b in pairs(bda)do -if(a_b)then dda.parent:addEvent(__b,dda)end end end;if not(c_a)then c_a=true;return true end;return false end}bd.__index=bd;return bd end end;aa["objects"]={} -aa["objects"]["Input"]=function(...)local ab=da("Object") -local bb=da("utils")local cb=da("basaltLogs")local db=bb.getValueFromXML -return -function(_c)local ac=ab(_c)local bc="Input" -local cc="text"local dc=0;ac:setZIndex(5)ac:setValue("")ac.width=10;ac.height=1 -local _d=1;local ad=1;local bd=""local cd;local dd;local __a=bd;local a_a=false -local b_a={getType=function(c_a)return bc end,setInputType=function(c_a,d_a) -if(d_a=="password")or(d_a== -"number")or(d_a=="text")then cc=d_a end;c_a:updateDraw()return c_a end,setDefaultText=function(c_a,d_a,_aa,aaa) -bd=d_a;cd=aaa or cd;dd=_aa or dd -if(c_a:isFocused())then __a=""else __a=bd end;c_a:updateDraw()return c_a end,getInputType=function(c_a)return -cc end,setValue=function(c_a,d_a)ac.setValue(c_a,tostring(d_a)) -if not(a_a)then _d= -tostring(d_a):len()+1 -ad=math.max(1,_d-c_a:getWidth()+1)if(c_a:isFocused())then local _aa,aaa=c_a:getAnchorPosition() -c_a.parent:setCursor(true, -_aa+_d-ad,aaa+math.floor(c_a:getHeight()/2),c_a.fgColor)end end;c_a:updateDraw()return c_a end,getValue=function(c_a) -local d_a=ac.getValue(c_a) -return cc=="number"and tonumber(d_a)or d_a end,setInputLimit=function(c_a,d_a) -dc=tonumber(d_a)or dc;c_a:updateDraw()return c_a end,getInputLimit=function(c_a)return dc end,setValuesByXMLData=function(c_a,d_a) -ac.setValuesByXMLData(c_a,d_a)local _aa,aaa -if(db("defaultBG",d_a)~=nil)then _aa=db("defaultBG",d_a)end -if(db("defaultFG",d_a)~=nil)then aaa=db("defaultFG",d_a)end;if(db("default",d_a)~=nil)then -c_a:setDefaultText(db("default",d_a),aaa~=nil and colors[aaa], -_aa~=nil and colors[_aa])end -if(db("limit",d_a)~= -nil)then c_a:setInputLimit(db("limit",d_a))end;if(db("type",d_a)~=nil)then -c_a:setInputType(db("type",d_a))end;return c_a end,getFocusHandler=function(c_a) -ac.getFocusHandler(c_a) -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition()__a=""if(bd~="")then -c_a:updateDraw()end -c_a.parent:setCursor(true,d_a+_d-ad,_aa+math.max(math.ceil( -c_a:getHeight()/2 -1,1)),c_a.fgColor)end end,loseFocusHandler=function(c_a) -ac.loseFocusHandler(c_a)if(c_a.parent~=nil)then __a=bd;if(bd~="")then c_a:updateDraw()end -c_a.parent:setCursor(false)end end,keyHandler=function(c_a,d_a) -if -(ac.keyHandler(c_a,d_a))then local _aa,aaa=c_a:getSize()a_a=true -if(d_a==keys.backspace)then -local bba=tostring(ac.getValue())if(_d>1)then -c_a:setValue(bba:sub(1,_d-2)..bba:sub(_d,bba:len()))if(_d>1)then _d=_d-1 end -if(ad>1)then if(_dbba)then _d=bba+1 end;if(_d<1)then _d=1 end;if -(_d=_aa+ad)then ad=_d-_aa+1 end;if(ad<1)then ad=1 end end -if(d_a==keys.left)then _d=_d-1;if(_d>=1)then -if(_d=_aa+ad)then ad=_d end end;if(_d<1)then _d=1 end;if(ad<1)then ad=1 end end;local baa,caa=c_a:getAnchorPosition() -local daa=tostring(ac.getValue()) -local _ba=(_d<=daa:len()and _d-1 or daa:len())- (ad-1)local aba=c_a:getX() -if(_ba>aba+_aa-1)then _ba=aba+_aa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,baa+_ba,caa+ -math.max(math.ceil(aaa/2 -1,1)),c_a.fgColor)end -c_a:updateDraw()a_a=false;return true end;return false end,charHandler=function(c_a,d_a) -if -(ac.charHandler(c_a,d_a))then a_a=true;local _aa,aaa=c_a:getSize()local baa=ac.getValue() -if( -baa:len()0)then -if( -tonumber(ac.getValue())==nil)then c_a:setValue(cba)_d=_d-1 end end end else -c_a:setValue(baa:sub(1,_d-1)..d_a..baa:sub(_d,baa:len()))_d=_d+1 end;if(_d>=_aa+ad)then ad=ad+1 end end;local caa,daa=c_a:getAnchorPosition() -local _ba=tostring(ac.getValue()) -local aba=(_d<=_ba:len()and _d-1 or _ba:len())- (ad-1)local bba=c_a:getX() -if(aba>bba+_aa-1)then aba=bba+_aa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,caa+aba,daa+ -math.max(math.ceil(aaa/2 -1,1)),c_a.fgColor)end;a_a=false -c_a:updateDraw()return true end;return false end,mouseHandler=function(c_a,d_a,_aa,aaa) -if -(ac.mouseHandler(c_a,d_a,_aa,aaa))then local baa,caa=c_a:getAnchorPosition() -local daa,_ba=c_a:getAbsolutePosition(baa,caa)local aba,bba=c_a:getSize()_d=_aa-daa+ad;local cba=ac.getValue()if(_d> -cba:len())then _d=cba:len()+1 end;if(_d=baa+ad)then ad=(_d+1)-baa end -local daa,_ba=c_a:getAnchorPosition()local aba=tostring(ac.getValue()) -local bba=( -_d<=aba:len()and _d-1 or aba:len())- (ad-1)local cba=c_a:getX() -if(bba>cba+baa-1)then bba=cba+baa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,daa+bba,_ba+ -math.max(math.ceil(caa/2 -1,1)),c_a.fgColor)end -c_a:updateDraw()a_a=false end end end,draw=function(c_a) -if -(ac.draw(c_a))then -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -local aaa,baa=c_a:getSize()local caa=bb.getTextVerticalAlign(baa,"center")if -(c_a.bgColor~=false)then -c_a.parent:drawBackgroundBox(d_a,_aa,aaa,baa,c_a.bgColor)end -for n=1,baa do -if(n==caa)then -local daa=tostring(ac.getValue())local _ba=c_a.bgColor;local aba=c_a.fgColor;local bba;if(daa:len()<=0)then bba=__a -_ba=cd or _ba;aba=dd or aba end;bba=__a -if(daa~="")then bba=daa end;bba=bba:sub(ad,aaa+ad-1)local cba=aaa-bba:len()if(cba<0)then -cba=0 end;if(cc=="password")and(daa~="")then -bba=string.rep("*",bba:len())end -bba=bba..string.rep(c_a.bgSymbol,cba) -c_a.parent:writeText(d_a,_aa+ (n-1),bba,_ba,aba)end end;if(c_a:isFocused())then -c_a.parent:setCursor(true,d_a+_d-ad,_aa+ -math.floor(c_a:getHeight()/2),c_a.fgColor)end end end end,init=function(c_a) -if( -c_a.parent~=nil)then c_a.parent:addEvent("mouse_click",c_a) -c_a.parent:addEvent("key",c_a)c_a.parent:addEvent("char",c_a) -c_a.parent:addEvent("other_event",c_a)c_a.parent:addEvent("mouse_drag",c_a)end -if(ac.init(c_a))then -c_a.bgColor=c_a.parent:getTheme("InputBG")c_a.fgColor=c_a.parent:getTheme("InputText")end end}return setmetatable(b_a,ac)end end -aa["objects"]["Button"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=da("tHex") -return -function(_c)local ac=ab(_c)local bc="Button"local cc="center"local dc="center" -ac:setZIndex(5)ac:setValue("Button")ac.width=12;ac.height=3 -local _d={init=function(ad) -if(ac.init(ad))then -ad.bgColor=ad.parent:getTheme("ButtonBG")ad.fgColor=ad.parent:getTheme("ButtonText")end end,getType=function(ad)return bc end,setHorizontalAlign=function(ad,bd) -cc=bd;ad:updateDraw()return ad end,setVerticalAlign=function(ad,bd)dc=bd -ad:updateDraw()return ad end,setText=function(ad,bd)ac:setValue(tostring(bd)) -ad:updateDraw()return ad end,setValuesByXMLData=function(ad,bd) -ac.setValuesByXMLData(ad,bd) -if(cb("text",bd)~=nil)then ad:setText(cb("text",bd))end;if(cb("horizontalAlign",bd)~=nil)then -cc=cb("horizontalAlign",bd)end;if(cb("verticalAlign",bd)~=nil)then -dc=cb("verticalAlign",bd)end;return ad end,draw=function(ad) -if -(ac.draw(ad))then -if(ad.parent~=nil)then local bd,cd=ad:getAnchorPosition() -local dd,__a=ad:getSize()local a_a=bb.getTextVerticalAlign(__a,dc) -for n=1,__a do -if(n==a_a)then -local b_a=ad:getValue() -ad.parent:setText(bd+ (dd/2 -b_a:len()/2),cd+ (n-1),bb.getTextHorizontalAlign(b_a,b_a:len(),cc)) -ad.parent:setFG(bd+ (dd/2 -b_a:len()/2),cd+ (n-1),bb.getTextHorizontalAlign(db[ad.fgColor]:rep(b_a:len()),b_a:len(),cc))end end end end end}return setmetatable(_d,ac)end end -aa["objects"]["Graphic"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("utils").getValueFromXML;local db=da("bimg")local _c=da("images") -local ac,bc,cc,dc=string.sub,string.len,math.max,math.min -return -function(_d)local ad=ab(_d)local bd="Graphic"local cd=db()local dd=cd.getFrameObject(1)local __a -local a_a=1;ad:setZIndex(5)local b_a,c_a=0,0 -local d_a={getType=function(_aa)return bd end,setOffset=function(_aa,aaa,baa,caa) -if(caa)then -b_a=b_a+aaa or 0;c_a=c_a+baa or 0 else b_a=aaa or b_a;c_a=baa or c_a end;_aa:updateDraw()return _aa end,getOffset=function(_aa)return -b_a,c_a end,setValuesByXMLData=function(_aa,aaa)ad.setValuesByXMLData(_aa,aaa)return _aa end,selectFrame=function(_aa,aaa)if( -cd.getFrameObject(aaa)==nil)then cd.addFrame(aaa)end -dd=cd.getFrameObject(aaa)__a=dd.getImage(aaa)a_a=aaa;_aa:updateDraw()end,addFrame=function(_aa,aaa) -cd.addFrame(aaa)return _aa end,getFrameMetadata=function(_aa,aaa,baa)return cd.getFrameData(aaa,baa)end,setFrameMetadata=function(_aa,aaa,baa,caa) -cd.setFrameData(aaa,baa,caa)return _aa end,getMetadata=function(_aa,aaa)return cd.getMetadata(aaa)end,setMetadata=function(_aa,aaa,baa)return -cd.setMetadata(aaa,baa)end,getFrame=function(_aa,aaa)return cd.getFrame(aaa)end,getFrameObject=function(_aa,aaa)return -cd.getFrameObject(aaa)end,removeFrame=function(_aa,aaa)cd.removeFrame(aaa)return _aa end,moveFrame=function(_aa,aaa,baa) -cd.moveFrame(aaa,baa)return _aa end,getFrames=function(_aa)return cd.getFrames()end,getFrameCount=function(_aa)return -#cd.getFrames()end,getSelectedFrame=function(_aa)return a_a end,blit=function(_aa,aaa,baa,caa,daa,_ba) -x=daa or x;y=_ba or y;dd.blit(aaa,baa,caa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setText=function(_aa,aaa,baa,caa) -x=baa or x;y=caa or y;dd.text(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setBg=function(_aa,aaa,baa,caa)x=baa or x;y= -caa or y;dd.bg(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setFg=function(_aa,aaa,baa,caa)x=baa or x;y=caa or -y;dd.fg(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,getImageSize=function(_aa) -return cd.getSize()end,setImageSize=function(_aa,aaa,baa)cd.setSize(aaa,baa)__a=dd.getImage() -_aa:updateDraw()return _aa end,resizeImage=function(_aa,aaa,baa) -local caa=_c.resizeBIMG(cd.createBimg(),aaa,baa)cd=db(caa)a_a=1;dd=cd.getFrameObject(1)__a=dd.getImage() -_aa:updateDraw()return _aa end,loadImage=function(_aa,aaa) -if -(fs.exists(aaa))then local baa=_c.loadBIMG(aaa)cd=db(baa)a_a=1 -dd=cd.getFrameObject(1)__a=dd.getImage()_aa:updateDraw()end;return _aa end,clear=function(_aa) -cd=db()__a=nil;_aa:updateDraw()return _aa end,getImage=function(_aa)return -cd.createBimg()end,draw=function(_aa) -if(ad.draw(_aa))then -if(_aa.parent~=nil)then -local aaa,baa=_aa:getAnchorPosition()local caa,daa=_aa:getSize() -if(__a~=nil)then -for _ba,aba in pairs(__a)do if -(_ba<=daa-c_a)and(_ba+c_a>=1)then -_aa.parent:blit(aaa+b_a,baa+_ba-1 +c_a,aba[1],aba[2],aba[3])end end end end end end,init=function(_aa) -if -(ad.init(_aa))then _aa.bgColor=_aa.parent:getTheme("GraphicBG")end end}return setmetatable(d_a,ad)end end -aa["objects"]["Checkbox"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="Checkbox"_c:setZIndex(5) -_c:setValue(false)_c.width=1;_c.height=1;local bc="\42" -local cc={getType=function(dc)return ac end,setSymbol=function(dc,_d)bc=_d -dc:updateDraw()return dc end,mouseHandler=function(dc,_d,ad,bd) -if(_c.mouseHandler(dc,_d,ad,bd))then -if(_d==1)then -if( -dc:getValue()~=true)and(dc:getValue()~=false)then -dc:setValue(false)else dc:setValue(not dc:getValue())end;dc:updateDraw()return true end end;return false end,touchHandler=function(dc,_d,ad)return -dc:mouseHandler(1,_d,ad)end,setValuesByXMLData=function(dc,_d) -_c.setValuesByXMLData(dc,_d) -if(cb("checked",_d)~=nil)then if(cb("checked",_d))then dc:setValue(true)else -dc:setValue(false)end end;return dc end,draw=function(dc) -if -(_c.draw(dc))then -if(dc.parent~=nil)then local _d,ad=dc:getAnchorPosition() -local bd,cd=dc:getSize()local dd=bb.getTextVerticalAlign(cd,"center")if -(dc.bgColor~=false)then -dc.parent:drawBackgroundBox(_d,ad,bd,cd,dc.bgColor)end -for n=1,cd do -if(n==dd)then -if(dc:getValue()==true)then -dc.parent:writeText(_d, -ad+ (n-1),bb.getTextHorizontalAlign(bc,bd,"center"),dc.bgColor,dc.fgColor)else -dc.parent:writeText(_d,ad+ (n-1),bb.getTextHorizontalAlign(" ",bd,"center"),dc.bgColor,dc.fgColor)end end end end end end,init=function(dc) -dc.parent:addEvent("mouse_click",dc)dc.parent:addEvent("mouse_up",dc) -if(_c.init(dc))then -dc.bgColor=dc.parent:getTheme("CheckboxBG")dc.fgColor=dc.parent:getTheme("CheckboxText")end end}return setmetatable(cc,_c)end end -aa["objects"]["Label"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=bb.createText;local _c=da("tHex")local ac=da("bigfont") -return -function(bc)local cc=ab(bc) -local dc="Label"cc:setZIndex(3)local _d=true;cc:setValue("Label")cc.width=5 -local ad="left"local bd="top"local cd=0;local dd,__a=false,false -local a_a={getType=function(b_a)return dc end,setText=function(b_a,c_a)c_a=tostring(c_a) -cc:setValue(c_a) -if(_d)then local d_a=b_a.parent:getOffset() -if( -c_a:len()+b_a:getX()>b_a.parent:getWidth()+d_a)then local _aa= -b_a.parent:getWidth()+d_a-b_a:getX()cc.setSize(b_a,_aa, -#db(c_a,_aa))else -cc.setSize(b_a,c_a:len(),1)end end;b_a:updateDraw()return b_a end,setBackground=function(b_a,c_a) -cc.setBackground(b_a,c_a)__a=true;b_a:updateDraw()return b_a end,setForeground=function(b_a,c_a) -cc.setForeground(b_a,c_a)dd=true;b_a:updateDraw()return b_a end,setTextAlign=function(b_a,c_a,d_a)ad= -c_a or ad;bd=d_a or bd;b_a:updateDraw()return b_a end,setFontSize=function(b_a,c_a)if( -c_a>0)and(c_a<=4)then cd=c_a-1 or 0 end -b_a:updateDraw()return b_a end,getFontSize=function(b_a)return cd+1 end,setValuesByXMLData=function(b_a,c_a) -cc.setValuesByXMLData(b_a,c_a) -if(cb("text",c_a)~=nil)then b_a:setText(cb("text",c_a))end -if(cb("verticalAlign",c_a)~=nil)then bd=cb("verticalAlign",c_a)end;if(cb("horizontalAlign",c_a)~=nil)then -ad=cb("horizontalAlign",c_a)end;if(cb("font",c_a)~=nil)then -b_a:setFontSize(cb("font",c_a))end;return b_a end,setSize=function(b_a,c_a,d_a,_aa) -cc.setSize(b_a,c_a,d_a,_aa)_d=false;b_a:updateDraw()return b_a end,eventHandler=function(b_a,c_a) -if( -c_a=="basalt_resize")then -if(_d)then local d_a=b_a:getValue() -if( -d_a:len()+b_a:getX()>b_a.parent:getWidth())then local _aa= -b_a.parent:getWidth()-b_a:getX() -cc.setSize(b_a,_aa,#db(d_a,_aa))else cc.setSize(b_a,d_a:len(),1)end else end end end,draw=function(b_a) -if -(cc.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize()local baa=bb.getTextVerticalAlign(aaa,bd) -if(cd==0)then -if not(_d)then -local caa=db(b_a:getValue(),b_a:getWidth()) -for daa,_ba in pairs(caa)do if(daa<=aaa)then -b_a.parent:writeText(c_a,d_a+daa-1,_ba,b_a.bgColor,b_a.fgColor)end end else -if -(#b_a:getValue()+c_a>b_a.parent:getWidth())then local caa=db(b_a:getValue(),b_a:getWidth()) -for daa,_ba in -pairs(caa)do if(daa<=aaa)then -b_a.parent:writeText(c_a,d_a+daa-1,_ba,b_a.bgColor,b_a.fgColor)end end else -b_a.parent:writeText(c_a,d_a,b_a:getValue(),b_a.bgColor,b_a.fgColor)end end else -local caa=ac(cd,b_a:getValue(),b_a.fgColor,b_a.bgColor or colors.lightGray) -if(_d)then b_a:setSize(#caa[1][1],#caa[1]-1)end;local daa,_ba=b_a.parent:getSize() -local aba,bba=#caa[1][1],#caa[1] -c_a=c_a or math.floor((daa-aba)/2)+1 -d_a=d_a or math.floor((_ba-bba)/2)+1 -for i=1,bba do -b_a.parent:setFG(c_a,d_a+i-1,caa[2][i])b_a.parent:setBG(c_a,d_a+i-1,caa[3][i])b_a.parent:setText(c_a, -d_a+i-1,caa[1][i])end end end end end,init=function(b_a) -b_a.parent:addEvent("other_event",b_a) -if(cc.init(b_a))then -b_a.bgColor=b_a.parent:getTheme("LabelBG")b_a.fgColor=b_a.parent:getTheme("LabelText") -if -( -b_a.parent.bgColor==colors.black)and(b_a.fgColor==colors.black)then b_a.fgColor=colors.lightGray end end end}return setmetatable(a_a,cc)end end -aa["objects"]["Image"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML;local cb=da("images")local db,_c=table.unpack,string.sub -return -function(ac)local bc=ab(ac) -local cc="Image"bc:setZIndex(2)local dc;local _d;local ad=1;local bd=false;local cd;local dd=false;bc.width=24 -bc.height=8 -local function __a(b_a) -if(dc~=nil)then local c_a={} -for d_a,_aa in pairs(colors)do if(type(_aa)=="number")then -c_a[d_a]={term.nativePaletteColor(_aa)}end end;if(dc.palette~=nil)then -for d_a,_aa in pairs(dc.palette)do c_a[d_a]=tonumber(_aa)end end -if(dc[b_a]~=nil)and -(dc[b_a].palette~=nil)then for d_a,_aa in pairs(dc[b_a].palette)do -c_a[d_a]=tonumber(_aa)end end;return c_a end end -local a_a={init=function(b_a)if(bc.init(b_a))then -b_a.bgColor=b_a.parent:getTheme("ImageBG")end end,getType=function(b_a)return -cc end,loadImage=function(b_a,c_a,d_a)if not(fs.exists(c_a))then -error("No valid path: "..c_a)end;dc=cb.loadImageAsBimg(c_a,d_a) -ad=1;_d=dc;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()return b_a end,setImage=function(b_a,c_a) -dc=c_a;_d=dc;ad=1;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()return b_a end,usePalette=function(b_a,c_a)dd= -c_a~=nil and c_a or true;return b_a end,play=function(b_a,c_a) -if(dc.animated)then -local d_a= -dc[ad].duration or dc.secondsPerFrame or 0.2;b_a.parent:addEvent("other_event",b_a) -cd=os.startTimer(d_a)bd=c_a or false end;return b_a end,selectFrame=function(b_a,c_a)if( -dc[c_a]~=nil)then ad=c_a;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()end end,eventHandler=function(b_a,c_a,d_a,...) -bc.eventHandler(b_a,c_a,d_a,...) -if(c_a=="timer")then -if(d_a==cd)then -if(dc[ad+1]~=nil)then ad=ad+1;local _aa= -dc[ad].duration or dc.secondsPerFrame or 0.2 -cd=os.startTimer(_aa)else -if(bd)then ad=1 -local _aa=dc[ad].duration or dc.secondsPerFrame or 0.2;cd=os.startTimer(_aa)end end;b_a:updateDraw()end end end,getMetadata=function(b_a,c_a)return -dc[c_a]end,getImageSize=function(b_a)return dc.width,dc.height end,resizeImage=function(b_a,c_a,d_a) -_d=cb.resizeBIMG(dc,c_a,d_a)b_a:updateDraw()return b_a end,setValuesByXMLData=function(b_a,c_a) -bc.setValuesByXMLData(b_a,c_a) -if(bb("path",c_a)~=nil)then b_a:loadImage(bb("path",c_a))end;return b_a end,draw=function(b_a) -if -(bc.draw(b_a))then -if(_d~=nil)then if(dd)then -b_a:getBaseFrame():setThemeColor(__a(ad))end;local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize() -for baa,caa in ipairs(_d[ad])do local daa,_ba,aba=db(caa)daa=_c(daa,1,_aa) -_ba=_c(_ba,1,_aa)aba=_c(aba,1,_aa) -b_a.parent:blit(c_a,d_a+baa-1,daa,_ba,aba)if(baa==aaa)then break end end end end end}return setmetatable(a_a,bc)end end -aa["objects"]["Menubar"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=da("tHex") -return -function(_c)local ac=ab(_c)local bc="Menubar"local cc={}ac.width=30;ac.height=1 -ac:setZIndex(5)local dc={}local _d;local ad;local bd=true;local cd="left"local dd=0;local __a=1;local a_a=false -local function b_a()local c_a=0;local d_a=0 -local _aa=cc:getWidth() -for n=1,#dc do if(d_a+dc[n].text:len()+__a*2 >_aa)then -if( -d_a<_aa)then -c_a=c_a+ (dc[n].text:len()+__a*2 - (_aa-d_a))else c_a=c_a+dc[n].text:len()+__a*2 end end;d_a= -d_a+dc[n].text:len()+__a*2 end;return c_a end -cc={getType=function(c_a)return bc end,addItem=function(c_a,d_a,_aa,aaa,...) -table.insert(dc,{text=tostring(d_a),bgCol=_aa or c_a.bgColor,fgCol=aaa or c_a.fgColor,args={...}})if(#dc==1)then c_a:setValue(dc[1])end -c_a:updateDraw()return c_a end,getAll=function(c_a)return -dc end,getItemIndex=function(c_a)local d_a=c_a:getValue()for _aa,aaa in pairs(dc)do -if(aaa==d_a)then return _aa end end end,clear=function(c_a) -dc={}c_a:setValue({},false)c_a:updateDraw()return c_a end,setSpace=function(c_a,d_a)__a= -d_a or __a;c_a:updateDraw()return c_a end,setOffset=function(c_a,d_a)dd= -d_a or 0;if(dd<0)then dd=0 end;local _aa=b_a()if(dd>_aa)then dd=_aa end -c_a:updateDraw()return c_a end,getOffset=function(c_a)return dd end,setScrollable=function(c_a,d_a) -a_a=d_a;if(d_a==nil)then a_a=true end;return c_a end,setValuesByXMLData=function(c_a,d_a) -ac.setValuesByXMLData(c_a,d_a)if(cb("selectionBG",d_a)~=nil)then -_d=colors[cb("selectionBG",d_a)]end;if(cb("selectionFG",d_a)~=nil)then -ad=colors[cb("selectionFG",d_a)]end;if(cb("scrollable",d_a)~=nil)then -if -(cb("scrollable",d_a))then c_a:setScrollable(true)else c_a:setScrollable(false)end end -if( -cb("offset",d_a)~=nil)then c_a:setOffset(cb("offset",d_a))end -if(cb("space",d_a)~=nil)then __a=cb("space",d_a)end -if(d_a["item"]~=nil)then local _aa=d_a["item"] -if(_aa.properties~=nil)then _aa={_aa}end;for aaa,baa in pairs(_aa)do -c_a:addItem(cb("text",baa),colors[cb("bg",baa)],colors[cb("fg",baa)])end end;return c_a end,removeItem=function(c_a,d_a) -table.remove(dc,d_a)c_a:updateDraw()return c_a end,getItem=function(c_a,d_a) -return dc[d_a]end,getItemCount=function(c_a)return#dc end,editItem=function(c_a,d_a,_aa,aaa,baa,...)table.remove(dc,d_a) -table.insert(dc,d_a,{text=_aa,bgCol= -aaa or c_a.bgColor,fgCol=baa or c_a.fgColor,args={...}})c_a:updateDraw()return c_a end,selectItem=function(c_a,d_a)c_a:setValue( -dc[d_a]or{},false)c_a:updateDraw()return c_a end,setSelectedItem=function(c_a,d_a,_aa,aaa)_d= -d_a or c_a.bgColor;ad=_aa or c_a.fgColor;bd=aaa -c_a:updateDraw()return c_a end,mouseHandler=function(c_a,d_a,_aa,aaa) -if -(ac.mouseHandler(c_a,d_a,_aa,aaa))then -local baa,caa=c_a:getAbsolutePosition(c_a:getAnchorPosition())local daa,_ba=c_a:getSize()local aba=0 -for n=1,#dc do -if(dc[n]~=nil)then -if -(baa+aba<=_aa+dd)and(baa+aba+ -dc[n].text:len()+ (__a*2)>_aa+dd)and(caa==aaa)then -c_a:setValue(dc[n]) -c_a:getEventSystem():sendEvent(event,c_a,event,0,_aa,aaa,dc[n])end;aba=aba+dc[n].text:len()+__a*2 end end;c_a:updateDraw()return true end;return false end,scrollHandler=function(c_a,d_a,_aa,aaa) -if -(ac.scrollHandler(c_a,d_a,_aa,aaa))then if(a_a)then dd=dd+d_a;if(dd<0)then dd=0 end;local baa=b_a()if(dd>baa)then dd=baa end -c_a:updateDraw()end;return true end;return false end,draw=function(c_a) -if -(ac.draw(c_a))then -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -local aaa,baa=c_a:getSize()if(c_a.bgColor~=false)then -c_a.parent:drawBackgroundBox(d_a,_aa,aaa,baa,c_a.bgColor)end;local caa=""local daa=""local _ba="" -for aba,bba in pairs(dc)do -local cba= -(" "):rep(__a)..bba.text.. (" "):rep(__a)caa=caa..cba -if(bba==c_a:getValue())then daa=daa.. -db[_d or bba.bgCol or c_a.bgColor]:rep(cba:len())_ba=_ba.. -db[ -ad or bba.FgCol or c_a.fgColor]:rep(cba:len())else daa=daa.. -db[bba.bgCol or c_a.bgColor]:rep(cba:len())_ba=_ba.. -db[bba.FgCol or c_a.fgColor]:rep(cba:len())end end -c_a.parent:setText(d_a,_aa,caa:sub(dd+1,aaa+dd)) -c_a.parent:setBG(d_a,_aa,daa:sub(dd+1,aaa+dd)) -c_a.parent:setFG(d_a,_aa,_ba:sub(dd+1,aaa+dd))end end end,init=function(c_a) -c_a.parent:addEvent("mouse_click",c_a)c_a.parent:addEvent("mouse_scroll",c_a) -if -(ac.init(c_a))then c_a.bgColor=c_a.parent:getTheme("MenubarBG") -c_a.fgColor=c_a.parent:getTheme("MenubarText")_d=c_a.parent:getTheme("SelectionBG") -ad=c_a.parent:getTheme("SelectionText")end end}return setmetatable(cc,ac)end end -aa["objects"]["Dropdown"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=da("utils").getValueFromXML -return -function(db)local _c=ab(db)local ac="Dropdown"_c.width=12;_c.height=1;_c:setZIndex(6) -local bc={}local cc;local dc;local _d=true;local ad="left"local bd=0;local cd=16;local dd=6;local __a="\16"local a_a="\31"local b_a=false -local c_a={getType=function(d_a)return -ac end,setValuesByXMLData=function(d_a,_aa)_c.setValuesByXMLData(d_a,_aa) -if( -cb("selectionBG",_aa)~=nil)then cc=colors[cb("selectionBG",_aa)]end;if(cb("selectionFG",_aa)~=nil)then -dc=colors[cb("selectionFG",_aa)]end;if(cb("dropdownWidth",_aa)~=nil)then -cd=cb("dropdownWidth",_aa)end;if(cb("dropdownHeight",_aa)~=nil)then -dd=cb("dropdownHeight",_aa)end;if(cb("offset",_aa)~=nil)then -bd=cb("offset",_aa)end -if(_aa["item"]~=nil)then local aaa=_aa["item"]if( -aaa.properties~=nil)then aaa={aaa}end;for baa,caa in pairs(aaa)do -d_a:addItem(cb("text",caa),colors[cb("bg",caa)],colors[cb("fg",caa)])end end end,setOffset=function(d_a,_aa) -bd=_aa;d_a:updateDraw()return d_a end,getOffset=function(d_a)return bd end,addItem=function(d_a,_aa,aaa,baa,...) -table.insert(bc,{text=_aa,bgCol= -aaa or d_a.bgColor,fgCol=baa or d_a.fgColor,args={...}})d_a:updateDraw()return d_a end,getAll=function(d_a)return -bc end,removeItem=function(d_a,_aa)table.remove(bc,_aa)d_a:updateDraw() -return d_a end,getItem=function(d_a,_aa)return bc[_aa]end,getItemIndex=function(d_a) -local _aa=d_a:getValue()for aaa,baa in pairs(bc)do if(baa==_aa)then return aaa end end end,clear=function(d_a) -bc={}d_a:setValue({},false)d_a:updateDraw()return d_a end,getItemCount=function(d_a)return -#bc end,editItem=function(d_a,_aa,aaa,baa,caa,...)table.remove(bc,_aa) -table.insert(bc,_aa,{text=aaa,bgCol=baa or d_a.bgColor,fgCol= -caa or d_a.fgColor,args={...}})d_a:updateDraw()return d_a end,selectItem=function(d_a,_aa)d_a:setValue( -bc[_aa]or{},false)d_a:updateDraw()return d_a end,setSelectedItem=function(d_a,_aa,aaa,baa)cc= -_aa or d_a.bgColor;dc=aaa or d_a.fgColor -_d=baa~=nil and baa;d_a:updateDraw()return d_a end,setDropdownSize=function(d_a,_aa,aaa) -cd,dd=_aa,aaa;d_a:updateDraw()return d_a end,getDropdownSize=function(d_a)return cd,dd end,mouseHandler=function(d_a,_aa,aaa,baa) -if -(b_a)then -local caa,daa=d_a:getAbsolutePosition(d_a:getAnchorPosition()) -if(_aa==1)then -if(#bc>0)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(caa<=aaa)and(caa+cd>aaa)and -(daa+n==baa)then d_a:setValue(bc[n+bd]) -d_a:updateDraw() -local _ba=d_a:getEventSystem():sendEvent("mouse_click",d_a,"mouse_click",dir,aaa,baa)if(_ba==false)then return _ba end;return true end end end end end end -if(_c.mouseHandler(d_a,_aa,aaa,baa))then b_a=(not b_a)d_a:updateDraw() -return true else if(b_a)then d_a:updateDraw()b_a=false end;return false end end,mouseUpHandler=function(d_a,_aa,aaa,baa) -if -(b_a)then -local caa,daa=d_a:getAbsolutePosition(d_a:getAnchorPosition()) -if(_aa==1)then -if(#bc>0)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(caa<=aaa)and(caa+cd>aaa)and -(daa+n==baa)then b_a=false;d_a:updateDraw() -local _ba=d_a:getEventSystem():sendEvent("mouse_up",d_a,"mouse_up",dir,aaa,baa)if(_ba==false)then return _ba end;return true end end end end end end end,scrollHandler=function(d_a,_aa,aaa,baa) -if -(b_a)and(d_a:isFocused())then bd=bd+_aa;if(bd<0)then bd=0 end;if(_aa==1)then -if(#bc>dd)then if(bd> -#bc-dd)then bd=#bc-dd end else bd=math.min(#bc-1,0)end end -local caa=d_a:getEventSystem():sendEvent("mouse_scroll",d_a,"mouse_scroll",_aa,aaa,baa)if(caa==false)then return caa end;d_a:updateDraw()return true end end,draw=function(d_a) -if -(_c.draw(d_a))then local _aa,aaa=d_a:getAnchorPosition()local baa,caa=d_a:getSize() -if( -d_a.parent~=nil)then if(d_a.bgColor~=false)then -d_a.parent:drawBackgroundBox(_aa,aaa,baa,caa,d_a.bgColor)end;local daa=d_a:getValue() -local _ba=bb.getTextHorizontalAlign(( -daa~=nil and daa.text or""),baa,ad):sub(1, -baa-1).. (b_a and a_a or __a) -d_a.parent:writeText(_aa,aaa,_ba,d_a.bgColor,d_a.fgColor) -if(b_a)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(bc[n+bd]==daa)then -if(_d)then -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[ -n+bd].text,cd,ad),cc,dc)else -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[n+bd].text,cd,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end else -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[n+bd].text,cd,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end end end end end end end,init=function(d_a) -d_a.parent:addEvent("mouse_click",d_a)d_a.parent:addEvent("mouse_up",d_a) -d_a.parent:addEvent("mouse_scroll",d_a) -if(_c.init(d_a))then -d_a.bgColor=d_a.parent:getTheme("DropdownBG")d_a.fgColor=d_a.parent:getTheme("DropdownText") -cc=d_a.parent:getTheme("SelectionBG")dc=d_a.parent:getTheme("SelectionText")end end}return setmetatable(c_a,_c)end end -aa["objects"]["Animation"]=function(...)local ab=da("utils").getValueFromXML -local bb=da("basaltEvent") -local cb,db,_c,ac,bc,cc=math.floor,math.sin,math.cos,math.pi,math.sqrt,math.pow -local dc=function(cab,dab,_bb)return cab+ (dab-cab)*_bb end;local _d=function(cab)return cab end -local ad=function(cab)return 1 -cab end;local bd=function(cab)return cab*cab*cab end;local cd=function(cab)return -ad(bd(ad(cab)))end;local dd=function(cab)return -dc(bd(cab),cd(cab),cab)end;local __a=function(cab)return -db((cab*ac)/2)end;local a_a=function(cab)return -ad(_c((cab*ac)/2))end;local b_a=function(cab)return -- (_c(ac*x)-1)/2 end -local c_a=function(cab) -local dab=1.70158;local _bb=dab+1;return _bb*cab^3 -dab*cab^2 end;local d_a=function(cab)return cab^3 end -local _aa=function(cab)local dab=(2 *ac)/3;return - -cab==0 and 0 or(cab==1 and 1 or(-2 ^ (10 *cab-10)* -db((cab*10 -10.75)*dab)))end -local function aaa(cab)return cab==0 and 0 or 2 ^ (10 *cab-10)end -local function baa(cab)return cab==0 and 0 or 2 ^ (10 *cab-10)end -local function caa(cab)local dab=1.70158;local _bb=dab*1.525;return -cab<0.5 and( (2 *cab)^2 * -( (_bb+1)*2 *cab-_bb))/2 or -( -(2 *cab-2)^2 * ( (_bb+1)* (cab*2 -2)+_bb)+2)/2 end;local function daa(cab)return -cab<0.5 and 4 *cab^3 or 1 - (-2 *cab+2)^3 /2 end -local function _ba(cab) -local dab=(2 *ac)/4.5 -return -cab==0 and 0 or(cab==1 and 1 or -( -cab<0.5 and- (2 ^ (20 *cab-10)* -db((20 *cab-11.125)*dab))/2 or -(2 ^ (-20 *cab+10)*db((20 *cab-11.125)*dab))/2 +1))end -local function aba(cab)return -cab==0 and 0 or(cab==1 and 1 or -( -cab<0.5 and 2 ^ (20 *cab-10)/2 or(2 -2 ^ (-20 *cab+10))/2))end;local function bba(cab)return -cab<0.5 and 2 *cab^2 or 1 - (-2 *cab+2)^2 /2 end;local function cba(cab)return -cab<0.5 and 8 * -cab^4 or 1 - (-2 *cab+2)^4 /2 end;local function dba(cab)return -cab<0.5 and 16 * -cab^5 or 1 - (-2 *cab+2)^5 /2 end;local function _ca(cab) -return cab^2 end;local function aca(cab)return cab^4 end -local function bca(cab)return cab^5 end;local function cca(cab)local dab=1.70158;local _bb=dab+1;return -1 +_bb* (cab-1)^3 +dab* (cab-1)^2 end;local function dca(cab)return 1 - -(1 -cab)^3 end -local function _da(cab)local dab=(2 *ac)/3;return - -cab==0 and 0 or(cab==1 and 1 or( -2 ^ (-10 *cab)*db((cab*10 -0.75)*dab)+1))end -local function ada(cab)return cab==1 and 1 or 1 -2 ^ (-10 *cab)end;local function bda(cab)return 1 - (1 -cab)* (1 -cab)end;local function cda(cab)return 1 - ( -1 -cab)^4 end;local function dda(cab) -return 1 - (1 -cab)^5 end -local function __b(cab)return 1 -bc(1 -cc(cab,2))end;local function a_b(cab)return bc(1 -cc(cab-1,2))end -local function b_b(cab)return - -cab<0.5 and(1 -bc( -1 -cc(2 *cab,2)))/2 or(bc(1 -cc(-2 *cab+2,2))+1)/2 end -local function c_b(cab)local dab=7.5625;local _bb=2.75 -if(cab<1 /_bb)then return dab*cab*cab elseif(cab<2 /_bb)then local abb=cab- -1.5 /_bb;return dab*abb*abb+0.75 elseif(cab<2.5 /_bb)then local abb=cab- -2.25 /_bb;return dab*abb*abb+0.9375 else -local abb=cab-2.625 /_bb;return dab*abb*abb+0.984375 end end;local function d_b(cab)return 1 -c_b(1 -cab)end;local function _ab(cab)return -x<0.5 and(1 - -c_b(1 -2 *cab))/2 or(1 +c_b(2 *cab-1))/2 end -local aab={linear=_d,lerp=dc,flip=ad,easeIn=bd,easeInSine=a_a,easeInBack=c_a,easeInCubic=d_a,easeInElastic=_aa,easeInExpo=baa,easeInQuad=_ca,easeInQuart=aca,easeInQuint=bca,easeInCirc=__b,easeInBounce=d_b,easeOut=cd,easeOutSine=__a,easeOutBack=cca,easeOutCubic=dca,easeOutElastic=_da,easeOutExpo=ada,easeOutQuad=bda,easeOutQuart=cda,easeOutQuint=dda,easeOutCirc=a_b,easeOutBounce=c_b,easeInOut=dd,easeInOutSine=b_a,easeInOutBack=caa,easeInOutCubic=daa,easeInOutElastic=_ba,easeInOutExpo=aba,easeInOutQuad=bba,easeInOutQuart=cba,easeInOutQuint=dba,easeInOutCirc=b_b,easeInOutBounce=_ab}local bab={} -return -function(cab)local dab={}local _bb="Animation"local abb;local bbb={}local cbb=0;local dbb=false;local _cb=1;local acb=false -local bcb=bb()local ccb=0;local dcb;local _db=false;local adb=false;local bdb="easeOut"local cdb;local function ddb(c_c)for d_c,_ac in pairs(c_c)do -_ac(dab,bbb[_cb].t,_cb)end end -local function __c(c_c)if(_cb==1)then -c_c:animationStartHandler()end;if(bbb[_cb]~=nil)then ddb(bbb[_cb].f) -cbb=bbb[_cb].t end;_cb=_cb+1 -if(bbb[_cb]==nil)then if(acb)then _cb=1;cbb=0 else -c_c:animationDoneHandler()return end end;if(bbb[_cb].t>0)then -abb=os.startTimer(bbb[_cb].t-cbb)else __c(c_c)end end -local function a_c(c_c,d_c)for n=1,#bbb do -if(bbb[n].t==c_c)then table.insert(bbb[n].f,d_c)return end end -for n=1,#bbb do -if(bbb[n].t>c_c)then if -(bbb[n-1]~=nil)then if(bbb[n-1].t=_ac-0.01)then if(bab[dac][dbc]==_bc)then bab[dac][dbc]= -nil end end end end)end end -dab={name=cab,getType=function(c_c)return _bb end,getBaseFrame=function(c_c)if(c_c.parent~=nil)then -return c_c.parent:getBaseFrame()end;return c_c end,setMode=function(c_c,d_c) -bdb=d_c;return c_c end,addMode=function(c_c,d_c,_ac)aab[d_c]=_ac;return c_c end,generateXMLEventFunction=function(c_c,d_c,_ac) -local aac=function(bac) -if( -bac:sub(1,1)=="#")then -local cac=c_c:getBaseFrame():getDeepObject(bac:sub(2,bac:len())) -if(cac~=nil)and(cac.internalObjetCall~=nil)then d_c(c_c,function() -cac:internalObjetCall()end)end else -d_c(c_c,c_c:getBaseFrame():getVariable(bac))end end;if(type(_ac)=="string")then aac(_ac)elseif(type(_ac)=="table")then -for bac,cac in pairs(_ac)do aac(cac)end end;return c_c end,setValuesByXMLData=function(c_c,d_c)_db= -ab("loop",d_c)==true and true or false -if( -ab("object",d_c)~=nil)then -local _ac=c_c:getBaseFrame():getDeepObject(ab("object",d_c))if(_ac==nil)then -_ac=c_c:getBaseFrame():getVariable(ab("object",d_c))end -if(_ac~=nil)then c_c:setObject(_ac)end end -if(d_c["move"]~=nil)then local _ac=ab("x",d_c["move"]) -local aac=ab("y",d_c["move"])local bac=ab("duration",d_c["move"]) -local cac=ab("time",d_c["move"])c_c:move(_ac,aac,bac,cac)end -if(d_c["size"]~=nil)then local _ac=ab("width",d_c["size"]) -local aac=ab("height",d_c["size"])local bac=ab("duration",d_c["size"]) -local cac=ab("time",d_c["size"])c_c:size(_ac,aac,bac,cac)end -if(d_c["offset"]~=nil)then local _ac=ab("x",d_c["offset"]) -local aac=ab("y",d_c["offset"])local bac=ab("duration",d_c["offset"]) -local cac=ab("time",d_c["offset"])c_c:offset(_ac,aac,bac,cac)end -if(d_c["textColor"]~=nil)then -local _ac=ab("duration",d_c["textColor"])local aac=ab("time",d_c["textColor"])local bac={} -local cac=d_c["textColor"]["color"] -if(cac~=nil)then if(cac.properties~=nil)then cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,colors[_bc:value()])end end;if(_ac~=nil)and(#bac>0)then -c_c:changeTextColor(_ac,aac or 0,table.unpack(bac))end end -if(d_c["background"]~=nil)then -local _ac=ab("duration",d_c["background"])local aac=ab("time",d_c["background"])local bac={} -local cac=d_c["background"]["color"] -if(cac~=nil)then if(cac.properties~=nil)then cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,colors[_bc:value()])end end;if(_ac~=nil)and(#bac>0)then -c_c:changeBackground(_ac,aac or 0,table.unpack(bac))end end -if(d_c["text"]~=nil)then local _ac=ab("duration",d_c["text"]) -local aac=ab("time",d_c["text"])local bac={}local cac=d_c["text"]["text"] -if(cac~=nil)then if(cac.properties~=nil)then -cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,_bc:value())end end;if(_ac~=nil)and(#bac>0)then -c_c:changeText(_ac,aac or 0,table.unpack(bac))end end;if(ab("onDone",d_c)~=nil)then -c_c:generateXMLEventFunction(c_c.onDone,ab("onDone",d_c))end;if(ab("onStart",d_c)~=nil)then -c_c:generateXMLEventFunction(c_c.onDone,ab("onStart",d_c))end -if -(ab("autoDestroy",d_c)~=nil)then if(ab("autoDestroy",d_c))then adb=true end end;bdb=ab("mode",d_c)or bdb -if(ab("play",d_c)~=nil)then if -(ab("play",d_c))then c_c:play(_db)end end;return c_c end,getZIndex=function(c_c)return -1 end,getName=function(c_c)return c_c.name end,setObject=function(c_c,d_c)cdb=d_c;return c_c end,move=function(c_c,d_c,_ac,aac,bac,cac)cdb= -cac or cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getPosition,cdb.setPosition,"position",c_c)return c_c end,offset=function(c_c,d_c,_ac,aac,bac,cac)cdb= -cac or cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getOffset,cdb.setOffset,"offset",c_c)return c_c end,size=function(c_c,d_c,_ac,aac,bac,cac)cdb=cac or -cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getSize,cdb.setSize,"size",c_c)return c_c end,changeText=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setText(cdb,aac[n])end)end;return c_c end,changeBackground=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setBackground(cdb,aac[n])end)end;return c_c end,changeTextColor=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setForeground(cdb,aac[n])end)end;return c_c end,add=function(c_c,d_c,_ac) -dcb=d_c -a_c((_ac or ccb)+ -(bbb[#bbb]~=nil and bbb[#bbb].t or 0),d_c)return c_c end,wait=function(c_c,d_c)ccb=d_c;return c_c end,rep=function(c_c,d_c) -if( -dcb~=nil)then for n=1,d_c or 1 do -a_c((wait or ccb)+ -(bbb[#bbb]~=nil and bbb[#bbb].t or 0),dcb)end end;return c_c end,onDone=function(c_c,d_c) -bcb:registerEvent("animation_done",d_c)return c_c end,onStart=function(c_c,d_c) -bcb:registerEvent("animation_start",d_c)return c_c end,setAutoDestroy=function(c_c,d_c) -adb=d_c~=nil and d_c or true;return c_c end,animationDoneHandler=function(c_c) -bcb:sendEvent("animation_done",c_c)c_c.parent:removeEvent("other_event",c_c)if(adb)then -c_c.parent:removeObject(c_c)c_c=nil end end,animationStartHandler=function(c_c) -bcb:sendEvent("animation_start",c_c)end,clear=function(c_c)bbb={}dcb=nil;ccb=0;_cb=1;cbb=0;acb=false;return c_c end,play=function(c_c,d_c) -c_c:cancel()dbb=true;acb=d_c and true or false;_cb=1;cbb=0 -if(bbb[_cb]~=nil)then -if( -bbb[_cb].t>0)then abb=os.startTimer(bbb[_cb].t)else __c(c_c)end else c_c:animationDoneHandler()end;c_c.parent:addEvent("other_event",c_c)return c_c end,cancel=function(c_c)if( -abb~=nil)then os.cancelTimer(abb)acb=false end -dbb=false;c_c.parent:removeEvent("other_event",c_c)return c_c end,internalObjetCall=function(c_c) -c_c:play(_db)end,eventHandler=function(c_c,d_c,_ac)if(dbb)then -if(d_c=="timer")and(_ac==abb)then if(bbb[_cb]~=nil)then -__c(c_c)else c_c:animationDoneHandler()end end end end}dab.__index=dab;return dab end end -aa["objects"]["List"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="List"_c.width=16;_c.height=6;_c:setZIndex(5)local bc={} -local cc;local dc;local _d=true;local ad="left"local bd=0;local cd=true -local dd={getType=function(__a)return ac end,addItem=function(__a,a_a,b_a,c_a,...) -table.insert(bc,{text=a_a,bgCol=b_a or __a.bgColor,fgCol= -c_a or __a.fgColor,args={...}})if(#bc<=1)then __a:setValue(bc[1],false)end -__a:updateDraw()return __a end,setOffset=function(__a,a_a) -bd=a_a;__a:updateDraw()return __a end,getOffset=function(__a)return bd end,removeItem=function(__a,a_a) -table.remove(bc,a_a)__a:updateDraw()return __a end,getItem=function(__a,a_a) -return bc[a_a]end,getAll=function(__a)return bc end,getItemIndex=function(__a)local a_a=__a:getValue()for b_a,c_a in pairs(bc)do if -(c_a==a_a)then return b_a end end end,clear=function(__a) -bc={}__a:setValue({},false)__a:updateDraw()return __a end,getItemCount=function(__a)return -#bc end,editItem=function(__a,a_a,b_a,c_a,d_a,...)table.remove(bc,a_a) -table.insert(bc,a_a,{text=b_a,bgCol=c_a or __a.bgColor,fgCol= -d_a or __a.fgColor,args={...}})__a:updateDraw()return __a end,selectItem=function(__a,a_a)__a:setValue( -bc[a_a]or{},false)__a:updateDraw()return __a end,setSelectedItem=function(__a,a_a,b_a,c_a)cc= -a_a or __a.bgColor;dc=b_a or __a.fgColor;_d=c_a~=nil and c_a or -true;__a:updateDraw()return __a end,setScrollable=function(__a,a_a) -cd=a_a;if(a_a==nil)then cd=true end;__a:updateDraw()return __a end,setValuesByXMLData=function(__a,a_a) -_c.setValuesByXMLData(__a,a_a)if(cb("selectionBG",a_a)~=nil)then -cc=colors[cb("selectionBG",a_a)]end;if(cb("selectionFG",a_a)~=nil)then -dc=colors[cb("selectionFG",a_a)]end;if(cb("scrollable",a_a)~=nil)then -if -(cb("scrollable",a_a))then __a:setScrollable(true)else __a:setScrollable(false)end end;if( -cb("offset",a_a)~=nil)then bd=cb("offset",a_a)end -if(a_a["item"]~= -nil)then local b_a=a_a["item"] -if(b_a.properties~=nil)then b_a={b_a}end;for c_a,d_a in pairs(b_a)do -__a:addItem(cb("text",d_a),colors[cb("bg",d_a)],colors[cb("fg",d_a)])end end;return __a end,scrollHandler=function(__a,a_a,b_a,c_a) -if -(_c.scrollHandler(__a,a_a,b_a,c_a))then -if(cd)then local d_a,_aa=__a:getSize()bd=bd+a_a;if(bd<0)then bd=0 end -if(a_a>=1)then if(#bc>_aa)then if(bd> -#bc-_aa)then bd=#bc-_aa end;if(bd>=#bc)then bd=#bc-1 end else bd= -bd-1 end end;__a:updateDraw()end;return true end;return false end,mouseHandler=function(__a,a_a,b_a,c_a) -if -(_c.mouseHandler(__a,a_a,b_a,c_a))then -local d_a,_aa=__a:getAbsolutePosition(__a:getAnchorPosition())local aaa,baa=__a:getSize() -if(#bc>0)then for n=1,baa do -if(bc[n+bd]~=nil)then if(d_a<=b_a)and -(d_a+aaa>b_a)and(_aa+n-1 ==c_a)then -__a:setValue(bc[n+bd])__a:updateDraw()end end end end;return true end;return false end,dragHandler=function(__a,a_a,b_a,c_a)return -__a:mouseHandler(a_a,b_a,c_a)end,touchHandler=function(__a,a_a,b_a)return -__a:mouseHandler(1,a_a,b_a)end,draw=function(__a) -if(_c.draw(__a))then -if -(__a.parent~=nil)then local a_a,b_a=__a:getAnchorPosition()local c_a,d_a=__a:getSize()if( -__a.bgColor~=false)then -__a.parent:drawBackgroundBox(a_a,b_a,c_a,d_a,__a.bgColor)end -for n=1,d_a do -if(bc[n+bd]~=nil)then -if(bc[n+bd]== -__a:getValue())then -if(_d)then -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),cc,dc)else -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end else -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end end end end end end,init=function(__a) -__a.parent:addEvent("mouse_click",__a)__a.parent:addEvent("mouse_drag",__a) -__a.parent:addEvent("mouse_scroll",__a) -if(_c.init(__a))then __a.bgColor=__a.parent:getTheme("ListBG") -__a.fgColor=__a.parent:getTheme("ListText")cc=__a.parent:getTheme("SelectionBG") -dc=__a.parent:getTheme("SelectionText")end end}return setmetatable(dd,_c)end end -aa["objects"]["Pane"]=function(...)local ab=da("Object")local bb=da("basaltLogs") -return -function(cb) -local db=ab(cb)local _c="Pane" -local ac={getType=function(bc)return _c end,setBackground=function(bc,cc,dc,_d)db.setBackground(bc,cc,dc,_d) -return bc end,init=function(bc) -if(db.init(bc))then -bc.bgColor=bc.parent:getTheme("PaneBG")bc.fgColor=bc.parent:getTheme("PaneBG")end end}return setmetatable(ac,db)end end -aa["objects"]["Program"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("process")local db=da("utils").getValueFromXML;local _c=string.sub -return -function(ac,bc)local cc=ab(ac) -local dc="Program"cc:setZIndex(5)local _d;local ad;local bd={} -local function cd(baa,caa,daa,_ba,aba)local bba,cba=1,1 -local dba,_ca=colors.black,colors.white;local aca=false;local bca=false;local cca={}local dca={}local _da={}local ada={}local bda;local cda={}for i=0,15 do local abb=2 ^i -ada[abb]={bc:getBasaltInstance().getBaseTerm().getPaletteColour(abb)}end;local function dda() -bda=(" "):rep(daa) -for n=0,15 do local abb=2 ^n;local bbb=bb[abb]cda[abb]=bbb:rep(daa)end end -local function __b()dda()local abb=bda -local bbb=cda[colors.white]local cbb=cda[colors.black] -for n=1,_ba do -cca[n]=_c(cca[n]==nil and abb or cca[n]..abb:sub(1, -daa-cca[n]:len()),1,daa) -_da[n]=_c(_da[n]==nil and bbb or _da[n].. -bbb:sub(1,daa-_da[n]:len()),1,daa) -dca[n]=_c(dca[n]==nil and cbb or dca[n].. -cbb:sub(1,daa-dca[n]:len()),1,daa)end;cc.updateDraw(cc)end;__b()local function a_b()if -bba>=1 and cba>=1 and bba<=daa and cba<=_ba then else end end -local function b_b(abb,bbb,cbb) -local dbb=bba;local _cb=dbb+#abb-1 -if cba>=1 and cba<=_ba then -if dbb<=daa and _cb>=1 then -if dbb==1 and _cb== -daa then cca[cba]=abb;_da[cba]=bbb;dca[cba]=cbb else local acb,bcb,ccb -if dbb<1 then local __c= -1 -dbb+1;local a_c=daa-dbb+1;acb=_c(abb,__c,a_c) -bcb=_c(bbb,__c,a_c)ccb=_c(cbb,__c,a_c)elseif _cb>daa then local __c=daa-dbb+1;acb=_c(abb,1,__c) -bcb=_c(bbb,1,__c)ccb=_c(cbb,1,__c)else acb=abb;bcb=bbb;ccb=cbb end;local dcb=cca[cba]local _db=_da[cba]local adb=dca[cba]local bdb,cdb,ddb -if dbb>1 then local __c=dbb-1;bdb= -_c(dcb,1,__c)..acb;cdb=_c(_db,1,__c)..bcb -ddb=_c(adb,1,__c)..ccb else bdb=acb;cdb=bcb;ddb=ccb end -if _cb=1 and _cb<=_ba then -cca[newY]=cca[_cb]dca[newY]=dca[_cb]_da[newY]=_da[_cb]else cca[newY]=bbb -_da[newY]=cbb;dca[newY]=dbb end end end;if(bca)then a_b()end end,isColor=function()return -bc:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return -bc:getBasaltInstance().getBaseTerm().isColor()end,write=function(abb) -abb=tostring(abb)if(bca)then -b_b(abb,bb[_ca]:rep(abb:len()),bb[dba]:rep(abb:len()))end end,clearLine=function() -if -(bca)then c_b(1,cba,(" "):rep(daa)) -d_b(1,cba,bb[dba]:rep(daa))_ab(1,cba,bb[_ca]:rep(daa))end;if(bca)then a_b()end end,clear=function() -for n=1,_ba -do c_b(1,n,(" "):rep(daa)) -d_b(1,n,bb[dba]:rep(daa))_ab(1,n,bb[_ca]:rep(daa))end;if(bca)then a_b()end end,blit=function(abb,bbb,cbb)if -type(abb)~="string"then -error("bad argument #1 (expected string, got "..type(abb)..")",2)end;if type(bbb)~="string"then -error( -"bad argument #2 (expected string, got "..type(bbb)..")",2)end;if type(cbb)~="string"then -error( -"bad argument #3 (expected string, got "..type(cbb)..")",2)end -if -#bbb~=#abb or#cbb~=#abb then error("Arguments must be the same length",2)end;if(bca)then b_b(abb,bbb,cbb)end end}return _bb end;cc.width=30;cc.height=12;local dd=cd(1,1,cc.width,cc.height)local __a -local a_a=false;local b_a={} -local function c_a(baa)local caa,daa=dd.getCursorPos() -local _ba,aba=baa:getAnchorPosition()local bba,cba=baa:getSize() -if(_ba+caa-1 >=1 and -_ba+caa-1 <=_ba+bba-1 and daa+aba-1 >=1 and -daa+aba-1 <=aba+cba-1)then -baa.parent:setCursor( -baa:isFocused()and dd.getCursorBlink(),_ba+caa-1,daa+aba-1,dd.getTextColor())end end -local function d_a(baa,caa,...)local daa,_ba=__a:resume(caa,...) -if(daa==false)and(_ba~=nil)and -(_ba~="Terminated")then -local aba=baa:sendEvent("program_error",_ba) -if(aba~=false)then error("Basalt Program - ".._ba)end end -if(__a:getStatus()=="dead")then baa:sendEvent("program_done")end end -local function _aa(baa,caa,daa,_ba,aba)if(__a==nil)then return false end -if not(__a:isDead())then if not(a_a)then -local bba,cba=baa:getAbsolutePosition(baa:getAnchorPosition( -nil,nil,true))d_a(baa,caa,daa,_ba-bba+1,aba-cba+1) -c_a(baa)end end end -local function aaa(baa,caa,daa,_ba)if(__a==nil)then return false end -if not(__a:isDead())then if not(a_a)then if(baa.draw)then -d_a(baa,caa,daa,_ba)c_a(baa)end end end end -_d={getType=function(baa)return dc end,show=function(baa)cc.show(baa) -dd.setBackgroundColor(baa.bgColor)dd.setTextColor(baa.fgColor) -dd.basalt_setVisible(true)return baa end,hide=function(baa) -cc.hide(baa)dd.basalt_setVisible(false)return baa end,setPosition=function(baa,caa,daa,_ba) -cc.setPosition(baa,caa,daa,_ba) -dd.basalt_reposition(baa:getAnchorPosition())return baa end,setValuesByXMLData=function(baa,caa) -cc.setValuesByXMLData(baa,caa)if(db("path",caa)~=nil)then ad=db("path",caa)end -if( -db("execute",caa)~=nil)then if(db("execute",caa))then -if(ad~=nil)then baa:execute(ad)end end end end,getBasaltWindow=function()return -dd end,getBasaltProcess=function()return __a end,setSize=function(baa,caa,daa,_ba)cc.setSize(baa,caa,daa,_ba) -dd.basalt_resize(baa:getWidth(),baa:getHeight())return baa end,getStatus=function(baa)if(__a~=nil)then return -__a:getStatus()end;return"inactive"end,setEnviroment=function(baa,caa)bd= -caa or{}return baa end,execute=function(baa,caa,...)ad=caa or ad -__a=cb:new(ad,dd,bd,...)dd.setBackgroundColor(colors.black) -dd.setTextColor(colors.white)dd.clear()dd.setCursorPos(1,1) -dd.setBackgroundColor(baa.bgColor)dd.setTextColor(baa.fgColor) -dd.basalt_setVisible(true)d_a(baa)a_a=false -if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)baa.parent:addEvent("mouse_up",baa) -baa.parent:addEvent("mouse_drag",baa)baa.parent:addEvent("mouse_scroll",baa) -baa.parent:addEvent("key",baa)baa.parent:addEvent("key_up",baa) -baa.parent:addEvent("char",baa)baa.parent:addEvent("other_event",baa)end;return baa end,stop=function(baa) -if( -__a~=nil)then -if not(__a:isDead())then d_a(baa,"terminate")if(__a:isDead())then -if( -baa.parent~=nil)then baa.parent:setCursor(false)end end end end;baa.parent:removeEvents(baa)return baa end,pause=function(baa,caa)a_a= -caa or(not a_a) -if(__a~=nil)then if not(__a:isDead())then if not(a_a)then -baa:injectEvents(b_a)b_a={}end end end;return baa end,isPaused=function(baa)return -a_a end,injectEvent=function(baa,caa,daa,_ba,aba,bba,cba) -if(__a~=nil)then -if not(__a:isDead())then if(a_a==false)or(cba)then -d_a(baa,caa,daa,_ba,aba,bba)else -table.insert(b_a,{event=caa,args={daa,_ba,aba,bba}})end end end;return baa end,getQueuedEvents=function(baa)return -b_a end,updateQueuedEvents=function(baa,caa)b_a=caa or b_a;return baa end,injectEvents=function(baa,caa)if(__a~=nil)then -if not -(__a:isDead())then for daa,_ba in pairs(caa)do -d_a(baa,_ba.event,table.unpack(_ba.args))end end end;return baa end,mouseHandler=function(baa,caa,daa,_ba) -if -(cc.mouseHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_click",caa,daa,_ba)return true end;return false end,mouseUpHandler=function(baa,caa,daa,_ba) -if -(cc.mouseUpHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_up",caa,daa,_ba)return true end;return false end,scrollHandler=function(baa,caa,daa,_ba) -if -(cc.scrollHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_scroll",caa,daa,_ba)return true end;return false end,dragHandler=function(baa,caa,daa,_ba) -if -(cc.dragHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_drag",caa,daa,_ba)return true end;return false end,keyHandler=function(baa,caa,daa)if -(cc.keyHandler(baa,caa,daa))then aaa(baa,"key",caa,daa)return true end;return -false end,keyUpHandler=function(baa,caa)if -(cc.keyUpHandler(baa,caa))then aaa(baa,"key_up",caa)return true end -return false end,charHandler=function(baa,caa)if -(cc.charHandler(baa,caa))then aaa(baa,"char",caa)return true end -return false end,getFocusHandler=function(baa) -cc.getFocusHandler(baa) -if(__a~=nil)then -if not(__a:isDead())then -if not(a_a)then -if(baa.parent~=nil)then -local caa,daa=dd.getCursorPos()local _ba,aba=baa:getAnchorPosition()local bba,cba=baa:getSize() -if -( -_ba+caa-1 >=1 and _ba+caa-1 <=_ba+bba-1 and -daa+aba-1 >=1 and daa+aba-1 <=aba+cba-1)then -baa.parent:setCursor(dd.getCursorBlink(),_ba+caa-1,daa+aba-1,dd.getTextColor())end end end end end end,loseFocusHandler=function(baa) -cc.loseFocusHandler(baa) -if(__a~=nil)then if not(__a:isDead())then if(baa.parent~=nil)then -baa.parent:setCursor(false)end end end end,customEventHandler=function(baa,caa,...) -cc.customEventHandler(baa,caa,...)if(__a==nil)then return end -if(caa=="basalt_resize")then local daa,_ba=dd.getSize() -local aba,bba=baa:getSize() -if(daa~=aba)or(_ba~=bba)then dd.basalt_resize(aba,bba)if not -(__a:isDead())then d_a(baa,"term_resize")end end -dd.basalt_reposition(baa:getAnchorPosition())end end,eventHandler=function(baa,caa,daa,_ba,aba,bba) -cc.eventHandler(baa,caa,daa,_ba,aba,bba)if(__a==nil)then return end -if not(__a:isDead())then -if not(a_a)then if(caa~="terminate")then -d_a(baa,caa,daa,_ba,aba,bba)end -if(baa:isFocused())then -local cba,dba=baa:getAnchorPosition()local _ca,aca=dd.getCursorPos() -if(baa.parent~=nil)then -local bca,cca=baa:getSize() -if -(cba+_ca-1 >=1 and cba+_ca-1 <=cba+bca-1 and -aca+dba-1 >=1 and aca+dba-1 <=dba+cca-1)then -baa.parent:setCursor(dd.getCursorBlink(),cba+_ca-1,aca+dba-1,dd.getTextColor())end end;if(caa=="terminate")then d_a(baa,caa) -baa.parent:setCursor(false)return true end end else -table.insert(b_a,{event=caa,args={daa,_ba,aba,bba}})end end end,draw=function(baa) -if -(cc.draw(baa))then -if(baa.parent~=nil)then local caa,daa=baa:getAnchorPosition() -local _ba,aba=dd.getCursorPos()local bba,cba=baa:getSize()dd.basalt_reposition(caa,daa) -dd.basalt_update() -if -(caa+_ba-1 >=1 and caa+_ba-1 <=caa+bba-1 and -aba+daa-1 >=1 and aba+daa-1 <=daa+cba-1)then -baa.parent:setCursor(baa:isFocused()and dd.getCursorBlink(), -caa+_ba-1,aba+daa-1,dd.getTextColor())end end end end,onError=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("program_error",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)end;return baa end,onDone=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("program_done",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)end;return baa end,init=function(baa) -if -(cc.init(baa))then baa.bgColor=baa.parent:getTheme("ProgramBG")end end}return setmetatable(_d,cc)end end -aa["objects"]["Progressbar"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Progressbar"local ac=0;db:setZIndex(5) -db:setValue(false)db.width=25;db.height=1;local bc;local cc=""local dc=colors.white;local _d=""local ad=0 -local bd={init=function(cd) -if -(db.init(cd))then cd.bgColor=cd.parent:getTheme("ProgressbarBG") -cd.fgColor=cd.parent:getTheme("ProgressbarText")bc=cd.parent:getTheme("ProgressbarActiveBG")end end,getType=function(cd)return -_c end,setValuesByXMLData=function(cd,dd)db.setValuesByXMLData(cd,dd)if(bb("direction",dd)~= -nil)then ad=bb("direction",dd)end -if( -bb("progressColor",dd)~=nil)then bc=colors[bb("progressColor",dd)]end -if(bb("progressSymbol",dd)~=nil)then cc=bb("progressSymbol",dd)end;if(bb("backgroundSymbol",dd)~=nil)then -_d=bb("backgroundSymbol",dd)end -if -(bb("progressSymbolColor",dd)~=nil)then dc=colors[bb("progressSymbolColor",dd)]end;if(bb("onDone",dd)~=nil)then -cd:generateXMLEventFunction(cd.onProgressDone,bb("onDone",dd))end;return cd end,setDirection=function(cd,dd) -ad=dd;cd:updateDraw()return cd end,setProgressBar=function(cd,dd,__a,a_a)bc=dd or bc -cc=__a or cc;dc=a_a or dc;cd:updateDraw()return cd end,setBackgroundSymbol=function(cd,dd) -_d=dd:sub(1,1)cd:updateDraw()return cd end,setProgress=function(cd,dd)if -(dd>=0)and(dd<=100)and(ac~=dd)then ac=dd;cd:setValue(ac)if(ac==100)then -cd:progressDoneHandler()end end -cd:updateDraw()return cd end,getProgress=function(cd)return -ac end,onProgressDone=function(cd,dd)cd:registerEvent("progress_done",dd) -return cd end,progressDoneHandler=function(cd) -cd:sendEvent("progress_done",cd)end,draw=function(cd) -if(db.draw(cd))then -if(cd.parent~=nil)then -local dd,__a=cd:getAnchorPosition()local a_a,b_a=cd:getSize()if(cd.bgColor~=false)then -cd.parent:drawBackgroundBox(dd,__a,a_a,b_a,cd.bgColor)end;if(_d~="")then -cd.parent:drawTextBox(dd,__a,a_a,b_a,_d)end;if(cd.fgColor~=false)then -cd.parent:drawForegroundBox(dd,__a,a_a,b_a,cd.fgColor)end -if(ad==1)then cd.parent:drawBackgroundBox(dd,__a,a_a, -b_a/100 *ac,bc)cd.parent:drawForegroundBox(dd,__a,a_a, -b_a/100 *ac,dc)cd.parent:drawTextBox(dd,__a,a_a, -b_a/100 *ac,cc)elseif(ad==2)then -cd.parent:drawBackgroundBox(dd, -__a+math.ceil(b_a-b_a/100 *ac),a_a,b_a/100 *ac,bc) -cd.parent:drawForegroundBox(dd,__a+math.ceil(b_a-b_a/100 *ac),a_a, -b_a/100 *ac,dc) -cd.parent:drawTextBox(dd,__a+math.ceil(b_a-b_a/100 *ac),a_a, -b_a/100 *ac,cc)elseif(ad==3)then -cd.parent:drawBackgroundBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,bc) -cd.parent:drawForegroundBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,dc) -cd.parent:drawTextBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,cc)else -cd.parent:drawBackgroundBox(dd,__a,a_a/100 *ac,b_a,bc) -cd.parent:drawForegroundBox(dd,__a,a_a/100 *ac,b_a,dc) -cd.parent:drawTextBox(dd,__a,a_a/100 *ac,b_a,cc)end end end end}return setmetatable(bd,db)end end -aa["objects"]["Scrollbar"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Scrollbar"db.width=1;db.height=8;db:setValue(1) -db:setZIndex(2)local ac="vertical"local bc=" "local cc;local dc="\127"local _d=db.height;local ad=1;local bd=1 -local function cd(__a,a_a,b_a,c_a) -local d_a,_aa=__a:getAbsolutePosition(__a:getAnchorPosition())local aaa,baa=__a:getSize() -if(ac=="horizontal")then -for _index=0,aaa do -if -(d_a+_index==b_a)and(_aa<=c_a)and(_aa+baa>c_a)then -ad=math.min(_index+1,aaa- (bd-1))__a:setValue(_d/aaa* (ad))__a:updateDraw()end end end -if(ac=="vertical")then -for _index=0,baa do -if -(_aa+_index==c_a)and(d_a<=b_a)and(d_a+aaa>b_a)then ad=math.min(_index+1,baa- (bd-1)) -__a:setValue(_d/baa* (ad))__a:updateDraw()end end end end -local dd={getType=function(__a)return _c end,setSymbol=function(__a,a_a)bc=a_a:sub(1,1)__a:updateDraw()return __a end,setValuesByXMLData=function(__a,a_a) -db.setValuesByXMLData(__a,a_a) -if(bb("maxValue",a_a)~=nil)then _d=bb("maxValue",a_a)end;if(bb("backgroundSymbol",a_a)~=nil)then -dc=bb("backgroundSymbol",a_a):sub(1,1)end;if(bb("symbol",a_a)~=nil)then -bc=bb("symbol",a_a):sub(1,1)end;if(bb("barType",a_a)~=nil)then -ac=bb("barType",a_a):lower()end;if(bb("symbolSize",a_a)~=nil)then -__a:setSymbolSize(bb("symbolSize",a_a))end;if(bb("symbolColor",a_a)~=nil)then -cc=colors[bb("symbolColor",a_a)]end;if(bb("index",a_a)~=nil)then -__a:setIndex(bb("index",a_a))end end,setIndex=function(__a,a_a) -ad=a_a;if(ad<1)then ad=1 end;local b_a,c_a=__a:getSize() -ad=math.min(ad,( -ac=="vertical"and c_a or b_a)- (bd-1)) -__a:setValue(_d/ (ac=="vertical"and c_a or b_a)*ad)__a:updateDraw()return __a end,getIndex=function(__a)return -ad end,setSymbolSize=function(__a,a_a)bd=tonumber(a_a)or 1 -local b_a,c_a=__a:getSize() -if(ac=="vertical")then -__a:setValue(ad-1 * (_d/ (c_a- (bd-1)))- (_d/ (c_a- -(bd-1))))elseif(ac=="horizontal")then -__a:setValue(ad-1 * (_d/ (b_a- (bd-1)))- (_d/ (b_a- ( -bd-1))))end;__a:updateDraw()return __a end,setMaxValue=function(__a,a_a) -_d=a_a;__a:updateDraw()return __a end,setBackgroundSymbol=function(__a,a_a) -dc=string.sub(a_a,1,1)__a:updateDraw()return __a end,setSymbolColor=function(__a,a_a)cc=a_a -__a:updateDraw()return __a end,setBarType=function(__a,a_a)ac=a_a:lower() -__a:updateDraw()return __a end,mouseHandler=function(__a,a_a,b_a,c_a)if(db.mouseHandler(__a,a_a,b_a,c_a))then -cd(__a,a_a,b_a,c_a)return true end;return false end,dragHandler=function(__a,a_a,b_a,c_a)if -(db.dragHandler(__a,a_a,b_a,c_a))then cd(__a,a_a,b_a,c_a)return true end -return false end,scrollHandler=function(__a,a_a,b_a,c_a) -if -(db.scrollHandler(__a,a_a,b_a,c_a))then local d_a,_aa=__a:getSize()ad=ad+a_a;if(ad<1)then ad=1 end -ad=math.min(ad,( -ac=="vertical"and _aa or d_a)- (bd-1)) -__a:setValue(_d/ (ac=="vertical"and _aa or d_a)*ad)__a:updateDraw()end end,draw=function(__a) -if -(db.draw(__a))then -if(__a.parent~=nil)then local a_a,b_a=__a:getAnchorPosition() -local c_a,d_a=__a:getSize() -if(ac=="horizontal")then -__a.parent:writeText(a_a,b_a,dc:rep(ad-1),__a.bgColor,__a.fgColor) -__a.parent:writeText(a_a+ad-1,b_a,bc:rep(bd),cc,cc) -__a.parent:writeText(a_a+ad+bd-1,b_a,dc:rep(c_a- (ad+bd-1)),__a.bgColor,__a.fgColor)end -if(ac=="vertical")then -for n=0,d_a-1 do -if(ad==n+1)then -for curIndexOffset=0,math.min(bd-1,d_a)do __a.parent:writeText(a_a,b_a+n+ -curIndexOffset,bc,cc,cc)end else if(n+1 ad-1 +bd)then -__a.parent:writeText(a_a,b_a+n,dc,__a.bgColor,__a.fgColor)end end end end end end end,init=function(__a) -__a.parent:addEvent("mouse_click",__a)__a.parent:addEvent("mouse_drag",__a) -__a.parent:addEvent("mouse_scroll",__a) -if(db.init(__a))then -__a.bgColor=__a.parent:getTheme("ScrollbarBG")__a.fgColor=__a.parent:getTheme("ScrollbarText") -cc=__a.parent:getTheme("ScrollbarSymbolColor")end end}return setmetatable(dd,db)end end -aa["objects"]["Radio"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="Radio"_c.width=8;_c:setZIndex(5)local bc={}local cc;local dc -local _d;local ad;local bd;local cd;local dd=true;local __a="\7"local a_a="left" -local b_a={getType=function(c_a)return ac end,setValuesByXMLData=function(c_a,d_a) -_c.setValuesByXMLData(c_a,d_a)if(cb("selectionBG",d_a)~=nil)then -cc=colors[cb("selectionBG",d_a)]end;if(cb("selectionFG",d_a)~=nil)then -dc=colors[cb("selectionFG",d_a)]end;if(cb("boxBG",d_a)~=nil)then -_d=colors[cb("boxBG",d_a)]end;if(cb("inactiveBoxBG",d_a)~=nil)then -bd=colors[cb("inactiveBoxBG",d_a)]end;if(cb("inactiveBoxFG",d_a)~=nil)then -cd=colors[cb("inactiveBoxFG",d_a)]end;if(cb("boxFG",d_a)~=nil)then -ad=colors[cb("boxFG",d_a)]end;if(cb("symbol",d_a)~=nil)then -__a=cb("symbol",d_a)end -if(d_a["item"]~=nil)then local _aa=d_a["item"]if( -_aa.properties~=nil)then _aa={_aa}end;for aaa,baa in pairs(_aa)do -c_a:addItem(cb("text",baa),cb("x",baa),cb("y",baa),colors[cb("bg",baa)],colors[cb("fg",baa)])end end;return c_a end,addItem=function(c_a,d_a,_aa,aaa,baa,caa,...) -table.insert(bc,{x= -_aa or 1,y=aaa or 1,text=d_a,bgCol=baa or c_a.bgColor,fgCol=caa or c_a.fgColor,args={...}})if(#bc==1)then c_a:setValue(bc[1])end -c_a:updateDraw()return c_a end,getAll=function(c_a)return -bc end,removeItem=function(c_a,d_a)table.remove(bc,d_a)c_a:updateDraw() -return c_a end,getItem=function(c_a,d_a)return bc[d_a]end,getItemIndex=function(c_a) -local d_a=c_a:getValue()for _aa,aaa in pairs(bc)do if(aaa==d_a)then return _aa end end end,clear=function(c_a) -bc={}c_a:setValue({},false)c_a:updateDraw()return c_a end,getItemCount=function(c_a)return -#bc end,editItem=function(c_a,d_a,_aa,aaa,baa,caa,daa,...)table.remove(bc,d_a) -table.insert(bc,d_a,{x=aaa or 1,y=baa or 1,text=_aa,bgCol= -caa or c_a.bgColor,fgCol=daa or c_a.fgColor,args={...}})c_a:updateDraw()return c_a end,selectItem=function(c_a,d_a)c_a:setValue( -bc[d_a]or{},false)c_a:updateDraw()return c_a end,setActiveSymbol=function(c_a,d_a) -__a=d_a:sub(1,1)c_a:updateDraw()return c_a end,setSelectedItem=function(c_a,d_a,_aa,aaa,baa,caa) -cc=d_a or cc;dc=_aa or dc;_d=aaa or _d;ad=baa or ad -dd=caa~=nil and caa or true;c_a:updateDraw()return c_a end,mouseHandler=function(c_a,d_a,_aa,aaa) -if( -#bc>0)then -local baa,caa=c_a:getAbsolutePosition(c_a:getAnchorPosition()) -for daa,_ba in pairs(bc)do -if(baa+_ba.x-1 <=_aa)and( -baa+_ba.x-1 +_ba.text:len()+1 >=_aa)and( -caa+_ba.y-1 ==aaa)then -c_a:setValue(_ba) -local aba=c_a:getEventSystem():sendEvent("mouse_click",c_a,"mouse_click",d_a,_aa,aaa)if(aba==false)then return aba end;if(c_a.parent~=nil)then -c_a.parent:setFocusedObject(c_a)end;c_a:updateDraw()return true end end end;return false end,draw=function(c_a) -if( -c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -for aaa,baa in pairs(bc)do -if(baa== -c_a:getValue())then if(a_a=="left")then -c_a.parent:writeText(baa.x+d_a-1,baa.y+_aa-1,__a,_d,ad) -c_a.parent:writeText(baa.x+2 +d_a-1,baa.y+_aa-1,baa.text,cc,dc)end else -c_a.parent:drawBackgroundBox( -baa.x+d_a-1,baa.y+_aa-1,1,1,bd or c_a.bgColor) -c_a.parent:writeText(baa.x+2 +d_a-1,baa.y+_aa-1,baa.text,baa.bgCol,baa.fgCol)end end;return true end end,init=function(c_a) -c_a.parent:addEvent("mouse_click",c_a) -if(_c.init(c_a))then -c_a.bgColor=c_a.parent:getTheme("MenubarBG")c_a.fgColor=c_a.parent:getTheme("MenubarFG") -cc=c_a.parent:getTheme("SelectionBG")dc=c_a.parent:getTheme("SelectionText") -_d=c_a.parent:getTheme("MenubarBG")ad=c_a.parent:getTheme("MenubarText")end end}return setmetatable(b_a,_c)end end -aa["objects"]["Slider"]=function(...)local ab=da("Object") -local bb=da("basaltLogs")local cb=da("utils").getValueFromXML -return -function(db)local _c=ab(db)local ac="Slider" -_c.width=8;_c.height=1;_c:setValue(1)local bc="horizontal"local cc=" "local dc;local _d="\140" -local ad=_c.width;local bd=1;local cd=1 -local function dd(a_a,b_a,c_a,d_a) -local _aa,aaa=a_a:getAbsolutePosition(a_a:getAnchorPosition())local baa,caa=a_a:getSize() -if(bc=="horizontal")then -for _index=0,baa do -if -(_aa+_index==c_a)and(aaa<=d_a)and(aaa+caa>d_a)then -bd=math.min(_index+1,baa- (cd-1))a_a:setValue(ad/baa* (bd))a_a:updateDraw()end end end -if(bc=="vertical")then -for _index=0,caa do -if -(aaa+_index==d_a)and(_aa<=c_a)and(_aa+baa>c_a)then bd=math.min(_index+1,caa- (cd-1)) -a_a:setValue(ad/caa* (bd))a_a:updateDraw()end end end end -local __a={getType=function(a_a)return ac end,setSymbol=function(a_a,b_a)cc=b_a:sub(1,1)a_a:updateDraw()return a_a end,setValuesByXMLData=function(a_a,b_a) -_c.setValuesByXMLData(a_a,b_a) -if(cb("maxValue",b_a)~=nil)then ad=cb("maxValue",b_a)end;if(cb("backgroundSymbol",b_a)~=nil)then -_d=cb("backgroundSymbol",b_a):sub(1,1)end;if(cb("barType",b_a)~=nil)then -bc=cb("barType",b_a):lower()end;if(cb("symbol",b_a)~=nil)then -cc=cb("symbol",b_a):sub(1,1)end;if(cb("symbolSize",b_a)~=nil)then -a_a:setSymbolSize(cb("symbolSize",b_a))end;if(cb("symbolColor",b_a)~=nil)then -dc=colors[cb("symbolColor",b_a)]end;if(cb("index",b_a)~=nil)then -a_a:setIndex(cb("index",b_a))end end,setIndex=function(a_a,b_a) -bd=b_a;if(bd<1)then bd=1 end;local c_a,d_a=a_a:getSize() -bd=math.min(bd,( -bc=="vertical"and d_a or c_a)- (cd-1)) -a_a:setValue(ad/ (bc=="vertical"and d_a or c_a)*bd)a_a:updateDraw()return a_a end,getIndex=function(a_a)return -bd end,setSymbolSize=function(a_a,b_a)cd=tonumber(b_a)or 1 -if(bc=="vertical")then -a_a:setValue(bd-1 * (ad/ (h- (cd- -1)))- (ad/ (h- (cd-1))))elseif(bc=="horizontal")then -a_a:setValue(bd-1 * (ad/ (w- (cd-1)))- (ad/ -(w- (cd-1))))end;a_a:updateDraw()return a_a end,setMaxValue=function(a_a,b_a) -ad=b_a;return a_a end,setBackgroundSymbol=function(a_a,b_a)_d=string.sub(b_a,1,1) -a_a:updateDraw()return a_a end,setSymbolColor=function(a_a,b_a)dc=b_a;a_a:updateDraw() -return a_a end,setBarType=function(a_a,b_a)bc=b_a:lower()a_a:updateDraw() -return a_a end,mouseHandler=function(a_a,b_a,c_a,d_a)if(_c.mouseHandler(a_a,b_a,c_a,d_a))then -dd(a_a,b_a,c_a,d_a)return true end;return false end,dragHandler=function(a_a,b_a,c_a,d_a)if -(_c.dragHandler(a_a,b_a,c_a,d_a))then dd(a_a,b_a,c_a,d_a)return true end -return false end,scrollHandler=function(a_a,b_a,c_a,d_a) -if -(_c.scrollHandler(a_a,b_a,c_a,d_a))then local _aa,aaa=a_a:getSize()bd=bd+b_a;if(bd<1)then bd=1 end -bd=math.min(bd,( -bc=="vertical"and aaa or _aa)- (cd-1)) -a_a:setValue(ad/ (bc=="vertical"and aaa or _aa)*bd)a_a:updateDraw()return true end;return false end,draw=function(a_a) -if -(_c.draw(a_a))then -if(a_a.parent~=nil)then local b_a,c_a=a_a:getAnchorPosition() -local d_a,_aa=a_a:getSize() -if(bc=="horizontal")then -a_a.parent:writeText(b_a,c_a,_d:rep(bd-1),a_a.bgColor,a_a.fgColor) -a_a.parent:writeText(b_a+bd-1,c_a,cc:rep(cd),dc,dc) -a_a.parent:writeText(b_a+bd+cd-1,c_a,_d:rep(d_a- (bd+cd-1)),a_a.bgColor,a_a.fgColor)end -if(bc=="vertical")then -for n=0,_aa-1 do -if(bd==n+1)then -for curIndexOffset=0,math.min(cd-1,_aa)do a_a.parent:writeText(b_a,c_a+n+ -curIndexOffset,cc,dc,dc)end else if(n+1 bd-1 +cd)then -a_a.parent:writeText(b_a,c_a+n,_d,a_a.bgColor,a_a.fgColor)end end end end end end end,init=function(a_a) -a_a.parent:addEvent("mouse_click",a_a)a_a.parent:addEvent("mouse_drag",a_a) -a_a.parent:addEvent("mouse_scroll",a_a) -if(_c.init(a_a))then -a_a.bgColor=a_a.parent:getTheme("SliderBG")a_a.fgColor=a_a.parent:getTheme("SliderText") -dc=a_a.parent:getTheme("SliderSymbolColor")end end}return setmetatable(__a,_c)end end -aa["objects"]["Textfield"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("utils").getValueFromXML;local db=da("basaltLogs") -local _c,ac,bc,cc,dc=string.rep,string.find,string.gmatch,string.sub,string.len -return -function(_d)local ad=ab(_d)local bd="Textfield"local cd,dd,__a,a_a=1,1,1,1;local b_a={" "}local c_a={""}local d_a={""} -local _aa={}local aaa={}local baa,caa,daa,_ba;local aba,bba=colors.lightBlue,colors.black;ad.width=30 -ad.height=12;ad:setZIndex(5)local function cba() -if -(baa~=nil)and(caa~=nil)and(daa~=nil)and(_ba~=nil)then return true end;return false end -local function dba()local ada,bda,cda,dda -if -(cba())then if(baa>caa)then ada,bda=caa,baa else ada,bda=baa,caa end;if(daa>_ba)then -cda,dda=_ba,daa else cda,dda=daa,_ba end end;return ada,bda,cda,dda end;local function _ca()end -local function aca(ada)local bda,cda,dda,__b=dba(ada) -for n=__b,dda,-1 do -if(n==dda)or(n==__b)then local a_b=b_a[n] -local b_b=c_a[n]local c_b=d_a[n] -if(n==dda)and(n==__b)then a_b=a_b:sub(1,bda-1).. -a_b:sub(cda+1,a_b:len())b_b=b_b:sub(1,bda-1).. -b_b:sub(cda+1,b_b:len())c_b=c_b:sub(1,bda-1).. -c_b:sub(cda+1,c_b:len())elseif(n==bda)then -a_b=a_b:sub(1,bda)b_b=b_b:sub(1,bda)c_b=c_b:sub(1,bda)elseif(n==dda)then -a_b=a_b:sub(cda,a_b:len())b_b=b_b:sub(cda,b_b:len()) -c_b=c_b:sub(cda,c_b:len())end;b_a[n]=a_b;c_a[n]=b_b;d_a[n]=c_b else table.remove(b_a,n) -table.remove(c_a,n)table.remove(d_a,n)end end;__a,a_a=baa,daa;baa,caa,daa,_ba=nil,nil,nil,nil;return ada end -local function bca(ada,bda)local cda={} -if(ada:len()>0)then -for dda in bc(ada,bda)do local __b,a_b=ac(ada,dda) -if -(__b~=nil)and(a_b~=nil)then table.insert(cda,__b)table.insert(cda,a_b) -local b_b=cc(ada,1,(__b-1))local c_b=cc(ada,a_b+1,ada:len())ada=b_b.. (":"):rep(dda:len()).. -c_b end end end;return cda end -local function cca(ada,bda)bda=bda or a_a -local cda=bb[ada.fgColor]:rep(d_a[bda]:len()) -local dda=bb[ada.bgColor]:rep(c_a[bda]:len()) -for __b,a_b in pairs(aaa)do local b_b=bca(b_a[bda],a_b[1]) -if(#b_b>0)then -for x=1,#b_b/2 do -local c_b=x*2 -1;if(a_b[2]~=nil)then -cda=cda:sub(1,b_b[c_b]-1)..bb[a_b[2]]:rep(b_b[c_b+1]- ( -b_b[c_b]-1)).. -cda:sub(b_b[c_b+1]+1,cda:len())end;if -(a_b[3]~=nil)then -dda=dda:sub(1,b_b[c_b]-1).. - -bb[a_b[3]]:rep(b_b[c_b+1]- (b_b[c_b]-1))..dda:sub(b_b[c_b+1]+1,dda:len())end end end end -for __b,a_b in pairs(_aa)do -for b_b,c_b in pairs(a_b)do local d_b=bca(b_a[bda],c_b) -if(#d_b>0)then for x=1,#d_b/2 do -local _ab=x*2 -1 -cda=cda:sub(1,d_b[_ab]-1).. - -bb[__b]:rep(d_b[_ab+1]- (d_b[_ab]-1))..cda:sub(d_b[_ab+1]+1,cda:len())end end end end;d_a[bda]=cda;c_a[bda]=dda;ada:updateDraw()end;local function dca(ada)for n=1,#b_a do cca(ada,n)end end -local _da={getType=function(ada)return bd end,setBackground=function(ada,bda) -ad.setBackground(ada,bda)dca(ada)return ada end,setForeground=function(ada,bda) -ad.setForeground(ada,bda)dca(ada)return ada end,setValuesByXMLData=function(ada,bda) -ad.setValuesByXMLData(ada,bda) -if(bda["lines"]~=nil)then local cda=bda["lines"]["line"]if -(cda.properties~=nil)then cda={cda}end;for dda,__b in pairs(cda)do -ada:addLine(__b:value())end end -if(bda["keywords"]~=nil)then -for cda,dda in pairs(bda["keywords"])do -if(colors[cda]~=nil)then -local __b=dda;if(__b.properties~=nil)then __b={__b}end;local a_b={} -for b_b,c_b in pairs(__b)do -local d_b=c_b["keyword"]if(c_b["keyword"].properties~=nil)then -d_b={c_b["keyword"]}end;for _ab,aab in pairs(d_b)do -table.insert(a_b,aab:value())end end;ada:addKeywords(colors[cda],a_b)end end end -if(bda["rules"]~=nil)then -if(bda["rules"]["rule"]~=nil)then -local cda=bda["rules"]["rule"]if(bda["rules"]["rule"].properties~=nil)then -cda={bda["rules"]["rule"]}end -for dda,__b in pairs(cda)do if(cb("pattern",__b)~=nil)then -ada:addRule(cb("pattern",__b),colors[cb("fg",__b)],colors[cb("bg",__b)])end end end end end,getLines=function(ada)return -b_a end,getLine=function(ada,bda)return b_a[bda]end,editLine=function(ada,bda,cda) -b_a[bda]=cda or b_a[bda]cca(ada,bda)ada:updateDraw()return ada end,clear=function(ada) -b_a={" "}c_a={""}d_a={""}baa,caa,daa,_ba=nil,nil,nil,nil;cd,dd,__a,a_a=1,1,1,1 -ada:updateDraw()return ada end,addLine=function(ada,bda,cda) -if -(bda~=nil)then -if(#b_a==1)and(b_a[1]=="")then b_a[1]=bda -c_a[1]=bb[ada.bgColor]:rep(bda:len())d_a[1]=bb[ada.fgColor]:rep(bda:len()) -cca(ada,1)return ada end -if(cda~=nil)then table.insert(b_a,cda,bda) -table.insert(c_a,cda,bb[ada.bgColor]:rep(bda:len())) -table.insert(d_a,cda,bb[ada.fgColor]:rep(bda:len()))else table.insert(b_a,bda) -table.insert(c_a,bb[ada.bgColor]:rep(bda:len())) -table.insert(d_a,bb[ada.fgColor]:rep(bda:len()))end end;cca(ada,cda or#b_a)ada:updateDraw()return ada end,addKeywords=function(ada,bda,cda)if( -_aa[bda]==nil)then _aa[bda]={}end;for dda,__b in pairs(cda)do -table.insert(_aa[bda],__b)end;ada:updateDraw()return ada end,addRule=function(ada,bda,cda,dda) -table.insert(aaa,{bda,cda,dda})ada:updateDraw()return ada end,editRule=function(ada,bda,cda,dda)for __b,a_b in -pairs(aaa)do -if(a_b[1]==bda)then aaa[__b][2]=cda;aaa[__b][3]=dda end end;ada:updateDraw()return ada end,removeRule=function(ada,bda) -for cda,dda in -pairs(aaa)do if(dda[1]==bda)then table.remove(aaa,cda)end end;ada:updateDraw()return ada end,setKeywords=function(ada,bda,cda) -_aa[bda]=cda;ada:updateDraw()return ada end,removeLine=function(ada,bda) -if(#b_a>1)then table.remove(b_a, -bda or#b_a) -table.remove(c_a,bda or#c_a)table.remove(d_a,bda or#d_a)else b_a={" "}c_a={""}d_a={""}end;ada:updateDraw()return ada end,getTextCursor=function(ada)return -__a,a_a end,getFocusHandler=function(ada)ad.getFocusHandler(ada) -if(ada.parent~=nil)then -local bda,cda=ada:getAnchorPosition()if(ada.parent~=nil)then -ada.parent:setCursor(true,bda+__a-dd,cda+a_a-cd,ada.fgColor)end end end,loseFocusHandler=function(ada) -ad.loseFocusHandler(ada) -if(ada.parent~=nil)then ada.parent:setCursor(false)end end,keyHandler=function(ada,bda) -if -(ad.keyHandler(ada,event,bda))then local cda,dda=ada:getAnchorPosition()local __b,a_b=ada:getSize() -if(bda== -keys.backspace)then -if(b_a[a_a]=="")then -if(a_a>1)then table.remove(b_a,a_a) -table.remove(d_a,a_a)table.remove(c_a,a_a) -__a=b_a[a_a-1]:len()+1;dd=__a-__b+1;if(dd<1)then dd=1 end;a_a=a_a-1 end elseif(__a<=1)then -if(a_a>1)then __a=b_a[a_a-1]:len()+1 -dd=__a-__b+1;if(dd<1)then dd=1 end;b_a[a_a-1]=b_a[a_a-1]..b_a[a_a]d_a[ -a_a-1]=d_a[a_a-1]..d_a[a_a]c_a[a_a-1]=c_a[a_a-1].. -c_a[a_a]table.remove(b_a,a_a) -table.remove(d_a,a_a)table.remove(c_a,a_a)a_a=a_a-1 end else b_a[a_a]=b_a[a_a]:sub(1,__a-2).. -b_a[a_a]:sub(__a,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-2)..d_a[a_a]:sub(__a,d_a[a_a]:len())c_a[a_a]=c_a[a_a]:sub(1,__a-2).. -c_a[a_a]:sub(__a,c_a[a_a]:len())if(__a>1)then -__a=__a-1 end;if(dd>1)then if(__ab_a[a_a]:len())then -if( -b_a[a_a+1]~=nil)then b_a[a_a]=b_a[a_a]..b_a[a_a+1] -table.remove(b_a,a_a+1)table.remove(c_a,a_a+1)table.remove(d_a,a_a+1)end else b_a[a_a]=b_a[a_a]:sub(1,__a-1).. -b_a[a_a]:sub(__a+1,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-1)..d_a[a_a]:sub(__a+1,d_a[a_a]:len())c_a[a_a]=c_a[a_a]:sub(1,__a-1).. -c_a[a_a]:sub(__a+1,c_a[a_a]:len())end end;cca(ada)end -if(bda==keys.enter)then -table.insert(b_a,a_a+1,b_a[a_a]:sub(__a,b_a[a_a]:len())) -table.insert(d_a,a_a+1,d_a[a_a]:sub(__a,d_a[a_a]:len())) -table.insert(c_a,a_a+1,c_a[a_a]:sub(__a,c_a[a_a]:len()))b_a[a_a]=b_a[a_a]:sub(1,__a-1) -d_a[a_a]=d_a[a_a]:sub(1,__a-1)c_a[a_a]=c_a[a_a]:sub(1,__a-1)a_a=a_a+1;__a=1;dd=1;if(a_a-cd>= -a_b)then cd=cd+1 end;ada:setValue("")end -if(bda==keys.up)then -if(a_a>1)then a_a=a_a-1;if(__a>b_a[a_a]:len()+1)then __a= -b_a[a_a]:len()+1 end -if(dd>1)then if(__a1)then if(a_ab_a[a_a]:len()+1)then __a=b_a[a_a]:len()+1 end -if(dd>1)then if -(__a=cd+a_b)then cd=cd+1 end end end -if(bda==keys.right)then __a=__a+1 -if(a_a<#b_a)then if -(__a>b_a[a_a]:len()+1)then __a=1;a_a=a_a+1 end elseif(__a>b_a[a_a]:len())then __a= -b_a[a_a]:len()+1 end;if(__a<1)then __a=1 end -if(__a=__b+dd)then dd=__a-__b+1 end;if(dd<1)then dd=1 end end -if(bda==keys.left)then __a=__a-1;if(__a>=1)then -if(__a=__b+dd)then dd=__a end end -if(a_a>1)then if(__a<1)then a_a=a_a-1 -__a=b_a[a_a]:len()+1;dd=__a-__b+1 end end;if(__a<1)then __a=1 end;if(dd<1)then dd=1 end end -if not -( (cda+__a-dd>=cda and cda+__a-dd=dda and dda+a_a-cd -ada:getX()+__b-1)then b_b=ada:getX()+__b-1 end -local c_b=(a_a-cd=__b+dd)then dd=dd+1 end;cca(ada) -ada:setValue("") -if not -( (cda+__a-dd>=cda and cda+__a-dd=dda and dda+a_a-cd -ada:getX()+__b-1)then b_b=ada:getX()+__b-1 end -local c_b=(a_a-cdb_b+cda- (__b+1)+dd)and(b_bb_a[a_a]:len())then __a= -b_a[a_a]:len()+1;caa=__a end;if(__a#b_a- (_ab-1))then cd=#b_a- (_ab-1)end;if -(cd<1)then cd=1 end -if - -(__b+__a-dd>=__b and __b+__a-dd<__b+d_b)and(c_b+a_a-cd>=c_b and c_b+a_a-cd -b_a[a_a]:len())then __a=b_a[a_a]:len()+1;baa=__a end;if(__ab_a[_ba]:len())then caa= -b_a[_ba]:len()+1 end;if(baa==caa)and(daa==_ba)then baa,caa,daa,_ba= -nil,nil,nil,nil end -ada:updateDraw()end;return true end end,eventHandler=function(ada,bda,cda,dda,__b,a_b) -if -(ad.eventHandler(ada,bda,cda,dda,__b,a_b))then -if(bda=="paste")then -if(ada:isFocused())then local b_b,c_b=ada:getSize()b_a[a_a]=b_a[a_a]:sub(1, -__a-1).. -cda..b_a[a_a]:sub(__a,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-1)..bb[ada.fgColor]:rep(cda:len()).. -d_a[a_a]:sub(__a,d_a[a_a]:len()) -c_a[a_a]=c_a[a_a]:sub(1,__a-1).. - -bb[ada.bgColor]:rep(cda:len())..c_a[a_a]:sub(__a,c_a[a_a]:len())__a=__a+cda:len() -if(__a>=b_b+dd)then dd=(__a+1)-b_b end;local d_b,_ab=ada:getAnchorPosition() -ada.parent:setCursor(true,d_b+__a-dd,_ab+ -a_a-cd,ada.fgColor)cca(ada)ada:updateDraw()end end end end,draw=function(ada) -if -(ad.draw(ada))then -if(ada.parent~=nil)then local bda,cda=ada:getAnchorPosition() -local dda,__b=ada:getSize() -for n=1,__b do local a_b=""local b_b=""local c_b="" -if(b_a[n+cd-1]~=nil)then a_b=b_a[n+cd-1]c_b=d_a[ -n+cd-1]b_b=c_a[n+cd-1]end;a_b=a_b:sub(dd,dda+dd-1) -b_b=b_b:sub(dd,dda+dd-1)c_b=c_b:sub(dd,dda+dd-1)local d_b=dda-a_b:len()if(d_b<0)then -d_b=0 end;a_b=a_b.._c(ada.bgSymbol,d_b)b_b=b_b.. -_c(bb[ada.bgColor],d_b) -c_b=c_b.._c(bb[ada.fgColor],d_b)ada.parent:setText(bda,cda+n-1,a_b)ada.parent:setBG(bda, -cda+n-1,b_b) -ada.parent:setFG(bda,cda+n-1,c_b)end -if -(baa~=nil)and(caa~=nil)and(daa~=nil)and(_ba~=nil)then local a_b,b_b,c_b,d_b=dba(ada) -for n=c_b,d_b do local _ab=b_a[n]:len()local aab=0 -if -(n==c_b)and(n==d_b)then aab=a_b-1;_ab=_ab- (a_b-1)- (_ab-b_b)elseif(n==d_b)then -_ab=_ab- (_ab-b_b)elseif(n==c_b)then _ab=_ab- (a_b-1)aab=a_b-1 end -ada.parent:setBG(bda+aab,cda+n-1,_c(bb[aba],_ab)) -ada.parent:setFG(bda+aab,cda+n-1,_c(bb[bba],_ab))end end -if(ada:isFocused())then local a_b,b_b=ada:getAnchorPosition()end end end end,init=function(ada) -ada.parent:addEvent("mouse_click",ada)ada.parent:addEvent("mouse_up",ada) -ada.parent:addEvent("mouse_scroll",ada)ada.parent:addEvent("mouse_drag",ada) -ada.parent:addEvent("key",ada)ada.parent:addEvent("char",ada) -ada.parent:addEvent("other_event",ada) -if(ad.init(ada))then -ada.bgColor=ada.parent:getTheme("TextfieldBG")ada.fgColor=ada.parent:getTheme("TextfieldText")end end}return setmetatable(_da,ad)end end -aa["objects"]["Thread"]=function(...)local ab=da("utils").getValueFromXML -return -function(bb)local cb -local db="Thread"local _c;local ac;local bc=false;local cc -local dc=function(_d,ad) -if(ad:sub(1,1)=="#")then -local bd=_d:getBaseFrame():getDeepObject(ad:sub(2,ad:len())) -if(bd~=nil)and(bd.internalObjetCall~=nil)then return(function() -bd:internalObjetCall()end)end else return _d:getBaseFrame():getVariable(ad)end;return _d end -cb={name=bb,getType=function(_d)return db end,getZIndex=function(_d)return 1 end,getName=function(_d)return _d.name end,getBaseFrame=function(_d)if -(_d.parent~=nil)then return _d.parent:getBaseFrame()end -return _d end,setValuesByXMLData=function(_d,ad)local bd;if(ab("thread",ad)~=nil)then -bd=dc(_d,ab("thread",ad))end -if(ab("start",ad)~=nil)then if -(ab("start",ad))and(bd~=nil)then _d:start(bd)end end;return _d end,start=function(_d,ad) -if( -ad==nil)then error("Function provided to thread is nil")end;_c=ad;ac=coroutine.create(_c)bc=true;cc=nil -local bd,cd=coroutine.resume(ac)cc=cd;if not(bd)then if(cd~="Terminated")then -error("Thread Error Occurred - "..cd)end end -_d.parent:addEvent("mouse_click",_d)_d.parent:addEvent("mouse_up",_d) -_d.parent:addEvent("mouse_scroll",_d)_d.parent:addEvent("mouse_drag",_d) -_d.parent:addEvent("key",_d)_d.parent:addEvent("key_up",_d) -_d.parent:addEvent("char",_d)_d.parent:addEvent("other_event",_d)return _d end,getStatus=function(_d,ad)if( -ac~=nil)then return coroutine.status(ac)end;return nil end,stop=function(_d,ad) -bc=false;_d.parent:removeEvent("mouse_click",_d) -_d.parent:removeEvent("mouse_up",_d)_d.parent:removeEvent("mouse_scroll",_d) -_d.parent:removeEvent("mouse_drag",_d)_d.parent:removeEvent("key",_d) -_d.parent:removeEvent("key_up",_d)_d.parent:removeEvent("char",_d) -_d.parent:removeEvent("other_event",_d)return _d end,mouseHandler=function(_d,...) -_d:eventHandler("mouse_click",...)end,mouseUpHandler=function(_d,...)_d:eventHandler("mouse_up",...)end,mouseScrollHandler=function(_d,...) -_d:eventHandler("mouse_scroll",...)end,mouseDragHandler=function(_d,...) -_d:eventHandler("mouse_drag",...)end,mouseMoveHandler=function(_d,...) -_d:eventHandler("mouse_move",...)end,keyHandler=function(_d,...)_d:eventHandler("key",...)end,keyUpHandler=function(_d,...) -_d:eventHandler("key_up",...)end,charHandler=function(_d,...)_d:eventHandler("char",...)end,eventHandler=function(_d,ad,...) -if -(bc)then -if(coroutine.status(ac)=="suspended")then if(cc~=nil)then if(ad~=cc)then return end;cc= -nil end -local bd,cd=coroutine.resume(ac,ad,...)cc=cd;if not(bd)then if(cd~="Terminated")then -error("Thread Error Occurred - "..cd)end end else -_d:stop()end end end}cb.__index=cb;return cb end end -aa["objects"]["Timer"]=function(...)local ab=da("basaltEvent") -local bb=da("utils").getValueFromXML -return -function(cb)local db="Timer"local _c=0;local ac=0;local bc=0;local cc;local dc=ab()local _d=false -local ad=function(cd,dd,__a) -local a_a=function(b_a) -if(b_a:sub(1,1)=="#")then -local c_a=cd:getBaseFrame():getDeepObject(b_a:sub(2,b_a:len())) -if(c_a~=nil)and(c_a.internalObjetCall~=nil)then dd(cd,function() -c_a:internalObjetCall()end)end else -dd(cd,cd:getBaseFrame():getVariable(b_a))end end;if(type(__a)=="string")then a_a(__a)elseif(type(__a)=="table")then -for b_a,c_a in pairs(__a)do a_a(c_a)end end;return cd end -local bd={name=cb,getType=function(cd)return db end,setValuesByXMLData=function(cd,dd) -if(bb("time",dd)~=nil)then _c=bb("time",dd)end;if(bb("repeat",dd)~=nil)then ac=bb("repeat",dd)end -if( -bb("start",dd)~=nil)then if(bb("start",dd))then cd:start()end end;if(bb("onCall",dd)~=nil)then -ad(cd,cd.onCall,bb("onCall",dd))end;return cd end,getBaseFrame=function(cd) -if( -cd.parent~=nil)then return cd.parent:getBaseFrame()end;return cd end,getZIndex=function(cd)return 1 end,getName=function(cd) -return cd.name end,setTime=function(cd,dd,__a)_c=dd or 0;ac=__a or 1;return cd end,start=function(cd)if(_d)then -os.cancelTimer(cc)end;bc=ac;cc=os.startTimer(_c)_d=true -cd.parent:addEvent("other_event",cd)return cd end,isActive=function(cd)return _d end,cancel=function(cd)if( -cc~=nil)then os.cancelTimer(cc)end;_d=false -cd.parent:removeEvent("other_event",cd)return cd end,onCall=function(cd,dd) -dc:registerEvent("timed_event",dd)return cd end,eventHandler=function(cd,dd,__a) -if -dd=="timer"and __a==cc and _d then dc:sendEvent("timed_event",cd) -if(bc>=1)then bc=bc-1;if(bc>=1)then -cc=os.startTimer(_c)end elseif(bc==-1)then cc=os.startTimer(_c)end end end}bd.__index=bd;return bd end end -aa["objects"]["Switch"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Switch"db.width=2;db.height=1 -db.bgColor=colors.lightGray;db.fgColor=colors.gray;db:setValue(false)db:setZIndex(5) -local ac=colors.black;local bc=colors.red;local cc=colors.green -local dc={getType=function(_d)return _c end,setSymbolColor=function(_d,ad)ac=ad -_d:updateDraw()return _d end,setActiveBackground=function(_d,ad)cc=ad;_d:updateDraw()return _d end,setInactiveBackground=function(_d,ad) -bc=ad;_d:updateDraw()return _d end,setValuesByXMLData=function(_d,ad) -db.setValuesByXMLData(_d,ad)if(bb("inactiveBG",ad)~=nil)then -bc=colors[bb("inactiveBG",ad)]end;if(bb("activeBG",ad)~=nil)then -cc=colors[bb("activeBG",ad)]end;if(bb("symbolColor",ad)~=nil)then -ac=colors[bb("symbolColor",ad)]end end,mouseHandler=function(_d,ad,bd,cd) -if -(db.mouseHandler(_d,ad,bd,cd))then -local dd,__a=_d:getAbsolutePosition(_d:getAnchorPosition())_d:setValue(not _d:getValue()) -_d:updateDraw()return true end end,draw=function(_d) -if -(db.draw(_d))then -if(_d.parent~=nil)then local ad,bd=_d:getAnchorPosition() -local cd,dd=_d:getSize() -_d.parent:drawBackgroundBox(ad,bd,cd,dd,_d.bgColor) -if(_d:getValue())then -_d.parent:drawBackgroundBox(ad,bd,1,dd,cc)_d.parent:drawBackgroundBox(ad+1,bd,1,dd,ac)else -_d.parent:drawBackgroundBox(ad,bd,1,dd,ac)_d.parent:drawBackgroundBox(ad+1,bd,1,dd,bc)end end end end,init=function(_d) -_d.parent:addEvent("mouse_click",_d) -if(db.init(_d))then _d.bgColor=_d.parent:getTheme("SwitchBG") -_d.fgColor=_d.parent:getTheme("SwitchText")ac=_d.parent:getTheme("SwitchBGSymbol") -bc=_d.parent:getTheme("SwitchInactive")cc=_d.parent:getTheme("SwitchActive")end end}return setmetatable(dc,db)end end;aa["libraries"]={} -aa["libraries"]["basaltEvent"]=function(...) -return -function()local ab={}local bb={} -local cb={registerEvent=function(db,_c,ac)if( -ab[_c]==nil)then ab[_c]={}bb[_c]=1 end -ab[_c][bb[_c]]=ac;bb[_c]=bb[_c]+1;return bb[_c]-1 end,removeEvent=function(db,_c,ac)ab[_c][ac[_c]]= -nil end,sendEvent=function(db,_c,...)local ac -if(ab[_c]~=nil)then for bc,cc in pairs(ab[_c])do -local dc=cc(...)if(dc==false)then ac=dc end end end;return ac end}cb.__index=cb;return cb end end -aa["libraries"]["basaltLogs"]=function(...)local ab=""local bb="basaltLog.txt"local cb="Debug" -fs.delete( -ab~=""and ab.."/"..bb or bb) -local db={__call=function(_c,ac,bc)if(ac==nil)then return end -local cc=ab~=""and ab.."/"..bb or bb -local dc=fs.open(cc,fs.exists(cc)and"a"or"w") -dc.writeLine("[Basalt][".. (bc and bc or cb).."]: "..tostring(ac))dc.close()end}return setmetatable({},db)end -aa["libraries"]["basaltMon"]=function(...) -local ab={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local bb,cb,db,_c=type,string.len,string.rep,string.sub -return -function(ac)local bc={} -for _ba,aba in pairs(ac)do -bc[_ba]={} -for bba,cba in pairs(aba)do local dba=peripheral.wrap(cba)if(dba==nil)then -error("Unable to find monitor "..cba)end;bc[_ba][bba]=dba -bc[_ba][bba].name=cba end end;local cc,dc,_d,ad,bd,cd,dd,__a=1,1,1,1,0,0,0,0;local a_a,b_a=false,1 -local c_a,d_a=colors.white,colors.black -local function _aa()local _ba,aba=0,0 -for bba,cba in pairs(bc)do local dba,_ca=0,0 -for aca,bca in pairs(cba)do local cca,dca=bca.getSize() -dba=dba+cca;_ca=dca>_ca and dca or _ca end;_ba=_ba>dba and _ba or dba;aba=aba+_ca end;dd,__a=_ba,aba end;_aa() -local function aaa()local _ba=0;local aba,bba=0,0 -for cba,dba in pairs(bc)do local _ca=0;local aca=0 -for bca,cca in pairs(dba)do -local dca,_da=cca.getSize()if(cc-_ca>=1)and(cc-_ca<=dca)then aba=bca end;cca.setCursorPos( -cc-_ca,dc-_ba)_ca=_ca+dca -if(aca<_da)then aca=_da end end;if(dc-_ba>=1)and(dc-_ba<=aca)then bba=cba end -_ba=_ba+aca end;_d,ad=aba,bba end;aaa() -local function baa(_ba,...)local aba={...}return -function()for bba,cba in pairs(bc)do for dba,_ca in pairs(cba)do -_ca[_ba](table.unpack(aba))end end end end -local function caa()baa("setCursorBlink",false)() -if not(a_a)then return end;if(bc[ad]==nil)then return end;local _ba=bc[ad][_d] -if(_ba==nil)then return end;_ba.setCursorBlink(a_a)end -local function daa(_ba,aba,bba)if(bc[ad]==nil)then return end;local cba=bc[ad][_d] -if(cba==nil)then return end;cba.blit(_ba,aba,bba)local dba,_ca=cba.getSize() -if -(cb(_ba)+cc>dba)then local aca=bc[ad][_d+1]if(aca~=nil)then aca.blit(_ba,aba,bba)_d=_d+1;cc=cc+ -cb(_ba)end end;aaa()end -return -{clear=baa("clear"),setCursorBlink=function(_ba)a_a=_ba;caa()end,getCursorBlink=function()return a_a end,getCursorPos=function()return cc,dc end,setCursorPos=function(_ba,aba) -cc,dc=_ba,aba;aaa()caa()end,setTextScale=function(_ba) -baa("setTextScale",_ba)()_aa()aaa()b_a=_ba end,getTextScale=function()return b_a end,blit=function(_ba,aba,bba) -daa(_ba,aba,bba)end,write=function(_ba)_ba=tostring(_ba)local aba=cb(_ba) -daa(_ba,db(ab[c_a],aba),db(ab[d_a],aba))end,getSize=function()return dd,__a end,setBackgroundColor=function(_ba) -baa("setBackgroundColor",_ba)()d_a=_ba end,setTextColor=function(_ba) -baa("setTextColor",_ba)()c_a=_ba end,calculateClick=function(_ba,aba,bba)local cba=0 -for dba,_ca in pairs(bc)do local aca=0;local bca=0 -for cca,dca in pairs(_ca)do -local _da,ada=dca.getSize()if(dca.name==_ba)then return aba+aca,bba+cba end -aca=aca+_da;if(ada>bca)then bca=ada end end;cba=cba+bca end;return aba,bba end}end end -aa["libraries"]["basaltDraw"]=function(...)local ab=da("tHex") -local bb,cb=string.sub,string.rep -return -function(db)local _c=db or term.current()local ac;local bc,cc=_c.getSize()local dc={} -local _d={}local ad={}local bd={}local cd={}local dd={}local __a;local a_a={} -local function b_a()__a=cb(" ",bc)for n=0,15 do local daa=2 ^n -local _ba=ab[daa]a_a[daa]=cb(_ba,bc)end end;b_a() -local function c_a()b_a()local daa=__a;local _ba=a_a[colors.white] -local aba=a_a[colors.black] -for currentY=1,cc do -dc[currentY]=bb(dc[currentY]==nil and daa or dc[currentY]..daa:sub(1,bc- -dc[currentY]:len()),1,bc) -ad[currentY]=bb(ad[currentY]==nil and _ba or ad[currentY].._ba:sub(1,bc- -ad[currentY]:len()),1,bc) -_d[currentY]=bb(_d[currentY]==nil and aba or _d[currentY]..aba:sub(1,bc- -_d[currentY]:len()),1,bc)end end;c_a() -local function d_a(daa,_ba,aba) -if(_ba>=1)and(_ba<=cc)then -if -(daa+aba:len()>0)and(daa<=bc)then local bba=dc[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then local _ca=1 -daa+1 -local aca=bc-daa+1;aba=bb(aba,_ca,aca)elseif(dba>bc)then local _ca=bc-daa+1;aba=bb(aba,1,_ca)end -if(daa>1)then local _ca=daa-1;cba=bb(bba,1,_ca)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if(daa+aba:len()>0)and(daa<=bc)then -local bba=_d[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then -aba=bb(aba,1 -daa+1,bc-daa+1)elseif(dba>bc)then aba=bb(aba,1,bc-daa+1)end -if(daa>1)then cba=bb(bba,1,daa-1)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if(daa+aba:len()>0)and(daa<=bc)then -local bba=ad[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then local _ca=1 -daa+1;local aca=bc-daa+1 -aba=bb(aba,_ca,aca)elseif(dba>bc)then local _ca=bc-daa+1;aba=bb(aba,1,_ca)end -if(daa>1)then local _ca=daa-1;cba=bb(bba,1,_ca)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if( -daa+aba:len()>0)and(daa<=bc)then local dba=dc[_ba]local _ca=ad[_ba]local aca=_d[_ba] -local bca,cca,dca;local _da=daa+#aba-1 -if(daa<1)then local ada=1 -daa+1;local bda=bc-daa+1 -aba=bb(aba,ada,bda)bba=bb(bba,ada,bda)cba=bb(cba,ada,bda)elseif(_da>bc)then local ada=bc-daa+1 -aba=bb(aba,1,ada)bba=bb(bba,1,ada)cba=bb(cba,1,ada)end -if(daa>1)then local ada=daa-1;bca=bb(dba,1,ada)..aba -cca=bb(_ca,1,ada)..bba;dca=bb(aca,1,ada)..cba else bca=aba;cca=bba;dca=cba end -if _daac)then ac=#cc[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local a_a=function(d_a,_aa,aaa)ad=_aa or ad;bd=aaa or bd -if(_d[bd]==nil)then _d[bd]=bb("f",ad-1)..d_a.. -bb("f",ac- (#d_a+ad))else _d[bd]= -ab(_d[bd],1,ad-1).. -bb("f",ad-#_d[bd])..d_a..ab(_d[bd],ad+#d_a,ac)end;if(#_d[bd]>ac)then ac=#_d[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local b_a=function(d_a,_aa,aaa)ad=_aa or ad;bd=aaa or bd -if(dc[bd]==nil)then dc[bd]=bb("0",ad-1)..d_a.. -bb("0",ac- (#d_a+ad))else dc[bd]= -ab(dc[bd],1,ad-1).. -bb("0",ad-#dc[bd])..d_a..ab(dc[bd],ad+#d_a,ac)end;if(#dc[bd]>ac)then ac=#dc[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local function c_a(d_a)cd={}cc,dc,_d={},{},{} -for _aa,aaa in pairs(db)do if(type(_aa)=="string")then cd[_aa]=aaa else -cc[_aa],dc[_aa],_d[_aa]=aaa[1],aaa[2],aaa[3]end end;_c.updateSize(ac,bc)end;if(db~=nil)then ac=#db[1][1]bc=#db;c_a(db)end -return -{recalculateSize=dd,setFrame=c_a,getFrame=function()local d_a={} -for _aa,aaa in -pairs(cc)do table.insert(d_a,{aaa,dc[_aa],_d[_aa]})end;for _aa,aaa in pairs(cd)do d_a[_aa]=aaa end;return d_a,ac,bc end,getImage=function() -local d_a={}for _aa,aaa in pairs(cc)do -table.insert(d_a,{aaa,dc[_aa],_d[_aa]})end;return d_a end,setFrameData=function(d_a,_aa) -if( -_aa~=nil)then cd[d_a]=_aa else if(type(d_a)=="table")then cd=d_a end end end,setFrameImage=function(d_a) -for _aa,aaa in pairs(d_a.t)do -cc[_aa]=d_a.t[_aa]dc[_aa]=d_a.fg[_aa]_d[_aa]=d_a.bg[_aa]end end,getFrameImage=function() -return{t=cc,fg=dc,bg=_d}end,getFrameData=function(d_a)return(d_a~=nil and cd[d_a]or cd)end,blit=function(d_a,_aa,aaa,baa,caa) -__a(d_a,baa,caa)b_a(_aa,baa,caa)a_a(aaa,baa,caa)end,text=__a,fg=b_a,bg=a_a,getSize=function()return -ac,bc end,setSize=function(d_a,_aa)local aaa,baa,caa={},{},{} -for _y=1,_aa do -if(cc[_y]~=nil)then aaa[_y]=ab(cc[_y],1,d_a)..bb(" ", -d_a-ac)else aaa[_y]=bb(" ",d_a)end;if(dc[_y]~=nil)then -baa[_y]=ab(dc[_y],1,d_a)..bb("0",d_a-ac)else baa[_y]=bb("0",d_a)end;if -(_d[_y]~=nil)then caa[_y]=ab(_d[_y],1,d_a)..bb("f",d_a-ac)else -caa[_y]=bb("f",d_a)end end;cc,dc,_d=aaa,baa,caa;ac,bc=d_a,_aa end}end -return -function(db)local _c={} -local ac={creator="Bimg Library by NyoriE",date=os.date("!%Y-%m-%dT%TZ")}local bc,cc=0,0;local dc={} -local function _d(cd,dd)cd=cd or#_c+1 -table.insert(_c,cd,cb(dd,dc))if(dd==nil)then _c[cd].setSize(bc,cc)end end;local function ad(cd)table.remove(_c,cd or#_c)end -local function bd(cd,dd) -local __a=_c[cd] -if(__a~=nil)then local a_a=cd+dd;if(a_a>=1)and(a_a<=#_c)then table.remove(_c,cd) -table.insert(_c,a_a,__a)end end end -dc={updateSize=function(cd,dd,__a)local a_a=__a==true and true or false -if(cd>bc)then a_a=true;bc=cd end;if(dd>cc)then a_a=true;cc=dd end -if(a_a)then for b_a,c_a in pairs(_c)do c_a.setSize(bc,cc) -c_a.recalculateSize()end end end,text=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.text(dd,__a,a_a)end,fg=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.fg(dd,__a,a_a)end,bg=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.bg(dd,__a,a_a)end,blit=function(cd,dd,__a,a_a,b_a,c_a) -local d_a=_c[cd]if(d_a==nil)then d_a=_d(cd)end;d_a.blit(dd,__a,a_a,b_a,c_a)end,setSize=function(cd,dd) -bc=cd;cc=dd;for __a,a_a in pairs(_c)do a_a.setSize(cd,dd)end end,getFrame=function(cd)if( -_c[cd]~=nil)then return _c[cd].getFrame()end end,getFrameObjects=function()return -_c end,getFrames=function()local cd={}for dd,__a in pairs(_c)do local a_a=__a.getFrame() -table.insert(cd,a_a)end;return cd end,getFrameObject=function(cd)return -_c[cd]end,addFrame=function(cd)local dd=cb()if(#_c<=1)then -if(ac.animated==nil)then ac.animated=true end -if(ac.secondsPerFrame==nil)then ac.secondsPerFrame=0.2 end end;_d(cd)return dd end,removeFrame=function(cd) -ad(cd) -if(#_c<=1)then if(ac.animated==nil)then ac.animated=true end;if -(ac.secondsPerFrame==nil)then ac.secondsPerFrame=0.2 end end end,moveFrame=bd,setFrameData=function(cd,dd,__a) -if( -_c[cd]~=nil)then _c[cd].setFrameData(dd,__a)end end,getFrameData=function(cd,dd)return _c[cd]~=nil and -_c[cd].getFrameData(dd)end,getSize=function()return -bc,cc end,setAnimation=function(cd)ac.animation=cd end,setMetadata=function(cd,dd)if(dd~=nil)then ac[cd]=dd else if( -type(cd)=="table")then ac=cd end end end,getMetadata=function(cd)return -cd~=nil and ac[cd]or ac end,createBimg=function() -local cd={} -for dd,__a in pairs(_c)do local a_a=__a.getFrame()table.insert(cd,a_a)end;for dd,__a in pairs(ac)do cd[dd]=__a end;cd.width=bc;cd.height=cc;return cd end} -if(db~=nil)then for cd,dd in pairs(db)do -if(type(cd)=="string")then ac[cd]=dd else _d(cd,dd)end end -if -(ac.width==nil)or(ac.height==nil)then for cd,dd in pairs(_c)do local __a,a_a=dd.getSize()if(__a>bc)then __a=bc end -if(a_a>cc)then a_a=cc end end -dc.updateSize(bc,cc,true)end else _d(1)end;return dc end end -aa["libraries"]["images"]=function(...) -local ab,bb,cb=string.sub,math.floor,string.rep -local function db(bd)local cd={{}}local dd=fs.open(bd,"r") -if(dd~=nil)then for __a in dd.readLine do -table.insert(cd[1],{cb(" ",#__a),cb(" ", -#__a),__a})end;dd.close()return cd end end -local function _c(bd)return paintutils.loadImage(bd),"nfp"end -local function ac(bd)local cd=fs.open(bd,"rb") -local dd=textutils.unserialize(cd.readAll())cd.close()if(dd~=nil)then return dd,"bimg"end end;local function bc(bd)end;local function cc(bd)end;local function dc(bd,cd) -if(cd==nil)then if(bd:find(".bimg"))then return ac(bd)elseif -(bd:find(".bbf"))then return bc(bd)else return _c(bd)end end end -local function _d(bd,cd)if( -cd==nil)then -if(bd:find(".bimg"))then return ac(bd)elseif(bd:find(".bbf"))then return cc(bd)else return db(bd)end end end -local function ad(bd,cd,dd) -local __a,a_a=bd.width or#bd[1][1][1],bd.height or#bd[1]local b_a={} -for c_a,d_a in pairs(bd)do -if(type(c_a)=="number")then local _aa={} -for y=1,dd do local aaa,baa,caa="","","" -local daa=bb(y/dd*a_a+0.5) -if(d_a[daa]~=nil)then -for x=1,cd do local _ba=bb(x/cd*__a+0.5)aaa=aaa.. -ab(d_a[daa][1],_ba,_ba) -baa=baa..ab(d_a[daa][2],_ba,_ba)caa=caa..ab(d_a[daa][3],_ba,_ba)end;table.insert(_aa,{aaa,baa,caa})end end;table.insert(b_a,c_a,_aa)else b_a[c_a]=d_a end end;b_a.width=cd;b_a.height=dd;return b_a end -return{loadNFP=_c,loadBIMG=ac,loadImage=dc,resizeBIMG=ad,loadImageAsBimg=_d}end -aa["libraries"]["layout"]=function(...) -local function ab(cb)local db={}db.___value=nil;db.___name=cb -db.___children={}db.___props={}function db:value()return self.___value end;function db:setValue(_c) -self.___value=_c end;function db:name()return self.___name end;function db:setName(_c) -self.___name=_c end;function db:children()return self.___children end;function db:numChildren()return -#self.___children end -function db:addChild(_c) -if -self[_c:name()]~=nil then if -type(self[_c:name()].name)=="function"then local ac={}table.insert(ac,self[_c:name()]) -self[_c:name()]=ac end -table.insert(self[_c:name()],_c)else self[_c:name()]=_c end;table.insert(self.___children,_c)end;function db:properties()return self.___props end;function db:numProperties() -return#self.___props end -function db:addProperty(_c,ac)local bc="@".._c -if self[bc]~=nil then if -type(self[bc])=="string"then local cc={}table.insert(cc,self[bc]) -self[bc]=cc end -table.insert(self[bc],ac)else self[bc]=ac end -table.insert(self.___props,{name=_c,value=self[_c]})end;return db end;local bb={} -function bb:ToXmlString(cb)cb=string.gsub(cb,"&","&") -cb=string.gsub(cb,"<","<")cb=string.gsub(cb,">",">") -cb=string.gsub(cb,"\"",""") -cb=string.gsub(cb,"([^%w%&%;%p%\t% ])",function(db) -return string.format("&#x%X;",string.byte(db))end)return cb end -function bb:FromXmlString(cb) -cb=string.gsub(cb,"&#x([%x]+)%;",function(db) -return string.char(tonumber(db,16))end) -cb=string.gsub(cb,"&#([0-9]+)%;",function(db)return string.char(tonumber(db,10))end)cb=string.gsub(cb,""","\"") -cb=string.gsub(cb,"'","'")cb=string.gsub(cb,">",">") -cb=string.gsub(cb,"<","<")cb=string.gsub(cb,"&","&")return cb end;function bb:ParseArgs(cb,db) -string.gsub(db,"(%w+)=([\"'])(.-)%2",function(_c,ac,bc) -cb:addProperty(_c,self:FromXmlString(bc))end)end -function bb:ParseXmlText(cb) -local db={}local _c=ab()table.insert(db,_c)local ac,bc,cc,dc,_d;local ad,bd=1,1 -while true do -ac,bd,bc,cc,dc,_d=string.find(cb,"<(%/?)([%w_:]+)(.-)(%/?)>",ad)if not ac then break end;local dd=string.sub(cb,ad,ac-1) -if not -string.find(dd,"^%s*$")then -local __a=(_c:value()or"")..self:FromXmlString(dd)db[#db]:setValue(__a)end -if _d=="/"then local __a=ab(cc)self:ParseArgs(__a,dc) -_c:addChild(__a)elseif bc==""then local __a=ab(cc)self:ParseArgs(__a,dc) -table.insert(db,__a)_c=__a else local __a=table.remove(db)_c=db[#db] -if#db<1 then error("XmlParser: nothing to close with ".. -cc)end;if __a:name()~=cc then -error("XmlParser: trying to close "..__a.name.." with "..cc)end;_c:addChild(__a)end;ad=bd+1 end;local cd=string.sub(cb,ad)if#db>1 then -error("XmlParser: unclosed "..db[#db]:name())end;return _c end -function bb:loadFile(cb,db)if not db then db=system.ResourceDirectory end -local _c=system.pathForFile(cb,db)local ac,bc=io.open(_c,"r") -if ac and not bc then local cc=ac:read("*a") -io.close(ac)return self:ParseXmlText(cc),nil else print(bc)return nil end end;return bb end -aa["libraries"]["module"]=function(...)return function(ab)local bb,cb=pcall(da,ab) -return bb and cb or nil end end -aa["libraries"]["process"]=function(...)local ab={}local bb={}local cb=0 -local db=dofile("rom/modules/main/cc/require.lua").make -function bb:new(_c,ac,bc,...)local cc={...} -local dc=setmetatable({path=_c},{__index=self})dc.window=ac;ac.current=term.current;ac.redirect=term.redirect -dc.processId=cb -if(type(_c)=="string")then -dc.coroutine=coroutine.create(function() -local _d=shell.resolveProgram(_c)local ad=setmetatable(bc,{__index=_ENV})ad.shell=shell -ad.basaltProgram=true;ad.arg={[0]=_c,table.unpack(cc)} -ad.require,ad.package=db(ad,fs.getDir(_d)) -if(fs.exists(_d))then local bd=fs.open(_d,"r")local cd=bd.readAll() -bd.close()local dd=load(cd,_c,"bt",ad)if(dd~=nil)then return dd()end end end)elseif(type(_c)=="function")then -dc.coroutine=coroutine.create(function() -_c(table.unpack(cc))end)else return end;ab[cb]=dc;cb=cb+1;return dc end -function bb:resume(_c,...)local ac=term.current()term.redirect(self.window) -if( -self.filter~=nil)then if(_c~=self.filter)then return end;self.filter=nil end;local bc,cc=coroutine.resume(self.coroutine,_c,...)if bc then -self.filter=cc else printError(cc)end;term.redirect(ac) -return bc,cc end -function bb:isDead() -if(self.coroutine~=nil)then -if -(coroutine.status(self.coroutine)=="dead")then table.remove(ab,self.processId)return true end else return true end;return false end -function bb:getStatus()if(self.coroutine~=nil)then -return coroutine.status(self.coroutine)end;return nil end -function bb:start()coroutine.resume(self.coroutine)end;return bb end -aa["libraries"]["tHex"]=function(...) -return -{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}end -aa["libraries"]["utils"]=function(...) -local ab,bb,cb=string.sub,string.find,string.reverse -local function db(ad,bd)local cd={}if ad==""or bd==""then return cd end;local dd=1 -local __a,a_a=bb(ad,bd,dd)while __a do table.insert(cd,ab(ad,dd,__a-1))dd=a_a+1 -__a,a_a=bb(ad,bd,dd)end -table.insert(cd,ab(ad,dd))return cd end -local _c={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local ac,bc,cc={},{},{}for i=0,15 do bc[2 ^i]=i end -do local ad="0123456789abcdef" -for i=1,16 do ac[ad:sub(i,i)]= -i-1;ac[i-1]=ad:sub(i,i) -cc[ad:sub(i,i)]=2 ^ (i-1)cc[2 ^ (i-1)]=ad:sub(i,i)local bd=_c[i-1]for i=1,#bd do -bd[i]=2 ^bd[i]end end end -local function dc(ad)local bd=_c[bc[ad[#ad][1]]] -for j=1,#bd do local cd=bd[j]for i=1,#ad-1 do if -ad[i][1]==cd then return i end end end;return 1 end -local function _d(ad,bd) -if not bd then local dd={}bd={}for i=1,6 do local __a=ad[i]local a_a=bd[__a] -bd[__a],dd[i]=a_a and(a_a+1)or 1,__a end;ad=dd end;local cd={}for dd,__a in pairs(bd)do cd[#cd+1]={dd,__a}end -if#cd>1 then -while -#cd>2 do -table.sort(cd,function(d_a,_aa)return d_a[2]>_aa[2]end)local __a,a_a=dc(cd),#cd;local b_a,c_a=cd[a_a][1],cd[__a][1] -for i=1,6 do if ad[i]==b_a then -ad[i]=c_a;cd[__a][2]=cd[__a][2]+1 end end;cd[a_a]=nil end;local dd=128 -for i=1,#ad-1 do if ad[i]~=ad[6]then dd=dd+2 ^ (i-1)end end;return string.char(dd), -cc[cd[1][1]==ad[6]and cd[2][1]or cd[1][1]],cc[ad[6]]else -return"\128",cc[ad[1]],cc[ad[1]]end end -return -{getTextHorizontalAlign=function(ad,bd,cd,dd)ad=ab(ad,1,bd)local __a=bd-string.len(ad) -if(cd=="right")then ad=string.rep( -dd or" ",__a)..ad elseif(cd=="center")then -ad=string.rep(dd or" ",math.floor( -__a/2))..ad.. -string.rep(dd or" ",math.floor(__a/2)) -ad=ad.. (string.len(ad) -bd do local b_a=bb(cb(ab(a_a,1,bd))," ")if not b_a then b_a=bd else -b_a=bd-b_a+1 end;local c_a=ab(a_a,1,b_a) -table.insert(dd,c_a)a_a=ab(a_a,b_a+1)end;if#a_a>0 then table.insert(dd,a_a)end end;return dd end,getValueFromXML=function(ad,bd) -local cd;if(type(bd)~="table")then return end;if(bd[ad]~=nil)then -if -(type(bd[ad])=="table")then if(bd[ad].value~=nil)then cd=bd[ad]:value()end end end;if(cd==nil)then -cd=bd["@"..ad]end;if(cd=="true")then cd=true elseif(cd=="false")then cd=false elseif(tonumber(cd)~=nil)then -cd=tonumber(cd)end;return cd end,numberFromString=function(ad)return load( -"return "..ad)()end,uuid=function() -local ad=math.random -local function bd()local cd='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'return -string.gsub(cd,'[xy]',function(dd)local __a= -(dd=='x')and ad(0,0xf)or ad(8,0xb) -return string.format('%x',__a)end)end;return bd()end,array=function(ad,bd)return -load( -"return {".. -("nil,"):rep(ad).. ("[0]=nil,"):rep(bd).."}")()end,shrink=function(ad,bd)local cd,dd,__a,a_a={{},{},{}},0, -#ad+#ad%3,bd or colours.black;for i=1,#ad do if -#ad[i]>dd then dd=#ad[i]end end -for y=0,__a-1,3 do -local b_a,c_a,d_a,_aa={},{},{},1 -for x=0,dd-1,2 do local aaa,baa={},{} -for yy=1,3 do -for xx=1,2 do -aaa[#aaa+1]=(ad[y+yy]and ad[y+yy][x+xx])and -(ad[y+ -yy][x+xx]==0 and a_a or ad[y+yy][x+xx])or a_a;baa[aaa[#aaa]]= -baa[aaa[#aaa]]and(baa[aaa[#aaa]]+1)or 1 end end;b_a[_aa],c_a[_aa],d_a[_aa]=_d(aaa,baa)_aa=_aa+1 end -cd[1][#cd[1]+1],cd[2][#cd[2]+1],cd[3][#cd[3]+1]=table.concat(b_a),table.concat(c_a),table.concat(d_a)end;cd.width,cd.height=#cd[1][1],#cd[1]return cd end}end;return aa["main"]() \ No newline at end of file diff --git a/docs/docs1_6/versions/latest.lua b/docs/docs1_6/versions/latest.lua deleted file mode 100644 index c6c1b29..0000000 --- a/docs/docs1_6/versions/latest.lua +++ /dev/null @@ -1,3083 +0,0 @@ -local aa={}local ba=true;local ca=require -local da=function(ab) -for bb,cb in pairs(aa)do -if(type(cb)=="table")then for db,_c in pairs(cb)do if(db==ab)then -return _c()end end else if(bb==ab)then return cb()end end end;return ca(ab)end -local _b=function(ab)if(ab~=nil)then return aa[ab]end;return aa end -aa["module"]=function(...)return -function(ab)local bb,cb=pcall(da,ab)return bb and cb or nil end end -aa["loadObjects"]=function(...)local ab={}if(ba)then -for db,_c in pairs(_b("objects"))do ab[db]=_c()end;return ab end;local bb=table.pack(...)local cb=fs.getDir( -bb[2]or"Basalt")if(cb==nil)then -error("Unable to find directory "..bb[2].. -" please report this bug to our discord.")end;for db,_c in -pairs(fs.list(fs.combine(cb,"objects")))do -if(_c~="example.lua")then local ac=_c:gsub(".lua","")ab[ac]=da(ac)end end;return ab end -aa["main"]=function(...)local ab=da("basaltEvent")()local bb=da("Frame") -local cb=da("theme")local db=da("utils")local _c=da("basaltLogs")local ac=db.uuid -local bc=db.createText;local cc=db.tableCount;local dc=300;local _d=50;local ad=term.current()local bd="1.6.5"local cd=fs.getDir( -table.pack(...)[2]or"") -local dd,__a,a_a,b_a,c_a,d_a={},{},{},{},{},{}local _aa,aaa,baa,caa;local daa={}if -not term.isColor or not term.isColor()then -error('Basalt requires an advanced (golden) computer to run.',0)end;local _ba={} -for dab,_bb in -pairs(colors)do if(type(_bb)=="number")then -_ba[dab]={ad.getPaletteColor(_bb)}end end -local function aba()caa=false;ad.clear()ad.setCursorPos(1,1) -for dab,_bb in pairs(colors)do if(type(_bb)== -"number")then -ad.setPaletteColor(_bb,colors.packRGB(table.unpack(_ba[dab])))end end end -local function bba(dab)ad.clear()ad.setBackgroundColor(colors.black) -ad.setTextColor(colors.red)local _bb,abb=ad.getSize()if(daa.logging)then _c(dab,"Error")end;local bbb=bc( -"Basalt error: "..dab,_bb)local cbb=1;for dbb,_cb in pairs(bbb)do -ad.setCursorPos(1,cbb)ad.write(_cb)cbb=cbb+1 end;ad.setCursorPos(1, -cbb+1)caa=false end -local function cba(dab) -assert(dab~="function","Schedule needs a function in order to work!") -return function(...)local _bb=coroutine.create(dab) -local abb,bbb=coroutine.resume(_bb,...) -if(abb)then table.insert(d_a,{_bb,bbb})else bba(bbb)end end end;local dba=function(dab,_bb)c_a[dab]=_bb end -local _ca=function(dab)return c_a[dab]end;local aca=function(dab)cb=dab end -local bca=function(dab)return cb[dab]end -local cca={getDynamicValueEventSetting=function()return daa.dynamicValueEvents end,getMainFrame=function()return _aa end,setVariable=dba,getVariable=_ca,getTheme=bca,setMainFrame=function(dab) -_aa=dab end,getActiveFrame=function()return aaa end,setActiveFrame=function(dab)aaa=dab end,getFocusedObject=function()return baa end,setFocusedObject=function(dab)baa=dab end,getMonitorFrame=function(dab)return -a_a[dab]or b_a[dab][1]end,setMonitorFrame=function(dab,_bb,abb)if(_aa==_bb)then -_aa=nil end -if(abb)then b_a[dab]={_bb,sides}else a_a[dab]=_bb end;if(_bb==nil)then b_a[dab]=nil end end,getBaseTerm=function()return -ad end,schedule=cba,stop=aba,newFrame=bb,getDirectory=function()return cd end} -local function dca(dab,...) -if(#d_a>0)then local _bb={} -for n=1,#d_a do -if(d_a[n]~=nil)then -if -(coroutine.status(d_a[n][1])=="suspended")then -if(d_a[n][2]~=nil)then -if(d_a[n][2]==dab)then -local abb,bbb=coroutine.resume(d_a[n][1],dab,...)d_a[n][2]=bbb;if not(abb)then bba(bbb)end end else local abb,bbb=coroutine.resume(d_a[n][1],dab,...) -d_a[n][2]=bbb;if not(abb)then bba(bbb)end end else table.insert(_bb,n)end end end -for n=1,#_bb do table.remove(d_a,_bb[n]- (n-1))end end end -local function _da()if(caa==false)then return end;if(_aa~=nil)then _aa:draw() -_aa:updateTerm()end -for dab,_bb in pairs(a_a)do _bb:draw()_bb:updateTerm()end -for dab,_bb in pairs(b_a)do _bb[1]:draw()_bb[1]:updateTerm()end end;local ada,bda,cda=nil,nil,nil;local dda=nil -local function __b(dab,_bb,abb,bbb)ada,bda,cda=_bb,abb,bbb;if(dda==nil)then -dda=os.startTimer(dc/1000)end end -local function a_b()dda=nil;_aa:hoverHandler(bda,cda,ada)aaa=_aa end;local b_b,c_b,d_b=nil,nil,nil;local _ab=nil;local function aab()_ab=nil;_aa:dragHandler(b_b,c_b,d_b) -aaa=_aa end;local function bab(dab,_bb,abb,bbb)b_b,c_b,d_b=_bb,abb,bbb -if(_d<50)then aab()else if(_ab==nil)then _ab=os.startTimer( -_d/1000)end end end -local function cab(dab,...) -local _bb={...} -if(ab:sendEvent("basaltEventCycle",dab,...)==false)then return end;if(dab=="terminate")then daa.stop()end -if(_aa~=nil)then -local abb={mouse_click=_aa.mouseHandler,mouse_up=_aa.mouseUpHandler,mouse_scroll=_aa.scrollHandler,mouse_drag=bab,mouse_move=__b}local bbb=abb[dab] -if(bbb~=nil)then bbb(_aa,...)dca(dab,...)_da()return end end -if(dab=="monitor_touch")then if(a_a[_bb[1]]~=nil)then -a_a[_bb[1]]:mouseHandler(1,_bb[2],_bb[3],true)aaa=a_a[_bb[1]]end -if -(cc(b_a)>0)then for abb,bbb in pairs(b_a)do -bbb[1]:mouseHandler(1,_bb[2],_bb[3],true,_bb[1])end end;dca(dab,...)_da()return end -if(aaa~=nil)then -local abb={char=aaa.charHandler,key=aaa.keyHandler,key_up=aaa.keyUpHandler}local bbb=abb[dab]if(bbb~=nil)then if(dab=="key")then dd[_bb[1]]=true elseif(dab=="key_up")then -dd[_bb[1]]=false end;bbb(aaa,...)dca(dab,...) -_da()return end end -if(dab=="timer")and(_bb[1]==dda)then a_b()elseif -(dab=="timer")and(_bb[1]==_ab)then aab()else -for abb,bbb in pairs(__a)do bbb:eventHandler(dab,...)end end;dca(dab,...)_da()end -daa={logging=false,dynamicValueEvents=false,setTheme=aca,getTheme=bca,drawFrames=_da,getVersion=function()return bd end,setVariable=dba,getVariable=_ca,setBaseTerm=function(dab)ad=dab end,log=function(...)_c(...)end,setMouseMoveThrottle=function(dab) -if -(_HOST:find("CraftOS%-PC"))then if(config.get("mouse_move_throttle")~=10)then -config.set("mouse_move_throttle",10)end -if(dab<100)then dc=100 else dc=dab end;return true end;return false end,setMouseDragThrottle=function(dab)if( -dab<=0)then _d=0 else _ab=nil;_d=dab end end,autoUpdate=function(dab) -caa=dab;if(dab==nil)then caa=true end;local function _bb()_da()while caa do -cab(os.pullEventRaw())end end -local abb,bbb=xpcall(_bb,debug.traceback)if not(abb)then bba(bbb)return end end,update=function(dab,...)if( -dab~=nil)then local _bb,abb=xpcall(cab,debug.traceback,dab,...)if not(_bb)then -bba(abb)return end end end,stop=aba,stopUpdate=aba,isKeyDown=function(dab)if( -dd[dab]==nil)then return false end;return dd[dab]end,getFrame=function(dab)for _bb,abb in -pairs(__a)do if(abb.name==dab)then return abb end end end,getActiveFrame=function()return -aaa end,setActiveFrame=function(dab) -if(dab:getType()=="Frame")then aaa=dab;return true end;return false end,onEvent=function(...) -for dab,_bb in -pairs(table.pack(...))do if(type(_bb)=="function")then -ab:registerEvent("basaltEventCycle",_bb)end end end,schedule=cba,createFrame=function(dab) -dab=dab or ac() -for abb,bbb in pairs(__a)do if(bbb.name==dab)then return nil end end;local _bb=bb(dab,nil,nil,cca)_bb:init() -table.insert(__a,_bb)if -(_aa==nil)and(_bb:getName()~="basaltDebuggingFrame")then _bb:show()end;return _bb end,removeFrame=function(dab)__a[dab]= -nil end,setProjectDir=function(dab)cd=dab end,debug=function(...)local dab={...}if(_aa==nil)then print(...) -return end -if(_aa.name~="basaltDebuggingFrame")then if(_aa~=daa.debugFrame)then -daa.debugLabel:setParent(_aa)end end;local _bb="" -for abb,bbb in pairs(dab)do _bb=_bb.. -tostring(bbb).. (#dab~=abb and", "or"")end;daa.debugLabel:setText("[Debug] ".._bb) -for abb,bbb in -pairs(bc(_bb,daa.debugList:getWidth()))do daa.debugList:addItem(bbb)end;if(daa.debugList:getItemCount()>50)then -daa.debugList:removeItem(1)end -daa.debugList:setValue(daa.debugList:getItem(daa.debugList:getItemCount()))if -(daa.debugList.getItemCount()>daa.debugList:getHeight())then -daa.debugList:setOffset(daa.debugList:getItemCount()- -daa.debugList:getHeight())end -daa.debugLabel:show()end} -daa.debugFrame=daa.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray) -daa.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if( -daa.oldFrame~=nil)then daa.oldFrame:show()end end):setBackground(colors.red):show() -daa.debugList=daa.debugFrame:addList("debugList"):setSize("parent.w - 2","parent.h - 3"):setPosition(2,3):setScrollable(true):show() -daa.debugLabel=daa.debugFrame:addLabel("debugLabel"):onClick(function() -daa.oldFrame=_aa;daa.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return daa end -aa["theme"]=function(...) -return -{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=false,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green,LabelBG=false,LabelText=colors.black,GraphBG=colors.gray,GraphText=colors.black}end -aa["Frame"]=function(...)local ab=da("module")local bb=da("Object") -local cb=da("loadObjects")local db=da("basaltDraw")local _c=da("utils")local ac=ab("layout") -local bc=ab("basaltMon")local cc=_c.uuid;local dc=_c.rpairs;local _d=_c.getValueFromXML;local ad=_c.tableCount -local bd,cd,dd=string.sub,math.min,math.max -return -function(__a,a_a,b_a,c_a)local d_a=bb(__a)local _aa="Frame"local aaa={}local baa={}local caa={}local daa={}local _ba={}local aba={} -local bba={}local cba={}local dba=0;local _ca=b_a or term.current()local aca=""local bca=false -local cca=false;local dca=false;local _da=0;local ada=0;local bda=false;local cda=0;local dda=false;local __b=false;local a_b=""local b_b=false -local c_b=false;local d_b;local _ab;local aab=true;local bab=true;local cab=false;local dab={}local _bb={} -d_a:setZIndex(10)local abb=db(_ca)local bbb=false;local cbb=1;local dbb=1;local _cb=colors.white;local acb,bcb=0,0;local ccb={} -local function dcb(dbc,_cc)if(_cc~= -nil)then _cc:setValuesByXMLData(dbc)end end -local function _db(dbc,_cc,acc) -if(dbc~=nil)then if(dbc.properties~=nil)then dbc={dbc}end;for bcc,ccc in pairs(dbc)do local dcc=_cc(acc, -ccc["@id"]or cc()) -table.insert(ccb,dcc)dcb(ccc,dcc)end end end -local function adb(dbc)if(type(dbc)~="string")then dbc=dbc.name end;for _cc,acc in pairs(aaa)do -for bcc,ccc in -pairs(acc)do if(ccc:getName()==dbc)then return ccc end end end end -local function bdb(dbc)local _cc=adb(dbc)if(_cc~=nil)then return _cc end -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do if( -dcc:getType()=="Frame")then local _dc=dcc:getDeepObject(dbc) -if(_dc~=nil)then return _dc end end end end end -local function cdb(dbc)local _cc=dbc:getZIndex() -if(adb(dbc.name)~=nil)then return nil end -if(aaa[_cc]==nil)then -for x=1,#baa+1 do if(baa[x]~=nil)then if(_cc==baa[x])then break end;if -(_cc>baa[x])then table.insert(baa,x,_cc)break end else -table.insert(baa,_cc)end end;if(#baa<=0)then table.insert(baa,_cc)end;aaa[_cc]={}end;dbc.parent=caa;if(dbc.init~=nil)then dbc:init()end -table.insert(aaa[_cc],dbc)return dbc end -local function ddb(dbc,_cc) -for acc,bcc in pairs(daa)do -for ccc,dcc in pairs(bcc)do -for _dc,adc in pairs(dcc)do -if(adc==_cc)then -table.remove(daa[acc][ccc],_dc)if(dbc.parent~=nil)then if(ad(daa[acc])<=0)then -dbc.parent:removeEvent(acc,dbc)end end end end end end end -local function __c(dbc,_cc) -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if(type(_cc)=="string")then -if(dcc:getName()==_cc)then -table.remove(aaa[acc],ccc)ddb(caa,dcc)dbc:updateDraw()return true end else if(dcc==_cc)then table.remove(aaa[acc],ccc)ddb(caa,dcc) -dbc:updateDraw()return true end end end end;return false end;local function a_c(dbc,_cc,acc) -for bcc,ccc in pairs(daa[_cc])do for dcc,_dc in pairs(ccc)do -if(_dc:getName()==acc)then return _dc end end end end -local function b_c(dbc,_cc,acc) -local bcc=acc:getZIndex()if(daa[_cc]==nil)then daa[_cc]={}end;if(_ba[_cc]==nil)then -_ba[_cc]={}end -if(a_c(dbc,_cc,acc.name)~=nil)then return nil end -if(dbc.parent~=nil)then dbc.parent:addEvent(_cc,dbc)end;dab[_cc]=true -if(daa[_cc][bcc]==nil)then -for x=1,#_ba[_cc]+1 do -if -(_ba[_cc][x]~=nil)then if(bcc==_ba[_cc][x])then break end;if(bcc>_ba[_cc][x])then -table.insert(_ba[_cc],x,bcc)break end else -table.insert(_ba[_cc],bcc)end end -if(#_ba[_cc]<=0)then table.insert(_ba[_cc],bcc)end;daa[_cc][bcc]={}end;table.insert(daa[_cc][bcc],acc)return acc end -local function c_c(dbc,_cc,acc) -if(daa[_cc]~=nil)then -for bcc,ccc in pairs(daa[_cc])do -for dcc,_dc in pairs(ccc)do -if(_dc==acc)then -table.remove(daa[_cc][bcc],dcc)if(#daa[_cc][bcc]<=0)then daa[_cc][bcc]=nil -if(dbc.parent~=nil)then if( -ad(daa[_cc])<=0)then dab[_cc]=false -dbc.parent:removeEvent(_cc,dbc)end end end;return -true end end end end;return false end;local d_c=math -local function _ac(dbc) -local _cc,acc=pcall(load("return "..dbc,"",nil,{math=d_c}))if not(_cc)then -error(dbc.." is not a valid dynamic code")end;return acc end -local function aac(dbc,_cc,acc)for bcc,ccc in pairs(cba)do -if(ccc[2]==acc)and(ccc[4]==_cc)then return ccc end end;dba=dba+1 -cba[dba]={0,acc,{},_cc,dba}return cba[dba]end -local function bac(dbc,_cc)local acc={}local bcc={}for ccc in _cc:gmatch("%a+%.x")do local dcc=ccc:gsub("%.x","") -if -(dcc~="self")and(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%w+%.y")do local dcc=ccc:gsub("%.y","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end;for ccc in _cc:gmatch("%a+%.w")do local dcc=ccc:gsub("%.w","") -if(dcc~="self")and -(dcc~="parent")then table.insert(acc,dcc)end end -for ccc in -_cc:gmatch("%a+%.h")do local dcc=ccc:gsub("%.h","")if(dcc~="self")and(dcc~="parent")then -table.insert(acc,dcc)end end -for ccc,dcc in pairs(acc)do bcc[dcc]=adb(dcc)if(bcc[dcc]==nil)then -error("Dynamic Values - unable to find object "..dcc)end end;bcc["self"]=dbc;bcc["parent"]=dbc:getParent()return bcc end -local function cac(dbc,_cc)local acc=dbc;for bcc in dbc:gmatch("%w+%.x")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.x","")]:getX())end;for bcc in dbc:gmatch("%w+%.y")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.y","")]:getY())end;for bcc in dbc:gmatch("%w+%.w")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.w","")]:getWidth())end;for bcc in dbc:gmatch("%w+%.h")do -acc=acc:gsub(bcc,_cc[bcc:gsub("%.h","")]:getHeight())end;return acc end -local function dac(dbc) -if(#cba>0)then -for n=1,dba do -if(cba[n]~=nil)then local _cc;if(#cba[n][3]<=0)then -cba[n][3]=bac(cba[n][4],cba[n][2])end -_cc=cac(cba[n][2],cba[n][3])cba[n][1]=_ac(_cc)if(cba[n][4]:getType()=="Frame")then -cba[n][4]:recalculateDynamicValues()end end end -for _cc,acc in pairs(baa)do -if(aaa[acc]~=nil)then -for bcc,ccc in pairs(aaa[acc])do -if -(c_a.getDynamicValueEventSetting())then if(ccc.eventHandler~=nil)then -ccc:eventHandler("basalt_dynamicvalue",dbc)end end;if(ccc.customEventHandler~=nil)then -ccc:customEventHandler("basalt_resize",dbc)end end end end end end;local function _bc(dbc)return cba[dbc][1]end -local function abc(dbc)local _cc=0 -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if( -dcc.getHeight~=nil)and(dcc.getY~=nil)then -if -(dcc:getType()=="Dropdown")then local _dc,adc=dcc:getHeight(),dcc:getY() -local bdc,cdc=dcc:getDropdownSize()_dc=_dc+cdc-1 -if(_dc+adc-dbc:getHeight()>=_cc)then _cc=dd( -_dc+adc-dbc:getHeight(),0)end else local _dc,adc=dcc:getHeight(),dcc:getY()if( -_dc+adc-dbc:getHeight()>=_cc)then -_cc=dd(_dc+adc-dbc:getHeight(),0)end end end end end;return _cc end -local function bbc(dbc)local _cc=0 -for acc,bcc in pairs(aaa)do -for ccc,dcc in pairs(bcc)do -if -(dcc.getWidth~=nil)and(dcc.getX~=nil)then local _dc,adc=dcc:getWidth(),dcc:getX()if( -_dc+adc-dbc:getWidth()>=_cc)then -_cc=dd(_dc+adc-dbc:getWidth(),0)end end end end;return _cc end;local function cbc(dbc)if(bab)then cda=abc(dbc)end end -caa={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",addEvent=b_c,removeEvent=c_c,removeEvents=ddb,getEvent=a_c,newDynamicValue=aac,recalculateDynamicValues=dac,getDynamicValue=_bc,getType=function(dbc)return -_aa end,setZIndex=function(dbc,_cc)d_a.setZIndex(dbc,_cc)for acc,bcc in pairs(dab)do if(bcc)then -dbc.parent:addEvent(acc,dbc)end end;return dbc end,setFocusedObject=function(dbc,_cc) -if( -_ab~=_cc)then if(_ab~=nil)then -if(adb(_ab)~=nil)then _ab:loseFocusHandler()end end;if(_cc~=nil)then if(adb(_cc)~=nil)then -_cc:getFocusHandler()end end;_ab=_cc end;return dbc end,getVariable=function(dbc,_cc)return -c_a.getVariable(_cc)end,setSize=function(dbc,_cc,acc,bcc) -d_a.setSize(dbc,_cc,acc,bcc)if(dbc.parent==nil)then abb=db(_ca)end -for ccc,dcc in pairs(baa)do if(aaa[dcc]~=nil)then -for _dc,adc in -pairs(aaa[dcc])do if(adc.customEventHandler~=nil)then -adc:customEventHandler("basalt_resize",dbc)end end end end;dbc:recalculateDynamicValues()aab=false;return dbc end,setTheme=function(dbc,_cc,acc) -if( -type(_cc)=="table")then bba=_cc elseif(type(_cc)=="string")then bba[_cc]=acc end;dbc:updateDraw()return dbc end,getTheme=function(dbc,_cc) -return -bba[_cc]or(dbc.parent~=nil and dbc.parent:getTheme(_cc)or -c_a.getTheme(_cc))end,getThemeColor=function(dbc,_cc)return -_cc~=nil and _bb[_cc]or _bb end,setThemeColor=function(dbc,_cc,...) -if -(dbc.parent==nil)then -if(dbc==c_a.getActiveFrame())then -if(type(_cc)=="string")then _bb[_cc]=... -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],...)elseif(type(_cc)=="table")then -for acc,bcc in pairs(_cc)do _bb[acc]=bcc -if(type(bcc)=="number")then -_ca.setPaletteColor( -type(acc)=="number"and acc or colors[acc],bcc)else local ccc,dcc,_dc=table.unpack(bcc) -_ca.setPaletteColor( -type(acc)=="number"and acc or colors[acc],ccc,dcc,_dc)end end end end end;return dbc end,setPosition=function(dbc,_cc,acc,bcc) -d_a.setPosition(dbc,_cc,acc,bcc)dbc:recalculateDynamicValues()return dbc end,getBasaltInstance=function(dbc)return -c_a end,setOffset=function(dbc,_cc,acc) -acb=_cc~=nil and -d_c.floor(_cc<0 and d_c.abs(_cc)or-_cc)or acb -bcb=acc~=nil and -d_c.floor(acc<0 and d_c.abs(acc)or-acc)or bcb;dbc:updateDraw()return dbc end,getOffsetInternal=function(dbc)return -acb,bcb end,getOffset=function(dbc)return acb<0 and d_c.abs(acb)or-acb,bcb<0 and -d_c.abs(bcb)or-bcb end,removeFocusedObject=function(dbc)if( -_ab~=nil)then -if(adb(_ab)~=nil)then _ab:loseFocusHandler()end end;_ab=nil;return dbc end,getFocusedObject=function(dbc)return -_ab end,setCursor=function(dbc,_cc,acc,bcc,ccc) -if(dbc.parent~=nil)then -local dcc,_dc=dbc:getAnchorPosition() -dbc.parent:setCursor(_cc or false,(acc or 0)+dcc-1,(bcc or 0)+_dc-1, -ccc or _cb)else -local dcc,_dc=dbc:getAbsolutePosition(dbc:getAnchorPosition(dbc:getX(),dbc:getY(),true))bbb=_cc or false;if(acc~=nil)then cbb=dcc+acc-1 end;if(bcc~=nil)then dbb=_dc+ -bcc-1 end;_cb=ccc or _cb;if(bbb)then -_ca.setTextColor(_cb)_ca.setCursorPos(cbb,dbb)_ca.setCursorBlink(bbb)else -_ca.setCursorBlink(false)end end;return dbc end,setMovable=function(dbc,_cc) -if( -dbc.parent~=nil)then b_b=_cc or not b_b -dbc.parent:addEvent("mouse_click",dbc)dab["mouse_click"]=true -dbc.parent:addEvent("mouse_up",dbc)dab["mouse_up"]=true -dbc.parent:addEvent("mouse_drag",dbc)dab["mouse_drag"]=true end;return dbc end,setScrollable=function(dbc,_cc)bda=( -_cc or _cc==nil)and true or false -if( -dbc.parent~=nil)then dbc.parent:addEvent("mouse_scroll",dbc)end;dab["mouse_scroll"]=true;return dbc end,setScrollAmount=function(dbc,_cc)cda= -_cc or cda;bab=false;return dbc end,getScrollAmount=function(dbc)return bab and cbc(dbc)or -cda end,getCalculatedVerticalScroll=abc,getCalculatedHorizontalScroll=bbc,show=function(dbc)d_a.show(dbc) -if( -dbc.parent==nil)then c_a.setActiveFrame(dbc) -for _cc,acc in pairs(colors)do if -(type(acc)=="number")then -_ca.setPaletteColor(acc,colors.packRGB(term.nativePaletteColor((acc))))end end -for _cc,acc in pairs(_bb)do -if(type(acc)=="number")then -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],acc)else local bcc,ccc,dcc=table.unpack(acc) -_ca.setPaletteColor( -type(_cc)=="number"and _cc or colors[_cc],bcc,ccc,dcc)end end -if(bca)and not(cca)then c_a.setMonitorFrame(aca,dbc)elseif(cca)then -c_a.setMonitorFrame(dbc:getName(),dbc,aca)else c_a.setMainFrame(dbc)end end;return dbc end,hide=function(dbc) -d_a.hide(dbc) -if(dbc.parent==nil)then if(activeFrame==dbc)then activeFrame=nil end -if(bca)and -not(cca)then if(c_a.getMonitorFrame(aca)==dbc)then -c_a.setActiveFrame(nil)end elseif(cca)then -if( -c_a.getMonitorFrame(dbc:getName())==dbc)then c_a.setActiveFrame(nil)end else -if(c_a.getMainFrame()==dbc)then c_a.setMainFrame(nil)end end end;return dbc end,addLayout=function(dbc,_cc) -if( -_cc~=nil)then -if(fs.exists(_cc))then local acc=fs.open(_cc,"r") -local bcc=ac:ParseXmlText(acc.readAll())acc.close()ccb={}dbc:setValuesByXMLData(bcc)end end;return dbc end,getLastLayout=function(dbc)return -ccb end,addLayoutFromString=function(dbc,_cc)if(_cc~=nil)then local acc=ac:ParseXmlText(_cc) -dbc:setValuesByXMLData(acc)end;return dbc end,setValuesByXMLData=function(dbc,_cc) -d_a.setValuesByXMLData(dbc,_cc)if(_d("movable",_cc)~=nil)then if(_d("movable",_cc))then -dbc:setMovable(true)end end;if( -_d("scrollable",_cc)~=nil)then -if(_d("scrollable",_cc))then dbc:setScrollable(true)end end;if -(_d("monitor",_cc)~=nil)then -dbc:setMonitor(_d("monitor",_cc)):show()end;if(_d("mirror",_cc)~=nil)then -dbc:setMirror(_d("mirror",_cc))end -if(_d("bar",_cc)~=nil)then if(_d("bar",_cc))then -dbc:showBar(true)else dbc:showBar(false)end end -if(_d("barText",_cc)~=nil)then dbc.barText=_d("barText",_cc)end;if(_d("barBG",_cc)~=nil)then -dbc.barBackground=colors[_d("barBG",_cc)]end;if(_d("barFG",_cc)~=nil)then -dbc.barTextcolor=colors[_d("barFG",_cc)]end;if(_d("barAlign",_cc)~=nil)then -dbc.barTextAlign=_d("barAlign",_cc)end;if(_d("layout",_cc)~=nil)then -dbc:addLayout(_d("layout",_cc))end;if(_d("xOffset",_cc)~=nil)then -dbc:setOffset(_d("xOffset",_cc),bcb)end;if(_d("yOffset",_cc)~=nil)then -dbc:setOffset(bcb,_d("yOffset",_cc))end;if(_d("scrollAmount",_cc)~=nil)then -dbc:setScrollAmount(_d("scrollAmount",_cc))end;local acc=_cc:children() -for bcc,ccc in -pairs(acc)do if(ccc.___name~="animation")then -local dcc=ccc.___name:gsub("^%l",string.upper) -if(cb[dcc]~=nil)then _db(ccc,dbc["add"..dcc],dbc)end end end;_db(_cc["frame"],dbc.addFrame,dbc) -_db(_cc["animation"],dbc.addAnimation,dbc)return dbc end,showBar=function(dbc,_cc)dbc.barActive= -_cc or not dbc.barActive;dbc:updateDraw() -return dbc end,setBar=function(dbc,_cc,acc,bcc)dbc.barText=_cc or""dbc.barBackground= -acc or dbc.barBackground -dbc.barTextcolor=bcc or dbc.barTextcolor;dbc:updateDraw()return dbc end,setBarTextAlign=function(dbc,_cc)dbc.barTextAlign= -_cc or"left"dbc:updateDraw()return dbc end,setMirror=function(dbc,_cc)if( -dbc.parent~=nil)then -error("Frame has to be a base frame in order to attach a mirror.")end;a_b=_cc;if(mirror~=nil)then -abb.setMirror(mirror)end;dda=true;return dbc end,removeMirror=function(dbc)mirror= -nil;dda=false;abb.setMirror(nil)return dbc end,setMonitorScale=function(dbc,_cc)if -(bca)then _ca.setTextScale(_cc)end;return dbc end,setMonitor=function(dbc,_cc,acc) -if( -_cc~=nil)and(_cc~=false)then -if(type(_cc)=="string")then -if( -peripheral.getType(_cc)=="monitor")then _ca=peripheral.wrap(_cc)dca=true end -if(dbc.parent~=nil)then dbc.parent:removeObject(dbc)end;bca=true;c_a.setMonitorFrame(_cc,dbc)elseif(type(_cc)=="table")then -_ca=bc(_cc)dca=true;bca=true;cca=true -c_a.setMonitorFrame(dbc:getName(),dbc,true)end else _ca=parentTerminal;bca=false;cca=false -if(type(aca)=="string")then -if( -c_a.getMonitorFrame(aca)==dbc)then c_a.setMonitorFrame(aca,nil)end else -if(c_a.getMonitorFrame(dbc:getName())==dbc)then c_a.setMonitorFrame(dbc:getName(), -nil)end end end;if(acc~=nil)then _ca.setTextScale(acc)end;abb=db(_ca) -dbc:setSize(_ca.getSize())aab=true;aca=_cc or nil;dbc:updateDraw()return dbc end,loseFocusHandler=function(dbc) -d_a.loseFocusHandler(dbc)if(_ab~=nil)then _ab:loseFocusHandler()_ab=nil end end,getFocusHandler=function(dbc) -d_a.getFocusHandler(dbc) -if(dbc.parent~=nil)then -if(b_b)then dbc.parent:removeEvents(dbc) -dbc.parent:removeObject(dbc)dbc.parent:addObject(dbc)for _cc,acc in pairs(dab)do if(acc)then -dbc.parent:addEvent(_cc,dbc)end end -dbc:updateDraw()end end;if(_ab~=nil)then _ab:getFocusHandler()end end,eventHandler=function(dbc,_cc,...) -d_a.eventHandler(dbc,_cc,...) -if(daa["other_event"]~=nil)then -for acc,bcc in ipairs(_ba["other_event"])do if( -daa["other_event"][bcc]~=nil)then -for ccc,dcc in dc(daa["other_event"][bcc])do if -(dcc.eventHandler~=nil)then dcc:eventHandler(_cc,...)end end end end end -if(aab)and not(bca)then if(dbc.parent==nil)then -if(_cc=="term_resize")then -dbc:sendEvent("basalt_resize",dbc,_cc,...)dbc:setSize(_ca.getSize())aab=true end end end -if(bca)then -if(aab)then -if(_cc=="monitor_resize")then -if(type(aca)=="string")then -dbc:setSize(_ca.getSize())elseif(type(aca)=="table")then -for acc,bcc in pairs(aca)do for ccc,dcc in pairs(bcc)do if(p1 ==dcc)then -dbc:setSize(_ca.getSize())end end end end;aab=true;dbc:updateDraw()end end -if(_cc=="peripheral")and(p1 ==aca)then if -(peripheral.getType(aca)=="monitor")then dca=true;_ca=peripheral.wrap(aca)abb=db(_ca) -dbc:updateDraw()end end -if(_cc=="peripheral_detach")and(p1 ==aca)then dca=false end end -if(dda)then if(peripheral.getType(a_b)=="monitor")then __b=true -abb.setMirror(peripheral.wrap(a_b))end;if(_cc=="peripheral_detach")and -(p1 ==a_b)then dca=false end -if -(_cc=="monitor_touch")and(a_b==p1)then dbc:mouseHandler(1,p2,p3,true)end end end,mouseHandler=function(dbc,_cc,acc,bcc,ccc,dcc) -if -(cca)then if(_ca.calculateClick~=nil)then -acc,bcc=_ca.calculateClick(dcc,acc,bcc)end end -if(d_a.mouseHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_click"]~=nil)then -dbc:setCursor(false) -for _dc,adc in ipairs(_ba["mouse_click"])do -if -(daa["mouse_click"][adc]~=nil)then for bdc,cdc in dc(daa["mouse_click"][adc])do -if(cdc.mouseHandler~=nil)then if -(cdc:mouseHandler(_cc,acc,bcc))then return true end end end end end end -if(b_b)then -local _dc,adc=dbc:getAbsolutePosition(dbc:getAnchorPosition())if -(acc>=_dc)and(acc<=_dc+dbc:getWidth()-1)and(bcc==adc)then c_b=true;_da=_dc-acc -ada=yOff and 1 or 0 end end;dbc:removeFocusedObject()return true end;return false end,mouseUpHandler=function(dbc,_cc,acc,bcc)if -(c_b)then c_b=false end -if(d_a.mouseUpHandler(dbc,_cc,acc,bcc))then -if -(daa["mouse_up"]~=nil)then -for ccc,dcc in ipairs(_ba["mouse_up"])do -if(daa["mouse_up"][dcc]~=nil)then -for _dc,adc in -dc(daa["mouse_up"][dcc])do if(adc.mouseUpHandler~=nil)then -if(adc:mouseUpHandler(_cc,acc,bcc))then return true end end end end end end;return true end;return false end,scrollHandler=function(dbc,_cc,acc,bcc) -if -(d_a.scrollHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_scroll"]~=nil)then -for dcc,_dc in pairs(_ba["mouse_scroll"])do -if( -daa["mouse_scroll"][_dc]~=nil)then -for adc,bdc in dc(daa["mouse_scroll"][_dc])do if(bdc.scrollHandler~= -nil)then -if(bdc:scrollHandler(_cc,acc,bcc))then return true end end end end end end;local ccc=bcb -if(bda)then cbc(dbc)if(_cc>0)or(_cc<0)then -bcb=dd(cd(bcb-_cc,0),-cda)dbc:updateDraw()end end;if(bcb==ccc)then return false end;dbc:removeFocusedObject() -return true end;return false end,hoverHandler=function(dbc,_cc,acc,bcc) -if -(d_a.hoverHandler(dbc,_cc,acc,bcc))then -if(daa["mouse_move"]~=nil)then -for ccc,dcc in pairs(_ba["mouse_move"])do -if( -daa["mouse_move"][dcc]~=nil)then for _dc,adc in dc(daa["mouse_move"][dcc])do -if -(adc.hoverHandler~=nil)then if(adc:hoverHandler(_cc,acc,bcc))then return true end end end end end end end;return false end,dragHandler=function(dbc,_cc,acc,bcc) -if -(c_b)then local ccc,dcc=dbc.parent:getOffsetInternal()ccc=ccc<0 and -d_c.abs(ccc)or-ccc;dcc=dcc<0 and d_c.abs(dcc)or- -dcc;local _dc=1;local adc=1;if(dbc.parent~=nil)then -_dc,adc=dbc.parent:getAbsolutePosition(dbc.parent:getAnchorPosition())end -dbc:setPosition( -acc+_da- (_dc-1)+ccc,bcc+ada- (adc-1)+dcc)dbc:updateDraw()return true end -if(dbc:isVisible())and(dbc:isEnabled())then -if -(daa["mouse_drag"]~=nil)then -for ccc,dcc in ipairs(_ba["mouse_drag"])do -if -(daa["mouse_drag"][dcc]~=nil)then for _dc,adc in dc(daa["mouse_drag"][dcc])do -if(adc.dragHandler~=nil)then if -(adc:dragHandler(_cc,acc,bcc))then return true end end end end end end end;d_a.dragHandler(dbc,_cc,acc,bcc)return false end,keyHandler=function(dbc,_cc,acc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local bcc=dbc:getEventSystem():sendEvent("key",dbc,"key",_cc)if(bcc==false)then return false end -if(daa["key"]~=nil)then -for ccc,dcc in pairs(_ba["key"])do -if( -daa["key"][dcc]~=nil)then -for _dc,adc in dc(daa["key"][dcc])do if(adc.keyHandler~=nil)then if -(adc:keyHandler(_cc,acc))then return true end end end end end end end;return false end,keyUpHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("key_up",dbc,"key_up",_cc)if(acc==false)then return false end -if(daa["key_up"]~=nil)then -for bcc,ccc in -pairs(_ba["key_up"])do -if(daa["key_up"][ccc]~=nil)then for dcc,_dc in dc(daa["key_up"][ccc])do -if( -_dc.keyUpHandler~=nil)then if(_dc:keyUpHandler(_cc))then return true end end end end end end end;return false end,charHandler=function(dbc,_cc) -if -(dbc:isFocused())or(dbc.parent==nil)then -local acc=dbc:getEventSystem():sendEvent("char",dbc,"char",_cc)if(acc==false)then return false end -if(daa["char"]~=nil)then -for bcc,ccc in -pairs(_ba["char"])do -if(daa["char"][ccc]~=nil)then for dcc,_dc in dc(daa["char"][ccc])do -if -(_dc.charHandler~=nil)then if(_dc:charHandler(_cc))then return true end end end end end end end;return false end,setText=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setText(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setText(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,setBG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setBG(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setBG(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,setFG=function(dbc,_cc,acc,bcc) -local ccc,dcc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:setFG(dd( -_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))else -abb.setFG(dd(_cc+ (ccc-1),ccc),dcc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)))end end end,writeText=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -if(dbc.parent~=nil)then -dbc.parent:writeText(dd( -_cc+ (_dc-1),_dc),adc+acc-1,bd(bcc,dd(1 -_cc+1,1), -dbc:getWidth()-_cc+1),ccc,dcc)else -abb.writeText(dd(_cc+ (_dc-1),_dc),adc+acc-1,bd(bcc,dd(1 -_cc+1,1),dd( -dbc:getWidth()-_cc+1,1)),ccc,dcc)end end end,blit=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -if(acc>=1)and(acc<=dbc:getHeight())then -local bdc=dbc:getWidth() -if(dbc.parent~=nil)then -bcc=bd(bcc,dd(1 -_cc+1,1),bdc-_cc+1)ccc=bd(ccc,dd(1 -_cc+1,1),bdc-_cc+1)dcc=bd(dcc,dd( -1 -_cc+1,1),bdc-_cc+1) -dbc.parent:blit(dd( -_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)else -bcc=bd(bcc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -ccc=bd(ccc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -dcc=bd(dcc,dd(1 -_cc+1,1),dd(bdc-_cc+1,1)) -abb.blit(dd(_cc+ (_dc-1),_dc),adc+acc-1,bcc,ccc,dcc)end end end,drawBackgroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)else -abb.drawBackgroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)end end,drawTextBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawTextBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,bd(dcc,1,1))else -abb.drawTextBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,bd(dcc,1,1))end end,drawForegroundBox=function(dbc,_cc,acc,bcc,ccc,dcc) -local _dc,adc=dbc:getAnchorPosition() -ccc=(acc<1 and( -ccc+acc>dbc:getHeight()and dbc:getHeight()or ccc+acc-1)or( -ccc+ -acc>dbc:getHeight()and dbc:getHeight()-acc+1 or ccc)) -bcc=(_cc<1 and(bcc+_cc>dbc:getWidth()and dbc:getWidth()or bcc+ -_cc-1)or( - -bcc+_cc>dbc:getWidth()and dbc:getWidth()-_cc+1 or bcc)) -if(dbc.parent~=nil)then -dbc.parent:drawForegroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)else -abb.drawForegroundBox(dd(_cc+ (_dc-1),_dc),dd(acc+ (adc-1),adc),bcc,ccc,dcc)end end,draw=function(dbc,_cc)if -(bca)and not(dca)then return false end -if(dbc.parent==nil)then if(dbc:getDraw()== -false)then return false end end -if(d_a.draw(dbc))then -local acc,bcc=dbc:getAbsolutePosition(dbc:getAnchorPosition())local ccc,dcc=dbc:getAnchorPosition()local _dc,adc=dbc:getSize() -if( -dbc.parent==nil)then -if(dbc.bgColor~=false)then -abb.drawBackgroundBox(ccc,dcc,_dc,adc,dbc.bgColor)abb.drawTextBox(ccc,dcc,_dc,adc," ")end;if(dbc.fgColor~=false)then -abb.drawForegroundBox(ccc,dcc,_dc,adc,dbc.fgColor)end end -if(dbc.barActive)then -if(dbc.parent~=nil)then -dbc.parent:writeText(ccc,dcc,_c.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)else -abb.writeText(ccc,dcc,_c.getTextHorizontalAlign(dbc.barText,_dc,dbc.barTextAlign),dbc.barBackground,dbc.barTextcolor)end -if(dbc:getBorder("left"))then -if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc,1,1,dbc.barBackground)if(dbc.bgColor~=false)then -dbc.parent:drawBackgroundBox(ccc-1,dcc+1,1,adc-1,dbc.bgColor)end end end -if(dbc:getBorder("top"))then if(dbc.parent~=nil)then -dbc.parent:drawBackgroundBox(ccc-1,dcc-1,_dc+1,1,dbc.barBackground)end end end;for bdc,cdc in dc(baa)do -if(aaa[cdc]~=nil)then for ddc,__d in pairs(aaa[cdc])do -if(__d.draw~=nil)then __d:draw()end end end end end end,updateTerm=function(dbc)if -(bca)and not(dca)then return false end;abb.update()end,addObject=function(dbc,_cc)return -cdb(_cc)end,removeObject=__c,getObject=function(dbc,_cc)return adb(_cc)end,getDeepObject=function(dbc,_cc)return bdb(_cc)end,addFrame=function(dbc,_cc)local acc=c_a.newFrame( -_cc or cc(),dbc,nil,c_a)return cdb(acc)end,init=function(dbc) -if -not(cab)then -if(a_a~=nil)then d_a.width,d_a.height=a_a:getSize() -dbc:setBackground(a_a:getTheme("FrameBG")) -dbc:setForeground(a_a:getTheme("FrameText"))else d_a.width,d_a.height=_ca.getSize() -dbc:setBackground(c_a.getTheme("BasaltBG")) -dbc:setForeground(c_a.getTheme("BasaltText"))end;cab=true end end} -for dbc,_cc in pairs(cb)do caa["add"..dbc]=function(acc,bcc) -return cdb(_cc(bcc or cc(),acc))end end;setmetatable(caa,d_a)return caa end end -aa["Object"]=function(...)local ab=da("basaltEvent")local bb=da("utils") -local cb=da("module")local db=cb("images")local _c=bb.splitString;local ac=bb.numberFromString -local bc=bb.getValueFromXML;local cc,dc=table.unpack,string.sub -return -function(_d)local ad="Object"local bd={}local cd=1;local dd -local __a="topLeft"local a_a=false;local b_a=true;local c_a=false;local d_a=false;local _aa=false;local aaa=false -local baa={left=false,right=false,top=false,bottom=false}local caa=colors.black;local daa=true;local _ba=false;local aba,bba,cba,dba=0,0,0,0;local _ca;local aca;local bca=1;local cca -local dca;local _da=true;local ada=true;local bda={}local cda=ab() -bd={x=1,y=1,width=1,height=1,bgColor=colors.black,bgSymbol=" ",bgSymbolColor=colors.black,fgColor=colors.white,transparentColor=false,name=_d or"Object",parent= -nil,show=function(dda)b_a=true;dda:updateDraw()return dda end,hide=function(dda)b_a=false -dda:updateDraw()return dda end,enable=function(dda)daa=true;return dda end,disable=function(dda)daa=false -return dda end,isEnabled=function(dda)return daa end,generateXMLEventFunction=function(dda,__b,a_b) -local b_b=function(c_b) -if(c_b:sub(1,1)=="#")then -local d_b=dda:getBaseFrame():getDeepObject(c_b:sub(2,c_b:len())) -if(d_b~=nil)and(d_b.internalObjetCall~=nil)then __b(dda,function() -d_b:internalObjetCall()end)end else -__b(dda,dda:getBaseFrame():getVariable(c_b))end end;if(type(a_b)=="string")then b_b(a_b)elseif(type(a_b)=="table")then -for c_b,d_b in pairs(a_b)do b_b(d_b)end end;return dda end,setValuesByXMLData=function(dda,__b) -local a_b=dda:getBaseFrame()local b_b,c_b,d_b -if(bc("texture",__b)~=nil)then b_b=bc("texture",__b)end;if(bc("mode",__b)~=nil)then c_b=bc("mode",__b)end -if( -bc("texturePlay",__b)~=nil)then d_b=bc("texturePlay",__b)end;local _ab,aab;if(bc("x",__b)~=nil)then _ab=bc("x",__b)end;if( -bc("y",__b)~=nil)then aab=bc("y",__b)end;if -(_ab~=nil)or(aab~=nil)then dda:setPosition(_ab,aab)end;local bab,cab;if( -bc("width",__b)~=nil)then bab=bc("width",__b)end;if( -bc("height",__b)~=nil)then cab=bc("height",__b)end;if(bab~=nil)or( -cab~=nil)then dda:setSize(bab,cab)end;if( -bc("bg",__b)~=nil)then -dda:setBackground(colors[bc("bg",__b)])end;if(bc("bgSymbol",__b)~=nil)then -dda:setBackground(dda.bgColor,bc("bgSymbol",__b))end;if -(bc("bgSymbolColor",__b)~=nil)then -dda:setBackground(dda.bgColor,dda.bgSymbol,colors[bc("bgSymbolColor",__b)])end -if -(bc("fg",__b)~=nil)then dda:setForeground(colors[bc("fg",__b)])end;if(bc("value",__b)~=nil)then -dda:setValue(colors[bc("value",__b)])end -if(bc("visible",__b)~=nil)then if -(bc("visible",__b))then dda:show()else dda:hide()end end -if(bc("enabled",__b)~=nil)then if(bc("enabled",__b))then dda:enable()else -dda:disable()end end;if(bc("zIndex",__b)~=nil)then -dda:setZIndex(bc("zIndex",__b))end;if(bc("anchor",__b)~=nil)then -dda:setAnchor(bc("anchor",__b))end;if(bc("shadowColor",__b)~=nil)then -dda:setShadow(colors[bc("shadowColor",__b)])end;if(bc("border",__b)~=nil)then -dda:setBorder(colors[bc("border",__b)])end;if(bc("borderLeft",__b)~=nil)then -baa["left"]=bc("borderLeft",__b)end;if(bc("borderTop",__b)~=nil)then -baa["top"]=bc("borderTop",__b)end;if(bc("borderRight",__b)~=nil)then -baa["right"]=bc("borderRight",__b)end;if(bc("borderBottom",__b)~=nil)then -baa["bottom"]=bc("borderBottom",__b)end;if(bc("borderColor",__b)~=nil)then -dda:setBorder(colors[bc("borderColor",__b)])end;if -(bc("ignoreOffset",__b)~=nil)then -if(bc("ignoreOffset",__b))then dda:ignoreOffset(true)end end;if -(bc("onClick",__b)~=nil)then -dda:generateXMLEventFunction(dda.onClick,bc("onClick",__b))end;if -(bc("onClickUp",__b)~=nil)then -dda:generateXMLEventFunction(dda.onClickUp,bc("onClickUp",__b))end;if -(bc("onScroll",__b)~=nil)then -dda:generateXMLEventFunction(dda.onScroll,bc("onScroll",__b))end;if -(bc("onDrag",__b)~=nil)then -dda:generateXMLEventFunction(dda.onDrag,bc("onDrag",__b))end;if(bc("onHover",__b)~=nil)then -dda:generateXMLEventFunction(dda.onHover,bc("onHover",__b))end;if -(bc("onLeave",__b)~=nil)then -dda:generateXMLEventFunction(dda.onLeave,bc("onLeave",__b))end;if(bc("onKey",__b)~=nil)then -dda:generateXMLEventFunction(dda.onKey,bc("onKey",__b))end;if(bc("onKeyUp",__b)~=nil)then -dda:generateXMLEventFunction(dda.onKeyUp,bc("onKeyUp",__b))end;if -(bc("onChange",__b)~=nil)then -dda:generateXMLEventFunction(dda.onChange,bc("onChange",__b))end;if -(bc("onResize",__b)~=nil)then -dda:generateXMLEventFunction(dda.onResize,bc("onResize",__b))end;if -(bc("onReposition",__b)~=nil)then -dda:generateXMLEventFunction(dda.onReposition,bc("onReposition",__b))end;if -(bc("onEvent",__b)~=nil)then -dda:generateXMLEventFunction(dda.onEvent,bc("onEvent",__b))end;if -(bc("onGetFocus",__b)~=nil)then -dda:generateXMLEventFunction(dda.onGetFocus,bc("onGetFocus",__b))end;if -(bc("onLoseFocus",__b)~=nil)then -dda:generateXMLEventFunction(dda.onLoseFocus,bc("onLoseFocus",__b))end;if(b_b~=nil)then -dda:setTexture(b_b,c_b,d_b)end;dda:updateDraw()return dda end,isVisible=function(dda)return -b_a end,setFocus=function(dda)if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return dda end,setZIndex=function(dda,__b) -cd=__b -if(dda.parent~=nil)then dda.parent:removeObject(dda) -dda.parent:addObject(dda)dda:updateEventHandlers()end;return dda end,updateEventHandlers=function(dda) -for __b,a_b in -pairs(bda)do if(a_b)then dda.parent:addEvent(__b,dda)end end end,getZIndex=function(dda)return cd end,getType=function(dda)return ad end,getName=function(dda)return -dda.name end,remove=function(dda)if(dda.parent~=nil)then -dda.parent:removeObject(dda)end;dda:updateDraw()return dda end,setParent=function(dda,__b) -if( -__b.getType~=nil and __b:getType()=="Frame")then -dda:remove()__b:addObject(dda)if(dda.draw)then dda:show()end end;return dda end,setValue=function(dda,__b,a_b)if( -dd~=__b)then dd=__b;dda:updateDraw()if(a_b~=false)then -dda:valueChangedHandler()end end -return dda end,getValue=function(dda)return dd end,getDraw=function(dda)return -ada end,updateDraw=function(dda,__b)ada=__b;if(__b==nil)then ada=true end;if(ada)then if(dda.parent~=nil)then -dda.parent:updateDraw()end end;return dda end,getEventSystem=function(dda)return -cda end,getParent=function(dda)return dda.parent end,setPosition=function(dda,__b,a_b,b_b) -if(type(__b)=="number")then dda.x= -b_b and dda:getX()+__b or __b end;if(type(a_b)=="number")then -dda.y=b_b and dda:getY()+a_b or a_b end -if(dda.parent~=nil)then if(type(__b)=="string")then -dda.x=dda.parent:newDynamicValue(dda,__b)end;if(type(a_b)=="string")then -dda.y=dda.parent:newDynamicValue(dda,a_b)end -dda.parent:recalculateDynamicValues()end;dda:customEventHandler("basalt_reposition") -dda:updateDraw()return dda end,getX=function(dda)return - -type(dda.x)=="number"and dda.x or math.floor(dda.x[1]+0.5)end,getY=function(dda)return - -type(dda.y)=="number"and dda.y or math.floor(dda.y[1]+0.5)end,getPosition=function(dda)return -dda:getX(),dda:getY()end,getVisibility=function(dda)return b_a end,setVisibility=function(dda,__b) -b_a=__b or not b_a;dda:updateDraw()return dda end,setSize=function(dda,__b,a_b,b_b)if(type(__b)== -"number")then -dda.width=b_b and dda:getWidth()+__b or __b end -if(type(a_b)=="number")then dda.height=b_b and -dda:getHeight()+a_b or a_b end -if(dda.parent~=nil)then if(type(__b)=="string")then -dda.width=dda.parent:newDynamicValue(dda,__b)end;if(type(a_b)=="string")then -dda.height=dda.parent:newDynamicValue(dda,a_b)end -dda.parent:recalculateDynamicValues()end;if(_ca~=nil)and(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]end -dda:customEventHandler("basalt_resize")dda:updateDraw()return dda end,getHeight=function(dda) -return -type(dda.height)=="number"and dda.height or -math.floor(dda.height[1]+0.5)end,getWidth=function(dda)return - -type(dda.width)=="number"and dda.width or math.floor(dda.width[1]+0.5)end,getSize=function(dda)return -dda:getWidth(),dda:getHeight()end,calculateDynamicValues=function(dda) -if( -type(dda.width)=="table")then dda.width:calculate()end -if(type(dda.height)=="table")then dda.height:calculate()end -if(type(dda.x)=="table")then dda.x:calculate()end -if(type(dda.y)=="table")then dda.y:calculate()end;dda:updateDraw()return dda end,setBackground=function(dda,__b,a_b,b_b)dda.bgColor= -__b or false -dda.bgSymbol=a_b or(dda.bgColor~=false and dda.bgSymbol or -false)dda.bgSymbolColor=b_b or dda.bgSymbolColor -dda:updateDraw()return dda end,setTexture=function(dda,__b,a_b,b_b)if( -type(__b)=="string")then _ca=db.loadImageAsBimg(__b)elseif(type(__b)=="table")then -_ca=__b end -if(_ca.animated)then local c_b=_ca[bca].duration or -_ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)dda.parent:addEvent("other_event",dda) -bda["other_event"]=true end;_da=b_b==false and false or true;bca=1 -dca=a_b or"normal"if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[1]else aca=_ca[1]end -dda:updateDraw()return dda end,setTransparent=function(dda,__b)dda.transparentColor= -__b or false;if(__b~=false)then dda.bgSymbol=false -dda.bgSymbolColor=false end;dda:updateDraw()return dda end,getBackground=function(dda)return -dda.bgColor end,setForeground=function(dda,__b)dda.fgColor=__b or false -dda:updateDraw()return dda end,getForeground=function(dda)return dda.fgColor end,setShadow=function(dda,__b)if( -__b==false)then aaa=false else caa=__b;aaa=true end -dda:updateDraw()return dda end,isShadowActive=function(dda)return aaa end,setBorder=function(dda,...) -if( -...~=nil)then local __b={...} -for a_b,b_b in pairs(__b)do if(b_b=="left")or(#__b==1)then -baa["left"]=__b[1]end;if(b_b=="top")or(#__b==1)then -baa["top"]=__b[1]end;if(b_b=="right")or(#__b==1)then -baa["right"]=__b[1]end;if(b_b=="bottom")or(#__b==1)then -baa["bottom"]=__b[1]end end end;dda:updateDraw()return dda end,getBorder=function(dda,__b)if( -__b=="left")then return borderLeft end -if(__b=="top")then return borderTop end;if(__b=="right")then return borderRight end;if(__b=="bottom")then -return borderBottom end end,draw=function(dda) -if -(b_a)then -if(dda.parent~=nil)then local __b,a_b=dda:getAnchorPosition() -local b_b,c_b=dda:getSize()local d_b,_ab=dda.parent:getSize() -if(__b+b_b<1)or(__b>d_b)or(a_b+ -c_b<1)or(a_b>_ab)then return false end;if(dda.transparentColor~=false)then -dda.parent:drawForegroundBox(__b,a_b,b_b,c_b,dda.transparentColor)end;if(dda.bgColor~=false)then -dda.parent:drawBackgroundBox(__b,a_b,b_b,c_b,dda.bgColor)end -if(dda.bgSymbol~=false)then -dda.parent:drawTextBox(__b,a_b,b_b,c_b,dda.bgSymbol)if(dda.bgSymbol~=" ")then -dda.parent:drawForegroundBox(__b,a_b,b_b,c_b,dda.bgSymbolColor)end end -if(aca~=nil)then -if(dca=="center")then local bab,cab=#aca[1][1],#aca -local dab=bab__b)and(c_b<=a_b)and(c_b+_ab>a_b)then return true end end;return false end,mouseHandler=function(dda,__b,a_b,b_b,c_b) -if -(dda:isCoordsInObject(a_b,b_b))then local d_b,_ab=dda:getAbsolutePosition() -local aab=cda:sendEvent("mouse_click",dda,"mouse_click",__b,a_b- -(d_b-1),b_b- (_ab-1),a_b,b_b,c_b)if(aab==false)then return false end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;_aa=true;_ba=true;aba,bba=a_b,b_b;return true end;return false end,mouseUpHandler=function(dda,__b,a_b,b_b) -_ba=false -if(_aa)then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_release",dda,"mouse_release",__b,a_b- ( -c_b-1),b_b- (d_b-1),a_b,b_b)_aa=false end -if(dda:isCoordsInObject(a_b,b_b))then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_up",dda,"mouse_up",__b, -a_b- (c_b-1),b_b- (d_b-1),a_b,b_b)if(_ab==false)then return false end;return true end;return false end,dragHandler=function(dda,__b,a_b,b_b) -if -(_ba)then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_drag",dda,"mouse_drag",__b,a_b- (c_b-1), -b_b- (d_b-1),aba-a_b,bba-b_b,a_b,b_b)aba,bba=a_b,b_b;if(_ab~=nil)then return _ab end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return true end -if(dda:isCoordsInObject(a_b,b_b))then -local c_b,d_b=dda:getAbsolutePosition(dda:getAnchorPosition())aba,bba=a_b,b_b;cba,dba=c_b-a_b,d_b-b_b end;return false end,scrollHandler=function(dda,__b,a_b,b_b) -if -(dda:isCoordsInObject(a_b,b_b))then local c_b,d_b=dda:getAbsolutePosition() -local _ab=cda:sendEvent("mouse_scroll",dda,"mouse_scroll",__b,a_b- -(c_b-1),b_b- (d_b-1))if(_ab==false)then return false end;if(dda.parent~=nil)then -dda.parent:setFocusedObject(dda)end;return true end;return false end,hoverHandler=function(dda,__b,a_b,b_b) -if -(dda:isCoordsInObject(__b,a_b))then -local c_b=cda:sendEvent("mouse_hover",dda,"mouse_hover",__b,a_b,b_b)if(c_b==false)then return false end;d_a=true;return true end -if(d_a)then -local c_b=cda:sendEvent("mouse_leave",dda,"mouse_leave",__b,a_b,b_b)if(c_b==false)then return false end;d_a=false end;return false end,keyHandler=function(dda,__b,a_b)if -(daa)and(b_a)then -if(dda:isFocused())then -local b_b=cda:sendEvent("key",dda,"key",__b,a_b)if(b_b==false)then return false end;return true end end;return -false end,keyUpHandler=function(dda,__b)if -(daa)and(b_a)then -if(dda:isFocused())then -local a_b=cda:sendEvent("key_up",dda,"key_up",__b)if(a_b==false)then return false end;return true end end;return -false end,charHandler=function(dda,__b)if -(daa)and(b_a)then -if(dda:isFocused())then -local a_b=cda:sendEvent("char",dda,"char",__b)if(a_b==false)then return false end;return true end end;return -false end,valueChangedHandler=function(dda) -cda:sendEvent("value_changed",dda,dd)end,eventHandler=function(dda,__b,...)local a_b={...} -if -(__b=="timer")and(a_b[1]==cca)then -if(_ca[bca+1]~=nil)then bca=bca+1;if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]else aca=_ca[bca]end;local c_b=_ca[bca].duration or -_ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)else -if(_da)then bca=1;if(dca=="stretch")then -aca=db.resizeBIMG(_ca,dda:getSize())[1]else aca=_ca[1]end;local c_b= -_ca[1].duration or _ca.secondsPerFrame or 0.2 -cca=os.startTimer(c_b)end end;dda:updateDraw()end;local b_b=cda:sendEvent("other_event",dda,__b,...)if(b_b~=nil)then -return b_b end end,customEventHandler=function(dda,__b,...) -if -( -_ca~=nil)and(dca=="stretch")and(__b=="basalt_resize")then -aca=db.resizeBIMG(_ca,dda:getSize())[bca]dda:updateDraw()end;local a_b=cda:sendEvent("custom_event",dda,__b,...)if(a_b~=nil)then -return a_b end;return true end,getFocusHandler=function(dda) -local __b=cda:sendEvent("get_focus",dda)if(__b~=nil)then return __b end;return true end,loseFocusHandler=function(dda) -_ba=false;local __b=cda:sendEvent("lose_focus",dda) -if(__b~=nil)then return __b end;return true end,init=function(dda) -if -(dda.parent~=nil)then for __b,a_b in pairs(bda)do -if(a_b)then dda.parent:addEvent(__b,dda)end end end;if not(c_a)then c_a=true;return true end;return false end}bd.__index=bd;return bd end end;aa["objects"]={} -aa["objects"]["Input"]=function(...)local ab=da("Object") -local bb=da("utils")local cb=da("basaltLogs")local db=bb.getValueFromXML -return -function(_c)local ac=ab(_c)local bc="Input" -local cc="text"local dc=0;ac:setZIndex(5)ac:setValue("")ac.width=10;ac.height=1 -local _d=1;local ad=1;local bd=""local cd;local dd;local __a=bd;local a_a=false -local b_a={getType=function(c_a)return bc end,setInputType=function(c_a,d_a) -if(d_a=="password")or(d_a== -"number")or(d_a=="text")then cc=d_a end;c_a:updateDraw()return c_a end,setDefaultText=function(c_a,d_a,_aa,aaa) -bd=d_a;cd=aaa or cd;dd=_aa or dd -if(c_a:isFocused())then __a=""else __a=bd end;c_a:updateDraw()return c_a end,getInputType=function(c_a)return -cc end,setValue=function(c_a,d_a)ac.setValue(c_a,tostring(d_a)) -if not(a_a)then _d= -tostring(d_a):len()+1 -ad=math.max(1,_d-c_a:getWidth()+1)if(c_a:isFocused())then local _aa,aaa=c_a:getAnchorPosition() -c_a.parent:setCursor(true, -_aa+_d-ad,aaa+math.floor(c_a:getHeight()/2),c_a.fgColor)end end;c_a:updateDraw()return c_a end,getValue=function(c_a) -local d_a=ac.getValue(c_a) -return cc=="number"and tonumber(d_a)or d_a end,setInputLimit=function(c_a,d_a) -dc=tonumber(d_a)or dc;c_a:updateDraw()return c_a end,getInputLimit=function(c_a)return dc end,setValuesByXMLData=function(c_a,d_a) -ac.setValuesByXMLData(c_a,d_a)local _aa,aaa -if(db("defaultBG",d_a)~=nil)then _aa=db("defaultBG",d_a)end -if(db("defaultFG",d_a)~=nil)then aaa=db("defaultFG",d_a)end;if(db("default",d_a)~=nil)then -c_a:setDefaultText(db("default",d_a),aaa~=nil and colors[aaa], -_aa~=nil and colors[_aa])end -if(db("limit",d_a)~= -nil)then c_a:setInputLimit(db("limit",d_a))end;if(db("type",d_a)~=nil)then -c_a:setInputType(db("type",d_a))end;return c_a end,getFocusHandler=function(c_a) -ac.getFocusHandler(c_a) -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition()__a=""if(bd~="")then -c_a:updateDraw()end -c_a.parent:setCursor(true,d_a+_d-ad,_aa+math.max(math.ceil( -c_a:getHeight()/2 -1,1)),c_a.fgColor)end end,loseFocusHandler=function(c_a) -ac.loseFocusHandler(c_a)if(c_a.parent~=nil)then __a=bd;if(bd~="")then c_a:updateDraw()end -c_a.parent:setCursor(false)end end,keyHandler=function(c_a,d_a) -if -(ac.keyHandler(c_a,d_a))then local _aa,aaa=c_a:getSize()a_a=true -if(d_a==keys.backspace)then -local bba=tostring(ac.getValue())if(_d>1)then -c_a:setValue(bba:sub(1,_d-2)..bba:sub(_d,bba:len()))if(_d>1)then _d=_d-1 end -if(ad>1)then if(_dbba)then _d=bba+1 end;if(_d<1)then _d=1 end;if -(_d=_aa+ad)then ad=_d-_aa+1 end;if(ad<1)then ad=1 end end -if(d_a==keys.left)then _d=_d-1;if(_d>=1)then -if(_d=_aa+ad)then ad=_d end end;if(_d<1)then _d=1 end;if(ad<1)then ad=1 end end;local baa,caa=c_a:getAnchorPosition() -local daa=tostring(ac.getValue()) -local _ba=(_d<=daa:len()and _d-1 or daa:len())- (ad-1)local aba=c_a:getX() -if(_ba>aba+_aa-1)then _ba=aba+_aa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,baa+_ba,caa+ -math.max(math.ceil(aaa/2 -1,1)),c_a.fgColor)end -c_a:updateDraw()a_a=false;return true end;return false end,charHandler=function(c_a,d_a) -if -(ac.charHandler(c_a,d_a))then a_a=true;local _aa,aaa=c_a:getSize()local baa=ac.getValue() -if( -baa:len()0)then -if( -tonumber(ac.getValue())==nil)then c_a:setValue(cba)_d=_d-1 end end end else -c_a:setValue(baa:sub(1,_d-1)..d_a..baa:sub(_d,baa:len()))_d=_d+1 end;if(_d>=_aa+ad)then ad=ad+1 end end;local caa,daa=c_a:getAnchorPosition() -local _ba=tostring(ac.getValue()) -local aba=(_d<=_ba:len()and _d-1 or _ba:len())- (ad-1)local bba=c_a:getX() -if(aba>bba+_aa-1)then aba=bba+_aa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,caa+aba,daa+ -math.max(math.ceil(aaa/2 -1,1)),c_a.fgColor)end;a_a=false -c_a:updateDraw()return true end;return false end,mouseHandler=function(c_a,d_a,_aa,aaa) -if -(ac.mouseHandler(c_a,d_a,_aa,aaa))then local baa,caa=c_a:getAnchorPosition() -local daa,_ba=c_a:getAbsolutePosition(baa,caa)local aba,bba=c_a:getSize()_d=_aa-daa+ad;local cba=ac.getValue()if(_d> -cba:len())then _d=cba:len()+1 end;if(_d=baa+ad)then ad=(_d+1)-baa end -local daa,_ba=c_a:getAnchorPosition()local aba=tostring(ac.getValue()) -local bba=( -_d<=aba:len()and _d-1 or aba:len())- (ad-1)local cba=c_a:getX() -if(bba>cba+baa-1)then bba=cba+baa-1 end;if(c_a.parent~=nil)then -c_a.parent:setCursor(true,daa+bba,_ba+ -math.max(math.ceil(caa/2 -1,1)),c_a.fgColor)end -c_a:updateDraw()a_a=false end end end,draw=function(c_a) -if -(ac.draw(c_a))then -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -local aaa,baa=c_a:getSize()local caa=bb.getTextVerticalAlign(baa,"center")if -(c_a.bgColor~=false)then -c_a.parent:drawBackgroundBox(d_a,_aa,aaa,baa,c_a.bgColor)end -for n=1,baa do -if(n==caa)then -local daa=tostring(ac.getValue())local _ba=c_a.bgColor;local aba=c_a.fgColor;local bba;if(daa:len()<=0)then bba=__a -_ba=cd or _ba;aba=dd or aba end;bba=__a -if(daa~="")then bba=daa end;bba=bba:sub(ad,aaa+ad-1)local cba=aaa-bba:len()if(cba<0)then -cba=0 end;if(cc=="password")and(daa~="")then -bba=string.rep("*",bba:len())end -bba=bba..string.rep(c_a.bgSymbol,cba) -c_a.parent:writeText(d_a,_aa+ (n-1),bba,_ba,aba)end end;if(c_a:isFocused())then -c_a.parent:setCursor(true,d_a+_d-ad,_aa+ -math.floor(c_a:getHeight()/2),c_a.fgColor)end end end end,init=function(c_a) -if( -c_a.parent~=nil)then c_a.parent:addEvent("mouse_click",c_a) -c_a.parent:addEvent("key",c_a)c_a.parent:addEvent("char",c_a) -c_a.parent:addEvent("other_event",c_a)c_a.parent:addEvent("mouse_drag",c_a)end -if(ac.init(c_a))then -c_a.bgColor=c_a.parent:getTheme("InputBG")c_a.fgColor=c_a.parent:getTheme("InputText")end end}return setmetatable(b_a,ac)end end -aa["objects"]["Button"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=da("tHex") -return -function(_c)local ac=ab(_c)local bc="Button"local cc="center"local dc="center" -ac:setZIndex(5)ac:setValue("Button")ac.width=12;ac.height=3 -local _d={init=function(ad) -if(ac.init(ad))then -ad.bgColor=ad.parent:getTheme("ButtonBG")ad.fgColor=ad.parent:getTheme("ButtonText")end end,getType=function(ad)return bc end,setHorizontalAlign=function(ad,bd) -cc=bd;ad:updateDraw()return ad end,setVerticalAlign=function(ad,bd)dc=bd -ad:updateDraw()return ad end,setText=function(ad,bd)ac:setValue(tostring(bd)) -ad:updateDraw()return ad end,setValuesByXMLData=function(ad,bd) -ac.setValuesByXMLData(ad,bd) -if(cb("text",bd)~=nil)then ad:setText(cb("text",bd))end;if(cb("horizontalAlign",bd)~=nil)then -cc=cb("horizontalAlign",bd)end;if(cb("verticalAlign",bd)~=nil)then -dc=cb("verticalAlign",bd)end;return ad end,draw=function(ad) -if -(ac.draw(ad))then -if(ad.parent~=nil)then local bd,cd=ad:getAnchorPosition() -local dd,__a=ad:getSize()local a_a=bb.getTextVerticalAlign(__a,dc) -for n=1,__a do -if(n==a_a)then -local b_a=ad:getValue() -ad.parent:setText(bd+ (dd/2 -b_a:len()/2),cd+ (n-1),bb.getTextHorizontalAlign(b_a,b_a:len(),cc)) -ad.parent:setFG(bd+ (dd/2 -b_a:len()/2),cd+ (n-1),bb.getTextHorizontalAlign(db[ad.fgColor]:rep(b_a:len()),b_a:len(),cc))end end end end end}return setmetatable(_d,ac)end end -aa["objects"]["Graphic"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("utils").getValueFromXML;local db=da("bimg")local _c=da("images") -local ac,bc,cc,dc=string.sub,string.len,math.max,math.min -return -function(_d)local ad=ab(_d)local bd="Graphic"local cd=db()local dd=cd.getFrameObject(1)local __a -local a_a=1;ad:setZIndex(5)local b_a,c_a=0,0 -local d_a={getType=function(_aa)return bd end,setOffset=function(_aa,aaa,baa,caa) -if(caa)then -b_a=b_a+aaa or 0;c_a=c_a+baa or 0 else b_a=aaa or b_a;c_a=baa or c_a end;_aa:updateDraw()return _aa end,getOffset=function(_aa)return -b_a,c_a end,setValuesByXMLData=function(_aa,aaa)ad.setValuesByXMLData(_aa,aaa)return _aa end,selectFrame=function(_aa,aaa)if( -cd.getFrameObject(aaa)==nil)then cd.addFrame(aaa)end -dd=cd.getFrameObject(aaa)__a=dd.getImage(aaa)a_a=aaa;_aa:updateDraw()end,addFrame=function(_aa,aaa) -cd.addFrame(aaa)return _aa end,getFrameMetadata=function(_aa,aaa,baa)return cd.getFrameData(aaa,baa)end,setFrameMetadata=function(_aa,aaa,baa,caa) -cd.setFrameData(aaa,baa,caa)return _aa end,getMetadata=function(_aa,aaa)return cd.getMetadata(aaa)end,setMetadata=function(_aa,aaa,baa)return -cd.setMetadata(aaa,baa)end,getFrame=function(_aa,aaa)return cd.getFrame(aaa)end,getFrameObject=function(_aa,aaa)return -cd.getFrameObject(aaa)end,removeFrame=function(_aa,aaa)cd.removeFrame(aaa)return _aa end,moveFrame=function(_aa,aaa,baa) -cd.moveFrame(aaa,baa)return _aa end,getFrames=function(_aa)return cd.getFrames()end,getFrameCount=function(_aa)return -#cd.getFrames()end,getSelectedFrame=function(_aa)return a_a end,blit=function(_aa,aaa,baa,caa,daa,_ba) -x=daa or x;y=_ba or y;dd.blit(aaa,baa,caa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setText=function(_aa,aaa,baa,caa) -x=baa or x;y=caa or y;dd.text(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setBg=function(_aa,aaa,baa,caa)x=baa or x;y= -caa or y;dd.bg(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,setFg=function(_aa,aaa,baa,caa)x=baa or x;y=caa or -y;dd.fg(aaa,x,y)__a=dd.getImage() -_aa:updateDraw()return _aa end,getImageSize=function(_aa) -return cd.getSize()end,setImageSize=function(_aa,aaa,baa)cd.setSize(aaa,baa)__a=dd.getImage() -_aa:updateDraw()return _aa end,resizeImage=function(_aa,aaa,baa) -local caa=_c.resizeBIMG(cd.createBimg(),aaa,baa)cd=db(caa)a_a=1;dd=cd.getFrameObject(1)__a=dd.getImage() -_aa:updateDraw()return _aa end,loadImage=function(_aa,aaa) -if -(fs.exists(aaa))then local baa=_c.loadBIMG(aaa)cd=db(baa)a_a=1 -dd=cd.getFrameObject(1)__a=dd.getImage()_aa:updateDraw()end;return _aa end,clear=function(_aa) -cd=db()__a=nil;_aa:updateDraw()return _aa end,getImage=function(_aa)return -cd.createBimg()end,draw=function(_aa) -if(ad.draw(_aa))then -if(_aa.parent~=nil)then -local aaa,baa=_aa:getAnchorPosition()local caa,daa=_aa:getSize() -if(__a~=nil)then -for _ba,aba in pairs(__a)do if -(_ba<=daa-c_a)and(_ba+c_a>=1)then -_aa.parent:blit(aaa+b_a,baa+_ba-1 +c_a,aba[1],aba[2],aba[3])end end end end end end,init=function(_aa) -if -(ad.init(_aa))then _aa.bgColor=_aa.parent:getTheme("GraphicBG")end end}return setmetatable(d_a,ad)end end -aa["objects"]["Checkbox"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="Checkbox"_c:setZIndex(5) -_c:setValue(false)_c.width=1;_c.height=1;local bc="\42" -local cc={getType=function(dc)return ac end,setSymbol=function(dc,_d)bc=_d -dc:updateDraw()return dc end,mouseHandler=function(dc,_d,ad,bd) -if(_c.mouseHandler(dc,_d,ad,bd))then -if(_d==1)then -if( -dc:getValue()~=true)and(dc:getValue()~=false)then -dc:setValue(false)else dc:setValue(not dc:getValue())end;dc:updateDraw()return true end end;return false end,touchHandler=function(dc,_d,ad)return -dc:mouseHandler(1,_d,ad)end,setValuesByXMLData=function(dc,_d) -_c.setValuesByXMLData(dc,_d) -if(cb("checked",_d)~=nil)then if(cb("checked",_d))then dc:setValue(true)else -dc:setValue(false)end end;return dc end,draw=function(dc) -if -(_c.draw(dc))then -if(dc.parent~=nil)then local _d,ad=dc:getAnchorPosition() -local bd,cd=dc:getSize()local dd=bb.getTextVerticalAlign(cd,"center")if -(dc.bgColor~=false)then -dc.parent:drawBackgroundBox(_d,ad,bd,cd,dc.bgColor)end -for n=1,cd do -if(n==dd)then -if(dc:getValue()==true)then -dc.parent:writeText(_d, -ad+ (n-1),bb.getTextHorizontalAlign(bc,bd,"center"),dc.bgColor,dc.fgColor)else -dc.parent:writeText(_d,ad+ (n-1),bb.getTextHorizontalAlign(" ",bd,"center"),dc.bgColor,dc.fgColor)end end end end end end,init=function(dc) -dc.parent:addEvent("mouse_click",dc)dc.parent:addEvent("mouse_up",dc) -if(_c.init(dc))then -dc.bgColor=dc.parent:getTheme("CheckboxBG")dc.fgColor=dc.parent:getTheme("CheckboxText")end end}return setmetatable(cc,_c)end end -aa["objects"]["Label"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=bb.createText;local _c=da("tHex")local ac=da("bigfont") -return -function(bc)local cc=ab(bc) -local dc="Label"cc:setZIndex(3)local _d=true;cc:setValue("Label")cc.width=5 -local ad="left"local bd="top"local cd=0;local dd,__a=false,false -local a_a={getType=function(b_a)return dc end,setText=function(b_a,c_a)c_a=tostring(c_a) -cc:setValue(c_a) -if(_d)then local d_a=b_a.parent:getOffset() -if( -c_a:len()+b_a:getX()>b_a.parent:getWidth()+d_a)then local _aa= -b_a.parent:getWidth()+d_a-b_a:getX()cc.setSize(b_a,_aa, -#db(c_a,_aa))else -cc.setSize(b_a,c_a:len(),1)end end;b_a:updateDraw()return b_a end,setBackground=function(b_a,c_a) -cc.setBackground(b_a,c_a)__a=true;b_a:updateDraw()return b_a end,setForeground=function(b_a,c_a) -cc.setForeground(b_a,c_a)dd=true;b_a:updateDraw()return b_a end,setTextAlign=function(b_a,c_a,d_a)ad= -c_a or ad;bd=d_a or bd;b_a:updateDraw()return b_a end,setFontSize=function(b_a,c_a)if( -c_a>0)and(c_a<=4)then cd=c_a-1 or 0 end -b_a:updateDraw()return b_a end,getFontSize=function(b_a)return cd+1 end,setValuesByXMLData=function(b_a,c_a) -cc.setValuesByXMLData(b_a,c_a) -if(cb("text",c_a)~=nil)then b_a:setText(cb("text",c_a))end -if(cb("verticalAlign",c_a)~=nil)then bd=cb("verticalAlign",c_a)end;if(cb("horizontalAlign",c_a)~=nil)then -ad=cb("horizontalAlign",c_a)end;if(cb("font",c_a)~=nil)then -b_a:setFontSize(cb("font",c_a))end;return b_a end,setSize=function(b_a,c_a,d_a,_aa) -cc.setSize(b_a,c_a,d_a,_aa)_d=false;b_a:updateDraw()return b_a end,eventHandler=function(b_a,c_a) -if( -c_a=="basalt_resize")then -if(_d)then local d_a=b_a:getValue() -if( -d_a:len()+b_a:getX()>b_a.parent:getWidth())then local _aa= -b_a.parent:getWidth()-b_a:getX() -cc.setSize(b_a,_aa,#db(d_a,_aa))else cc.setSize(b_a,d_a:len(),1)end else end end end,draw=function(b_a) -if -(cc.draw(b_a))then -if(b_a.parent~=nil)then local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize()local baa=bb.getTextVerticalAlign(aaa,bd) -if(cd==0)then -if not(_d)then -local caa=db(b_a:getValue(),b_a:getWidth()) -for daa,_ba in pairs(caa)do if(daa<=aaa)then -b_a.parent:writeText(c_a,d_a+daa-1,_ba,b_a.bgColor,b_a.fgColor)end end else -if -(#b_a:getValue()+c_a>b_a.parent:getWidth())then local caa=db(b_a:getValue(),b_a:getWidth()) -for daa,_ba in -pairs(caa)do if(daa<=aaa)then -b_a.parent:writeText(c_a,d_a+daa-1,_ba,b_a.bgColor,b_a.fgColor)end end else -b_a.parent:writeText(c_a,d_a,b_a:getValue(),b_a.bgColor,b_a.fgColor)end end else -local caa=ac(cd,b_a:getValue(),b_a.fgColor,b_a.bgColor or colors.lightGray) -if(_d)then b_a:setSize(#caa[1][1],#caa[1]-1)end;local daa,_ba=b_a.parent:getSize() -local aba,bba=#caa[1][1],#caa[1] -c_a=c_a or math.floor((daa-aba)/2)+1 -d_a=d_a or math.floor((_ba-bba)/2)+1 -for i=1,bba do -b_a.parent:setFG(c_a,d_a+i-1,caa[2][i])b_a.parent:setBG(c_a,d_a+i-1,caa[3][i])b_a.parent:setText(c_a, -d_a+i-1,caa[1][i])end end end end end,init=function(b_a) -b_a.parent:addEvent("other_event",b_a) -if(cc.init(b_a))then -b_a.bgColor=b_a.parent:getTheme("LabelBG")b_a.fgColor=b_a.parent:getTheme("LabelText") -if -( -b_a.parent.bgColor==colors.black)and(b_a.fgColor==colors.black)then b_a.fgColor=colors.lightGray end end end}return setmetatable(a_a,cc)end end -aa["objects"]["Image"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML;local cb=da("images")local db,_c=table.unpack,string.sub -return -function(ac)local bc=ab(ac) -local cc="Image"bc:setZIndex(2)local dc;local _d;local ad=1;local bd=false;local cd;local dd=false;bc.width=24 -bc.height=8 -local function __a(b_a) -if(dc~=nil)then local c_a={} -for d_a,_aa in pairs(colors)do if(type(_aa)=="number")then -c_a[d_a]={term.nativePaletteColor(_aa)}end end;if(dc.palette~=nil)then -for d_a,_aa in pairs(dc.palette)do c_a[d_a]=tonumber(_aa)end end -if(dc[b_a]~=nil)and -(dc[b_a].palette~=nil)then for d_a,_aa in pairs(dc[b_a].palette)do -c_a[d_a]=tonumber(_aa)end end;return c_a end end -local a_a={init=function(b_a)if(bc.init(b_a))then -b_a.bgColor=b_a.parent:getTheme("ImageBG")end end,getType=function(b_a)return -cc end,loadImage=function(b_a,c_a,d_a)if not(fs.exists(c_a))then -error("No valid path: "..c_a)end;dc=cb.loadImageAsBimg(c_a,d_a) -ad=1;_d=dc;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()return b_a end,setImage=function(b_a,c_a) -dc=c_a;_d=dc;ad=1;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()return b_a end,usePalette=function(b_a,c_a)dd= -c_a~=nil and c_a or true;return b_a end,play=function(b_a,c_a) -if(dc.animated)then -local d_a= -dc[ad].duration or dc.secondsPerFrame or 0.2;b_a.parent:addEvent("other_event",b_a) -cd=os.startTimer(d_a)bd=c_a or false end;return b_a end,selectFrame=function(b_a,c_a)if( -dc[c_a]~=nil)then ad=c_a;if(cd~=nil)then os.cancelTimer(cd)end -b_a:updateDraw()end end,eventHandler=function(b_a,c_a,d_a,...) -bc.eventHandler(b_a,c_a,d_a,...) -if(c_a=="timer")then -if(d_a==cd)then -if(dc[ad+1]~=nil)then ad=ad+1;local _aa= -dc[ad].duration or dc.secondsPerFrame or 0.2 -cd=os.startTimer(_aa)else -if(bd)then ad=1 -local _aa=dc[ad].duration or dc.secondsPerFrame or 0.2;cd=os.startTimer(_aa)end end;b_a:updateDraw()end end end,getMetadata=function(b_a,c_a)return -dc[c_a]end,getImageSize=function(b_a)return dc.width,dc.height end,resizeImage=function(b_a,c_a,d_a) -_d=cb.resizeBIMG(dc,c_a,d_a)b_a:updateDraw()return b_a end,setValuesByXMLData=function(b_a,c_a) -bc.setValuesByXMLData(b_a,c_a) -if(bb("path",c_a)~=nil)then b_a:loadImage(bb("path",c_a))end;return b_a end,draw=function(b_a) -if -(bc.draw(b_a))then -if(_d~=nil)then if(dd)then -b_a:getBaseFrame():setThemeColor(__a(ad))end;local c_a,d_a=b_a:getAnchorPosition() -local _aa,aaa=b_a:getSize() -for baa,caa in ipairs(_d[ad])do local daa,_ba,aba=db(caa)daa=_c(daa,1,_aa) -_ba=_c(_ba,1,_aa)aba=_c(aba,1,_aa) -b_a.parent:blit(c_a,d_a+baa-1,daa,_ba,aba)if(baa==aaa)then break end end end end end}return setmetatable(a_a,bc)end end -aa["objects"]["Menubar"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML;local db=da("tHex") -return -function(_c)local ac=ab(_c)local bc="Menubar"local cc={}ac.width=30;ac.height=1 -ac:setZIndex(5)local dc={}local _d;local ad;local bd=true;local cd="left"local dd=0;local __a=1;local a_a=false -local function b_a()local c_a=0;local d_a=0 -local _aa=cc:getWidth() -for n=1,#dc do if(d_a+dc[n].text:len()+__a*2 >_aa)then -if( -d_a<_aa)then -c_a=c_a+ (dc[n].text:len()+__a*2 - (_aa-d_a))else c_a=c_a+dc[n].text:len()+__a*2 end end;d_a= -d_a+dc[n].text:len()+__a*2 end;return c_a end -cc={getType=function(c_a)return bc end,addItem=function(c_a,d_a,_aa,aaa,...) -table.insert(dc,{text=tostring(d_a),bgCol=_aa or c_a.bgColor,fgCol=aaa or c_a.fgColor,args={...}})if(#dc==1)then c_a:setValue(dc[1])end -c_a:updateDraw()return c_a end,getAll=function(c_a)return -dc end,getItemIndex=function(c_a)local d_a=c_a:getValue()for _aa,aaa in pairs(dc)do -if(aaa==d_a)then return _aa end end end,clear=function(c_a) -dc={}c_a:setValue({},false)c_a:updateDraw()return c_a end,setSpace=function(c_a,d_a)__a= -d_a or __a;c_a:updateDraw()return c_a end,setOffset=function(c_a,d_a)dd= -d_a or 0;if(dd<0)then dd=0 end;local _aa=b_a()if(dd>_aa)then dd=_aa end -c_a:updateDraw()return c_a end,getOffset=function(c_a)return dd end,setScrollable=function(c_a,d_a) -a_a=d_a;if(d_a==nil)then a_a=true end;return c_a end,setValuesByXMLData=function(c_a,d_a) -ac.setValuesByXMLData(c_a,d_a)if(cb("selectionBG",d_a)~=nil)then -_d=colors[cb("selectionBG",d_a)]end;if(cb("selectionFG",d_a)~=nil)then -ad=colors[cb("selectionFG",d_a)]end;if(cb("scrollable",d_a)~=nil)then -if -(cb("scrollable",d_a))then c_a:setScrollable(true)else c_a:setScrollable(false)end end -if( -cb("offset",d_a)~=nil)then c_a:setOffset(cb("offset",d_a))end -if(cb("space",d_a)~=nil)then __a=cb("space",d_a)end -if(d_a["item"]~=nil)then local _aa=d_a["item"] -if(_aa.properties~=nil)then _aa={_aa}end;for aaa,baa in pairs(_aa)do -c_a:addItem(cb("text",baa),colors[cb("bg",baa)],colors[cb("fg",baa)])end end;return c_a end,removeItem=function(c_a,d_a) -table.remove(dc,d_a)c_a:updateDraw()return c_a end,getItem=function(c_a,d_a) -return dc[d_a]end,getItemCount=function(c_a)return#dc end,editItem=function(c_a,d_a,_aa,aaa,baa,...)table.remove(dc,d_a) -table.insert(dc,d_a,{text=_aa,bgCol= -aaa or c_a.bgColor,fgCol=baa or c_a.fgColor,args={...}})c_a:updateDraw()return c_a end,selectItem=function(c_a,d_a)c_a:setValue( -dc[d_a]or{},false)c_a:updateDraw()return c_a end,setSelectedItem=function(c_a,d_a,_aa,aaa)_d= -d_a or c_a.bgColor;ad=_aa or c_a.fgColor;bd=aaa -c_a:updateDraw()return c_a end,mouseHandler=function(c_a,d_a,_aa,aaa) -if -(ac.mouseHandler(c_a,d_a,_aa,aaa))then -local baa,caa=c_a:getAbsolutePosition(c_a:getAnchorPosition())local daa,_ba=c_a:getSize()local aba=0 -for n=1,#dc do -if(dc[n]~=nil)then -if -(baa+aba<=_aa+dd)and(baa+aba+ -dc[n].text:len()+ (__a*2)>_aa+dd)and(caa==aaa)then -c_a:setValue(dc[n]) -c_a:getEventSystem():sendEvent(event,c_a,event,0,_aa,aaa,dc[n])end;aba=aba+dc[n].text:len()+__a*2 end end;c_a:updateDraw()return true end;return false end,scrollHandler=function(c_a,d_a,_aa,aaa) -if -(ac.scrollHandler(c_a,d_a,_aa,aaa))then if(a_a)then dd=dd+d_a;if(dd<0)then dd=0 end;local baa=b_a()if(dd>baa)then dd=baa end -c_a:updateDraw()end;return true end;return false end,draw=function(c_a) -if -(ac.draw(c_a))then -if(c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -local aaa,baa=c_a:getSize()if(c_a.bgColor~=false)then -c_a.parent:drawBackgroundBox(d_a,_aa,aaa,baa,c_a.bgColor)end;local caa=""local daa=""local _ba="" -for aba,bba in pairs(dc)do -local cba= -(" "):rep(__a)..bba.text.. (" "):rep(__a)caa=caa..cba -if(bba==c_a:getValue())then daa=daa.. -db[_d or bba.bgCol or c_a.bgColor]:rep(cba:len())_ba=_ba.. -db[ -ad or bba.FgCol or c_a.fgColor]:rep(cba:len())else daa=daa.. -db[bba.bgCol or c_a.bgColor]:rep(cba:len())_ba=_ba.. -db[bba.FgCol or c_a.fgColor]:rep(cba:len())end end -c_a.parent:setText(d_a,_aa,caa:sub(dd+1,aaa+dd)) -c_a.parent:setBG(d_a,_aa,daa:sub(dd+1,aaa+dd)) -c_a.parent:setFG(d_a,_aa,_ba:sub(dd+1,aaa+dd))end end end,init=function(c_a) -c_a.parent:addEvent("mouse_click",c_a)c_a.parent:addEvent("mouse_scroll",c_a) -if -(ac.init(c_a))then c_a.bgColor=c_a.parent:getTheme("MenubarBG") -c_a.fgColor=c_a.parent:getTheme("MenubarText")_d=c_a.parent:getTheme("SelectionBG") -ad=c_a.parent:getTheme("SelectionText")end end}return setmetatable(cc,ac)end end -aa["objects"]["Dropdown"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=da("utils").getValueFromXML -return -function(db)local _c=ab(db)local ac="Dropdown"_c.width=12;_c.height=1;_c:setZIndex(6) -local bc={}local cc;local dc;local _d=true;local ad="left"local bd=0;local cd=16;local dd=6;local __a="\16"local a_a="\31"local b_a=false -local c_a={getType=function(d_a)return -ac end,setValuesByXMLData=function(d_a,_aa)_c.setValuesByXMLData(d_a,_aa) -if( -cb("selectionBG",_aa)~=nil)then cc=colors[cb("selectionBG",_aa)]end;if(cb("selectionFG",_aa)~=nil)then -dc=colors[cb("selectionFG",_aa)]end;if(cb("dropdownWidth",_aa)~=nil)then -cd=cb("dropdownWidth",_aa)end;if(cb("dropdownHeight",_aa)~=nil)then -dd=cb("dropdownHeight",_aa)end;if(cb("offset",_aa)~=nil)then -bd=cb("offset",_aa)end -if(_aa["item"]~=nil)then local aaa=_aa["item"]if( -aaa.properties~=nil)then aaa={aaa}end;for baa,caa in pairs(aaa)do -d_a:addItem(cb("text",caa),colors[cb("bg",caa)],colors[cb("fg",caa)])end end end,setOffset=function(d_a,_aa) -bd=_aa;d_a:updateDraw()return d_a end,getOffset=function(d_a)return bd end,addItem=function(d_a,_aa,aaa,baa,...) -table.insert(bc,{text=_aa,bgCol= -aaa or d_a.bgColor,fgCol=baa or d_a.fgColor,args={...}})d_a:updateDraw()return d_a end,getAll=function(d_a)return -bc end,removeItem=function(d_a,_aa)table.remove(bc,_aa)d_a:updateDraw() -return d_a end,getItem=function(d_a,_aa)return bc[_aa]end,getItemIndex=function(d_a) -local _aa=d_a:getValue()for aaa,baa in pairs(bc)do if(baa==_aa)then return aaa end end end,clear=function(d_a) -bc={}d_a:setValue({},false)d_a:updateDraw()return d_a end,getItemCount=function(d_a)return -#bc end,editItem=function(d_a,_aa,aaa,baa,caa,...)table.remove(bc,_aa) -table.insert(bc,_aa,{text=aaa,bgCol=baa or d_a.bgColor,fgCol= -caa or d_a.fgColor,args={...}})d_a:updateDraw()return d_a end,selectItem=function(d_a,_aa)d_a:setValue( -bc[_aa]or{},false)d_a:updateDraw()return d_a end,setSelectedItem=function(d_a,_aa,aaa,baa)cc= -_aa or d_a.bgColor;dc=aaa or d_a.fgColor -_d=baa~=nil and baa;d_a:updateDraw()return d_a end,setDropdownSize=function(d_a,_aa,aaa) -cd,dd=_aa,aaa;d_a:updateDraw()return d_a end,getDropdownSize=function(d_a)return cd,dd end,mouseHandler=function(d_a,_aa,aaa,baa) -if -(b_a)then -local caa,daa=d_a:getAbsolutePosition(d_a:getAnchorPosition()) -if(_aa==1)then -if(#bc>0)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(caa<=aaa)and(caa+cd>aaa)and -(daa+n==baa)then d_a:setValue(bc[n+bd]) -d_a:updateDraw() -local _ba=d_a:getEventSystem():sendEvent("mouse_click",d_a,"mouse_click",dir,aaa,baa)if(_ba==false)then return _ba end;return true end end end end end end -if(_c.mouseHandler(d_a,_aa,aaa,baa))then b_a=(not b_a)d_a:updateDraw() -return true else if(b_a)then d_a:updateDraw()b_a=false end;return false end end,mouseUpHandler=function(d_a,_aa,aaa,baa) -if -(b_a)then -local caa,daa=d_a:getAbsolutePosition(d_a:getAnchorPosition()) -if(_aa==1)then -if(#bc>0)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(caa<=aaa)and(caa+cd>aaa)and -(daa+n==baa)then b_a=false;d_a:updateDraw() -local _ba=d_a:getEventSystem():sendEvent("mouse_up",d_a,"mouse_up",dir,aaa,baa)if(_ba==false)then return _ba end;return true end end end end end end end,scrollHandler=function(d_a,_aa,aaa,baa) -if -(b_a)and(d_a:isFocused())then bd=bd+_aa;if(bd<0)then bd=0 end;if(_aa==1)then -if(#bc>dd)then if(bd> -#bc-dd)then bd=#bc-dd end else bd=math.min(#bc-1,0)end end -local caa=d_a:getEventSystem():sendEvent("mouse_scroll",d_a,"mouse_scroll",_aa,aaa,baa)if(caa==false)then return caa end;d_a:updateDraw()return true end end,draw=function(d_a) -if -(_c.draw(d_a))then local _aa,aaa=d_a:getAnchorPosition()local baa,caa=d_a:getSize() -if( -d_a.parent~=nil)then if(d_a.bgColor~=false)then -d_a.parent:drawBackgroundBox(_aa,aaa,baa,caa,d_a.bgColor)end;local daa=d_a:getValue() -local _ba=bb.getTextHorizontalAlign(( -daa~=nil and daa.text or""),baa,ad):sub(1, -baa-1).. (b_a and a_a or __a) -d_a.parent:writeText(_aa,aaa,_ba,d_a.bgColor,d_a.fgColor) -if(b_a)then -for n=1,dd do -if(bc[n+bd]~=nil)then -if(bc[n+bd]==daa)then -if(_d)then -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[ -n+bd].text,cd,ad),cc,dc)else -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[n+bd].text,cd,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end else -d_a.parent:writeText(_aa,aaa+n,bb.getTextHorizontalAlign(bc[n+bd].text,cd,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end end end end end end end,init=function(d_a) -d_a.parent:addEvent("mouse_click",d_a)d_a.parent:addEvent("mouse_up",d_a) -d_a.parent:addEvent("mouse_scroll",d_a) -if(_c.init(d_a))then -d_a.bgColor=d_a.parent:getTheme("DropdownBG")d_a.fgColor=d_a.parent:getTheme("DropdownText") -cc=d_a.parent:getTheme("SelectionBG")dc=d_a.parent:getTheme("SelectionText")end end}return setmetatable(c_a,_c)end end -aa["objects"]["Animation"]=function(...)local ab=da("utils").getValueFromXML -local bb=da("basaltEvent") -local cb,db,_c,ac,bc,cc=math.floor,math.sin,math.cos,math.pi,math.sqrt,math.pow -local dc=function(cab,dab,_bb)return cab+ (dab-cab)*_bb end;local _d=function(cab)return cab end -local ad=function(cab)return 1 -cab end;local bd=function(cab)return cab*cab*cab end;local cd=function(cab)return -ad(bd(ad(cab)))end;local dd=function(cab)return -dc(bd(cab),cd(cab),cab)end;local __a=function(cab)return -db((cab*ac)/2)end;local a_a=function(cab)return -ad(_c((cab*ac)/2))end;local b_a=function(cab)return -- (_c(ac*x)-1)/2 end -local c_a=function(cab) -local dab=1.70158;local _bb=dab+1;return _bb*cab^3 -dab*cab^2 end;local d_a=function(cab)return cab^3 end -local _aa=function(cab)local dab=(2 *ac)/3;return - -cab==0 and 0 or(cab==1 and 1 or(-2 ^ (10 *cab-10)* -db((cab*10 -10.75)*dab)))end -local function aaa(cab)return cab==0 and 0 or 2 ^ (10 *cab-10)end -local function baa(cab)return cab==0 and 0 or 2 ^ (10 *cab-10)end -local function caa(cab)local dab=1.70158;local _bb=dab*1.525;return -cab<0.5 and( (2 *cab)^2 * -( (_bb+1)*2 *cab-_bb))/2 or -( -(2 *cab-2)^2 * ( (_bb+1)* (cab*2 -2)+_bb)+2)/2 end;local function daa(cab)return -cab<0.5 and 4 *cab^3 or 1 - (-2 *cab+2)^3 /2 end -local function _ba(cab) -local dab=(2 *ac)/4.5 -return -cab==0 and 0 or(cab==1 and 1 or -( -cab<0.5 and- (2 ^ (20 *cab-10)* -db((20 *cab-11.125)*dab))/2 or -(2 ^ (-20 *cab+10)*db((20 *cab-11.125)*dab))/2 +1))end -local function aba(cab)return -cab==0 and 0 or(cab==1 and 1 or -( -cab<0.5 and 2 ^ (20 *cab-10)/2 or(2 -2 ^ (-20 *cab+10))/2))end;local function bba(cab)return -cab<0.5 and 2 *cab^2 or 1 - (-2 *cab+2)^2 /2 end;local function cba(cab)return -cab<0.5 and 8 * -cab^4 or 1 - (-2 *cab+2)^4 /2 end;local function dba(cab)return -cab<0.5 and 16 * -cab^5 or 1 - (-2 *cab+2)^5 /2 end;local function _ca(cab) -return cab^2 end;local function aca(cab)return cab^4 end -local function bca(cab)return cab^5 end;local function cca(cab)local dab=1.70158;local _bb=dab+1;return -1 +_bb* (cab-1)^3 +dab* (cab-1)^2 end;local function dca(cab)return 1 - -(1 -cab)^3 end -local function _da(cab)local dab=(2 *ac)/3;return - -cab==0 and 0 or(cab==1 and 1 or( -2 ^ (-10 *cab)*db((cab*10 -0.75)*dab)+1))end -local function ada(cab)return cab==1 and 1 or 1 -2 ^ (-10 *cab)end;local function bda(cab)return 1 - (1 -cab)* (1 -cab)end;local function cda(cab)return 1 - ( -1 -cab)^4 end;local function dda(cab) -return 1 - (1 -cab)^5 end -local function __b(cab)return 1 -bc(1 -cc(cab,2))end;local function a_b(cab)return bc(1 -cc(cab-1,2))end -local function b_b(cab)return - -cab<0.5 and(1 -bc( -1 -cc(2 *cab,2)))/2 or(bc(1 -cc(-2 *cab+2,2))+1)/2 end -local function c_b(cab)local dab=7.5625;local _bb=2.75 -if(cab<1 /_bb)then return dab*cab*cab elseif(cab<2 /_bb)then local abb=cab- -1.5 /_bb;return dab*abb*abb+0.75 elseif(cab<2.5 /_bb)then local abb=cab- -2.25 /_bb;return dab*abb*abb+0.9375 else -local abb=cab-2.625 /_bb;return dab*abb*abb+0.984375 end end;local function d_b(cab)return 1 -c_b(1 -cab)end;local function _ab(cab)return -x<0.5 and(1 - -c_b(1 -2 *cab))/2 or(1 +c_b(2 *cab-1))/2 end -local aab={linear=_d,lerp=dc,flip=ad,easeIn=bd,easeInSine=a_a,easeInBack=c_a,easeInCubic=d_a,easeInElastic=_aa,easeInExpo=baa,easeInQuad=_ca,easeInQuart=aca,easeInQuint=bca,easeInCirc=__b,easeInBounce=d_b,easeOut=cd,easeOutSine=__a,easeOutBack=cca,easeOutCubic=dca,easeOutElastic=_da,easeOutExpo=ada,easeOutQuad=bda,easeOutQuart=cda,easeOutQuint=dda,easeOutCirc=a_b,easeOutBounce=c_b,easeInOut=dd,easeInOutSine=b_a,easeInOutBack=caa,easeInOutCubic=daa,easeInOutElastic=_ba,easeInOutExpo=aba,easeInOutQuad=bba,easeInOutQuart=cba,easeInOutQuint=dba,easeInOutCirc=b_b,easeInOutBounce=_ab}local bab={} -return -function(cab)local dab={}local _bb="Animation"local abb;local bbb={}local cbb=0;local dbb=false;local _cb=1;local acb=false -local bcb=bb()local ccb=0;local dcb;local _db=false;local adb=false;local bdb="easeOut"local cdb;local function ddb(c_c)for d_c,_ac in pairs(c_c)do -_ac(dab,bbb[_cb].t,_cb)end end -local function __c(c_c)if(_cb==1)then -c_c:animationStartHandler()end;if(bbb[_cb]~=nil)then ddb(bbb[_cb].f) -cbb=bbb[_cb].t end;_cb=_cb+1 -if(bbb[_cb]==nil)then if(acb)then _cb=1;cbb=0 else -c_c:animationDoneHandler()return end end;if(bbb[_cb].t>0)then -abb=os.startTimer(bbb[_cb].t-cbb)else __c(c_c)end end -local function a_c(c_c,d_c)for n=1,#bbb do -if(bbb[n].t==c_c)then table.insert(bbb[n].f,d_c)return end end -for n=1,#bbb do -if(bbb[n].t>c_c)then if -(bbb[n-1]~=nil)then if(bbb[n-1].t=_ac-0.01)then if(bab[dac][dbc]==_bc)then bab[dac][dbc]= -nil end end end end)end end -dab={name=cab,getType=function(c_c)return _bb end,getBaseFrame=function(c_c)if(c_c.parent~=nil)then -return c_c.parent:getBaseFrame()end;return c_c end,setMode=function(c_c,d_c) -bdb=d_c;return c_c end,addMode=function(c_c,d_c,_ac)aab[d_c]=_ac;return c_c end,generateXMLEventFunction=function(c_c,d_c,_ac) -local aac=function(bac) -if( -bac:sub(1,1)=="#")then -local cac=c_c:getBaseFrame():getDeepObject(bac:sub(2,bac:len())) -if(cac~=nil)and(cac.internalObjetCall~=nil)then d_c(c_c,function() -cac:internalObjetCall()end)end else -d_c(c_c,c_c:getBaseFrame():getVariable(bac))end end;if(type(_ac)=="string")then aac(_ac)elseif(type(_ac)=="table")then -for bac,cac in pairs(_ac)do aac(cac)end end;return c_c end,setValuesByXMLData=function(c_c,d_c)_db= -ab("loop",d_c)==true and true or false -if( -ab("object",d_c)~=nil)then -local _ac=c_c:getBaseFrame():getDeepObject(ab("object",d_c))if(_ac==nil)then -_ac=c_c:getBaseFrame():getVariable(ab("object",d_c))end -if(_ac~=nil)then c_c:setObject(_ac)end end -if(d_c["move"]~=nil)then local _ac=ab("x",d_c["move"]) -local aac=ab("y",d_c["move"])local bac=ab("duration",d_c["move"]) -local cac=ab("time",d_c["move"])c_c:move(_ac,aac,bac,cac)end -if(d_c["size"]~=nil)then local _ac=ab("width",d_c["size"]) -local aac=ab("height",d_c["size"])local bac=ab("duration",d_c["size"]) -local cac=ab("time",d_c["size"])c_c:size(_ac,aac,bac,cac)end -if(d_c["offset"]~=nil)then local _ac=ab("x",d_c["offset"]) -local aac=ab("y",d_c["offset"])local bac=ab("duration",d_c["offset"]) -local cac=ab("time",d_c["offset"])c_c:offset(_ac,aac,bac,cac)end -if(d_c["textColor"]~=nil)then -local _ac=ab("duration",d_c["textColor"])local aac=ab("time",d_c["textColor"])local bac={} -local cac=d_c["textColor"]["color"] -if(cac~=nil)then if(cac.properties~=nil)then cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,colors[_bc:value()])end end;if(_ac~=nil)and(#bac>0)then -c_c:changeTextColor(_ac,aac or 0,table.unpack(bac))end end -if(d_c["background"]~=nil)then -local _ac=ab("duration",d_c["background"])local aac=ab("time",d_c["background"])local bac={} -local cac=d_c["background"]["color"] -if(cac~=nil)then if(cac.properties~=nil)then cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,colors[_bc:value()])end end;if(_ac~=nil)and(#bac>0)then -c_c:changeBackground(_ac,aac or 0,table.unpack(bac))end end -if(d_c["text"]~=nil)then local _ac=ab("duration",d_c["text"]) -local aac=ab("time",d_c["text"])local bac={}local cac=d_c["text"]["text"] -if(cac~=nil)then if(cac.properties~=nil)then -cac={cac}end;for dac,_bc in pairs(cac)do -table.insert(bac,_bc:value())end end;if(_ac~=nil)and(#bac>0)then -c_c:changeText(_ac,aac or 0,table.unpack(bac))end end;if(ab("onDone",d_c)~=nil)then -c_c:generateXMLEventFunction(c_c.onDone,ab("onDone",d_c))end;if(ab("onStart",d_c)~=nil)then -c_c:generateXMLEventFunction(c_c.onDone,ab("onStart",d_c))end -if -(ab("autoDestroy",d_c)~=nil)then if(ab("autoDestroy",d_c))then adb=true end end;bdb=ab("mode",d_c)or bdb -if(ab("play",d_c)~=nil)then if -(ab("play",d_c))then c_c:play(_db)end end;return c_c end,getZIndex=function(c_c)return -1 end,getName=function(c_c)return c_c.name end,setObject=function(c_c,d_c)cdb=d_c;return c_c end,move=function(c_c,d_c,_ac,aac,bac,cac)cdb= -cac or cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getPosition,cdb.setPosition,"position",c_c)return c_c end,offset=function(c_c,d_c,_ac,aac,bac,cac)cdb= -cac or cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getOffset,cdb.setOffset,"offset",c_c)return c_c end,size=function(c_c,d_c,_ac,aac,bac,cac)cdb=cac or -cdb -b_c(d_c,_ac,aac,bac or 0,cdb.getSize,cdb.setSize,"size",c_c)return c_c end,changeText=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setText(cdb,aac[n])end)end;return c_c end,changeBackground=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setBackground(cdb,aac[n])end)end;return c_c end,changeTextColor=function(c_c,d_c,_ac,...) -local aac={...}_ac=_ac or 0;cdb=obj or cdb;for n=1,#aac do -a_c(_ac+n* (d_c/#aac),function() -cdb.setForeground(cdb,aac[n])end)end;return c_c end,add=function(c_c,d_c,_ac) -dcb=d_c -a_c((_ac or ccb)+ -(bbb[#bbb]~=nil and bbb[#bbb].t or 0),d_c)return c_c end,wait=function(c_c,d_c)ccb=d_c;return c_c end,rep=function(c_c,d_c) -if( -dcb~=nil)then for n=1,d_c or 1 do -a_c((wait or ccb)+ -(bbb[#bbb]~=nil and bbb[#bbb].t or 0),dcb)end end;return c_c end,onDone=function(c_c,d_c) -bcb:registerEvent("animation_done",d_c)return c_c end,onStart=function(c_c,d_c) -bcb:registerEvent("animation_start",d_c)return c_c end,setAutoDestroy=function(c_c,d_c) -adb=d_c~=nil and d_c or true;return c_c end,animationDoneHandler=function(c_c) -bcb:sendEvent("animation_done",c_c)c_c.parent:removeEvent("other_event",c_c)if(adb)then -c_c.parent:removeObject(c_c)c_c=nil end end,animationStartHandler=function(c_c) -bcb:sendEvent("animation_start",c_c)end,clear=function(c_c)bbb={}dcb=nil;ccb=0;_cb=1;cbb=0;acb=false;return c_c end,play=function(c_c,d_c) -c_c:cancel()dbb=true;acb=d_c and true or false;_cb=1;cbb=0 -if(bbb[_cb]~=nil)then -if( -bbb[_cb].t>0)then abb=os.startTimer(bbb[_cb].t)else __c(c_c)end else c_c:animationDoneHandler()end;c_c.parent:addEvent("other_event",c_c)return c_c end,cancel=function(c_c)if( -abb~=nil)then os.cancelTimer(abb)acb=false end -dbb=false;c_c.parent:removeEvent("other_event",c_c)return c_c end,internalObjetCall=function(c_c) -c_c:play(_db)end,eventHandler=function(c_c,d_c,_ac)if(dbb)then -if(d_c=="timer")and(_ac==abb)then if(bbb[_cb]~=nil)then -__c(c_c)else c_c:animationDoneHandler()end end end end}dab.__index=dab;return dab end end -aa["objects"]["List"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="List"_c.width=16;_c.height=6;_c:setZIndex(5)local bc={} -local cc;local dc;local _d=true;local ad="left"local bd=0;local cd=true -local dd={getType=function(__a)return ac end,addItem=function(__a,a_a,b_a,c_a,...) -table.insert(bc,{text=a_a,bgCol=b_a or __a.bgColor,fgCol= -c_a or __a.fgColor,args={...}})if(#bc<=1)then __a:setValue(bc[1],false)end -__a:updateDraw()return __a end,setOffset=function(__a,a_a) -bd=a_a;__a:updateDraw()return __a end,getOffset=function(__a)return bd end,removeItem=function(__a,a_a) -table.remove(bc,a_a)__a:updateDraw()return __a end,getItem=function(__a,a_a) -return bc[a_a]end,getAll=function(__a)return bc end,getItemIndex=function(__a)local a_a=__a:getValue()for b_a,c_a in pairs(bc)do if -(c_a==a_a)then return b_a end end end,clear=function(__a) -bc={}__a:setValue({},false)__a:updateDraw()return __a end,getItemCount=function(__a)return -#bc end,editItem=function(__a,a_a,b_a,c_a,d_a,...)table.remove(bc,a_a) -table.insert(bc,a_a,{text=b_a,bgCol=c_a or __a.bgColor,fgCol= -d_a or __a.fgColor,args={...}})__a:updateDraw()return __a end,selectItem=function(__a,a_a)__a:setValue( -bc[a_a]or{},false)__a:updateDraw()return __a end,setSelectedItem=function(__a,a_a,b_a,c_a)cc= -a_a or __a.bgColor;dc=b_a or __a.fgColor;_d=c_a~=nil and c_a or -true;__a:updateDraw()return __a end,setScrollable=function(__a,a_a) -cd=a_a;if(a_a==nil)then cd=true end;__a:updateDraw()return __a end,setValuesByXMLData=function(__a,a_a) -_c.setValuesByXMLData(__a,a_a)if(cb("selectionBG",a_a)~=nil)then -cc=colors[cb("selectionBG",a_a)]end;if(cb("selectionFG",a_a)~=nil)then -dc=colors[cb("selectionFG",a_a)]end;if(cb("scrollable",a_a)~=nil)then -if -(cb("scrollable",a_a))then __a:setScrollable(true)else __a:setScrollable(false)end end;if( -cb("offset",a_a)~=nil)then bd=cb("offset",a_a)end -if(a_a["item"]~= -nil)then local b_a=a_a["item"] -if(b_a.properties~=nil)then b_a={b_a}end;for c_a,d_a in pairs(b_a)do -__a:addItem(cb("text",d_a),colors[cb("bg",d_a)],colors[cb("fg",d_a)])end end;return __a end,scrollHandler=function(__a,a_a,b_a,c_a) -if -(_c.scrollHandler(__a,a_a,b_a,c_a))then -if(cd)then local d_a,_aa=__a:getSize()bd=bd+a_a;if(bd<0)then bd=0 end -if(a_a>=1)then if(#bc>_aa)then if(bd> -#bc-_aa)then bd=#bc-_aa end;if(bd>=#bc)then bd=#bc-1 end else bd= -bd-1 end end;__a:updateDraw()end;return true end;return false end,mouseHandler=function(__a,a_a,b_a,c_a) -if -(_c.mouseHandler(__a,a_a,b_a,c_a))then -local d_a,_aa=__a:getAbsolutePosition(__a:getAnchorPosition())local aaa,baa=__a:getSize() -if(#bc>0)then for n=1,baa do -if(bc[n+bd]~=nil)then if(d_a<=b_a)and -(d_a+aaa>b_a)and(_aa+n-1 ==c_a)then -__a:setValue(bc[n+bd])__a:updateDraw()end end end end;return true end;return false end,dragHandler=function(__a,a_a,b_a,c_a)return -__a:mouseHandler(a_a,b_a,c_a)end,touchHandler=function(__a,a_a,b_a)return -__a:mouseHandler(1,a_a,b_a)end,draw=function(__a) -if(_c.draw(__a))then -if -(__a.parent~=nil)then local a_a,b_a=__a:getAnchorPosition()local c_a,d_a=__a:getSize()if( -__a.bgColor~=false)then -__a.parent:drawBackgroundBox(a_a,b_a,c_a,d_a,__a.bgColor)end -for n=1,d_a do -if(bc[n+bd]~=nil)then -if(bc[n+bd]== -__a:getValue())then -if(_d)then -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),cc,dc)else -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end else -__a.parent:writeText(a_a,b_a+n-1,bb.getTextHorizontalAlign(bc[n+bd].text,c_a,ad),bc[ -n+bd].bgCol,bc[n+bd].fgCol)end end end end end end,init=function(__a) -__a.parent:addEvent("mouse_click",__a)__a.parent:addEvent("mouse_drag",__a) -__a.parent:addEvent("mouse_scroll",__a) -if(_c.init(__a))then __a.bgColor=__a.parent:getTheme("ListBG") -__a.fgColor=__a.parent:getTheme("ListText")cc=__a.parent:getTheme("SelectionBG") -dc=__a.parent:getTheme("SelectionText")end end}return setmetatable(dd,_c)end end -aa["objects"]["Pane"]=function(...)local ab=da("Object")local bb=da("basaltLogs") -return -function(cb) -local db=ab(cb)local _c="Pane" -local ac={getType=function(bc)return _c end,setBackground=function(bc,cc,dc,_d)db.setBackground(bc,cc,dc,_d) -return bc end,init=function(bc) -if(db.init(bc))then -bc.bgColor=bc.parent:getTheme("PaneBG")bc.fgColor=bc.parent:getTheme("PaneBG")end end}return setmetatable(ac,db)end end -aa["objects"]["Program"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("process")local db=da("utils").getValueFromXML;local _c=string.sub -return -function(ac,bc)local cc=ab(ac) -local dc="Program"cc:setZIndex(5)local _d;local ad;local bd={} -local function cd(baa,caa,daa,_ba,aba)local bba,cba=1,1 -local dba,_ca=colors.black,colors.white;local aca=false;local bca=false;local cca={}local dca={}local _da={}local ada={}local bda;local cda={}for i=0,15 do local abb=2 ^i -ada[abb]={bc:getBasaltInstance().getBaseTerm().getPaletteColour(abb)}end;local function dda() -bda=(" "):rep(daa) -for n=0,15 do local abb=2 ^n;local bbb=bb[abb]cda[abb]=bbb:rep(daa)end end -local function __b()dda()local abb=bda -local bbb=cda[colors.white]local cbb=cda[colors.black] -for n=1,_ba do -cca[n]=_c(cca[n]==nil and abb or cca[n]..abb:sub(1, -daa-cca[n]:len()),1,daa) -_da[n]=_c(_da[n]==nil and bbb or _da[n].. -bbb:sub(1,daa-_da[n]:len()),1,daa) -dca[n]=_c(dca[n]==nil and cbb or dca[n].. -cbb:sub(1,daa-dca[n]:len()),1,daa)end;cc.updateDraw(cc)end;__b()local function a_b()if -bba>=1 and cba>=1 and bba<=daa and cba<=_ba then else end end -local function b_b(abb,bbb,cbb) -local dbb=bba;local _cb=dbb+#abb-1 -if cba>=1 and cba<=_ba then -if dbb<=daa and _cb>=1 then -if dbb==1 and _cb== -daa then cca[cba]=abb;_da[cba]=bbb;dca[cba]=cbb else local acb,bcb,ccb -if dbb<1 then local __c= -1 -dbb+1;local a_c=daa-dbb+1;acb=_c(abb,__c,a_c) -bcb=_c(bbb,__c,a_c)ccb=_c(cbb,__c,a_c)elseif _cb>daa then local __c=daa-dbb+1;acb=_c(abb,1,__c) -bcb=_c(bbb,1,__c)ccb=_c(cbb,1,__c)else acb=abb;bcb=bbb;ccb=cbb end;local dcb=cca[cba]local _db=_da[cba]local adb=dca[cba]local bdb,cdb,ddb -if dbb>1 then local __c=dbb-1;bdb= -_c(dcb,1,__c)..acb;cdb=_c(_db,1,__c)..bcb -ddb=_c(adb,1,__c)..ccb else bdb=acb;cdb=bcb;ddb=ccb end -if _cb=1 and _cb<=_ba then -cca[newY]=cca[_cb]dca[newY]=dca[_cb]_da[newY]=_da[_cb]else cca[newY]=bbb -_da[newY]=cbb;dca[newY]=dbb end end end;if(bca)then a_b()end end,isColor=function()return -bc:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return -bc:getBasaltInstance().getBaseTerm().isColor()end,write=function(abb) -abb=tostring(abb)if(bca)then -b_b(abb,bb[_ca]:rep(abb:len()),bb[dba]:rep(abb:len()))end end,clearLine=function() -if -(bca)then c_b(1,cba,(" "):rep(daa)) -d_b(1,cba,bb[dba]:rep(daa))_ab(1,cba,bb[_ca]:rep(daa))end;if(bca)then a_b()end end,clear=function() -for n=1,_ba -do c_b(1,n,(" "):rep(daa)) -d_b(1,n,bb[dba]:rep(daa))_ab(1,n,bb[_ca]:rep(daa))end;if(bca)then a_b()end end,blit=function(abb,bbb,cbb)if -type(abb)~="string"then -error("bad argument #1 (expected string, got "..type(abb)..")",2)end;if type(bbb)~="string"then -error( -"bad argument #2 (expected string, got "..type(bbb)..")",2)end;if type(cbb)~="string"then -error( -"bad argument #3 (expected string, got "..type(cbb)..")",2)end -if -#bbb~=#abb or#cbb~=#abb then error("Arguments must be the same length",2)end;if(bca)then b_b(abb,bbb,cbb)end end}return _bb end;cc.width=30;cc.height=12;local dd=cd(1,1,cc.width,cc.height)local __a -local a_a=false;local b_a={} -local function c_a(baa)local caa,daa=dd.getCursorPos() -local _ba,aba=baa:getAnchorPosition()local bba,cba=baa:getSize() -if(_ba+caa-1 >=1 and -_ba+caa-1 <=_ba+bba-1 and daa+aba-1 >=1 and -daa+aba-1 <=aba+cba-1)then -baa.parent:setCursor( -baa:isFocused()and dd.getCursorBlink(),_ba+caa-1,daa+aba-1,dd.getTextColor())end end -local function d_a(baa,caa,...)local daa,_ba=__a:resume(caa,...) -if(daa==false)and(_ba~=nil)and -(_ba~="Terminated")then -local aba=baa:sendEvent("program_error",_ba) -if(aba~=false)then error("Basalt Program - ".._ba)end end -if(__a:getStatus()=="dead")then baa:sendEvent("program_done")end end -local function _aa(baa,caa,daa,_ba,aba)if(__a==nil)then return false end -if not(__a:isDead())then if not(a_a)then -local bba,cba=baa:getAbsolutePosition(baa:getAnchorPosition( -nil,nil,true))d_a(baa,caa,daa,_ba-bba+1,aba-cba+1) -c_a(baa)end end end -local function aaa(baa,caa,daa,_ba)if(__a==nil)then return false end -if not(__a:isDead())then if not(a_a)then if(baa.draw)then -d_a(baa,caa,daa,_ba)c_a(baa)end end end end -_d={getType=function(baa)return dc end,show=function(baa)cc.show(baa) -dd.setBackgroundColor(baa.bgColor)dd.setTextColor(baa.fgColor) -dd.basalt_setVisible(true)return baa end,hide=function(baa) -cc.hide(baa)dd.basalt_setVisible(false)return baa end,setPosition=function(baa,caa,daa,_ba) -cc.setPosition(baa,caa,daa,_ba) -dd.basalt_reposition(baa:getAnchorPosition())return baa end,setValuesByXMLData=function(baa,caa) -cc.setValuesByXMLData(baa,caa)if(db("path",caa)~=nil)then ad=db("path",caa)end -if( -db("execute",caa)~=nil)then if(db("execute",caa))then -if(ad~=nil)then baa:execute(ad)end end end end,getBasaltWindow=function()return -dd end,getBasaltProcess=function()return __a end,setSize=function(baa,caa,daa,_ba)cc.setSize(baa,caa,daa,_ba) -dd.basalt_resize(baa:getWidth(),baa:getHeight())return baa end,getStatus=function(baa)if(__a~=nil)then return -__a:getStatus()end;return"inactive"end,setEnviroment=function(baa,caa)bd= -caa or{}return baa end,execute=function(baa,caa,...)ad=caa or ad -__a=cb:new(ad,dd,bd,...)dd.setBackgroundColor(colors.black) -dd.setTextColor(colors.white)dd.clear()dd.setCursorPos(1,1) -dd.setBackgroundColor(baa.bgColor)dd.setTextColor(baa.fgColor) -dd.basalt_setVisible(true)d_a(baa)a_a=false -if(baa.parent~=nil)then -baa.parent:addEvent("mouse_click",baa)baa.parent:addEvent("mouse_up",baa) -baa.parent:addEvent("mouse_drag",baa)baa.parent:addEvent("mouse_scroll",baa) -baa.parent:addEvent("key",baa)baa.parent:addEvent("key_up",baa) -baa.parent:addEvent("char",baa)baa.parent:addEvent("other_event",baa)end;return baa end,stop=function(baa) -if( -__a~=nil)then -if not(__a:isDead())then d_a(baa,"terminate")if(__a:isDead())then -if( -baa.parent~=nil)then baa.parent:setCursor(false)end end end end;baa.parent:removeEvents(baa)return baa end,pause=function(baa,caa)a_a= -caa or(not a_a) -if(__a~=nil)then if not(__a:isDead())then if not(a_a)then -baa:injectEvents(b_a)b_a={}end end end;return baa end,isPaused=function(baa)return -a_a end,injectEvent=function(baa,caa,daa,_ba,aba,bba,cba) -if(__a~=nil)then -if not(__a:isDead())then if(a_a==false)or(cba)then -d_a(baa,caa,daa,_ba,aba,bba)else -table.insert(b_a,{event=caa,args={daa,_ba,aba,bba}})end end end;return baa end,getQueuedEvents=function(baa)return -b_a end,updateQueuedEvents=function(baa,caa)b_a=caa or b_a;return baa end,injectEvents=function(baa,caa)if(__a~=nil)then -if not -(__a:isDead())then for daa,_ba in pairs(caa)do -d_a(baa,_ba.event,table.unpack(_ba.args))end end end;return baa end,mouseHandler=function(baa,caa,daa,_ba) -if -(cc.mouseHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_click",caa,daa,_ba)return true end;return false end,mouseUpHandler=function(baa,caa,daa,_ba) -if -(cc.mouseUpHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_up",caa,daa,_ba)return true end;return false end,scrollHandler=function(baa,caa,daa,_ba) -if -(cc.scrollHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_scroll",caa,daa,_ba)return true end;return false end,dragHandler=function(baa,caa,daa,_ba) -if -(cc.dragHandler(baa,caa,daa,_ba))then _aa(baa,"mouse_drag",caa,daa,_ba)return true end;return false end,keyHandler=function(baa,caa,daa)if -(cc.keyHandler(baa,caa,daa))then aaa(baa,"key",caa,daa)return true end;return -false end,keyUpHandler=function(baa,caa)if -(cc.keyUpHandler(baa,caa))then aaa(baa,"key_up",caa)return true end -return false end,charHandler=function(baa,caa)if -(cc.charHandler(baa,caa))then aaa(baa,"char",caa)return true end -return false end,getFocusHandler=function(baa) -cc.getFocusHandler(baa) -if(__a~=nil)then -if not(__a:isDead())then -if not(a_a)then -if(baa.parent~=nil)then -local caa,daa=dd.getCursorPos()local _ba,aba=baa:getAnchorPosition()local bba,cba=baa:getSize() -if -( -_ba+caa-1 >=1 and _ba+caa-1 <=_ba+bba-1 and -daa+aba-1 >=1 and daa+aba-1 <=aba+cba-1)then -baa.parent:setCursor(dd.getCursorBlink(),_ba+caa-1,daa+aba-1,dd.getTextColor())end end end end end end,loseFocusHandler=function(baa) -cc.loseFocusHandler(baa) -if(__a~=nil)then if not(__a:isDead())then if(baa.parent~=nil)then -baa.parent:setCursor(false)end end end end,customEventHandler=function(baa,caa,...) -cc.customEventHandler(baa,caa,...)if(__a==nil)then return end -if(caa=="basalt_resize")then local daa,_ba=dd.getSize() -local aba,bba=baa:getSize() -if(daa~=aba)or(_ba~=bba)then dd.basalt_resize(aba,bba)if not -(__a:isDead())then d_a(baa,"term_resize")end end -dd.basalt_reposition(baa:getAnchorPosition())end end,eventHandler=function(baa,caa,daa,_ba,aba,bba) -cc.eventHandler(baa,caa,daa,_ba,aba,bba)if(__a==nil)then return end -if not(__a:isDead())then -if not(a_a)then if(caa~="terminate")then -d_a(baa,caa,daa,_ba,aba,bba)end -if(baa:isFocused())then -local cba,dba=baa:getAnchorPosition()local _ca,aca=dd.getCursorPos() -if(baa.parent~=nil)then -local bca,cca=baa:getSize() -if -(cba+_ca-1 >=1 and cba+_ca-1 <=cba+bca-1 and -aca+dba-1 >=1 and aca+dba-1 <=dba+cca-1)then -baa.parent:setCursor(dd.getCursorBlink(),cba+_ca-1,aca+dba-1,dd.getTextColor())end end;if(caa=="terminate")then d_a(baa,caa) -baa.parent:setCursor(false)return true end end else -table.insert(b_a,{event=caa,args={daa,_ba,aba,bba}})end end end,draw=function(baa) -if -(cc.draw(baa))then -if(baa.parent~=nil)then local caa,daa=baa:getAnchorPosition() -local _ba,aba=dd.getCursorPos()local bba,cba=baa:getSize()dd.basalt_reposition(caa,daa) -dd.basalt_update() -if -(caa+_ba-1 >=1 and caa+_ba-1 <=caa+bba-1 and -aba+daa-1 >=1 and aba+daa-1 <=daa+cba-1)then -baa.parent:setCursor(baa:isFocused()and dd.getCursorBlink(), -caa+_ba-1,aba+daa-1,dd.getTextColor())end end end end,onError=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("program_error",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)end;return baa end,onDone=function(baa,...) -for caa,daa in -pairs(table.pack(...))do if(type(daa)=="function")then -baa:registerEvent("program_done",daa)end end;if(baa.parent~=nil)then -baa.parent:addEvent("other_event",baa)end;return baa end,init=function(baa) -if -(cc.init(baa))then baa.bgColor=baa.parent:getTheme("ProgramBG")end end}return setmetatable(_d,cc)end end -aa["objects"]["Progressbar"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Progressbar"local ac=0;db:setZIndex(5) -db:setValue(false)db.width=25;db.height=1;local bc;local cc=""local dc=colors.white;local _d=""local ad=0 -local bd={init=function(cd) -if -(db.init(cd))then cd.bgColor=cd.parent:getTheme("ProgressbarBG") -cd.fgColor=cd.parent:getTheme("ProgressbarText")bc=cd.parent:getTheme("ProgressbarActiveBG")end end,getType=function(cd)return -_c end,setValuesByXMLData=function(cd,dd)db.setValuesByXMLData(cd,dd)if(bb("direction",dd)~= -nil)then ad=bb("direction",dd)end -if( -bb("progressColor",dd)~=nil)then bc=colors[bb("progressColor",dd)]end -if(bb("progressSymbol",dd)~=nil)then cc=bb("progressSymbol",dd)end;if(bb("backgroundSymbol",dd)~=nil)then -_d=bb("backgroundSymbol",dd)end -if -(bb("progressSymbolColor",dd)~=nil)then dc=colors[bb("progressSymbolColor",dd)]end;if(bb("onDone",dd)~=nil)then -cd:generateXMLEventFunction(cd.onProgressDone,bb("onDone",dd))end;return cd end,setDirection=function(cd,dd) -ad=dd;cd:updateDraw()return cd end,setProgressBar=function(cd,dd,__a,a_a)bc=dd or bc -cc=__a or cc;dc=a_a or dc;cd:updateDraw()return cd end,setBackgroundSymbol=function(cd,dd) -_d=dd:sub(1,1)cd:updateDraw()return cd end,setProgress=function(cd,dd)if -(dd>=0)and(dd<=100)and(ac~=dd)then ac=dd;cd:setValue(ac)if(ac==100)then -cd:progressDoneHandler()end end -cd:updateDraw()return cd end,getProgress=function(cd)return -ac end,onProgressDone=function(cd,dd)cd:registerEvent("progress_done",dd) -return cd end,progressDoneHandler=function(cd) -cd:sendEvent("progress_done",cd)end,draw=function(cd) -if(db.draw(cd))then -if(cd.parent~=nil)then -local dd,__a=cd:getAnchorPosition()local a_a,b_a=cd:getSize()if(cd.bgColor~=false)then -cd.parent:drawBackgroundBox(dd,__a,a_a,b_a,cd.bgColor)end;if(_d~="")then -cd.parent:drawTextBox(dd,__a,a_a,b_a,_d)end;if(cd.fgColor~=false)then -cd.parent:drawForegroundBox(dd,__a,a_a,b_a,cd.fgColor)end -if(ad==1)then cd.parent:drawBackgroundBox(dd,__a,a_a, -b_a/100 *ac,bc)cd.parent:drawForegroundBox(dd,__a,a_a, -b_a/100 *ac,dc)cd.parent:drawTextBox(dd,__a,a_a, -b_a/100 *ac,cc)elseif(ad==2)then -cd.parent:drawBackgroundBox(dd, -__a+math.ceil(b_a-b_a/100 *ac),a_a,b_a/100 *ac,bc) -cd.parent:drawForegroundBox(dd,__a+math.ceil(b_a-b_a/100 *ac),a_a, -b_a/100 *ac,dc) -cd.parent:drawTextBox(dd,__a+math.ceil(b_a-b_a/100 *ac),a_a, -b_a/100 *ac,cc)elseif(ad==3)then -cd.parent:drawBackgroundBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,bc) -cd.parent:drawForegroundBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,dc) -cd.parent:drawTextBox(dd+math.ceil(a_a-a_a/100 *ac),__a, -a_a/100 *ac,b_a,cc)else -cd.parent:drawBackgroundBox(dd,__a,a_a/100 *ac,b_a,bc) -cd.parent:drawForegroundBox(dd,__a,a_a/100 *ac,b_a,dc) -cd.parent:drawTextBox(dd,__a,a_a/100 *ac,b_a,cc)end end end end}return setmetatable(bd,db)end end -aa["objects"]["Scrollbar"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Scrollbar"db.width=1;db.height=8;db:setValue(1) -db:setZIndex(2)local ac="vertical"local bc=" "local cc;local dc="\127"local _d=db.height;local ad=1;local bd=1 -local function cd(__a,a_a,b_a,c_a) -local d_a,_aa=__a:getAbsolutePosition(__a:getAnchorPosition())local aaa,baa=__a:getSize() -if(ac=="horizontal")then -for _index=0,aaa do -if -(d_a+_index==b_a)and(_aa<=c_a)and(_aa+baa>c_a)then -ad=math.min(_index+1,aaa- (bd-1))__a:setValue(_d/aaa* (ad))__a:updateDraw()end end end -if(ac=="vertical")then -for _index=0,baa do -if -(_aa+_index==c_a)and(d_a<=b_a)and(d_a+aaa>b_a)then ad=math.min(_index+1,baa- (bd-1)) -__a:setValue(_d/baa* (ad))__a:updateDraw()end end end end -local dd={getType=function(__a)return _c end,setSymbol=function(__a,a_a)bc=a_a:sub(1,1)__a:updateDraw()return __a end,setValuesByXMLData=function(__a,a_a) -db.setValuesByXMLData(__a,a_a) -if(bb("maxValue",a_a)~=nil)then _d=bb("maxValue",a_a)end;if(bb("backgroundSymbol",a_a)~=nil)then -dc=bb("backgroundSymbol",a_a):sub(1,1)end;if(bb("symbol",a_a)~=nil)then -bc=bb("symbol",a_a):sub(1,1)end;if(bb("barType",a_a)~=nil)then -ac=bb("barType",a_a):lower()end;if(bb("symbolSize",a_a)~=nil)then -__a:setSymbolSize(bb("symbolSize",a_a))end;if(bb("symbolColor",a_a)~=nil)then -cc=colors[bb("symbolColor",a_a)]end;if(bb("index",a_a)~=nil)then -__a:setIndex(bb("index",a_a))end end,setIndex=function(__a,a_a) -ad=a_a;if(ad<1)then ad=1 end;local b_a,c_a=__a:getSize() -ad=math.min(ad,( -ac=="vertical"and c_a or b_a)- (bd-1)) -__a:setValue(_d/ (ac=="vertical"and c_a or b_a)*ad)__a:updateDraw()return __a end,getIndex=function(__a)return -ad end,setSymbolSize=function(__a,a_a)bd=tonumber(a_a)or 1 -local b_a,c_a=__a:getSize() -if(ac=="vertical")then -__a:setValue(ad-1 * (_d/ (c_a- (bd-1)))- (_d/ (c_a- -(bd-1))))elseif(ac=="horizontal")then -__a:setValue(ad-1 * (_d/ (b_a- (bd-1)))- (_d/ (b_a- ( -bd-1))))end;__a:updateDraw()return __a end,setMaxValue=function(__a,a_a) -_d=a_a;__a:updateDraw()return __a end,setBackgroundSymbol=function(__a,a_a) -dc=string.sub(a_a,1,1)__a:updateDraw()return __a end,setSymbolColor=function(__a,a_a)cc=a_a -__a:updateDraw()return __a end,setBarType=function(__a,a_a)ac=a_a:lower() -__a:updateDraw()return __a end,mouseHandler=function(__a,a_a,b_a,c_a)if(db.mouseHandler(__a,a_a,b_a,c_a))then -cd(__a,a_a,b_a,c_a)return true end;return false end,dragHandler=function(__a,a_a,b_a,c_a)if -(db.dragHandler(__a,a_a,b_a,c_a))then cd(__a,a_a,b_a,c_a)return true end -return false end,scrollHandler=function(__a,a_a,b_a,c_a) -if -(db.scrollHandler(__a,a_a,b_a,c_a))then local d_a,_aa=__a:getSize()ad=ad+a_a;if(ad<1)then ad=1 end -ad=math.min(ad,( -ac=="vertical"and _aa or d_a)- (bd-1)) -__a:setValue(_d/ (ac=="vertical"and _aa or d_a)*ad)__a:updateDraw()end end,draw=function(__a) -if -(db.draw(__a))then -if(__a.parent~=nil)then local a_a,b_a=__a:getAnchorPosition() -local c_a,d_a=__a:getSize() -if(ac=="horizontal")then -__a.parent:writeText(a_a,b_a,dc:rep(ad-1),__a.bgColor,__a.fgColor) -__a.parent:writeText(a_a+ad-1,b_a,bc:rep(bd),cc,cc) -__a.parent:writeText(a_a+ad+bd-1,b_a,dc:rep(c_a- (ad+bd-1)),__a.bgColor,__a.fgColor)end -if(ac=="vertical")then -for n=0,d_a-1 do -if(ad==n+1)then -for curIndexOffset=0,math.min(bd-1,d_a)do __a.parent:writeText(a_a,b_a+n+ -curIndexOffset,bc,cc,cc)end else if(n+1 ad-1 +bd)then -__a.parent:writeText(a_a,b_a+n,dc,__a.bgColor,__a.fgColor)end end end end end end end,init=function(__a) -__a.parent:addEvent("mouse_click",__a)__a.parent:addEvent("mouse_drag",__a) -__a.parent:addEvent("mouse_scroll",__a) -if(db.init(__a))then -__a.bgColor=__a.parent:getTheme("ScrollbarBG")__a.fgColor=__a.parent:getTheme("ScrollbarText") -cc=__a.parent:getTheme("ScrollbarSymbolColor")end end}return setmetatable(dd,db)end end -aa["objects"]["Radio"]=function(...)local ab=da("Object")local bb=da("utils") -local cb=bb.getValueFromXML -return -function(db)local _c=ab(db)local ac="Radio"_c.width=8;_c:setZIndex(5)local bc={}local cc;local dc -local _d;local ad;local bd;local cd;local dd=true;local __a="\7"local a_a="left" -local b_a={getType=function(c_a)return ac end,setValuesByXMLData=function(c_a,d_a) -_c.setValuesByXMLData(c_a,d_a)if(cb("selectionBG",d_a)~=nil)then -cc=colors[cb("selectionBG",d_a)]end;if(cb("selectionFG",d_a)~=nil)then -dc=colors[cb("selectionFG",d_a)]end;if(cb("boxBG",d_a)~=nil)then -_d=colors[cb("boxBG",d_a)]end;if(cb("inactiveBoxBG",d_a)~=nil)then -bd=colors[cb("inactiveBoxBG",d_a)]end;if(cb("inactiveBoxFG",d_a)~=nil)then -cd=colors[cb("inactiveBoxFG",d_a)]end;if(cb("boxFG",d_a)~=nil)then -ad=colors[cb("boxFG",d_a)]end;if(cb("symbol",d_a)~=nil)then -__a=cb("symbol",d_a)end -if(d_a["item"]~=nil)then local _aa=d_a["item"]if( -_aa.properties~=nil)then _aa={_aa}end;for aaa,baa in pairs(_aa)do -c_a:addItem(cb("text",baa),cb("x",baa),cb("y",baa),colors[cb("bg",baa)],colors[cb("fg",baa)])end end;return c_a end,addItem=function(c_a,d_a,_aa,aaa,baa,caa,...) -table.insert(bc,{x= -_aa or 1,y=aaa or 1,text=d_a,bgCol=baa or c_a.bgColor,fgCol=caa or c_a.fgColor,args={...}})if(#bc==1)then c_a:setValue(bc[1])end -c_a:updateDraw()return c_a end,getAll=function(c_a)return -bc end,removeItem=function(c_a,d_a)table.remove(bc,d_a)c_a:updateDraw() -return c_a end,getItem=function(c_a,d_a)return bc[d_a]end,getItemIndex=function(c_a) -local d_a=c_a:getValue()for _aa,aaa in pairs(bc)do if(aaa==d_a)then return _aa end end end,clear=function(c_a) -bc={}c_a:setValue({},false)c_a:updateDraw()return c_a end,getItemCount=function(c_a)return -#bc end,editItem=function(c_a,d_a,_aa,aaa,baa,caa,daa,...)table.remove(bc,d_a) -table.insert(bc,d_a,{x=aaa or 1,y=baa or 1,text=_aa,bgCol= -caa or c_a.bgColor,fgCol=daa or c_a.fgColor,args={...}})c_a:updateDraw()return c_a end,selectItem=function(c_a,d_a)c_a:setValue( -bc[d_a]or{},false)c_a:updateDraw()return c_a end,setActiveSymbol=function(c_a,d_a) -__a=d_a:sub(1,1)c_a:updateDraw()return c_a end,setSelectedItem=function(c_a,d_a,_aa,aaa,baa,caa) -cc=d_a or cc;dc=_aa or dc;_d=aaa or _d;ad=baa or ad -dd=caa~=nil and caa or true;c_a:updateDraw()return c_a end,mouseHandler=function(c_a,d_a,_aa,aaa) -if( -#bc>0)then -local baa,caa=c_a:getAbsolutePosition(c_a:getAnchorPosition()) -for daa,_ba in pairs(bc)do -if(baa+_ba.x-1 <=_aa)and( -baa+_ba.x-1 +_ba.text:len()+1 >=_aa)and( -caa+_ba.y-1 ==aaa)then -c_a:setValue(_ba) -local aba=c_a:getEventSystem():sendEvent("mouse_click",c_a,"mouse_click",d_a,_aa,aaa)if(aba==false)then return aba end;if(c_a.parent~=nil)then -c_a.parent:setFocusedObject(c_a)end;c_a:updateDraw()return true end end end;return false end,draw=function(c_a) -if( -c_a.parent~=nil)then local d_a,_aa=c_a:getAnchorPosition() -for aaa,baa in pairs(bc)do -if(baa== -c_a:getValue())then if(a_a=="left")then -c_a.parent:writeText(baa.x+d_a-1,baa.y+_aa-1,__a,_d,ad) -c_a.parent:writeText(baa.x+2 +d_a-1,baa.y+_aa-1,baa.text,cc,dc)end else -c_a.parent:drawBackgroundBox( -baa.x+d_a-1,baa.y+_aa-1,1,1,bd or c_a.bgColor) -c_a.parent:writeText(baa.x+2 +d_a-1,baa.y+_aa-1,baa.text,baa.bgCol,baa.fgCol)end end;return true end end,init=function(c_a) -c_a.parent:addEvent("mouse_click",c_a) -if(_c.init(c_a))then -c_a.bgColor=c_a.parent:getTheme("MenubarBG")c_a.fgColor=c_a.parent:getTheme("MenubarFG") -cc=c_a.parent:getTheme("SelectionBG")dc=c_a.parent:getTheme("SelectionText") -_d=c_a.parent:getTheme("MenubarBG")ad=c_a.parent:getTheme("MenubarText")end end}return setmetatable(b_a,_c)end end -aa["objects"]["Slider"]=function(...)local ab=da("Object") -local bb=da("basaltLogs")local cb=da("utils").getValueFromXML -return -function(db)local _c=ab(db)local ac="Slider" -_c.width=8;_c.height=1;_c:setValue(1)local bc="horizontal"local cc=" "local dc;local _d="\140" -local ad=_c.width;local bd=1;local cd=1 -local function dd(a_a,b_a,c_a,d_a) -local _aa,aaa=a_a:getAbsolutePosition(a_a:getAnchorPosition())local baa,caa=a_a:getSize() -if(bc=="horizontal")then -for _index=0,baa do -if -(_aa+_index==c_a)and(aaa<=d_a)and(aaa+caa>d_a)then -bd=math.min(_index+1,baa- (cd-1))a_a:setValue(ad/baa* (bd))a_a:updateDraw()end end end -if(bc=="vertical")then -for _index=0,caa do -if -(aaa+_index==d_a)and(_aa<=c_a)and(_aa+baa>c_a)then bd=math.min(_index+1,caa- (cd-1)) -a_a:setValue(ad/caa* (bd))a_a:updateDraw()end end end end -local __a={getType=function(a_a)return ac end,setSymbol=function(a_a,b_a)cc=b_a:sub(1,1)a_a:updateDraw()return a_a end,setValuesByXMLData=function(a_a,b_a) -_c.setValuesByXMLData(a_a,b_a) -if(cb("maxValue",b_a)~=nil)then ad=cb("maxValue",b_a)end;if(cb("backgroundSymbol",b_a)~=nil)then -_d=cb("backgroundSymbol",b_a):sub(1,1)end;if(cb("barType",b_a)~=nil)then -bc=cb("barType",b_a):lower()end;if(cb("symbol",b_a)~=nil)then -cc=cb("symbol",b_a):sub(1,1)end;if(cb("symbolSize",b_a)~=nil)then -a_a:setSymbolSize(cb("symbolSize",b_a))end;if(cb("symbolColor",b_a)~=nil)then -dc=colors[cb("symbolColor",b_a)]end;if(cb("index",b_a)~=nil)then -a_a:setIndex(cb("index",b_a))end end,setIndex=function(a_a,b_a) -bd=b_a;if(bd<1)then bd=1 end;local c_a,d_a=a_a:getSize() -bd=math.min(bd,( -bc=="vertical"and d_a or c_a)- (cd-1)) -a_a:setValue(ad/ (bc=="vertical"and d_a or c_a)*bd)a_a:updateDraw()return a_a end,getIndex=function(a_a)return -bd end,setSymbolSize=function(a_a,b_a)cd=tonumber(b_a)or 1 -if(bc=="vertical")then -a_a:setValue(bd-1 * (ad/ (h- (cd- -1)))- (ad/ (h- (cd-1))))elseif(bc=="horizontal")then -a_a:setValue(bd-1 * (ad/ (w- (cd-1)))- (ad/ -(w- (cd-1))))end;a_a:updateDraw()return a_a end,setMaxValue=function(a_a,b_a) -ad=b_a;return a_a end,setBackgroundSymbol=function(a_a,b_a)_d=string.sub(b_a,1,1) -a_a:updateDraw()return a_a end,setSymbolColor=function(a_a,b_a)dc=b_a;a_a:updateDraw() -return a_a end,setBarType=function(a_a,b_a)bc=b_a:lower()a_a:updateDraw() -return a_a end,mouseHandler=function(a_a,b_a,c_a,d_a)if(_c.mouseHandler(a_a,b_a,c_a,d_a))then -dd(a_a,b_a,c_a,d_a)return true end;return false end,dragHandler=function(a_a,b_a,c_a,d_a)if -(_c.dragHandler(a_a,b_a,c_a,d_a))then dd(a_a,b_a,c_a,d_a)return true end -return false end,scrollHandler=function(a_a,b_a,c_a,d_a) -if -(_c.scrollHandler(a_a,b_a,c_a,d_a))then local _aa,aaa=a_a:getSize()bd=bd+b_a;if(bd<1)then bd=1 end -bd=math.min(bd,( -bc=="vertical"and aaa or _aa)- (cd-1)) -a_a:setValue(ad/ (bc=="vertical"and aaa or _aa)*bd)a_a:updateDraw()return true end;return false end,draw=function(a_a) -if -(_c.draw(a_a))then -if(a_a.parent~=nil)then local b_a,c_a=a_a:getAnchorPosition() -local d_a,_aa=a_a:getSize() -if(bc=="horizontal")then -a_a.parent:writeText(b_a,c_a,_d:rep(bd-1),a_a.bgColor,a_a.fgColor) -a_a.parent:writeText(b_a+bd-1,c_a,cc:rep(cd),dc,dc) -a_a.parent:writeText(b_a+bd+cd-1,c_a,_d:rep(d_a- (bd+cd-1)),a_a.bgColor,a_a.fgColor)end -if(bc=="vertical")then -for n=0,_aa-1 do -if(bd==n+1)then -for curIndexOffset=0,math.min(cd-1,_aa)do a_a.parent:writeText(b_a,c_a+n+ -curIndexOffset,cc,dc,dc)end else if(n+1 bd-1 +cd)then -a_a.parent:writeText(b_a,c_a+n,_d,a_a.bgColor,a_a.fgColor)end end end end end end end,init=function(a_a) -a_a.parent:addEvent("mouse_click",a_a)a_a.parent:addEvent("mouse_drag",a_a) -a_a.parent:addEvent("mouse_scroll",a_a) -if(_c.init(a_a))then -a_a.bgColor=a_a.parent:getTheme("SliderBG")a_a.fgColor=a_a.parent:getTheme("SliderText") -dc=a_a.parent:getTheme("SliderSymbolColor")end end}return setmetatable(__a,_c)end end -aa["objects"]["Textfield"]=function(...)local ab=da("Object")local bb=da("tHex") -local cb=da("utils").getValueFromXML;local db=da("basaltLogs") -local _c,ac,bc,cc,dc=string.rep,string.find,string.gmatch,string.sub,string.len -return -function(_d)local ad=ab(_d)local bd="Textfield"local cd,dd,__a,a_a=1,1,1,1;local b_a={" "}local c_a={""}local d_a={""} -local _aa={}local aaa={}local baa,caa,daa,_ba;local aba,bba=colors.lightBlue,colors.black;ad.width=30 -ad.height=12;ad:setZIndex(5)local function cba() -if -(baa~=nil)and(caa~=nil)and(daa~=nil)and(_ba~=nil)then return true end;return false end -local function dba()local ada,bda,cda,dda -if -(cba())then if(baa>caa)then ada,bda=caa,baa else ada,bda=baa,caa end;if(daa>_ba)then -cda,dda=_ba,daa else cda,dda=daa,_ba end end;return ada,bda,cda,dda end;local function _ca()end -local function aca(ada)local bda,cda,dda,__b=dba(ada) -for n=__b,dda,-1 do -if(n==dda)or(n==__b)then local a_b=b_a[n] -local b_b=c_a[n]local c_b=d_a[n] -if(n==dda)and(n==__b)then a_b=a_b:sub(1,bda-1).. -a_b:sub(cda+1,a_b:len())b_b=b_b:sub(1,bda-1).. -b_b:sub(cda+1,b_b:len())c_b=c_b:sub(1,bda-1).. -c_b:sub(cda+1,c_b:len())elseif(n==bda)then -a_b=a_b:sub(1,bda)b_b=b_b:sub(1,bda)c_b=c_b:sub(1,bda)elseif(n==dda)then -a_b=a_b:sub(cda,a_b:len())b_b=b_b:sub(cda,b_b:len()) -c_b=c_b:sub(cda,c_b:len())end;b_a[n]=a_b;c_a[n]=b_b;d_a[n]=c_b else table.remove(b_a,n) -table.remove(c_a,n)table.remove(d_a,n)end end;__a,a_a=baa,daa;baa,caa,daa,_ba=nil,nil,nil,nil;return ada end -local function bca(ada,bda)local cda={} -if(ada:len()>0)then -for dda in bc(ada,bda)do local __b,a_b=ac(ada,dda) -if -(__b~=nil)and(a_b~=nil)then table.insert(cda,__b)table.insert(cda,a_b) -local b_b=cc(ada,1,(__b-1))local c_b=cc(ada,a_b+1,ada:len())ada=b_b.. (":"):rep(dda:len()).. -c_b end end end;return cda end -local function cca(ada,bda)bda=bda or a_a -local cda=bb[ada.fgColor]:rep(d_a[bda]:len()) -local dda=bb[ada.bgColor]:rep(c_a[bda]:len()) -for __b,a_b in pairs(aaa)do local b_b=bca(b_a[bda],a_b[1]) -if(#b_b>0)then -for x=1,#b_b/2 do -local c_b=x*2 -1;if(a_b[2]~=nil)then -cda=cda:sub(1,b_b[c_b]-1)..bb[a_b[2]]:rep(b_b[c_b+1]- ( -b_b[c_b]-1)).. -cda:sub(b_b[c_b+1]+1,cda:len())end;if -(a_b[3]~=nil)then -dda=dda:sub(1,b_b[c_b]-1).. - -bb[a_b[3]]:rep(b_b[c_b+1]- (b_b[c_b]-1))..dda:sub(b_b[c_b+1]+1,dda:len())end end end end -for __b,a_b in pairs(_aa)do -for b_b,c_b in pairs(a_b)do local d_b=bca(b_a[bda],c_b) -if(#d_b>0)then for x=1,#d_b/2 do -local _ab=x*2 -1 -cda=cda:sub(1,d_b[_ab]-1).. - -bb[__b]:rep(d_b[_ab+1]- (d_b[_ab]-1))..cda:sub(d_b[_ab+1]+1,cda:len())end end end end;d_a[bda]=cda;c_a[bda]=dda;ada:updateDraw()end;local function dca(ada)for n=1,#b_a do cca(ada,n)end end -local _da={getType=function(ada)return bd end,setBackground=function(ada,bda) -ad.setBackground(ada,bda)dca(ada)return ada end,setForeground=function(ada,bda) -ad.setForeground(ada,bda)dca(ada)return ada end,setValuesByXMLData=function(ada,bda) -ad.setValuesByXMLData(ada,bda) -if(bda["lines"]~=nil)then local cda=bda["lines"]["line"]if -(cda.properties~=nil)then cda={cda}end;for dda,__b in pairs(cda)do -ada:addLine(__b:value())end end -if(bda["keywords"]~=nil)then -for cda,dda in pairs(bda["keywords"])do -if(colors[cda]~=nil)then -local __b=dda;if(__b.properties~=nil)then __b={__b}end;local a_b={} -for b_b,c_b in pairs(__b)do -local d_b=c_b["keyword"]if(c_b["keyword"].properties~=nil)then -d_b={c_b["keyword"]}end;for _ab,aab in pairs(d_b)do -table.insert(a_b,aab:value())end end;ada:addKeywords(colors[cda],a_b)end end end -if(bda["rules"]~=nil)then -if(bda["rules"]["rule"]~=nil)then -local cda=bda["rules"]["rule"]if(bda["rules"]["rule"].properties~=nil)then -cda={bda["rules"]["rule"]}end -for dda,__b in pairs(cda)do if(cb("pattern",__b)~=nil)then -ada:addRule(cb("pattern",__b),colors[cb("fg",__b)],colors[cb("bg",__b)])end end end end end,getLines=function(ada)return -b_a end,getLine=function(ada,bda)return b_a[bda]end,editLine=function(ada,bda,cda) -b_a[bda]=cda or b_a[bda]cca(ada,bda)ada:updateDraw()return ada end,clear=function(ada) -b_a={" "}c_a={""}d_a={""}baa,caa,daa,_ba=nil,nil,nil,nil;cd,dd,__a,a_a=1,1,1,1 -ada:updateDraw()return ada end,addLine=function(ada,bda,cda) -if -(bda~=nil)then -if(#b_a==1)and(b_a[1]=="")then b_a[1]=bda -c_a[1]=bb[ada.bgColor]:rep(bda:len())d_a[1]=bb[ada.fgColor]:rep(bda:len()) -cca(ada,1)return ada end -if(cda~=nil)then table.insert(b_a,cda,bda) -table.insert(c_a,cda,bb[ada.bgColor]:rep(bda:len())) -table.insert(d_a,cda,bb[ada.fgColor]:rep(bda:len()))else table.insert(b_a,bda) -table.insert(c_a,bb[ada.bgColor]:rep(bda:len())) -table.insert(d_a,bb[ada.fgColor]:rep(bda:len()))end end;cca(ada,cda or#b_a)ada:updateDraw()return ada end,addKeywords=function(ada,bda,cda)if( -_aa[bda]==nil)then _aa[bda]={}end;for dda,__b in pairs(cda)do -table.insert(_aa[bda],__b)end;ada:updateDraw()return ada end,addRule=function(ada,bda,cda,dda) -table.insert(aaa,{bda,cda,dda})ada:updateDraw()return ada end,editRule=function(ada,bda,cda,dda)for __b,a_b in -pairs(aaa)do -if(a_b[1]==bda)then aaa[__b][2]=cda;aaa[__b][3]=dda end end;ada:updateDraw()return ada end,removeRule=function(ada,bda) -for cda,dda in -pairs(aaa)do if(dda[1]==bda)then table.remove(aaa,cda)end end;ada:updateDraw()return ada end,setKeywords=function(ada,bda,cda) -_aa[bda]=cda;ada:updateDraw()return ada end,removeLine=function(ada,bda) -if(#b_a>1)then table.remove(b_a, -bda or#b_a) -table.remove(c_a,bda or#c_a)table.remove(d_a,bda or#d_a)else b_a={" "}c_a={""}d_a={""}end;ada:updateDraw()return ada end,getTextCursor=function(ada)return -__a,a_a end,getFocusHandler=function(ada)ad.getFocusHandler(ada) -if(ada.parent~=nil)then -local bda,cda=ada:getAnchorPosition()if(ada.parent~=nil)then -ada.parent:setCursor(true,bda+__a-dd,cda+a_a-cd,ada.fgColor)end end end,loseFocusHandler=function(ada) -ad.loseFocusHandler(ada) -if(ada.parent~=nil)then ada.parent:setCursor(false)end end,keyHandler=function(ada,bda) -if -(ad.keyHandler(ada,event,bda))then local cda,dda=ada:getAnchorPosition()local __b,a_b=ada:getSize() -if(bda== -keys.backspace)then -if(b_a[a_a]=="")then -if(a_a>1)then table.remove(b_a,a_a) -table.remove(d_a,a_a)table.remove(c_a,a_a) -__a=b_a[a_a-1]:len()+1;dd=__a-__b+1;if(dd<1)then dd=1 end;a_a=a_a-1 end elseif(__a<=1)then -if(a_a>1)then __a=b_a[a_a-1]:len()+1 -dd=__a-__b+1;if(dd<1)then dd=1 end;b_a[a_a-1]=b_a[a_a-1]..b_a[a_a]d_a[ -a_a-1]=d_a[a_a-1]..d_a[a_a]c_a[a_a-1]=c_a[a_a-1].. -c_a[a_a]table.remove(b_a,a_a) -table.remove(d_a,a_a)table.remove(c_a,a_a)a_a=a_a-1 end else b_a[a_a]=b_a[a_a]:sub(1,__a-2).. -b_a[a_a]:sub(__a,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-2)..d_a[a_a]:sub(__a,d_a[a_a]:len())c_a[a_a]=c_a[a_a]:sub(1,__a-2).. -c_a[a_a]:sub(__a,c_a[a_a]:len())if(__a>1)then -__a=__a-1 end;if(dd>1)then if(__ab_a[a_a]:len())then -if( -b_a[a_a+1]~=nil)then b_a[a_a]=b_a[a_a]..b_a[a_a+1] -table.remove(b_a,a_a+1)table.remove(c_a,a_a+1)table.remove(d_a,a_a+1)end else b_a[a_a]=b_a[a_a]:sub(1,__a-1).. -b_a[a_a]:sub(__a+1,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-1)..d_a[a_a]:sub(__a+1,d_a[a_a]:len())c_a[a_a]=c_a[a_a]:sub(1,__a-1).. -c_a[a_a]:sub(__a+1,c_a[a_a]:len())end end;cca(ada)end -if(bda==keys.enter)then -table.insert(b_a,a_a+1,b_a[a_a]:sub(__a,b_a[a_a]:len())) -table.insert(d_a,a_a+1,d_a[a_a]:sub(__a,d_a[a_a]:len())) -table.insert(c_a,a_a+1,c_a[a_a]:sub(__a,c_a[a_a]:len()))b_a[a_a]=b_a[a_a]:sub(1,__a-1) -d_a[a_a]=d_a[a_a]:sub(1,__a-1)c_a[a_a]=c_a[a_a]:sub(1,__a-1)a_a=a_a+1;__a=1;dd=1;if(a_a-cd>= -a_b)then cd=cd+1 end;ada:setValue("")end -if(bda==keys.up)then -if(a_a>1)then a_a=a_a-1;if(__a>b_a[a_a]:len()+1)then __a= -b_a[a_a]:len()+1 end -if(dd>1)then if(__a1)then if(a_ab_a[a_a]:len()+1)then __a=b_a[a_a]:len()+1 end -if(dd>1)then if -(__a=cd+a_b)then cd=cd+1 end end end -if(bda==keys.right)then __a=__a+1 -if(a_a<#b_a)then if -(__a>b_a[a_a]:len()+1)then __a=1;a_a=a_a+1 end elseif(__a>b_a[a_a]:len())then __a= -b_a[a_a]:len()+1 end;if(__a<1)then __a=1 end -if(__a=__b+dd)then dd=__a-__b+1 end;if(dd<1)then dd=1 end end -if(bda==keys.left)then __a=__a-1;if(__a>=1)then -if(__a=__b+dd)then dd=__a end end -if(a_a>1)then if(__a<1)then a_a=a_a-1 -__a=b_a[a_a]:len()+1;dd=__a-__b+1 end end;if(__a<1)then __a=1 end;if(dd<1)then dd=1 end end -if not -( (cda+__a-dd>=cda and cda+__a-dd=dda and dda+a_a-cd -ada:getX()+__b-1)then b_b=ada:getX()+__b-1 end -local c_b=(a_a-cd=__b+dd)then dd=dd+1 end;cca(ada) -ada:setValue("") -if not -( (cda+__a-dd>=cda and cda+__a-dd=dda and dda+a_a-cd -ada:getX()+__b-1)then b_b=ada:getX()+__b-1 end -local c_b=(a_a-cdb_b+cda- (__b+1)+dd)and(b_bb_a[a_a]:len())then __a= -b_a[a_a]:len()+1;caa=__a end;if(__a#b_a- (_ab-1))then cd=#b_a- (_ab-1)end;if -(cd<1)then cd=1 end -if - -(__b+__a-dd>=__b and __b+__a-dd<__b+d_b)and(c_b+a_a-cd>=c_b and c_b+a_a-cd -b_a[a_a]:len())then __a=b_a[a_a]:len()+1;baa=__a end;if(__ab_a[_ba]:len())then caa= -b_a[_ba]:len()+1 end;if(baa==caa)and(daa==_ba)then baa,caa,daa,_ba= -nil,nil,nil,nil end -ada:updateDraw()end;return true end end,eventHandler=function(ada,bda,cda,dda,__b,a_b) -if -(ad.eventHandler(ada,bda,cda,dda,__b,a_b))then -if(bda=="paste")then -if(ada:isFocused())then local b_b,c_b=ada:getSize()b_a[a_a]=b_a[a_a]:sub(1, -__a-1).. -cda..b_a[a_a]:sub(__a,b_a[a_a]:len()) -d_a[a_a]=d_a[a_a]:sub(1, -__a-1)..bb[ada.fgColor]:rep(cda:len()).. -d_a[a_a]:sub(__a,d_a[a_a]:len()) -c_a[a_a]=c_a[a_a]:sub(1,__a-1).. - -bb[ada.bgColor]:rep(cda:len())..c_a[a_a]:sub(__a,c_a[a_a]:len())__a=__a+cda:len() -if(__a>=b_b+dd)then dd=(__a+1)-b_b end;local d_b,_ab=ada:getAnchorPosition() -ada.parent:setCursor(true,d_b+__a-dd,_ab+ -a_a-cd,ada.fgColor)cca(ada)ada:updateDraw()end end end end,draw=function(ada) -if -(ad.draw(ada))then -if(ada.parent~=nil)then local bda,cda=ada:getAnchorPosition() -local dda,__b=ada:getSize() -for n=1,__b do local a_b=""local b_b=""local c_b="" -if(b_a[n+cd-1]~=nil)then a_b=b_a[n+cd-1]c_b=d_a[ -n+cd-1]b_b=c_a[n+cd-1]end;a_b=a_b:sub(dd,dda+dd-1) -b_b=b_b:sub(dd,dda+dd-1)c_b=c_b:sub(dd,dda+dd-1)local d_b=dda-a_b:len()if(d_b<0)then -d_b=0 end;a_b=a_b.._c(ada.bgSymbol,d_b)b_b=b_b.. -_c(bb[ada.bgColor],d_b) -c_b=c_b.._c(bb[ada.fgColor],d_b)ada.parent:setText(bda,cda+n-1,a_b)ada.parent:setBG(bda, -cda+n-1,b_b) -ada.parent:setFG(bda,cda+n-1,c_b)end -if -(baa~=nil)and(caa~=nil)and(daa~=nil)and(_ba~=nil)then local a_b,b_b,c_b,d_b=dba(ada) -for n=c_b,d_b do local _ab=b_a[n]:len()local aab=0 -if -(n==c_b)and(n==d_b)then aab=a_b-1;_ab=_ab- (a_b-1)- (_ab-b_b)elseif(n==d_b)then -_ab=_ab- (_ab-b_b)elseif(n==c_b)then _ab=_ab- (a_b-1)aab=a_b-1 end -ada.parent:setBG(bda+aab,cda+n-1,_c(bb[aba],_ab)) -ada.parent:setFG(bda+aab,cda+n-1,_c(bb[bba],_ab))end end -if(ada:isFocused())then local a_b,b_b=ada:getAnchorPosition()end end end end,init=function(ada) -ada.parent:addEvent("mouse_click",ada)ada.parent:addEvent("mouse_up",ada) -ada.parent:addEvent("mouse_scroll",ada)ada.parent:addEvent("mouse_drag",ada) -ada.parent:addEvent("key",ada)ada.parent:addEvent("char",ada) -ada.parent:addEvent("other_event",ada) -if(ad.init(ada))then -ada.bgColor=ada.parent:getTheme("TextfieldBG")ada.fgColor=ada.parent:getTheme("TextfieldText")end end}return setmetatable(_da,ad)end end -aa["objects"]["Thread"]=function(...)local ab=da("utils").getValueFromXML -return -function(bb)local cb -local db="Thread"local _c;local ac;local bc=false;local cc -local dc=function(_d,ad) -if(ad:sub(1,1)=="#")then -local bd=_d:getBaseFrame():getDeepObject(ad:sub(2,ad:len())) -if(bd~=nil)and(bd.internalObjetCall~=nil)then return(function() -bd:internalObjetCall()end)end else return _d:getBaseFrame():getVariable(ad)end;return _d end -cb={name=bb,getType=function(_d)return db end,getZIndex=function(_d)return 1 end,getName=function(_d)return _d.name end,getBaseFrame=function(_d)if -(_d.parent~=nil)then return _d.parent:getBaseFrame()end -return _d end,setValuesByXMLData=function(_d,ad)local bd;if(ab("thread",ad)~=nil)then -bd=dc(_d,ab("thread",ad))end -if(ab("start",ad)~=nil)then if -(ab("start",ad))and(bd~=nil)then _d:start(bd)end end;return _d end,start=function(_d,ad) -if( -ad==nil)then error("Function provided to thread is nil")end;_c=ad;ac=coroutine.create(_c)bc=true;cc=nil -local bd,cd=coroutine.resume(ac)cc=cd;if not(bd)then if(cd~="Terminated")then -error("Thread Error Occurred - "..cd)end end -_d.parent:addEvent("mouse_click",_d)_d.parent:addEvent("mouse_up",_d) -_d.parent:addEvent("mouse_scroll",_d)_d.parent:addEvent("mouse_drag",_d) -_d.parent:addEvent("key",_d)_d.parent:addEvent("key_up",_d) -_d.parent:addEvent("char",_d)_d.parent:addEvent("other_event",_d)return _d end,getStatus=function(_d,ad)if( -ac~=nil)then return coroutine.status(ac)end;return nil end,stop=function(_d,ad) -bc=false;_d.parent:removeEvent("mouse_click",_d) -_d.parent:removeEvent("mouse_up",_d)_d.parent:removeEvent("mouse_scroll",_d) -_d.parent:removeEvent("mouse_drag",_d)_d.parent:removeEvent("key",_d) -_d.parent:removeEvent("key_up",_d)_d.parent:removeEvent("char",_d) -_d.parent:removeEvent("other_event",_d)return _d end,mouseHandler=function(_d,...) -_d:eventHandler("mouse_click",...)end,mouseUpHandler=function(_d,...)_d:eventHandler("mouse_up",...)end,mouseScrollHandler=function(_d,...) -_d:eventHandler("mouse_scroll",...)end,mouseDragHandler=function(_d,...) -_d:eventHandler("mouse_drag",...)end,mouseMoveHandler=function(_d,...) -_d:eventHandler("mouse_move",...)end,keyHandler=function(_d,...)_d:eventHandler("key",...)end,keyUpHandler=function(_d,...) -_d:eventHandler("key_up",...)end,charHandler=function(_d,...)_d:eventHandler("char",...)end,eventHandler=function(_d,ad,...) -if -(bc)then -if(coroutine.status(ac)=="suspended")then if(cc~=nil)then if(ad~=cc)then return end;cc= -nil end -local bd,cd=coroutine.resume(ac,ad,...)cc=cd;if not(bd)then if(cd~="Terminated")then -error("Thread Error Occurred - "..cd)end end else -_d:stop()end end end}cb.__index=cb;return cb end end -aa["objects"]["Timer"]=function(...)local ab=da("basaltEvent") -local bb=da("utils").getValueFromXML -return -function(cb)local db="Timer"local _c=0;local ac=0;local bc=0;local cc;local dc=ab()local _d=false -local ad=function(cd,dd,__a) -local a_a=function(b_a) -if(b_a:sub(1,1)=="#")then -local c_a=cd:getBaseFrame():getDeepObject(b_a:sub(2,b_a:len())) -if(c_a~=nil)and(c_a.internalObjetCall~=nil)then dd(cd,function() -c_a:internalObjetCall()end)end else -dd(cd,cd:getBaseFrame():getVariable(b_a))end end;if(type(__a)=="string")then a_a(__a)elseif(type(__a)=="table")then -for b_a,c_a in pairs(__a)do a_a(c_a)end end;return cd end -local bd={name=cb,getType=function(cd)return db end,setValuesByXMLData=function(cd,dd) -if(bb("time",dd)~=nil)then _c=bb("time",dd)end;if(bb("repeat",dd)~=nil)then ac=bb("repeat",dd)end -if( -bb("start",dd)~=nil)then if(bb("start",dd))then cd:start()end end;if(bb("onCall",dd)~=nil)then -ad(cd,cd.onCall,bb("onCall",dd))end;return cd end,getBaseFrame=function(cd) -if( -cd.parent~=nil)then return cd.parent:getBaseFrame()end;return cd end,getZIndex=function(cd)return 1 end,getName=function(cd) -return cd.name end,setTime=function(cd,dd,__a)_c=dd or 0;ac=__a or 1;return cd end,start=function(cd)if(_d)then -os.cancelTimer(cc)end;bc=ac;cc=os.startTimer(_c)_d=true -cd.parent:addEvent("other_event",cd)return cd end,isActive=function(cd)return _d end,cancel=function(cd)if( -cc~=nil)then os.cancelTimer(cc)end;_d=false -cd.parent:removeEvent("other_event",cd)return cd end,onCall=function(cd,dd) -dc:registerEvent("timed_event",dd)return cd end,eventHandler=function(cd,dd,__a) -if -dd=="timer"and __a==cc and _d then dc:sendEvent("timed_event",cd) -if(bc>=1)then bc=bc-1;if(bc>=1)then -cc=os.startTimer(_c)end elseif(bc==-1)then cc=os.startTimer(_c)end end end}bd.__index=bd;return bd end end -aa["objects"]["Switch"]=function(...)local ab=da("Object") -local bb=da("utils").getValueFromXML -return -function(cb)local db=ab(cb)local _c="Switch"db.width=2;db.height=1 -db.bgColor=colors.lightGray;db.fgColor=colors.gray;db:setValue(false)db:setZIndex(5) -local ac=colors.black;local bc=colors.red;local cc=colors.green -local dc={getType=function(_d)return _c end,setSymbolColor=function(_d,ad)ac=ad -_d:updateDraw()return _d end,setActiveBackground=function(_d,ad)cc=ad;_d:updateDraw()return _d end,setInactiveBackground=function(_d,ad) -bc=ad;_d:updateDraw()return _d end,setValuesByXMLData=function(_d,ad) -db.setValuesByXMLData(_d,ad)if(bb("inactiveBG",ad)~=nil)then -bc=colors[bb("inactiveBG",ad)]end;if(bb("activeBG",ad)~=nil)then -cc=colors[bb("activeBG",ad)]end;if(bb("symbolColor",ad)~=nil)then -ac=colors[bb("symbolColor",ad)]end end,mouseHandler=function(_d,ad,bd,cd) -if -(db.mouseHandler(_d,ad,bd,cd))then -local dd,__a=_d:getAbsolutePosition(_d:getAnchorPosition())_d:setValue(not _d:getValue()) -_d:updateDraw()return true end end,draw=function(_d) -if -(db.draw(_d))then -if(_d.parent~=nil)then local ad,bd=_d:getAnchorPosition() -local cd,dd=_d:getSize() -_d.parent:drawBackgroundBox(ad,bd,cd,dd,_d.bgColor) -if(_d:getValue())then -_d.parent:drawBackgroundBox(ad,bd,1,dd,cc)_d.parent:drawBackgroundBox(ad+1,bd,1,dd,ac)else -_d.parent:drawBackgroundBox(ad,bd,1,dd,ac)_d.parent:drawBackgroundBox(ad+1,bd,1,dd,bc)end end end end,init=function(_d) -_d.parent:addEvent("mouse_click",_d) -if(db.init(_d))then _d.bgColor=_d.parent:getTheme("SwitchBG") -_d.fgColor=_d.parent:getTheme("SwitchText")ac=_d.parent:getTheme("SwitchBGSymbol") -bc=_d.parent:getTheme("SwitchInactive")cc=_d.parent:getTheme("SwitchActive")end end}return setmetatable(dc,db)end end;aa["libraries"]={} -aa["libraries"]["basaltEvent"]=function(...) -return -function()local ab={}local bb={} -local cb={registerEvent=function(db,_c,ac)if( -ab[_c]==nil)then ab[_c]={}bb[_c]=1 end -ab[_c][bb[_c]]=ac;bb[_c]=bb[_c]+1;return bb[_c]-1 end,removeEvent=function(db,_c,ac)ab[_c][ac[_c]]= -nil end,sendEvent=function(db,_c,...)local ac -if(ab[_c]~=nil)then for bc,cc in pairs(ab[_c])do -local dc=cc(...)if(dc==false)then ac=dc end end end;return ac end}cb.__index=cb;return cb end end -aa["libraries"]["basaltLogs"]=function(...)local ab=""local bb="basaltLog.txt"local cb="Debug" -fs.delete( -ab~=""and ab.."/"..bb or bb) -local db={__call=function(_c,ac,bc)if(ac==nil)then return end -local cc=ab~=""and ab.."/"..bb or bb -local dc=fs.open(cc,fs.exists(cc)and"a"or"w") -dc.writeLine("[Basalt][".. (bc and bc or cb).."]: "..tostring(ac))dc.close()end}return setmetatable({},db)end -aa["libraries"]["basaltMon"]=function(...) -local ab={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local bb,cb,db,_c=type,string.len,string.rep,string.sub -return -function(ac)local bc={} -for _ba,aba in pairs(ac)do -bc[_ba]={} -for bba,cba in pairs(aba)do local dba=peripheral.wrap(cba)if(dba==nil)then -error("Unable to find monitor "..cba)end;bc[_ba][bba]=dba -bc[_ba][bba].name=cba end end;local cc,dc,_d,ad,bd,cd,dd,__a=1,1,1,1,0,0,0,0;local a_a,b_a=false,1 -local c_a,d_a=colors.white,colors.black -local function _aa()local _ba,aba=0,0 -for bba,cba in pairs(bc)do local dba,_ca=0,0 -for aca,bca in pairs(cba)do local cca,dca=bca.getSize() -dba=dba+cca;_ca=dca>_ca and dca or _ca end;_ba=_ba>dba and _ba or dba;aba=aba+_ca end;dd,__a=_ba,aba end;_aa() -local function aaa()local _ba=0;local aba,bba=0,0 -for cba,dba in pairs(bc)do local _ca=0;local aca=0 -for bca,cca in pairs(dba)do -local dca,_da=cca.getSize()if(cc-_ca>=1)and(cc-_ca<=dca)then aba=bca end;cca.setCursorPos( -cc-_ca,dc-_ba)_ca=_ca+dca -if(aca<_da)then aca=_da end end;if(dc-_ba>=1)and(dc-_ba<=aca)then bba=cba end -_ba=_ba+aca end;_d,ad=aba,bba end;aaa() -local function baa(_ba,...)local aba={...}return -function()for bba,cba in pairs(bc)do for dba,_ca in pairs(cba)do -_ca[_ba](table.unpack(aba))end end end end -local function caa()baa("setCursorBlink",false)() -if not(a_a)then return end;if(bc[ad]==nil)then return end;local _ba=bc[ad][_d] -if(_ba==nil)then return end;_ba.setCursorBlink(a_a)end -local function daa(_ba,aba,bba)if(bc[ad]==nil)then return end;local cba=bc[ad][_d] -if(cba==nil)then return end;cba.blit(_ba,aba,bba)local dba,_ca=cba.getSize() -if -(cb(_ba)+cc>dba)then local aca=bc[ad][_d+1]if(aca~=nil)then aca.blit(_ba,aba,bba)_d=_d+1;cc=cc+ -cb(_ba)end end;aaa()end -return -{clear=baa("clear"),setCursorBlink=function(_ba)a_a=_ba;caa()end,getCursorBlink=function()return a_a end,getCursorPos=function()return cc,dc end,setCursorPos=function(_ba,aba) -cc,dc=_ba,aba;aaa()caa()end,setTextScale=function(_ba) -baa("setTextScale",_ba)()_aa()aaa()b_a=_ba end,getTextScale=function()return b_a end,blit=function(_ba,aba,bba) -daa(_ba,aba,bba)end,write=function(_ba)_ba=tostring(_ba)local aba=cb(_ba) -daa(_ba,db(ab[c_a],aba),db(ab[d_a],aba))end,getSize=function()return dd,__a end,setBackgroundColor=function(_ba) -baa("setBackgroundColor",_ba)()d_a=_ba end,setTextColor=function(_ba) -baa("setTextColor",_ba)()c_a=_ba end,calculateClick=function(_ba,aba,bba)local cba=0 -for dba,_ca in pairs(bc)do local aca=0;local bca=0 -for cca,dca in pairs(_ca)do -local _da,ada=dca.getSize()if(dca.name==_ba)then return aba+aca,bba+cba end -aca=aca+_da;if(ada>bca)then bca=ada end end;cba=cba+bca end;return aba,bba end}end end -aa["libraries"]["basaltDraw"]=function(...)local ab=da("tHex") -local bb,cb=string.sub,string.rep -return -function(db)local _c=db or term.current()local ac;local bc,cc=_c.getSize()local dc={} -local _d={}local ad={}local bd={}local cd={}local dd={}local __a;local a_a={} -local function b_a()__a=cb(" ",bc)for n=0,15 do local daa=2 ^n -local _ba=ab[daa]a_a[daa]=cb(_ba,bc)end end;b_a() -local function c_a()b_a()local daa=__a;local _ba=a_a[colors.white] -local aba=a_a[colors.black] -for currentY=1,cc do -dc[currentY]=bb(dc[currentY]==nil and daa or dc[currentY]..daa:sub(1,bc- -dc[currentY]:len()),1,bc) -ad[currentY]=bb(ad[currentY]==nil and _ba or ad[currentY].._ba:sub(1,bc- -ad[currentY]:len()),1,bc) -_d[currentY]=bb(_d[currentY]==nil and aba or _d[currentY]..aba:sub(1,bc- -_d[currentY]:len()),1,bc)end end;c_a() -local function d_a(daa,_ba,aba) -if(_ba>=1)and(_ba<=cc)then -if -(daa+aba:len()>0)and(daa<=bc)then local bba=dc[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then local _ca=1 -daa+1 -local aca=bc-daa+1;aba=bb(aba,_ca,aca)elseif(dba>bc)then local _ca=bc-daa+1;aba=bb(aba,1,_ca)end -if(daa>1)then local _ca=daa-1;cba=bb(bba,1,_ca)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if(daa+aba:len()>0)and(daa<=bc)then -local bba=_d[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then -aba=bb(aba,1 -daa+1,bc-daa+1)elseif(dba>bc)then aba=bb(aba,1,bc-daa+1)end -if(daa>1)then cba=bb(bba,1,daa-1)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if(daa+aba:len()>0)and(daa<=bc)then -local bba=ad[_ba]local cba;local dba=daa+#aba-1 -if(daa<1)then local _ca=1 -daa+1;local aca=bc-daa+1 -aba=bb(aba,_ca,aca)elseif(dba>bc)then local _ca=bc-daa+1;aba=bb(aba,1,_ca)end -if(daa>1)then local _ca=daa-1;cba=bb(bba,1,_ca)..aba else cba=aba end;if dba=1)and(_ba<=cc)then -if( -daa+aba:len()>0)and(daa<=bc)then local dba=dc[_ba]local _ca=ad[_ba]local aca=_d[_ba] -local bca,cca,dca;local _da=daa+#aba-1 -if(daa<1)then local ada=1 -daa+1;local bda=bc-daa+1 -aba=bb(aba,ada,bda)bba=bb(bba,ada,bda)cba=bb(cba,ada,bda)elseif(_da>bc)then local ada=bc-daa+1 -aba=bb(aba,1,ada)bba=bb(bba,1,ada)cba=bb(cba,1,ada)end -if(daa>1)then local ada=daa-1;bca=bb(dba,1,ada)..aba -cca=bb(_ca,1,ada)..bba;dca=bb(aca,1,ada)..cba else bca=aba;cca=bba;dca=cba end -if _daac)then ac=#cc[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local a_a=function(d_a,_aa,aaa)ad=_aa or ad;bd=aaa or bd -if(_d[bd]==nil)then _d[bd]=bb("f",ad-1)..d_a.. -bb("f",ac- (#d_a+ad))else _d[bd]= -ab(_d[bd],1,ad-1).. -bb("f",ad-#_d[bd])..d_a..ab(_d[bd],ad+#d_a,ac)end;if(#_d[bd]>ac)then ac=#_d[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local b_a=function(d_a,_aa,aaa)ad=_aa or ad;bd=aaa or bd -if(dc[bd]==nil)then dc[bd]=bb("0",ad-1)..d_a.. -bb("0",ac- (#d_a+ad))else dc[bd]= -ab(dc[bd],1,ad-1).. -bb("0",ad-#dc[bd])..d_a..ab(dc[bd],ad+#d_a,ac)end;if(#dc[bd]>ac)then ac=#dc[bd]end;if(bd>bc)then bc=bd end -_c.updateSize(ac,bc)end -local function c_a(d_a)cd={}cc,dc,_d={},{},{} -for _aa,aaa in pairs(db)do if(type(_aa)=="string")then cd[_aa]=aaa else -cc[_aa],dc[_aa],_d[_aa]=aaa[1],aaa[2],aaa[3]end end;_c.updateSize(ac,bc)end;if(db~=nil)then ac=#db[1][1]bc=#db;c_a(db)end -return -{recalculateSize=dd,setFrame=c_a,getFrame=function()local d_a={} -for _aa,aaa in -pairs(cc)do table.insert(d_a,{aaa,dc[_aa],_d[_aa]})end;for _aa,aaa in pairs(cd)do d_a[_aa]=aaa end;return d_a,ac,bc end,getImage=function() -local d_a={}for _aa,aaa in pairs(cc)do -table.insert(d_a,{aaa,dc[_aa],_d[_aa]})end;return d_a end,setFrameData=function(d_a,_aa) -if( -_aa~=nil)then cd[d_a]=_aa else if(type(d_a)=="table")then cd=d_a end end end,setFrameImage=function(d_a) -for _aa,aaa in pairs(d_a.t)do -cc[_aa]=d_a.t[_aa]dc[_aa]=d_a.fg[_aa]_d[_aa]=d_a.bg[_aa]end end,getFrameImage=function() -return{t=cc,fg=dc,bg=_d}end,getFrameData=function(d_a)return(d_a~=nil and cd[d_a]or cd)end,blit=function(d_a,_aa,aaa,baa,caa) -__a(d_a,baa,caa)b_a(_aa,baa,caa)a_a(aaa,baa,caa)end,text=__a,fg=b_a,bg=a_a,getSize=function()return -ac,bc end,setSize=function(d_a,_aa)local aaa,baa,caa={},{},{} -for _y=1,_aa do -if(cc[_y]~=nil)then aaa[_y]=ab(cc[_y],1,d_a)..bb(" ", -d_a-ac)else aaa[_y]=bb(" ",d_a)end;if(dc[_y]~=nil)then -baa[_y]=ab(dc[_y],1,d_a)..bb("0",d_a-ac)else baa[_y]=bb("0",d_a)end;if -(_d[_y]~=nil)then caa[_y]=ab(_d[_y],1,d_a)..bb("f",d_a-ac)else -caa[_y]=bb("f",d_a)end end;cc,dc,_d=aaa,baa,caa;ac,bc=d_a,_aa end}end -return -function(db)local _c={} -local ac={creator="Bimg Library by NyoriE",date=os.date("!%Y-%m-%dT%TZ")}local bc,cc=0,0;local dc={} -local function _d(cd,dd)cd=cd or#_c+1 -table.insert(_c,cd,cb(dd,dc))if(dd==nil)then _c[cd].setSize(bc,cc)end end;local function ad(cd)table.remove(_c,cd or#_c)end -local function bd(cd,dd) -local __a=_c[cd] -if(__a~=nil)then local a_a=cd+dd;if(a_a>=1)and(a_a<=#_c)then table.remove(_c,cd) -table.insert(_c,a_a,__a)end end end -dc={updateSize=function(cd,dd,__a)local a_a=__a==true and true or false -if(cd>bc)then a_a=true;bc=cd end;if(dd>cc)then a_a=true;cc=dd end -if(a_a)then for b_a,c_a in pairs(_c)do c_a.setSize(bc,cc) -c_a.recalculateSize()end end end,text=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.text(dd,__a,a_a)end,fg=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.fg(dd,__a,a_a)end,bg=function(cd,dd,__a,a_a) -local b_a=_c[cd]if(b_a==nil)then b_a=_d(cd)end;b_a.bg(dd,__a,a_a)end,blit=function(cd,dd,__a,a_a,b_a,c_a) -local d_a=_c[cd]if(d_a==nil)then d_a=_d(cd)end;d_a.blit(dd,__a,a_a,b_a,c_a)end,setSize=function(cd,dd) -bc=cd;cc=dd;for __a,a_a in pairs(_c)do a_a.setSize(cd,dd)end end,getFrame=function(cd)if( -_c[cd]~=nil)then return _c[cd].getFrame()end end,getFrameObjects=function()return -_c end,getFrames=function()local cd={}for dd,__a in pairs(_c)do local a_a=__a.getFrame() -table.insert(cd,a_a)end;return cd end,getFrameObject=function(cd)return -_c[cd]end,addFrame=function(cd)local dd=cb()if(#_c<=1)then -if(ac.animated==nil)then ac.animated=true end -if(ac.secondsPerFrame==nil)then ac.secondsPerFrame=0.2 end end;_d(cd)return dd end,removeFrame=function(cd) -ad(cd) -if(#_c<=1)then if(ac.animated==nil)then ac.animated=true end;if -(ac.secondsPerFrame==nil)then ac.secondsPerFrame=0.2 end end end,moveFrame=bd,setFrameData=function(cd,dd,__a) -if( -_c[cd]~=nil)then _c[cd].setFrameData(dd,__a)end end,getFrameData=function(cd,dd)return _c[cd]~=nil and -_c[cd].getFrameData(dd)end,getSize=function()return -bc,cc end,setAnimation=function(cd)ac.animation=cd end,setMetadata=function(cd,dd)if(dd~=nil)then ac[cd]=dd else if( -type(cd)=="table")then ac=cd end end end,getMetadata=function(cd)return -cd~=nil and ac[cd]or ac end,createBimg=function() -local cd={} -for dd,__a in pairs(_c)do local a_a=__a.getFrame()table.insert(cd,a_a)end;for dd,__a in pairs(ac)do cd[dd]=__a end;cd.width=bc;cd.height=cc;return cd end} -if(db~=nil)then for cd,dd in pairs(db)do -if(type(cd)=="string")then ac[cd]=dd else _d(cd,dd)end end -if -(ac.width==nil)or(ac.height==nil)then for cd,dd in pairs(_c)do local __a,a_a=dd.getSize()if(__a>bc)then __a=bc end -if(a_a>cc)then a_a=cc end end -dc.updateSize(bc,cc,true)end else _d(1)end;return dc end end -aa["libraries"]["images"]=function(...) -local ab,bb,cb=string.sub,math.floor,string.rep -local function db(bd)local cd={{}}local dd=fs.open(bd,"r") -if(dd~=nil)then for __a in dd.readLine do -table.insert(cd[1],{cb(" ",#__a),cb(" ", -#__a),__a})end;dd.close()return cd end end -local function _c(bd)return paintutils.loadImage(bd),"nfp"end -local function ac(bd)local cd=fs.open(bd,"rb") -local dd=textutils.unserialize(cd.readAll())cd.close()if(dd~=nil)then return dd,"bimg"end end;local function bc(bd)end;local function cc(bd)end;local function dc(bd,cd) -if(cd==nil)then if(bd:find(".bimg"))then return ac(bd)elseif -(bd:find(".bbf"))then return bc(bd)else return _c(bd)end end end -local function _d(bd,cd)if( -cd==nil)then -if(bd:find(".bimg"))then return ac(bd)elseif(bd:find(".bbf"))then return cc(bd)else return db(bd)end end end -local function ad(bd,cd,dd) -local __a,a_a=bd.width or#bd[1][1][1],bd.height or#bd[1]local b_a={} -for c_a,d_a in pairs(bd)do -if(type(c_a)=="number")then local _aa={} -for y=1,dd do local aaa,baa,caa="","","" -local daa=bb(y/dd*a_a+0.5) -if(d_a[daa]~=nil)then -for x=1,cd do local _ba=bb(x/cd*__a+0.5)aaa=aaa.. -ab(d_a[daa][1],_ba,_ba) -baa=baa..ab(d_a[daa][2],_ba,_ba)caa=caa..ab(d_a[daa][3],_ba,_ba)end;table.insert(_aa,{aaa,baa,caa})end end;table.insert(b_a,c_a,_aa)else b_a[c_a]=d_a end end;b_a.width=cd;b_a.height=dd;return b_a end -return{loadNFP=_c,loadBIMG=ac,loadImage=dc,resizeBIMG=ad,loadImageAsBimg=_d}end -aa["libraries"]["layout"]=function(...) -local function ab(cb)local db={}db.___value=nil;db.___name=cb -db.___children={}db.___props={}function db:value()return self.___value end;function db:setValue(_c) -self.___value=_c end;function db:name()return self.___name end;function db:setName(_c) -self.___name=_c end;function db:children()return self.___children end;function db:numChildren()return -#self.___children end -function db:addChild(_c) -if -self[_c:name()]~=nil then if -type(self[_c:name()].name)=="function"then local ac={}table.insert(ac,self[_c:name()]) -self[_c:name()]=ac end -table.insert(self[_c:name()],_c)else self[_c:name()]=_c end;table.insert(self.___children,_c)end;function db:properties()return self.___props end;function db:numProperties() -return#self.___props end -function db:addProperty(_c,ac)local bc="@".._c -if self[bc]~=nil then if -type(self[bc])=="string"then local cc={}table.insert(cc,self[bc]) -self[bc]=cc end -table.insert(self[bc],ac)else self[bc]=ac end -table.insert(self.___props,{name=_c,value=self[_c]})end;return db end;local bb={} -function bb:ToXmlString(cb)cb=string.gsub(cb,"&","&") -cb=string.gsub(cb,"<","<")cb=string.gsub(cb,">",">") -cb=string.gsub(cb,"\"",""") -cb=string.gsub(cb,"([^%w%&%;%p%\t% ])",function(db) -return string.format("&#x%X;",string.byte(db))end)return cb end -function bb:FromXmlString(cb) -cb=string.gsub(cb,"&#x([%x]+)%;",function(db) -return string.char(tonumber(db,16))end) -cb=string.gsub(cb,"&#([0-9]+)%;",function(db)return string.char(tonumber(db,10))end)cb=string.gsub(cb,""","\"") -cb=string.gsub(cb,"'","'")cb=string.gsub(cb,">",">") -cb=string.gsub(cb,"<","<")cb=string.gsub(cb,"&","&")return cb end;function bb:ParseArgs(cb,db) -string.gsub(db,"(%w+)=([\"'])(.-)%2",function(_c,ac,bc) -cb:addProperty(_c,self:FromXmlString(bc))end)end -function bb:ParseXmlText(cb) -local db={}local _c=ab()table.insert(db,_c)local ac,bc,cc,dc,_d;local ad,bd=1,1 -while true do -ac,bd,bc,cc,dc,_d=string.find(cb,"<(%/?)([%w_:]+)(.-)(%/?)>",ad)if not ac then break end;local dd=string.sub(cb,ad,ac-1) -if not -string.find(dd,"^%s*$")then -local __a=(_c:value()or"")..self:FromXmlString(dd)db[#db]:setValue(__a)end -if _d=="/"then local __a=ab(cc)self:ParseArgs(__a,dc) -_c:addChild(__a)elseif bc==""then local __a=ab(cc)self:ParseArgs(__a,dc) -table.insert(db,__a)_c=__a else local __a=table.remove(db)_c=db[#db] -if#db<1 then error("XmlParser: nothing to close with ".. -cc)end;if __a:name()~=cc then -error("XmlParser: trying to close "..__a.name.." with "..cc)end;_c:addChild(__a)end;ad=bd+1 end;local cd=string.sub(cb,ad)if#db>1 then -error("XmlParser: unclosed "..db[#db]:name())end;return _c end -function bb:loadFile(cb,db)if not db then db=system.ResourceDirectory end -local _c=system.pathForFile(cb,db)local ac,bc=io.open(_c,"r") -if ac and not bc then local cc=ac:read("*a") -io.close(ac)return self:ParseXmlText(cc),nil else print(bc)return nil end end;return bb end -aa["libraries"]["module"]=function(...)return function(ab)local bb,cb=pcall(da,ab) -return bb and cb or nil end end -aa["libraries"]["process"]=function(...)local ab={}local bb={}local cb=0 -local db=dofile("rom/modules/main/cc/require.lua").make -function bb:new(_c,ac,bc,...)local cc={...} -local dc=setmetatable({path=_c},{__index=self})dc.window=ac;ac.current=term.current;ac.redirect=term.redirect -dc.processId=cb -if(type(_c)=="string")then -dc.coroutine=coroutine.create(function() -local _d=shell.resolveProgram(_c)local ad=setmetatable(bc,{__index=_ENV})ad.shell=shell -ad.basaltProgram=true;ad.arg={[0]=_c,table.unpack(cc)} -ad.require,ad.package=db(ad,fs.getDir(_d)) -if(fs.exists(_d))then local bd=fs.open(_d,"r")local cd=bd.readAll() -bd.close()local dd=load(cd,_c,"bt",ad)if(dd~=nil)then return dd()end end end)elseif(type(_c)=="function")then -dc.coroutine=coroutine.create(function() -_c(table.unpack(cc))end)else return end;ab[cb]=dc;cb=cb+1;return dc end -function bb:resume(_c,...)local ac=term.current()term.redirect(self.window) -if( -self.filter~=nil)then if(_c~=self.filter)then return end;self.filter=nil end;local bc,cc=coroutine.resume(self.coroutine,_c,...)if bc then -self.filter=cc else printError(cc)end;term.redirect(ac) -return bc,cc end -function bb:isDead() -if(self.coroutine~=nil)then -if -(coroutine.status(self.coroutine)=="dead")then table.remove(ab,self.processId)return true end else return true end;return false end -function bb:getStatus()if(self.coroutine~=nil)then -return coroutine.status(self.coroutine)end;return nil end -function bb:start()coroutine.resume(self.coroutine)end;return bb end -aa["libraries"]["tHex"]=function(...) -return -{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}end -aa["libraries"]["utils"]=function(...) -local ab,bb,cb=string.sub,string.find,string.reverse -local function db(ad,bd)local cd={}if ad==""or bd==""then return cd end;local dd=1 -local __a,a_a=bb(ad,bd,dd)while __a do table.insert(cd,ab(ad,dd,__a-1))dd=a_a+1 -__a,a_a=bb(ad,bd,dd)end -table.insert(cd,ab(ad,dd))return cd end -local _c={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local ac,bc,cc={},{},{}for i=0,15 do bc[2 ^i]=i end -do local ad="0123456789abcdef" -for i=1,16 do ac[ad:sub(i,i)]= -i-1;ac[i-1]=ad:sub(i,i) -cc[ad:sub(i,i)]=2 ^ (i-1)cc[2 ^ (i-1)]=ad:sub(i,i)local bd=_c[i-1]for i=1,#bd do -bd[i]=2 ^bd[i]end end end -local function dc(ad)local bd=_c[bc[ad[#ad][1]]] -for j=1,#bd do local cd=bd[j]for i=1,#ad-1 do if -ad[i][1]==cd then return i end end end;return 1 end -local function _d(ad,bd) -if not bd then local dd={}bd={}for i=1,6 do local __a=ad[i]local a_a=bd[__a] -bd[__a],dd[i]=a_a and(a_a+1)or 1,__a end;ad=dd end;local cd={}for dd,__a in pairs(bd)do cd[#cd+1]={dd,__a}end -if#cd>1 then -while -#cd>2 do -table.sort(cd,function(d_a,_aa)return d_a[2]>_aa[2]end)local __a,a_a=dc(cd),#cd;local b_a,c_a=cd[a_a][1],cd[__a][1] -for i=1,6 do if ad[i]==b_a then -ad[i]=c_a;cd[__a][2]=cd[__a][2]+1 end end;cd[a_a]=nil end;local dd=128 -for i=1,#ad-1 do if ad[i]~=ad[6]then dd=dd+2 ^ (i-1)end end;return string.char(dd), -cc[cd[1][1]==ad[6]and cd[2][1]or cd[1][1]],cc[ad[6]]else -return"\128",cc[ad[1]],cc[ad[1]]end end -return -{getTextHorizontalAlign=function(ad,bd,cd,dd)ad=ab(ad,1,bd)local __a=bd-string.len(ad) -if(cd=="right")then ad=string.rep( -dd or" ",__a)..ad elseif(cd=="center")then -ad=string.rep(dd or" ",math.floor( -__a/2))..ad.. -string.rep(dd or" ",math.floor(__a/2)) -ad=ad.. (string.len(ad) -bd do local b_a=bb(cb(ab(a_a,1,bd))," ")if not b_a then b_a=bd else -b_a=bd-b_a+1 end;local c_a=ab(a_a,1,b_a) -table.insert(dd,c_a)a_a=ab(a_a,b_a+1)end;if#a_a>0 then table.insert(dd,a_a)end end;return dd end,getValueFromXML=function(ad,bd) -local cd;if(type(bd)~="table")then return end;if(bd[ad]~=nil)then -if -(type(bd[ad])=="table")then if(bd[ad].value~=nil)then cd=bd[ad]:value()end end end;if(cd==nil)then -cd=bd["@"..ad]end;if(cd=="true")then cd=true elseif(cd=="false")then cd=false elseif(tonumber(cd)~=nil)then -cd=tonumber(cd)end;return cd end,numberFromString=function(ad)return load( -"return "..ad)()end,uuid=function() -local ad=math.random -local function bd()local cd='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'return -string.gsub(cd,'[xy]',function(dd)local __a= -(dd=='x')and ad(0,0xf)or ad(8,0xb) -return string.format('%x',__a)end)end;return bd()end,array=function(ad,bd)return -load( -"return {".. -("nil,"):rep(ad).. ("[0]=nil,"):rep(bd).."}")()end,shrink=function(ad,bd)local cd,dd,__a,a_a={{},{},{}},0, -#ad+#ad%3,bd or colours.black;for i=1,#ad do if -#ad[i]>dd then dd=#ad[i]end end -for y=0,__a-1,3 do -local b_a,c_a,d_a,_aa={},{},{},1 -for x=0,dd-1,2 do local aaa,baa={},{} -for yy=1,3 do -for xx=1,2 do -aaa[#aaa+1]=(ad[y+yy]and ad[y+yy][x+xx])and -(ad[y+ -yy][x+xx]==0 and a_a or ad[y+yy][x+xx])or a_a;baa[aaa[#aaa]]= -baa[aaa[#aaa]]and(baa[aaa[#aaa]]+1)or 1 end end;b_a[_aa],c_a[_aa],d_a[_aa]=_d(aaa,baa)_aa=_aa+1 end -cd[1][#cd[1]+1],cd[2][#cd[2]+1],cd[3][#cd[3]+1]=table.concat(b_a),table.concat(c_a),table.concat(d_a)end;cd.width,cd.height=#cd[1][1],#cd[1]return cd end}end;return aa["main"]() \ No newline at end of file