
require "scripts/style"


-- The "Twodemos" game handles its messages in Lua, unlike the "TGame" game
-- which handles them in C++.
function SendMapGameMessage( msg, data )
	if msg=="back" then
		QuitToMainMenu();
	end
	if msg=="planstart" then
	-- assume we have set the current plan already
    SwapToModal("scripts/planmenu.lua");
	end
  if msg=="planselect" then
  			if (CheckUsers()) then
							-- Tell TSettings what game mode we're entering
							-- SetCurrentGameMode(0);
							-- Switch to the appropriate screen
							SelectPlan(data);
							-- SwapToModal("scripts/planmenu.lua");
							-- assume we have set the current plan already
              SwapToModal("scripts/planmenu.lua");
				end
  end

end


PlansList = {};


function StepButton(planIDX, planID, stepX, stepY, buttonArt, labelOn)
  PlansList[planIDX] = { plan=planID, button=labelOn, posX=stepX,posY=stepY };
	return StateWindow {
      name=labelOn,
      x=stepX, y=stepY,
 -- max w/h of step image
      w=200, h=200,
			Bitmap
			{
        name="off",
        image=buttonArt[4],        
        x=0, y=0,
			},	
			Button
			{
				x=0,y=0,
				name="on",
				type = kPush,
				sound="audio/sfx/Pushpin_Buttons_Click",
        rolloversound="audio/sfx/Pushpin_Buttons_Hover",
				graphics = {
          buttonArt[1],
          buttonArt[2],
          buttonArt[3],
        },
				command=
					function()
            SendMapGameMessage("planselect", planID);            
					end
			},
			Bitmap
      {
        x=0,y=0,
        image=buttonArt[5],
        name="complete",
      },
--      Button
--			{
--				x=0,y=0,
--				name="complete",
--				type = kPush,
--				sound="audio/sfx/Pushpin_Buttons_Click",
--        rolloversound="audio/sfx/Pushpin_Buttons_Hover",
--				graphics = {
--          buttonArt[5],
--          buttonArt[2],
--          buttonArt[3],
--        },
--				command=
--					function()
--            SendMapGameMessage("planselect", planID);
--					end
--			},
	}

end






MakeDialog
{
	-- Name the modal dialog
	name="mapmenu",
	MapMenu
	{
	
			
		fit=true;
		Bitmap
		{
			name="backgroundimage",
			image="mapscreen/corkboard",

      
      
      
      StepButton(1,"plan01",80,120,{                  
          "mapscreen/step01/step01on",
          "mapscreen/step01/step01selected",
          "mapscreen/step01/step01hover",
          "mapscreen/Step01/step01disabled",
          "mapscreen/Step01/step01complete",
        }, "Step01"),
        
      StepButton(2,"plan02",250,110,{      
          "mapscreen/step02/step02on",
          "mapscreen/step02/step02selected",
          "mapscreen/step02/step02hover",
          "mapscreen/Step02/step02disabled",
          "mapscreen/Step02/step02complete",
        }, "Step02"),
        
      StepButton(3,"plan03",430,120,{                  
          "mapscreen/step03/step03on",
          "mapscreen/step03/step03selected",
          "mapscreen/step03/step03hover",
          "mapscreen/Step03/step03disabled",
          "mapscreen/Step03/step03complete",
        }, "Step03"),
      StepButton(4,"plan04",600,110,{                  
          "mapscreen/step04/step04on",
          "mapscreen/step04/step04selected",
          "mapscreen/step04/step04hover",
          "mapscreen/Step04/step04disabled",
          "mapscreen/Step04/step04complete",
        }, "Step04"),
      StepButton(5,"plan05",70,260,{                  
          "mapscreen/step05/step05on",
          "mapscreen/step05/step05selected",
          "mapscreen/step05/step05hover",
          "mapscreen/Step05/step05disabled",
          "mapscreen/Step05/step05complete",
        }, "Step05"),
      StepButton(6,"plan06",250,250,{                  
          "mapscreen/step06/step06on",
          "mapscreen/step06/step06selected",
          "mapscreen/step06/step06hover",
          "mapscreen/Step06/step06disabled",
          "mapscreen/Step06/step06complete",
        }, "Step06"),
      StepButton(7,"plan07",430,250,{                  
          "mapscreen/step07/step07on",
          "mapscreen/step07/step07selected",
          "mapscreen/step07/step07hover",
          "mapscreen/Step07/step07disabled",
          "mapscreen/Step07/step07complete",
        }, "Step07"),
      StepButton(8,"plan08", 600,240,{                  
          "mapscreen/step08/step08on",
          "mapscreen/step08/step08selected",
          "mapscreen/step08/step08hover",
          "mapscreen/Step08/step08disabled",
          "mapscreen/Step08/step08complete",
        }, "Step08"),
      StepButton(9,"plan09",85,390,{                  
          "mapscreen/step09/step09on",
          "mapscreen/step09/step09selected",
          "mapscreen/step09/step09hover",
          "mapscreen/Step09/step09disabled",
          "mapscreen/Step09/step09complete",
        }, "Step09"),
      StepButton(10,"plan10",250,390,{                  
          "mapscreen/step10/step10on",
          "mapscreen/step10/step10selected",
          "mapscreen/step10/step10hover",
          "mapscreen/Step10/step10disabled",
          "mapscreen/Step10/step10complete",
        }, "Step10"),
      StepButton(11,"plan11",425,380,{                  
          "mapscreen/step11/step11on",
          "mapscreen/step11/step11selected",
          "mapscreen/step11/step11hover",
          "mapscreen/Step11/step11disabled",
          "mapscreen/Step11/step11complete",
        }, "Step11"),
      StepButton(12,"plan12",590,400,{                  
          "mapscreen/step12/step12on",
          "mapscreen/step12/step12selected",
          "mapscreen/step12/step12hover",
          "mapscreen/Step12/step12disabled",
          "mapscreen/Step12/step12complete",
        }, "Step12"),
      StepButton(13,"plan13",200,230,{                  
          "mapscreen/step13/step13on",
          "mapscreen/step13/step13selected",
          "mapscreen/step13/step13hover",
          "mapscreen/Step13/step13disabled",
          "mapscreen/Step13/step13complete",
        }, "Step13"),
      StepButton(14,"plan14",290,220,{                  
          "mapscreen/step14/step14on",
          "mapscreen/step14/step14selected",
          "mapscreen/step14/step14hover",
          "mapscreen/Step14/step14disabled",
          "mapscreen/Step14/step14complete",
        }, "Step14"),
      StepButton(15,"plan15",400,210,{                  
          "mapscreen/step15/step15on",
          "mapscreen/step15/step15selected",
          "mapscreen/step15/step15hover",
          "mapscreen/Step15/step15disabled",
          "mapscreen/Step15/step15complete",
        }, "Step15"),
      
     

			
			AnimButton
      {
        x=60,
				y=579,
				name="back",
				label="back",
				font = {
          standardFont,
          18,
          BlackColor
        },
        animations={
          { key="normal", texture="buttons/buttonup", animation="main", default=1},        
          { key="down", texture="buttons/buttondown", animation="main"},
          { key="hover", texture="buttons/buttonrollover", animation="main"},
          { key="disabled", texture="buttons/buttondisabled", animation="main"},
        },
        sound=kDefaultButtonSound,
        rolloversound=kDefaultButtonHoverSound,
				command=
				function()
				   SendMapGameMessage( "back" );	      
				end
      },
         

		},

	},
  
}