Community Curator/Source/TSWRes Popit

PopitRes = {}

print("Popit Menus Loading")

function GT.PCTouch(TX, TY) local PopitClosed = TRec(SizeX-96, SizeY-96, SizeX-32, SizeY-32,TX,TY) if ObjSelected == nil then if PopitClosed then ToolClosed = true return "Close" end for k,v in pairs(ObjTab) do        local ObjTap = TRec(v["X"]- 16 -CamX, v["Y"]- 16 +CamY, (v["X"] + v["Size"])+ 4-CamX, (v["Y"] + v["Size"])+ 4+CamY, TX, TY) if ObjTap == true then if k > 4 then ObjSelected = k           end end end else local Object = ObjTab[ObjSelected] print(Object["Size"]) --print(ObjSelected) if PopitClosed then LTV = LTV - Object["TVal"] table.remove(ObjTab, ObjSelected) PopitRes.DeleteSound end if not Grid then Object["X"] = TX + CamX Object["Y"] = TY - CamY else Object["X"] = math.round((TX + CamX)/Grid)*Grid Object["Y"] = math.round((TY - CamY)/Grid)*Grid end ObjSelected = nil end end

function GT.PopitHold(TX, TY) CamMove(TX, TY) if ObjSelected then local Object = ObjTab[ObjSelected] local SizeUp = TRec(32, 32, 64, 64,TX,TY) local SizeDown = TRec(64, 32, 96, 64,TX,TY) if SizeUp then Object["Size"] = Object["Size"] + (Grid or 4) elseif SizeDown then Object["Size"] = Object["Size"] - (Grid or 4) end else if not TRec(PCStartX - 16, PCStartY - 16, PCStartX + 16, PCStartY + 16, TX, TY) then PCEdgeX, PCEdgeY = TX, TY     else PCEdgeX, PCEdgeY = nil, nil end end end

function GT.PoCuStart(TX, TY) PCStartX, PCStartY = TX, TY end

function GT.PopitCursor --print("Tag") Undo = false ObjSelected = nil for i=1, math.huge do     GT.DrawCMFrame draw.tracktouches(GT.PoCuStart, GT.PopitHold, GT.PCTouch) draw.doevents if ToolClosed then return end collectgarbage end end

function GT.PopitGTI(t, TX, TY) local X1,Y1,X2,Y2 = SizeX-(32*6), 64, SizeX-64, SizeY-32

--local X2, Y2 = X2 or SizeX, Y2 or SizeY local FunX,FunY = X1, Y1  local DwSize, IcoSize = 1, 32 local OptSz = 32 local DISz = (IcoSize*DwSize) local Odd = false for k,v in ipairs(t) do     local Tapped = TRec(FunX, FunY, FunX+32, FunY + 32, TX, TY) --print(k, Tapped) if Tapped then return k     end FunX = FunX + OptSz if FunX > X2 then FunX, FunY = X1, FunY + OptSz end end return false end

function GT.PopitGTIR(t, TX, TY) local X1,Y1,X2,Y2 = SizeX-(32*6), 64, SizeX-64, SizeY-32

--local X2, Y2 = X2 or SizeX, Y2 or SizeY local FunX,FunY = X1, Y1  local DwSize, IcoSize = 1, 32 local OptSz = 32 local DISz = (IcoSize*DwSize) local Odd = false for k,v in pairs(t) do     local Tapped = TRec(FunX, FunY, FunX+32, FunY + 32, TX, TY) --print(k, Tapped) if Tapped then return k     end FunX = FunX + OptSz if FunX > X2 then FunX, FunY = X1, FunY + OptSz end end return false end

function GT.PopitMenu(TX,TY) local TRec = TRec if not PopitOpen then return end local PopitClosed = TRec(SizeX-64, 32, SizeX-32, 64, TX, TY) if PopitClosed then PopitOpen = false SelectedMaterial = nil end if PopitCuMenu == "Home" then local ObjTap =TRec(SizeX-(32*5), 64, SizeX-(32*3.5), 64+(32*1.5),TX,TY) local TutTap = TRec(SizeX-112, 64, SizeX-64, 112, TX, TY) local PopCurTap =TRec(SizeX-(32*5), 112, SizeX-(32*3.5), 112+(32*1.5),TX,TY) local StiTap = TRec(SizeX-112, 112, SizeX-64, 160, TX, TY) local ToolsTap =TRec(SizeX-(32*5), 160, SizeX-(32*3.5), 160+(32*1.5),TX,TY) local CosTap =TRec(SizeX-112, 160, SizeX-64, 160+(32*1.5),TX,TY) local SaveTap =TRec(SizeX-(32*5), 208, SizeX-(32*3.5), 208+(32*1.5),TX,TY) local TestTap =TRec(SizeX-112, 208, SizeX-64, 208+(32*1.5),TX,TY) if ObjTap then PopitCuMenu = "Materials" elseif TutTap then --GT.TutorialMenu elseif PopCurTap then PopitOpen = false PopitCuTool = "Popit Cursor" GT.PopitCursor elseif StiTap then PopitCuMenu = "Stickers" elseif ToolsTap then PopitCuMenu = "Tools Bag" elseif CosTap then PopitCuMenu = "Costume Materials" elseif SaveTap then --PopitOpen = false        draw.setscreen(0)         print("Saving Level...")         GT.SaveLevel(1)         draw.setscreen(1) GT.CStartMenu elseif TestTap then Error, EMes = pcall(GT.TestMode) print(EMes) end elseif PopitCuMenu == "Stickers" then local Key = GT.PopitGTI(PopitRes.PMSelPage[PopitCuMenu], TX, TY) local Tag = PopitRes.PMSelPage[PopitCuMenu] if Key ~= false then PopitOpen = false CorTab = Key if type(Tag[Key]) == "string" then StickerSelected = GT.CreStiTab(Tag[Key], 0, 0, 0) PopitRes.StickerCursor else Tag[Key] end end elseif PopitCuMenu == "Materials" then local Key = GT.PopitGTIR(PopitRes.PMSelPage[PopitCuMenu], TX, TY) if Key ~= false then SelectedMaterial = Key PopitCuMenu = "Shapes" end elseif PopitCuMenu == "Costume Materials" then local Key = GT.PopitGTIR(PopitRes.PMSelPage[PopitCuMenu], TX, TY) if Key ~= false then SackMat = Key end else local Key = GT.PopitGTI(PopitRes.PMSelPage[PopitCuMenu], TX, TY) local Tag = PopitRes.PMSelPage[PopitCuMenu] --print("Tag "..tostring(Tag)) if Key ~= false then PopitOpen = false CorTab = Key if type(Tag[Key]) == "string" then PopitRes.ObjectCursor(Tag[Key]) else Tag[Key] end end end end

require "TSWRes Tool1"

PopitRes.PMPage = {} local PMPage = PopitRes.PMPage PMPage["Materials"] = ObjMaterials PMPage["Shapes"] = { [1] = "Square", [2] = "Circle", [3] = "Triangle", [4] = "Pentagon", [5] = "Hexagon", [6] = "Octagon", [7] = "MatCha" } PMPage["Stickers"] = {[1] = "StickerEditor", [2] = "LBPPick"} PMPage["Tools Bag"] = {"CorEdi", "StartGate", "FinishGate", "ScoreBubble", "Scoreboard"} PMPage["Costumes"] = {} PMPage["Costume Materials"] = SackboyMaterials

PopitRes.PMSelPage = {} local PMSelPage = PopitRes.PMSelPage PMSelPage["Materials"] = ObjMaterials PMSelPage["Shapes"] = { [1] = "Square", [2] = "Circle", [3] = "Triangle", [4] = "Pentagon", [5] = "Hexagon", [6] = "Octagon", [7] = PopitRes.MaterialChanger } PMSelPage["Stickers"] = {[1] = PopitRes.StickerEditor, [2] = "LBPPick"} PMSelPage["Tools Bag"] = {PopitRes.CorEditor, "StartGate", "FinishGate", "ScoreBubble", "Scoreboard"} PMSelPage["Costumes"] = {} PMSelPage["Costume Materials"] = SackboyMaterials

function PopitRes.SplatterSound sys.alert("drop") end

function PopitRes.PlaceSound sys.alert("drop") end

function PopitRes.UnavailSound sys.alert("tink") sys.alert("neg") sys.alert("drop") end

function PopitRes.DeleteSound sys.alert("neg") end

function PopitRes.PhysicsSound sys.alert("drop") end

return PopitRes