---------------------------------------------------------------------------------------------------
--  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 locationNumber = "0" .. GetCurrentLocation( false );

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

function GetHelpDialog( locationNumber )
	if( locationNumber == "01" ) then
		return "autumn_this_page_looks";
	elseif( locationNumber == "02" ) then
		return "autumn_another_message_hidden";
	elseif( locationNumber == "03" ) then
		return "autumn_lets_see_what_we_got";
	elseif( locationNumber == "04" ) then
		return "autumn_this_is_getting_familiar";
	elseif( locationNumber == "05" ) then
		return "autumn_okay_more_pieces_back_together";
	elseif( locationNumber == "06" ) then
		return "autumn_journal_pages_read_together";
	elseif( locationNumber == "07" ) then
		return "autumn_feeling_getting_close_next";
	else
		return "";
	end
end

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

function GetOnCompleteDialog( locationNumber )
	if( locationNumber == "01" ) then
		return "autumn_theres_picture_building";
	elseif( locationNumber == "02" ) then
		return "autumn_another_address_crazy_joe";
	elseif( locationNumber == "03" ) then
		return "autumn_mayan_ruins_guatemala";
	elseif( locationNumber == "04" ) then
		return "autumn_oasis_in_egypt";
	elseif( locationNumber == "05" ) then
		return "autumn_what_oolala_like_paris";
	elseif( locationNumber == "06" ) then
		return "autumn_where_to_next_sri_lanka";
	elseif( locationNumber == "07" ) then
		return "autumn_nanchang_china_auctioned";
	else
		return "";
	end
end

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

function GetMinigameDialogs( locationNumber )
	t = {};
	
	if( locationNumber ~= "08" and locationNumber ~= "09" ) then
		t = {
			journal_dialog_intro =
			{
				name = "journal_dialog_intro";
 				image = "autumn_thoughtful";
				sound = GetHelpDialog( locationNumber );
				text = GetHelpDialog( locationNumber );
			};
					  
			journal_dialog_oncomplete =
			{
				name = "journal_dialog_oncomplete";
				image = "autumn_amused";
				sound = GetOnCompleteDialog( locationNumber );
				text = GetOnCompleteDialog( locationNumber );
			}; };
	end

	return t;
end

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

dialogs = GetMinigameDialogs( locationNumber );	

MakeDialog
{
	SetStyle( MinigameJigsawStyle );
	
	MinigameJournal
	{
		name = "journal";
		lockcorrectpieces = true;
		lockinitialpieces = true;
		returnpiecesonmiss = true;
		fadeoncomplete = false;
		timetoholdpiece = 350;
		piecescript = "scripts/minigames/journal/journal" .. locationNumber .. ".lua";
		dialogtexture = "minigames/journal/background_text";
		leftheader = "<b>" .. GetString( "journalleftheader" ) .. "</b>";
		rightheader = "<b>" .. GetString( "journalrightheader" ) .. "</b>";
		goalentrybeginning1 = GetString( "goalentrybeginning" );
		goalentrybeginning2 = GetString( "goalentrybeginning2" );
		goalentrybeginning3 = GetString( "goalentrybeginning3" );
		goalentrysep = GetString( "goalentrysep" );
		goalentryseplast = GetString( "goalentryseplast" );
		goalentryprearea1 = GetString( "goalentryprearea" );
		goalentryprearea2 = GetString( "goalentryprearea2" );
		goalentryprearea3 = GetString( "goalentryprearea3" );
		goalentrypostarea = GetString( "goalentrypostarea" );
		goalinventorybeginning = GetString( "goalinventorybeginning" );
		goalinventoryend = GetString( "goalinventoryend" );
		goalinventorysingle = "_single";
		goalinventoryplural = "_plural";
		stringtimeplayed = GetString( "cumulativetime" );
		goalentrycolor = "281B0C";
		lefttextfont = JournalLeftFont;
		righttextfont = JournalRightFont;
		headerfont = JournalHeaderFont;
		pagenumberfont = JournalPageNumberFont;
		journalentrymask = "journalentry_%02d_%02d";
		fadetime = 250;
		fullpagemask = "minigames/journal/full%02d";
		pagetextalpha = 0.75;
		journaldestinationx = 730;
		journaldestinationy = 550;
		journalscale = 0.1;
		skippiecedelay = 40;
		
		lefttext =
		{
			x = 109;
			y = 133;
			w = 280;
			h = 350;
		};
		
		righttext =
		{
			x = 435;
			y = 133;
			w = 265;
			h = 350;
		};
		
		timetext =
		{
			x = 400;
			y = 50;
			alpha = 1;
			w = 512;
			h = 64;
			flags = kHAlignCenter + kVAlignCenter;
			font = JournalTimeFont;
			text = "";
			allowlinebreaks = false;
			dropshadowoffset = gs_dropShadowOffset;
			dropshadowcolor = TextFontColor;
			drawtotexture = false;
		};
		
		lefttextheader =
		{
			x = 249;
			y = 108;
			w = 280;
			h = 30;
		};
		
		righttextheader =
		{
			x = 560;
			y = 108;
			w = 235;
			h = 30;		
		};
		
		leftpagetext =
		{
			x = 250;
			y = 500;
			w = 52;
			h = 52;
		};
		
		rightpagetext =
		{
			x = 575;
			y = 500;
			w = 52;
			h = 52;
		};
		
		windowsprite =
		{
			sprite = "minigames/journal/background";
			xcenter = 400;
			ycenter = 300;
		};
		
		pagesprite =
		{
			sprite = "minigames/journal/full" .. locationNumber;
			x = 411;
			y = 76;
		};
		
		playfield =
		{
			field =
			{
				x = 408;
				y = 73;
				w = 315;
				h = 450;
			};
		};
		
		piecefield =
		{
			x = 87;
			y = 72;
			w = 315;
			h = 450;
		};

		pieces = {};
		slots = {};
		
		pieceinfo =
		{
			movetime = 200;
			maxalphahilight = 0.3;
			minalphahilight = 0.1;
			timehilight = 400;
			hidewheninslot = false;
			image = "minigames/journal/pieces" .. locationNumber;
			timepickedup = 50;
			xoffsetpickedup = -4;
			yoffsetpickedup = -4;
			shadowalpha = 0.65;
		};
		
		MinigameButtons();
		AddMinigameTutorial( 400, 300, "journaltutorial", "tutorial", -1 );
		
		SetStyle( ButtonHudLeftStyle );
		
		Button
		{
			x = 85;
			y = 480;
			name = "journalprevious";
			
			command =
				function()
					PageLeft();
				end
		};
		
		SetStyle( ButtonHudRightStyle );
		
		Button
		{
			x = 685;
			y = 480;
			name = "journalnext";
			
			command =
				function()
					PageRight();
				end
		};
		
		SetStyle( ButtonHudCloseStyle );
		
		Button
		{
			x = 685;
			y = 90;
			name = "journalclose";
			
			command =
				function()
					JournalClose();
				end
		};
	};
};

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