//============================================================================= // Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. // // File: exitcontext.cpp // // Description: Implementation of ExitContext. // // History: + Created -- Darwin Chau // //============================================================================= //======================================== // System Includes //======================================== #include #include #include #include //======================================== // Project Includes //======================================== #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include
//****************************************************************************** // // Global Data, Local Data, Local Classes // //****************************************************************************** // Static pointer to instance of singleton. ExitContext* ExitContext::spInstance = NULL; //****************************************************************************** // // Public Member Functions // //****************************************************************************** //============================================================================== // ExitContext::GetInstance //============================================================================== // // Description: - Access point for the ExitContext singleton. // - Creates the ExitContext if needed. // // Parameters: None. // // Return: Pointer to the ExitContext. // // Constraints: This is a singleton so only one instance is allowed. // //============================================================================== ExitContext* ExitContext::GetInstance() { if( spInstance == NULL ) { spInstance = new(GMA_PERSISTENT) ExitContext; rAssert( spInstance ); } return spInstance; } //****************************************************************************** // // Protected Member Functions // //****************************************************************************** //============================================================================== // ExitContext::OnStart //============================================================================== // // Description: // // Parameters: // // Return: // // Note: Exiting is currently not valid from every context. This needs more // checking and handling of special cases. // //============================================================================== void ExitContext::OnStart( ContextEnum previousContext ) { MEMTRACK_PUSH_FLAG( "Exit" ); if( previousContext == CONTEXT_GAMEPLAY || previousContext == CONTEXT_LOADING_GAMEPLAY ) { // My precious little hack... my preciouss. GameFlow::GetInstance()->GetContext( CONTEXT_PAUSE )->Start( CONTEXT_GAMEPLAY ); GameFlow::GetInstance()->GetContext( CONTEXT_PAUSE )->Stop( CONTEXT_EXIT ); } GetLoadingManager()->CancelPendingRequests(); p3d::loadManager->CancelAll(); GetSoundManager()->OnGameplayEnd( false ); } //============================================================================== // ExitContext::OnStop //============================================================================== // // Description: // // Parameters: // // Return: // //============================================================================== void ExitContext::OnStop( ContextEnum nextContext ) { MEMTRACK_POP_FLAG( "" ); GetGame()->Stop(); rAssertMsg( false, "No happen should." ); } //============================================================================== // ExitContext::OnUpdate //============================================================================== // // Description: // // Parameters: // // Return: // //============================================================================== void ExitContext::OnUpdate( unsigned int elapsedTime ) { } //============================================================================== // ExitContext::OnSuspend //============================================================================== // // Description: // // Parameters: // // Return: // //============================================================================== void ExitContext::OnSuspend() { } //============================================================================== // ExitContext::OnResume //============================================================================== // // Description: // // Parameters: // // Return: // //============================================================================== void ExitContext::OnResume() { } //============================================================================== // ExitContext::OnHandleEvent //============================================================================== // // Description: // // Parameters: // // Return: // //============================================================================== void ExitContext::OnHandleEvent( EventEnum id, void* pEventData ) { } //****************************************************************************** // // Private Member Functions // //****************************************************************************** //============================================================================== // ExitContext::ExitContext //============================================================================== // // Description: // // Parameters: // // Return: // //==============================================================================// ExitContext::ExitContext() { } //============================================================================== // ExitContext::~ExitContext //============================================================================== // // Description: // // Parameters: // // Return: // //==============================================================================// ExitContext::~ExitContext() { spInstance = NULL; }