require "StandardMouseButton"
require "CDialog"
		
-- reserve constructor
Game_WinDialog = 
{
	name = "Game_WinDialog"
}

function Game_WinDialog:Create(  )
	
	-- The main screen container
	local instance = root.dialogs[ self.name ];
	instance:SetPosition( 208, 99 )
	CDialog:Attach( instance )
	
	-- The ok button
	local okButton = instance.button
	
	
	-- The main init function
	function instance:Init( )
		
		if ( instance.complete == 1 ) then
			-- no bonus (ie crisis coming!)
			if ( instance.bonusType == 0 ) then

				-- various crisis messages
				if ( instance.crisis == 0 ) then
					--instance._title:SetText("|10|UI|You've got a great eye!\n\nBut there's trouble in the new kitchen�Jenny and Robert need some help, and fast!|");
					instance._title:SetText("You make this look easy!\nBut your cool demeanor is about to be put to the test - there's some bad news from the bakery...");
				elseif ( instance.crisis == 1 ) then
					--instance._title:SetText("|11|UI|You should do this for a living!\n\nBut don't relax just yet�you're going to need all your strength once you see what happened in the backyard!|");
					instance._title:SetText("Well done, Rachel is one step closer to her Dream Day!\nBut there's a situation at the florist that might put a wrench in the works...");
				elseif ( instance.crisis == 2 ) then
					--instance._title:SetText("|12|UI|Congratulations, you did it!\n\nBut don't celebrate yet - there's trouble in paradise. Is Jenny and Robert's dream home in jeopardy?|");
					instance._title:SetText("You were born for this job!\nBut brace yourself, there's been some sort of disaster at the gown shop! This one will take all the wedding planning magic you can muster...");
				elseif ( instance.crisis == 3 ) then
					--instance._title:SetText("|13|UI|You are unstoppable!\n\nBut there seems to be a bit of a problem in the master bathroom�Jenny and Robert need your help!|");
					instance._title:SetText("You've got this wedding planning thing down pat! But are you ready to face a bigger challenge? There's something amiss at the flower shop...");
				elseif ( instance.crisis == 4 ) then
					--instance._title:SetText("|14|UI|You really know what you're doing!\n\nNow let's hope you can help out with the slight disruption in the dining room...|");
					instance._title:SetText("The good news: you're great at this!\nThe bad news: something's gone horribly wrong at the bakery.now it's up to you to save Emily's Dream Day!");
				elseif ( instance.crisis == 5 ) then
					--instance._title:SetText("|12|UI|Congratulations, you did it!\n\nBut don't celebrate yet - there's trouble in paradise. Is Jenny and Robert's dream home in jeopardy?|");
					instance._title:SetText("You make this look so easy!\nBut don't count on a Dream Day just yet...there's bad news from the seamstress, and unless you save the day, Emily will be walking down the aisle in her bathrobe...");
				elseif ( instance.crisis == 6 ) then
					--instance._title:SetText("|15|UI|You did it! The house is finally finished\n\nClick OK to see a slideshow of Jenny and Robert's First Home transformation!|");
					instance._title:SetText("|15|UI|You did it! The house is finally finished\n\nClick OK to see a slideshow of Jenny and Robert's First Home transformation!|");
				else
					instance._title:SetText("|16|UI|Unknown Crisis ID|");
				end
				
			-- concentration
			elseif ( instance.bonusType == 1 ) then
				--instance._title:SetText("|17|UI|Nicely done!\n\nIt's time to go upstairs and take a break... click OK to visit The Attic and choose a minigame!|" );
				instance._title:SetText("\nLevel Complete!\n\nIt's time to check the Dream Day Registry... click OK to play a minigame and open a new gift!" );
				
			-- story
			elseif ( instance.bonusType == 2 ) then
				--instance._title:SetText("|18|UI|You've got a great eye!\n\nNow it's time to find out more about Jenny and Robert's first home adventures...click OK to play Choose A Story. Finish the story to reveal a special bonus item!|" );
				if(instance.isBrideA == 1) then
					instance._title:SetText("\nLevel Complete!\n\nIt's time to find out more about Rachel and Nate's love story...click OK to play Choose A Story and unlock a special bonus item!" );
				else
					instance._title:SetText("\nLevel Complete!\n\nIt's time to find out more about Emily and Jason's love story...click OK to play Choose A Story and unlock a special bonus item!" );
				end
			end
			
			if(instance.IsHoneymoonLevel == 1) then
				instance._title:SetText("\nHoneymoon Level Complete!\n\nRachel and Nate prepared a photo album for you - it's time to see the photos of their Dream Day!\nBy the way, it looks like your hard work has attracted some attention..." );
			elseif(instance.IsHoneymoonLevel == 2) then
				instance._title:SetText("\nHoneymoon Level Complete!\n\nEmily and Jason prepared a photo album for you - it's time to see the photos of their Dream Day!\nBy the way, it looks like your hard work has attracted some attention..." );
			end
		else
			--instance._title:SetText("|19|UI|\nCongratulations!\n\nYou found all the items on Jenny and Robert's list. Click OK to return to the First Home Album and select a new room!|" );
			instance._title:SetText("\nCongratulations!\n\nYou found all the items on your list. Click OK to return to the Wedding Album and select a new location!" );
		end
		
		StandardMouseButton( okButton );
		okButton:Init( )
	end

	-- Handle keyboard input for the dialog
	function instance:CharDown( i_Key )
		log( "On Key Down" .. i_Key )
	end

	function instance:OnUpdate( )
		self:OnUpdateDialog()
	end

	-- The ok button
	function okButton:Init( )
		function okButton:Pressed( )
			instance:CloseAndSave( )
		end
		self:AddAsGlobalHandler()
		function okButton:OnKeyDown( i_Key )
			-- press ok on pressing return button
			if ( i_Key == 13 ) then
				okButton:Pressed()
			end
		end
	end
end

Game_WinDialog:Create( )
