This commit is contained in:
FluorescentCIAAfricanAmerican
2020-04-22 12:56:21 -04:00
commit 3bf9df6b27
15370 changed files with 5489726 additions and 0 deletions

View File

@ -0,0 +1,42 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef ATTRIBUTEELEMENTCHOICELIST_H
#define ATTRIBUTEELEMENTCHOICELIST_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/inotifyui.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
//-----------------------------------------------------------------------------
// returns the choice string that AddElementsRecursively would have returned
//-----------------------------------------------------------------------------
const char *GetChoiceString( CDmElement *pElement );
//-----------------------------------------------------------------------------
// Recursively adds all elements of the specified type under pElement into the choice list
//-----------------------------------------------------------------------------
void AddElementsRecursively( CDmElement *pElement, ElementChoiceList_t &list, const char *pElementType = NULL );
//-----------------------------------------------------------------------------
// Recursively adds all elements of the specified type under pElement into the vector
//-----------------------------------------------------------------------------
void AddElementsRecursively( CDmElement *pElement, DmeHandleVec_t &list, const char *pElementType = NULL );
#endif // ATTRIBUTEELEMENTCHOICELIST_H

View File

@ -0,0 +1,326 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Core Movie Maker UI API
//
//=============================================================================
#ifndef BASETOOLSYSTEM_H
#define BASETOOLSYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/interface.h"
#include "toolframework/itoolsystem.h"
#include "vgui/IScheme.h"
#include "vgui_controls/EditablePanel.h"
#include "vgui_controls/PHandle.h"
#include "toolutils/recentfilelist.h"
#include "vgui/keycode.h"
#include "vgui_controls/fileopenstatemachine.h"
// #defines
#define TOGGLE_WINDOWED_KEY_CODE KEY_F11
#define TOGGLE_WINDOWED_KEY_NAME "F11"
#define TOGGLE_INPUT_KEY_CODE KEY_F10
#define TOGGLE_INPUT_KEY_NAME "F10"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class KeyValues;
class CToolUI;
class CToolMenuButton;
class CMiniViewport;
class IGlobalFlexController;
namespace vgui
{
class Panel;
class Menu;
class CKeyBoardEditorDialog;
class CKeyBindingHelpDialog;
enum KeyBindingContextHandle_t;
class IScheme;
}
//-----------------------------------------------------------------------------
// Save document types
//-----------------------------------------------------------------------------
enum SaveDocumentCloseType_t
{
SAVEDOC_QUIT_AFTER_SAVE = 0,
SAVEDOC_CLOSE_AFTER_SAVE,
SAVEDOC_LEAVEOPEN_AFTER_SAVE,
SAVEDOC_POSTCOMMAND_AFTER_SAVE, // Closes, then posts a command
SAVEDOC_LEAVEOPEN_POSTCOMMAND_AFTER_SAVE, // Leaves open, then posts a command
};
//-----------------------------------------------------------------------------
// The toolsystem panel is the main panel in which the tool "ui" lives.
// The tool "ui" encapsulates the main menu and a client area in which the
// tools are drawn.
// Usually, the workspace is the size of the entire screen
// and the ui can be smaller than the toolsystem panel. The reason these are decoupled
// is so that you can get the 'action' menu no matter where you click on the screen
//-----------------------------------------------------------------------------
class CBaseToolSystem : public vgui::EditablePanel, public IToolSystem, public vgui::IFileOpenStateMachineClient
{
DECLARE_CLASS_SIMPLE( CBaseToolSystem, vgui::EditablePanel );
public:
// Methods inherited from IToolSystem
virtual bool Init( );
virtual void Shutdown();
virtual bool ServerInit( CreateInterfaceFn serverFactory );
virtual bool ClientInit( CreateInterfaceFn clientFactory );
virtual void ServerShutdown();
virtual void ClientShutdown();
virtual bool CanQuit();
virtual void PostMessage( HTOOLHANDLE hEntity, KeyValues *message );
virtual void Think( bool finalTick );
virtual void ServerLevelInitPreEntity();
virtual void ServerLevelInitPostEntity();
virtual void ServerLevelShutdownPreEntity();
virtual void ServerLevelShutdownPostEntity();
virtual void ServerFrameUpdatePreEntityThink();
virtual void ServerFrameUpdatePostEntityThink();
virtual void ServerPreClientUpdate();
virtual void ServerPreSetupVisibility();
virtual const char* GetEntityData( const char *pActualEntityData );
virtual void ClientLevelInitPreEntity();
virtual void ClientLevelInitPostEntity();
virtual void ClientLevelShutdownPreEntity();
virtual void ClientLevelShutdownPostEntity();
virtual void ClientPreRender();
virtual void ClientPostRender();
virtual void OnToolActivate();
virtual void OnToolDeactivate();
virtual bool TrapKey( ButtonCode_t key, bool down );
virtual void AdjustEngineViewport( int& x, int& y, int& width, int& height );
virtual bool SetupEngineView( Vector &origin, QAngle &angles, float &fov );
virtual bool SetupAudioState( AudioState_t &audioState );
virtual bool ShouldGameRenderView();
virtual bool IsThirdPersonCamera();
virtual bool IsToolRecording();
virtual IMaterialProxy *LookupProxy( const char *proxyName );
virtual bool GetSoundSpatialization( int iUserData, int guid, SpatializationInfo_t& info );
virtual void HostRunFrameBegin();
virtual void HostRunFrameEnd();
virtual void RenderFrameBegin();
virtual void RenderFrameEnd();
virtual void VGui_PreRender( int paintMode );
virtual void VGui_PostRender( int paintMode );
virtual void VGui_PreSimulate();
virtual void VGui_PostSimulate();
// Inherited from vgui::Panel
virtual void OnMousePressed( vgui::MouseCode code );
virtual void OnThink();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme);
// Inherited from IFileOpenStateMachineClient
virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues ) { Assert(0); }
virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues ) { Assert(0); return false; }
virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues ) { Assert(0); return false; }
MESSAGE_FUNC_INT( OnUnhandledMouseClick, "UnhandledMouseClick", code );
public:
// Other methods
// NOTE: This name here is 'general' strictly so 'general' shows up in the keybinding dialog
CBaseToolSystem( char const *toolName = "#ToolGeneral" );
// Gets the action target to sent to panels so that the tool system's OnCommand is called
vgui::Panel *GetActionTarget();
// Gets at the action menu
vgui::Menu *GetActionMenu();
// Returns the client area
vgui::Panel* GetClientArea();
// Adds a menu button to the main menu bar
void AddMenuButton( CToolMenuButton *pMenuButton );
// Returns the current map name
char const *MapName() const;
// Derived classes implement this to create an action menu
// that appears if you right-click in the tool workspace
virtual vgui::Menu *CreateActionMenu( vgui::Panel *pParent ) { return NULL; }
// Derived classes implement this to create a custom menubar
virtual vgui::MenuBar *CreateMenuBar( CBaseToolSystem *pParent );
// Derived classes implement this to create status bar, can return NULL for no status bar in tool...
virtual vgui::Panel *CreateStatusBar( vgui::Panel *pParent );
virtual CMiniViewport *CreateMiniViewport( vgui::Panel *parent );
virtual void UpdateMenu( vgui::Menu *menu );
virtual void ShowMiniViewport( bool state );
void SetMiniViewportBounds( int x, int y, int width, int height );
void SetMiniViewportText( const char *pText );
void GetMiniViewportEngineBounds( int &x, int &y, int &width, int &height );
vgui::Panel *GetMiniViewport( void );
virtual void ComputeMenuBarTitle( char *buf, size_t buflen );
// Usage mode
void SetMode( bool bGameInputEnabled, bool bFullscreen );
bool IsFullscreen() const;
bool IsGameInputEnabled() const;
void EnableFullscreenToolMode( bool bEnable );
// Is this the active tool?
bool IsActiveTool( ) const;
// Returns the tool that had focus most recently
Panel *GetMostRecentlyFocusedTool();
void PostMessageToAllTools( KeyValues *message );
protected:
virtual void PaintBackground();
// Derived classes must implement this to specify where in the
// registry to store registry settings
virtual const char *GetRegistryName() = 0;
// Derived classes must return the key bindings context
virtual const char *GetBindingsContextFile() = 0;
// Derived classes implement this to do stuff when the tool is shown or hidden
virtual void OnModeChanged() {}
// Derived classes can implement this to get a new scheme to be applied to this tool
virtual vgui::HScheme GetToolScheme() { return 0; }
// Derived classes can implement this to get notified when files are saved/loaded
virtual void OnFileOperationCompleted( const char *pFileType, bool bWroteFile, vgui::FileOpenStateMachine::CompletionState_t state, KeyValues *pContextKeyValues ) {}
// Used to open a specified file, and deal with all the lovely dialogs
void OpenFile( const char *pOpenFileType, const char *pSaveFileName = NULL, const char *pSaveFileType = NULL, int nFlags = 0, KeyValues *pKeyValues = NULL );
void OpenFile( const char *pOpenFileName, const char *pOpenFileType, const char *pSaveFileName = NULL, const char *pSaveFileType = NULL, int nFlags = 0, KeyValues *pKeyValues = NULL );
// Used to save a specified file, and deal with all the lovely dialogs
// Pass in NULL to get a dialog to choose a filename to save
// Posts the keyvalues
void SaveFile( const char *pFileName, const char *pFileType, int nFlags, KeyValues *pKeyValues = NULL );
KEYBINDING_FUNC_NODECLARE( editkeybindings, KEY_E, vgui::MODIFIER_SHIFT | vgui::MODIFIER_CONTROL | vgui::MODIFIER_ALT, OnEditKeyBindings, "#editkeybindings_help", 0 );
KEYBINDING_FUNC( keybindinghelp, KEY_H, 0, OnKeyBindingHelp, "#keybindinghelp_help", 0 );
virtual char const *GetBackgroundTextureName();
virtual char const *GetLogoTextureName() = 0;
virtual bool HasDocument();
virtual void ToggleForceToolCamera();
// Shows, hides the tool ui (menu, client area, status bar)
void SetToolUIVisible( bool bVisible );
// Deals with keybindings
void LoadKeyBindings();
void ShowKeyBindingsEditor( vgui::Panel *panel, vgui::KeyBindingContextHandle_t handle );
void ShowKeyBindingsHelp( vgui::Panel *panel, vgui::KeyBindingContextHandle_t handle, vgui::KeyCode boundKey, int modifiers );
vgui::KeyBindingContextHandle_t GetKeyBindingsHandle();
// Registers tool window
void RegisterToolWindow( vgui::PHandle hPanel );
void UnregisterAllToolWindows();
void PostMessageToActiveTool( char const *msg, float delay = 0.0f );
void PostMessageToActiveTool( KeyValues *pKeyValues, float flDelay = 0.0f );
protected:
// Recent file list
CRecentFileList m_RecentFiles;
private:
// Shows/hides the tool
bool ShowUI( bool bVisible );
// Updates UI visibility
void UpdateUIVisibility();
// Create, destroy action menu
void InitActionMenu();
void ShutdownActionMenu();
// Positions the action menu when it's time to pop it up
void PositionActionMenu();
// Messages related to saving a file
MESSAGE_FUNC_PARAMS( OnFileStateMachineFinished, "FileStateMachineFinished", kv );
// Handlers for standard menus
MESSAGE_FUNC( OnClearRecent, "OnClearRecent" );
MESSAGE_FUNC( OnEditKeyBindings, "OnEditKeyBindings" );
// The root toolsystem panel which should cover the entire screen
// here to allow us to do action menus anywhere
// The tool UI
CToolUI *m_pToolUI;
// The action menu
vgui::DHANDLE<vgui::Menu> m_hActionMenu;
bool m_bGameInputEnabled;
bool m_bFullscreenMode;
bool m_bIsActive;
bool m_bFullscreenToolModeEnabled;
vgui::DHANDLE< CMiniViewport > m_hMiniViewport;
vgui::FileOpenStateMachine *m_pFileOpenStateMachine;
IMaterial *m_pBackground;
IMaterial *m_pLogo;
// Keybindings
vgui::KeyBindingContextHandle_t m_KeyBindingsHandle;
vgui::DHANDLE< vgui::CKeyBoardEditorDialog > m_hKeyBindingsEditor;
vgui::DHANDLE< vgui::CKeyBindingHelpDialog > m_hKeyBindingsHelp;
CUtlVector< vgui::PHandle > m_Tools;
vgui::PHandle m_MostRecentlyFocused;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Is this the active tool?
//-----------------------------------------------------------------------------
inline bool CBaseToolSystem::IsActiveTool( ) const
{
return m_bIsActive;
}
//-----------------------------------------------------------------------------
// Mode query
//-----------------------------------------------------------------------------
inline bool CBaseToolSystem::IsFullscreen( ) const
{
return m_bFullscreenMode;
}
inline bool CBaseToolSystem::IsGameInputEnabled() const
{
// NOTE: IsActive check here is a little bogus.
// It's necessary to get the IFM to play nice with other tools, though.
// Is there a better way of doing it?
return m_bGameInputEnabled || !m_bIsActive;
}
#endif // BASETOOLSYSTEM_H

View File

@ -0,0 +1,34 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef CONSOLEPAGE_H
#define CONSOLEPAGE_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/consoledialog.h"
//-----------------------------------------------------------------------------
// Purpose: Game/dev console dialog
//-----------------------------------------------------------------------------
class CConsolePage : public vgui::CConsolePanel
{
DECLARE_CLASS_SIMPLE( CConsolePage, vgui::CConsolePanel );
public:
CConsolePage( Panel *parent, bool bStatusVersion );
private:
MESSAGE_FUNC_CHARPTR( OnCommandSubmitted, "CommandSubmitted", command );
// vgui overrides
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
};
#endif // CONSOLEPAGE_H

View File

@ -0,0 +1,171 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Decorator class to make a DME renderable as a MDL
//
//===========================================================================//
#ifndef DMEMDLRENDERABLE_H
#define DMEMDLRENDERABLE_H
#ifdef _WIN32
#pragma once
#endif
#include "toolutils/dmerenderable.h"
#include "movieobjects/dmemdl.h"
#include "movieobjects/dmetransform.h"
#include "datacache/imdlcache.h"
#include "mathlib/mathlib.h"
#include "datamodel/dmehandle.h"
#include "toolutils/enginetools_int.h"
#include "materialsystem/imaterialsystemhardwareconfig.h"
#include "tier3/tier3.h"
//-----------------------------------------------------------------------------
// Deals with the base implementation for turning a Dme into a renderable
//-----------------------------------------------------------------------------
template < class T >
class CDmeMdlRenderable : public CDmeRenderable< T >
{
DEFINE_UNINSTANCEABLE_ELEMENT( CDmeMdlRenderable, CDmeRenderable< T > );
// IClientUnknown implementation.
public:
virtual int GetBody();
virtual int GetSkin();
virtual int DrawModel( int flags );
virtual void GetRenderBounds( Vector& mins, Vector& maxs );
void SetModelName( const char *pMDLName );
protected:
CDmeMDL *GetMDL() { return m_hMDL; }
private:
void SetUpLighting( const Vector &vecCenter );
CDmeHandle<CDmeMDL> m_hMDL;
CDmeHandle<CDmeTransform> m_hTransform;
};
//-----------------------------------------------------------------------------
// Construction, destruction
//-----------------------------------------------------------------------------
template < class T >
void CDmeMdlRenderable<T>::OnConstruction()
{
m_hMDL = CreateElement<CDmeMDL>( "MDLRenderable", GetFileId() );
m_hTransform = CreateElement<CDmeTransform>( "MDLTransform", GetFileId() );
}
template < class T >
void CDmeMdlRenderable<T>::OnDestruction()
{
g_pDataModel->DestroyElement( m_hMDL );
g_pDataModel->DestroyElement( m_hTransform );
}
template < class T >
int CDmeMdlRenderable<T>::GetBody()
{
return m_hMDL->m_nBody;
}
template < class T >
int CDmeMdlRenderable<T>::GetSkin()
{
return m_hMDL->m_nSkin;
}
template < class T >
int CDmeMdlRenderable<T>::DrawModel( int flags )
{
matrix3x4_t mat;
AngleMatrix( GetRenderAngles(), GetRenderOrigin(), mat );
m_hTransform->SetTransform( mat );
m_hMDL->m_flTime = Plat_FloatTime();
SetUpLighting( GetRenderOrigin() );
bool bIsDrawingInEngine = m_hMDL->IsDrawingInEngine();
m_hMDL->DrawInEngine( true );
m_hMDL->Draw( mat );
m_hMDL->DrawInEngine( bIsDrawingInEngine );
return 1;
}
template < class T >
void CDmeMdlRenderable<T>::GetRenderBounds( Vector& mins, Vector& maxs )
{
m_hMDL->GetBoundingBox( &mins, &maxs );
}
template < class T >
void CDmeMdlRenderable<T>::SetModelName( const char *pMDLRelativePath )
{
if ( pMDLRelativePath )
{
MDLHandle_t hMdl = g_pMDLCache->FindMDL( pMDLRelativePath );
m_hMDL->SetMDL( hMdl );
}
else
{
m_hMDL->SetMDL( MDLHANDLE_INVALID );
}
}
//-----------------------------------------------------------------------------
// Set up lighting conditions
//-----------------------------------------------------------------------------
template < class T >
void CDmeMdlRenderable<T>::SetUpLighting( const Vector &vecCenter )
{
// Set up lighting conditions
Vector vecAmbient[6];
Vector4D vecAmbient4D[6];
LightDesc_t desc[2];
int nLightCount = enginetools->GetLightingConditions( vecCenter, vecAmbient, 2, desc );
int nMaxLights = g_pMaterialSystemHardwareConfig->MaxNumLights();
if( nLightCount > nMaxLights )
{
nLightCount = nMaxLights;
}
int i;
for( i = 0; i < 6; i++ )
{
VectorCopy( vecAmbient[i], vecAmbient4D[i].AsVector3D() );
vecAmbient4D[i][3] = 1.0f;
}
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
pRenderContext->SetAmbientLightCube( vecAmbient4D );
for( i = 0; i < nLightCount; i++ )
{
LightDesc_t *pLight = &desc[i];
pLight->m_Flags = 0;
if( pLight->m_Attenuation0 != 0.0f )
{
pLight->m_Flags |= LIGHTTYPE_OPTIMIZATIONFLAGS_HAS_ATTENUATION0;
}
if( pLight->m_Attenuation1 != 0.0f )
{
pLight->m_Flags |= LIGHTTYPE_OPTIMIZATIONFLAGS_HAS_ATTENUATION1;
}
if( pLight->m_Attenuation2 != 0.0f )
{
pLight->m_Flags |= LIGHTTYPE_OPTIMIZATIONFLAGS_HAS_ATTENUATION2;
}
pRenderContext->SetLight( i, desc[i] );
}
for( ; i < nMaxLights; i++ )
{
LightDesc_t disableDesc;
disableDesc.m_Type = MATERIAL_LIGHT_DISABLE;
pRenderContext->SetLight( i, disableDesc );
}
}
#endif // DMEMDLRENDERABLE_H

View File

@ -0,0 +1,340 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Base decorator class to make a DME renderable
//
//===========================================================================//
#ifndef DMERENDERABLE_H
#define DMERENDERABLE_H
#ifdef _WIN32
#pragma once
#endif
#include "iclientunknown.h"
#include "iclientrenderable.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmattributevar.h"
#include "mathlib/mathlib.h"
#include "basehandle.h"
#include "toolutils/enginetools_int.h"
#include "engine/iclientleafsystem.h"
#include "datamodel/dmelementfactoryhelper.h"
//-----------------------------------------------------------------------------
// Deals with the base implementation for turning a Dme into a renderable
//-----------------------------------------------------------------------------
template < class T >
class CDmeRenderable : public T, public IClientUnknown, public IClientRenderable
{
DEFINE_UNINSTANCEABLE_ELEMENT( CDmeRenderable, T );
protected:
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
// IClientUnknown implementation.
public:
virtual void SetRefEHandle( const CBaseHandle &handle );
virtual const CBaseHandle& GetRefEHandle() const;
virtual IClientUnknown* GetIClientUnknown() { return this; }
virtual ICollideable* GetCollideable() { return 0; }
virtual IClientRenderable* GetClientRenderable() { return this; }
virtual IClientNetworkable* GetClientNetworkable() { return 0; }
virtual IClientEntity* GetIClientEntity() { return 0; }
virtual C_BaseEntity* GetBaseEntity() { return 0; }
virtual IClientThinkable* GetClientThinkable() { return 0; }
// virtual const Vector & GetRenderOrigin( void ) { return vec3_origin; }
// virtual const QAngle & GetRenderAngles( void ) { return vec3_angle; }
virtual bool ShouldDraw( void ) { return false; }
virtual bool IsTransparent( void ) { return false; }
virtual bool IsTwoPass( void ) { return false; }
virtual void OnThreadedDrawSetup() {}
virtual bool UsesPowerOfTwoFrameBufferTexture() { return false; }
virtual bool UsesFullFrameBufferTexture() { return false; }
virtual ClientShadowHandle_t GetShadowHandle() const;
virtual ClientRenderHandle_t& RenderHandle();
virtual int GetBody() { return 0; }
virtual int GetSkin() { return 0; }
virtual const model_t* GetModel( ) const { return NULL; }
// virtual int DrawModel( int flags );
virtual void ComputeFxBlend( ) { return; }
virtual int GetFxBlend( ) { return 255; }
virtual bool LODTest() { return true; }
virtual bool SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime ) { return true; }
virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights ) {}
virtual bool UsesFlexDelayedWeights() { return false; }
virtual void DoAnimationEvents( void ) {}
virtual IPVSNotify* GetPVSNotifyInterface() { return NULL; }
virtual void GetRenderBoundsWorldspace( Vector& absMins, Vector& absMaxs );
virtual void GetColorModulation( float* color );
// virtual void GetRenderBounds( Vector& mins, Vector& maxs );
virtual bool ShouldReceiveProjectedTextures( int flags ) { return false; }
virtual bool GetShadowCastDistance( float *pDist, ShadowType_t shadowType ) const { return false; }
virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const { return false; }
virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
virtual bool IsShadowDirty( ) { return false; }
virtual void MarkShadowDirty( bool bDirty ) {}
virtual IClientRenderable *GetShadowParent() { return NULL; }
virtual IClientRenderable *FirstShadowChild(){ return NULL; }
virtual IClientRenderable *NextShadowPeer() { return NULL; }
virtual ShadowType_t ShadowCastType() { return SHADOWS_NONE; }
virtual void CreateModelInstance() {}
virtual ModelInstanceHandle_t GetModelInstance() { return MODEL_INSTANCE_INVALID; }
virtual const matrix3x4_t &RenderableToWorldTransform();
virtual int LookupAttachment( const char *pAttachmentName ) { return -1; }
virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
virtual bool GetAttachment( int number, matrix3x4_t &matrix );
virtual float *GetRenderClipPlane() { return NULL; }
virtual void RecordToolMessage() {}
virtual bool IgnoresZBuffer( void ) const { return false; }
// Add/remove to engine from drawing
void DrawInEngine( bool bDrawInEngine );
bool IsDrawingInEngine() const;
protected:
virtual CDmAttribute* GetVisibilityAttribute() { return NULL; }
virtual CDmAttribute* GetDrawnInEngineAttribute() { return m_bWantsToBeDrawnInEngine.GetAttribute(); }
Vector m_vecRenderOrigin;
QAngle m_angRenderAngles;
protected:
CDmaVar<bool> m_bWantsToBeDrawnInEngine;
bool m_bIsDrawingInEngine;
CBaseHandle m_RefEHandle; // Reference ehandle. Used to generate ehandles off this entity.
ClientRenderHandle_t m_hRenderHandle;
};
//-----------------------------------------------------------------------------
// Construction, destruction
//-----------------------------------------------------------------------------
template < class T >
void CDmeRenderable<T>::OnConstruction()
{
m_hRenderHandle = INVALID_CLIENT_RENDER_HANDLE;
m_bWantsToBeDrawnInEngine.InitAndSet( this, "wantsToBeDrawnInEngine", false, FATTRIB_DONTSAVE | FATTRIB_HAS_CALLBACK );
m_bIsDrawingInEngine = false;
}
template < class T >
void CDmeRenderable<T>::OnDestruction()
{
if ( m_bIsDrawingInEngine )
{
if ( clienttools )
{
clienttools->RemoveClientRenderable( this );
}
m_bIsDrawingInEngine = false;
}
}
//-----------------------------------------------------------------------------
// EHandles
//-----------------------------------------------------------------------------
template < class T >
void CDmeRenderable<T>::SetRefEHandle( const CBaseHandle &handle )
{
m_RefEHandle = handle;
}
template < class T >
const CBaseHandle& CDmeRenderable<T>::GetRefEHandle() const
{
return m_RefEHandle;
}
//-----------------------------------------------------------------------------
// Add/remove to engine from drawing
//-----------------------------------------------------------------------------
template < class T >
void CDmeRenderable<T>::DrawInEngine( bool bDrawInEngine )
{
m_bWantsToBeDrawnInEngine = bDrawInEngine;
}
template < class T >
bool CDmeRenderable<T>::IsDrawingInEngine() const
{
return m_bIsDrawingInEngine;
}
//-----------------------------------------------------------------------------
// Called when attributes changed
//-----------------------------------------------------------------------------
template < class T >
void CDmeRenderable<T>::OnAttributeChanged( CDmAttribute *pAttribute )
{
T::OnAttributeChanged( pAttribute );
CDmAttribute *pVisibilityAttribute = GetVisibilityAttribute();
if ( pAttribute == pVisibilityAttribute || pAttribute == m_bWantsToBeDrawnInEngine.GetAttribute() )
{
bool bIsVisible = pVisibilityAttribute ? pVisibilityAttribute->GetValue<bool>() : true;
bool bShouldDrawInEngine = m_bWantsToBeDrawnInEngine && bIsVisible;
if ( m_bIsDrawingInEngine != bShouldDrawInEngine )
{
m_bIsDrawingInEngine = bShouldDrawInEngine;
if ( clienttools )
{
if ( m_bIsDrawingInEngine )
{
clienttools->AddClientRenderable( this, IsTransparent() ? RENDER_GROUP_TRANSLUCENT_ENTITY : RENDER_GROUP_OPAQUE_ENTITY );
}
else
{
clienttools->RemoveClientRenderable( this );
}
}
}
}
}
//-----------------------------------------------------------------------------
// Color modulation
//-----------------------------------------------------------------------------
template < class T >
void CDmeRenderable<T>::GetColorModulation( float* color )
{
Assert(color);
color[0] = color[1] = color[2] = 1.0f;
}
//-----------------------------------------------------------------------------
// Attachments
//-----------------------------------------------------------------------------
template < class T >
bool CDmeRenderable<T>::GetAttachment( int number, Vector &origin, QAngle &angles )
{
origin = GetRenderOrigin();
angles = GetRenderAngles();
return true;
}
template < class T >
bool CDmeRenderable<T>::GetAttachment( int number, matrix3x4_t &matrix )
{
MatrixCopy( RenderableToWorldTransform(), matrix );
return true;
}
//-----------------------------------------------------------------------------
// Other methods
//-----------------------------------------------------------------------------
template < class T >
void CDmeRenderable<T>::GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType )
{
GetRenderBounds( mins, maxs );
}
template < class T >
inline ClientShadowHandle_t CDmeRenderable<T>::GetShadowHandle() const
{
return CLIENTSHADOW_INVALID_HANDLE;
}
template < class T >
inline ClientRenderHandle_t& CDmeRenderable<T>::RenderHandle()
{
return m_hRenderHandle;
}
template < class T >
void CDmeRenderable<T>::GetRenderBoundsWorldspace( Vector& absMins, Vector& absMaxs )
{
Vector mins, maxs;
GetRenderBounds( mins, maxs );
// FIXME: Should I just use a sphere here?
// Another option is to pass the OBB down the tree; makes for a better fit
// Generate a world-aligned AABB
const QAngle& angles = GetRenderAngles();
const Vector& origin = GetRenderOrigin();
if ( angles == vec3_angle )
{
VectorAdd( mins, origin, absMins );
VectorAdd( maxs, origin, absMaxs );
}
else
{
matrix3x4_t boxToWorld;
AngleMatrix( angles, origin, boxToWorld );
TransformAABB( boxToWorld, mins, maxs, absMins, absMaxs );
}
Assert( absMins.IsValid() && absMaxs.IsValid() );
}
template < class T >
const matrix3x4_t &CDmeRenderable<T>::RenderableToWorldTransform()
{
static matrix3x4_t mat;
AngleMatrix( GetRenderAngles(), GetRenderOrigin(), mat );
return mat;
}
//-----------------------------------------------------------------------------
// Adds a 'visibility' attribute onto renderables that need it
//-----------------------------------------------------------------------------
template < class T >
class CDmeVisibilityControl : public T
{
DEFINE_UNINSTANCEABLE_ELEMENT( CDmeVisibilityControl, T );
public:
// Control visibility
bool IsVisible() const;
void SetVisible( bool bVisible );
private:
virtual CDmAttribute* GetVisibilityAttribute() { return m_bIsVisible.GetAttribute(); }
CDmaVar< bool > m_bIsVisible;
};
//-----------------------------------------------------------------------------
// Construction, destruction
//-----------------------------------------------------------------------------
template < class T >
void CDmeVisibilityControl<T>::OnConstruction()
{
m_bIsVisible.InitAndSet( this, "visible", true, FATTRIB_HAS_CALLBACK );
}
template < class T >
void CDmeVisibilityControl<T>::OnDestruction()
{
}
//-----------------------------------------------------------------------------
// Deal with visibility
//-----------------------------------------------------------------------------
template < class T >
void CDmeVisibilityControl<T>::SetVisible( bool bVisible )
{
if ( bVisible != m_bIsVisible )
{
m_bIsVisible = bVisible;
}
}
template < class T >
bool CDmeVisibilityControl<T>::IsVisible() const
{
return m_bIsVisible;
}
#endif // DMERENDERABLE_H

View File

@ -0,0 +1,35 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Standard file menu
//
//=============================================================================
#ifndef TOOLEDITMENUBUTTON_H
#define TOOLEDITMENUBUTTON_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
}
class CToolMenuButton;
//-----------------------------------------------------------------------------
// Global function to create the switch menu
//-----------------------------------------------------------------------------
CToolMenuButton* CreateToolEditMenuButton( vgui::Panel *parent, const char *panelName,
const char *text, vgui::Panel *pActionTarget );
#endif // TOOLEDITMENUBUTTON_H

View File

@ -0,0 +1,104 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Standard file menu
//
//=============================================================================
#ifndef TOOLFILEMENUBUTTON_H
#define TOOLFILEMENUBUTTON_H
#ifdef _WIN32
#pragma once
#endif
#include "toolutils/toolmenubutton.h"
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
class Menu;
}
class CToolMenuButton;
//-----------------------------------------------------------------------------
// Called back by the file menu
//-----------------------------------------------------------------------------
class IFileMenuCallbacks
{
public:
enum MenuItems_t
{
FILE_NEW = 0x01,
FILE_OPEN = 0x02,
FILE_SAVE = 0x04,
FILE_SAVEAS = 0x08,
FILE_CLOSE = 0x10,
FILE_RECENT = 0x20,
FILE_CLEAR_RECENT = 0x40,
FILE_EXIT = 0x80,
FILE_ALL = 0xFFFFFFFF
};
// Logically OR together all items that should be enabled
virtual int GetFileMenuItemsEnabled( ) = 0;
// Add recent files to the menu passed in
virtual void AddRecentFilesToMenu( vgui::Menu *menu ) = 0;
// Get the perforce file name (to set the various perforce menu options)
virtual bool GetPerforceFileName( char *pFileName, int nMaxLen ) = 0;
// Gets the root vgui panel
virtual vgui::Panel *GetRootPanel() = 0;
};
//-----------------------------------------------------------------------------
// Standard file menu
//-----------------------------------------------------------------------------
class CToolFileMenuButton : public CToolMenuButton
{
DECLARE_CLASS_SIMPLE( CToolFileMenuButton, CToolMenuButton );
public:
CToolFileMenuButton( vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *pActionTarget, IFileMenuCallbacks *pFileMenuCallback );
virtual void OnShowMenu( vgui::Menu *menu );
private:
MESSAGE_FUNC( OnPerforceAdd, "OnPerforceAdd" );
MESSAGE_FUNC( OnPerforceOpen, "OnPerforceOpen" );
MESSAGE_FUNC( OnPerforceRevert, "OnPerforceRevert" );
MESSAGE_FUNC( OnPerforceSubmit, "OnPerforceSubmit" );
MESSAGE_FUNC( OnPerforceP4Win, "OnPerforceP4Win" );
MESSAGE_FUNC( OnPerforceListOpenFiles, "OnPerforceListOpenFiles" );
vgui::Menu *m_pRecentFiles;
vgui::Menu *m_pPerforce;
int m_nRecentFiles;
IFileMenuCallbacks *m_pFileMenuCallback;
int m_nPerforceAdd;
int m_nPerforceOpen;
int m_nPerforceRevert;
int m_nPerforceSubmit;
int m_nPerforceP4Win;
int m_nPerforceListOpenFiles;
};
//-----------------------------------------------------------------------------
// Global function to create the switch menu
//-----------------------------------------------------------------------------
CToolMenuButton* CreateToolFileMenuButton( vgui::Panel *parent, const char *panelName,
const char *text, vgui::Panel *pActionTarget, IFileMenuCallbacks *pCallbacks );
#endif // TOOLFILEMENUBUTTON_H

View File

@ -0,0 +1,32 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Core Movie Maker UI API
//
//=============================================================================
#ifndef TOOLHELPMENUBUTTON_H
#define TOOLHELPMENUBUTTON_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
}
class CToolMenuButton;
//-----------------------------------------------------------------------------
// Global function to create the switch menu
//-----------------------------------------------------------------------------
CToolMenuButton* CreateToolHelpMenuButton( char const *toolName, char const *helpBinding, vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *pActionTarget );
#endif // TOOLHELPMENUBUTTON_H

View File

@ -0,0 +1,75 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Core Movie Maker UI API
//
//=============================================================================
#ifndef TOOLMENUBUTTON_H
#define TOOLMENUBUTTON_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/menubutton.h"
#include "tier1/utldict.h"
#include "tier1/utlsymbol.h"
//-----------------------------------------------------------------------------
// Base class for tools menus
//-----------------------------------------------------------------------------
class CToolMenuButton : public vgui::MenuButton
{
DECLARE_CLASS_SIMPLE( CToolMenuButton, vgui::MenuButton );
public:
CToolMenuButton( vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *actionTarget );
virtual void OnShowMenu(vgui::Menu *menu);
vgui::Menu *GetMenu();
// Add a simple text item to the menu
virtual int AddMenuItem( char const *itemName, const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
virtual int AddCheckableMenuItem( char const *itemName, const char *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
// Wide-character version to add a simple text item to the menu
virtual int AddMenuItem( char const *itemName, const wchar_t *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
virtual int AddCheckableMenuItem( char const *itemName, const wchar_t *itemText, KeyValues *message, Panel *target, const KeyValues *userData = NULL, char const *kbcommandname = NULL );
virtual int FindMenuItem( char const *itemName );
virtual void AddSeparatorAfterItem( char const *itemName );
virtual void MoveMenuItem( int itemID, int moveBeforeThisItemID );
virtual void SetItemEnabled( int itemID, bool state );
// Pass in a NULL binding to clear it
virtual void SetCurrentKeyBindingLabel( char const *itemName, char const *binding );
virtual void AddSeparator();
void Reset();
protected:
void UpdateMenuItemKeyBindings();
vgui::Menu *m_pMenu;
vgui::Panel *m_pActionTarget;
struct MenuItem_t
{
MenuItem_t()
: m_ItemID( 0 ),
m_KeyBinding( UTL_INVAL_SYMBOL )
{
}
unsigned short m_ItemID;
CUtlSymbol m_KeyBinding;
};
CUtlDict< MenuItem_t, unsigned short > m_Items;
};
#endif // TOOLMENUBUTTON_H

View File

@ -0,0 +1,32 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Core Movie Maker UI API
//
//=============================================================================
#ifndef TOOLSWITCHMENUBUTTON_H
#define TOOLSWITCHMENUBUTTON_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
}
class CToolMenuButton;
//-----------------------------------------------------------------------------
// Global function to create the switch menu
//-----------------------------------------------------------------------------
CToolMenuButton* CreateToolSwitchMenuButton( vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *pActionTarget );
#endif // TOOLSWITCHMENUBUTTON_H

View File

@ -0,0 +1,27 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef BASEPROPERTIESCONTAINER_H
#define BASEPROPERTIESCONTAINER_H
#ifdef _WIN32
#pragma once
#endif
#include "dme_controls/ElementPropertiesTree.h"
class CBasePropertiesContainer : public CElementPropertiesTreeInternal
{
DECLARE_CLASS_SIMPLE( CBasePropertiesContainer, CElementPropertiesTreeInternal);
public:
CBasePropertiesContainer( vgui::Panel *parent, IDmNotify *pNotify, CDmeEditorTypeDictionary *pDict = NULL );
virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
virtual void OnPanelDropped( CUtlVector< KeyValues * >& msglist );
};
#endif // BASEPROPERTIESCONTAINER_H

View File

@ -0,0 +1,45 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef BASESTATUSBAR_H
#define BASESTATUSBAR_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/EditablePanel.h"
#include "datamodel/dmehandle.h"
class CDmeClip;
class CMovieDoc;
class CConsolePage;
namespace vgui
{
class Label;
}
class CBaseStatusBar : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CBaseStatusBar, vgui::EditablePanel )
public:
CBaseStatusBar( vgui::Panel *parent, char const *panelName );
private:
void UpdateMemoryUsage( float mbUsed );
virtual void PerformLayout();
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
virtual void OnThink();
CConsolePage *m_pConsole;
vgui::Label *m_pLabel;
vgui::Label *m_pMemory;
vgui::Label *m_pFPS;
vgui::Label *m_pGameTime;
float m_flLastFPSSnapShot;
};
#endif // BASESTATUSBAR_H

View File

@ -0,0 +1,41 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef ENGINETOOLS_INT_H
#define ENGINETOOLS_INT_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IEngineTool;
class IEngineVGui;
class IServerTools;
class IClientTools;
class IFileSystem;
class IP4;
class IVDebugOverlay;
class IDmSerializers;
//-----------------------------------------------------------------------------
// Singleton interfaces
//-----------------------------------------------------------------------------
extern IEngineTool *enginetools;
extern IEngineVGui *enginevgui;
extern IServerTools *servertools;
extern IClientTools *clienttools;
extern IFileSystem *g_pFileSystem;
extern IP4 *p4;
extern IVDebugOverlay *debugoverlay;
extern IDmSerializers *dmserializers;
#endif // ENGINETOOLS_INT_H

View File

@ -0,0 +1,43 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef MINIVIEWPORT_H
#define MINIVIEWPORT_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/ToolWindow.h"
class CMiniViewportPropertyPage;
class CMiniViewport : public vgui::ToolWindow
{
DECLARE_CLASS_SIMPLE( CMiniViewport, vgui::ToolWindow );
public:
CMiniViewport( vgui::Panel *parent,
bool contextLabel,
vgui::IToolWindowFactory *factory = 0,
vgui::Panel *page = NULL,
char const *title = NULL,
bool contextMenu = false );
void GetViewport( bool& enabled, int& x, int& y, int& width, int& height );
void GetEngineBounds( int& x, int& y, int& w, int& h );
void RenderFrameBegin();
// Sets text to draw over the window
void SetOverlayText( const char *pText );
void ReleaseLayoffTexture();
private:
vgui::DHANDLE< CMiniViewportPropertyPage > m_hPage;
};
#endif // MINIVIEWPORT_H

View File

@ -0,0 +1,81 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Class that contains a list of recent files
//
//=============================================================================
#ifndef RECENTFILELIST_H
#define RECENTFILELIST_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlvector.h"
#include "tier1/utlstring.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Menu;
class Panel;
}
//-----------------------------------------------------------------------------
// Max # of recent files
//-----------------------------------------------------------------------------
#define MAX_RECENT_FILES 20
//-----------------------------------------------------------------------------
// Class that contains a list of recent files
//-----------------------------------------------------------------------------
class CRecentFileList
{
public:
// Adds a file to the list
void Add( const char *pFileName, const char *pFileFormat );
// Gets the file in a particular slot
const char *GetFile( int slot ) const;
const char *GetFileFormat( int slot ) const;
// Removes all files from the list
void Clear();
// Load, store to registry
void LoadFromRegistry( const char *pToolKeyName );
void SaveToRegistry( const char *pToolKeyName ) const;
// Adds all files in a list to a menu.
// Will generate the commands '<pCommandName>01', '<pCommandName>02', etc.
// depending on which one is selected
void AddToMenu( vgui::Menu *menu, vgui::Panel *actionTarget, const char *pCommandName ) const;
// Returns true if there's no files in the file list
bool IsEmpty() const;
private:
struct RecentFileInfo_t
{
CUtlString m_pFileName;
CUtlString m_pFileFormat;
bool operator==( const RecentFileInfo_t& src ) const
{
return m_pFileName == src.m_pFileName;
}
};
CUtlVector< RecentFileInfo_t > m_RecentFiles;
};
#endif // RECENTFILELIST_H

View File

@ -0,0 +1,37 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef SAVEWINDOWPOSITIONS_H
#define SAVEWINDOWPOSITIONS_H
#ifdef _WIN32
#pragma once
#endif
namespace vgui
{
class Panel;
class ToolWindow;
class IToolWindowFactory;
};
class CMovieView;
//-----------------------------------------------------------------------------
// Purpose: This will save the bounds and the visibility state of UI elements registered during startup
//-----------------------------------------------------------------------------
class IWindowPositionMgr
{
public:
virtual void SavePositions( char const *filename, char const *key ) = 0;
virtual bool LoadPositions( char const *filename, vgui::Panel *parent, vgui::IToolWindowFactory *factory, char const *key, bool force = false ) = 0;
virtual void RegisterPanel( char const *saveName, vgui::Panel *panel, bool contextMenu ) = 0;
virtual void UnregisterPanel( vgui::Panel *panel ) = 0;
};
extern IWindowPositionMgr *windowposmgr;
#endif // SAVEWINDOWPOSITIONS_H

View File

@ -0,0 +1,71 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// This menu bar displays a couple extra labels:
// one which contains the tool name, and one which contains a arbitrary info
//
//=============================================================================
#ifndef TOOLMENUBAR_H
#define TOOLMENUBAR_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/menubar.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
class Panel;
class Label;
}
class CBaseToolSystem;
//-----------------------------------------------------------------------------
// Main menu bar
//-----------------------------------------------------------------------------
class CToolMenuBar : public vgui::MenuBar
{
DECLARE_CLASS_SIMPLE( CToolMenuBar, vgui::MenuBar );
public:
CToolMenuBar( CBaseToolSystem *parent, const char *panelName );
virtual void PerformLayout();
void SetToolName( const char *name );
void SetInfo( const char *text );
CBaseToolSystem *GetToolSystem();
protected:
Label *m_pInfo;
Label *m_pToolName;
CBaseToolSystem *m_pToolSystem;
};
//-----------------------------------------------------------------------------
// Main menu bar version that stores file name on it
//-----------------------------------------------------------------------------
class CToolFileMenuBar : public CToolMenuBar
{
DECLARE_CLASS_SIMPLE( CToolFileMenuBar, CToolMenuBar );
public:
CToolFileMenuBar( CBaseToolSystem *parent, const char *panelName );
virtual void PerformLayout();
void SetFileName( const char *pFileName );
private:
Label *m_pFileName;
};
#endif // TOOLMENUBAR_H

View File

@ -0,0 +1,59 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef TOOLWINDOWFACTORY_H
#define TOOLWINDOWFACTORY_H
#ifdef _WIN32
#pragma once
#endif
#include "vgui_controls/ToolWindow.h"
#include "vgui/IInput.h"
#define TOOLWINDOW_DEFAULT_WIDTH 640
#define TOOLWINDOW_DEFAULT_HEIGHT 480
#define TOOLWINDOW_MIN_WIDTH 120
#define TOOLWINDOW_MIN_HEIGHT 80
template < class T >
class CToolWindowFactory : public vgui::IToolWindowFactory
{
public:
virtual vgui::ToolWindow *InstanceToolWindow
(
vgui::Panel *parent,
bool contextLabel, // Tool window shows context button for pages with context menus?
vgui::Panel *firstPage,
char const *title,
bool contextMenu // Page has context menu
);
};
//-----------------------------------------------------------------------------
// Methods related to CToolWindowFactory
//-----------------------------------------------------------------------------
template < class T >
vgui::ToolWindow *CToolWindowFactory<T>::InstanceToolWindow( vgui::Panel *parent, bool contextLabel, vgui::Panel *firstPage, char const *title, bool contextMenu )
{
Assert( parent );
if ( !parent )
return NULL;
int mx, my;
vgui::input()->GetCursorPos( mx, my );
parent->ScreenToLocal( mx, my );
T *container = new T( parent, contextLabel, this, firstPage, title, contextMenu );
Assert( container );
if ( container )
{
container->SetBounds( mx, my, TOOLWINDOW_DEFAULT_WIDTH, TOOLWINDOW_DEFAULT_HEIGHT );
container->SetMinimumSize( TOOLWINDOW_MIN_WIDTH, TOOLWINDOW_MIN_HEIGHT );
}
return container;
}
#endif // TOOLWINDOWFACTORY_H

View File

@ -0,0 +1,29 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef VGUI_TOOLS_H
#define VGUI_TOOLS_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#include <vgui/VGUI.h>
// Every tool must expose this back to us
extern char const *GetVGuiControlsModuleName();
bool VGui_Startup( CreateInterfaceFn appSystemFactory );
bool VGui_PostInit();
void VGui_Shutdown( void );
// Must be implemented by .dll
void VGUI_CreateToolRootPanel( void );
void VGUI_DestroyToolRootPanel( void );
vgui::VPANEL VGui_GetToolRootPanel( void );
#endif // VGUI_TOOLS_H