From f56bb35301836e56582a575a75864392a0177875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 2 Dec 2013 19:31:46 -0800 Subject: Fix line endings. WHAMMY. --- mp/src/public/appframework/AppFramework.h | 316 ++++++++-------- mp/src/public/appframework/IAppSystem.h | 244 ++++++------ mp/src/public/appframework/IAppSystemGroup.h | 530 +++++++++++++-------------- mp/src/public/appframework/VguiMatSysApp.h | 142 +++---- mp/src/public/appframework/ilaunchermgr.h | 320 ++++++++-------- mp/src/public/appframework/tier2app.h | 170 ++++----- mp/src/public/appframework/tier3app.h | 242 ++++++------ 7 files changed, 982 insertions(+), 982 deletions(-) (limited to 'mp/src/public/appframework') diff --git a/mp/src/public/appframework/AppFramework.h b/mp/src/public/appframework/AppFramework.h index ec260299..185d2f33 100644 --- a/mp/src/public/appframework/AppFramework.h +++ b/mp/src/public/appframework/AppFramework.h @@ -1,158 +1,158 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: An application framework -// -// $Revision: $ -// $NoKeywords: $ -//===========================================================================// - -#ifndef APPFRAMEWORK_H -#define APPFRAMEWORK_H - -#ifdef _WIN32 -#pragma once -#endif - -#include "appframework/IAppSystemGroup.h" - - -//----------------------------------------------------------------------------- -// Gets the application instance.. -//----------------------------------------------------------------------------- -void *GetAppInstance(); - - -//----------------------------------------------------------------------------- -// Sets the application instance, should only be used if you're not calling AppMain. -//----------------------------------------------------------------------------- -void SetAppInstance( void* hInstance ); - - -//----------------------------------------------------------------------------- -// Main entry point for the application -//----------------------------------------------------------------------------- -int AppMain( void* hInstance, void* hPrevInstance, const char* lpCmdLine, int nCmdShow, CAppSystemGroup *pAppSystemGroup ); -int AppMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); - - -//----------------------------------------------------------------------------- -// Used to startup/shutdown the application -//----------------------------------------------------------------------------- -int AppStartup( void* hInstance, void* hPrevInstance, const char* lpCmdLine, int nCmdShow, CAppSystemGroup *pAppSystemGroup ); -int AppStartup( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); -void AppShutdown( CAppSystemGroup *pAppSystemGroup ); - - -//----------------------------------------------------------------------------- -// Macros to create singleton application objects for windowed + console apps -//----------------------------------------------------------------------------- -#if !defined( _X360 ) - -#ifdef WIN32 -#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ - int __stdcall WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) \ - { \ - return AppMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow, &_globalVarName ); \ - } -#elif defined( OSX ) -#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ - int main( int argc, char **argv ) \ - { \ - extern int ValveCocoaMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \ - return ValveCocoaMain( argc, argv, &_globalVarName ); \ - } -#elif defined( LINUX ) -#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ - int main( int argc, char **argv ) \ - { \ - extern int ValveLinuxWindowedMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \ - return ValveLinuxWindowedMain( argc, argv, &_globalVarName ); \ - } -#else -#error -#endif - -#else -#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ - void __cdecl main() \ - { \ - AppMain( (HINSTANCE)1, (HINSTANCE)0, NULL, 0, &_globalVarName ); \ - } -#endif - -#if !defined( _X360 ) -#define DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ - int main( int argc, char **argv ) \ - { \ - return AppMain( argc, argv, &_globalVarName ); \ - } -#else -#define DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ - void __cdecl main() \ - { \ - AppMain( 0, (char**)NULL, &_globalVarName ); \ - } -#endif - -#define DEFINE_WINDOWED_APPLICATION_OBJECT( _className ) \ - static _className __s_ApplicationObject; \ - DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( __s_ApplicationObject ) - -#define DEFINE_CONSOLE_APPLICATION_OBJECT( _className ) \ - static _className __s_ApplicationObject; \ - DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( __s_ApplicationObject ) - - -//----------------------------------------------------------------------------- -// This class is a helper class used for steam-based applications. -// It loads up the file system in preparation for using it to load other -// required modules from steam. -//----------------------------------------------------------------------------- -class CSteamApplication : public CAppSystemGroup -{ - typedef CAppSystemGroup BaseClass; - -public: - CSteamApplication( CSteamAppSystemGroup *pAppSystemGroup ); - - // Implementation of IAppSystemGroup - virtual bool Create( ); - virtual bool PreInit( ); - virtual int Main( ); - virtual void PostShutdown(); - virtual void Destroy(); - - // Use this version in cases where you can't control the main loop and - // expect to be ticked - virtual int Startup(); - virtual void Shutdown(); - -protected: - IFileSystem *m_pFileSystem; - CSteamAppSystemGroup *m_pChildAppSystemGroup; - bool m_bSteam; -}; - - -//----------------------------------------------------------------------------- -// Macros to help create singleton application objects for windowed + console steam apps -//----------------------------------------------------------------------------- -#define DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT_GLOBALVAR( _className, _varName ) \ - static CSteamApplication __s_SteamApplicationObject( &_varName ); \ - DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) - -#define DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( _className ) \ - static _className __s_ApplicationObject; \ - static CSteamApplication __s_SteamApplicationObject( &__s_ApplicationObject ); \ - DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) - -#define DEFINE_CONSOLE_STEAM_APPLICATION_OBJECT_GLOBALVAR( _className, _varName ) \ - static CSteamApplication __s_SteamApplicationObject( &_varName ); \ - DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) - -#define DEFINE_CONSOLE_STEAM_APPLICATION_OBJECT( _className ) \ - static _className __s_ApplicationObject; \ - static CSteamApplication __s_SteamApplicationObject( &__s_ApplicationObject ); \ - DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) - -#endif // APPFRAMEWORK_H +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: An application framework +// +// $Revision: $ +// $NoKeywords: $ +//===========================================================================// + +#ifndef APPFRAMEWORK_H +#define APPFRAMEWORK_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "appframework/IAppSystemGroup.h" + + +//----------------------------------------------------------------------------- +// Gets the application instance.. +//----------------------------------------------------------------------------- +void *GetAppInstance(); + + +//----------------------------------------------------------------------------- +// Sets the application instance, should only be used if you're not calling AppMain. +//----------------------------------------------------------------------------- +void SetAppInstance( void* hInstance ); + + +//----------------------------------------------------------------------------- +// Main entry point for the application +//----------------------------------------------------------------------------- +int AppMain( void* hInstance, void* hPrevInstance, const char* lpCmdLine, int nCmdShow, CAppSystemGroup *pAppSystemGroup ); +int AppMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); + + +//----------------------------------------------------------------------------- +// Used to startup/shutdown the application +//----------------------------------------------------------------------------- +int AppStartup( void* hInstance, void* hPrevInstance, const char* lpCmdLine, int nCmdShow, CAppSystemGroup *pAppSystemGroup ); +int AppStartup( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); +void AppShutdown( CAppSystemGroup *pAppSystemGroup ); + + +//----------------------------------------------------------------------------- +// Macros to create singleton application objects for windowed + console apps +//----------------------------------------------------------------------------- +#if !defined( _X360 ) + +#ifdef WIN32 +#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ + int __stdcall WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) \ + { \ + return AppMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow, &_globalVarName ); \ + } +#elif defined( OSX ) +#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ + int main( int argc, char **argv ) \ + { \ + extern int ValveCocoaMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \ + return ValveCocoaMain( argc, argv, &_globalVarName ); \ + } +#elif defined( LINUX ) +#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ + int main( int argc, char **argv ) \ + { \ + extern int ValveLinuxWindowedMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \ + return ValveLinuxWindowedMain( argc, argv, &_globalVarName ); \ + } +#else +#error +#endif + +#else +#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ + void __cdecl main() \ + { \ + AppMain( (HINSTANCE)1, (HINSTANCE)0, NULL, 0, &_globalVarName ); \ + } +#endif + +#if !defined( _X360 ) +#define DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ + int main( int argc, char **argv ) \ + { \ + return AppMain( argc, argv, &_globalVarName ); \ + } +#else +#define DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ + void __cdecl main() \ + { \ + AppMain( 0, (char**)NULL, &_globalVarName ); \ + } +#endif + +#define DEFINE_WINDOWED_APPLICATION_OBJECT( _className ) \ + static _className __s_ApplicationObject; \ + DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( __s_ApplicationObject ) + +#define DEFINE_CONSOLE_APPLICATION_OBJECT( _className ) \ + static _className __s_ApplicationObject; \ + DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( __s_ApplicationObject ) + + +//----------------------------------------------------------------------------- +// This class is a helper class used for steam-based applications. +// It loads up the file system in preparation for using it to load other +// required modules from steam. +//----------------------------------------------------------------------------- +class CSteamApplication : public CAppSystemGroup +{ + typedef CAppSystemGroup BaseClass; + +public: + CSteamApplication( CSteamAppSystemGroup *pAppSystemGroup ); + + // Implementation of IAppSystemGroup + virtual bool Create( ); + virtual bool PreInit( ); + virtual int Main( ); + virtual void PostShutdown(); + virtual void Destroy(); + + // Use this version in cases where you can't control the main loop and + // expect to be ticked + virtual int Startup(); + virtual void Shutdown(); + +protected: + IFileSystem *m_pFileSystem; + CSteamAppSystemGroup *m_pChildAppSystemGroup; + bool m_bSteam; +}; + + +//----------------------------------------------------------------------------- +// Macros to help create singleton application objects for windowed + console steam apps +//----------------------------------------------------------------------------- +#define DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT_GLOBALVAR( _className, _varName ) \ + static CSteamApplication __s_SteamApplicationObject( &_varName ); \ + DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) + +#define DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( _className ) \ + static _className __s_ApplicationObject; \ + static CSteamApplication __s_SteamApplicationObject( &__s_ApplicationObject ); \ + DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) + +#define DEFINE_CONSOLE_STEAM_APPLICATION_OBJECT_GLOBALVAR( _className, _varName ) \ + static CSteamApplication __s_SteamApplicationObject( &_varName ); \ + DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) + +#define DEFINE_CONSOLE_STEAM_APPLICATION_OBJECT( _className ) \ + static _className __s_ApplicationObject; \ + static CSteamApplication __s_SteamApplicationObject( &__s_ApplicationObject ); \ + DEFINE_CONSOLE_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject ) + +#endif // APPFRAMEWORK_H diff --git a/mp/src/public/appframework/IAppSystem.h b/mp/src/public/appframework/IAppSystem.h index 16da0710..33bcbb2e 100644 --- a/mp/src/public/appframework/IAppSystem.h +++ b/mp/src/public/appframework/IAppSystem.h @@ -1,122 +1,122 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: An application framework -// -// $Revision: $ -// $NoKeywords: $ -//=============================================================================// - -#ifndef IAPPSYSTEM_H -#define IAPPSYSTEM_H - -#ifdef _WIN32 -#pragma once -#endif - -#include "tier1/interface.h" - - -//----------------------------------------------------------------------------- -// Client systems are singleton objects in the client codebase responsible for -// various tasks -// The order in which the client systems appear in this list are the -// order in which they are initialized and updated. They are shut down in -// reverse order from which they are initialized. -//----------------------------------------------------------------------------- - -enum InitReturnVal_t -{ - INIT_FAILED = 0, - INIT_OK, - - INIT_LAST_VAL, -}; - - -abstract_class IAppSystem -{ -public: - // Here's where the app systems get to learn about each other - virtual bool Connect( CreateInterfaceFn factory ) = 0; - virtual void Disconnect() = 0; - - // Here's where systems can access other interfaces implemented by this object - // Returns NULL if it doesn't implement the requested interface - virtual void *QueryInterface( const char *pInterfaceName ) = 0; - - // Init, shutdown - virtual InitReturnVal_t Init() = 0; - virtual void Shutdown() = 0; -}; - - -//----------------------------------------------------------------------------- -// Helper empty implementation of an IAppSystem -//----------------------------------------------------------------------------- -template< class IInterface > -class CBaseAppSystem : public IInterface -{ -public: - // Here's where the app systems get to learn about each other - virtual bool Connect( CreateInterfaceFn factory ) { return true; } - virtual void Disconnect() {} - - // Here's where systems can access other interfaces implemented by this object - // Returns NULL if it doesn't implement the requested interface - virtual void *QueryInterface( const char *pInterfaceName ) { return NULL; } - - // Init, shutdown - virtual InitReturnVal_t Init() { return INIT_OK; } - virtual void Shutdown() {} -}; - - -//----------------------------------------------------------------------------- -// Helper implementation of an IAppSystem for tier0 -//----------------------------------------------------------------------------- -template< class IInterface > -class CTier0AppSystem : public CBaseAppSystem< IInterface > -{ -public: - CTier0AppSystem( bool bIsPrimaryAppSystem = true ) - { - m_bIsPrimaryAppSystem = bIsPrimaryAppSystem; - } - -protected: - // NOTE: a single DLL may have multiple AppSystems it's trying to - // expose. If this is true, you must return true from only - // one of those AppSystems; not doing so will cause all static - // libraries connected to it to connect/disconnect multiple times - - // NOTE: We don't do this as a virtual function to avoid - // having to up the version on all interfaces - bool IsPrimaryAppSystem() { return m_bIsPrimaryAppSystem; } - -private: - bool m_bIsPrimaryAppSystem; -}; - - -//----------------------------------------------------------------------------- -// This is the version of IAppSystem shipped 10/15/04 -// NOTE: Never change this!!! -//----------------------------------------------------------------------------- -abstract_class IAppSystemV0 -{ -public: - // Here's where the app systems get to learn about each other - virtual bool Connect( CreateInterfaceFn factory ) = 0; - virtual void Disconnect() = 0; - - // Here's where systems can access other interfaces implemented by this object - // Returns NULL if it doesn't implement the requested interface - virtual void *QueryInterface( const char *pInterfaceName ) = 0; - - // Init, shutdown - virtual InitReturnVal_t Init() = 0; - virtual void Shutdown() = 0; -}; - -#endif // IAPPSYSTEM_H - +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: An application framework +// +// $Revision: $ +// $NoKeywords: $ +//=============================================================================// + +#ifndef IAPPSYSTEM_H +#define IAPPSYSTEM_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/interface.h" + + +//----------------------------------------------------------------------------- +// Client systems are singleton objects in the client codebase responsible for +// various tasks +// The order in which the client systems appear in this list are the +// order in which they are initialized and updated. They are shut down in +// reverse order from which they are initialized. +//----------------------------------------------------------------------------- + +enum InitReturnVal_t +{ + INIT_FAILED = 0, + INIT_OK, + + INIT_LAST_VAL, +}; + + +abstract_class IAppSystem +{ +public: + // Here's where the app systems get to learn about each other + virtual bool Connect( CreateInterfaceFn factory ) = 0; + virtual void Disconnect() = 0; + + // Here's where systems can access other interfaces implemented by this object + // Returns NULL if it doesn't implement the requested interface + virtual void *QueryInterface( const char *pInterfaceName ) = 0; + + // Init, shutdown + virtual InitReturnVal_t Init() = 0; + virtual void Shutdown() = 0; +}; + + +//----------------------------------------------------------------------------- +// Helper empty implementation of an IAppSystem +//----------------------------------------------------------------------------- +template< class IInterface > +class CBaseAppSystem : public IInterface +{ +public: + // Here's where the app systems get to learn about each other + virtual bool Connect( CreateInterfaceFn factory ) { return true; } + virtual void Disconnect() {} + + // Here's where systems can access other interfaces implemented by this object + // Returns NULL if it doesn't implement the requested interface + virtual void *QueryInterface( const char *pInterfaceName ) { return NULL; } + + // Init, shutdown + virtual InitReturnVal_t Init() { return INIT_OK; } + virtual void Shutdown() {} +}; + + +//----------------------------------------------------------------------------- +// Helper implementation of an IAppSystem for tier0 +//----------------------------------------------------------------------------- +template< class IInterface > +class CTier0AppSystem : public CBaseAppSystem< IInterface > +{ +public: + CTier0AppSystem( bool bIsPrimaryAppSystem = true ) + { + m_bIsPrimaryAppSystem = bIsPrimaryAppSystem; + } + +protected: + // NOTE: a single DLL may have multiple AppSystems it's trying to + // expose. If this is true, you must return true from only + // one of those AppSystems; not doing so will cause all static + // libraries connected to it to connect/disconnect multiple times + + // NOTE: We don't do this as a virtual function to avoid + // having to up the version on all interfaces + bool IsPrimaryAppSystem() { return m_bIsPrimaryAppSystem; } + +private: + bool m_bIsPrimaryAppSystem; +}; + + +//----------------------------------------------------------------------------- +// This is the version of IAppSystem shipped 10/15/04 +// NOTE: Never change this!!! +//----------------------------------------------------------------------------- +abstract_class IAppSystemV0 +{ +public: + // Here's where the app systems get to learn about each other + virtual bool Connect( CreateInterfaceFn factory ) = 0; + virtual void Disconnect() = 0; + + // Here's where systems can access other interfaces implemented by this object + // Returns NULL if it doesn't implement the requested interface + virtual void *QueryInterface( const char *pInterfaceName ) = 0; + + // Init, shutdown + virtual InitReturnVal_t Init() = 0; + virtual void Shutdown() = 0; +}; + +#endif // IAPPSYSTEM_H + diff --git a/mp/src/public/appframework/IAppSystemGroup.h b/mp/src/public/appframework/IAppSystemGroup.h index 24387c34..5cc32aa8 100644 --- a/mp/src/public/appframework/IAppSystemGroup.h +++ b/mp/src/public/appframework/IAppSystemGroup.h @@ -1,265 +1,265 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// Purpose: Defines a group of app systems that all have the same lifetime -// that need to be connected/initialized, etc. in a well-defined order -// -// $Revision: $ -// $NoKeywords: $ -//============================================================================= - -#ifndef IAPPSYSTEMGROUP_H -#define IAPPSYSTEMGROUP_H - -#ifdef _WIN32 -#pragma once -#endif - - -#include "tier1/interface.h" -#include "tier1/utlvector.h" -#include "tier1/utldict.h" -#include "IAppSystem.h" - -//----------------------------------------------------------------------------- -// forward declarations -//----------------------------------------------------------------------------- -class IAppSystem; -class CSysModule; -class IBaseInterface; -class IFileSystem; - -//----------------------------------------------------------------------------- -// Handle to a DLL -//----------------------------------------------------------------------------- -typedef int AppModule_t; - -enum -{ - APP_MODULE_INVALID = (AppModule_t)~0 -}; - - -//----------------------------------------------------------------------------- -// NOTE: The following methods must be implemented in your application -// although they can be empty implementations if you like... -//----------------------------------------------------------------------------- -abstract_class IAppSystemGroup -{ -public: - // An installed application creation function, you should tell the group - // the DLLs and the singleton interfaces you want to instantiate. - // Return false if there's any problems and the app will abort - virtual bool Create( ) = 0; - - // Allow the application to do some work after AppSystems are connected but - // they are all Initialized. - // Return false if there's any problems and the app will abort - virtual bool PreInit() = 0; - - // Main loop implemented by the application - virtual int Main( ) = 0; - - // Allow the application to do some work after all AppSystems are shut down - virtual void PostShutdown() = 0; - - // Call an installed application destroy function, occurring after all modules - // are unloaded - virtual void Destroy() = 0; -}; - - -//----------------------------------------------------------------------------- -// Specifies a module + interface name for initialization -//----------------------------------------------------------------------------- -struct AppSystemInfo_t -{ - const char *m_pModuleName; - const char *m_pInterfaceName; -}; - - -//----------------------------------------------------------------------------- -// This class represents a group of app systems that all have the same lifetime -// that need to be connected/initialized, etc. in a well-defined order -//----------------------------------------------------------------------------- -class CAppSystemGroup : public IAppSystemGroup -{ -public: - // Used to determine where we exited out from the system - enum AppSystemGroupStage_t - { - CREATION = 0, - CONNECTION, - PREINITIALIZATION, - INITIALIZATION, - SHUTDOWN, - POSTSHUTDOWN, - DISCONNECTION, - DESTRUCTION, - - NONE, // This means no error - }; - -public: - // constructor - CAppSystemGroup( CAppSystemGroup *pParentAppSystem = NULL ); - - // Runs the app system group. - // First, modules are loaded, next they are connected, followed by initialization - // Then Main() is run - // Then modules are shut down, disconnected, and unloaded - int Run( ); - - // Use this version in cases where you can't control the main loop and - // expect to be ticked - virtual int Startup(); - virtual void Shutdown(); - - // Returns the stage at which the app system group ran into an error - AppSystemGroupStage_t GetErrorStage() const; - -protected: - // These methods are meant to be called by derived classes of CAppSystemGroup - - // Methods to load + unload DLLs - AppModule_t LoadModule( const char *pDLLName ); - AppModule_t LoadModule( CreateInterfaceFn factory ); - - // Method to add various global singleton systems - IAppSystem *AddSystem( AppModule_t module, const char *pInterfaceName ); - void AddSystem( IAppSystem *pAppSystem, const char *pInterfaceName ); - - // Simpler method of doing the LoadModule/AddSystem thing. - // Make sure the last AppSystemInfo has a NULL module name - bool AddSystems( AppSystemInfo_t *pSystems ); - - // Method to look up a particular named system... - void *FindSystem( const char *pInterfaceName ); - - // Gets at a class factory for the topmost appsystem group in an appsystem stack - static CreateInterfaceFn GetFactory(); - -private: - int OnStartup(); - void OnShutdown(); - - void UnloadAllModules( ); - void RemoveAllSystems(); - - // Method to connect/disconnect all systems - bool ConnectSystems( ); - void DisconnectSystems(); - - // Method to initialize/shutdown all systems - InitReturnVal_t InitSystems(); - void ShutdownSystems(); - - // Gets at the parent appsystem group - CAppSystemGroup *GetParent(); - - // Loads a module the standard way - virtual CSysModule *LoadModuleDLL( const char *pDLLName ); - - void ReportStartupFailure( int nErrorStage, int nSysIndex ); - - struct Module_t - { - CSysModule *m_pModule; - CreateInterfaceFn m_Factory; - char *m_pModuleName; - }; - - CUtlVector m_Modules; - CUtlVector m_Systems; - CUtlDict m_SystemDict; - CAppSystemGroup *m_pParentAppSystem; - AppSystemGroupStage_t m_nErrorStage; - - friend void *AppSystemCreateInterfaceFn(const char *pName, int *pReturnCode); - friend class CSteamAppSystemGroup; -}; - - -//----------------------------------------------------------------------------- -// This class represents a group of app systems that are loaded through steam -//----------------------------------------------------------------------------- -class CSteamAppSystemGroup : public CAppSystemGroup -{ -public: - CSteamAppSystemGroup( IFileSystem *pFileSystem = NULL, CAppSystemGroup *pParentAppSystem = NULL ); - - // Used by CSteamApplication to set up necessary pointers if we can't do it in the constructor - void Setup( IFileSystem *pFileSystem, CAppSystemGroup *pParentAppSystem ); - -protected: - // Sets up the search paths - bool SetupSearchPaths( const char *pStartingDir, bool bOnlyUseStartingDir, bool bIsTool ); - - // Returns the game info path. Only works if you've called SetupSearchPaths first - const char *GetGameInfoPath() const; - -private: - virtual CSysModule *LoadModuleDLL( const char *pDLLName ); - - IFileSystem *m_pFileSystem; - char m_pGameInfoPath[ MAX_PATH ]; -}; - - -//----------------------------------------------------------------------------- -// Helper empty decorator implementation of an IAppSystemGroup -//----------------------------------------------------------------------------- -template< class CBaseClass > -class CDefaultAppSystemGroup : public CBaseClass -{ -public: - virtual bool Create( ) { return true; } - virtual bool PreInit() { return true; } - virtual void PostShutdown() {} - virtual void Destroy() {} -}; - - -//----------------------------------------------------------------------------- -// Special helper for game info directory suggestion -//----------------------------------------------------------------------------- - -class CFSSteamSetupInfo; // Forward declaration - -// -// SuggestGameInfoDirFn_t -// Game info suggestion function. -// Provided by the application to possibly detect the suggested game info -// directory and initialize all the game-info-related systems appropriately. -// Parameters: -// pFsSteamSetupInfo steam file system setup information if available. -// pchPathBuffer buffer to hold game info directory path on return. -// nBufferLength length of the provided buffer to hold game info directory path. -// pbBubbleDirectories should contain "true" on return to bubble the directories up searching for game info file. -// Return values: -// Returns "true" if the game info directory path suggestion is available and -// was successfully copied into the provided buffer. -// Returns "false" otherwise, interpreted that no suggestion will be used. -// -typedef bool ( * SuggestGameInfoDirFn_t ) ( CFSSteamSetupInfo const *pFsSteamSetupInfo, char *pchPathBuffer, int nBufferLength, bool *pbBubbleDirectories ); - -// -// SetSuggestGameInfoDirFn -// Installs the supplied game info directory suggestion function. -// Parameters: -// pfnNewFn the new game info directory suggestion function. -// Returns: -// The previously installed suggestion function or NULL if none was installed before. -// This function never fails. -// -SuggestGameInfoDirFn_t SetSuggestGameInfoDirFn( SuggestGameInfoDirFn_t pfnNewFn ); - - -#endif // APPSYSTEMGROUP_H - - +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: Defines a group of app systems that all have the same lifetime +// that need to be connected/initialized, etc. in a well-defined order +// +// $Revision: $ +// $NoKeywords: $ +//============================================================================= + +#ifndef IAPPSYSTEMGROUP_H +#define IAPPSYSTEMGROUP_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "tier1/interface.h" +#include "tier1/utlvector.h" +#include "tier1/utldict.h" +#include "IAppSystem.h" + +//----------------------------------------------------------------------------- +// forward declarations +//----------------------------------------------------------------------------- +class IAppSystem; +class CSysModule; +class IBaseInterface; +class IFileSystem; + +//----------------------------------------------------------------------------- +// Handle to a DLL +//----------------------------------------------------------------------------- +typedef int AppModule_t; + +enum +{ + APP_MODULE_INVALID = (AppModule_t)~0 +}; + + +//----------------------------------------------------------------------------- +// NOTE: The following methods must be implemented in your application +// although they can be empty implementations if you like... +//----------------------------------------------------------------------------- +abstract_class IAppSystemGroup +{ +public: + // An installed application creation function, you should tell the group + // the DLLs and the singleton interfaces you want to instantiate. + // Return false if there's any problems and the app will abort + virtual bool Create( ) = 0; + + // Allow the application to do some work after AppSystems are connected but + // they are all Initialized. + // Return false if there's any problems and the app will abort + virtual bool PreInit() = 0; + + // Main loop implemented by the application + virtual int Main( ) = 0; + + // Allow the application to do some work after all AppSystems are shut down + virtual void PostShutdown() = 0; + + // Call an installed application destroy function, occurring after all modules + // are unloaded + virtual void Destroy() = 0; +}; + + +//----------------------------------------------------------------------------- +// Specifies a module + interface name for initialization +//----------------------------------------------------------------------------- +struct AppSystemInfo_t +{ + const char *m_pModuleName; + const char *m_pInterfaceName; +}; + + +//----------------------------------------------------------------------------- +// This class represents a group of app systems that all have the same lifetime +// that need to be connected/initialized, etc. in a well-defined order +//----------------------------------------------------------------------------- +class CAppSystemGroup : public IAppSystemGroup +{ +public: + // Used to determine where we exited out from the system + enum AppSystemGroupStage_t + { + CREATION = 0, + CONNECTION, + PREINITIALIZATION, + INITIALIZATION, + SHUTDOWN, + POSTSHUTDOWN, + DISCONNECTION, + DESTRUCTION, + + NONE, // This means no error + }; + +public: + // constructor + CAppSystemGroup( CAppSystemGroup *pParentAppSystem = NULL ); + + // Runs the app system group. + // First, modules are loaded, next they are connected, followed by initialization + // Then Main() is run + // Then modules are shut down, disconnected, and unloaded + int Run( ); + + // Use this version in cases where you can't control the main loop and + // expect to be ticked + virtual int Startup(); + virtual void Shutdown(); + + // Returns the stage at which the app system group ran into an error + AppSystemGroupStage_t GetErrorStage() const; + +protected: + // These methods are meant to be called by derived classes of CAppSystemGroup + + // Methods to load + unload DLLs + AppModule_t LoadModule( const char *pDLLName ); + AppModule_t LoadModule( CreateInterfaceFn factory ); + + // Method to add various global singleton systems + IAppSystem *AddSystem( AppModule_t module, const char *pInterfaceName ); + void AddSystem( IAppSystem *pAppSystem, const char *pInterfaceName ); + + // Simpler method of doing the LoadModule/AddSystem thing. + // Make sure the last AppSystemInfo has a NULL module name + bool AddSystems( AppSystemInfo_t *pSystems ); + + // Method to look up a particular named system... + void *FindSystem( const char *pInterfaceName ); + + // Gets at a class factory for the topmost appsystem group in an appsystem stack + static CreateInterfaceFn GetFactory(); + +private: + int OnStartup(); + void OnShutdown(); + + void UnloadAllModules( ); + void RemoveAllSystems(); + + // Method to connect/disconnect all systems + bool ConnectSystems( ); + void DisconnectSystems(); + + // Method to initialize/shutdown all systems + InitReturnVal_t InitSystems(); + void ShutdownSystems(); + + // Gets at the parent appsystem group + CAppSystemGroup *GetParent(); + + // Loads a module the standard way + virtual CSysModule *LoadModuleDLL( const char *pDLLName ); + + void ReportStartupFailure( int nErrorStage, int nSysIndex ); + + struct Module_t + { + CSysModule *m_pModule; + CreateInterfaceFn m_Factory; + char *m_pModuleName; + }; + + CUtlVector m_Modules; + CUtlVector m_Systems; + CUtlDict m_SystemDict; + CAppSystemGroup *m_pParentAppSystem; + AppSystemGroupStage_t m_nErrorStage; + + friend void *AppSystemCreateInterfaceFn(const char *pName, int *pReturnCode); + friend class CSteamAppSystemGroup; +}; + + +//----------------------------------------------------------------------------- +// This class represents a group of app systems that are loaded through steam +//----------------------------------------------------------------------------- +class CSteamAppSystemGroup : public CAppSystemGroup +{ +public: + CSteamAppSystemGroup( IFileSystem *pFileSystem = NULL, CAppSystemGroup *pParentAppSystem = NULL ); + + // Used by CSteamApplication to set up necessary pointers if we can't do it in the constructor + void Setup( IFileSystem *pFileSystem, CAppSystemGroup *pParentAppSystem ); + +protected: + // Sets up the search paths + bool SetupSearchPaths( const char *pStartingDir, bool bOnlyUseStartingDir, bool bIsTool ); + + // Returns the game info path. Only works if you've called SetupSearchPaths first + const char *GetGameInfoPath() const; + +private: + virtual CSysModule *LoadModuleDLL( const char *pDLLName ); + + IFileSystem *m_pFileSystem; + char m_pGameInfoPath[ MAX_PATH ]; +}; + + +//----------------------------------------------------------------------------- +// Helper empty decorator implementation of an IAppSystemGroup +//----------------------------------------------------------------------------- +template< class CBaseClass > +class CDefaultAppSystemGroup : public CBaseClass +{ +public: + virtual bool Create( ) { return true; } + virtual bool PreInit() { return true; } + virtual void PostShutdown() {} + virtual void Destroy() {} +}; + + +//----------------------------------------------------------------------------- +// Special helper for game info directory suggestion +//----------------------------------------------------------------------------- + +class CFSSteamSetupInfo; // Forward declaration + +// +// SuggestGameInfoDirFn_t +// Game info suggestion function. +// Provided by the application to possibly detect the suggested game info +// directory and initialize all the game-info-related systems appropriately. +// Parameters: +// pFsSteamSetupInfo steam file system setup information if available. +// pchPathBuffer buffer to hold game info directory path on return. +// nBufferLength length of the provided buffer to hold game info directory path. +// pbBubbleDirectories should contain "true" on return to bubble the directories up searching for game info file. +// Return values: +// Returns "true" if the game info directory path suggestion is available and +// was successfully copied into the provided buffer. +// Returns "false" otherwise, interpreted that no suggestion will be used. +// +typedef bool ( * SuggestGameInfoDirFn_t ) ( CFSSteamSetupInfo const *pFsSteamSetupInfo, char *pchPathBuffer, int nBufferLength, bool *pbBubbleDirectories ); + +// +// SetSuggestGameInfoDirFn +// Installs the supplied game info directory suggestion function. +// Parameters: +// pfnNewFn the new game info directory suggestion function. +// Returns: +// The previously installed suggestion function or NULL if none was installed before. +// This function never fails. +// +SuggestGameInfoDirFn_t SetSuggestGameInfoDirFn( SuggestGameInfoDirFn_t pfnNewFn ); + + +#endif // APPSYSTEMGROUP_H + + diff --git a/mp/src/public/appframework/VguiMatSysApp.h b/mp/src/public/appframework/VguiMatSysApp.h index 7158c230..e40793ea 100644 --- a/mp/src/public/appframework/VguiMatSysApp.h +++ b/mp/src/public/appframework/VguiMatSysApp.h @@ -1,71 +1,71 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// Material editor -//============================================================================= - -#ifndef VGUIMATSYSAPP_H -#define VGUIMATSYSAPP_H - -#ifdef _WIN32 -#pragma once -#endif - - -#include "appframework/tier3app.h" - - -//----------------------------------------------------------------------------- -// The application object -//----------------------------------------------------------------------------- -class CVguiMatSysApp : public CVguiSteamApp -{ - typedef CVguiSteamApp BaseClass; - -public: - CVguiMatSysApp(); - - // Methods of IApplication - virtual bool Create(); - virtual bool PreInit(); - virtual void PostShutdown(); - virtual void Destroy(); - - // Returns the window handle (HWND in Win32) - void* GetAppWindow(); - - // Gets the window size - int GetWindowWidth() const; - int GetWindowHeight() const; - -protected: - void AppPumpMessages(); - - // Sets the video mode - bool SetVideoMode( ); - - // Sets up the game path - bool SetupSearchPaths( const char *pStartingDir, bool bOnlyUseStartingDir, bool bIsTool ); - -private: - // Returns the app name - virtual const char *GetAppName() = 0; - virtual bool AppUsesReadPixels() { return false; } - - // Creates the app window - virtual void *CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h ); - - void *m_HWnd; - int m_nWidth; - int m_nHeight; -}; - - -#endif // VGUIMATSYSAPP_H +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// $Header: $ +// $NoKeywords: $ +// +// Material editor +//============================================================================= + +#ifndef VGUIMATSYSAPP_H +#define VGUIMATSYSAPP_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "appframework/tier3app.h" + + +//----------------------------------------------------------------------------- +// The application object +//----------------------------------------------------------------------------- +class CVguiMatSysApp : public CVguiSteamApp +{ + typedef CVguiSteamApp BaseClass; + +public: + CVguiMatSysApp(); + + // Methods of IApplication + virtual bool Create(); + virtual bool PreInit(); + virtual void PostShutdown(); + virtual void Destroy(); + + // Returns the window handle (HWND in Win32) + void* GetAppWindow(); + + // Gets the window size + int GetWindowWidth() const; + int GetWindowHeight() const; + +protected: + void AppPumpMessages(); + + // Sets the video mode + bool SetVideoMode( ); + + // Sets up the game path + bool SetupSearchPaths( const char *pStartingDir, bool bOnlyUseStartingDir, bool bIsTool ); + +private: + // Returns the app name + virtual const char *GetAppName() = 0; + virtual bool AppUsesReadPixels() { return false; } + + // Creates the app window + virtual void *CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h ); + + void *m_HWnd; + int m_nWidth; + int m_nHeight; +}; + + +#endif // VGUIMATSYSAPP_H diff --git a/mp/src/public/appframework/ilaunchermgr.h b/mp/src/public/appframework/ilaunchermgr.h index 7fa5dc76..2498ab36 100644 --- a/mp/src/public/appframework/ilaunchermgr.h +++ b/mp/src/public/appframework/ilaunchermgr.h @@ -1,160 +1,160 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// ilaunchermgr.h -// -//================================================================================================== -#ifndef ILAUNCHERMGR_H -#define ILAUNCHERMGR_H - -#ifdef _WIN32 -#pragma once -#endif - -#if defined( USE_SDL ) - -#include "tier0/threadtools.h" -#include "appframework/IAppSystem.h" - -#if defined( DX_TO_GL_ABSTRACTION ) - #if defined( LINUX ) || defined( _WIN32 ) - #include "togl/linuxwin/glmgrbasics.h" - #include "togl/linuxwin/glmdisplay.h" - #elif defined( OSX ) - #include "togl/osx/glmgrbasics.h" - #include "togl/osx/glmdisplay.h" - #endif - -class GLMDisplayDB; -class CShowPixelsParams; -#endif - -// if you rev this version also update materialsystem/cmaterialsystem.cpp CMaterialSystem::Connect as it defines the string directly -#define SDLMGR_INTERFACE_VERSION "SDLMgrInterface001" - -class CCocoaEvent; -class CStackCrawlParams; - -typedef struct SDL_Cursor SDL_Cursor; - -class ILauncherMgr : public IAppSystem -{ -public: - virtual bool Connect( CreateInterfaceFn factory ) = 0; - virtual void Disconnect() = 0; - - virtual void *QueryInterface( const char *pInterfaceName ) = 0; - - // Init, shutdown - virtual InitReturnVal_t Init() = 0; - virtual void Shutdown() = 0; - - // Create the window. - virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height ) = 0; - - virtual void IncWindowRefCount() = 0; - virtual void DecWindowRefCount() = 0; - - // Get the next N events. The function returns the number of events that were filled into your array. - virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) = 0; -#ifdef LINUX - virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) = 0; -#endif - - // Set the mouse cursor position. - virtual void SetCursorPosition( int x, int y ) = 0; - - virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight ) = 0; - virtual bool IsWindowFullScreen() = 0; - virtual void MoveWindow( int x, int y ) = 0; - virtual void SizeWindow( int width, int tall ) = 0; - virtual void PumpWindowsMessageLoop() = 0; - - virtual void DestroyGameWindow() = 0; - virtual void SetApplicationIcon( const char *pchAppIconFile ) = 0; - - virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) = 0; - - virtual void GetNativeDisplayInfo( int nDisplay, uint &nWidth, uint &nHeight, uint &nRefreshHz ) = 0; // Retrieve the size of the monitor (desktop) - virtual void RenderedSize( uint &width, uint &height, bool set ) = 0; // either set or retrieve rendered size value (from dxabstract) - virtual void DisplayedSize( uint &width, uint &height ) = 0; // query backbuffer size (window size whether FS or windowed) - -#if defined( DX_TO_GL_ABSTRACTION ) - virtual PseudoGLContextPtr GetMainContext() = 0; - // Get the NSGLContext for a window's main view - note this is the carbon windowref as an argument - virtual PseudoGLContextPtr GetGLContextForWindow( void* windowref ) = 0; - virtual PseudoGLContextPtr CreateExtraContext() = 0; - virtual void DeleteContext( PseudoGLContextPtr hContext ) = 0; - virtual bool MakeContextCurrent( PseudoGLContextPtr hContext ) = 0; - virtual GLMDisplayDB *GetDisplayDB( void ) = 0; - virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) = 0; - virtual void ShowPixels( CShowPixelsParams *params ) = 0; -#endif - - virtual void GetStackCrawl( CStackCrawlParams *params ) = 0; - - virtual void WaitUntilUserInput( int msSleepTime ) = 0; - - virtual void *GetWindowRef() = 0; - - virtual void SetMouseVisible( bool bState ) = 0; - virtual void SetMouseCursor( SDL_Cursor *hCursor ) = 0; - virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) = 0; - virtual void OnFrameRendered() = 0; - - virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) = 0; - - virtual double GetPrevGLSwapWindowTime() = 0; -}; - -extern ILauncherMgr *g_pLauncherMgr; - -enum CocoaEventType_t -{ - CocoaEvent_KeyDown, - CocoaEvent_KeyUp, - CocoaEvent_MouseButtonDown, - CocoaEvent_MouseMove, - CocoaEvent_MouseButtonUp, - CocoaEvent_AppActivate, - CocoaEvent_MouseScroll, - CocoaEvent_AppQuit, - CocoaEvent_Deleted, // Event was one of the above, but has been handled and should be ignored now. -}; - -// enum values need to match bit-shifting logic in CInputSystem::UpdateMouseButtonState and -// the codes from NSEvent pressedMouseButtons, turns out the two are in agreement right now -enum CocoaMouseButton_t -{ - COCOABUTTON_LEFT = 1 << 0, - COCOABUTTON_RIGHT = 1 << 1, - COCOABUTTON_MIDDLE = 1 << 2, - COCOABUTTON_4 = 1 << 3, - COCOABUTTON_5 = 1 << 4, -}; - -enum ECocoaKeyModifier -{ - eCapsLockKey, - eShiftKey, - eControlKey, - eAltKey, // aka option - eCommandKey -}; - -class CCocoaEvent -{ -public: - CocoaEventType_t m_EventType; - int m_VirtualKeyCode; - wchar_t m_UnicodeKey; - wchar_t m_UnicodeKeyUnmodified; - uint m_ModifierKeyMask; // - int m_MousePos[2]; - int m_MouseButtonFlags; // Current state of the mouse buttons. See COCOABUTTON_xxxx. - uint m_nMouseClickCount; - int m_MouseButton; // which of the CocoaMouseButton_t buttons this is for from above -}; - -#endif // defined( USE_SDL ) - -#endif // ILAUNCHERMGR_H +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// ilaunchermgr.h +// +//================================================================================================== +#ifndef ILAUNCHERMGR_H +#define ILAUNCHERMGR_H + +#ifdef _WIN32 +#pragma once +#endif + +#if defined( USE_SDL ) + +#include "tier0/threadtools.h" +#include "appframework/IAppSystem.h" + +#if defined( DX_TO_GL_ABSTRACTION ) + #if defined( LINUX ) || defined( _WIN32 ) + #include "togl/linuxwin/glmgrbasics.h" + #include "togl/linuxwin/glmdisplay.h" + #elif defined( OSX ) + #include "togl/osx/glmgrbasics.h" + #include "togl/osx/glmdisplay.h" + #endif + +class GLMDisplayDB; +class CShowPixelsParams; +#endif + +// if you rev this version also update materialsystem/cmaterialsystem.cpp CMaterialSystem::Connect as it defines the string directly +#define SDLMGR_INTERFACE_VERSION "SDLMgrInterface001" + +class CCocoaEvent; +class CStackCrawlParams; + +typedef struct SDL_Cursor SDL_Cursor; + +class ILauncherMgr : public IAppSystem +{ +public: + virtual bool Connect( CreateInterfaceFn factory ) = 0; + virtual void Disconnect() = 0; + + virtual void *QueryInterface( const char *pInterfaceName ) = 0; + + // Init, shutdown + virtual InitReturnVal_t Init() = 0; + virtual void Shutdown() = 0; + + // Create the window. + virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height ) = 0; + + virtual void IncWindowRefCount() = 0; + virtual void DecWindowRefCount() = 0; + + // Get the next N events. The function returns the number of events that were filled into your array. + virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) = 0; +#ifdef LINUX + virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) = 0; +#endif + + // Set the mouse cursor position. + virtual void SetCursorPosition( int x, int y ) = 0; + + virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight ) = 0; + virtual bool IsWindowFullScreen() = 0; + virtual void MoveWindow( int x, int y ) = 0; + virtual void SizeWindow( int width, int tall ) = 0; + virtual void PumpWindowsMessageLoop() = 0; + + virtual void DestroyGameWindow() = 0; + virtual void SetApplicationIcon( const char *pchAppIconFile ) = 0; + + virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) = 0; + + virtual void GetNativeDisplayInfo( int nDisplay, uint &nWidth, uint &nHeight, uint &nRefreshHz ) = 0; // Retrieve the size of the monitor (desktop) + virtual void RenderedSize( uint &width, uint &height, bool set ) = 0; // either set or retrieve rendered size value (from dxabstract) + virtual void DisplayedSize( uint &width, uint &height ) = 0; // query backbuffer size (window size whether FS or windowed) + +#if defined( DX_TO_GL_ABSTRACTION ) + virtual PseudoGLContextPtr GetMainContext() = 0; + // Get the NSGLContext for a window's main view - note this is the carbon windowref as an argument + virtual PseudoGLContextPtr GetGLContextForWindow( void* windowref ) = 0; + virtual PseudoGLContextPtr CreateExtraContext() = 0; + virtual void DeleteContext( PseudoGLContextPtr hContext ) = 0; + virtual bool MakeContextCurrent( PseudoGLContextPtr hContext ) = 0; + virtual GLMDisplayDB *GetDisplayDB( void ) = 0; + virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) = 0; + virtual void ShowPixels( CShowPixelsParams *params ) = 0; +#endif + + virtual void GetStackCrawl( CStackCrawlParams *params ) = 0; + + virtual void WaitUntilUserInput( int msSleepTime ) = 0; + + virtual void *GetWindowRef() = 0; + + virtual void SetMouseVisible( bool bState ) = 0; + virtual void SetMouseCursor( SDL_Cursor *hCursor ) = 0; + virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) = 0; + virtual void OnFrameRendered() = 0; + + virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) = 0; + + virtual double GetPrevGLSwapWindowTime() = 0; +}; + +extern ILauncherMgr *g_pLauncherMgr; + +enum CocoaEventType_t +{ + CocoaEvent_KeyDown, + CocoaEvent_KeyUp, + CocoaEvent_MouseButtonDown, + CocoaEvent_MouseMove, + CocoaEvent_MouseButtonUp, + CocoaEvent_AppActivate, + CocoaEvent_MouseScroll, + CocoaEvent_AppQuit, + CocoaEvent_Deleted, // Event was one of the above, but has been handled and should be ignored now. +}; + +// enum values need to match bit-shifting logic in CInputSystem::UpdateMouseButtonState and +// the codes from NSEvent pressedMouseButtons, turns out the two are in agreement right now +enum CocoaMouseButton_t +{ + COCOABUTTON_LEFT = 1 << 0, + COCOABUTTON_RIGHT = 1 << 1, + COCOABUTTON_MIDDLE = 1 << 2, + COCOABUTTON_4 = 1 << 3, + COCOABUTTON_5 = 1 << 4, +}; + +enum ECocoaKeyModifier +{ + eCapsLockKey, + eShiftKey, + eControlKey, + eAltKey, // aka option + eCommandKey +}; + +class CCocoaEvent +{ +public: + CocoaEventType_t m_EventType; + int m_VirtualKeyCode; + wchar_t m_UnicodeKey; + wchar_t m_UnicodeKeyUnmodified; + uint m_ModifierKeyMask; // + int m_MousePos[2]; + int m_MouseButtonFlags; // Current state of the mouse buttons. See COCOABUTTON_xxxx. + uint m_nMouseClickCount; + int m_MouseButton; // which of the CocoaMouseButton_t buttons this is for from above +}; + +#endif // defined( USE_SDL ) + +#endif // ILAUNCHERMGR_H diff --git a/mp/src/public/appframework/tier2app.h b/mp/src/public/appframework/tier2app.h index 54268974..266fc104 100644 --- a/mp/src/public/appframework/tier2app.h +++ b/mp/src/public/appframework/tier2app.h @@ -1,85 +1,85 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// The application object for apps that use tier2 -//============================================================================= - -#ifndef TIER2APP_H -#define TIER2APP_H - -#ifdef _WIN32 -#pragma once -#endif - - -#include "appframework/AppFramework.h" -#include "tier2/tier2dm.h" -#include "tier1/convar.h" - - -//----------------------------------------------------------------------------- -// The application object for apps that use tier2 -//----------------------------------------------------------------------------- -class CTier2SteamApp : public CSteamAppSystemGroup -{ - typedef CSteamAppSystemGroup BaseClass; - -public: - // Methods of IApplication - virtual bool PreInit() - { - CreateInterfaceFn factory = GetFactory(); - ConnectTier1Libraries( &factory, 1 ); - ConVar_Register( 0 ); - ConnectTier2Libraries( &factory, 1 ); - return true; - } - - virtual void PostShutdown() - { - DisconnectTier2Libraries(); - ConVar_Unregister(); - DisconnectTier1Libraries(); - } -}; - - -//----------------------------------------------------------------------------- -// The application object for apps that use tier2 and datamodel -//----------------------------------------------------------------------------- -class CTier2DmSteamApp : public CTier2SteamApp -{ - typedef CTier2SteamApp BaseClass; - -public: - // Methods of IApplication - virtual bool PreInit() - { - if ( !BaseClass::PreInit() ) - return false; - - CreateInterfaceFn factory = GetFactory(); - if ( !ConnectDataModel( factory ) ) - return false; - - InitReturnVal_t nRetVal = InitDataModel(); - return ( nRetVal == INIT_OK ); - } - - virtual void PostShutdown() - { - ShutdownDataModel(); - DisconnectDataModel(); - BaseClass::PostShutdown(); - } -}; - - -#endif // TIER2APP_H +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// $Header: $ +// $NoKeywords: $ +// +// The application object for apps that use tier2 +//============================================================================= + +#ifndef TIER2APP_H +#define TIER2APP_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "appframework/AppFramework.h" +#include "tier2/tier2dm.h" +#include "tier1/convar.h" + + +//----------------------------------------------------------------------------- +// The application object for apps that use tier2 +//----------------------------------------------------------------------------- +class CTier2SteamApp : public CSteamAppSystemGroup +{ + typedef CSteamAppSystemGroup BaseClass; + +public: + // Methods of IApplication + virtual bool PreInit() + { + CreateInterfaceFn factory = GetFactory(); + ConnectTier1Libraries( &factory, 1 ); + ConVar_Register( 0 ); + ConnectTier2Libraries( &factory, 1 ); + return true; + } + + virtual void PostShutdown() + { + DisconnectTier2Libraries(); + ConVar_Unregister(); + DisconnectTier1Libraries(); + } +}; + + +//----------------------------------------------------------------------------- +// The application object for apps that use tier2 and datamodel +//----------------------------------------------------------------------------- +class CTier2DmSteamApp : public CTier2SteamApp +{ + typedef CTier2SteamApp BaseClass; + +public: + // Methods of IApplication + virtual bool PreInit() + { + if ( !BaseClass::PreInit() ) + return false; + + CreateInterfaceFn factory = GetFactory(); + if ( !ConnectDataModel( factory ) ) + return false; + + InitReturnVal_t nRetVal = InitDataModel(); + return ( nRetVal == INIT_OK ); + } + + virtual void PostShutdown() + { + ShutdownDataModel(); + DisconnectDataModel(); + BaseClass::PostShutdown(); + } +}; + + +#endif // TIER2APP_H diff --git a/mp/src/public/appframework/tier3app.h b/mp/src/public/appframework/tier3app.h index 60df8b74..d1806472 100644 --- a/mp/src/public/appframework/tier3app.h +++ b/mp/src/public/appframework/tier3app.h @@ -1,121 +1,121 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// The application objects for apps that use tier3 -//============================================================================= - -#ifndef TIER3APP_H -#define TIER3APP_H - -#ifdef _WIN32 -#pragma once -#endif - - -#include "appframework/tier2app.h" -#include "tier3/tier3.h" -#include "vgui_controls/Controls.h" - - -//----------------------------------------------------------------------------- -// The application object for apps that use tier3 -//----------------------------------------------------------------------------- -class CTier3SteamApp : public CTier2SteamApp -{ - typedef CTier2SteamApp BaseClass; - -public: - // Methods of IApplication - virtual bool PreInit() - { - if ( !BaseClass::PreInit() ) - return false; - - CreateInterfaceFn factory = GetFactory(); - ConnectTier3Libraries( &factory, 1 ); - return true; - } - - virtual void PostShutdown() - { - DisconnectTier3Libraries(); - BaseClass::PostShutdown(); - } -}; - - -//----------------------------------------------------------------------------- -// The application object for apps that use tier3 -//----------------------------------------------------------------------------- -class CTier3DmSteamApp : public CTier2DmSteamApp -{ - typedef CTier2DmSteamApp BaseClass; - -public: - // Methods of IApplication - virtual bool PreInit() - { - if ( !BaseClass::PreInit() ) - return false; - - CreateInterfaceFn factory = GetFactory(); - ConnectTier3Libraries( &factory, 1 ); - return true; - } - - virtual void PostShutdown() - { - DisconnectTier3Libraries(); - BaseClass::PostShutdown(); - } -}; - - -//----------------------------------------------------------------------------- -// The application object for apps that use vgui -//----------------------------------------------------------------------------- -class CVguiSteamApp : public CTier3SteamApp -{ - typedef CTier3SteamApp BaseClass; - -public: - // Methods of IApplication - virtual bool PreInit() - { - if ( !BaseClass::PreInit() ) - return false; - - CreateInterfaceFn factory = GetFactory(); - return vgui::VGui_InitInterfacesList( "CVguiSteamApp", &factory, 1 ); - } -}; - - -//----------------------------------------------------------------------------- -// The application object for apps that use vgui -//----------------------------------------------------------------------------- -class CVguiDmSteamApp : public CTier3DmSteamApp -{ - typedef CTier3DmSteamApp BaseClass; - -public: - // Methods of IApplication - virtual bool PreInit() - { - if ( !BaseClass::PreInit() ) - return false; - - CreateInterfaceFn factory = GetFactory(); - return vgui::VGui_InitInterfacesList( "CVguiSteamApp", &factory, 1 ); - } -}; - - -#endif // TIER3APP_H +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// $Header: $ +// $NoKeywords: $ +// +// The application objects for apps that use tier3 +//============================================================================= + +#ifndef TIER3APP_H +#define TIER3APP_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "appframework/tier2app.h" +#include "tier3/tier3.h" +#include "vgui_controls/Controls.h" + + +//----------------------------------------------------------------------------- +// The application object for apps that use tier3 +//----------------------------------------------------------------------------- +class CTier3SteamApp : public CTier2SteamApp +{ + typedef CTier2SteamApp BaseClass; + +public: + // Methods of IApplication + virtual bool PreInit() + { + if ( !BaseClass::PreInit() ) + return false; + + CreateInterfaceFn factory = GetFactory(); + ConnectTier3Libraries( &factory, 1 ); + return true; + } + + virtual void PostShutdown() + { + DisconnectTier3Libraries(); + BaseClass::PostShutdown(); + } +}; + + +//----------------------------------------------------------------------------- +// The application object for apps that use tier3 +//----------------------------------------------------------------------------- +class CTier3DmSteamApp : public CTier2DmSteamApp +{ + typedef CTier2DmSteamApp BaseClass; + +public: + // Methods of IApplication + virtual bool PreInit() + { + if ( !BaseClass::PreInit() ) + return false; + + CreateInterfaceFn factory = GetFactory(); + ConnectTier3Libraries( &factory, 1 ); + return true; + } + + virtual void PostShutdown() + { + DisconnectTier3Libraries(); + BaseClass::PostShutdown(); + } +}; + + +//----------------------------------------------------------------------------- +// The application object for apps that use vgui +//----------------------------------------------------------------------------- +class CVguiSteamApp : public CTier3SteamApp +{ + typedef CTier3SteamApp BaseClass; + +public: + // Methods of IApplication + virtual bool PreInit() + { + if ( !BaseClass::PreInit() ) + return false; + + CreateInterfaceFn factory = GetFactory(); + return vgui::VGui_InitInterfacesList( "CVguiSteamApp", &factory, 1 ); + } +}; + + +//----------------------------------------------------------------------------- +// The application object for apps that use vgui +//----------------------------------------------------------------------------- +class CVguiDmSteamApp : public CTier3DmSteamApp +{ + typedef CTier3DmSteamApp BaseClass; + +public: + // Methods of IApplication + virtual bool PreInit() + { + if ( !BaseClass::PreInit() ) + return false; + + CreateInterfaceFn factory = GetFactory(); + return vgui::VGui_InitInterfacesList( "CVguiSteamApp", &factory, 1 ); + } +}; + + +#endif // TIER3APP_H -- cgit v1.2.3