---------------------------------------------------------------------------------------------------
--  Copyright © 2009 PoBros, Incorporated. All Rights Reserved.
--
--  This source code is the proprietary confidential property of PoBros Incorporated.
--  Modification, reproduction, publication, or distribution in any form to any party 
--  other than the licensee is strictly prohibited.
--
--  FOR USE BY AUTHORIZED PERSONS ONLY
---------------------------------------------------------------------------------------------------

require( "scripts/style.lua" );

local kButtonXOffset = 15;
local kStartFull = false;
local kSkipIntro = false;
local kFadeOut = false;
local kMusic = gs_musicMap;
local kUpLeft = 0;
local kUpRight = 1;
local kDownLeft = 2;
local kDownRight = 3;
local kUp = 4;
local kDown = 5;
local kRight = 6;
local kLeft = 7;

-- Map Text
local kTextWidth = 300;
local kTextHeight = 50;
local kTextFont = MapTextFont;
local kTextDropShadowOffset = 1;
local kTextDropShadowColor = Color( 0, 0, 0, 255 );

if( gDialogTable.body == "startfull" ) then
	kStartFull = true;
	kSkipIntro = true;
elseif( gDialogTable.body == "skipintro" ) then
	kSkipIntro = true;
	kMusic = "";
end

---------------------------------------------------------------------------------------------------

function ContinueMap()
	if( CheckForValidLicense() ) then
		if( GetCurrentLocation( false ) == 9 ) then
			FadeOut( "SwapToModal( 'scripts/gameplay.lua' );" );
		else
			SwapWithStoryboard( 'map' );
		end
	else
		FadeOut( "SwapToModal( 'scripts/mainmenu.lua' );" );
	end
end

---------------------------------------------------------------------------------------------------

MakeDialog
{
	name = "map";
	SetStyle( MapStyle );
		
	Map
	{	
		music = "";
		largemap = "map/world_map";
		path = "map/paths/line%02d";
		skipintro = kSkipIntro;
		startfull = kStartFull;
		fadeout = gDialogTable.fadeout;
		dot = "map/dot";
		
		playlist =
		{
			playlisttrack = kMusic;
			timefadeout = 250;
			timecrossfade = 0;
			groupid = {gs_musicMapGroupID;};
		};
		
		SetStyle( DefaultStyle );
		
		dots =
		{
			location01 = { x = 125; y = 229; };
			location02 = { x = 230; y = 230; };
			location03 = { x = 204; y = 281; };
			location04 = { x = 189; y = 312; };
			location05 = { x = 432; y = 291; };
			location06 = { x = 377; y = 229; };
			location07 = { x = 537; y = 328; };
			location08 = { x = 605; y = 269; };
		};
		
		locations = 
		{
			location02 =
			{
				pathx = 71;
				pathy = 339;
				largecenterx = 150;
				largecentery = 175;
				direction = kRight;
				travel = "plane";
				scalemaplarge = 2.5;
				
				text =
				{
					text01 =
					{
						x = 99;
						y = 342;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignLeft + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_01" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 350;
						y = 400;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignRight + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_02" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
			
			location03 =
			{
				pathx = 211;
				pathy = 344;
				largecenterx = 225;
				largecentery = 175;
				direction = kDownLeft;
				travel = "plane";
				scalemaplarge = 2.5;
				
				text =
				{
					text01 =
					{
						x = 250;
						y = 325;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignCenter + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_02" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 211;
						y = 490;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignCenter + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_03" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
			
			location04 =
			{
				pathx = 209;
				pathy = 371;
				largecenterx = 200;
				largecentery = 225;
				direction = kDownLeft;
				travel = "plane";
				scalemaplarge = 1.8;
				
				text =
				{
					text01 =
					{
						x = 260;
						y = 355;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignCenter + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_03" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 209;
						y = 460;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignCenter + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_04" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
			
			location05 =
			{
				pathx = 71;
				pathy = 359;
				largecenterx = 500;
				largecentery = 150;
				direction = kRight;
				travel = "plane";
				scalemaplarge = 1.3;
				
				text =
				{
					text01 =
					{
						x = 55;
						y = 410;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignLeft + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_04" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 360;
						y = 350;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignRight + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_05" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
			
			location06 =
			{
				pathx = 125;
				pathy = 334;
				largecenterx = 550;
				largecentery = 150;
				direction = kUpRight;
				travel = "plane";
				scalemaplarge = 1.8;
				
				text =
				{
					text01 =
					{
						x = 320;
						y = 515;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignRight + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_05" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 125;
						y = 324;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignLeft + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_06" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
			
			location07 =
			{
				pathx = 82;
				pathy = 315;
				largecenterx = 700;
				largecentery = 200;
				direction = kDownRight;
				travel = "plane";
				scalemaplarge = 1.8;
				
				text =
				{
					text01 =
					{
						x = 82;
						y = 305;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignLeft + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_06" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 365;
						y = 495;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignRight + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_07" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
			
			location08 =
			{
				pathx = 116;
				pathy = 328;
				largecenterx = 750;
				largecentery = 200;
				direction = kUpRight;
				travel = "plane";
				scalemaplarge = 2.5;
				
				text =
				{
					text01 =
					{
						x = 120;
						y = 510;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignLeft + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_07" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 360;
						y = 315;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignRight + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_08" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
			
			location09 =
			{
				pathx = 160;
				pathy = 202;
				largecenterx = 400;
				largecentery = 300;
				direction = kRight;
				travel = "plane";
				scalemaplarge = 1.25;
				
				text =
				{
					text01 =
					{
						x = 160;
						y = 220;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignLeft + kVAlignTop;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_08" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
					
					text02 =
					{
						x = 700;
						y = 230;
						w = kTextWidth;
						h = kTextHeight;
						flags = kHAlignRight + kVAlignBottom;
						font = kTextFont;
						allowlinebreaks = true;
						text = GetString( "location_09" );
						dropshadowoffset = kTextDropShadowOffset;
						dropshadowcolor = kTextDropShadowColor;
					};
				};
			};
		};
		
		travel =
		{
			plane =
			{
				sound = gs_soundAirplane;
				traveltime = 11000;
				traveldelaytime = 500;
				layerfadetime = 1000;
				fadetime = 500;
				map = "map/map%02d";
				spacetravelx = 150;
				soundfade = 4000;
				soundgroupid = gs_sfxMapGroupID;
				
				travel =
				{
					image = "map/airplane";
					xcenter = 305;
					ycenter = 150;
					midpointx = 400;
					y = 150;
					oscillateamount = 25;
					rotateamount = 0.02;
					timesecondary = 3000;
					
					children =
					{
						image = "";
						x = 0;
						y = 0;
						xcenter = 0;
						ycenter = 0;
						framespeed = 0;
						flags = kHAlignLeft + kVAlignTop;
						
						children =
						{
							mindelay = 0;
							maxdelay = 0;
							action = "showall";
							
							list =
							{
								child1 =
								{
									image = "map/propeller";
									framespeed = 5;
									animation = "wrap";
									x = 0;
									y = 0;
									xcenter = 305;
									ycenter = 150;
								};
							};
						};
					};
				};
				
				background =
				{
					image = "";
					x = 0;
					y = 0;
					xcenter = 0;
					ycenter = 0;
					framespeed = 0;
					flags = kHAlignLeft + kVAlignTop;
					
					children =
					{
						mindelay = 0;
						maxdelay = 0;
						action = "showall";
						
						list =
						{
							child1 =
							{
								image = "map/blueoverlay";
								x = 0;
								y = 0;
								framespeed = 0;
								xcenter = 0;
								ycenter = 0;
								layer = -1;
							};
							
							child2 =
							{
								image = "";
								x = 0;
								y = 0;
								xcenter = 0;
								ycenter = 0;
								framespeed = 0;
								layer = 1;
								
								move =
								{
									beginx = 800;
									beginy = 0;
									endx = 0;
									endy = 0;				
									duration = 20000;
									loop = true;
									randomstart = true;
									smoothing = "none";
									mindelay = 0;
									maxdelay = 0;
									fittopixel = true;		
								};
								
								children =
								{
									mindelay = 0;
									maxdelay = 0;
									action = "showall";
									
									list =
									{
										child1 =
										{
											image = "map/clouds1";
											x = 0;
											y = 0;
											xcenter = 0;
											ycenter = 0;
											tint = Color( 75, 75, 75, 255 );
										};
										
										child2 =
										{
											image = "map/clouds1";
											x = -800;
											y = 0;
											xcenter = 0;
											ycenter = 0;
											tint = Color( 75, 75, 75, 255 );
										};
									};
								};
							};
						};
					};
				};
				
				foreground =
				{
					image = "";
					x = 0;
					y = 0;
					xcenter = 0;
					ycenter = 0;
					framespeed = 0;
					
					move =
					{
						beginx = 800;
						beginy = 0;
						endx = 0;
						endy = 0;				
						duration = 7500;
						loop = true;
						randomstart = true;
						initialdelay = 0;
						smoothing = "none";
						mindelay = 0;
						maxdelay = 0;
						fittopixel = true;		
					};
					
					children =
					{
						mindelay = 0;
						maxdelay = 0;
						action = "showall";
						
						list =
						{
							child1 =
							{
								image = "map/clouds2";
								x = 0;
								y = 0;
								xcenter = 0;
								ycenter = 0;
							};
							
							child2 =
							{
								image = "map/clouds2";
								x = -800;
								y = 0;
								xcenter = 0;
								ycenter = 0;
							};
						};
					};
				};
			};
		};
		
		modifiers =
		{
			timeshowlargemap = 1000;
			timemapcrossfade = 1500;
			timescreenfade = 1000;
			musicfadetosmallmap = 1000;
			musicfadetotravel = 4000;
			musicfadevolume = 0.35;
		};
		
		SetStyle( ButtonStyle );
		
		Button
		{
			x = kMax - 150 - kButtonXOffset;
			y = kMax - 50;
			name = "skip";
			text = "skip";
			
			command =
				function()
					MapButtonPress();
				end
		};
		
		Button
		{
			x = kButtonXOffset;
			y = kMax - 50;
			name = "menu";
			text = "menu";
			
			command =
				function()
					PauseMap();
					value = DoModal( "scripts/pause.lua" );
					
					if( value == "mainmenu" ) then
						FadeOut( "SwapToModal( 'scripts/mainmenu.lua' );" );
					else
						ResumeMap();
					end
				end
		};
	};
};

---------------------------------------------------------------------------------------------------

gDialogTable.fadeout = "";