Community Curator/Source/TSWRes Draw

local print = print print("Draw functions loading") local D255 = 1/255 draw.setscreen(1) Draw = {}

Col255MT = require "TSWRes Col255MetaTable"

setmetatable(draw.white, Col255MT) setmetatable(draw.black, Col255MT) setmetatable(draw.blue, Col255MT) setmetatable(draw.brown, Col255MT) setmetatable(draw.red, Col255MT) setmetatable(draw.cyan, Col255MT) setmetatable(draw.green, Col255MT) setmetatable(draw.orange, Col255MT) setmetatable(draw.yellow, Col255MT) setmetatable(draw.purple, Col255MT) setmetatable(draw.gray, Col255MT) setmetatable(draw.lightgray, Col255MT) setmetatable(draw.darkgray, Col255MT) draw.lightGray = draw.lightgray draw.darkGray = draw.darkgray

function Draw.Col255(R,G,B,A) A = A or 255 local Tab = {R*D255,G*D255,B*D255,A*D255} Tab = setmetatable(Tab, Col255MT) -- use return Tab end Col255 = Draw.Col255

Draw.BGs = {} function Draw.BGs.Loading draw.clear(draw.black) draw.string("Please Wait...", 128, 256, draw.white) end

draw.beginframe Draw.BGs.Loading draw.endframe

Draw.Popit = {} Draw.Icons = {}

function Draw.Icons.Save(X,Y,Size) local FillRoundRect, FillTriangle = draw.fillroundedrect, draw.filltriangle local DSR = 4*Size local RX, RY = 32*Size, 32*Size local TX1, TY1, TX2, TY2, TX3 = 4*Size, 8*Size, 16*Size, 28*Size, 28*Size FillRoundRect(X, Y, (X)+RX, (Y)+RY, DSR, draw.blue) FillTriangle(X+TX1, Y+TY1, X+TX2, Y+TY2, X+TX3, Y+TY1, draw.lightGray) end

-- Draw Buttons --

function Draw.PodButton(Str, X1, Y1, X2, Y2, FCol) local XSize = X2-X1 draw.fillroundedrect(X1, Y1, X2, Y2, 4, FCol) draw.roundedrect(X1, Y1, X2, Y2, 4, draw.black) draw.string(Str, X1+( (XSize) / 2 - (draw.stringsize(Str)/2)), Y2 - 24, draw.black) end

function Draw.DPad(DX, DY, BgCol, FgCol) local TSz=32 local LSz=TSz*2 local XSz=TSz*3 draw.rect(DX, DY, DX+XSz, DY+XSz, BgCol) draw.rect(DX+TSz, DY, DX+LSz, DY+TSz, FgCol) draw.rect(DX+TSz, DY+LSz, DX+LSz, DY+XSz, FgCol) draw.rect(DX, DY+TSz, DX+TSz, DY+LSz, FgCol) draw.rect(DX+LSz, DY+TSz, DX+XSz, DY+LSz, FgCol) end

-- Backgrounds --

require "TSWRes BGs"

-- In-game stuff

-- Popit Menu

function Draw.Popit.LaBg local FillColor = PlayCol1 draw.fillroundedrect( SizeX-(32*6), 32, SizeX-32, SizeY-32, 4, FillColor ) Draw.PodButton("X", SizeX-64, 32, SizeX-32, 64, FillColor) draw.string(PopitCuMenu, SizeX - (32*5), 36, draw.black) end

function Draw.Popit.Home local rect, SizeX = draw.rect, SizeX rect(SizeX-(32*5), 64, SizeX-(32*3.5), 64+(32*1.5), draw.black)

rect(SizeX-112, 64, SizeX-64, 112, draw.black) draw.setfont("Arial", 32) draw.string("?", SizeX-112, 64, draw.black) draw.setfont("Arial", 16)

rect(SizeX-(32*5), 112, SizeX-(32*3.5), 160, draw.black) Draw.PopitCursor(SizeX-((32*5)-(24)), 136, 32)

rect(SizeX-112, 112, SizeX-64, 160, draw.black)

rect(SizeX-(32*5), 160, SizeX-(32*3.5), 208, draw.black)

rect(SizeX-112, 160, SizeX-64, 208, draw.black)

rect(SizeX-(32*5), 208, SizeX-(32*3.5), 256, draw.black) Draw.Icons.Save(SizeX-(32*5),208,1.5)

rect(SizeX-112, 208, SizeX-64, 256, draw.black) draw.filltriangle( SizeX-112, 208, SizeX-64, 256-24, SizeX-112, 256, PlayCol2 ) end

function Draw.Popit.ContentMenu Draw.PrintIcons(PMPage[PopitCuMenu], SizeX-(32*6), 96, SizeX-64, SizeY-32) end

function Draw.Popit.MaterialsMenu Draw.PrintMaterials(ObjMaterials, SizeX-(32*6), 96, SizeX-64, SizeY-32) end

function Draw.Popit.SackboyMaterialsMenu Draw.PrintMaterials(SackboyMaterials, SizeX-(32*6), 96, SizeX-64, SizeY-32) end

function Draw.Popit.StickersMenu Draw.PrintStickersPopit( PopitRes.PMPage["Stickers"],SizeX-(32*6), 96, SizeX-64, SizeY-32) end

function Draw.Popit.Menu if PopitOpen == false then return end Draw.Popit.LaBg if PopitCuMenu == "Home" then Draw.Popit.Home elseif PopitCuMenu == "Costume Materials" then Draw.Popit.SackboyMaterialsMenu elseif PopitCuMenu == "Materials" then Draw.Popit.MaterialsMenu elseif PopitCuMenu == "Stickers" then Draw.Popit.StickersMenu else Draw.PrintIcons( PopitRes.PMPage[PopitCuMenu], SizeX-(32*6), 64, SizeX-64, SizeY-32) end end

-- Draw Tools -- require "TSWRes DrawToolIco"

-- Draw Objects require "TSWRes DrawObjects"

-- Status Bar --

local function StrIfTrueElse(Boolean, StrT, StrF) if Boolean == true then return StrT end return StrF end

local function UHOH(Overhead) local Neg = true Overhead = tonumber((1/FR)-Overhead) if tonumber(Overhead) >=0 then Neg = false end local OveStr=StrIfTrueElse(Neg, "overhead", "underhead") local OverStr=string.sub(tostring(math.abs(Overhead)),3, 6) local RetStr = ("("..(OverStr).."ms "..OveStr..")") return RetStr end

function Draw.StatusBar(FS) local FSSub = string.sub(tostring(FS), 3, 6) local OS = string.sub(tostring(FS*(1/FR)), 3, 6) local StatStr = "Draw: "..FSSub.."ms "..UHOH(FS)..", LTV: "..LTV.."/"..MT.." ("..LTV/MT..")" draw.string(StatStr, 24, SizeY-24, draw.black) draw.string("RAM: "..ObjRes.BytesPlus(collectgarbage("count")*1024), SizeX-180, 24, draw.black) end

require "TSWRes Draw1" require "TSWRes DrawCM"

return Draw