require "scripts/style"

kButtonSpacing = 60;	-- Put our buttons 60 pixels apart
kButtonY = kCenter-60;	-- 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 );

local sx = 248
local sy = 39

MakeDialog
{
	-- Name the modal dialog
	name="pausemenu",
	Bitmap{
		image="backgrounds/dark",
		x=kCenter,
		y=kCenter,
		alpha=true
	},
	Bitmap
	{
		image="ui/ingamemenu/_back",
		x=sx,
		y=sy,

		SetStyle(ButtonStyle),
		Button
		{
			--x=380-sx,
			y=234-sy,
			x=kCenter,
			--y=kCenter - 100,
			graphics={"ui/ingamemenu/buttons/resume/resume_in","ui/ingamemenu/buttons/resume/resume_ac","ui/ingamemenu/buttons/resume/resume_ac"},
			name="resumebutton",
			label="resume",
			close = true,	-- Just close this window
			cancel=true,
			command=
				function()
	                SetState( kPause, false );
			WindowFocused(true);
				end;

		},

		Button
		{
			--x=412-sx,
			y=394-sy,
			x=kCenter,
			--y=kCenter,
			graphics={"ui/ingamemenu/buttons/options/options_in","ui/ingamemenu/buttons/options/options_ac","ui/ingamemenu/buttons/options/options_ac"},
			name="optionsbutton",
			label="optionsbutton",
			command=
				function()
					-- Pop up an options screen
					DoModal("scripts/options.lua");
				end
		},

		Button
		{
			--x=412-sx,
			y=486-sy,
			x=kCenter,
			--y=kCenter + 80,
			graphics={"ui/ingamemenu/buttons/mainmenu/mainmenu_in","ui/ingamemenu/buttons/mainmenu/mainmenu_ac","ui/ingamemenu/buttons/mainmenu/mainmenu_ac"},
			label="quit",
			command=
				function()
					PopModal('pausemenu');
					--DoModal('scripts/gameover.lua');
					-- Our game processes this message--it's not
					-- handled by Playground
                    			--[[SendGameMessage( "quit" );
	                		SetState( kPause, false );]]

					if gQuitVerifyActive then
						return;
					end

					gQuitVerifyActive = true;
					DisplayDialog{
						"scripts/yesno.lua",
						yes=function()
								SendGameMessage( "quit" );
								SetState( kPause, false );
						   end,
						no=function()
								SetState( kPause, false );
								WindowFocused(true);
						end,
						title = "quittitle",
						body = "quitconfirm",
						darkBgk = "backgrounds/dark"
					};
					gQuitVerifyActive = false;
					SetState( kPause, false );
				end
		},
	},
}