
require "scripts/style"
require "scripts/widgets/topbar"



ButtonsList = {};


CostPopupFont = {
  standardFont,
  15,
  WhiteColor
};


-- The "Twodemos" game handles its messages in Lua, unlike the "TGame" game
-- which handles them in C++.
function SendScriptMessage( msg, data )
	if msg=="back" then
    SwapToModal("scripts/mapmenu.lua");							
	end
	if msg=="planexecute" then
    SendModalMessage("executeplan",0);	
	end
	if msg=="planstart" then
				-- Tell TSettings what game mode we're entering
				SetCurrentGameMode(0);
				-- Switch to the appropriate screen
        SendModalMessage("startlevel",0);	
				SwapToModal("scripts/gameboard.lua");												
	end
end


SetState( kGameMode, "pregame" );

MakeDialog
{
	-- Name the modal dialog
	name="planmetamenu",
	PlanMetaMenu
	{
    font = StandardButtonFont,    
    partw = 90,
		fit=true,
		
		PlanColorGo    = Color(255,255,255,128),
		PlanColorStop  = Color(255,0,0,255),
		
		Bitmap
		{
		 
			name="backgroundimage",
			image="planmetascreen/background",
		  Bitmap
		  {
         name="planwindow",
        x = 0, y = 370,
        w = kMax, h = 230,
		  },
		  SortWindow
		  {
         name="platformwindow",
        x = 0, y = 0,
        w = kMax, h = 400,
		  },

    AnimSprite
    {
      name='lights',
      x=400,y=305,-- from the center
             
      xRef = 0, yRef = 0,
      animations={
        { key="idle", texture="planmetascreen/lights/lights", animation="main", default=1},
      },
    },        



      AnimSprite 
      {
        x=0, y=0, --from the center
        w=45, h=45,
        name="minions",
        animations={
          { key="idle", texture="", animation="", default="1"},
          { key="minion01", texture="planmetascreen/minion_animation/minions_01", animation="main", next="minion02"},
          { key="minion02", texture="planmetascreen/minion_animation/minions_02", animation="main", next="minion03"},
          { key="minion03", texture="planmetascreen/minion_animation/minions_03", animation="main", next="minion04"},
          { key="minion04", texture="planmetascreen/minion_animation/minions_04", animation="main", next="minion05"},
          { key="minion05", texture="planmetascreen/minion_animation/minions_05", animation="main", next="minion06"},
          { key="minion06", texture="planmetascreen/minion_animation/minions_06", animation="main", next="minion07"},
          { key="minion07", texture="planmetascreen/minion_animation/minions_07", animation="main", next="minion08"},
          { key="minion08", texture="planmetascreen/minion_animation/minions_08", animation="main", next="minion09"},
          { key="minion09", texture="planmetascreen/minion_animation/minions_09", animation="main", next="minion10"},
          { key="minion10", texture="planmetascreen/minion_animation/minions_10", animation="main", next="minion11"},
          { key="minion11", texture="planmetascreen/minion_animation/minions_11", animation="main", next="minion12"},
          { key="minion12", texture="planmetascreen/minion_animation/minions_12", animation="main", next="minion13"},
          { key="minion13", texture="planmetascreen/minion_animation/minions_13", animation="main", next="minion14"},
          { key="minion14", texture="planmetascreen/minion_animation/minions_14", animation="main", next="minion15"},
          { key="minion15", texture="planmetascreen/minion_animation/minions_15", animation="main", next="minion16"},
          { key="minion16", texture="planmetascreen/minion_animation/minions_16", animation="main", next="minion17"},
          { key="minion17", texture="planmetascreen/minion_animation/minions_17", animation="main", next="minion18"},
          { key="minion18", texture="planmetascreen/minion_animation/minions_18", animation="main", next="idle"},
        },
      },
      
      
      AnimSprite 
      {
        x=750, y=400, --from the center        
        name="stairminions",
        animations={
          { key="idle", texture="planmetascreen/minion_idle/minion_idle_01", animation="main", default="1" },
        }
      },

		  
		  StateWindow {
        x=595, y=392,
        w=205, h=207, --maximum w/h
        default="off",
        name="planbutton",
        Button
			{
				x=0,
				y=0,
				name="off",				
					type = kPush,
				graphics = {
          "planmetascreen/gobutton/off",
          "planmetascreen/gobutton/off",
          "planmetascreen/gobutton/off",
        },		
				command=
				function()				   
				end				
			},
			Button
			{
				x=0,
				y=0,
				name="playlevel",				
					type = kPush,
				graphics = {
          "planmetascreen/gobutton/play_off",
          "planmetascreen/gobutton/play_click",
          "planmetascreen/gobutton/play_hover",
        },		
        rolloversound="audio/sfx/Play_Button_Hover_Meta_Screen",	
				command=
				function()
				   SendScriptMessage( "planstart" );	      
				end				
			},
			
			Button
			{
	  		x=0,
				y=0,
				name="execute",				
					type = kPush,
				graphics = {
          "planmetascreen/gobutton/execute_off",
          "planmetascreen/gobutton/execute_click",
          "planmetascreen/gobutton/execute_hover",
        },					
        rolloversound="audio/sfx/Execute_Button_Hover_Meta_Screen",			

				command=
				function()
				   SendScriptMessage( "planexecute" );	      
				end				
			},
      },

			Bitmap
			{
        name="costpopup",
        x=0, y=0,
        w=225, h=300,
        image="planmetascreen/costpopup/background",
        Text
        {
              -- this is the text of cash money
              font = CostPopupFont,
              name = "itemname",             
              x=60,y=70,w=180,h=100,
              flags = kHAlignCenter + kVAlignTop,				              
        },       
        Window 
        {
          name="iconwindow",
          x=55, y=105,
          w=175, h=240,   
          
          Bitmap {x=0, y=7, image="planmetascreen/costpopup/coinsicon"},
          Text { x=70, y=5, w=100, h=50, name="count-coins", font={standardFont, 18, WhiteColor }, flags=kHAlignLeft + kVAlignCenter },
          Bitmap {x=0, y=62, image="planmetascreen/costpopup/chemicalsicon"},
          Text { x=70, y=60, w=100, h=50, name="count-chemical", font={standardFont, 18, WhiteColor }, flags=kHAlignLeft + kVAlignCenter },
          Bitmap {x=0, y=122, image="planmetascreen/costpopup/monstersicon"},
          Text { x=70, y=120, w=100, h=50, name="count-monster", font={standardFont, 18, WhiteColor }, flags=kHAlignLeft + kVAlignCenter },
          Bitmap {x=0, y=180, image="planmetascreen/costpopup/machinesicon"},
          Text { x=70, y=180, w=100, h=50, name="count-mechanical", font={standardFont, 18, WhiteColor }, flags=kHAlignLeft + kVAlignCenter },
                   
        },

			},
      

      SetStyle(ButtonStyle),      
			Button
			{
				x=3,
				y=565,
				name="back",
				label="back",
				type = kPush,							
				command=
				function()
				   SendScriptMessage( "back" );	      
				end	
			},
			
      
      MakeTopBar(),    
		},
		
	}
}