This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

View File

@@ -0,0 +1,228 @@
//===== Copyright © 1996-2005, 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"
#include "ilaunchabledll.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
//-----------------------------------------------------------------------------
// This assumes you've used one of the
#define DEFINE_LAUNCHABLE_DLL_STEAM_APP() \
class CAppLaunchableDLL : public ILaunchableDLL \
{ \
public: \
virtual int main( int argc, char **argv ) \
{ \
return AppMain( argc, argv, &__s_SteamApplicationObject ); \
} \
}; \
static CAppLaunchableDLL __g_AppLaunchableDLL; \
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CAppLaunchableDLL, ILaunchableDLL, LAUNCHABLE_DLL_INTERFACE_VERSION, __g_AppLaunchableDLL );
#if !defined( _X360 )
#if 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( PLATFORM_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
#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \
int __stdcall WinMain( struct HINSTANCE__* hInstance, struct HINSTANCE__* hPrevInstance, NULLTERMINATED char *lpCmdLine, int nCmdShow ) \
{ \
return AppMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow, &_globalVarName ); \
}
#endif
#else
#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \
DLL_EXPORT int AppMain360( struct HINSTANCE__* hInstance, struct HINSTANCE__* hPrevInstance, NULLTERMINATED char *lpCmdLine, int nCmdShow ) \
{ \
return AppMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow, &_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 ) \
DLL_EXPORT int AppMain360( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) \
{ \
return AppMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow, &_globalVarName ); \
}
#endif
#define DEFINE_BINLAUNCHABLE_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \
class CApplicationDLL : public ILaunchableDLL \
{ \
public: \
virtual int main( int argc, char **argv ) \
{ \
return AppMain( argc, argv, &_globalVarName ); \
} \
}; \
EXPOSE_SINGLE_INTERFACE( CApplicationDLL, ILaunchableDLL, LAUNCHABLE_DLL_INTERFACE_VERSION )
#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 )
#define DEFINE_BINLAUNCHABLE_APPLICATION_OBJECT( _className ) \
static _className __s_ApplicationObject; \
DEFINE_BINLAUNCHABLE_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();
public:
// Here's a hook to override the filesystem DLL that it tries to load.
// By default, it uses FileSystem_GetFileSystemDLLName to figure this out.
virtual bool GetFileSystemDLLName( char *pOut, int nMaxBytes, bool &bIsSteam );
protected:
IFileSystem *m_pFileSystem;
CSteamAppSystemGroup *m_pChildAppSystemGroup;
bool m_bSteam;
};
class CBinLaunchableSteamApp : public CSteamApplication
{
public:
CBinLaunchableSteamApp( CSteamAppSystemGroup *pAppSystemGroup ) : CSteamApplication( pAppSystemGroup )
{
}
virtual bool GetFileSystemDLLName( char *pOut, int nMaxChars, bool &bIsSteam )
{
// Our path should already include game\bin, so just use the filename directly
// and don't try to figure out an absolute path to it as CSteamApplication does.
V_strncpy( pOut, "filesystem_stdio", nMaxChars );
bIsSteam = false;
return true;
}
};
//-----------------------------------------------------------------------------
// 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 )
#define DEFINE_BINLAUNCHABLE_STEAM_APPLICATION_OBJECT_GLOBALVAR( _className, _varName ) \
static CBinLaunchableSteamApp __s_SteamApplicationObject( &_varName ); \
DEFINE_BINLAUNCHABLE_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject )
#define DEFINE_BINLAUNCHABLE_STEAM_APPLICATION_OBJECT( _className ) \
static _className __s_ApplicationObject; \
static CBinLaunchableSteamApp __s_SteamApplicationObject( &__s_ApplicationObject ); \
DEFINE_BINLAUNCHABLE_APPLICATION_OBJECT_GLOBALVAR( __s_SteamApplicationObject )
// This defines your steam application object and ties it to your appsystemgroup.
// This does NOT hookup its AppMain to get called. You'll have to call that from startup code
// or use something like DEFINE_LAUNCHABLE_DLL_STEAM_APP() to call it.
//
// _steamApplicationClass derives from CSteamApplication.
// _appClass derives from CAppSystemGroup (.. can derive from - or be - CTier2SteamApp for example).
//
#define DEFINE_CUSTOM_STEAM_APPLICATION_OBJECT( _steamApplicationClassName, _appClassName ) \
static _appClassName __s_ApplicationObject; \
static _steamApplicationClassName __s_SteamApplicationObject( &__s_ApplicationObject );
#endif // APPFRAMEWORK_H

View File

@@ -0,0 +1,302 @@
//======== (C) Copyright 1999, 2000 Valve, L.L.C. 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 "tier1/UtlStringMap.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;
// Allow the application to do some work after AppSystems are initialized but
// before main is run
// Return false if there's any problems and the app will abort
virtual bool PostInit() = 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 PreShutdown() = 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;
};
//-----------------------------------------------------------------------------
// 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,
DEPENDENCIES,
CONNECTION,
PREINITIALIZATION,
INITIALIZATION,
POSTINITIALIZATION,
RUNNING,
PRESHUTDOWN,
SHUTDOWN,
POSTSHUTDOWN,
DISCONNECTION,
DESTRUCTION,
APPSYSTEM_GROUP_STAGE_COUNT,
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();
// Default implementations...
virtual bool PostInit() { return true; }
virtual void PreShutdown() { }
// Returns the stage at which the app system group ran into an error
AppSystemGroupStage_t GetCurrentStage() const;
int ReloadModule( const char * pDLLName );
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 );
// Adds a factory to the system so other stuff can query it. Triggers a connect systems
void AddNonAppSystemFactory( CreateInterfaceFn fn );
// Removes a factory, triggers a disconnect call if it succeeds
void RemoveNonAppSystemFactory( CreateInterfaceFn fn );
// Causes the systems to reconnect to an interface
void ReconnectSystems( const char *pInterfaceName );
// Method to look up a particular named system...
void *FindSystem( const char *pInterfaceName );
// Creates the app window (windowed app only)
virtual void *CreateAppWindow( void *hInstance, const char *pTitle, bool bWindowed, int w, int h, bool bResizing );
void SetAppWindowTitle( void* hWnd, const char *pTitle );
// Gets at a class factory for the topmost appsystem group in an appsystem stack
static CreateInterfaceFn GetFactory();
private:
struct Module_t
{
CSysModule *m_pModule;
CreateInterfaceFn m_Factory;
char *m_pModuleName;
};
typedef CUtlStringMap< CUtlSymbolTable > LibraryDependencies_t;
int OnStartup();
void OnShutdown();
void UnloadAllModules( );
void RemoveAllSystems();
// Method to load all dependent systems
bool LoadDependentSystems();
// 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 ComputeDependencies( LibraryDependencies_t &depend );
void SortDependentLibraries( LibraryDependencies_t &depend );
const char *FindSystemName( int nIndex );
static bool SortLessFunc( const int &left, const int &right );
void ReportStartupFailure( int nErrorStage, int nSysIndex );
CUtlVector<Module_t> m_Modules;
CUtlVector<IAppSystem*> m_Systems;
CUtlVector<CreateInterfaceFn> m_NonAppSystemFactories;
CUtlDict<int, unsigned short> m_SystemDict;
CAppSystemGroup *m_pParentAppSystem;
AppSystemGroupStage_t m_nCurrentStage;
static LibraryDependencies_t *sm_pSortDependencies;
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 bool PostInit() { return true; }
virtual void PreShutdown() { }
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

View File

@@ -0,0 +1,51 @@
//=========== (C) Copyright 1999 Valve, L.L.C. 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/matsysapp.h"
FORWARD_DECLARE_HANDLE( InputContextHandle_t );
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CVguiMatSysApp : public CMatSysApp
{
typedef CMatSysApp BaseClass;
public:
CVguiMatSysApp();
// Methods of IApplication
virtual bool Create();
virtual bool PreInit();
virtual bool PostInit();
virtual void PreShutdown();
virtual void PostShutdown();
virtual void Destroy();
InputContextHandle_t GetAppInputContext();
private:
InputContextHandle_t m_hAppInputContext;
};
#endif // VGUIMATSYSAPP_H

View File

@@ -0,0 +1,123 @@
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: An application framework
//
// $Revision: $
// $NoKeywords: $
//===========================================================================//
#ifndef IAPPSYSTEM_H
#define IAPPSYSTEM_H
#ifdef COMPILER_MSVC
#pragma once
#endif
#include "tier1/interface.h"
#include "interfaces/interfaces.h"
//-----------------------------------------------------------------------------
// Specifies a module + interface name for initialization
//-----------------------------------------------------------------------------
struct AppSystemInfo_t
{
const char *m_pModuleName;
const char *m_pInterfaceName;
};
//-----------------------------------------------------------------------------
// 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,
};
enum AppSystemTier_t
{
APP_SYSTEM_TIER0 = 0,
APP_SYSTEM_TIER1,
APP_SYSTEM_TIER2,
APP_SYSTEM_TIER3,
APP_SYSTEM_TIER_OTHER,
};
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;
// Returns all dependent libraries
virtual const AppSystemInfo_t* GetDependencies() {return NULL;}
// Returns the tier
virtual AppSystemTier_t GetTier() {return APP_SYSTEM_TIER_OTHER;}
// Reconnect to a particular interface
virtual void Reconnect( CreateInterfaceFn factory, const char *pInterfaceName ) {}
// Is this appsystem a singleton? (returns false if there can be multiple instances of this interface)
virtual bool IsSingleton() { return true; }
};
//-----------------------------------------------------------------------------
// 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() {}
virtual const AppSystemInfo_t* GetDependencies() { return NULL; }
virtual AppSystemTier_t GetTier() { return APP_SYSTEM_TIER_OTHER; }
virtual void Reconnect( CreateInterfaceFn factory, const char *pInterfaceName )
{
ReconnectInterface( factory, pInterfaceName );
}
};
//-----------------------------------------------------------------------------
// Helper implementation of an IAppSystem for tier0
//-----------------------------------------------------------------------------
template< class IInterface >
class CTier0AppSystem : public CBaseAppSystem< IInterface >
{
};
#endif // IAPPSYSTEM_H

View File

@@ -0,0 +1,260 @@
//================ Copyright (c) 1996-2009 Valve Corporation. All Rights Reserved. =================
//
//
//
//==================================================================================================
#ifndef ICOCOAMGR_H
#define ICOCOAMGR_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/threadtools.h"
#include "appframework/IAppSystem.h"
#include "glmgr/glmgr.h"
// if you rev this version also update materialsystem/cmaterialsystem.cpp CMaterialSystem::Connect as it defines the string directly
#define COCOAMGR_INTERFACE_VERSION "CocoaMgrInterface006"
enum CocoaEventType_t
{
CocoaEvent_KeyDown,
CocoaEvent_KeyUp,
CocoaEvent_MouseButtonDown,
CocoaEvent_MouseMove,
CocoaEvent_MouseButtonUp,
CocoaEvent_AppActivate,
CocoaEvent_MouseScroll,
CocoaEvent_AppQuit
};
// 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
};
class CShowPixelsParams
{
public:
GLuint m_srcTexName;
int m_width,m_height;
bool m_vsyncEnable;
bool m_fsEnable; // want receiving view to be full screen. for now, just target the main screen. extend later.
bool m_useBlit; // use FBO blit - sending context says it is available.
bool m_noBlit; // the back buffer has already been populated by the caller (perhaps via direct MSAA resolve from multisampled RT tex)
bool m_onlySyncView; // react to full/windowed state change only, do not present bits
};
#define kMaxCrawlFrames 100
#define kMaxCrawlText (kMaxCrawlFrames * 256)
class CStackCrawlParams
{
public:
uint m_frameLimit; // input: max frames to retrieve
uint m_frameCount; // output: frames found
void *m_crawl[kMaxCrawlFrames]; // call site addresses
char *m_crawlNames[kMaxCrawlFrames]; // pointers into text following, one per decoded name
char m_crawlText[kMaxCrawlText];
};
struct GLMRendererInfoFields;
class GLMDisplayDB;
class ICocoaMgr : 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;
// Get the NSWindow*.
// virtual void* GetNSWindow() = 0;
// Get the NSGLContext for a window's main view - note this is the carbon windowref as an argument
virtual PseudoNSGLContextPtr GetNSGLContextForWindow( void* windowref ) = 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;
// Set the mouse cursor position.
virtual void SetCursorPosition( int x, int y ) = 0;
virtual void *GetWindowRef() = 0;
virtual void ShowPixels( CShowPixelsParams *params ) = 0;
virtual void MoveWindow( int x, int y ) = 0;
virtual void SizeWindow( int width, int tall ) = 0;
virtual void PumpWindowsMessageLoop() = 0;
virtual void GetStackCrawl( CStackCrawlParams *params ) = 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 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)
virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) = 0;
virtual GLMDisplayDB *GetDisplayDB( void ) = 0;
virtual void WaitUntilUserInput( int msSleepTime ) = 0;
};
//===============================================================================
// modes, displays, and renderers
// think of renderers as being at the top of a tree.
// each renderer has displays hanging off of it.
// each display has modes hanging off of it.
// the tree is populated on demand and then queried as needed.
//===============================================================================
// GLMDisplayModeInfoFields is in glmdisplay.h
class GLMDisplayMode
{
public:
GLMDisplayModeInfoFields m_info;
GLMDisplayMode( uint width, uint height, uint refreshHz );
~GLMDisplayMode( void );
void Dump( int which );
};
//===============================================================================
// GLMDisplayInfoFields is in glmdisplay.h
class GLMDisplayInfo
{
public:
GLMDisplayInfoFields m_info;
CUtlVector< GLMDisplayMode* > *m_modes; // starts out NULL, set by PopulateModes
GLMDisplayInfo( CGDirectDisplayID displayID, CGOpenGLDisplayMask displayMask );
~GLMDisplayInfo( void );
void PopulateModes( void );
void Dump( int which );
};
//===============================================================================
// GLMRendererInfoFields is in glmdisplay.h
class GLMRendererInfo
{
public:
GLMRendererInfoFields m_info;
CUtlVector< GLMDisplayInfo* > *m_displays; // starts out NULL, set by PopulateDisplays
GLMRendererInfo ( GLMRendererInfoFields *info );
~GLMRendererInfo ( void );
void PopulateDisplays( void );
void Dump( int which );
};
//===============================================================================
// this is just a tuple describing fake adapters which are really renderer/display pairings.
// dxabstract bridges the gap between the d3d adapter-centric world and the GL renderer+display world.
// this makes it straightforward to handle cases like two video cards with two displays on one, and one on the other -
// you get three fake adapters which represent each useful screen.
// the constraint that dxa will have to follow though, is that if the user wants to change their
// display selection for full screen, they would only be able to pick on that has the same underlying renderer.
// can't change fakeAdapter from one to another with different GL renderer under it. Screen hop but no card hop.
struct GLMFakeAdapter
{
int m_rendererIndex;
int m_displayIndex;
};
class GLMDisplayDB
{
public:
CUtlVector< GLMRendererInfo* > *m_renderers; // starts out NULL, set by PopulateRenderers
CUtlVector< GLMFakeAdapter > m_fakeAdapters;
GLMDisplayDB ( void );
~GLMDisplayDB ( void );
virtual void PopulateRenderers( void );
virtual void PopulateFakeAdapters( uint realRendererIndex ); // fake adapters = one real adapter times however many displays are on it
virtual void Populate( void );
// The info-get functions return false on success.
virtual int GetFakeAdapterCount( void );
virtual bool GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut );
virtual int GetRendererCount( void );
virtual bool GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut );
virtual int GetDisplayCount( int rendererIndex );
virtual bool GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut );
virtual int GetModeCount( int rendererIndex, int displayIndex );
virtual bool GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut );
virtual void Dump( void );
};
#endif // ICOCOAMGR_H

View File

@@ -0,0 +1,37 @@
//================ Copyright (c) 1996-2009 Valve Corporation. All Rights Reserved. =================
//
//
//
//==================================================================================================
#ifndef IGLXMGR_H
#define IGLXMGR_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/basetypes.h"
#define GLXMGR_INTERFACE_VERSION "GLXMgrInterface001"
DECLARE_POINTER_HANDLE( GLXMgrContext_t );
class IGLXMgr
{
public:
// Window creation.
// pAttributes are GLX_ attributes that go to glXChooseVisual.
virtual void* CreateWindow( const char *pTitle, bool bWindowed, int width, int height ) = 0;
// GL context management.
virtual GLXMgrContext_t GetMainContext() = 0;
virtual GLXMgrContext_t CreateExtraContext() = 0;
virtual void DeleteContext( GLXMgrContext_t hContext ) = 0;
virtual void MakeContextCurrent( GLXMgrContext_t hContext ) = 0;
};
#endif // IGLXMGR_H

View File

@@ -0,0 +1,183 @@
//================ Copyright (c) 1996-2009 Valve Corporation. All Rights Reserved. =================
//
// ilaunchermgr.h
//
//==================================================================================================
#ifndef ILAUNCHERMGR_H
#define ILAUNCHERMGR_H
#ifdef _WIN32
#pragma once
#endif
#if defined( USE_SDL ) || defined( OSX ) || defined( LINUX )
// Purpose: The overlay doesn't properly work on OS X 64-bit because a bunch of
// Cocoa functions that we hook were never ported to 64-bit. Until that is fixed,
// we basically have to work around this by making sure the cursor is visible
// and set to something that is reasonable for usage in the overlay.
#if ( defined( OSX ) && defined( PLATFORM_64BITS ) && !defined( NO_STEAM ) )
#define WITH_OVERLAY_CURSOR_VISIBILITY_WORKAROUND 1
#endif
#include "tier0/threadtools.h"
#include "appframework/iappsystem.h"
#include "inputsystem/iinputsystem.h"
#include "togl/glmgrbasics.h"
#include "togl/glmdisplay.h"
// if you rev this version also update materialsystem/cmaterialsystem.cpp CMaterialSystem::Connect as it defines the string directly
#if defined( USE_SDL )
#define SDLMGR_INTERFACE_VERSION "SDLMgrInterface001"
#elif defined( OSX )
#define COCOAMGR_INTERFACE_VERSION "CocoaMgrInterface006"
#endif
class GLMDisplayDB;
class CCocoaEvent;
class CShowPixelsParams;
class CStackCrawlParams;
#if defined( USE_SDL )
typedef struct SDL_Cursor SDL_Cursor;
#endif
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.
#ifdef USE_SDL
virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height, bool bDesktopFriendlyFullscreen ) = 0;
#else
virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height ) = 0;
#endif
virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) = 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;
// 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;
// Set the mouse cursor position.
virtual void SetCursorPosition( int x, int y ) = 0;
virtual void ShowPixels( CShowPixelsParams *params ) = 0;
#ifdef USE_SDL
virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight, bool bDesktopFriendlyFullscreen ) = 0;
#else
virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight ) = 0;
#endif
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)
virtual GLMDisplayDB *GetDisplayDB( void ) = 0;
virtual void WaitUntilUserInput( int msSleepTime ) = 0;
virtual PseudoGLContextPtr GetMainContext() = 0;
virtual PseudoGLContextPtr CreateExtraContext() = 0;
virtual void DeleteContext( PseudoGLContextPtr hContext ) = 0;
virtual bool MakeContextCurrent( PseudoGLContextPtr hContext ) = 0;
virtual void GetStackCrawl( CStackCrawlParams *params ) = 0;
virtual void *GetWindowRef() = 0;
virtual void SetMouseVisible( bool bState ) = 0;
#ifdef USE_SDL
virtual int GetActiveDisplayIndex() = 0;
virtual void SetMouseCursor( SDL_Cursor *hCursor ) = 0;
virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) = 0;
virtual void OnFrameRendered() = 0;
#endif
#ifndef OSX
virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) = 0;
#endif
#if WITH_OVERLAY_CURSOR_VISIBILITY_WORKAROUND
virtual void ForceSystemCursorVisible() = 0;
virtual void UnforceSystemCursorVisible() = 0;
#endif
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 ) || defined( OSX ) || defined( LINUX)
#endif // ILAUNCHERMGR_H

View File

@@ -0,0 +1,121 @@
//=========== (C) Copyright 1999 Valve, L.L.C. 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: $
//
// Used for material system apps
//=============================================================================
#ifndef MATERIALSYSTEM2APP_H
#define MATERIALSYSTEM2APP_H
#ifdef _WIN32
#pragma once
#endif
#include "appframework/tier2app.h"
#include "tier0/platwindow.h"
#include "rendersystem/irenderdevice.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
FORWARD_DECLARE_HANDLE( SwapChainHandle_t );
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CMaterialSystem2App : public CTier2SteamApp, public IRenderDeviceSetup
{
typedef CTier2SteamApp BaseClass;
public:
enum RenderSystemDLL_t
{
RENDER_SYSTEM_DX9 = 0,
RENDER_SYSTEM_DX11,
RENDER_SYSTEM_GL,
RENDER_SYSTEM_X360,
};
public:
CMaterialSystem2App();
// Methods of IApplication
virtual bool Create();
virtual bool PreInit();
virtual bool PostInit();
virtual void PreShutdown();
virtual void Destroy();
// Returns the window handle
PlatWindow_t GetAppWindow();
// Gets the render system we're running on
RenderSystemDLL_t GetRenderSystem() const;
// Returns the number of threads our thread pool is using
int GetThreadCount() const;
// Creates a 3D-capable window
SwapChainHandle_t Create3DWindow( const char *pTitle, int nWidth, int nHeight, bool bResizing, bool bFullscreen, bool bAcceptsInput );
protected:
void AppPumpMessages();
// Sets up the game path
bool SetupSearchPaths( const char *pStartingDir, bool bOnlyUseStartingDir, bool bIsTool );
private:
// Inherited from IRenderDeviceSetup
virtual bool CreateRenderDevice();
private:
// Returns the app name
virtual const char *GetAppName() = 0;
virtual bool IsConsoleApp() { return false; }
bool AddRenderSystem();
void ApplyModSettings( );
bool CreateMainWindow( bool bResizing );
bool CreateMainConsoleWindow();
SwapChainHandle_t m_hSwapChain;
int m_nThreadCount;
RenderSystemDLL_t m_nRenderSystem;
CreateInterfaceFn m_RenderFactory;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Gets the render system we're running on
//-----------------------------------------------------------------------------
inline CMaterialSystem2App::RenderSystemDLL_t CMaterialSystem2App::GetRenderSystem() const
{
return m_nRenderSystem;
}
//-----------------------------------------------------------------------------
// Returns the number of threads our thread pool is using
//-----------------------------------------------------------------------------
inline int CMaterialSystem2App::GetThreadCount() const
{
return m_nThreadCount;
}
#endif // MATERIALSYSTEM2APP_H

View File

@@ -0,0 +1,68 @@
//=========== (C) Copyright 1999 Valve, L.L.C. 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: $
//
// Used for material system apps
//=============================================================================
#ifndef MATSYSAPP_H
#define MATSYSAPP_H
#ifdef _WIN32
#pragma once
#endif
#include "appframework/tier2app.h"
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CMatSysApp : public CTier2SteamApp
{
typedef CTier2SteamApp BaseClass;
public:
CMatSysApp();
// 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; }
void *m_HWnd;
int m_nWidth;
int m_nHeight;
};
#endif // MATSYSAPP_H

View File

@@ -0,0 +1,89 @@
//=========== (C) Copyright 1999 Valve, L.L.C. 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();
}
virtual void Destroy()
{
}
};
//-----------------------------------------------------------------------------
// 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

View File

@@ -0,0 +1,121 @@
//=========== (C) Copyright 1999 Valve, L.L.C. 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

View File

@@ -0,0 +1,51 @@
//=========== (C) Copyright 1999 Valve, L.L.C. 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 VGUIMATERIALSYSTEM2APP_H
#define VGUIMATERIALSYSTEM2APP_H
#ifdef _WIN32
#pragma once
#endif
#include "appframework/materialsystem2app.h"
FORWARD_DECLARE_HANDLE( InputContextHandle_t );
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CVGuiMaterialSystem2App : public CMaterialSystem2App
{
typedef CMaterialSystem2App BaseClass;
public:
CVGuiMaterialSystem2App();
// Methods of IApplication
virtual bool Create();
virtual bool PreInit();
virtual bool PostInit();
virtual void PreShutdown();
virtual void PostShutdown();
virtual void Destroy();
InputContextHandle_t GetAppInputContext();
private:
InputContextHandle_t m_hAppInputContext;
};
#endif // VGUIMATERIALSYSTEM2APP_H