require "StandardMouseButton"
require "CDialog"

-- reserve constructor
Game_BluebirdDialog = 
{
	name = "Game_BluebirdDialog"
}

function Game_BluebirdDialog: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( )
		
		-- show the correct gift ### bluebird in this case...
		--instance.gifts:SetFrameFromLabel( instance.gift );
		
		local titleText;
		local bodyText;
		local levelFrame;
		
		-- ### text below is not accurate - it's been changed in StringTable.xml....
		if ( instance.bluebirds == 5 ) then
			titleText = "|280|Bluebird UI|Wood Anniversary|"
			bodyText = "|281|Bluebird UI|Congratulations on finding five bluebirds of happiness! Only five more to reach the next anniversary... and when you find 50, you'll get a special reward!|"
			levelFrame = 1
		elseif ( instance.bluebirds == 15 ) then
			titleText = "|282|Bluebird UI|Crystal Anniversary|"
			bodyText = "|283|Bluebird UI|You've discovered ten bluebirds - congratulations! Don't stop now, the silver anniversary is at 25!|"
			levelFrame = 4
		elseif ( instance.bluebirds == 25 ) then
			titleText = "|284|Bluebird UI|Silver Anniversary|"
			bodyText = "|285|Bluebird UI|Happy day! Now it gets a bit tougher... you'll need 50 bluebirds to reach your golden anniversary and pick a special gift for Jenny and Robert!|"
			levelFrame = 2
		else 
			titleText = "|286|Bluebird UI|Gold Anniversary|"
			bodyText = "|287|Bluebird UI|You did it! These 50 bluebirds of happiness will mean a long and happy marriage for Jenny and Robert.|"
			levelFrame = 3
		end
		
		instance.title:SetText( titleText );
		instance.body:SetText( bodyText );
		instance.bluebirdLevel:SetFrame( levelFrame );
		
		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_BluebirdDialog:Create( )
