require "scripts/style"
require "scripts/characters/maggie"

kButtonSpacing = 60;	-- Put our buttons 60 pixels apart
kButtonY = kCenter-85;	-- Three buttons means center 60 pixels above the center

-- When this dialog is popped up, we're entering pause state, so
-- let's just notify TGameState now.
SetState( kPause, true );

MakeDialog
{
	-- Name the modal dialog
	name="levelendmenu",
	
	LevelEndDialog
	{
    x=0, y=0, w=kMax, h=kMax,
    --this is the background image. We have to do it in two parts,
    --  if we do it as one full-size image it will make the background black
    Group 
    {
      Bitmap
      {
        --  scene complete flyover
        name="shade",
        x=0, y=0, 
        autoscale=true,
        image="backgrounds/shade",
      },
      Bitmap
      {
        --  scene complete flyover
        name="shade",
        x=400, y=0, 
        autoscale=true,
        image="backgrounds/shade",
      },
    },
  
	Bitmap
	{
		image="popup/levelend/level_passed",
		x=kCenter,
		y=kCenter,

    Text
		{
				font = { standardFont, 28, WhiteColor },
				name = "levelend-title",
				x=40,y=10,w=(kMax-50),h=100,
				flags = kHAlignCenter + kVAlignCenter,
				label = "levelend"
    },
    


    -- failure text
    
    Text
    {
      x=220, y=120,
      w=330, h=320,
			font = { standardFont, 18, BlackColor },
			flags = kHAlignCenter + kVAlignCenter,
			name="levelend-text-failed",
			label="levelend-failed",
    },

    
    -- optional text that says "hey, good job!" or whatever.
    
    Text
    {
      x=220, y=120,
      w=330, h=120,
			font = { standardFont, 18, BlackColor },
			flags = kHAlignCenter + kVAlignCenter,
			name="levelend-text",
			label="levelend",
    },
    
    -- the window that shows the parts you've earned
    Bitmap
    {
        x=220, y=250,
        image="popup/levelend/level_passed_window",
        name = "tallywindow",
        --add the rows for each of the icons
        Bitmap {x=20, y=30, image="popup/levelend/components/chemicalsicon"},
        Text { x=80, y=30, w=100, h=50, name="count-chemical", font={standardFont, 18, BlackColor }, flags=kHAlignLeft + kVAlignCenter },
        Bitmap {x=20, y=100, image="popup/levelend/components/machinesicon"},
        Text { x=80, y=100, w=100, h=50, name="count-mechanical", font={standardFont, 18, BlackColor }, flags=kHAlignLeft + kVAlignCenter },
        Bitmap {x=170, y=30, image="popup/levelend/components/monstersicon"},
        Text { x=230, y=30, w=100, h=50, name="count-monster", font={standardFont, 18, BlackColor }, flags=kHAlignLeft + kVAlignCenter },
        Bitmap {x=170, y=100, image="popup/levelend/components/coinsicon"},
        Text { x=230, y=100, w=100, h=50, name="count-coins", font={standardFont, 18, BlackColor }, flags=kHAlignLeft + kVAlignCenter },
    },
    
    MakeMaggie(105,280),
    
			
		SetStyle(LongButtonStyle),
		
			AnimButton
      {
        x = 340,
				y = 465,
				name="continuebutton",
			label="continue",
			close = true,	-- Just close this window
			--cancel=true,
			command=
				function()
                PopModal("levelendmenu");                
	              SetState( kPause, false );
	              SendGameMessage("endlevel");	                
				end;

        animations={
          { key="normal", texture="buttons/long_button_up",  default=1},        
          { key="down", texture="buttons/long_button_down"},
          { key="hover", texture="buttons/long_button_over"},
          { key="disabled", texture="buttons/long_button_over"},
        },
     
      },	

    },
	}, -- end LevelEndDialog
}
