diff options
Diffstat (limited to 'game/code/contexts')
35 files changed, 6549 insertions, 0 deletions
diff --git a/game/code/contexts/allcontexts.cpp b/game/code/contexts/allcontexts.cpp new file mode 100644 index 0000000..2890207 --- /dev/null +++ b/game/code/contexts/allcontexts.cpp @@ -0,0 +1,8 @@ +#include <contexts/bootupcontext.cpp> +#include <contexts/context.cpp> +#include <contexts/entrycontext.cpp> +#include <contexts/exitcontext.cpp> +#include <contexts/frontendcontext.cpp> +#include <contexts/playingcontext.cpp> +#include <contexts/loadingcontext.cpp> +#include <contexts/pausecontext.cpp> diff --git a/game/code/contexts/bootupcontext.cpp b/game/code/contexts/bootupcontext.cpp new file mode 100644 index 0000000..0811517 --- /dev/null +++ b/game/code/contexts/bootupcontext.cpp @@ -0,0 +1,611 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: bootupcontext.cpp +// +// Description: Implementation of BootupContext. +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifdef RAD_RELEASE + #ifndef RAD_E3 + #define SHOW_MOVIES + #endif +#endif + +//======================================== +// System Includes +//======================================== +#include <raddebug.hpp> +#include <radtime.hpp> +#include <raddebugwatch.hpp> +#include <radmovie2.hpp> +#include <p3d/utility.hpp> +#include <p3d/context.hpp> +#include <pddi/pddi.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/bootupcontext.h> + +#include <atc/atcmanager.h> +#include <cards/cardgallery.h> +#include <cheats/cheatinputsystem.h> +#include <constants/movienames.h> +#include <contexts/contextenum.h> +#include <data/gamedatamanager.h> +#include <data/memcard/memorycardmanager.h> +#include <gameflow/gameflow.h> +#include <input/inputmanager.h> +#include <interiors/interiormanager.h> +#include <loading/loadingmanager.h> +#include <main/commandlineoptions.h> +#include <memory/leakdetection.h> +#include <memory/srrmemory.h> +#include <mission/gameplaymanager.h> +#include <mission/missionmanager.h> +#include <mission/charactersheet/charactersheetmanager.h> +#include <mission/rewards/rewardsmanager.h> +#include <presentation/presentation.h> +#include <presentation/presevents/presentationevent.h> +#include <presentation/gui/guisystem.h> +#include <presentation/tutorialmanager.h> +#include <render/rendermanager/rendermanager.h> +#include <render/rendermanager/renderlayer.h> +#include <sound/soundmanager.h> +#include <supersprint/supersprintmanager.h> +#include <worldsim/worldphysicsmanager.h> +#include <worldsim/character/charactermanager.h> + +#ifdef RAD_GAMECUBE + #include <main/gamecube_extras/gcmanager.h> +#endif + +#ifdef RAD_WIN32 + #include <main/win32platform.h> + #include <data/config/gameconfigmanager.h> +#endif + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// Static pointer to instance of singleton. +BootupContext* BootupContext::spInstance = NULL; + +#ifdef RAD_RELEASE + #ifdef RAD_PS2 + // TC: Edwin (Singh) says that the PS2 TRC requires that the license screen + // be displayed for at least 5 seconds. + // + const int MINIMUM_LICENSE_SCREEN_DISPLAY_TIME = 5000; // in msec + #else + const int MINIMUM_LICENSE_SCREEN_DISPLAY_TIME = 1000; // in msec + #endif +#else + const int MINIMUM_LICENSE_SCREEN_DISPLAY_TIME = 1000; // in msec +#endif + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// BootupContext::GetInstance +//============================================================================== +// +// Description: - Access point for the BootupContext singleton. +// - Creates the BootupContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the BootupContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +BootupContext* BootupContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new(GMA_PERSISTENT) BootupContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================= +// BootupContext::StartMovies +//============================================================================= +// Description: Comment +// +// Parameters: Game Mode (Frontend/In-Game) +// +// Return: void +// +//============================================================================= +void BootupContext::StartMovies() +{ +#ifndef FINAL + if( CommandLineOptions::Get( CLO_SKIP_FE ) ) + { + // enable 'unlock missions' cheat for 'skipfe' commandline option + // + GetCheatInputSystem()->SetCheatEnabled( CHEAT_ID_UNLOCK_MISSIONS, true ); + + short levelIndex = CommandLineOptions::GetDefaultLevel(); + + if( levelIndex == -1 ) // L0 = minigame + { + SetGameplayManager( SuperSprintManager::GetInstance() ); + + // skip FE and go to mini-game + // + GetGameFlow()->SetContext( CONTEXT_SUPERSPRINT_FE ); + } + else + { + SetGameplayManager( MissionManager::GetInstance() ); + + // register controller ID [0] for player [0], by default + // + GetInputManager()->RegisterControllerID( 0, 0 ); + + short missionIndex = CommandLineOptions::GetDefaultMission(); + if( levelIndex == RenderEnums::L1 ) + { + // special case for level 1 due to tutorial mission being mission 0 + // + missionIndex++; + } + + // set level and mission to load for normal gameplay + // + GetGameplayManager()->SetLevelIndex( static_cast< RenderEnums::LevelEnum >( levelIndex ) ); + GetGameplayManager()->SetMissionIndex( static_cast< RenderEnums::MissionEnum >( missionIndex ) ); + + // skip FE and go to normal gameplay + // + GetGameFlow()->SetContext( CONTEXT_LOADING_GAMEPLAY ); + } + } + else +#endif // !FINAL + { +#ifdef SHOW_MOVIES + if( CommandLineOptions::Get( CLO_SKIP_MOVIE ) ) + { + // Switch to frontend context. + GetGameFlow()->SetContext( CONTEXT_FRONTEND ); + } + else + { + FMVEvent* pEvent = 0; + + GetPresentationManager()->QueueFMV( &pEvent, this ); + strcpy( pEvent->fileName, MovieNames::VUGLOGO ); + pEvent->SetRenderLayer( RenderEnums::PresentationSlot ); + pEvent->SetAutoPlay( true ); + pEvent->SetAudioIndex( FMVEvent::AUDIO_INDEX_ENGLISH ); + pEvent->SetClearWhenDone( true ); + + GetPresentationManager()->QueueFMV( &pEvent, this ); + strcpy( pEvent->fileName, MovieNames::FOXLOGO ); + pEvent->SetRenderLayer( RenderEnums::PresentationSlot ); + pEvent->SetAutoPlay( true ); + pEvent->SetAudioIndex( FMVEvent::AUDIO_INDEX_ENGLISH ); + pEvent->SetClearWhenDone( true ); + + GetPresentationManager()->QueueFMV( &pEvent, this ); + strcpy( pEvent->fileName, MovieNames::GRACIELOGO ); + pEvent->SetRenderLayer( RenderEnums::PresentationSlot ); + pEvent->SetAutoPlay( true ); + pEvent->SetAudioIndex( FMVEvent::AUDIO_INDEX_ENGLISH ); + pEvent->SetClearWhenDone( true ); + + GetPresentationManager()->QueueFMV( &pEvent, this ); + strcpy( pEvent->fileName, MovieNames::RADICALLOGO ); + pEvent->SetRenderLayer( RenderEnums::PresentationSlot ); + pEvent->SetAutoPlay( true ); + pEvent->SetAudioIndex( FMVEvent::AUDIO_INDEX_ENGLISH ); + pEvent->SetClearWhenDone( true ); + + GetRenderManager()->mpLayer( RenderEnums::GUI )->Chill(); + } +#else + // Switch to frontend context. + GetGameFlow()->SetContext( CONTEXT_FRONTEND ); +#endif + } +} + +void +BootupContext::StartLoadingSound() +{ + GetSoundManager()->OnBootupStart(); + + GetLoadingManager()->AddCallback( this, (void*)GetSoundManager() ); +} + +#ifdef RAD_WIN32 +void BootupContext::LoadConfig() +{ + // Load the config file for the game. + GameConfigManager* gc = GetGameConfigManager(); + bool success = gc->LoadConfigFile(); + + // If we couldn't load the config file, create a new one. + if( !success ) + { + Win32Platform::GetInstance()->LoadDefaults(); + gc->SaveConfigFile(); + } +} +#endif + +//****************************************************************************** +// +// Protected Member Functions +// +//****************************************************************************** + +//============================================================================== +// BootupContext::OnStart +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void BootupContext::OnStart( ContextEnum previousContext ) +{ + SetMemoryIdentification( "BootupContext" ); + HeapMgr()->PrepareHeapsFeCleanup(); + HeapMgr()->PrepareHeapsFeSetup(); + HeapMgr()->PushHeap (GMA_PERSISTENT); +#ifdef DEBUGINFO_ENABLED + DebugInfo::InitializeStaticVariables(); +#endif + + MEMTRACK_PUSH_FLAG( "Bootup" ); + GetGameDataManager()->Init(); + +#ifdef RAD_PS2 + // must load memory card info first, before anything else, since the + // memory card boot-up check is done right at the beginning + // + if( !CommandLineOptions::Get( CLO_SKIP_MEMCHECK ) ) + { + GetMemoryCardManager()->LoadMemcardInfo(); + } +#endif + + GetGuiSystem()->Init(); + GetGuiSystem()->RegisterUserInputHandlers(); + + GetCardGallery()->Init(); + GetCheatInputSystem()->Init(); + GetTutorialManager()->Initialize(); + GetATCManager()->Init(); + + GetCharacterSheetManager()->InitCharacterSheet(); + + GetPresentationManager()->InitializePlayerDrawable(); + +#ifdef RAD_GAMECUBE + //Initialize the GCManager's timers for testing reset and such. + GCManager::GetInstance()->Init(); +#endif + + GetWorldPhysicsManager()->Init(); + + GetInteriorManager()->OnBootupStart(); + + // TC: for PS2, we shouldn't start loading sound stuff until we get to the + // license screen to avoid any synchronous script parsing that could + // lock-up the CPU briefly on a GUI prompt screen + // +// GetSoundManager()->OnBootupStart(); + + GetCharacterManager()->PreLoad(); + + // load rewards script + // + GetRewardsManager()->LoadScript(); + + // preload some data that is common across all levels + // MissionScriptLoader::LoadP3DFile hacked to supress their loads in mission scripts + GetLoadingManager()->AddRequest( FILEHANDLER_PURE3D, "art\\cars\\common.p3d", GMA_DEFAULT, "Global" ); + GetLoadingManager()->AddRequest( FILEHANDLER_PURE3D, "art\\cars\\huskA.p3d", GMA_DEFAULT, "Global"); + GetLoadingManager()->AddRequest( FILEHANDLER_PURE3D, "art\\phonecamera.p3d", GMA_DEFAULT, "Global"); + GetLoadingManager()->AddRequest( FILEHANDLER_PURE3D, "art\\cards.p3d", GMA_DEFAULT, "Global"); + GetLoadingManager()->AddRequest( FILEHANDLER_PURE3D, "art\\wrench.p3d", GMA_DEFAULT, "Global"); + GetLoadingManager()->AddRequest( FILEHANDLER_PURE3D, "art\\missions\\generic\\missgen.p3d", GMA_DEFAULT, "Global"); + + // + // Address any loading requests that the managers have queued up + // + GetLoadingManager()->AddCallback( this ); + +#if defined( RAD_WIN32 ) && defined( SHOW_MOVIES ) + GetInputManager()->GetFEMouse()->SetInGameMode( true ); +#endif +} + + +//============================================================================== +// BootupContext::OnStop +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void BootupContext::OnStop( ContextEnum nextContext ) +{ + rTunePrintf("BootupContext::OnStop... "); + + GetGuiSystem()->UnregisterUserInputHandlers(); + + // release GUI bootup + GetGuiSystem()->HandleMessage( GUI_MSG_RELEASE_BOOTUP ); + +#if defined( RAD_WIN32 ) && defined( SHOW_MOVIES ) + GetInputManager()->GetFEMouse()->SetInGameMode( false ); +#endif + + + MEMTRACK_POP_FLAG( "" ); + + HeapMgr()->PopHeap ( GMA_PERSISTENT ); + + rTunePrintf("Finished\n"); + SetMemoryIdentification( "BootupContext Finished" ); +} + + +//============================================================================== +// BootupContext::OnUpdate +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void BootupContext::OnUpdate( unsigned int elapsedTime ) +{ + if( m_elapsedTime != -1 ) + { + if( m_elapsedTime > MINIMUM_LICENSE_SCREEN_DISPLAY_TIME && + m_bootupLoadCompleted && m_soundLoadCompleted ) + { + // Tell GUI system to quit out of the boot-up state + GetGuiSystem()->HandleMessage( GUI_MSG_QUIT_BOOTUP ); + + m_elapsedTime = -1; + } + else + { + m_elapsedTime += elapsedTime; + } + } + + // update game data manager + GetGameDataManager()->Update( elapsedTime ); + + GetPresentationManager()->Update( elapsedTime ); + + // update GUI system + GetGuiSystem()->Update( elapsedTime ); +} + + +//============================================================================== +// BootupContext::OnSuspend +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void BootupContext::OnSuspend() +{ +} + + +//============================================================================== +// BootupContext::OnResume +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void BootupContext::OnResume() +{ +} + + +//============================================================================== +// BootupContext::OnHandleEvent +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void BootupContext::OnHandleEvent( EventEnum id, void* pEventData ) +{ +} + +//============================================================================= +// BootupContext::OnProcessRequestsComplete +//============================================================================= +// Description: Called when startup loading is done +// +// Parameters: pUserData - unused +// +// Return: void +// +//============================================================================= +void BootupContext::OnProcessRequestsComplete( void* pUserData ) +{ + if( pUserData == GetSoundManager() ) + { + // set flag indicating all sound loads have completed + // + m_soundLoadCompleted = true; + } + else + { + // set flag indicating all bootup loads (except for sound) have completed + // + m_bootupLoadCompleted = true; + } + + // + // Tell the sound manager to do some processing, now that the scripts + // are sure to have been loaded. + // + // NOTE: I've moved this here since this call triggers a CPU-hogging + // bit of dialog script postprocessing. That processing should be pulled out + // and done offline, but until then, do this somewhere where + // it won't starve the completion of FMVs. -- Esan + // + if( m_bootupLoadCompleted && m_soundLoadCompleted ) + { + GetSoundManager()->OnBootupComplete(); + + GetInputManager()->ToggleRumble( false ); + } +} + +//============================================================================= +// BootupContext::OnPresentationEventBegin +//============================================================================= +// Description: Comment +// +// Parameters: ( PresentationEvent* pEvent ) +// +// Return: void +// +//============================================================================= +void BootupContext::OnPresentationEventBegin( PresentationEvent* pEvent ) +{ +} + +//============================================================================= +// BootupContext::OnPresentationEventLoadComplete +//============================================================================= +// Description: Comment +// +// Parameters: ( PresentationEvent* pEvent ) +// +// Return: void +// +//============================================================================= +void BootupContext::OnPresentationEventLoadComplete( PresentationEvent* pEvent ) +{ +} + + +//============================================================================= +// BootupContext::OnPresentationEventEnd +//============================================================================= +// Description: Comment +// +// Parameters: ( PresentationEvent* pEvent ) +// +// Return: void +// +//============================================================================= +void BootupContext::OnPresentationEventEnd( PresentationEvent* pEvent ) +{ + if( GetPresentationManager()->IsQueueEmpty() ) + { + GetRenderManager()->mpLayer( RenderEnums::GUI )->Warm(); + + // Switch to frontend context. + GetGameFlow()->SetContext( CONTEXT_FRONTEND ); + } +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + + +//============================================================================== +// BootupContext::BootupContext +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//==============================================================================// +BootupContext::BootupContext() +: m_elapsedTime( -1 ), + m_bootupLoadCompleted( false ), + m_soundLoadCompleted( false ), + m_pSharedShader( 0 ) +{ + m_pSharedShader = p3d::device->NewShader("simple"); + rAssert( m_pSharedShader ); + m_pSharedShader->AddRef(); +} + + +//============================================================================== +// BootupContext::~BootupContext +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//==============================================================================// +BootupContext::~BootupContext() +{ + // Too bad we can't use tEntity::Release() since is + //a pddi object. + if( m_pSharedShader != 0 ) + { + m_pSharedShader->Release(); + m_pSharedShader = 0; + } + spInstance = NULL; +} + diff --git a/game/code/contexts/bootupcontext.h b/game/code/contexts/bootupcontext.h new file mode 100644 index 0000000..1304e7f --- /dev/null +++ b/game/code/contexts/bootupcontext.h @@ -0,0 +1,98 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: bootupcontext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef BOOTUPCONTEXT_H +#define BOOTUPCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> // is-a Context + +#include <loading/loadingmanager.h> +#include <presentation/presevents/presentationevent.h> + +//======================================== +// Forward References +//======================================== +class HeadToHeadManager; +class pddiShader; + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class BootupContext : public Context, + public LoadingManager::ProcessRequestsCallback, + public PresentationEvent::PresentationEventCallBack +{ + public: + + // Static Methods for accessing this singleton. + static BootupContext* GetInstance(); + + void StartMovies(); + void StartLoadingSound(); + void ResetLicenseScreenDisplayTime() { m_elapsedTime = 0; } + +#ifdef RAD_WIN32 + void LoadConfig(); +#endif + + pddiShader* GetSharedShader( void ) { return m_pSharedShader; } + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + + virtual void OnProcessRequestsComplete( void* pUserData ); + + virtual void OnPresentationEventBegin( PresentationEvent* pEvent ); + virtual void OnPresentationEventLoadComplete( PresentationEvent* pEvent ); + virtual void OnPresentationEventEnd( PresentationEvent* pEvent ); + + private: + + // constructor and destructor are protected to force singleton implementation + BootupContext(); + virtual ~BootupContext(); + + // Declared but not defined to prevent copying and assignment. + BootupContext( const BootupContext& ); + BootupContext& operator=( const BootupContext& ); + + // Pointer to the one and only instance of this singleton. + static BootupContext* spInstance; + + int m_elapsedTime; + bool m_bootupLoadCompleted : 1; + bool m_soundLoadCompleted : 1; + + pddiShader* m_pSharedShader; +}; + +// A little syntactic sugar for getting at this singleton. +inline BootupContext* GetBootupContext() { return( BootupContext::GetInstance() ); } + + +#endif diff --git a/game/code/contexts/context.cpp b/game/code/contexts/context.cpp new file mode 100644 index 0000000..6252f25 --- /dev/null +++ b/game/code/contexts/context.cpp @@ -0,0 +1,197 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: context.cpp +// +// Description: Implementation of Context base class. +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <raddebug.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> +#include <memory/srrmemory.h> + + +#include <debug/debuginfo.h> + +// Managers. +// +#include <input/inputmanager.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// Context::DestroyInstance +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void Context::DestroyInstance() +{ + delete( GMA_PERSISTENT, this ); +} + +//============================================================================== +// Context::Start +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void Context::Start( ContextEnum previousContext ) +{ + this->OnStart( previousContext ); +} + + +//============================================================================== +// Context::Stop +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void Context::Stop( ContextEnum nextContext ) +{ + this->OnStop( nextContext ); +} + + +//============================================================================== +// Context::Update +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void Context::Update( unsigned int elapsedTime ) +{ + InputManager::GetInstance()->Update( elapsedTime ); + this->OnUpdate( elapsedTime ); +} + + +//============================================================================== +// Context::HandleEvent +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void Context::HandleEvent( EventEnum id, void* pEventData ) +{ + this->OnHandleEvent( id, pEventData ); +} + +//============================================================================= +// Context::Suspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void Context::Suspend() +{ + m_state = S_SUSPENDED; + + OnSuspend(); +} + +//============================================================================= +// Context::Resume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void Context::Resume() +{ + m_state = S_ACTIVE; + + OnResume(); +} + +//****************************************************************************** +// +// Protected Member Functions +// +//****************************************************************************** + + +//============================================================================== +// Context::Context +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//==============================================================================// +Context::Context() +{ +} + + +//============================================================================== +// Context::~Context +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//==============================================================================// +Context::~Context() +{ +} + diff --git a/game/code/contexts/context.h b/game/code/contexts/context.h new file mode 100644 index 0000000..b4435cb --- /dev/null +++ b/game/code/contexts/context.h @@ -0,0 +1,94 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: context.h +// +// Description: Context base class declaration. +// +// History: + Stolen and cleaned up from Penthouse -- Darwin Chau +// +//============================================================================= + +#ifndef CONTEXT_H +#define CONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/contextenum.h> +#include <events/eventlistener.h> + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: This is the Context Controller base class. It will be used as +// a base class for all context controllers in the game, such as +// PlayContext and PauseContext. These will +// be updated from the GameFlow. +// +//============================================================================= +class Context : public EventListener +{ + public: + + void DestroyInstance(); + + // gameflow should call these functions to manipulate the context controller; + // derived classes must NOT over-ride the following non-virtual functions; + // these functions will call the corresponding protected virtual functions + void Start( ContextEnum previousContext ); + void Stop( ContextEnum nextContext ); + void Update( unsigned int elapsedTime ); + + // The game must halt when the disc door is opened on the GameCube. + void Suspend(); + void Resume(); + bool IsSuspended() const {return m_state == S_SUSPENDED;}; + + virtual void HandleEvent( EventEnum id, void* pEventData ); + + protected: + + // constructor and destructor are protected to force singleton implementation + Context(); + virtual ~Context(); + + // derived classes MUST over-ride the following virtual functions to implement + // custom behaviour; these functions are called by the corresponding public + // non-virtual functions + virtual void OnStart( ContextEnum previousContext ) = 0; + virtual void OnStop( ContextEnum nextContext ) = 0; + virtual void OnUpdate( unsigned int elapsedTime ) = 0; + + virtual void OnSuspend() = 0; + virtual void OnResume() = 0; + + virtual void OnHandleEvent( EventEnum id, void* pEventData ) = 0; + + enum StateEnum + { + S_NONE, + S_READY, + S_ACTIVE, + S_SUSPENDED, + S_EXIT, + MAX_STATES + }; + + StateEnum m_state; + + private: + + // Declared but not defined to prevent copying and assignment. + Context( const Context& ); + Context& operator=( const Context& ); +}; + +#endif diff --git a/game/code/contexts/contextenum.h b/game/code/contexts/contextenum.h new file mode 100644 index 0000000..94871b0 --- /dev/null +++ b/game/code/contexts/contextenum.h @@ -0,0 +1,71 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: contextenum.h +// +// Description: Game contexts. +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef CONTEXTENUM_H +#define CONTEXTENUM_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== + +//======================================== +// Forward References +//======================================== + +//======================================== +// Constants, Typedefs and Statics +//======================================== +enum ContextEnum +{ + // The following shows the possible transitions between + // contexts: + // [ PREVIOUS ] [ CURRENT ] [ NEXT ] + + CONTEXT_ENTRY, // (Start) -----> ENTRY -----> BOOTUP + + CONTEXT_BOOTUP, // ENTRY -----> BOOTUP -----> FRONTEND + + CONTEXT_FRONTEND, // BOOTUP -----> FRONTEND -----> LOADING_G + // | | + // PAUSE --| |--> LOADING_D + + CONTEXT_LOADING_DEMO, // FRONTEND -----> LOADING_D -----> DEMO + + CONTEXT_DEMO, // LOADING_D -----> DEMO -----> FRONTEND + + CONTEXT_SUPERSPRINT_FE, // FRONTEND -----> SS_FE -----> LOADING_S + // | + // |--> FRONTEND + + CONTEXT_LOADING_SUPERSPRINT, // SS_FE -----> LOADING_S -----> SUPERSPRINT + + CONTEXT_SUPERSPRINT, // LOADING_S -----> SUPERSPRINT -----> SS_FE + + CONTEXT_LOADING_GAMEPLAY, // FRONTEND -----> LOADING_G -----> GAMEPLAY + + CONTEXT_GAMEPLAY, // LOADING_G -----> GAMEPLAY -----> PAUSE + // | + // PAUSE --| + + CONTEXT_PAUSE, // GAMEPLAY -----> PAUSE -----> GAMEPLAY + // | + // |--> FRONTEND + + CONTEXT_EXIT, // FRONTEND -----> EXIT -----> (End) + + NUM_CONTEXTS +}; + +#endif // CONTEXTENUM_H diff --git a/game/code/contexts/demo/alldemo.cpp b/game/code/contexts/demo/alldemo.cpp new file mode 100644 index 0000000..8162474 --- /dev/null +++ b/game/code/contexts/demo/alldemo.cpp @@ -0,0 +1,2 @@ +#include <contexts/demo/loadingdemocontext.cpp> +#include <contexts/demo/democontext.cpp> diff --git a/game/code/contexts/demo/democontext.cpp b/game/code/contexts/demo/democontext.cpp new file mode 100644 index 0000000..f1d2cfd --- /dev/null +++ b/game/code/contexts/demo/democontext.cpp @@ -0,0 +1,563 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement DemoContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <p3d/shadow.hpp> + +//======================================== +// Project Includes +//======================================== +#include <ai/vehicle/vehicleairender.h> + +#include <contexts/demo/democontext.h> +#include <gameflow/gameflow.h> +#include <main/commandlineoptions.h> +#include <main/game.h> +#include <memory/srrmemory.h> +#include <memory/leakdetection.h> +#include <mission/gameplaymanager.h> +#include <presentation/gui/guisystem.h> +#include <render/rendermanager/rendermanager.h> +#include <render/DSG/StatePropDSG.h> +#include <render/rendermanager/renderlayer.h> +#include <ai/actor/actormanager.h> + +#include <worldsim/character/footprint/footprintmanager.h> +#include <worldsim/coins/coinmanager.h> +#include <worldsim/coins/sparkle.h> +#include <worldsim/hitnrunmanager.h> +#include <worldsim/vehiclecentral.h> +#include <worldsim/worldphysicsmanager.h> +#include <worldsim/avatarmanager.h> +#include <worldsim/character/charactermanager.h> +#include <worldsim/traffic/trafficmanager.h> +#include <worldsim/ped/pedestrianmanager.h> + +#include <worldsim/skidmarks/skidmarkmanager.h> + +#include <camera/walkercam.h> +#include <camera/followcam.h> +#include <camera/wrecklesscam.h> +#include <camera/chasecam.h> +#include <camera/conversationcam.h> +#include <camera/supercammanager.h> + +#include <render/breakables/breakablesmanager.h> +#include <render/particles/particlemanager.h> +#include <render/animentitydsgmanager/animentitydsgmanager.h> +#include <render/RenderManager/WorldRenderLayer.h> +#include <worldsim/skidmarks/skidmarkgenerator.h> +#include <sound/soundmanager.h> +#include <meta/triggervolumetracker.h> +#include <render/Loaders/AnimDynaPhysLoader.h> + +#include <pedpaths/pathmanager.h> + +#include <input/inputmanager.h> + +// TODO: Remove once we put CreateRoadNetwork in the levels pipe +#include <roads/roadmanager.h> +#include <p3d/light.hpp> +#include <p3d/view.hpp> + +#include <worldsim/worldobject.h> +#include <ai/actionbuttonmanager.h> + +#include <presentation/presentation.h> + +#include <mission/animatedicon.h> + +#include <render/animentitydsgmanager/animentitydsgmanager.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +extern bool g_inDemoMode; + +// Static pointer to instance of singleton. +DemoContext* DemoContext::spInstance = NULL; + +const unsigned int DEMO_LOOP_TIME = 60000; // in msec + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// DemoContext::GetInstance +//============================================================================== +// +// Description: - Access point for the DemoContext singleton. +// - Creates the DemoContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the DemoContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +DemoContext* DemoContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new DemoContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================== +// DemoContext::DemoContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +DemoContext::DemoContext() +: m_demoLoopTime( DEMO_LOOP_TIME ), + m_elapsedTime( -1 ) +{ +} + +//============================================================================== +// DemoContext::~DemoContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +DemoContext::~DemoContext() +{ +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// DemoContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void DemoContext::OnStart( ContextEnum previousContext ) +{ + // Common to all playing contexts. + // + PlayingContext::OnStart( previousContext ); + + GetInputManager()->SetGameState( Input::ACTIVE_FRONTEND ); + + // We count the number of demos run. + // + GetGame()->IncrementDemoCount(); + + m_elapsedTime = 0; // reset elapsed demo time + + //////////////////////////////////////////////////////////// + // RenderManager + RenderManager* rm = GetRenderManager(); + RenderLayer* rl = rm->mpLayer( RenderEnums::LevelSlot ); + rAssert( rl ); + +#ifdef DEBUGWATCH + // bootstrap vehicleai renderer + VehicleAIRender::GetVehicleAIRender(); +#endif + + //////////////////////////////////////////////////////////// + // Cameras set up + unsigned int iNumPlayers = GetGameplayManager()->GetNumPlayers(); + rl->SetNumViews( iNumPlayers ); + rl->SetUpViewCam(); + + p3d::inventory->SelectSection("Default"); + tLightGroup* sun = p3d::find<tLightGroup>("sun"); + rAssert( sun ); + rm->SetLevelLayerLights( sun ); + + float aspect = p3d::display->IsWidescreen() ? (16.0f / 9.0f) : (4.0f / 3.0f); + + unsigned int view = 0; + + tPointCamera* cam = static_cast<tPointCamera*>( rl->pCam( view ) ); + rAssert( dynamic_cast<tPointCamera*> ( cam ) != NULL ); + rAssert( cam ); + + SuperCamCentral* scc = GetSuperCamManager()->GetSCC( view ); + rAssert( scc ); + + scc->SetCamera( cam ); + + FollowCam* fc = new FollowCam( FollowCam::FOLLOW_NEAR ); + fc->SetAspect( aspect ); + fc->CopyToData(); + scc->RegisterSuperCam( fc ); + + fc = new FollowCam( FollowCam::FOLLOW_FAR ); + fc->SetAspect( aspect ); + fc->CopyToData(); + scc->RegisterSuperCam( fc ); + + SuperCam* sc = new WalkerCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + sc = new ChaseCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + sc = new WrecklessCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + sc = new ConversationCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + + //////////////////////////////////////////////////////////// + // AvatarManager Bootstrapping + GetAvatarManager( )->EnterGame( ); + /* + GetActionButtonManager( )->EnterGame( ); + */ + + //////////////////////////////////////////////////////////// + // TrafficManager Init + TrafficManager::GetInstance()->Init(); + + //////////////////////////////////////////////////////////// + // PedestrianManager Init + PedestrianManager::GetInstance()->Init(); + + // TODO: Move this into level pipe + //Set up the sorting of the intersections and stuff. + RoadManager::GetInstance()->CreateRoadNetwork(); + + //////////////////////////////////////////////////////////// + // SkidMark Init Init + //Find skid mark shaders in the inventory and set proper values + SkidMarkGenerator::InitShaders(); + + GetSkidmarkManager()->Init(); + + //////////////////////////////////////////////////////////// + // OnStart calls + // + // Notify the sound system of gameplay start. This has been moved after + // the GUI startup above, since that leads to a mission reset, which causes + // character position in or out of the car to be decided, which the sound + // system uses to determine which sounds to start playing. + // + SoundManager::GetInstance()->OnGameplayStart(); + /* + GetPresentationManager()->OnGameplayStart(); + */ + + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_INGAME ); + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_DEMO ); // TC: must be called after GUI_MSG_RUN_INGAME + + GetGuiSystem()->RegisterUserInputHandlers(); + + GetGame()->SetTime( 0 ); + + g_inDemoMode = true; +} + +//============================================================================= +// DemoContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void DemoContext::OnStop( ContextEnum nextContext ) +{ + HeapMgr()->PushHeap (GMA_TEMP); + + // + // This is called to prevent DMA of destroyed textures, + // because we don't swap buffers until the next frame. + // + p3d::pddi->DrawSync(); + + // Clear the shadow list + AnimDynaPhysLoader::ClearShadowList(); + + GetCoinManager()->Destroy(); + GetSparkleManager()->Destroy(); + GetSkidmarkManager()->Destroy(); + GetHitnRunManager()->Destroy(); + + StatePropDSG::RemoveAllSharedtPoses(); + + + const bool shutdown = true; + GetSuperCamManager()->Init( shutdown ); + + TriggerVolumeTracker::GetInstance()->Cleanup(); + + // Clean up lights! + // + RenderLayer* rl = GetRenderManager()->mpLayer( RenderEnums::LevelSlot ); + rAssert( rl ); + for( unsigned int i = 0; i < rl->GetNumViews(); i++ ) + { + rl->pView(i)->RemoveAllLights (); + } + +#ifdef DEBUGWATCH + VehicleAIRender::Destroy(); +#endif + + GetPresentationManager()->OnGameplayStop(); + + GetPresentationManager()->Finalize(); + + //Destroy Avatars stuff first + + GetGameplayManager()->Finalize(); + SetGameplayManager( NULL ); + + GetAvatarManager()->Destroy(); + + TrafficManager::DestroyInstance(); + PedestrianManager::DestroyInstance(); + GetCharacterManager()->Destroy(); + GetVehicleCentral()->Unload(); + GetActorManager()->RemoveAllActors(); + GetActorManager()->RemoveAllSpawnPoints(); + + //We never entered. + //GetActionButtonManager( )->Destroy( ); + + GetBreakablesManager()->FreeAllBreakables(); + GetParticleManager()->ClearSystems(); + GetRenderManager()->DumpAllLoadedData(); + SkidMarkGenerator::ReleaseShaders(); + + GetSoundManager()->OnGameplayEnd( true ); + + PathManager::GetInstance()->Destroy(); + + + // TODO - Darryl? + // + // all active vehicles should be destroyed + // they are owned by the missions that created them. + + //This does cleanup. + RoadManager::GetInstance()->Destroy(); + + // release GUI in-game + GetGuiSystem()->HandleMessage( GUI_MSG_RELEASE_INGAME ); + + /* + // enable screen clearing + GetRenderManager()->mpLayer(RenderEnums::GUI)->pView( 0 )->SetClearMask( PDDI_BUFFER_ALL ); + */ + + // Cleanup the Avatar Manager + // + GetAvatarManager()->ExitGame(); + + // Flush out the special section used by physics to cache SkeletonInfos. + // + p3d::inventory->RemoveSectionElements (SKELCACHE); + p3d::inventory->DeleteSection (SKELCACHE); + + GetGuiSystem()->UnregisterUserInputHandlers(); + + // enable screen clearing + // + GetRenderManager()->mpLayer( RenderEnums::GUI )->pView( 0 )->SetClearMask( PDDI_BUFFER_ALL ); + +#ifndef RAD_RELEASE + // Dump out the contents of the inventory sections + // + p3d::inventory->Dump (true); +#endif + + AnimatedIcon::ShutdownAnimatedIcons(); + GetAnimEntityDSGManager()->RemoveAll(); + + HeapMgr()->PopHeap (GMA_TEMP); + + + // Common to all playing contexts. + // + PlayingContext::OnStop( nextContext ); +} + +//============================================================================= +// DemoContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void DemoContext::OnUpdate( unsigned int elapsedTime ) +{ + if ( !mQuitting ) + { + bool cont = true; + + if( m_elapsedTime != -1 ) + { + m_elapsedTime += static_cast<int>( elapsedTime ); + if( m_elapsedTime > static_cast<int>( m_demoLoopTime ) ) + { + if ( GetLoadingManager()->IsLoading() ) + { + //HACK! + //Oops! Can't quit yet! + m_elapsedTime -= static_cast<int>( elapsedTime ); + } + else + { + // demo loop time expired, quit out of demo + // + GetGuiSystem()->HandleMessage( GUI_MSG_QUIT_DEMO ); + + m_elapsedTime = -1; + mQuitting = true; //Now we're quitting + } + cont = false; + } + } + + if ( cont ) + { + float timeins = (float)(elapsedTime) / 1000.0f; + GetAvatarManager()->Update( timeins ); + + GetCharacterManager()->GarbageCollect( ); + + /////////////////////////////////////////////////////////////// + // Update Particles + GetParticleManager()->Update( elapsedTime ); + GetBreakablesManager()->Update( elapsedTime ); + GetAnimEntityDSGManager()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Gameplay Manager + GetGameplayManager()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Physics + GetWorldPhysicsManager()->Update(elapsedTime); + + /////////////////////////////////////////////////////////////// + // Update Peds + // ordering is important. Unless other parts of code change, we must call + // this before WorldPhysManager::Update() because PedestrianManager + // sets the flags for all characters to be updated in WorldPhys Update + PedestrianManager::GetInstance()->Update( elapsedTime ); + + /* + /////////////////////////////////////////////////////////////// + // Update PresentationManager + GetPresentationManager()->Update( elapsedTime ); + */ + + /////////////////////////////////////////////////////////////// + // Update Trigger volumes + GetTriggerVolumeTracker()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Traffic + TrafficManager::GetInstance()->Update( elapsedTime ); + + /* + /////////////////////////////////////////////////////////////// + // Update Interiors + GetInteriorManager()->Update( elapsedTime ); + */ + + //extra updates + GetFootprintManager()->Update( elapsedTime ); + BEGIN_PROFILE("SkidmarkManager"); + GetSkidmarkManager()->Update( elapsedTime ); + END_PROFILE("SkidmarkManager"); + ActorManager::GetInstance()->Update( elapsedTime ); + GetCoinManager()->Update( elapsedTime ); + GetSparkleManager()->Update( elapsedTime ); + GetHitnRunManager()->Update( elapsedTime ); + } + } //!mQuitting + + // Common to all playing contexts. + // + PlayingContext::OnUpdate( elapsedTime ); +} + +//============================================================================= +// DemoContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void DemoContext::OnSuspend() +{ + // Common to all playing contexts. + // + PlayingContext::OnSuspend(); +} + +//============================================================================= +// DemoContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void DemoContext::OnResume() +{ + // Common to all playing contexts. + // + PlayingContext::OnResume(); +} + diff --git a/game/code/contexts/demo/democontext.h b/game/code/contexts/demo/democontext.h new file mode 100644 index 0000000..32a50ed --- /dev/null +++ b/game/code/contexts/demo/democontext.h @@ -0,0 +1,75 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: DemoContext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef DEMOCONTEXT_H +#define DEMOCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/playingcontext.h> // is-a PlayingContext + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class DemoContext : public PlayingContext +{ + public: + + // Static Methods for accessing this singleton. + static DemoContext* GetInstance(); + + void EndDemo(void) { m_elapsedTime = m_demoLoopTime + 1; } + + void SetDemoLoopTime( unsigned int timems ) { m_demoLoopTime = timems; }; + +protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + private: + + // constructor and destructor are protected to force singleton implementation + DemoContext(); + virtual ~DemoContext(); + + // Declared but not defined to prevent copying and assignment. + DemoContext( const DemoContext& ); + DemoContext& operator=( const DemoContext& ); + + // Pointer to the one and only instance of this singleton. + static DemoContext* spInstance; + + unsigned int m_demoLoopTime; + int m_elapsedTime; + +}; + +// A little syntactic sugar for getting at this singleton. +inline DemoContext* GetDemoContext() { return( DemoContext::GetInstance() ); } + + +#endif // DEMOCONTEXT_H diff --git a/game/code/contexts/demo/loadingdemocontext.cpp b/game/code/contexts/demo/loadingdemocontext.cpp new file mode 100644 index 0000000..9d8323a --- /dev/null +++ b/game/code/contexts/demo/loadingdemocontext.cpp @@ -0,0 +1,244 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement LoadingDemoContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/demo/loadingdemocontext.h> + +#include <loading/loadingmanager.h> +#include <mission/gameplaymanager.h> +#include <presentation/gui/guisystem.h> +#include <worldsim/traffic/trafficmanager.h> +#include <worldsim/vehiclecentral.h> +#include <sound/soundmanager.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// Static pointer to instance of singleton. +LoadingDemoContext* LoadingDemoContext::spInstance = NULL; + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// LoadingDemoContext::GetInstance +//============================================================================== +// +// Description: - Access point for the LoadingDemoContext singleton. +// - Creates the LoadingDemoContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the LoadingDemoContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +LoadingDemoContext* LoadingDemoContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new LoadingDemoContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================== +// LoadingDemoContext::LoadingDemoContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingDemoContext::LoadingDemoContext() +{ +} + +//============================================================================== +// LoadingDemoContext::~LoadingDemoContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingDemoContext::~LoadingDemoContext() +{ +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// LoadingDemoContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void LoadingDemoContext::OnStart( ContextEnum previousContext ) +{ + GetGameplayManager()->mIsDemo = true; + + // Common to all loading contexts. + // + LoadingContext::OnStart( previousContext ); + +/***************************************************************************** + * Start inserting stuff below ... + *****************************************************************************/ + + // NOTE: + // Assumes we never start a DEMO on foot (always start inside the car) + GetVehicleCentral()->ActivateVehicleTriggers( false ); + + TrafficManager::GetInstance()->InitDefaultModelGroups(); + + // initialize GUI in-game mode (and load resources) + // + GetGuiSystem()->HandleMessage( GUI_MSG_INIT_INGAME ); + + GetLoadingManager()->AddCallback( this ); +} + +//============================================================================= +// LoadingDemoContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void LoadingDemoContext::OnStop( ContextEnum nextContext ) +{ + // Common to all loading contexts. + // + LoadingContext::OnStop( nextContext ); +} + +//============================================================================= +// LoadingDemoContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void LoadingDemoContext::OnUpdate( unsigned int elapsedTime ) +{ + GetGameplayManager()->Update( elapsedTime ); + + // Common to all loading contexts. + // + LoadingContext::OnUpdate( elapsedTime ); +} + +//============================================================================= +// LoadingDemoContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingDemoContext::OnSuspend() +{ + // Common to all loading contexts. + // + LoadingContext::OnSuspend(); +} + +//============================================================================= +// LoadingDemoContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingDemoContext::OnResume() +{ + // Common to all loading contexts. + // + LoadingContext::OnResume(); +} + +//============================================================================= +// LoadingDemoContext::PrepareNewHeaps +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingDemoContext::PrepareNewHeaps() +{ + HeapMgr()->PrepareHeapsInGame(); +} + +//============================================================================= +// LoadingDemoContext::OnProcessRequestsComplete +//============================================================================= +// Description: Comment +// +// Parameters: ( void* pUserData ) +// +// Return: void +// +//============================================================================= +void LoadingDemoContext::OnProcessRequestsComplete( void* pUserData ) +{ + GetGameplayManager()->LevelLoaded(); + + // + // Queue the loading for level sounds + // + GetSoundManager()->QueueLevelSoundLoads(); + + // Common to all loading contexts. + // + LoadingContext::OnProcessRequestsComplete( pUserData ); +} diff --git a/game/code/contexts/demo/loadingdemocontext.h b/game/code/contexts/demo/loadingdemocontext.h new file mode 100644 index 0000000..ca4c321 --- /dev/null +++ b/game/code/contexts/demo/loadingdemocontext.h @@ -0,0 +1,71 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: LoadingDemoContext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef LOADINGDEMOCONTEXT_H +#define LOADINGDEMOCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/loadingcontext.h> // is-a LoadingContext + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class LoadingDemoContext : public LoadingContext +{ + public: + // Static Methods for accessing this singleton. + static LoadingDemoContext* GetInstance(); + + virtual void OnProcessRequestsComplete( void* pUserData ); + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void PrepareNewHeaps(); + + private: + + // constructor and destructor are protected to force singleton implementation + LoadingDemoContext(); + virtual ~LoadingDemoContext(); + + // Declared but not defined to prevent copying and assignment. + LoadingDemoContext( const LoadingDemoContext& ); + LoadingDemoContext& operator=( const LoadingDemoContext& ); + + // Pointer to the one and only instance of this singleton. + static LoadingDemoContext* spInstance; + +}; + +// A little syntactic sugar for getting at this singleton. +inline LoadingDemoContext* GetLoadingDemoContext() { return( LoadingDemoContext::GetInstance() ); } + + +#endif // LOADINGDEMOCONTEXT_H diff --git a/game/code/contexts/entrycontext.cpp b/game/code/contexts/entrycontext.cpp new file mode 100644 index 0000000..41beb67 --- /dev/null +++ b/game/code/contexts/entrycontext.cpp @@ -0,0 +1,211 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: entrycontext.cpp +// +// Description: Implementation of EntryContext. +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <raddebug.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/entrycontext.h> +#include <memory/srrmemory.h> + + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// +// Static pointer to instance of singleton. +// +EntryContext* EntryContext::spInstance = NULL; + + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// EntryContext::GetInstance +//============================================================================== +// +// Description: - Access point for the EntryContext singleton. +// - Creates the EntryContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the EntryContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +EntryContext* EntryContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new(GMA_PERSISTENT) EntryContext; + rAssert( spInstance ); + } + + return spInstance; +} + + +//****************************************************************************** +// +// Protected Member Functions +// +//****************************************************************************** + +//============================================================================== +// EntryContext::OnStart +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void EntryContext::OnStart( ContextEnum previousContext ) +{ + MEMTRACK_PUSH_FLAG( "Entry" ); +} + + +//============================================================================== +// EntryContext::OnStop +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void EntryContext::OnStop( ContextEnum nextContext ) +{ + MEMTRACK_POP_FLAG( "" ); +} + + +//============================================================================== +// EntryContext::OnUpdate +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void EntryContext::OnUpdate( unsigned int elapsedTime ) +{ +} + + +//============================================================================== +// EntryContext::OnSuspend +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void EntryContext::OnSuspend() +{ +} + + +//============================================================================== +// EntryContext::OnResume +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void EntryContext::OnResume() +{ +} + + +//============================================================================== +// EntryContext::OnHandleEvent +//============================================================================== +// +// Description: +// +// Parameters: +// +// Return: +// +//============================================================================== +void EntryContext::OnHandleEvent( EventEnum id, void* pEventData ) +{ +} + + + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + + +//============================================================================== +// EntryContext::EntryContext +//============================================================================== +// +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//==============================================================================// +EntryContext::EntryContext() +{ +} + + +//============================================================================== +// EntryContext::~EntryContext +//============================================================================== +// +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//==============================================================================// +EntryContext::~EntryContext() +{ + spInstance = NULL; +} + diff --git a/game/code/contexts/entrycontext.h b/game/code/contexts/entrycontext.h new file mode 100644 index 0000000..0d30fe5 --- /dev/null +++ b/game/code/contexts/entrycontext.h @@ -0,0 +1,72 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: entrycontext.h +// +// Description: EntryContext class declaration. +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef ENTRYCONTEXT_H +#define ENTRYCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> // is-a Context + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: The game is initialized to this empty context. It doesn't +// do anything! +// +//============================================================================= +class EntryContext : public Context +{ + public: + + // Static Methods for accessing this singleton. + static EntryContext* GetInstance(); + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + + private: + + // constructor and destructor are protected to force singleton implementation + EntryContext(); + virtual ~EntryContext(); + + // Declared but not defined to prevent copying and assignment. + EntryContext( const EntryContext& ); + EntryContext& operator=( const EntryContext& ); + + // Pointer to the one and only instance of this singleton. + static EntryContext* spInstance; +}; + +// +// A little syntactic sugar for getting at this singleton. +// +inline EntryContext* GetEntryContext() { return( EntryContext::GetInstance() ); } + + +#endif // ENTRYCONTEXT_H diff --git a/game/code/contexts/exitcontext.cpp b/game/code/contexts/exitcontext.cpp new file mode 100644 index 0000000..3c8916a --- /dev/null +++ b/game/code/contexts/exitcontext.cpp @@ -0,0 +1,266 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: exitcontext.cpp +// +// Description: Implementation of ExitContext. +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <p3d/view.hpp> +#include <p3d/shadow.hpp> +#include <raddebug.hpp> + +#include <p3d/shadow.hpp> +//======================================== +// Project Includes +//======================================== +#include <ai/vehicle/vehicleairender.h> +#include <contexts/pausecontext.h> +#include <contexts/exitcontext.h> +#include <memory/leakdetection.h> +#include <memory/srrmemory.h> +#include <worldsim/worldobject.h> +#include <camera/supercammanager.h> +#include <interiors/interiormanager.h> +#include <meta/triggervolumetracker.h> +#include <loading/loadingmanager.h> +#include <mission/gameplaymanager.h> +#include <presentation/gui/guisystem.h> +#include <render/RenderManager/RenderManager.h> +#include <render/DSG/StatePropDSG.h> +#include <sound/soundmanager.h> +#include <worldsim/worldphysicsmanager.h> +#include <worldsim/character/charactermanager.h> +#include <worldsim/character/footprint/footprintmanager.h> +#include <worldsim/avatarmanager.h> +#include <worldsim/traffic/trafficmanager.h> +#include <worldsim/ped/pedestrianmanager.h> +#include <worldsim/coins/coinmanager.h> +#include <worldsim/coins/sparkle.h> +#include <worldsim/hitnrunmanager.h> +#include <worldsim/parkedcars/parkedcarmanager.h> +#include <ai/actionbuttonmanager.h> +#include <render/breakables/breakablesmanager.h> +#include <render/particles/ParticleManager.h> +#include <worldsim/skidmarks/skidmarkgenerator.h> +#include <worldsim/skidmarks/skidmarkmanager.h> +#include <ai/actor/actormanager.h> +#include <gameflow/gameflow.h> +#include <roads/roadmanager.h> +#include <render/Loaders/AnimDynaPhysLoader.h> +#include <pedpaths/pathmanager.h> +#include <data/gamedatamanager.h> +#include <mission/animatedicon.h> +#include <render/animentitydsgmanager/animentitydsgmanager.h> +#include <presentation/presentation.h> +#include <main/game.h> + +//****************************************************************************** +// +// 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; +} + diff --git a/game/code/contexts/exitcontext.h b/game/code/contexts/exitcontext.h new file mode 100644 index 0000000..425196b --- /dev/null +++ b/game/code/contexts/exitcontext.h @@ -0,0 +1,69 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: exitcontext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef EXITCONTEXT_H +#define EXITCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> // is-a Context + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class ExitContext : public Context +{ + public: + + // Static Methods for accessing this singleton. + static ExitContext* GetInstance(); + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + + private: + + // constructor and destructor are protected to force singleton implementation + ExitContext(); + virtual ~ExitContext(); + + // Declared but not defined to prevent copying and assignment. + ExitContext( const ExitContext& ); + ExitContext& operator=( const ExitContext& ); + + // Pointer to the one and only instance of this singleton. + static ExitContext* spInstance; +}; + +// A little syntactic sugar for getting at this singleton. +inline ExitContext* GetExitContext() { return( ExitContext::GetInstance() ); } + + +#endif diff --git a/game/code/contexts/frontendcontext.cpp b/game/code/contexts/frontendcontext.cpp new file mode 100644 index 0000000..3e3ca17 --- /dev/null +++ b/game/code/contexts/frontendcontext.cpp @@ -0,0 +1,326 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement FrontEndContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +// Foundation Tech +#include <raddebug.hpp> + +//======================================== +// Project Includes +//======================================== +#include <cheats/cheatinputsystem.h> +#include <contexts/frontendcontext.h> +#include <contexts/contextenum.h> +#include <memory/leakdetection.h> +#include <memory/srrmemory.h> + +#include <presentation/gui/guisystem.h> +#include <presentation/gui/frontend/guimanagerfrontend.h> +#include <mission/rewards/rewardsmanager.h> + +#include <sound/soundmanager.h> + +#include <input/inputmanager.h> + +#include <data/gamedatamanager.h> + +#include <worldsim/coins/coinmanager.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// Static pointer to instance of singleton. +FrontEndContext* FrontEndContext::spInstance = NULL; + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// FrontEndContext::GetInstance +//============================================================================== +// +// Description: - Access point for the FrontEndContext singleton. +// - Creates the FrontEndContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the FrontEndContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +FrontEndContext* FrontEndContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new(GMA_PERSISTENT) FrontEndContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================== +// FrontEndContext::FrontEndContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +FrontEndContext::FrontEndContext() +{ +} + +//============================================================================== +// FrontEndContext::~FrontEndContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +FrontEndContext::~FrontEndContext() +{ +} + + +//****************************************************************************** +// +// Protected Member Functions +// +//****************************************************************************** + +//============================================================================= +// FrontEndContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void FrontEndContext::OnStart( ContextEnum previousContext ) +{ + SetMemoryIdentification( "FEContext" ); + MEMTRACK_PUSH_FLAG( "Front End" ); + + HeapMgr()->PushHeap( GMA_LEVEL_FE ); + + if( previousContext != CONTEXT_BOOTUP ) + { + HeapMgr()->PrepareHeapsFeCleanup(); + LEAK_DETECTION_CHECKPOINT(); + HeapMgr()->PrepareHeapsFeSetup(); + + // reset all cheats + // + GetCheatInputSystem()->Reset(); + + // unregister controller ID from all players + // + GetInputManager()->UnregisterAllControllerID(); + + // tell GUI system to run backend during loading + // + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_BACKEND ); + + // initialize GUI frontend mode (and load resources) + GetGuiSystem()->HandleMessage( GUI_MSG_INIT_FRONTEND ); + + GetLoadingManager()->AddCallback( this ); + } + else + { + // Start the front end. + LEAK_DETECTION_CHECKPOINT(); + this->StartFrontEnd( CGuiWindow::GUI_SCREEN_ID_SPLASH ); + } + + GetInputManager()->ToggleRumble( false ); + + GetGuiSystem()->RegisterUserInputHandlers(); + + GetInputManager()->SetGameState( Input::ACTIVE_FRONTEND ); +} + +//============================================================================= +// FrontEndContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void FrontEndContext::OnStop( ContextEnum nextContext ) +{ + GetGuiSystem()->UnregisterUserInputHandlers(); + + // release GUI frontend + GetGuiSystem()->HandleMessage( GUI_MSG_RELEASE_FRONTEND ); + + // + // Notify the sound system that the front end is stopping + // + GetSoundManager()->OnFrontEndEnd(); + + GetInputManager()->SetGameState( Input::ACTIVE_ALL ); + + HeapMgr()->PopHeap(GMA_LEVEL_FE); + + MEMTRACK_POP_FLAG( "" ); + + SetMemoryIdentification( "FEContext Finished" ); +} + +//============================================================================= +// FrontEndContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void FrontEndContext::OnUpdate( unsigned int elapsedTime ) +{ + // update game data manager + // + GetGameDataManager()->Update( elapsedTime ); + + // update GUI system + // + GetGuiSystem()->Update( elapsedTime ); + + //Chuck: adding this so that the rewards manager reflects changes found in the charactersheet. + GetRewardsManager()->SynchWithCharacterSheet(); +} + +//============================================================================= +// FrontEndContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void FrontEndContext::OnSuspend() +{ +} + +//============================================================================= +// FrontEndContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void FrontEndContext::OnResume() +{ +} + +//============================================================================= +// FrontEndContext::OnHandleEvent +//============================================================================= +// Description: Comment +// +// Parameters: ( EventEnum id, void* pEventData ) +// +// Return: void +// +//============================================================================= +void FrontEndContext::OnHandleEvent( EventEnum id, void* pEventData ) +{ +} + +//============================================================================= +// FrontEndContext::OnProcessRequestsComplete +//============================================================================= +// Description: Called when startup loading is done +// +// Parameters: pUserData - unused +// +// Return: void +// +//============================================================================= +void FrontEndContext::OnProcessRequestsComplete( void* pUserData ) +{ + // tell GUI system to quit backend + // + GetGuiSystem()->HandleMessage( GUI_MSG_QUIT_BACKEND ); + +#ifndef RAD_DEMO + if( GetGuiSystem()->IsSplashScreenFinished() ) + { + if( GetGuiSystem()->IsShowCreditsUponReturnToFE() ) + { + this->StartFrontEnd( CGuiWindow::GUI_SCREEN_ID_VIEW_CREDITS ); + } + else + { + this->StartFrontEnd( CGuiWindow::GUI_SCREEN_ID_MAIN_MENU ); + } + } + else +#endif + { + this->StartFrontEnd( CGuiWindow::GUI_SCREEN_ID_SPLASH ); + } +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// FrontEndContext::StartFrontEnd +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void FrontEndContext::StartFrontEnd( unsigned int initialScreen ) +{ + // Start up GUI frontend manager + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_FRONTEND, initialScreen ); + + // + // Notify the sound system that the front end is starting + // + GetSoundManager()->OnFrontEndStart(); +} + diff --git a/game/code/contexts/frontendcontext.h b/game/code/contexts/frontendcontext.h new file mode 100644 index 0000000..5395723 --- /dev/null +++ b/game/code/contexts/frontendcontext.h @@ -0,0 +1,75 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: FrontEndcontext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef FRONTENDCONTEXT_H +#define FRONTENDCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> // is-a Context + +#include <loading/loadingmanager.h> + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class FrontEndContext : public Context, + public LoadingManager::ProcessRequestsCallback +{ + public: + + // Static Methods for accessing this singleton. + static FrontEndContext* GetInstance(); + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + virtual void OnProcessRequestsComplete( void* pUserData ); + + private: + + void StartFrontEnd( unsigned int initialScreen ); + + // constructor and destructor are protected to force singleton implementation + FrontEndContext(); + virtual ~FrontEndContext(); + + // Declared but not defined to prevent copying and assignment. + FrontEndContext( const FrontEndContext& ); + FrontEndContext& operator=( const FrontEndContext& ); + + // Pointer to the one and only instance of this singleton. + static FrontEndContext* spInstance; +}; + +// A little syntactic sugar for getting at this singleton. +inline FrontEndContext* GetFrontEndContext() { return( FrontEndContext::GetInstance() ); } + + +#endif // FRONTENDCONTEXT_H diff --git a/game/code/contexts/gameplay/allgameplay.cpp b/game/code/contexts/gameplay/allgameplay.cpp new file mode 100644 index 0000000..7b9a0b5 --- /dev/null +++ b/game/code/contexts/gameplay/allgameplay.cpp @@ -0,0 +1,2 @@ +#include <contexts/gameplay/loadinggameplaycontext.cpp> +#include <contexts/gameplay/gameplaycontext.cpp> diff --git a/game/code/contexts/gameplay/gameplaycontext.cpp b/game/code/contexts/gameplay/gameplaycontext.cpp new file mode 100644 index 0000000..ccee4e0 --- /dev/null +++ b/game/code/contexts/gameplay/gameplaycontext.cpp @@ -0,0 +1,616 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement GameplayContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +// Foundation Tech +#include <raddebug.hpp> +#include <radtime.hpp> +#include <raddebugwatch.hpp> + +//======================================== +// Project Includes +//======================================== + +#include <ai/vehicle/vehicleairender.h> + +#include <camera/animatedcam.h> +#include <camera/debugcam.h> +#include <camera/followcam.h> +#include <camera/relativeanimatedcam.h> +#include <camera/chasecam.h> +#include <camera/bumpercam.h> +#include <camera/kullcam.h> +#include <camera/trackercam.h> +#include <camera/walkercam.h> +#include <camera/railcam.h> +#include <camera/wrecklesscam.h> +#include <camera/supercammanager.h> +#include <camera/conversationcam.h> +#include <camera/reversecam.h> +#include <camera/snapshotcam.h> +#ifdef RAD_WIN32 +#include <camera/pccam.h> +#endif + +//#include <camera/firstpersoncam.h> + +#include <contexts/gameplay/gameplaycontext.h> +#include <contexts/contextenum.h> +#include <events/eventmanager.h> +#include <gameflow/gameflow.h> + +#include <data/gamedatamanager.h> + +#include <interiors/interiormanager.h> +#include <memory/leakdetection.h> +#include <memory/srrmemory.h> + +#include <meta/triggervolumetracker.h> + +#include <mission/gameplaymanager.h> +#include <mission/charactersheet/charactersheetmanager.h> + +#include <presentation/presentation.h> +#include <presentation/gui/guisystem.h> + +#include <render/rendermanager/rendermanager.h> +#include <render/RenderManager/RenderLayer.h> + +#include <worldsim/character/footprint/footprintmanager.h> +#include <worldsim/worldphysicsmanager.h> +#include <worldsim/avatarmanager.h> +#include <worldsim/coins/coinmanager.h> +#include <worldsim/skidmarks/skidmarkmanager.h> +#include <worldsim/coins/sparkle.h> +#include <worldsim/hitnrunmanager.h> +#include <ai/actionbuttonmanager.h> +#include <ai/actor/actormanager.h> + + +#include <worldsim/character/charactermanager.h> +#include <worldsim/traffic/trafficmanager.h> +#include <worldsim/ped/pedestrianmanager.h> + +#include <render/breakables/breakablesmanager.h> +#include <render/particles/particlemanager.h> +#include <render/animentitydsgmanager/animentitydsgmanager.h> +#include <render/RenderManager/WorldRenderLayer.h> +#include <worldsim/skidmarks/skidmarkgenerator.h> + +#include <sound/soundmanager.h> + +#include <roads/roadmanager.h> + +#include <input/inputmanager.h> +#include <p3d/light.hpp> +#include <p3d/view.hpp> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// Static pointer to instance of singleton. +GameplayContext* GameplayContext::spInstance = NULL; + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// GameplayContext::GetInstance +//============================================================================== +// +// Description: - Access point for the GameplayContext singleton. +// - Creates the GameplayContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the GameplayContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +GameplayContext* GameplayContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new(GMA_PERSISTENT) GameplayContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================== +// GameplayContext::GameplayContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +GameplayContext::GameplayContext() : + m_PausedAllButPresentation( false ), + mSlowMoHack( false ) +{ +#ifdef DEBUGWATCH + radDbgWatchAddUnsignedInt( &mDebugPhysTiming, "Debug Phys micros", "GameplayContext", NULL, NULL ); + radDbgWatchAddUnsignedInt( &mDebugTimeDelta, "Debug dT micros", "GameplayContext", NULL, NULL ); + radDbgWatchAddUnsignedInt( &mDebugOnUpdateDT, "Gameplay dT micros", "GameplayContext", NULL, NULL ); + radDbgWatchAddBoolean(&mSlowMoHack, "Slow Mo Hack", "GameplayContext", NULL, NULL); +#endif +} + +//============================================================================== +// GameplayContext::~GameplayContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +GameplayContext::~GameplayContext() +{ +#ifdef DEBUGWATCH + radDbgWatchDelete(&mDebugPhysTiming); + radDbgWatchDelete(&mDebugTimeDelta); + radDbgWatchDelete(&mDebugOnUpdateDT); + + radDbgWatchDelete(&mSlowMoHack); +#endif +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// GameplayContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void GameplayContext::OnStart( ContextEnum previousContext ) +{ + // Common to all playing contexts. + // + PlayingContext::OnStart( previousContext ); + + MEMTRACK_PUSH_FLAG( "Gameplay" ); + // do gameplay initializations only if previous context was loading context + if( previousContext == CONTEXT_LOADING_GAMEPLAY ) + { + // RenderManager + // + RenderManager* rm = GetRenderManager(); + + RenderLayer* rl = rm->mpLayer( RenderEnums::LevelSlot ); + rAssert( rl ); + +#ifdef DEBUGWATCH + // bootstrap vehicleai renderer + VehicleAIRender::GetVehicleAIRender(); +#endif + + // Set up cameras + // + unsigned int iNumPlayers = GetGameplayManager()->GetNumPlayers(); + + rl->SetNumViews( iNumPlayers ); + rl->SetUpViewCam(); + + p3d::inventory->SelectSection("Default"); + tLightGroup* sun = p3d::find<tLightGroup>("sun"); + rAssert( sun ); + rm->SetLevelLayerLights( sun ); + + float aspect = p3d::display->IsWidescreen() ? (16.0f / 9.0f) : (4.0f / 3.0f); + + if( iNumPlayers == 2 ) + { + aspect = 4.0f / 1.5f; + } + + for( unsigned int view = 0; view < iNumPlayers; view++ ) + { + + tPointCamera* cam = static_cast<tPointCamera*>( rl->pCam( view ) ); + rAssert( dynamic_cast<tPointCamera*> ( cam ) != NULL ); + rAssert( cam ); + + SuperCamCentral* scc = GetSuperCamManager()->GetSCC( view ); + rAssert( scc ); + scc->SetCamera( cam ); + + FollowCam* fc = new FollowCam( FollowCam::FOLLOW_NEAR ); + fc->SetAspect( aspect ); + fc->CopyToData(); + scc->RegisterSuperCam( fc ); + + fc = new FollowCam( FollowCam::FOLLOW_FAR ); + fc->SetAspect( aspect ); + fc->CopyToData(); + scc->RegisterSuperCam( fc ); + + SuperCam* sc = new BumperCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new ChaseCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new KullCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new DebugCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new TrackerCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new WalkerCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new ComedyCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new WrecklessCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new ConversationCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new ReverseCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new AnimatedCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + sc = new RelativeAnimatedCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); +// sc = new FirstPersonCam(); +// sc->SetAspect( aspect ); +// scc->RegisterSuperCam( sc ); +#ifdef RAD_WIN32 + sc = new PCCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); +#endif +#if !defined(FINAL) && defined(RAD_XBOX) + sc = new SnapshotCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); +#endif + } + + // Boot strap the AvatarManager. + // + GetAvatarManager( )->EnterGame( ); + GetActionButtonManager( )->EnterGame( ); + + TrafficManager::GetInstance()->Init(); + PedestrianManager::GetInstance()->Init(); + + // Prepare the manager to start gameplay + // + //GetGameplayManager()->Reset(); + +#ifdef RAD_DEMO + GetGameplayManager()->ResetIdleTime(); +#endif + + // Start up GUI in-game manager + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_INGAME ); + + // register GUI user input handler for active players only + // + int activeControllerIDs = 0; + for( int i = 0; i < MAX_PLAYERS; i++ ) + { + int controllerID = GetInputManager()->GetControllerIDforPlayer( i ); + if( controllerID != -1 ) + { + activeControllerIDs |= (1 << controllerID); + } + } + + GetGuiSystem()->RegisterUserInputHandlers( activeControllerIDs ); + + // Tell GameData Manager that game has been started + // + GetGameDataManager()->SetGameLoaded(); + + //Set up the sorting of the intersections and stuff. + RoadManager::GetInstance()->CreateRoadNetwork(); + + //Find skid mark shaders in the inventory and set proper values + SkidMarkGenerator::InitShaders(); + + GetSkidmarkManager()->Init(); + + // + // Notify the sound system of gameplay start. This has been moved after + // the GUI startup above, since that leads to a mission reset, which causes + // character position in or out of the car to be decided, which the sound + // system uses to determine which sounds to start playing. + // + SoundManager::GetInstance()->OnGameplayStart(); + + GetInteriorManager()->OnGameplayStart(); + + GetHitnRunManager()->ResetState(); + + //tick character manager once, to get state system and choreo started + GetCharacterManager()->PreSimUpdate( 0.0001f ); + GetCharacterManager()->PreSubstepUpdate( 0.0001f ); + GetCharacterManager()->Update( 0.0001f ); + GetCharacterManager()->PostSubstepUpdate( 0.0001f ); + GetCharacterManager()->PostSimUpdate( 0.0001f ); + + } + + GetPresentationManager()->OnGameplayStart(); + + HeapMgr()->ResetArtStats(); + GetEventManager()->TriggerEvent( EVENT_LEVEL_START ); + + if( previousContext != CONTEXT_PAUSE ) + { + AnimatedCam::CheckPendingCameraSwitch(); + } + + for( int view = 0; view < GetGameplayManager()->GetNumPlayers(); view++ ) + { + SuperCamCentral* scc = GetSuperCamManager()->GetSCC( view ); + scc->SetIsInitialCamera(true); + } + GetGameplayManager()->Update( 0 ); + GetTriggerVolumeTracker()->Update( 0 ); +} + +//============================================================================= +// GameplayContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void GameplayContext::OnStop( ContextEnum nextContext ) +{ + GetPresentationManager()->OnGameplayStop(); + + // turn off controller rumble, to comply w/ TCR/TRC standards + // + GetInputManager()->ToggleRumble( false ); + + + // Common to all playing contexts. + // + PlayingContext::OnStop( nextContext ); +} + +//============================================================================= +// GameplayContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void GameplayContext::OnUpdate( unsigned int elapsedTime ) +{ +#ifdef DEBUGWATCH + mDebugOnUpdateDT = radTimeGetMicroseconds(); +#endif + +#ifndef FINAL + if( CommandLineOptions::Get( CLO_PRINT_FRAMERATE ) ) + { + // + // Merasure the time taken to render frames 100-500 + // + const unsigned int startFrame = 200; + const unsigned int endFrame = 600; + static unsigned int count = 0; + ++count; + static unsigned int totalTime = 0; + totalTime += elapsedTime; + + if( count == startFrame ) + { + totalTime = 0; + } + if( count == endFrame ) + { + const unsigned int frames = endFrame - startFrame; + float msPerFrame = totalTime / static_cast< float >( frames ); + rReleasePrintf( "====================================\n" ); + rReleasePrintf( "%d frames rendered in %dms\n", frames, totalTime ); + rReleasePrintf( "%fms per frame\n", msPerFrame ); + rReleasePrintf( "====================================\n" ); + } + } + + static int frameCount = 60; + frameCount--; + if( frameCount == 0 ) + { + HeapMgr()->ResetArtStats(); + } +#endif + + // hack for yousuf + if( mSlowMoHack ) + { + //elapsedTime = 1; + elapsedTime = 2; + } + + if( !m_PausedAllButPresentation ) + { + float timeins = (float)(elapsedTime) / 1000.0f; + + BEGIN_PROFILE("GameplayManager"); + if ( m_state != S_SUSPENDED ) + { + GetGameplayManager()->Update( elapsedTime ); + } + END_PROFILE("GameplayManager"); + + + GetAvatarManager()->Update( timeins ); + + GetFootprintManager()->Update( elapsedTime ); + + GetCharacterManager()->GarbageCollect( ); + + BEGIN_PROFILE( "Update Particles" ); + + GetParticleManager()->Update( elapsedTime ); + GetBreakablesManager()->Update( elapsedTime ); + GetAnimEntityDSGManager()->Update( elapsedTime ); + + END_PROFILE( "Update Particles" ); + + #ifdef DEBUGWATCH + unsigned int t0 = radTimeGetMicroseconds(); + #endif + + BEGIN_PROFILE("WorldPhysics"); + GetWorldPhysicsManager()->Update(elapsedTime); + END_PROFILE("WorldPhysics"); + + // ordering is important. Unless other parts of code change, we must call + // this before WorldPhysManager::Update() because PedestrianManager + // sets the flags for all characters to be updated in WorldPhys Update + PedestrianManager::GetInstance()->Update( elapsedTime ); + + #ifdef DEBUGWATCH + mDebugTimeDelta = elapsedTime; + mDebugPhysTiming = radTimeGetMicroseconds()-t0 ; + #endif + + BEGIN_PROFILE("TriggerVolumeTracker"); + GetTriggerVolumeTracker()->Update( elapsedTime ); + END_PROFILE("TriggerVolumeTracker"); + + BEGIN_PROFILE("TrafficManager"); + TrafficManager::GetInstance()->Update( elapsedTime ); + END_PROFILE("TrafficManager"); + + BEGIN_PROFILE("ActorManager"); + ActorManager::GetInstance()->Update( elapsedTime ); + END_PROFILE("ActorManager"); + + BEGIN_PROFILE("InteriorManager"); + GetInteriorManager()->Update( elapsedTime ); + END_PROFILE("InteriorManager"); + + BEGIN_PROFILE("SkidmarkManager"); + GetSkidmarkManager()->Update( elapsedTime ); + END_PROFILE("SkidmarkManager"); + + BEGIN_PROFILE( "CoinManager" ); + GetCoinManager()->Update( elapsedTime ); + GetSparkleManager()->Update( elapsedTime ); + END_PROFILE( "CoinManager" ); + + BEGIN_PROFILE( "HitnRunManager" ); + GetHitnRunManager()->Update( elapsedTime ); + END_PROFILE( "HitnRunManager" ); + } + +#ifdef RAD_DEMO + GetGameplayManager()->UpdateIdleTime( elapsedTime ); +#endif + + BEGIN_PROFILE("PresentationManager"); + GetPresentationManager()->Update( elapsedTime ); + END_PROFILE("PresentationManager"); + + // Common to all playing contexts. + // + PlayingContext::OnUpdate( elapsedTime ); +#ifdef DEBUGWATCH + mDebugOnUpdateDT = radTimeGetMicroseconds()-mDebugOnUpdateDT; +#endif +} + +//============================================================================= +// GameplayContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void GameplayContext::OnSuspend() +{ + // Common to all playing contexts. + // + PlayingContext::OnSuspend(); +} + +//============================================================================= +// GameplayContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void GameplayContext::OnResume() +{ + // Common to all playing contexts. + // + PlayingContext::OnResume(); +} + +//============================================================================= +// GameplayContext::PauseAllButPresentation +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void GameplayContext::PauseAllButPresentation( const bool pause ) +{ + m_PausedAllButPresentation = pause; +} + diff --git a/game/code/contexts/gameplay/gameplaycontext.h b/game/code/contexts/gameplay/gameplaycontext.h new file mode 100644 index 0000000..01d788c --- /dev/null +++ b/game/code/contexts/gameplay/gameplaycontext.h @@ -0,0 +1,77 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: Gameplaycontext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef GAMEPLAYCONTEXT_H +#define GAMEPLAYCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/playingcontext.h> // is-a PlayingContext + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class GameplayContext : public PlayingContext +{ + public: + + // Static Methods for accessing this singleton. + static GameplayContext* GetInstance(); + void PauseAllButPresentation( const bool pause ); + bool IsPaused() { return m_PausedAllButPresentation; } + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + private: + + // constructor and destructor are protected to force singleton implementation + GameplayContext(); + virtual ~GameplayContext(); + + // Declared but not defined to prevent copying and assignment. + GameplayContext( const GameplayContext& ); + GameplayContext& operator=( const GameplayContext& ); + + // Pointer to the one and only instance of this singleton. + static GameplayContext* spInstance; + +#ifdef DEBUGWATCH + unsigned int mDebugPhysTiming, mDebugTimeDelta, mDebugOnUpdateDT; +#endif + bool m_PausedAllButPresentation; + + bool mSlowMoHack; + +}; + +// A little syntactic sugar for getting at this singleton. +inline GameplayContext* GetGameplayContext() { return( GameplayContext::GetInstance() ); } + + +#endif // GAMEPLAYCONTEXT_H diff --git a/game/code/contexts/gameplay/loadinggameplaycontext.cpp b/game/code/contexts/gameplay/loadinggameplaycontext.cpp new file mode 100644 index 0000000..1bb15c2 --- /dev/null +++ b/game/code/contexts/gameplay/loadinggameplaycontext.cpp @@ -0,0 +1,250 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement LoadingGameplayContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +// Foundation Tech +#include <raddebug.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/gameplay/loadinggameplaycontext.h> + +#include <interiors/interiormanager.h> +#include <loading/loadingmanager.h> +#include <memory/leakdetection.h> +#include <mission/gameplaymanager.h> +#include <presentation/gui/guisystem.h> +#include <worldsim/parkedcars/parkedcarmanager.h> +#include <worldsim/traffic/trafficmanager.h> +#include <sound/soundmanager.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// Static pointer to instance of singleton. +LoadingGameplayContext* LoadingGameplayContext::spInstance = NULL; + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// LoadingGameplayContext::GetInstance +//============================================================================== +// +// Description: - Access point for the LoadingGameplayContext singleton. +// - Creates the LoadingGameplayContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the LoadingGameplayContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +LoadingGameplayContext* LoadingGameplayContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new(GMA_PERSISTENT) LoadingGameplayContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================== +// LoadingGameplayContext::LoadingGameplayContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingGameplayContext::LoadingGameplayContext() +{ +} + +//============================================================================== +// LoadingGameplayContext::~LoadingGameplayContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingGameplayContext::~LoadingGameplayContext() +{ +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// LoadingGameplayContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void LoadingGameplayContext::OnStart( ContextEnum previousContext ) +{ + GetGameplayManager()->mIsDemo = false; + + // Common to all loading contexts. + // + LoadingContext::OnStart( previousContext ); + +/***************************************************************************** + * Start inserting stuff below ... + *****************************************************************************/ + + // NOTE: + // Assumes we never start a level in the car + GetVehicleCentral()->ActivateVehicleTriggers( true ); + + GetPCM(); //Start the parked car manager + + TrafficManager::GetInstance()->InitDefaultModelGroups(); + + // initialize GUI in-game mode (and load resources) + // + GetGuiSystem()->HandleMessage( GUI_MSG_INIT_INGAME ); + + GetLoadingManager()->AddCallback( this ); +} + +//============================================================================= +// LoadingGameplayContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void LoadingGameplayContext::OnStop( ContextEnum nextContext ) +{ + // Common to all loading contexts. + // + LoadingContext::OnStop( nextContext ); +} + +//============================================================================= +// LoadingGameplayContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void LoadingGameplayContext::OnUpdate( unsigned int elapsedTime ) +{ + GetGameplayManager()->Update( elapsedTime ); + + // Common to all loading contexts. + // + LoadingContext::OnUpdate( elapsedTime ); +} + +//============================================================================= +// LoadingGameplayContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingGameplayContext::OnSuspend() +{ + // Common to all loading contexts. + // + LoadingContext::OnSuspend(); +} + +//============================================================================= +// LoadingGameplayContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingGameplayContext::OnResume() +{ + // Common to all loading contexts. + // + LoadingContext::OnResume(); +} + +//============================================================================= +// LoadingGameplayContext::PrepareNewHeaps +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingGameplayContext::PrepareNewHeaps() +{ + HeapMgr()->PrepareHeapsInGame(); +} + +//============================================================================= +// LoadingGameplayContext::OnProcessRequestsComplete +//============================================================================= +// Description: Comment +// +// Parameters: ( void* pUserData ) +// +// Return: void +// +//============================================================================= +void LoadingGameplayContext::OnProcessRequestsComplete( void* pUserData ) +{ + GetGameplayManager()->LevelLoaded(); + + // + // Queue the loading for level sounds + // + GetSoundManager()->QueueLevelSoundLoads(); + + // Common to all loading contexts. + // + LoadingContext::OnProcessRequestsComplete( pUserData ); +} diff --git a/game/code/contexts/gameplay/loadinggameplaycontext.h b/game/code/contexts/gameplay/loadinggameplaycontext.h new file mode 100644 index 0000000..6e6d5d9 --- /dev/null +++ b/game/code/contexts/gameplay/loadinggameplaycontext.h @@ -0,0 +1,72 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: LoadingGameplayContext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef LOADINGGAMEPLAYCONTEXT_H +#define LOADINGGAMEPLAYCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/loadingcontext.h> // is-a LoadingContext + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class LoadingGameplayContext : public LoadingContext +{ + public: + // Static Methods for accessing this singleton. + static LoadingGameplayContext* GetInstance(); + + virtual void OnProcessRequestsComplete( void* pUserData ); + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void PrepareNewHeaps(); + + private: + + // constructor and destructor are protected to force singleton implementation + LoadingGameplayContext(); + virtual ~LoadingGameplayContext(); + + // Declared but not defined to prevent copying and assignment. + LoadingGameplayContext( const LoadingGameplayContext& ); + LoadingGameplayContext& operator=( const LoadingGameplayContext& ); + + // Pointer to the one and only instance of this singleton. + static LoadingGameplayContext* spInstance; + + bool mUnQueuedLoadRequests; +}; + +// A little syntactic sugar for getting at this singleton. +inline LoadingGameplayContext* GetLoadingGameplayContext() { return( LoadingGameplayContext::GetInstance() ); } + + +#endif // LOADINGGAMEPLAYCONTEXT_H diff --git a/game/code/contexts/loadingcontext.cpp b/game/code/contexts/loadingcontext.cpp new file mode 100644 index 0000000..fddf2ef --- /dev/null +++ b/game/code/contexts/loadingcontext.cpp @@ -0,0 +1,270 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement LoadingContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <p3d/shadow.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/loadingcontext.h> +#include <camera/animatedcam.h> +#include <camera/supercammanager.h> +#include <camera/supercamcentral.h> +#include <input/inputmanager.h> +#include <memory/srrmemory.h> +#include <mission/gameplaymanager.h> +#include <presentation/presentation.h> +#include <presentation/gui/guisystem.h> +#include <render/rendermanager/rendermanager.h> +#include <worldsim/coins/coinmanager.h> +#include <worldsim/coins/sparkle.h> +#include <worldsim/hitnrunmanager.h> +#include <worldsim/character/charactermanager.h> +#include <worldsim/vehiclecentral.h> + +#include <mission/animatedicon.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** +#ifndef FINAL +static unsigned int g_Timer; +#endif + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// LoadingContext::LoadingContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingContext::LoadingContext() +{ +} + +//============================================================================== +// LoadingContext::~LoadingContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingContext::~LoadingContext() +{ +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// LoadingContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void LoadingContext::OnStart( ContextEnum previousContext ) +{ + SetMemoryIdentification( "LoadingContext" ); +#ifndef FINAL + if( CommandLineOptions::Get( CLO_PRINT_LOAD_TIME ) ) + { + g_Timer = radTimeGetMicroseconds(); + } +#endif + + MEMTRACK_PUSH_FLAG( "Loading Context" ); + + this->PrepareNewHeaps(); + + HeapMgr()->PushHeap( GMA_LEVEL_OTHER ); + + // Note: *** Do NOT add any calls before the following GUI system call + // that will cause an AddRequest to the loading manager. + // The GUI system should have first dibs at queueing whatever it + // wants loaded for the loading screen. + // + + AnimatedIcon::InitAnimatedIcons( HeapMgr()->GetCurrentHeap() ); + + // no controller input while loading + // + GetInputManager()->SetGameState( Input::ACTIVE_NONE ); + + // tell GUI system to run backend during loading + // + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_BACKEND ); + + + GetCoinManager()->Init(); + GetSparkleManager()->Init(); + + GetHitnRunManager()->Init(); + + // This is here since it needs to be in all modes. + // + const bool shutdown = false; + GetSuperCamManager()->Init( shutdown ); + + GetVehicleCentral()->PreLoad(); + + GetRenderManager()->LoadAllNeededData(); + + PedestrianManager::GetInstance()->InitDefaultModelGroups(); + + GetPresentationManager()->Initialize(); + + GetGameplayManager()->Initialize(); + GetGameplayManager()->LoadLevelData(); +} + +//============================================================================= +// LoadingContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void LoadingContext::OnStop( ContextEnum nextContext ) +{ +#ifdef RAD_WIN32 + if( nextContext == CONTEXT_EXIT ) + { + GetLoadingManager()->CancelPendingRequests(); + p3d::loadManager->CancelAll(); + } +#endif + + RoadManager::GetInstance()->DumpRoadSegmentDataMemory(); + + // tell GUI system to quit backend + // + GetGuiSystem()->HandleMessage( GUI_MSG_QUIT_BACKEND ); + + GetInputManager()->SetGameState( Input::ACTIVE_ALL ); + + HeapMgr()->PopHeap( GMA_LEVEL_OTHER ); +#ifndef FINAL + if( CommandLineOptions::Get( CLO_PRINT_LOAD_TIME ) ) + { + unsigned int stopTime = radTimeGetMicroseconds(); + unsigned int time = stopTime - g_Timer; + float timeInSeconds = time / 1000000.0f; + rReleasePrintf( "Loading Time (s) = %f\n", timeInSeconds ); + } +#endif + AnimatedCam::TriggerMissionStartCamera(); + MEMTRACK_POP_FLAG( "" ); + SetMemoryIdentification( "LoadingContext Finished" ); + + GetInputManager()->EnableReset( true ); +} + +//============================================================================= +// LoadingContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void LoadingContext::OnUpdate( unsigned int elapsedTime ) +{ + // update GUI system + // + GetGuiSystem()->Update( elapsedTime ); +} + +//============================================================================= +// LoadingContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingContext::OnSuspend() +{ +} + +//============================================================================= +// LoadingContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingContext::OnResume() +{ +} + +//============================================================================= +// LoadingContext::OnHandleEvent +//============================================================================= +// Description: Comment +// +// Parameters: ( EventEnum id, void* pEventData ) +// +// Return: void +// +//============================================================================= +void LoadingContext::OnHandleEvent( EventEnum id, void* pEventData ) +{ +} + +//============================================================================= +// LoadingContext::OnProcessRequestsComplete +//============================================================================= +// Description: Comment +// +// Parameters: ( void* pUserData ) +// +// Return: void +// +//============================================================================= +void LoadingContext::OnProcessRequestsComplete( void* pUserData ) +{ + GetRenderManager()->DoPostLevelLoad(); +} + diff --git a/game/code/contexts/loadingcontext.h b/game/code/contexts/loadingcontext.h new file mode 100644 index 0000000..9c963e9 --- /dev/null +++ b/game/code/contexts/loadingcontext.h @@ -0,0 +1,66 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: Loadingcontext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef LOADINGCONTEXT_H +#define LOADINGCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> // is-a Context +#include <loading/loadingmanager.h> // also is-a ProcessRequests thingy + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class LoadingContext : public Context, + public LoadingManager::ProcessRequestsCallback +{ + public: + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + + // + // LoadingManager::ProcessRequestsCallback + // + virtual void OnProcessRequestsComplete( void* pUserData ); + + protected: + // constructor and destructor are protected to force singleton implementation + LoadingContext(); + virtual ~LoadingContext(); + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void PrepareNewHeaps() = 0; + + private: + // Declared but not defined to prevent copying and assignment. + LoadingContext( const LoadingContext& ); + LoadingContext& operator=( const LoadingContext& ); + +}; + +#endif // LOADINGCONTEXT_H diff --git a/game/code/contexts/pausecontext.cpp b/game/code/contexts/pausecontext.cpp new file mode 100644 index 0000000..b001c5f --- /dev/null +++ b/game/code/contexts/pausecontext.cpp @@ -0,0 +1,575 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement PauseContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <p3d/view.hpp> +#include <p3d/shadow.hpp> + +// Foundation Tech +#include <raddebug.hpp> +#include <radtime.hpp> +#include <raddebugwatch.hpp> + +//======================================== +// Project Includes +//======================================== +#include <ai/vehicle/vehicleairender.h> + +#include <contexts/pausecontext.h> +#include <contexts/contextenum.h> +#include <memory/leakdetection.h> +#include <memory/srrmemory.h> +#include <worldsim/worldobject.h> + +#include <camera/supercammanager.h> +#include <camera/animatedcam.h> +#include <interiors/interiormanager.h> +#include <meta/triggervolumetracker.h> +#include <mission/gameplaymanager.h> +#include <presentation/gui/guisystem.h> +#include <presentation/gui/ingame/guimanageringame.h> +#include <presentation/gui/ingame/guiscreenhud.h> +#include <presentation/gui/utility/hudmap.h> +#include <render/RenderManager/RenderManager.h> +#include <render/RenderManager/RenderLayer.h> +#include <render/DSG/StatePropDSG.h> +#include <sound/soundmanager.h> +#include <worldsim/worldphysicsmanager.h> +#include <worldsim/character/charactermanager.h> +#include <worldsim/character/footprint/footprintmanager.h> +#include <worldsim/avatarmanager.h> +#include <worldsim/traffic/trafficmanager.h> +#include <worldsim/ped/pedestrianmanager.h> +#include <worldsim/coins/coinmanager.h> +#include <worldsim/coins/sparkle.h> +#include <worldsim/hitnrunmanager.h> +#include <worldsim/parkedcars/parkedcarmanager.h> +#include <ai/actionbuttonmanager.h> +#include <render/breakables/breakablesmanager.h> +#include <render/particles/ParticleManager.h> +#include <worldsim/skidmarks/skidmarkgenerator.h> +#include <worldsim/skidmarks/skidmarkmanager.h> +#include <ai/actor/actormanager.h> +#include <gameflow/gameflow.h> +#include <roads/roadmanager.h> +#include <render/Loaders/AnimDynaPhysLoader.h> +#include <pedpaths/pathmanager.h> + +#include <input/inputmanager.h> + +#include <data/gamedatamanager.h> + +#include <mission/animatedicon.h> + +#include <render/animentitydsgmanager/animentitydsgmanager.h> +#include <presentation/presentation.h> +#include <presentation/tutorialmanager.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// Static pointer to instance of singleton. +PauseContext* PauseContext::spInstance = NULL; + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// PauseContext::GetInstance +//============================================================================== +// +// Description: - Access point for the PauseContext singleton. +// - Creates the PauseContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the PauseContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +PauseContext* PauseContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new(GMA_PERSISTENT) PauseContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================== +// PauseContext::PauseContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +PauseContext::PauseContext() +: mOldState( Input::ACTIVE_NONE ), + m_quitGamePending( false ), + m_waitingForContextSwitch( false ) +{ +} + +//============================================================================== +// PauseContext::~PauseContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +PauseContext::~PauseContext() +{ +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// PauseContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void PauseContext::OnStart( ContextEnum previousContext ) +{ + SetMemoryIdentification( "PauseContext" ); + MEMTRACK_PUSH_FLAG( "Pause" ); + + mOldState = GetInputManager()->GetGameState(); + if( mOldState == Input::ACTIVE_ANIM_CAM ) + { + // deactivate anim cam state first, since the input manager + // won't let us set the game state to anything else prior + // to that + // + GetInputManager()->SetGameState( Input::DEACTIVE_ANIM_CAM ); + SuperCam* sc = GetSuperCamManager()->GetSCC( 0 )->GetActiveSuperCam(); + AnimatedCam* ac = dynamic_cast<AnimatedCam*>(sc); + if(ac) + { + ac->Abort(); + } + } + GetInputManager()->SetGameState( Input::ACTIVE_FRONTEND ); + + GetCoinManager()->ClearHUDCoins(); + + m_quitGamePending = false; +} + + +extern void OutputHandler (const char * pString ); + + +//============================================================================= +// PauseContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void PauseContext::OnStop( ContextEnum nextContext ) +{ + // do gameplay terminations only if next context is frontend context or exit. + if( nextContext == CONTEXT_FRONTEND || + nextContext == CONTEXT_LOADING_GAMEPLAY || + nextContext == CONTEXT_EXIT ) + { + rReleasePrintf("PauseContext::OnStop Begins\n"); + + GetInputManager()->EnableReset( false ); + + RenderLayer* l = GetRenderManager()->mpLayer( RenderEnums::GUI ); + rAssert( l ); + l->Thaw(); +// GetGameFlow()->SetQuickStartLoading( false ); + // STL reallocs, etc may result in actually allocating some memory during this process. + // As such, reroute everything to temp. + // + HeapMgr()->PushHeap (GMA_TEMP); + + // + // This is called to prevent DMA of destroyed textures, + // because we don't swap buffers until the next frame. + // + p3d::pddi->DrawSync(); + + //::radThreadSleep (500); + + //::rDebugSetOutputHandler (OutputHandler); + + //rReleaseString ("DrawSync\n"); + + // Clear the shadow list + AnimDynaPhysLoader::ClearShadowList(); + + GetCoinManager()->Destroy(); + GetSparkleManager()->Destroy(); + GetHitnRunManager()->Destroy(); + + StatePropDSG::RemoveAllSharedtPoses(); + + + GetInteriorManager()->OnGameplayEnd(); + + //rReleaseString ("GetInteriorManager()->OnGameplayEnd()\n"); + + const bool shutdown = true; + GetSuperCamManager()->Init( shutdown ); + + //rReleaseString ("GetSuperCamManager()->Init( shutdown )\n"); + + TriggerVolumeTracker::GetInstance()->Cleanup(); + + //rReleaseString ("TriggerVolumeTracker::GetInstance()->Cleanup()\n"); + + // Clean up lights! + // + RenderLayer* rl = GetRenderManager()->mpLayer( RenderEnums::LevelSlot ); + rAssert( rl ); + for( unsigned int i = 0; i < rl->GetNumViews(); i++ ) + { + rl->pView(i)->RemoveAllLights (); + } + + //rReleaseString ("Remove all lights from all views\n"); + + //rReleaseString ("GetAvatarManager()->Destroy()\n"); + GetActorManager()->RemoveAllActors(); + GetActorManager()->RemoveAllSpawnPoints(); + + GetPresentationManager()->Finalize(); + + GetGameplayManager()->Finalize(); + //rReleaseString ("GetGameplayManager()->Finalize()\n"); + + // needs to be finalized after gameplay manager (Mission shudown needs avatars) + GetAvatarManager()->Destroy(); + + ParkedCarManager::DestroyInstance(); + //rReleaseString ("ParkedCarManager::DestroyInstance()\n"); + + TrafficManager::DestroyInstance(); + //rReleaseString ("TrafficManager::DestroyInstance()\n"); + + PedestrianManager::DestroyInstance(); + //rReleaseString ("PedestrianManager::DestroyInstance()\n"); + + GetCharacterManager()->Destroy(); + //rReleaseString ("GetCharacterManager()->Destroy()\n"); + + GetVehicleCentral()->Unload(); + + GetActionButtonManager( )->Destroy( ); + //rReleaseString ("GetActionButtonManager( )->Destroy( )\n"); + + + GetBreakablesManager()->FreeAllBreakables(); + //rReleaseString ("GetBreakablesManager()->FreeAllBreakables()\n"); + + GetParticleManager()->ClearSystems(); + //rReleaseString ("GetParticleManager()->ClearSystems()\n"); + + + GetWorldPhysicsManager()->OnQuitLevel(); // just some cleanup checks... + + + + SkidMarkGenerator::ReleaseShaders(); + //rReleaseString ("SkidMarkGenerator::ReleaseShaders()\n"); + GetSkidmarkManager()->Destroy(); + GetFootprintManager()->FreeTextures(); + + GetRenderManager()->ClearLevelLayerLights(); + rReleasePrintf("PauseContext::OnStop DumpAllLoadedData\n"); + GetRenderManager()->DumpAllLoadedData(); + //rReleaseString ("GetRenderManager()->DumpAllLoadedData()\n"); + + + + +#ifdef DEBUGWATCH + VehicleAIRender::Destroy(); + //rReleaseString ("VehicleAIRender::Destroy()\n"); + +#endif + GetSoundManager()->OnGameplayEnd( nextContext == CONTEXT_FRONTEND ); + //rReleaseString ("GetSoundManager()->OnGameplayEnd ()\n"); + + + PathManager::GetInstance()->Destroy(); + //rReleaseString ("PathManager::GetInstance()->Destroy()\n"); + + + + // TODO - Darryl? + // + // all active vehicles should be destroyed + // they are owned by the missions that created them. + + //This does cleanup. + RoadManager::GetInstance()->Destroy(); + //rReleaseString ("RoadManager::GetInstance()->Destroy()\n"); + + + + if( nextContext == CONTEXT_LOADING_GAMEPLAY ) + { + // if reloading in-game, set new level and mission to load + // + int level = GetGuiSystem()->GetInGameManager()->GetNextLevelToLoad(); + GetGameplayManager()->SetLevelIndex( static_cast<RenderEnums::LevelEnum>( level ) ); + + int mission = GetGuiSystem()->GetInGameManager()->GetNextMissionToLoad(); + GetGameplayManager()->SetMissionIndex( static_cast<RenderEnums::MissionEnum>( mission ) ); + //rReleaseString ("Set level and mission indices\n"); + + } + else + { + SetGameplayManager( NULL ); + } + + // Cleanup the Avatar Manager + // + GetAvatarManager()->ExitGame(); + //rReleaseString ("GetAvatarManager()->ExitGame()\n"); + + + // Flush out the special section used by physics to cache SkeletonInfos. + // + p3d::inventory->RemoveSectionElements (SKELCACHE); + p3d::inventory->DeleteSection (SKELCACHE); + rReleaseString ("Delete SKELCACHE inventory section\n"); + + + // release GUI in-game + GetGuiSystem()->HandleMessage( GUI_MSG_RELEASE_INGAME ); + rReleaseString ("GetGuiSystem()->HandleMessage( GUI_MSG_RELEASE_INGAME )\n"); + + CHudMap::ClearAllRegisteredIcons(); + + // unregister GUI user input handler for active players + // + int activeControllerIDs = 0; + for( int i = 0; i < MAX_PLAYERS; i++ ) + { + int controllerID = GetInputManager()->GetControllerIDforPlayer( i ); + if( controllerID != -1 ) + { + activeControllerIDs |= (1 << controllerID); + } + } + rReleaseString ("Change active controllers\n"); + + + GetGuiSystem()->UnregisterUserInputHandlers( activeControllerIDs ); + rReleaseString ("Change active controllers\n"); + + + // enable screen clearing + GetRenderManager()->mpLayer(RenderEnums::GUI)->pView( 0 )->SetClearMask( PDDI_BUFFER_ALL ); + rReleaseString ("Enable screen clearing\n"); + +#ifndef RAD_RELEASE + // Dump out the contents of the inventory sections + // + p3d::inventory->Dump (true); + rReleaseString ("Dump inventory\n"); + +#endif + AnimatedIcon::ShutdownAnimatedIcons(); + + GetAnimEntityDSGManager()->RemoveAll(); + + GetTutorialManager()->EnableTutorialMode( false ); + + HeapMgr()->PopHeap (GMA_TEMP); + } + + if ( nextContext == CONTEXT_GAMEPLAY ) + { + if( mOldState == Input::ACTIVE_ANIM_CAM ) + { + GetInputManager()->SetGameState( Input::ACTIVE_GAMEPLAY ); + } + else + { + GetInputManager()->SetGameState( mOldState ); + } + + int controllerID = GetInputManager()->GetControllerIDforPlayer( 0 ); + bool vibrationOn = GetInputManager()->IsRumbleEnabled(); + + if ( GetGameplayManager()->GetGameType() == GameplayManager::GT_NORMAL && + GetAvatarManager()->GetAvatarForPlayer( 0 )->GetVehicle() ) + { +#ifdef RAD_PS2 + bool hasWheel = false; + + if ( controllerID != Input::USB0 && + controllerID != Input::USB1 ) + { + if ( GetInputManager()->GetController( Input::USB0 )->IsConnected() ) + { + GetInputManager()->SetRumbleForDevice( Input::USB0, vibrationOn ); + hasWheel = true; + } + else if ( GetInputManager()->GetController( Input::USB1 )->IsConnected() ) + { + GetInputManager()->SetRumbleForDevice( Input::USB1, vibrationOn ); + hasWheel = true; + } + } + //I hate this. + if ( !hasWheel ) +#endif + GetInputManager()->SetRumbleForDevice( controllerID, vibrationOn ); + } + + } + else + { + GetInputManager()->SetGameState( Input::ACTIVE_ALL ); + } + SetMemoryIdentification( "PauseContext Finished" ); + MEMTRACK_POP_FLAG( "" ); +} + +//============================================================================= +// PauseContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void PauseContext::OnUpdate( unsigned int elapsedTime ) +{ + // update game data manager + GetGameDataManager()->Update( elapsedTime ); + + // update GUI system + GetGuiSystem()->Update( elapsedTime ); + + // update coin manager + GetCoinManager()->Update( elapsedTime ); + GetSparkleManager()->Update( elapsedTime ); + + //update hitnrun???? + //GetHitnRunManager()->Update(elapsedTime); + +#ifdef RAD_DEMO + GetGameplayManager()->UpdateIdleTime( elapsedTime ); +#endif + + // Check to see if we're loading so we don't screw up when we quit the level. + // + if( GetGameplayManager()->GetLevelComplete() && !GetLoadingManager()->IsLoading() ) + { + if( !m_quitGamePending ) + { + m_quitGamePending = true; + +#ifdef RAD_DEMO + GetGuiSystem()->HandleMessage( GUI_MSG_QUIT_INGAME ); +#else + if( GetGameplayManager()->GetGameComplete() ) + { + GetGuiSystem()->GotoScreen( CGuiWindow::GUI_SCREEN_ID_VIEW_CREDITS, + 0, 0, CLEAR_WINDOW_HISTORY ); + } + else + { + GetGuiSystem()->GotoScreen( CGuiWindow::GUI_SCREEN_ID_LEVEL_END, + 0, 0, CLEAR_WINDOW_HISTORY ); + } +#endif // RAD_DEMO + } + } + else + { + // update mission loading + // + GetGameplayManager()->PerformLoading(); + } +} + +//============================================================================= +// PauseContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void PauseContext::OnSuspend() +{ +} + +//============================================================================= +// PauseContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void PauseContext::OnResume() +{ +} + +//============================================================================= +// PauseContext::OnHandleEvent +//============================================================================= +// Description: Comment +// +// Parameters: ( EventEnum id, void* pEventData ) +// +// Return: void +// +//============================================================================= +void PauseContext::OnHandleEvent( EventEnum id, void* pEventData ) +{ +} diff --git a/game/code/contexts/pausecontext.h b/game/code/contexts/pausecontext.h new file mode 100644 index 0000000..780c07e --- /dev/null +++ b/game/code/contexts/pausecontext.h @@ -0,0 +1,77 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: PauseContext.h +// +// Description: +// +// History: + Created -- Tony Chu +// +//============================================================================= + +#ifndef PAUSECONTEXT_H +#define PAUSECONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> // is-a Context +#include <input/controller.h> + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class PauseContext : public Context +{ + public: + + // Static Methods for accessing this singleton. + static PauseContext* GetInstance(); + + bool IsWaitingForContextSwitch() { return m_waitingForContextSwitch; } + void SetWaitingForContextSwitch( bool tf ) { m_waitingForContextSwitch = tf; } + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + + private: + + // constructor and destructor are protected to force singleton implementation + PauseContext(); + virtual ~PauseContext(); + + // Declared but not defined to prevent copying and assignment. + PauseContext( const PauseContext& ); + PauseContext& operator=( const PauseContext& ); + + // Pointer to the one and only instance of this singleton. + static PauseContext* spInstance; + + Input::ActiveState mOldState; + bool m_quitGamePending : 1; + bool m_waitingForContextSwitch; +}; + +// A little syntactic sugar for getting at this singleton. +inline PauseContext* GetPauseContext() { return( PauseContext::GetInstance() ); } + + +#endif // PAUSECONTEXT_H diff --git a/game/code/contexts/playingcontext.cpp b/game/code/contexts/playingcontext.cpp new file mode 100644 index 0000000..5b58cc2 --- /dev/null +++ b/game/code/contexts/playingcontext.cpp @@ -0,0 +1,190 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement PlayingContext +// +// History: 21/05/2002 + Created -- NAME +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <p3d/view.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/playingcontext.h> + +#include <debug/profiler.h> +#include <input/inputmanager.h> +#include <interiors/interiormanager.h> +#include <memory/srrmemory.h> +#include <presentation/gui/guisystem.h> +#include <render/rendermanager/rendermanager.h> +#include <render/rendermanager/renderlayer.h> + +#include <mission/animatedicon.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// PlayingContext::PlayingContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +PlayingContext::PlayingContext() : + mQuitting( false ) +{ +} + +//============================================================================== +// PlayingContext::~PlayingContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +PlayingContext::~PlayingContext() +{ +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// PlayingContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void PlayingContext::OnStart( ContextEnum previousContext ) +{ + SetMemoryIdentification( "PlayingContext" ); + HeapMgr()->PushHeap( GMA_LEVEL_OTHER ); + GetInputManager()->SetGameState( Input::ACTIVE_GAMEPLAY ); + GetRenderManager()->mpLayer( RenderEnums::LevelSlot )->Thaw(); + + // disable screen clearing for GUI render layer + // + GetRenderManager()->mpLayer( RenderEnums::GUI )->pView( 0 )->SetClearMask( PDDI_BUFFER_DEPTH | PDDI_BUFFER_STENCIL ); + +#ifdef RAD_WIN32 + GetInputManager()->GetFEMouse()->SetInGameMode( true ); +#endif +} + +//============================================================================= +// PlayingContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void PlayingContext::OnStop( ContextEnum nextContext ) +{ + mQuitting = false; // I've quit after all. + +#ifdef RAD_WIN32 + GetInputManager()->GetFEMouse()->SetInGameMode( false ); +#endif + + GetInputManager()->SetGameState( Input::ACTIVE_ALL ); + + // Make sure no blur effects get carried over + GetRenderManager()->SetBlurAlpha( 0 ); + + HeapMgr()->PopHeap( GMA_LEVEL_OTHER ); + SetMemoryIdentification( "PlayingContext Finished" ); +} + +//============================================================================= +// PlayingContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void PlayingContext::OnUpdate( unsigned int elapsedTime ) +{ +BEGIN_PROFILE( "GuiSystem" ); + GetGuiSystem()->Update( elapsedTime ); +END_PROFILE( "GuiSystem" ); +} + +//============================================================================= +// PlayingContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void PlayingContext::OnSuspend() +{ +} + +//============================================================================= +// PlayingContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void PlayingContext::OnResume() +{ +} + +//============================================================================= +// PlayingContext::OnHandleEvent +//============================================================================= +// Description: Comment +// +// Parameters: ( EventEnum id, void* pEventData ) +// +// Return: void +// +//============================================================================= +void PlayingContext::OnHandleEvent( EventEnum id, void* pEventData ) +{ +} + diff --git a/game/code/contexts/playingcontext.h b/game/code/contexts/playingcontext.h new file mode 100644 index 0000000..302e9d7 --- /dev/null +++ b/game/code/contexts/playingcontext.h @@ -0,0 +1,59 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: PlayingContext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef PLAYINGCONTEXT_H +#define PLAYINGCONTEXT_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/context.h> // is-a Context + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class PlayingContext : public Context +{ + public: + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + + protected: + // constructor and destructor are protected to force singleton implementation + PlayingContext(); + virtual ~PlayingContext(); + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + bool mQuitting; + + private: + // Declared but not defined to prevent copying and assignment. + PlayingContext( const PlayingContext& ); + PlayingContext& operator=( const PlayingContext& ); + +}; + +#endif // PLAYINGCONTEXT_H diff --git a/game/code/contexts/supersprint/allsupersprintctx.cpp b/game/code/contexts/supersprint/allsupersprintctx.cpp new file mode 100644 index 0000000..eedae85 --- /dev/null +++ b/game/code/contexts/supersprint/allsupersprintctx.cpp @@ -0,0 +1,3 @@ +#include <contexts/supersprint/loadingsupersprintcontext.cpp> +#include <contexts/supersprint/supersprintcontext.cpp> +#include <contexts/supersprint/supersprintfecontext.cpp> diff --git a/game/code/contexts/supersprint/loadingsupersprintcontext.cpp b/game/code/contexts/supersprint/loadingsupersprintcontext.cpp new file mode 100644 index 0000000..e802da9 --- /dev/null +++ b/game/code/contexts/supersprint/loadingsupersprintcontext.cpp @@ -0,0 +1,240 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: +// +// Description: Implement LoadingSuperSprintContext +// +// History: 21/05/2002 + Created -- Cary Brisebois +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +// Foundation Tech +#include <raddebug.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/supersprint/loadingsupersprintcontext.h> + +#include <gameflow/gameflow.h> +#include <loading/loadingmanager.h> +#include <mission/charactersheet/charactersheetmanager.h> +#include <mission/gameplaymanager.h> +#include <render/rendermanager/rendermanager.h> +#include <supersprint/supersprintmanager.h> +#include <sound/soundmanager.h> + +//****************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//****************************************************************************** + +// Static pointer to instance of singleton. +LoadingSuperSprintContext* LoadingSuperSprintContext::spInstance = NULL; + +//****************************************************************************** +// +// Public Member Functions +// +//****************************************************************************** + +//============================================================================== +// LoadingSuperSprintContext::GetInstance +//============================================================================== +// +// Description: - Access point for the LoadingSuperSprintContext singleton. +// - Creates the LoadingSuperSprintContext if needed. +// +// Parameters: None. +// +// Return: Pointer to the LoadingSuperSprintContext. +// +// Constraints: This is a singleton so only one instance is allowed. +// +//============================================================================== +LoadingSuperSprintContext* LoadingSuperSprintContext::GetInstance() +{ + if( spInstance == NULL ) + { + spInstance = new(GMA_PERSISTENT) LoadingSuperSprintContext; + rAssert( spInstance ); + } + + return spInstance; +} + +//============================================================================== +// LoadingSuperSprintContext::LoadingSuperSprintContext +//============================================================================== +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingSuperSprintContext::LoadingSuperSprintContext() +{ +} + +//============================================================================== +// LoadingSuperSprintContext::~LoadingSuperSprintContext +//============================================================================== +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================== +LoadingSuperSprintContext::~LoadingSuperSprintContext() +{ +} + +//****************************************************************************** +// +// Private Member Functions +// +//****************************************************************************** + +//============================================================================= +// LoadingSuperSprintContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void LoadingSuperSprintContext::OnStart( ContextEnum previousContext ) +{ + GetGameplayManager()->mIsDemo = false; + + // + // Queue the loading for level sounds + // + GetSoundManager()->QueueLevelSoundLoads(); + + // Common to all loading contexts. + // + LoadingContext::OnStart( previousContext ); + +/***************************************************************************** + * Start inserting stuff below ... + *****************************************************************************/ + + GetSSM()->LoadCars(); + + // This is an extra callback to let this system know when all the loading is done for the + // context.. Kinda sneaky.. + // + GetLoadingManager()->AddCallback( this ); +} + +//============================================================================= +// LoadingSuperSprintContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void LoadingSuperSprintContext::OnStop( ContextEnum nextContext ) +{ + // Common to all loading contexts. + // + LoadingContext::OnStop( nextContext ); +} + +//============================================================================= +// LoadingSuperSprintContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void LoadingSuperSprintContext::OnUpdate( unsigned int elapsedTime ) +{ + // Common to all loading contexts. + // + LoadingContext::OnUpdate( elapsedTime ); +} + +//============================================================================= +// LoadingSuperSprintContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingSuperSprintContext::OnSuspend() +{ + // Common to all loading contexts. + // + LoadingContext::OnSuspend(); +} + +//============================================================================= +// LoadingSuperSprintContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingSuperSprintContext::OnResume() +{ + // Common to all loading contexts. + // + LoadingContext::OnResume(); +} + +//============================================================================= +// LoadingSuperSprintContext::PrepareNewHeaps +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void LoadingSuperSprintContext::PrepareNewHeaps() +{ +} + +//============================================================================= +// LoadingSuperSprintContext::OnProcessRequestsComplete +//============================================================================= +// Description: Comment +// +// Parameters: ( void* pUserData ) +// +// Return: void +// +//============================================================================= +void LoadingSuperSprintContext::OnProcessRequestsComplete( void* pUserData ) +{ + GetSSM()->LoadCharacters(); + GetSSM()->LoadScriptData(); + + // Common to all loading contexts. + // + LoadingContext::OnProcessRequestsComplete( pUserData ); +} diff --git a/game/code/contexts/supersprint/loadingsupersprintcontext.h b/game/code/contexts/supersprint/loadingsupersprintcontext.h new file mode 100644 index 0000000..ee17bb1 --- /dev/null +++ b/game/code/contexts/supersprint/loadingsupersprintcontext.h @@ -0,0 +1,72 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: LoadingSuperSprintContext.h +// +// Description: +// +// History: + Created -- Darwin Chau +// +//============================================================================= + +#ifndef LoadingSuperSprintContext_H +#define LoadingSuperSprintContext_H + +//======================================== +// System Includes +//======================================== + +//======================================== +// Project Includes +//======================================== +#include <contexts/loadingcontext.h> // is-a LoadingContext + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: +// +//============================================================================= +class LoadingSuperSprintContext : public LoadingContext +{ + public: + // Static Methods for accessing this singleton. + static LoadingSuperSprintContext* GetInstance(); + + virtual void OnProcessRequestsComplete( void* pUserData ); + + protected: + + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void PrepareNewHeaps(); + + private: + + // constructor and destructor are protected to force singleton implementation + LoadingSuperSprintContext(); + virtual ~LoadingSuperSprintContext(); + + // Declared but not defined to prevent copying and assignment. + LoadingSuperSprintContext( const LoadingSuperSprintContext& ); + LoadingSuperSprintContext& operator=( const LoadingSuperSprintContext& ); + + // Pointer to the one and only instance of this singleton. + static LoadingSuperSprintContext* spInstance; + + bool mUnQueuedLoadRequests; +}; + +// A little syntactic sugar for getting at this singleton. +inline LoadingSuperSprintContext* GetLoadingSuperSprintContext() { return( LoadingSuperSprintContext::GetInstance() ); } + + +#endif // LoadingSuperSprintContext_H diff --git a/game/code/contexts/supersprint/supersprintcontext.cpp b/game/code/contexts/supersprint/supersprintcontext.cpp new file mode 100644 index 0000000..c6b87cc --- /dev/null +++ b/game/code/contexts/supersprint/supersprintcontext.cpp @@ -0,0 +1,544 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: supersprintcontext.cpp +// +// Description: Implement SuperSprintContext +// +// History: 2/8/2003 + Created -- Cary Brisebois +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +// Foundation Tech +#include <raddebug.hpp> + +#include <p3d/shadow.hpp> + + +//======================================== +// Project Includes +//======================================== + +#include <ai/vehicle/vehicleairender.h> + +#include <contexts/supersprint/supersprintcontext.h> + +#include <memory/srrmemory.h> + +#include <gameflow/gameflow.h> +#include <main/commandlineoptions.h> +#include <main/game.h> +#include <memory/leakdetection.h> +#include <render/rendermanager/rendermanager.h> +#include <render/rendermanager/renderlayer.h> + +#include <worldsim/coins/coinmanager.h> +#include <worldsim/coins/sparkle.h> +#include <worldsim/hitnrunmanager.h> +#include <worldsim/vehiclecentral.h> +#include <worldsim/worldphysicsmanager.h> +#include <worldsim/avatarmanager.h> +#include <worldsim/character/charactermanager.h> +#include <worldsim/traffic/trafficmanager.h> +#include <worldsim/ped/pedestrianmanager.h> +#include <worldsim/skidmarks/skidmarkmanager.h> + +#include <render/breakables/breakablesmanager.h> +#include <render/particles/particlemanager.h> +#include <render/animentitydsgmanager/animentitydsgmanager.h> +#include <render/RenderManager/WorldRenderLayer.h> +#include <worldsim/skidmarks/skidmarkgenerator.h> +#include <sound/soundmanager.h> +#include <meta/triggervolumetracker.h> + +#include <pedpaths/pathmanager.h> + +#include <input/inputmanager.h> + +// TODO: Remove once we put CreateRoadNetwork in the levels pipe +#include <roads/roadmanager.h> +#include <p3d/light.hpp> +#include <p3d/view.hpp> + +#include <worldsim/worldobject.h> +#include <ai/actionbuttonmanager.h> + +#include <camera/supercammanager.h> +#include <camera/supercamcentral.h> +#include <camera/supercam.h> +#include <camera/supersprintcam.h> +#include <camera/bumpercam.h> +#include <camera/kullcam.h> +#include <camera/wrecklesscam.h> +#include <camera/followcam.h> +#include <camera/animatedcam.h> +#include <camera/walkercam.h> + +#include <supersprint/supersprintmanager.h> + +#include <ai/actor/actormanager.h> +#include <presentation/presentation.h> + +#include <mission/animatedicon.h> + +#include <presentation/gui/guisystem.h> +#include <presentation/gui/guiwindow.h> + +#include <render/animentitydsgmanager/animentitydsgmanager.h> + +//***************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//***************************************************************************** + +SuperSprintContext* SuperSprintContext::spInstance = NULL; +const int NUM_SKID_MARKS_SUPER_SPRINT = 30; + +//***************************************************************************** +// +// Public Member Functions +// +//***************************************************************************** + +SuperSprintContext* SuperSprintContext::GetInstance() +{ + if ( spInstance == NULL ) + { + HeapMgr()->PushHeap( GMA_PERSISTENT ); + spInstance = new SuperSprintContext(); + HeapMgr()->PopHeap(GMA_PERSISTENT); + } + + return spInstance; +} + +//***************************************************************************** +// +// Protected Member Functions +// +//***************************************************************************** + +//============================================================================= +// SuperSprintContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void SuperSprintContext::OnStart( ContextEnum previousContext ) +{ + this->Resume(); + + // Common to all playing contexts. + // + PlayingContext::OnStart( previousContext ); + + //////////////////////////////////////////////////////////// + // RenderManager + RenderManager* rm = GetRenderManager(); + RenderLayer* rl = rm->mpLayer( RenderEnums::LevelSlot ); + rAssert( rl ); + + GetRenderManager()->mpLayer( RenderEnums::PresentationSlot )->Chill(); + +#ifdef DEBUGWATCH + // bootstrap vehicleai renderer + VehicleAIRender::GetVehicleAIRender(); +#endif + + //////////////////////////////////////////////////////////// + // Cameras set up + rl->SetNumViews( 1 ); + rl->SetUpViewCam(); + + p3d::inventory->SelectSection("Default"); + tLightGroup* sun = p3d::find<tLightGroup>("sun"); + rAssert( sun ); + for( unsigned int i = 0; i < rl->GetNumViews(); i++ ) + { + for(int j=0;j<sun->GetNumLights();j++) + { + rl->pView(i)->AddLight( sun->GetLight(j) ); + } + } + // Disable mood lighting in supersprint mode + rm->SetLevelLayerLights( NULL ); + + + float aspect = p3d::display->IsWidescreen() ? (16.0f / 9.0f) : (4.0f / 3.0f); + + unsigned int view = 0; + + tPointCamera* cam = static_cast<tPointCamera*>( rl->pCam( view ) ); + rAssert( dynamic_cast<tPointCamera*> ( cam ) != NULL ); + rAssert( cam ); + + SuperCam* sc = NULL; + sc = new SuperSprintCam(); + sc->SetAspect( aspect ); + + for( int i = 0; i < GetGameplayManager()->GetNumPlayers(); ++i ) + { + SuperCamCentral* scc = GetSuperCamManager()->GetSCC( i ); + rAssert( scc ); + + scc->SetCamera( cam ); + scc->RegisterSuperCam( sc ); + + //Start with the right cam + scc->SelectSuperCam( SuperCam::SUPER_SPRINT_CAM, SuperCamCentral::CUT | SuperCamCentral::QUICK, 0 ); + } + + //Hack to add the other cameras to player 0 + SuperCamCentral* scc = GetSuperCamManager()->GetSCC( 0 ); + sc = new BumperCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + FollowCam* fc = new FollowCam( FollowCam::FOLLOW_NEAR ); + fc->SetAspect( aspect ); + fc->CopyToData(); + scc->RegisterSuperCam( fc ); + + fc = new FollowCam( FollowCam::FOLLOW_FAR ); + fc->SetAspect( aspect ); + fc->CopyToData(); + scc->RegisterSuperCam( fc ); + + sc = new KullCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + sc = new WrecklessCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + sc = new AnimatedCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + sc = new ComedyCam(); + sc->SetAspect( aspect ); + scc->RegisterSuperCam( sc ); + + //////////////////////////////////////////////////////////// + // AvatarManager Bootstrapping + GetAvatarManager( )->EnterGame( ); + + //////////////////////////////////////////////////////////// + // TrafficManager Init + //TrafficManager::GetInstance()->Init(); + + //////////////////////////////////////////////////////////// + // PedestrianManager Init + PedestrianManager::GetInstance()->Init(); + + // TODO: Move this into level pipe + //Set up the sorting of the intersections and stuff. + RoadManager::GetInstance()->CreateRoadNetwork(); + + //////////////////////////////////////////////////////////// + // SkidMark Init Init + //Find skid mark shaders in the inventory and set proper values + SkidMarkGenerator::InitShaders(); + GetSkidmarkManager()->Init( NUM_SKID_MARKS_SUPER_SPRINT ); + GetSkidmarkManager()->SetTimedFadeouts( true ); + + + //////////////////////////////////////////////////////////// + // OnStart calls + + rm->pWorldScene()->SetRenderAll(true); + + GetSSM()->StartRace(); + + // + // Notify the sound system of gameplay start. This has been moved after + // the StartRace call above, since that causes character position in or out + // of the car to be decided, which the sound system uses to determine + // which sounds to start playing. + // + SoundManager::GetInstance()->OnGameplayStart(); + + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_MINIGAME, + CGuiWindow::GUI_SCREEN_ID_MINI_HUD ); + + // register GUI user input handler for active players only + // + int activeControllerIDs = 0; + for( int i = 0; i < SuperSprintData::NUM_PLAYERS; i++ ) + { + int controllerID = GetInputManager()->GetControllerIDforPlayer( i ); + if( controllerID != -1 ) + { + activeControllerIDs |= (1 << controllerID); + } + } + + GetGuiSystem()->RegisterUserInputHandlers( activeControllerIDs ); + + GetInputManager()->SetGameState( Input::ACTIVE_SS_GAME ); +} + +//============================================================================= +// SuperSprintContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void SuperSprintContext::OnStop( ContextEnum nextContext ) +{ + GetInputManager()->EnableReset( false ); + + GetInputManager()->SetGameState( Input::ACTIVE_NONE ); + + // unregister GUI user input handlers + // + int activeControllerIDs = 0; + for( int i = 0; i < SuperSprintData::NUM_PLAYERS; i++ ) + { + int controllerID = GetInputManager()->GetControllerIDforPlayer( i ); + if( controllerID != -1 ) + { + activeControllerIDs |= (1 << controllerID); + } + } + + GetGuiSystem()->UnregisterUserInputHandlers( activeControllerIDs ); + + HeapMgr()->PushHeap (GMA_TEMP); + + // + // This is called to prevent DMA of destroyed textures, + // because we don't swap buffers until the next frame. + // + p3d::pddi->DrawSync(); + + const bool shutdown = true; + GetSuperCamManager()->Init( shutdown ); + + TriggerVolumeTracker::GetInstance()->Cleanup(); + + GetCoinManager()->Destroy(); + GetSparkleManager()->Destroy(); + GetHitnRunManager()->Destroy(); + + GetPresentationManager()->Finalize(); + + //Shut down the SuperSprintManager + GetGameplayManager()->Finalize(); + + GetSkidmarkManager()->Destroy(); + + GetRenderManager()->mpLayer( RenderEnums::PresentationSlot )->Warm(); + + // Clean up lights! + // + RenderLayer* rl = GetRenderManager()->mpLayer( RenderEnums::LevelSlot ); + rAssert( rl ); + for( unsigned int i = 0; i < rl->GetNumViews(); i++ ) + { + rl->pView(i)->RemoveAllLights (); + } + +#ifdef DEBUGWATCH + VehicleAIRender::Destroy(); +#endif + + GetPresentationManager()->OnGameplayStop(); + + //Destroy Avatars stuff first + GetAvatarManager()->Destroy(); + TrafficManager::DestroyInstance(); + PedestrianManager::DestroyInstance(); + GetCharacterManager()->Destroy(); + GetVehicleCentral()->Unload(); + GetActorManager()->RemoveAllActors(); + GetActorManager()->RemoveAllSpawnPoints(); + + //We never entered. + GetActionButtonManager( )->Destroy( ); + + GetBreakablesManager()->FreeAllBreakables(); + GetParticleManager()->ClearSystems(); + GetRenderManager()->DumpAllLoadedData(); + SkidMarkGenerator::ReleaseShaders(); + + GetSoundManager()->OnGameplayEnd( true ); + + PathManager::GetInstance()->Destroy(); + + //This does cleanup. + RoadManager::GetInstance()->Destroy(); + + // Cleanup the Avatar Manager + // + GetAvatarManager()->ExitGame(); + + // Flush out the special section used by physics to cache SkeletonInfos. + // + p3d::inventory->RemoveSectionElements (SKELCACHE); + p3d::inventory->DeleteSection (SKELCACHE); + rReleaseString ("Delete SKELCACHE inventory section\n"); + + // enable screen clearing + // + GetRenderManager()->mpLayer( RenderEnums::GUI )->pView( 0 )->SetClearMask( PDDI_BUFFER_ALL ); + +#ifndef RAD_RELEASE + // Dump out the contents of the inventory sections + // + p3d::inventory->Dump (true); +#endif + + AnimatedIcon::ShutdownAnimatedIcons(); + GetAnimEntityDSGManager()->RemoveAll(); + + HeapMgr()->PopHeap (GMA_TEMP); + + // Common to all playing contexts. + // + PlayingContext::OnStop( nextContext ); +} + +//============================================================================= +// SuperSprintContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void SuperSprintContext::OnUpdate( unsigned int elapsedTime ) +{ + if( m_state != S_SUSPENDED ) + { + float timeins = (float)(elapsedTime) / 1000.0f; + GetAvatarManager()->Update( timeins ); + + GetCharacterManager()->GarbageCollect( ); + + /////////////////////////////////////////////////////////////// + // Update Particles + GetParticleManager()->Update( elapsedTime ); + GetBreakablesManager()->Update( elapsedTime ); + GetAnimEntityDSGManager()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Gameplay Manager + GetGameplayManager()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Physics + GetWorldPhysicsManager()->Update(elapsedTime); + + /////////////////////////////////////////////////////////////// + // Update Peds + // ordering is important. Unless other parts of code change, we must call + // this before WorldPhysManager::Update() because PedestrianManager + // sets the flags for all characters to be updated in WorldPhys Update + PedestrianManager::GetInstance()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Trigger volumes + GetTriggerVolumeTracker()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Traffic + //TrafficManager::GetInstance()->Update( elapsedTime ); + + /////////////////////////////////////////////////////////////// + // Update Skidmarks (fading) + GetSkidmarkManager()->Update( elapsedTime ); + GetSparkleManager()->Update( elapsedTime ); + + //Update the Super Sprint Manager + GetSSM()->Update( elapsedTime ); + } + + // Common to all playing contexts. + // + PlayingContext::OnUpdate( elapsedTime ); +} + +//============================================================================= +// SuperSprintContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void SuperSprintContext::OnSuspend() +{ + // Common to all playing contexts. + // + PlayingContext::OnSuspend(); +} + +//============================================================================= +// SuperSprintContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void SuperSprintContext::OnResume() +{ + // Common to all playing contexts. + // + PlayingContext::OnResume(); +} + +//***************************************************************************** +// +// Private Member Functions +// +//***************************************************************************** + +//============================================================================= +// SuperSprintContext::SuperSprintContext +//============================================================================= +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================= +SuperSprintContext::SuperSprintContext() +{ +} + +//============================================================================= +// SuperSprintContext::~SuperSprintContext +//============================================================================= +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================= +SuperSprintContext::~SuperSprintContext() +{ +} + diff --git a/game/code/contexts/supersprint/supersprintcontext.h b/game/code/contexts/supersprint/supersprintcontext.h new file mode 100644 index 0000000..ed484a0 --- /dev/null +++ b/game/code/contexts/supersprint/supersprintcontext.h @@ -0,0 +1,63 @@ +//============================================================================= +// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. +// +// File: supersprintcontext.h +// +// Description: Blahblahblah +// +// History: 2/8/2003 + Created -- Cary Brisebois +// +//============================================================================= + +#ifndef SUPERSPRINTCONTEXT_H +#define SUPERSPRINTCONTEXT_H + +//======================================== +// Nested Includes +//======================================== +#include <contexts/playingcontext.h> // is-a PlayingContext + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: Blahblahblah +// +//============================================================================= + +class SuperSprintContext : public PlayingContext +{ +public: + // Static Methods for accessing this singleton. + static SuperSprintContext* GetInstance(); + +protected: + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + +private: + static SuperSprintContext* spInstance; + + SuperSprintContext(); + virtual ~SuperSprintContext(); + + //Prevent wasteful constructor creation. + SuperSprintContext( const SuperSprintContext& supersprintcontext ); + SuperSprintContext& operator=( const SuperSprintContext& supersprintcontext ); +}; + +//***************************************************************************** +// +//Inline Public Member Functions +// +//***************************************************************************** + +inline SuperSprintContext* GetSPCTX() { return SuperSprintContext::GetInstance(); }; + +#endif //SUPERSPRINTCONTEXT_H diff --git a/game/code/contexts/supersprint/supersprintfecontext.cpp b/game/code/contexts/supersprint/supersprintfecontext.cpp new file mode 100644 index 0000000..1188bda --- /dev/null +++ b/game/code/contexts/supersprint/supersprintfecontext.cpp @@ -0,0 +1,247 @@ +//============================================================================= +// Copyright (C) 2003 Radical Entertainment Ltd. All rights reserved. +// +// File: SuperSprintFEContext.cpp +// +// Description: Implement SuperSprintFEContext +// +// History: 03/26/2003 + Created -- Tony Chu +// +//============================================================================= + +//======================================== +// System Includes +//======================================== +#include <raddebug.hpp> +#include <p3d/utility.hpp> + +//======================================== +// Project Includes +//======================================== +#include <contexts/supersprint/supersprintfecontext.h> + +#include <input/inputmanager.h> +#include <memory/srrmemory.h> +#include <mission/gameplaymanager.h> +#include <presentation/gui/guisystem.h> +#include <supersprint/supersprintdata.h> +#include <supersprint/supersprintmanager.h> + +//***************************************************************************** +// +// Global Data, Local Data, Local Classes +// +//***************************************************************************** + +SuperSprintFEContext* SuperSprintFEContext::spInstance = NULL; + +//***************************************************************************** +// +// Public Member Functions +// +//***************************************************************************** + +SuperSprintFEContext* SuperSprintFEContext::GetInstance() +{ + if( spInstance == NULL ) + { + HeapMgr()->PushHeap( GMA_PERSISTENT ); + spInstance = new SuperSprintFEContext; + HeapMgr()->PopHeap( GMA_PERSISTENT ); + } + + return spInstance; +} + +//***************************************************************************** +// +// Protected Member Functions +// +//***************************************************************************** + +//============================================================================= +// SuperSprintFEContext::OnStart +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum previousContext ) +// +// Return: void +// +//============================================================================= +void SuperSprintFEContext::OnStart( ContextEnum previousContext ) +{ + if( previousContext != CONTEXT_SUPERSPRINT ) + { + HeapMgr()->PrepareHeapsSuperSprint(); + + // run backend loading screen + // + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_BACKEND ); + + // load mini-game FE + // + GetGuiSystem()->HandleMessage( GUI_MSG_INIT_MINIGAME ); + + GetLoadingManager()->AddCallback( this ); + } + + // register GUI user input handlers + // + GetGuiSystem()->RegisterUserInputHandlers(); + + // unregister all players' controller IDs + // + for( int i = 0; i < SuperSprintData::NUM_PLAYERS; i++ ) + { + GetInputManager()->UnregisterControllerID( i ); + } + + GetInputManager()->SetGameState( Input::ACTIVE_FRONTEND ); +} + +//============================================================================= +// SuperSprintFEContext::OnStop +//============================================================================= +// Description: Comment +// +// Parameters: ( ContextEnum nextContext ) +// +// Return: void +// +//============================================================================= +void SuperSprintFEContext::OnStop( ContextEnum nextContext ) +{ + p3d::pddi->DrawSync(); + + GetInputManager()->SetGameState( Input::ACTIVE_NONE ); + + // unregister GUI user input handlers + // + GetGuiSystem()->UnregisterUserInputHandlers(); + + if( nextContext != CONTEXT_LOADING_SUPERSPRINT ) + { + SuperSprintManager::DestroyInstance(); + + // unload mini-game FE + // + GetGuiSystem()->HandleMessage( GUI_MSG_RELEASE_MINIGAME ); + + //Clear the gameplay manager. + SetGameplayManager( NULL ); + } +} + +//============================================================================= +// SuperSprintFEContext::OnUpdate +//============================================================================= +// Description: Comment +// +// Parameters: ( unsigned int elapsedTime ) +// +// Return: void +// +//============================================================================= +void SuperSprintFEContext::OnUpdate( unsigned int elapsedTime ) +{ + GetGuiSystem()->Update( elapsedTime ); +} + +//============================================================================= +// SuperSprintFEContext::OnSuspend +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void SuperSprintFEContext::OnSuspend() +{ +} + +//============================================================================= +// SuperSprintFEContext::OnResume +//============================================================================= +// Description: Comment +// +// Parameters: () +// +// Return: void +// +//============================================================================= +void SuperSprintFEContext::OnResume() +{ +} + +//============================================================================= +// SuperSprintFEContext::OnHandleEvent +//============================================================================= +// Description: Comment +// +// Parameters: ( EventEnum id, void* pEventData ) +// +// Return: void +// +//============================================================================= +void SuperSprintFEContext::OnHandleEvent( EventEnum id, void* pEventData ) +{ +} + +//============================================================================= +// SuperSprintFEContext::OnProcessRequestsComplete +//============================================================================= +// Description: Called when startup loading is done +// +// Parameters: pUserData - unused +// +// Return: void +// +//============================================================================= +void SuperSprintFEContext::OnProcessRequestsComplete( void* pUserData ) +{ + // quit backend loading screen + // + GetGuiSystem()->HandleMessage( GUI_MSG_QUIT_BACKEND ); + + // startup the mini-game FE + // + GetGuiSystem()->HandleMessage( GUI_MSG_RUN_MINIGAME ); +} + +//***************************************************************************** +// +// Private Member Functions +// +//***************************************************************************** + +//============================================================================= +// SuperSprintFEContext::SuperSprintFEContext +//============================================================================= +// Description: Constructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================= +SuperSprintFEContext::SuperSprintFEContext() +{ +} + +//============================================================================= +// SuperSprintFEContext::~SuperSprintFEContext +//============================================================================= +// Description: Destructor. +// +// Parameters: None. +// +// Return: N/A. +// +//============================================================================= +SuperSprintFEContext::~SuperSprintFEContext() +{ +} + diff --git a/game/code/contexts/supersprint/supersprintfecontext.h b/game/code/contexts/supersprint/supersprintfecontext.h new file mode 100644 index 0000000..50439f9 --- /dev/null +++ b/game/code/contexts/supersprint/supersprintfecontext.h @@ -0,0 +1,73 @@ +//============================================================================= +// Copyright (C) 2003 Radical Entertainment Ltd. All rights reserved. +// +// File: SuperSprintFEContext.h +// +// Description: Blahblahblah +// +// History: 03/26/2003 + Created -- Tony Chu +// +//============================================================================= + +#ifndef SUPERSPRINTFECONTEXT_H +#define SUPERSPRINTFECONTEXT_H + +//======================================== +// Nested Includes +//======================================== +#include <contexts/context.h> // is-a Context + +#include <loading/loadingmanager.h> + +//======================================== +// Forward References +//======================================== + +//============================================================================= +// +// Synopsis: Blahblahblah +// +//============================================================================= + +class SuperSprintFEContext : public Context, + public LoadingManager::ProcessRequestsCallback +{ +public: + // Static Methods for accessing this singleton. + static SuperSprintFEContext* GetInstance(); + +protected: + virtual void OnStart( ContextEnum previousContext ); + virtual void OnStop( ContextEnum nextContext ); + virtual void OnUpdate( unsigned int elapsedTime ); + + virtual void OnSuspend(); + virtual void OnResume(); + + virtual void OnHandleEvent( EventEnum id, void* pEventData ); + virtual void OnProcessRequestsComplete( void* pUserData ); + +private: + static SuperSprintFEContext* spInstance; + + SuperSprintFEContext(); + virtual ~SuperSprintFEContext(); + + //Prevent wasteful constructor creation. + SuperSprintFEContext( const SuperSprintFEContext& SuperSprintFEContext ); + SuperSprintFEContext& operator=( const SuperSprintFEContext& SuperSprintFEContext ); + +}; + +//***************************************************************************** +// +//Inline Public Member Functions +// +//***************************************************************************** + +inline SuperSprintFEContext* GetSuperSprintFEContext() +{ + return SuperSprintFEContext::GetInstance(); +}; + +#endif // SUPERSPRINTFECONTEXT_H |