require "StandardMouseButton"
require "CDialog"


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

function Book_GameWonDialog:Create(  )
	
	-- The main screen container
	local instance = root.dialogs[ self.name ];
	instance:SetPosition( 139, 99 )
	CDialog:Attach( instance )

	-- The ok button
	local okButton = instance.button
	
	-- The main init function
	function instance:Init( )

		

		StandardMouseButton( okButton );
		okButton:Init( )
	end

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

	-- Handle keyboard input for the dialog
	function instance:CharDown( i_Key )
		log( "On Key Down" .. i_Key )
	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

Book_GameWonDialog:Create( )
