Community Curator/Source/TSWRes GameCM1

-- Create Mode Start Menu --

-- Gets the icon touched function CLDIcoTapped(TX, TY, Scroll) t2=t2 or t  local X1 = 32 local X2, Y2 = SizeX - 32, SizeY-32 local FunX,FunY = 32, 64 local DwSize, IcoSize = 1, 64 local OptSz = 64 local DISz = (IcoSize*DwSize) for k,v in pairs(Stickers) do     local TappedIcon = TRec(FunX, FunY, FunX+64, FunY+64, TX, TY + Scroll) if TappedIcon then LevelTab["Icon"] = k        Action = "Close" return k     end FunX = FunX + OptSz if FunX + OptSz > X2 then FunX, FunY = X1, FunY + OptSz end end end

-- Icon Menu Touch function CLDIcoTouch(TX, TY) local ClosePress = TRec(32, 32, 64, 64, TX, TY) local Scroll = 0 if ClosePress then Action = "Close" return else CLDIcoTapped(TX, TY, Scroll) end end

-- Level Icons function GT.LDIconsMenu for i=1, math.huge do     draw.tracktouches(Nil, Nil, CLDIcoTouch) local OldTime = sys.gettime Action = nil draw.beginframe Draw.BGs.CLDIconsMenu draw.endframe draw.doevents if Action == "Close" then Action = nil return end end end

-- Labels Menu Touch function CLDLabTouch(TX, TY) local ClosePress = TRec(32, 32, 64, 64, TX, TY) if ClosePress then Action = "Close" return end end

-- Labels function GT.LDLabelsMenu for i=1, math.huge do     local OldTime = sys.gettime draw.tracktouches(Nil, Nil, CLDLabTouch) Action = nil draw.beginframe Draw.BGs.CLDLabelsMenu draw.endframe draw.doevents if Action == "Close" then Action = nil return end end end

-- Create Mode Level Details Touch function CLDMTouch(TX, TY) local ClosePress = TRec(32, 32, 64, 64, TX, TY) local LvNamePress = TRec(64, 32, SizeX-64, 64, TX, TY) local LvDescTap = TRec(64, 64, SizeX - 32, SizeY-128, TX, TY) local LvLabTap = TRec(SizeX - 128, SizeY-96, SizeX - 32, SizeY-64, TX, TY) local LvIconTap = TRec(64, SizeY-96, 256, SizeY-32, TX, TY) if ClosePress then Action = "Close" return elseif LvNamePress then Action = "Name" return elseif LvDescTap then Action = "Description" return elseif LvLabTap then Action = "Labels" return elseif LvIconTap then Action = "Icon" return end end

-- The Level Details Menu function GT.LevelDetailsMenu Action = nil --if type(LevelTab) ~= "table" then  LevelTab = {["Name"] = "Broken Level", ["Description"] = "This level had no LevelTab."} end for i=1, math.huge do     local OldTime = sys.gettime draw.tracktouches(Nil, Nil, CLDMTouch) Action = nil draw.beginframe Draw.BGs.CLDMenu draw.endframe draw.doevents if Action == "Name" then if Key == nil then Key = require "TSKeyboard" SX, SY = draw.getport end LevelTab["Name"] = Key.Keyboard("Level Name", LevelTab["Name"]) elseif Action == "Description" then if Key == nil then Key = require "TSKeyboard" SX, SY = draw.getport end LevelTab["Description"] = Key.Keyboard("Level Description", LevelTab["Description"]) elseif Action == "Icon" then GT.LDIconsMenu elseif Action == "Labels" then GT.LDLabelsMenu elseif Action == "Close" then Action = nil return end ToPod = nil Action = nil local NewTime = sys.gettime local Frame = (NewTime-OldTime) CG sys.sleep(((1/FR)-(Frame))*1000) end end

-- Create Mode Start Menu Touch function CSMTouch(TX, TY) local ClosePress = TRec(32, 32, 64, 64, TX, TY) local LvDetPress = TRec(64, 32, SizeX-64, 64, TX, TY) local SaveTap = TRec(64, 96, 128, 128, TX, TY) local ReToPoTap = TRec(64, 160, 192, 192, TX, TY) local GridOffTap = TRec(224, 160, 256, 192, TX, TY) local GridSmallTap = TRec(256, 160, 288, 192, TX, TY) if ClosePress then Action = "Close" return elseif SaveTap then Action = "Save" return elseif ReToPoTap then Action = "ToPod" return elseif LvDetPress then Action = "LevelDetails" return elseif GridOffTap then Grid = nil return elseif GridSmallTap then Grid = 32 return elseif GridMediumTap then Grid = 64 return end end

-- Create Mode Start Menu function GT.CStartMenu draw.tracktouches(Nil, Nil, CSMTouch) Action = nil --if type(LevelTab) ~= "table" then  LevelTab = {["Name"] = "Broken Level", ["Description"] = "This level had no LevelTab."} end for i=1, math.huge do     draw.tracktouches(Nil, Nil, CSMTouch) local OldTime = sys.gettime Action = nil draw.beginframe Draw.BGs.CStartMenu draw.endframe draw.doevents if Action == "Close" then return elseif Action == "Save" then --print("Saving Level...") GT.SaveLevel(GT.Vars.CurrentLevel) return elseif Action == "ToPod" then ToPod = true return elseif Action == "PlayMode" then

elseif Action == "LevelDetails" then GT.LevelDetailsMenu end ToPod = nil Action = nil local NewTime = sys.gettime local Frame = (NewTime-OldTime) if Frame < 1/FR then CG end sys.sleep(((1/FR)-(Frame))*1000) end end

return