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

function Game_LoseDialog: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( )
		
		-- C1
		if ( instance.crisis == 0 ) then
			instance._title:SetText("Craftsman Crisis 1 Lost!");
		-- C2
		elseif ( instance.crisis == 1 ) then	
			instance._title:SetText("Craftsman Crisis 2 Lost!");
		-- C3
		elseif ( instance.crisis == 2 ) then
			instance._title:SetText("Craftsman Crisis 3 Lost!");
		-- V1
		elseif ( instance.crisis == 3 ) then
			instance._title:SetText("Victorian Crisis 1 Lost!");
		-- V2
		elseif ( instance.crisis == 4 ) then	
			instance._title:SetText("Victorian Crisis 2 Lost!");
		-- V3
		elseif ( instance.crisis == 5 ) then
			instance._title:SetText("Victorian Crisis 3 Lost!");
		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_LoseDialog:Create( )
