mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-07 17:29:36 +00:00
1
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "gameeventeditdoc.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "toolutils/enginetools_int.h"
|
||||
#include "filesystem.h"
|
||||
#include "toolframework/ienginetool.h"
|
||||
#include "datamodel/idatamodel.h"
|
||||
#include "toolutils/attributeelementchoicelist.h"
|
||||
#include "vgui_controls/messagebox.h"
|
||||
|
||||
// FIXME: This document currently stores a whole lot of nothing.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameEventEditDoc::CGameEventEditDoc()
|
||||
{
|
||||
m_hRoot = NULL;
|
||||
m_pTXTFileName[0] = 0;
|
||||
m_bDirty = false;
|
||||
g_pDataModel->InstallNotificationCallback( this );
|
||||
}
|
||||
|
||||
CGameEventEditDoc::~CGameEventEditDoc()
|
||||
{
|
||||
g_pDataModel->RemoveNotificationCallback( this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inherited from INotifyUI
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventEditDoc::NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags )
|
||||
{
|
||||
//OnDataChanged( pReason, nNotifySource, nNotifyFlags );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets the file name
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CGameEventEditDoc::GetTXTFileName()
|
||||
{
|
||||
return m_pTXTFileName;
|
||||
}
|
||||
|
||||
void CGameEventEditDoc::SetTXTFileName( const char *pFileName )
|
||||
{
|
||||
Q_strncpy( m_pTXTFileName, pFileName, sizeof( m_pTXTFileName ) );
|
||||
Q_FixSlashes( m_pTXTFileName );
|
||||
SetDirty( true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Dirty bits
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventEditDoc::SetDirty( bool bDirty )
|
||||
{
|
||||
m_bDirty = bDirty;
|
||||
}
|
||||
|
||||
bool CGameEventEditDoc::IsDirty() const
|
||||
{
|
||||
return m_bDirty;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Saves/loads from file
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CGameEventEditDoc::LoadFromFile( const char *pFileName )
|
||||
{
|
||||
/*
|
||||
Assert( !m_hRoot.Get() );
|
||||
|
||||
CAppDisableUndoScopeGuard guard( "CCommEditDoc::LoadFromFile", 0 );
|
||||
SetDirty( false );
|
||||
|
||||
if ( !pFileName[0] )
|
||||
return false;
|
||||
|
||||
char mapname[ 256 ];
|
||||
|
||||
// Compute the map name
|
||||
const char *pMaps = Q_stristr( pFileName, "\\maps\\" );
|
||||
if ( !pMaps )
|
||||
return false;
|
||||
|
||||
// Build map name
|
||||
//int nNameLen = (int)( (size_t)pComm - (size_t)pMaps ) - 5;
|
||||
Q_StripExtension( pFileName, mapname, sizeof(mapname) );
|
||||
char *pszFileName = (char*)Q_UnqualifiedFileName(mapname);
|
||||
|
||||
// Set the txt file name.
|
||||
// If we loaded an existing commentary file, keep the same filename.
|
||||
// If we loaded a .bsp, change the name & the extension.
|
||||
if ( !V_stricmp( Q_GetFileExtension( pFileName ), "bsp" ) )
|
||||
{
|
||||
const char *pCommentaryAppend = "_commentary.txt";
|
||||
Q_StripExtension( pFileName, m_pTXTFileName, sizeof(m_pTXTFileName)- strlen(pCommentaryAppend) - 1 );
|
||||
Q_strcat( m_pTXTFileName, pCommentaryAppend, sizeof( m_pTXTFileName ) );
|
||||
|
||||
if ( g_pFileSystem->FileExists( m_pTXTFileName ) )
|
||||
{
|
||||
char pBuf[1024];
|
||||
Q_snprintf( pBuf, sizeof(pBuf), "File %s already exists!\n", m_pTXTFileName );
|
||||
m_pTXTFileName[0] = 0;
|
||||
vgui::MessageBox *pMessageBox = new vgui::MessageBox( "Unable to overwrite file!\n", pBuf, g_pCommEditTool );
|
||||
pMessageBox->DoModal( );
|
||||
return false;
|
||||
}
|
||||
|
||||
DmFileId_t fileid = g_pDataModel->FindOrCreateFileId( m_pTXTFileName );
|
||||
|
||||
m_hRoot = CreateElement<CDmElement>( "root", fileid );
|
||||
CDmrElementArray<> subkeys( m_hRoot->AddAttribute( "subkeys", AT_ELEMENT_ARRAY ) );
|
||||
CDmElement *pRoot2 = CreateElement<CDmElement>( "Entities", fileid );
|
||||
pRoot2->AddAttribute( "subkeys", AT_ELEMENT_ARRAY );
|
||||
subkeys.AddToTail( pRoot2 );
|
||||
g_pDataModel->SetFileRoot( fileid, m_hRoot );
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pComm = Q_stristr( pszFileName, "_commentary" );
|
||||
if ( !pComm )
|
||||
{
|
||||
char pBuf[1024];
|
||||
Q_snprintf( pBuf, sizeof(pBuf), "File %s is not a commentary file!\nThe file name must end in _commentary.txt.\n", m_pTXTFileName );
|
||||
m_pTXTFileName[0] = 0;
|
||||
vgui::MessageBox *pMessageBox = new vgui::MessageBox( "Bad file name!\n", pBuf, g_pCommEditTool );
|
||||
pMessageBox->DoModal( );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clip off the "_commentary" at the end of the filename
|
||||
*pComm = '\0';
|
||||
|
||||
// This is not undoable
|
||||
CDisableUndoScopeGuard guard;
|
||||
|
||||
CDmElement *pTXT = NULL;
|
||||
|
||||
CElementForKeyValueCallback KeyValuesCallback;
|
||||
g_pDataModel->SetKeyValuesElementCallback( &KeyValuesCallback );
|
||||
DmFileId_t fileid = g_pDataModel->RestoreFromFile( pFileName, NULL, "keyvalues", &pTXT );
|
||||
g_pDataModel->SetKeyValuesElementCallback( NULL );
|
||||
|
||||
if ( fileid == DMFILEID_INVALID )
|
||||
{
|
||||
m_pTXTFileName[0] = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
SetTXTFileName( pFileName );
|
||||
m_hRoot = pTXT;
|
||||
}
|
||||
|
||||
guard.Release();
|
||||
SetDirty( false );
|
||||
|
||||
char cmd[ 256 ];
|
||||
Q_snprintf( cmd, sizeof( cmd ), "disconnect; map %s\n", pszFileName );
|
||||
enginetools->Command( cmd );
|
||||
enginetools->Execute( );*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGameEventEditDoc::SaveToFile( )
|
||||
{
|
||||
if ( m_hRoot.Get() && m_pTXTFileName && m_pTXTFileName[0] )
|
||||
{
|
||||
g_pDataModel->SaveToFile( m_pTXTFileName, NULL, "keyvalues", "keyvalues", m_hRoot );
|
||||
}
|
||||
|
||||
SetDirty( false );
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef GAMEEVENTEDITDOC_H
|
||||
#define GAMEEVENTEDITDOC_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "dme_controls/inotifyui.h"
|
||||
#include "datamodel/dmehandle.h"
|
||||
#include "datamodel/dmelement.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class ICommEditDocCallback;
|
||||
class CCommEditDoc;
|
||||
class CDmeCommentaryNodeEntity;
|
||||
|
||||
typedef CDmrElementArray<CDmeCommentaryNodeEntity> CDmrCommentaryNodeEntityList;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Contains all editable state
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameEventEditDoc : public IDmNotify
|
||||
{
|
||||
public:
|
||||
CGameEventEditDoc();
|
||||
~CGameEventEditDoc();
|
||||
|
||||
// Inherited from INotifyUI
|
||||
virtual void NotifyDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
|
||||
|
||||
// Sets/Gets the file name
|
||||
const char *GetTXTFileName();
|
||||
void SetTXTFileName( const char *pFileName );
|
||||
|
||||
// Dirty bits (has it changed since the last time it was saved?)
|
||||
void SetDirty( bool bDirty );
|
||||
bool IsDirty() const;
|
||||
|
||||
// Saves/loads from file
|
||||
bool LoadFromFile( const char *pFileName );
|
||||
void SaveToFile( );
|
||||
|
||||
/*
|
||||
// Returns the root object
|
||||
CDmElement *GetRootObject();
|
||||
|
||||
// Called when data changes (see INotifyUI for flags)
|
||||
void OnDataChanged( const char *pReason, int nNotifySource, int nNotifyFlags );
|
||||
|
||||
// Returns the entity list
|
||||
CDmAttribute *GetEntityList();
|
||||
|
||||
// Adds a new info_target
|
||||
void AddNewInfoTarget( void );
|
||||
void AddNewInfoTarget( const Vector &vecOrigin, const QAngle &angAngles );
|
||||
|
||||
// Adds a new commentary node
|
||||
void AddNewCommentaryNode( void );
|
||||
void AddNewCommentaryNode( const Vector &vecOrigin, const QAngle &angAngles );
|
||||
|
||||
// Deletes a commentary node
|
||||
void DeleteCommentaryNode( CDmElement *pNode );
|
||||
|
||||
// Returns the commentary node at the specified location
|
||||
CDmeCommentaryNodeEntity *GetCommentaryNodeForLocation( Vector &vecOrigin, QAngle &angAbsAngles );
|
||||
|
||||
// For element choice lists. Return false if it's an unknown choice list type
|
||||
virtual bool GetStringChoiceList( const char *pChoiceListType, CDmElement *pElement,
|
||||
const char *pAttributeName, bool bArrayElement, StringChoiceList_t &list );
|
||||
virtual bool GetElementChoiceList( const char *pChoiceListType, CDmElement *pElement,
|
||||
const char *pAttributeName, bool bArrayElement, ElementChoiceList_t &list );*/
|
||||
|
||||
|
||||
private:
|
||||
//ICommEditDocCallback *m_pCallback;
|
||||
CDmeHandle< CDmElement > m_hRoot;
|
||||
char m_pTXTFileName[512];
|
||||
bool m_bDirty;
|
||||
};
|
||||
|
||||
|
||||
#endif // GAMEEVENTEDITDOC_H
|
||||
@@ -0,0 +1,240 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
#include "gameeventeditpanel.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "iregistry.h"
|
||||
#include "vgui/ivgui.h"
|
||||
#include "vgui_controls/listpanel.h"
|
||||
#include "vgui_controls/textentry.h"
|
||||
#include "vgui_controls/checkbutton.h"
|
||||
#include "vgui_controls/combobox.h"
|
||||
#include "vgui_controls/radiobutton.h"
|
||||
#include "vgui_controls/messagebox.h"
|
||||
#include "vgui_controls/scrollbar.h"
|
||||
#include "vgui_controls/scrollableeditablepanel.h"
|
||||
#include "datamodel/dmelement.h"
|
||||
#include "matsys_controls/picker.h"
|
||||
#include "vgui_controls/fileopendialog.h"
|
||||
#include "filesystem.h"
|
||||
#include "tier2/fileutils.h"
|
||||
#include "igameevents.h"
|
||||
#include "toolutils/enginetools_int.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
char *VarArgs( PRINTF_FORMAT_STRING const char *format, ... )
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
va_start (argptr, format);
|
||||
Q_vsnprintf (string, sizeof( string ), format,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameEventEditPanel::CGameEventEditPanel( CGameEventEditDoc *pDoc, vgui::Panel* pParent )
|
||||
: BaseClass( pParent, "GameEventEditPanel" ), m_pDoc( pDoc )
|
||||
{
|
||||
SetPaintBackgroundEnabled( true );
|
||||
SetKeyBoardInputEnabled( true );
|
||||
|
||||
m_pEvents = new KeyValues( "events" );
|
||||
|
||||
m_EventFiles.RemoveAll();
|
||||
m_EventFileNames.RemoveAll();
|
||||
|
||||
// load the game events
|
||||
LoadEventsFromFile( "resource/GameEvents.res" );
|
||||
LoadEventsFromFile( "resource/ModEvents.res" );
|
||||
|
||||
m_pEventCombo = new vgui::ComboBox( this, "EventComboBox", 30, false );
|
||||
m_pEventCombo->SetNumberOfEditLines( 30 );
|
||||
|
||||
KeyValues *subkey = m_pEvents->GetFirstSubKey();
|
||||
while ( subkey )
|
||||
{
|
||||
m_pEventCombo->AddItem( subkey->GetName(), subkey );
|
||||
subkey = subkey->GetNextKey();
|
||||
}
|
||||
|
||||
if ( m_pEventCombo->GetItemCount() > 0 )
|
||||
{
|
||||
m_pEventCombo->ActivateItemByRow( 0 );
|
||||
}
|
||||
|
||||
for ( int i=0;i<MAX_GAME_EVENT_PARAMS;i++ )
|
||||
{
|
||||
m_pParamLabels[i] = new vgui::Label( this, VarArgs( "ParamLabel%d", i+1 ), VarArgs( "event param %d:", i+1 ) );
|
||||
m_pParamLabels[i]->AddActionSignalTarget( this );
|
||||
|
||||
m_pParams[i] = new vgui::TextEntry( this, VarArgs( "Param%d", i+1 ) );
|
||||
m_pParams[i]->AddActionSignalTarget( this );
|
||||
}
|
||||
|
||||
m_pSendEventButton = new vgui::Button( this, "SendEvent", "", this, "SendEvent" );
|
||||
|
||||
m_pFilterBox = new vgui::TextEntry( this, "FilterBox" );
|
||||
|
||||
LoadControlSettings( "resource/gameeventeditpanel.res" );
|
||||
}
|
||||
|
||||
CGameEventEditPanel::~CGameEventEditPanel()
|
||||
{
|
||||
m_pEvents->deleteThis();
|
||||
}
|
||||
|
||||
void CGameEventEditPanel::OnTextChanged( KeyValues *params )
|
||||
{
|
||||
Panel *panel = reinterpret_cast<vgui::Panel *>( params->GetPtr("panel") );
|
||||
|
||||
if ( panel == m_pFilterBox )
|
||||
{
|
||||
// repopulate the list based on the filter substr
|
||||
char filter[128];
|
||||
m_pFilterBox->GetText( filter, sizeof(filter) );
|
||||
int len = Q_strlen(filter);
|
||||
|
||||
m_pEventCombo->RemoveAll();
|
||||
|
||||
KeyValues *subkey = m_pEvents->GetFirstSubKey();
|
||||
while ( subkey )
|
||||
{
|
||||
if ( len == 0 || Q_strstr( subkey->GetName(), filter ) )
|
||||
{
|
||||
m_pEventCombo->AddItem( subkey->GetName(), subkey );
|
||||
}
|
||||
|
||||
subkey = subkey->GetNextKey();
|
||||
}
|
||||
|
||||
if ( m_pEventCombo->GetItemCount() > 0 )
|
||||
{
|
||||
m_pEventCombo->ActivateItemByRow( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( panel == m_pEventCombo )
|
||||
{
|
||||
Msg( "%s", params->GetName() );
|
||||
|
||||
KeyValues *kv = m_pEventCombo->GetActiveItemUserData();
|
||||
|
||||
int i = 0;
|
||||
|
||||
if ( kv )
|
||||
{
|
||||
KeyValues *subkey = kv->GetFirstSubKey();
|
||||
while ( subkey && i < MAX_GAME_EVENT_PARAMS )
|
||||
{
|
||||
Msg( subkey->GetName() );
|
||||
|
||||
char buf[128];
|
||||
Q_snprintf( buf, sizeof(buf), "%s (%s)", subkey->GetName(), subkey->GetString() );
|
||||
|
||||
m_pParamLabels[i]->SetText( buf );
|
||||
m_pParamLabels[i]->SetVisible( true );
|
||||
|
||||
const char *type = subkey->GetString();
|
||||
|
||||
if ( !Q_strcmp( type, "string" ) )
|
||||
{
|
||||
m_pParams[i]->SetAllowNumericInputOnly( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pParams[i]->SetAllowNumericInputOnly( true );
|
||||
}
|
||||
m_pParams[i]->SetText( "" );
|
||||
m_pParams[i]->SetVisible( true );
|
||||
|
||||
subkey = subkey->GetNextKey();
|
||||
i++;
|
||||
}
|
||||
|
||||
while( i < MAX_GAME_EVENT_PARAMS )
|
||||
{
|
||||
m_pParamLabels[i]->SetVisible( false );
|
||||
m_pParams[i]->SetVisible( false );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when buttons are clicked
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventEditPanel::OnCommand( const char *pCommand )
|
||||
{
|
||||
if ( !Q_stricmp( pCommand, "SendEvent" ) )
|
||||
{
|
||||
KeyValues *pData = m_pEventCombo->GetActiveItemUserData();
|
||||
|
||||
if ( pData )
|
||||
{
|
||||
const char *pEventName = pData->GetName();
|
||||
|
||||
IGameEvent *event = gameeventmanager->CreateEvent( pEventName );
|
||||
if ( event )
|
||||
{
|
||||
KeyValues *subkey = pData->GetFirstSubKey();
|
||||
|
||||
int i = 0;
|
||||
|
||||
while( subkey && i < MAX_GAME_EVENT_PARAMS )
|
||||
{
|
||||
char text[128];
|
||||
m_pParams[i]->GetText( text, sizeof(text) );
|
||||
event->SetString( subkey->GetName(), text );
|
||||
|
||||
subkey = subkey->GetNextKey();
|
||||
i++;
|
||||
}
|
||||
|
||||
gameeventmanager->FireEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::OnCommand( pCommand );
|
||||
}
|
||||
|
||||
void CGameEventEditPanel::LoadEventsFromFile( const char *filename )
|
||||
{
|
||||
if ( UTL_INVAL_SYMBOL == m_EventFiles.Find( filename ) )
|
||||
{
|
||||
CUtlSymbol id = m_EventFiles.AddString( filename );
|
||||
m_EventFileNames.AddToTail( id );
|
||||
}
|
||||
|
||||
KeyValues * key = new KeyValues(filename);
|
||||
KeyValues::AutoDelete autodelete_key( key );
|
||||
|
||||
if ( !key->LoadFromFile( g_pFileSystem, filename, "GAME" ) )
|
||||
return;
|
||||
|
||||
KeyValues *subkey = key->GetFirstSubKey();
|
||||
while ( subkey )
|
||||
{
|
||||
KeyValues *copy = subkey->MakeCopy();
|
||||
|
||||
m_pEvents->AddSubKey( copy );
|
||||
|
||||
subkey = subkey->GetNextKey();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef GAMEEVENTEDITPANEL_H
|
||||
#define GAMEEVENTEDITPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/editablepanel.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "datamodel/dmehandle.h"
|
||||
#include "igameevents.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameEventEditDoc;
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class ComboBox;
|
||||
class Button;
|
||||
class TextEntry;
|
||||
class ListPanel;
|
||||
class CheckButton;
|
||||
class RadioButton;
|
||||
}
|
||||
|
||||
#define MAX_GAME_EVENT_PARAMS 20
|
||||
|
||||
extern IGameEventManager2 *gameeventmanager;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Panel that shows all entities in the level
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameEventEditPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CGameEventEditPanel, vgui::EditablePanel );
|
||||
|
||||
public:
|
||||
CGameEventEditPanel( CGameEventEditDoc *pDoc, vgui::Panel* pParent ); // standard constructor
|
||||
~CGameEventEditPanel();
|
||||
|
||||
// Inherited from Panel
|
||||
virtual void OnCommand( const char *pCommand );
|
||||
|
||||
private:
|
||||
// Text to attribute...
|
||||
//void TextEntryToAttribute( vgui::TextEntry *pEntry, const char *pAttributeName );
|
||||
//void TextEntriesToVector( vgui::TextEntry *pEntry[3], const char *pAttributeName );
|
||||
|
||||
// Messages handled
|
||||
/*
|
||||
MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
|
||||
MESSAGE_FUNC_PARAMS( OnSoundSelected, "SoundSelected", kv );
|
||||
MESSAGE_FUNC_PARAMS( OnPicked, "Picked", kv );
|
||||
MESSAGE_FUNC_PARAMS( OnFileSelected, "FileSelected", kv );
|
||||
MESSAGE_FUNC_PARAMS( OnSoundRecorded, "SoundRecorded", kv );*/
|
||||
|
||||
//MESSAGE_FUNC( OnEventSend, "SendEvent" );
|
||||
|
||||
MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", kv );
|
||||
|
||||
void LoadEventsFromFile( const char *filename );
|
||||
|
||||
CGameEventEditDoc *m_pDoc;
|
||||
|
||||
// drop down of available events
|
||||
|
||||
vgui::ComboBox *m_pEventCombo;
|
||||
|
||||
vgui::Label *m_pParamLabels[MAX_GAME_EVENT_PARAMS];
|
||||
vgui::TextEntry *m_pParams[MAX_GAME_EVENT_PARAMS];
|
||||
|
||||
vgui::Button *m_pSendEventButton;
|
||||
|
||||
CUtlSymbolTable m_EventFiles; // list of all loaded event files
|
||||
CUtlVector<CUtlSymbol> m_EventFileNames;
|
||||
|
||||
KeyValues *m_pEvents;
|
||||
|
||||
vgui::TextEntry *m_pFilterBox;
|
||||
};
|
||||
|
||||
|
||||
#endif // GAMEEVENTEDITPANEL_H
|
||||
@@ -0,0 +1,625 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "toolutils/basetoolsystem.h"
|
||||
#include "toolutils/recentfilelist.h"
|
||||
#include "toolutils/toolmenubar.h"
|
||||
#include "toolutils/toolswitchmenubutton.h"
|
||||
#include "toolutils/toolfilemenubutton.h"
|
||||
#include "toolutils/toolmenubutton.h"
|
||||
#include "vgui_controls/Menu.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
#include "toolutils/enginetools_int.h"
|
||||
#include "toolframework/ienginetool.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/KeyCode.h"
|
||||
#include "vgui_controls/FileOpenDialog.h"
|
||||
#include "filesystem.h"
|
||||
#include "vgui/ilocalize.h"
|
||||
#include "dme_controls/elementpropertiestree.h"
|
||||
#include "tier0/icommandline.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "VGuiMatSurface/IMatSystemSurface.h"
|
||||
#include "tier3/tier3.h"
|
||||
#include "tier2/fileutils.h"
|
||||
#include "gameeventeditdoc.h"
|
||||
#include "gameeventeditpanel.h"
|
||||
#include "toolutils/toolwindowfactory.h"
|
||||
#include "toolutils/savewindowpositions.h" // for windowposmgr
|
||||
#include "toolutils/ConsolePage.h"
|
||||
#include "igameevents.h"
|
||||
|
||||
IGameEventManager2 *gameeventmanager = NULL;
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
const char *GetVGuiControlsModuleName()
|
||||
{
|
||||
return "GameEvents";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Connect, disconnect
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ConnectTools( CreateInterfaceFn factory )
|
||||
{
|
||||
gameeventmanager = ( IGameEventManager2 * )factory( INTERFACEVERSION_GAMEEVENTSMANAGER2, NULL );
|
||||
|
||||
if ( !gameeventmanager )
|
||||
{
|
||||
Warning( "Game Event Tool missing required interface\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return (materials != NULL) && (g_pMatSystemSurface != NULL);
|
||||
}
|
||||
|
||||
void DisconnectTools( )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Implementation of the game events tool
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameEventTool : public CBaseToolSystem, public IFileMenuCallbacks
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CGameEventTool, CBaseToolSystem );
|
||||
|
||||
public:
|
||||
CGameEventTool();
|
||||
|
||||
// Inherited from IToolSystem
|
||||
virtual const char *GetToolName() { return "Game Events"; }
|
||||
virtual const char *GetBindingsContextFile() { return "cfg/GameEvents.kb"; }
|
||||
virtual bool Init( );
|
||||
virtual void Shutdown();
|
||||
|
||||
// Inherited from IFileMenuCallbacks
|
||||
virtual int GetFileMenuItemsEnabled( );
|
||||
virtual void AddRecentFilesToMenu( vgui::Menu *menu );
|
||||
virtual bool GetPerforceFileName( char *pFileName, int nMaxLen ) { return false; }
|
||||
virtual vgui::Panel* GetRootPanel() { return this; }
|
||||
|
||||
// Inherited from CBaseToolSystem
|
||||
virtual vgui::HScheme GetToolScheme();
|
||||
virtual vgui::Menu *CreateActionMenu( vgui::Panel *pParent );
|
||||
virtual void OnCommand( const char *cmd );
|
||||
virtual const char *GetRegistryName() { return "SampleTool"; }
|
||||
virtual vgui::MenuBar *CreateMenuBar( CBaseToolSystem *pParent );
|
||||
|
||||
public:
|
||||
MESSAGE_FUNC( OnNew, "OnNew" );
|
||||
MESSAGE_FUNC( OnOpen, "OnOpen" );
|
||||
MESSAGE_FUNC( OnSave, "OnSave" );
|
||||
MESSAGE_FUNC( OnSaveAs, "OnSaveAs" );
|
||||
MESSAGE_FUNC( OnClose, "OnClose" );
|
||||
MESSAGE_FUNC( OnCloseNoSave, "OnCloseNoSave" );
|
||||
MESSAGE_FUNC( OnMarkNotDirty, "OnMarkNotDirty" );
|
||||
MESSAGE_FUNC( OnExit, "OnExit" );
|
||||
|
||||
void NewDocument();
|
||||
|
||||
void OpenFileFromHistory( int slot );
|
||||
virtual void SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues );
|
||||
virtual bool OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
|
||||
virtual bool OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues );
|
||||
virtual void OnFileOperationCompleted( const char *pFileType, bool bWroteFile, vgui::FileOpenStateMachine::CompletionState_t state, KeyValues *pContextKeyValues );
|
||||
|
||||
// Get at the edit panel
|
||||
CGameEventEditPanel *GetGameEventEditPanel();
|
||||
|
||||
private:
|
||||
// Loads up a new document
|
||||
bool LoadDocument( const char *pDocName );
|
||||
|
||||
// Creates, destroys tools
|
||||
void CreateTools( CGameEventEditDoc *doc );
|
||||
void InitTools();
|
||||
void DestroyTools();
|
||||
|
||||
void OnDefaultLayout();
|
||||
|
||||
// Updates the menu bar based on the current file
|
||||
void UpdateMenuBar( );
|
||||
|
||||
// Shows element properties
|
||||
void ShowElementProperties( );
|
||||
|
||||
virtual const char *GetLogoTextureName();
|
||||
|
||||
CConsolePage *GetConsole();
|
||||
void OnToggleConsole();
|
||||
|
||||
void ShowToolWindow( Panel *tool, char const *toolName, bool visible );
|
||||
void ToggleToolWindow( Panel *tool, char const *toolName );
|
||||
|
||||
CToolWindowFactory< ToolWindow > m_ToolWindowFactory;
|
||||
|
||||
|
||||
// The entity report
|
||||
vgui::DHANDLE< CGameEventEditPanel > m_hGameEventEditPanel;
|
||||
|
||||
// Document
|
||||
CGameEventEditDoc *m_pDoc;
|
||||
|
||||
// The menu bar
|
||||
CToolFileMenuBar *m_pMenuBar;
|
||||
|
||||
// console tab in viewport
|
||||
vgui::DHANDLE< CConsolePage > m_hConsole;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Singleton
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameEventTool *g_pSampleTool = NULL;
|
||||
|
||||
void CreateTools()
|
||||
{
|
||||
g_pSampleTool = new CGameEventTool();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameEventTool::CGameEventTool()
|
||||
{
|
||||
m_pMenuBar = NULL;
|
||||
m_pDoc = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Init, shutdown
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CGameEventTool::Init( )
|
||||
{
|
||||
m_RecentFiles.LoadFromRegistry( GetRegistryName() );
|
||||
|
||||
// NOTE: This has to happen before BaseClass::Init
|
||||
g_pVGuiLocalize->AddFile( "resource/toolgameevents_%language%.txt" );
|
||||
|
||||
if ( !BaseClass::Init( ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGameEventTool::Shutdown()
|
||||
{
|
||||
m_RecentFiles.SaveToRegistry( GetRegistryName() );
|
||||
BaseClass::Shutdown();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Derived classes can implement this to get a new scheme to be applied to this tool
|
||||
//-----------------------------------------------------------------------------
|
||||
vgui::HScheme CGameEventTool::GetToolScheme()
|
||||
{
|
||||
return vgui::scheme()->LoadSchemeFromFile( "Resource/BoxRocket.res", "SampleTool" );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Initializes the menu bar
|
||||
//-----------------------------------------------------------------------------
|
||||
vgui::MenuBar *CGameEventTool::CreateMenuBar( CBaseToolSystem *pParent )
|
||||
{
|
||||
m_pMenuBar = new CToolFileMenuBar( pParent, "Main Menu Bar" );
|
||||
|
||||
// Sets info in the menu bar
|
||||
char title[ 64 ];
|
||||
ComputeMenuBarTitle( title, sizeof( title ) );
|
||||
m_pMenuBar->SetInfo( title );
|
||||
m_pMenuBar->SetToolName( GetToolName() );
|
||||
|
||||
// Add menu buttons
|
||||
CToolMenuButton *pFileButton = CreateToolFileMenuButton( m_pMenuBar, "File", "&File", GetActionTarget(), this );
|
||||
CToolMenuButton *pSwitchButton = CreateToolSwitchMenuButton( m_pMenuBar, "Switcher", "&Tools", GetActionTarget() );
|
||||
|
||||
m_pMenuBar->AddButton( pFileButton );
|
||||
m_pMenuBar->AddButton( pSwitchButton );
|
||||
|
||||
return m_pMenuBar;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Creates the action menu
|
||||
//-----------------------------------------------------------------------------
|
||||
vgui::Menu *CGameEventTool::CreateActionMenu( vgui::Panel *pParent )
|
||||
{
|
||||
vgui::Menu *pActionMenu = new Menu( pParent, "ActionMenu" );
|
||||
pActionMenu->AddMenuItem( "#ToolHide", new KeyValues( "Command", "command", "HideActionMenu" ), GetActionTarget() );
|
||||
return pActionMenu;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inherited from IFileMenuCallbacks
|
||||
//-----------------------------------------------------------------------------
|
||||
int CGameEventTool::GetFileMenuItemsEnabled( )
|
||||
{
|
||||
int nFlags = FILE_ALL;
|
||||
if ( m_RecentFiles.IsEmpty() )
|
||||
{
|
||||
nFlags &= ~(FILE_RECENT | FILE_CLEAR_RECENT);
|
||||
}
|
||||
return nFlags;
|
||||
}
|
||||
|
||||
void CGameEventTool::AddRecentFilesToMenu( vgui::Menu *pMenu )
|
||||
{
|
||||
m_RecentFiles.AddToMenu( pMenu, GetActionTarget(), "OnRecent" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::OnExit()
|
||||
{
|
||||
enginetools->Command( "quit\n" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Handle commands from the action menu and other menus
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::OnCommand( const char *cmd )
|
||||
{
|
||||
if ( !V_stricmp( cmd, "HideActionMenu" ) )
|
||||
{
|
||||
if ( GetActionMenu() )
|
||||
{
|
||||
GetActionMenu()->SetVisible( false );
|
||||
}
|
||||
}
|
||||
else if ( const char *pOnRecentSuffix = StringAfterPrefix( cmd, "OnRecent" ) )
|
||||
{
|
||||
int idx = Q_atoi( pOnRecentSuffix );
|
||||
OpenFileFromHistory( idx );
|
||||
}
|
||||
else if( const char *pOnToolSuffix = StringAfterPrefix( cmd, "OnTool" ) )
|
||||
{
|
||||
int idx = Q_atoi( pOnToolSuffix );
|
||||
enginetools->SwitchToTool( idx );
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( cmd );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Command handlers
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::OnNew()
|
||||
{
|
||||
if ( m_pDoc )
|
||||
{
|
||||
if ( m_pDoc->IsDirty() )
|
||||
{
|
||||
SaveFile( m_pDoc->GetTXTFileName(), "xt", FOSM_SHOW_PERFORCE_DIALOGS | FOSM_SHOW_SAVE_QUERY,
|
||||
new KeyValues( "OnNew" ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NewDocument();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Loads up a new document
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::NewDocument( )
|
||||
{
|
||||
Assert( !m_pDoc );
|
||||
|
||||
m_pDoc = new CGameEventEditDoc(/* this */);
|
||||
|
||||
CreateTools( m_pDoc );
|
||||
UpdateMenuBar();
|
||||
InitTools();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when the File->Open menu is selected
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::OnOpen( )
|
||||
{
|
||||
int nFlags = 0;
|
||||
const char *pSaveFileName = NULL;
|
||||
if ( m_pDoc && m_pDoc->IsDirty() )
|
||||
{
|
||||
nFlags = FOSM_SHOW_PERFORCE_DIALOGS | FOSM_SHOW_SAVE_QUERY;
|
||||
pSaveFileName = m_pDoc->GetTXTFileName();
|
||||
}
|
||||
|
||||
OpenFile( "txt", pSaveFileName, "txt", nFlags );
|
||||
}
|
||||
|
||||
bool CGameEventTool::OnReadFileFromDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues )
|
||||
{
|
||||
OnCloseNoSave();
|
||||
if ( !LoadDocument( pFileName ) )
|
||||
return false;
|
||||
|
||||
m_RecentFiles.Add( pFileName, pFileFormat );
|
||||
m_RecentFiles.SaveToRegistry( GetRegistryName() );
|
||||
UpdateMenuBar();
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates the menu bar based on the current file
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::UpdateMenuBar( )
|
||||
{
|
||||
if ( !m_pDoc )
|
||||
{
|
||||
m_pMenuBar->SetFileName( "#CommEditNoFile" );
|
||||
return;
|
||||
}
|
||||
|
||||
const char *pTXTFile = m_pDoc->GetTXTFileName();
|
||||
if ( !pTXTFile[0] )
|
||||
{
|
||||
m_pMenuBar->SetFileName( "#CommEditNoFile" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_pDoc->IsDirty() )
|
||||
{
|
||||
char sz[ 512 ];
|
||||
Q_snprintf( sz, sizeof( sz ), "* %s", pTXTFile );
|
||||
m_pMenuBar->SetFileName( sz );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pMenuBar->SetFileName( pTXTFile );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGameEventTool::OnSave()
|
||||
{
|
||||
// FIXME: Implement
|
||||
}
|
||||
|
||||
void CGameEventTool::OnSaveAs()
|
||||
{
|
||||
SaveFile( NULL, NULL, 0 );
|
||||
}
|
||||
|
||||
bool CGameEventTool::OnWriteFileToDisk( const char *pFileName, const char *pFileFormat, KeyValues *pContextKeyValues )
|
||||
{
|
||||
// FIXME: Implement
|
||||
|
||||
m_RecentFiles.Add( pFileName, pFileFormat );
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGameEventTool::OnClose()
|
||||
{
|
||||
// FIXME: Implement
|
||||
}
|
||||
|
||||
void CGameEventTool::OnCloseNoSave()
|
||||
{
|
||||
// FIXME: Implement
|
||||
}
|
||||
|
||||
void CGameEventTool::OnMarkNotDirty()
|
||||
{
|
||||
// FIXME: Implement
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Show the save document query dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::OpenFileFromHistory( int slot )
|
||||
{
|
||||
const char *pFileName = m_RecentFiles.GetFile( slot );
|
||||
OnReadFileFromDisk( pFileName, NULL, 0 );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called when file operations complete
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::OnFileOperationCompleted( const char *pFileType, bool bWroteFile, vgui::FileOpenStateMachine::CompletionState_t state, KeyValues *pContextKeyValues )
|
||||
{
|
||||
// FIXME: Implement
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Show the File browser dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::SetupFileOpenDialog( vgui::FileOpenDialog *pDialog, bool bOpenFile, const char *pFileFormat, KeyValues *pContextKeyValues )
|
||||
{
|
||||
char pStartingDir[ MAX_PATH ];
|
||||
GetModSubdirectory( NULL, pStartingDir, sizeof(pStartingDir) );
|
||||
|
||||
pDialog->SetTitle( "Choose SampleTool .txt file", true );
|
||||
pDialog->SetStartDirectoryContext( "sample_session", pStartingDir );
|
||||
pDialog->AddFilter( "*.txt", "SampleTool (*.txt)", true );
|
||||
}
|
||||
|
||||
const char *CGameEventTool::GetLogoTextureName()
|
||||
{
|
||||
return "vgui/tools/sampletool/sampletool_logo";
|
||||
}
|
||||
|
||||
CGameEventEditPanel *CGameEventTool::GetGameEventEditPanel()
|
||||
{
|
||||
return m_hGameEventEditPanel.Get();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Creates
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::CreateTools( CGameEventEditDoc *doc )
|
||||
{
|
||||
if ( !m_hGameEventEditPanel.Get() )
|
||||
{
|
||||
m_hGameEventEditPanel = new CGameEventEditPanel( m_pDoc, this );
|
||||
}
|
||||
|
||||
if ( !m_hConsole.Get() )
|
||||
{
|
||||
m_hConsole = new CConsolePage( NULL, false );
|
||||
}
|
||||
|
||||
RegisterToolWindow( m_hGameEventEditPanel );
|
||||
RegisterToolWindow( m_hConsole );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Initializes the tools
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::InitTools()
|
||||
{
|
||||
//ShowElementProperties();
|
||||
|
||||
windowposmgr->RegisterPanel( "gameeventedit", m_hGameEventEditPanel, false );
|
||||
windowposmgr->RegisterPanel( "Console", m_hConsole, false ); // No context menu
|
||||
|
||||
if ( !windowposmgr->LoadPositions( "cfg/commedit.txt", this, &m_ToolWindowFactory, "CommEdit" ) )
|
||||
{
|
||||
OnDefaultLayout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CGameEventTool::DestroyTools()
|
||||
{
|
||||
UnregisterAllToolWindows();
|
||||
|
||||
if ( m_hGameEventEditPanel.Get() )
|
||||
{
|
||||
windowposmgr->UnregisterPanel( m_hGameEventEditPanel.Get() );
|
||||
delete m_hGameEventEditPanel.Get();
|
||||
m_hGameEventEditPanel = NULL;
|
||||
}
|
||||
|
||||
if ( m_hConsole.Get() )
|
||||
{
|
||||
windowposmgr->UnregisterPanel( m_hConsole.Get() );
|
||||
delete m_hConsole.Get();
|
||||
m_hConsole = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Loads up a new document
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CGameEventTool::LoadDocument( const char *pDocName )
|
||||
{
|
||||
Assert( !m_pDoc );
|
||||
|
||||
DestroyTools();
|
||||
|
||||
m_pDoc = new CGameEventEditDoc(/* this */);
|
||||
if ( !m_pDoc->LoadFromFile( pDocName ) )
|
||||
{
|
||||
delete m_pDoc;
|
||||
m_pDoc = NULL;
|
||||
Warning( "Fatal error loading '%s'\n", pDocName );
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowMiniViewport( true );
|
||||
|
||||
CreateTools( m_pDoc );
|
||||
InitTools();
|
||||
return true;
|
||||
}
|
||||
|
||||
CConsolePage *CGameEventTool::GetConsole()
|
||||
{
|
||||
return m_hConsole;
|
||||
}
|
||||
|
||||
|
||||
void CGameEventTool::ShowToolWindow( Panel *tool, char const *toolName, bool visible )
|
||||
{
|
||||
Assert( tool );
|
||||
|
||||
if ( tool->GetParent() == NULL && visible )
|
||||
{
|
||||
m_ToolWindowFactory.InstanceToolWindow( this, false, tool, toolName, false );
|
||||
}
|
||||
else if ( !visible )
|
||||
{
|
||||
ToolWindow *tw = dynamic_cast< ToolWindow * >( tool->GetParent()->GetParent() );
|
||||
Assert( tw );
|
||||
tw->RemovePage( tool );
|
||||
}
|
||||
}
|
||||
|
||||
void CGameEventTool::ToggleToolWindow( Panel *tool, char const *toolName )
|
||||
{
|
||||
Assert( tool );
|
||||
|
||||
if ( tool->GetParent() == NULL )
|
||||
{
|
||||
ShowToolWindow( tool, toolName, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowToolWindow( tool, toolName, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGameEventTool::OnToggleConsole()
|
||||
{
|
||||
if ( m_hConsole.Get() )
|
||||
{
|
||||
ToggleToolWindow( m_hConsole.Get(), "#BxConsole" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sets up the default layout
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameEventTool::OnDefaultLayout()
|
||||
{
|
||||
int y = m_pMenuBar->GetTall();
|
||||
|
||||
int usew, useh;
|
||||
GetSize( usew, useh );
|
||||
|
||||
int c = ToolWindow::GetToolWindowCount();
|
||||
for ( int i = c - 1; i >= 0 ; --i )
|
||||
{
|
||||
ToolWindow *kill = ToolWindow::GetToolWindow( i );
|
||||
delete kill;
|
||||
}
|
||||
|
||||
Assert( ToolWindow::GetToolWindowCount() == 0 );
|
||||
|
||||
CGameEventEditPanel *pEditPanel = GetGameEventEditPanel();
|
||||
CConsolePage *pConsole = GetConsole();
|
||||
|
||||
// Need three containers
|
||||
ToolWindow *pEditPanelWindow = m_ToolWindowFactory.InstanceToolWindow( GetClientArea(), false, pEditPanel, "#CommEditProperties", false );
|
||||
ToolWindow *pMiniViewport = dynamic_cast< ToolWindow* >( GetMiniViewport() );
|
||||
pMiniViewport->AddPage( pConsole, "#BxConsole", false );
|
||||
|
||||
int quarterScreen = usew / 4;
|
||||
SetMiniViewportBounds( quarterScreen, y, 3*quarterScreen, useh - y );
|
||||
pEditPanelWindow->SetBounds( 0, y, quarterScreen, useh - y );
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// GAMEEVENTS.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin\tools"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE,.\,..\common,$SRCDIR\game\shared"
|
||||
$PreprocessorDefinitions "$BASE;GAMEEVENTS_EXPORTS"
|
||||
}
|
||||
|
||||
$Linker
|
||||
{
|
||||
$AdditionalDependencies "$BASE Psapi.lib"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "GameEvents"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "gameevents.cpp"
|
||||
$File "gameeventeditdoc.cpp"
|
||||
$File "gameeventeditpanel.cpp"
|
||||
|
||||
$File "$SRCDIR\public\interpolatortypes.cpp"
|
||||
$File "$SRCDIR\public\registry.cpp"
|
||||
$File "$SRCDIR\public\vgui_controls\vgui_controls.cpp"
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "gameeventeditdoc.h"
|
||||
$File "gameeventeditpanel.h"
|
||||
$File "$SRCDIR\public\mathlib\mathlib.h"
|
||||
}
|
||||
|
||||
$Folder "Link Libraries"
|
||||
{
|
||||
$Lib datamodel
|
||||
$Lib dme_controls
|
||||
$Lib dmserializers
|
||||
$Lib mathlib
|
||||
$Lib matsys_controls
|
||||
$Lib movieobjects
|
||||
$Lib sfmobjects
|
||||
$Lib tier2
|
||||
$Lib tier3
|
||||
$Lib toolutils
|
||||
$Lib vgui_controls
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user