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("You’ve got a great eye!\n\nBut there’s trouble in the new kitchen…Jenny and Robert need some help, and fast!");
				elseif ( instance.crisis == 1 ) then
					instance._title:SetText("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!");
				elseif ( instance.crisis == 2 ) then
					instance._title:SetText("Congratulations, you did it!\n\nBut don’t celebrate yet - there's trouble in paradise. Is Jenny and Robert's dream home in jeopardy?");
				elseif ( instance.crisis == 3 ) then
					instance._title:SetText("You are unstoppable!\n\nBut there seems to be a bit of a problem in the master bathroom…Jenny and Robert need your help!");
				elseif ( instance.crisis == 4 ) then
					instance._title:SetText("You really know what you’re doing!\n\nNow let’s hope you can help out with the slight disruption in the dining room...");
				elseif ( instance.crisis == 5 ) then
					instance._title:SetText("Congratulations, you did it!\n\nBut don’t celebrate yet - there's trouble in paradise. Is Jenny and Robert's dream home in jeopardy?");
				elseif ( instance.crisis == 6 ) then
					instance._title:SetText("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("Unknown Crisis ID");
				end
				
			-- concentration
			elseif ( instance.bonusType == 1 ) then
				instance._title:SetText("Nicely done!\n\nIt’s time to go upstairs and take a break... click OK to visit The Attic and choose a minigame!" );
			-- story
			elseif ( instance.bonusType == 2 ) then
				instance._title:SetText("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!" );
			end
		else
			instance._title:SetText("\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!" );
		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( )
