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

function Minigame_SolveDialog:Create(  )
	
	-- The main screen container
	local instance = root.dialogs[ self.name ];
	instance:SetPosition( 139, 99 )
	CDialog:Attach( instance )
	
	local solveButton = instance.solveButton
	local helpButton = instance.helpButton
	local cancelButton = instance.cancelButton
	
	function instance:OnUpdate( )
		self:OnUpdateDialog()
	end
	
	
	-- The main init function
	function instance:Init( )
	
		-- if ( instance.boardType == 0 ) then --apartment
		--	instance._foo:SetText("Are you sure you want to obtain the item list without solving the puzzle?");
		-- elseif ( instance.boardType == 1 ) then	--escape
		--	instance._foo:SetText("Are you sure you want to use the Panic button? You'll escape this location, but you'll lose three minutes off the clock.");
		-- end
		
		StandardMouseButton( solveButton );
		solveButton:Init( )
		
		StandardMouseButton( helpButton );
		helpButton:Init( )

		StandardMouseButton( cancelButton );
		cancelButton:Init( )
	end

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

	-- The solve button
	function solveButton:Init( )
		function solveButton:Pressed( )
			instance:ScreenEvent( "Solve", "Minigame_SolveDialog" )
			instance:CloseAndSave( )
		end
		self:AddAsGlobalHandler()
		-- function solveButton:OnKeyDown( i_Key )
			-- press ok on pressing return button
			-- if ( i_Key == 13 ) then
			--	okButton:Pressed()
			-- end
		-- end
	end
	
	-- The help button
	function helpButton:Init( )
		function helpButton:Pressed( )
			instance:ScreenEvent( "Help", "Minigame_SolveDialog" )
			instance:CloseAndSave( )
		end
		self:AddAsGlobalHandler()
	end

    -- The cancel button 
	function cancelButton:Init( )
		function cancelButton:Pressed( )
			instance:CloseAndSave( )
		end
	end
end

Minigame_SolveDialog:Create( )
