initial
This commit is contained in:
1500
utils/hlfaceposer/AnimationBrowser.cpp
Normal file
1500
utils/hlfaceposer/AnimationBrowser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
187
utils/hlfaceposer/AnimationBrowser.h
Normal file
187
utils/hlfaceposer/AnimationBrowser.h
Normal file
@@ -0,0 +1,187 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if !defined( ANIMATIONBROWSER_H )
|
||||
#define ANIMATIONBROWSER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#define IDC_AB_TRAYSCROLL 1001
|
||||
#define IDC_AB_THUMBNAIL_INCREASE 1002
|
||||
#define IDC_AB_THUMBNAIL_DECREASE 1003
|
||||
#define IDC_AB_CONTEXT_CREATEBITMAP 1004
|
||||
#define IDC_AB_CONTEXT_CREATEALLBITMAPS 1005
|
||||
#define IDC_AB_FILTERTAB 1006
|
||||
|
||||
#define IDC_AB_CREATE_CUSTOM 1007
|
||||
|
||||
#define IDC_AB_ADDTOGROUPSTART 1100
|
||||
#define IDC_AB_ADDTOGROUPEND 1199
|
||||
|
||||
#define IDC_AB_REMOVEFROMGROUPSTART 1200
|
||||
#define IDC_AB_REMOVEFROMGROUPEND 1299
|
||||
|
||||
#define IDC_AB_DELETEGROUPSTART 1300
|
||||
#define IDC_AB_DELETEGROUPEND 1399
|
||||
|
||||
#define IDC_AB_RENAMEGROUPSTART 1400
|
||||
#define IDC_AB_RENAMEGROUPEND 1499
|
||||
|
||||
#define COLOR_TRAYBACKGROUND Color( 240, 240, 220 )
|
||||
|
||||
#include "faceposertoolwindow.h"
|
||||
#include "StudioModel.h"
|
||||
|
||||
class CAnimBrowserTab;
|
||||
|
||||
class CCustomAnim
|
||||
{
|
||||
public:
|
||||
CCustomAnim( const FileNameHandle_t &h )
|
||||
:
|
||||
m_bDirty( false ),
|
||||
m_ShortName( UTL_INVAL_SYMBOL )
|
||||
{
|
||||
m_Handle = h;
|
||||
}
|
||||
|
||||
void LoadFromFile();
|
||||
void SaveToFile();
|
||||
|
||||
bool HasAnimation( char const *search );
|
||||
|
||||
bool m_bDirty;
|
||||
CUtlSymbol m_ShortName;
|
||||
FileNameHandle_t m_Handle;
|
||||
CUtlVector< CUtlSymbol > m_Animations;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class AnimationBrowser : public mxWindow, public IFacePoserToolWindow
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
FILTER_NONE = 0,
|
||||
FILTER_GESTURES,
|
||||
FILTER_POSTURES,
|
||||
FILTER_STRING,
|
||||
FILTER_FIRST_CUSTOM
|
||||
};
|
||||
|
||||
AnimationBrowser( mxWindow *parent, int id = 0 );
|
||||
virtual ~AnimationBrowser ( void );
|
||||
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void redraw ();
|
||||
virtual bool PaintBackground( void );
|
||||
|
||||
virtual int handleEvent (mxEvent *event);
|
||||
|
||||
virtual void Think( float dt );
|
||||
|
||||
void ThumbnailIncrease( void );
|
||||
void ThumbnailDecrease( void );
|
||||
void RestoreThumbnailSize( void );
|
||||
|
||||
void Select( int sequence );
|
||||
void Deselect( void );
|
||||
|
||||
void SetCellSize( int cellsize );
|
||||
|
||||
void ReloadBitmaps( void );
|
||||
virtual void OnModelChanged();
|
||||
|
||||
void OnAddCustomAnimationFilter();
|
||||
|
||||
private: // Methods
|
||||
|
||||
void OnFilter();
|
||||
bool SequencePassesFilter( StudioModel *model, int sequence, mstudioseqdesc_t &seqdesc );
|
||||
|
||||
int GetSequenceCount();
|
||||
mstudioseqdesc_t *GetSeqDesc( int index );
|
||||
int TranslateSequenceNumber( int index );
|
||||
|
||||
int GetCellUnderPosition( int x, int y );
|
||||
|
||||
bool ComputeRect( int cell, int& rcx, int& rcy, int& rcw, int& rch );
|
||||
int ComputePixelsNeeded( void );
|
||||
|
||||
void RepositionSlider();
|
||||
void SetClickedCell( int cell );
|
||||
void ShowRightClickMenu( int mx, int my );
|
||||
|
||||
void DrawThumbNail( int sequence, CChoreoWidgetDrawHelper& helper,
|
||||
int rcx, int rcy, int rcw, int rch );
|
||||
|
||||
void DrawSequenceFocusRect( CChoreoWidgetDrawHelper& helper, int x, int y, int w, int h, const Color& clr );
|
||||
void DrawSequenceDescription( CChoreoWidgetDrawHelper& helper, int x, int y, int w, int h, int sequence, mstudioseqdesc_t &seqdesc );
|
||||
|
||||
void DrawFocusRect( void );
|
||||
|
||||
// Custom group tab stuff
|
||||
void FindCustomFiles( char const *subdir, CUtlVector< FileNameHandle_t >& files );
|
||||
void AddCustomFile( const FileNameHandle_t& handle );
|
||||
void RenameCustomFile( int index );
|
||||
void DeleteCustomFile( int index );
|
||||
void PurgeCustom();
|
||||
void BuildCustomFromFiles( CUtlVector< FileNameHandle_t >& files );
|
||||
void UpdateCustomTabs();
|
||||
int FindCustomFile( char const *shortName );
|
||||
void AddAnimationToCustomFile( int index, char const *animationName );
|
||||
void RemoveAnimationFromCustomFile( int index, char const *animationName );
|
||||
void RemoveAllAnimationsFromCustomFile( int index );
|
||||
|
||||
private: // Data
|
||||
|
||||
mxScrollbar *slScrollbar;
|
||||
CAnimBrowserTab *m_pFilterTab;
|
||||
mxLineEdit *m_pSearchEntry;
|
||||
|
||||
int m_nTopOffset;
|
||||
|
||||
int m_nLastNumAnimations;
|
||||
|
||||
int m_nGranularity;
|
||||
|
||||
int m_nCurCell;
|
||||
int m_nClickedCell;
|
||||
|
||||
// Formatting
|
||||
int m_nButtonSquare;
|
||||
|
||||
int m_nGap;
|
||||
int m_nDescriptionHeight;
|
||||
int m_nSnapshotWidth;
|
||||
int m_nSnapshotHeight;
|
||||
|
||||
bool m_bDragging;
|
||||
RECT m_rcFocus;
|
||||
RECT m_rcOrig;
|
||||
int m_nDragCell;
|
||||
int m_nXStart;
|
||||
int m_nYStart;
|
||||
|
||||
mxButton *m_pThumbnailIncreaseButton;
|
||||
mxButton *m_pThumbnailDecreaseButton;
|
||||
|
||||
CUtlVector< int > m_Filtered;
|
||||
int m_nCurFilter;
|
||||
char m_szSearchString[ 256 ];
|
||||
|
||||
float m_flDragTime;
|
||||
|
||||
CUtlVector< CCustomAnim * > m_CustomAnimationTabs;
|
||||
};
|
||||
|
||||
extern AnimationBrowser *g_pAnimationBrowserTool;
|
||||
|
||||
#endif // ANIMATIONBROWSER_H
|
||||
993
utils/hlfaceposer/CloseCaptionTool.cpp
Normal file
993
utils/hlfaceposer/CloseCaptionTool.cpp
Normal file
@@ -0,0 +1,993 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <stdio.h>
|
||||
#include "hlfaceposer.h"
|
||||
#include "CloseCaptionTool.h"
|
||||
#include "choreowidgetdrawhelper.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
CloseCaptionTool *g_pCloseCaptionTool = 0;
|
||||
|
||||
#define STREAM_FONT "Tahoma"
|
||||
#define STREAM_POINTSIZE 12
|
||||
#define STREAM_LINEHEIGHT ( STREAM_POINTSIZE + 2 )
|
||||
#define STREAM_WEIGHT FW_NORMAL
|
||||
|
||||
#define CAPTION_LINGER_TIME 1.5f
|
||||
// FIXME: Yahn, what is this, it's coded up as a DELAY before when the closed caption is displayed. That seems odd.
|
||||
#define CAPTION_PREDISPLAY_TIME 0.0f // 0.5f
|
||||
|
||||
|
||||
|
||||
|
||||
// A work unit is a pre-processed chunk of CC text to display
|
||||
// Any state changes (font/color/etc) cause a new work unit to be precomputed
|
||||
// Moving onto a new line also causes a new Work Unit
|
||||
// The width and height are stored so that layout can be quickly recomputed each frame
|
||||
class CCloseCaptionWorkUnit
|
||||
{
|
||||
public:
|
||||
CCloseCaptionWorkUnit();
|
||||
~CCloseCaptionWorkUnit();
|
||||
|
||||
void SetWidth( int w );
|
||||
int GetWidth() const;
|
||||
|
||||
void SetHeight( int h );
|
||||
int GetHeight() const;
|
||||
|
||||
void SetPos( int x, int y );
|
||||
void GetPos( int& x, int &y ) const;
|
||||
|
||||
void SetBold( bool bold );
|
||||
bool GetBold() const;
|
||||
|
||||
void SetItalic( bool ital );
|
||||
bool GetItalic() const;
|
||||
|
||||
void SetStream( const wchar_t *stream );
|
||||
const wchar_t *GetStream() const;
|
||||
|
||||
void SetColor( const Color& clr );
|
||||
const Color& GetColor() const;
|
||||
|
||||
int GetFontNumber() const
|
||||
{
|
||||
return CloseCaptionTool::GetFontNumber( m_bBold, m_bItalic );
|
||||
}
|
||||
|
||||
void Dump()
|
||||
{
|
||||
char buf[ 2048 ];
|
||||
g_pLocalize->ConvertUnicodeToANSI( GetStream(), buf, sizeof( buf ) );
|
||||
|
||||
Msg( "x = %i, y = %i, w = %i h = %i text %s\n", m_nX, m_nY, m_nWidth, m_nHeight, buf );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
int m_nX;
|
||||
int m_nY;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
|
||||
bool m_bBold;
|
||||
bool m_bItalic;
|
||||
wchar_t *m_pszStream;
|
||||
Color m_Color;
|
||||
};
|
||||
|
||||
CCloseCaptionWorkUnit::CCloseCaptionWorkUnit() :
|
||||
m_nWidth(0),
|
||||
m_nHeight(0),
|
||||
m_bBold(false),
|
||||
m_bItalic(false),
|
||||
m_pszStream(0),
|
||||
m_Color( Color( 255, 255, 255 ) )
|
||||
{
|
||||
}
|
||||
|
||||
CCloseCaptionWorkUnit::~CCloseCaptionWorkUnit()
|
||||
{
|
||||
delete[] m_pszStream;
|
||||
m_pszStream = NULL;
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::SetWidth( int w )
|
||||
{
|
||||
m_nWidth = w;
|
||||
}
|
||||
|
||||
int CCloseCaptionWorkUnit::GetWidth() const
|
||||
{
|
||||
return m_nWidth;
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::SetHeight( int h )
|
||||
{
|
||||
m_nHeight = h;
|
||||
}
|
||||
|
||||
int CCloseCaptionWorkUnit::GetHeight() const
|
||||
{
|
||||
return m_nHeight;
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::SetPos( int x, int y )
|
||||
{
|
||||
m_nX = x;
|
||||
m_nY = y;
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::GetPos( int& x, int &y ) const
|
||||
{
|
||||
x = m_nX;
|
||||
y = m_nY;
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::SetBold( bool bold )
|
||||
{
|
||||
m_bBold = bold;
|
||||
}
|
||||
|
||||
bool CCloseCaptionWorkUnit::GetBold() const
|
||||
{
|
||||
return m_bBold;
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::SetItalic( bool ital )
|
||||
{
|
||||
m_bItalic = ital;
|
||||
}
|
||||
|
||||
bool CCloseCaptionWorkUnit::GetItalic() const
|
||||
{
|
||||
return m_bItalic;
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::SetStream( const wchar_t *stream )
|
||||
{
|
||||
delete[] m_pszStream;
|
||||
m_pszStream = NULL;
|
||||
|
||||
int len = wcslen( stream );
|
||||
Assert( len < 4096 );
|
||||
m_pszStream = new wchar_t[ len + 1 ];
|
||||
wcsncpy( m_pszStream, stream, len );
|
||||
m_pszStream[ len ] = L'\0';
|
||||
}
|
||||
|
||||
const wchar_t *CCloseCaptionWorkUnit::GetStream() const
|
||||
{
|
||||
return m_pszStream ? m_pszStream : L"";
|
||||
}
|
||||
|
||||
void CCloseCaptionWorkUnit::SetColor( const Color& clr )
|
||||
{
|
||||
m_Color = clr;
|
||||
}
|
||||
|
||||
const Color &CCloseCaptionWorkUnit::GetColor() const
|
||||
{
|
||||
return m_Color;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCloseCaptionItem
|
||||
{
|
||||
public:
|
||||
CCloseCaptionItem(
|
||||
wchar_t *stream,
|
||||
float timetolive,
|
||||
float predisplay,
|
||||
bool valid
|
||||
) :
|
||||
m_flTimeToLive( 0.0f ),
|
||||
m_bValid( false ),
|
||||
m_nTotalWidth( 0 ),
|
||||
m_nTotalHeight( 0 ),
|
||||
m_bSizeComputed( false )
|
||||
{
|
||||
SetStream( stream );
|
||||
SetTimeToLive( timetolive );
|
||||
SetPreDisplayTime( CAPTION_PREDISPLAY_TIME + predisplay );
|
||||
m_bValid = valid;
|
||||
m_bSizeComputed = false;
|
||||
}
|
||||
|
||||
CCloseCaptionItem( const CCloseCaptionItem& src )
|
||||
{
|
||||
SetStream( src.m_szStream );
|
||||
m_flTimeToLive = src.m_flTimeToLive;
|
||||
m_bValid = src.m_bValid;
|
||||
}
|
||||
|
||||
~CCloseCaptionItem( void )
|
||||
{
|
||||
while ( m_Work.Count() > 0 )
|
||||
{
|
||||
CCloseCaptionWorkUnit *unit = m_Work[ 0 ];
|
||||
m_Work.Remove( 0 );
|
||||
delete unit;
|
||||
}
|
||||
}
|
||||
|
||||
void SetStream( const wchar_t *stream)
|
||||
{
|
||||
wcsncpy( m_szStream, stream, sizeof( m_szStream ) / sizeof( wchar_t ) );
|
||||
}
|
||||
|
||||
const wchar_t *GetStream() const
|
||||
{
|
||||
return m_szStream;
|
||||
}
|
||||
|
||||
void SetTimeToLive( float ttl )
|
||||
{
|
||||
m_flTimeToLive = ttl;
|
||||
}
|
||||
|
||||
float GetTimeToLive( void ) const
|
||||
{
|
||||
return m_flTimeToLive;
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_bValid;
|
||||
}
|
||||
|
||||
void SetHeight( int h )
|
||||
{
|
||||
m_nTotalHeight = h;
|
||||
}
|
||||
int GetHeight() const
|
||||
{
|
||||
return m_nTotalHeight;
|
||||
}
|
||||
void SetWidth( int w )
|
||||
{
|
||||
m_nTotalWidth = w;
|
||||
}
|
||||
int GetWidth() const
|
||||
{
|
||||
return m_nTotalWidth;
|
||||
}
|
||||
|
||||
void AddWork( CCloseCaptionWorkUnit *unit )
|
||||
{
|
||||
m_Work.AddToTail( unit );
|
||||
}
|
||||
|
||||
int GetNumWorkUnits() const
|
||||
{
|
||||
return m_Work.Count();
|
||||
}
|
||||
|
||||
CCloseCaptionWorkUnit *GetWorkUnit( int index )
|
||||
{
|
||||
Assert( index >= 0 && index < m_Work.Count() );
|
||||
|
||||
return m_Work[ index ];
|
||||
}
|
||||
|
||||
void SetSizeComputed( bool computed )
|
||||
{
|
||||
m_bSizeComputed = computed;
|
||||
}
|
||||
|
||||
bool GetSizeComputed() const
|
||||
{
|
||||
return m_bSizeComputed;
|
||||
}
|
||||
|
||||
void SetPreDisplayTime( float t )
|
||||
{
|
||||
m_flPreDisplayTime = t;
|
||||
}
|
||||
|
||||
float GetPreDisplayTime() const
|
||||
{
|
||||
return m_flPreDisplayTime;
|
||||
}
|
||||
private:
|
||||
wchar_t m_szStream[ 256 ];
|
||||
|
||||
float m_flPreDisplayTime;
|
||||
float m_flTimeToLive;
|
||||
bool m_bValid;
|
||||
int m_nTotalWidth;
|
||||
int m_nTotalHeight;
|
||||
|
||||
bool m_bSizeComputed;
|
||||
|
||||
CUtlVector< CCloseCaptionWorkUnit * > m_Work;
|
||||
};
|
||||
|
||||
ICloseCaptionManager *closecaptionmanager = NULL;
|
||||
|
||||
CloseCaptionTool::CloseCaptionTool( mxWindow *parent )
|
||||
: IFacePoserToolWindow( "CloseCaptionTool", "Close Caption" ), mxWindow( parent, 0, 0, 0, 0 )
|
||||
{
|
||||
m_nLastItemCount = -1;
|
||||
closecaptionmanager = this;
|
||||
|
||||
m_hFonts[ CCFONT_NORMAL ] = CreateFont(
|
||||
-STREAM_POINTSIZE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
STREAM_WEIGHT,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
DEFAULT_CHARSET,
|
||||
OUT_TT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
ANTIALIASED_QUALITY,
|
||||
DEFAULT_PITCH,
|
||||
STREAM_FONT );
|
||||
|
||||
m_hFonts[ CCFONT_ITALIC ] = CreateFont(
|
||||
-STREAM_POINTSIZE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
STREAM_WEIGHT,
|
||||
TRUE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
DEFAULT_CHARSET,
|
||||
OUT_TT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
ANTIALIASED_QUALITY,
|
||||
DEFAULT_PITCH,
|
||||
STREAM_FONT );
|
||||
|
||||
m_hFonts[ CCFONT_BOLD ] = CreateFont(
|
||||
-STREAM_POINTSIZE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
700,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
DEFAULT_CHARSET,
|
||||
OUT_TT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
ANTIALIASED_QUALITY,
|
||||
DEFAULT_PITCH,
|
||||
STREAM_FONT );
|
||||
|
||||
m_hFonts[ CCFONT_ITALICBOLD ] = CreateFont(
|
||||
-STREAM_POINTSIZE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
700,
|
||||
TRUE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
DEFAULT_CHARSET,
|
||||
OUT_TT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
ANTIALIASED_QUALITY,
|
||||
DEFAULT_PITCH,
|
||||
STREAM_FONT );
|
||||
}
|
||||
|
||||
CloseCaptionTool::~CloseCaptionTool( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : dt -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CloseCaptionTool::Think( float dt )
|
||||
{
|
||||
int c = m_Items.Count();
|
||||
int i;
|
||||
|
||||
// Pass one decay all timers
|
||||
for ( i = 0 ; i < c ; ++i )
|
||||
{
|
||||
CCloseCaptionItem *item = m_Items[ i ];
|
||||
|
||||
float predisplay = item->GetPreDisplayTime();
|
||||
if ( predisplay > 0.0f )
|
||||
{
|
||||
predisplay -= dt;
|
||||
predisplay = max( 0.0f, predisplay );
|
||||
item->SetPreDisplayTime( predisplay );
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove time from actual playback
|
||||
float ttl = item->GetTimeToLive();
|
||||
ttl -= dt;
|
||||
ttl = max( 0.0f, ttl );
|
||||
item->SetTimeToLive( ttl );
|
||||
}
|
||||
}
|
||||
|
||||
// Pass two, remove from head until we get to first item with time remaining
|
||||
bool foundfirstnondeletion = false;
|
||||
for ( i = 0 ; i < c ; ++i )
|
||||
{
|
||||
CCloseCaptionItem *item = m_Items[ i ];
|
||||
|
||||
// Skip items not yet showing...
|
||||
float predisplay = item->GetPreDisplayTime();
|
||||
if ( predisplay > 0.0f )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float ttl = item->GetTimeToLive();
|
||||
if ( ttl > 0.0f )
|
||||
{
|
||||
foundfirstnondeletion = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip the remainder of the items after we find the first/oldest active item
|
||||
if ( foundfirstnondeletion )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
delete item;
|
||||
m_Items.Remove( i );
|
||||
--i;
|
||||
--c;
|
||||
}
|
||||
|
||||
if ( m_Items.Count() != m_nLastItemCount )
|
||||
{
|
||||
redraw();
|
||||
}
|
||||
m_nLastItemCount = m_Items.Count();
|
||||
}
|
||||
|
||||
struct VisibleStreamItem
|
||||
{
|
||||
int height;
|
||||
CCloseCaptionItem *item;
|
||||
};
|
||||
|
||||
void CloseCaptionTool::redraw()
|
||||
{
|
||||
if ( !ToolCanDraw() )
|
||||
return;
|
||||
|
||||
CChoreoWidgetDrawHelper drawHelper( this );
|
||||
HandleToolRedraw( drawHelper );
|
||||
|
||||
RECT rcOutput;
|
||||
drawHelper.GetClientRect( rcOutput );
|
||||
|
||||
RECT rcText = rcOutput;
|
||||
drawHelper.DrawFilledRect( Color( 0, 0, 0 ), rcText );
|
||||
drawHelper.DrawOutlinedRect( Color( 200, 245, 150 ), PS_SOLID, 2, rcText );
|
||||
InflateRect( &rcText, -4, 0 );
|
||||
|
||||
int avail_width = rcText.right - rcText.left;
|
||||
|
||||
int totalheight = 0;
|
||||
int i;
|
||||
CUtlVector< VisibleStreamItem > visibleitems;
|
||||
int c = m_Items.Count();
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
CCloseCaptionItem *item = m_Items[ i ];
|
||||
|
||||
// Not ready for display yet.
|
||||
if ( item->GetPreDisplayTime() > 0.0f )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !item->GetSizeComputed() )
|
||||
{
|
||||
ComputeStreamWork( drawHelper, avail_width, item );
|
||||
}
|
||||
|
||||
int itemheight = item->GetHeight();
|
||||
|
||||
totalheight += itemheight;
|
||||
|
||||
VisibleStreamItem si;
|
||||
si.height = itemheight;
|
||||
si.item = item;
|
||||
|
||||
visibleitems.AddToTail( si );
|
||||
}
|
||||
|
||||
rcText.bottom -= 2;
|
||||
rcText.top = rcText.bottom - totalheight;
|
||||
|
||||
// Now draw them
|
||||
c = visibleitems.Count();
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
VisibleStreamItem *si = &visibleitems[ i ];
|
||||
|
||||
int height = si->height;
|
||||
CCloseCaptionItem *item = si->item;
|
||||
|
||||
rcText.bottom = rcText.top + height;
|
||||
|
||||
DrawStream( drawHelper, rcText, item );
|
||||
|
||||
OffsetRect( &rcText, 0, height );
|
||||
|
||||
if ( rcText.top >= rcOutput.bottom )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int CloseCaptionTool::handleEvent( mxEvent *event )
|
||||
{
|
||||
//MDLCACHE_CRITICAL_SECTION_( g_pMDLCache );
|
||||
|
||||
int iret = 0;
|
||||
|
||||
if ( HandleToolEvent( event ) )
|
||||
{
|
||||
return iret;
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
bool CloseCaptionTool::PaintBackground()
|
||||
{
|
||||
redraw();
|
||||
return false;
|
||||
}
|
||||
|
||||
void CloseCaptionTool::Reset( void )
|
||||
{
|
||||
while ( m_Items.Count() > 0 )
|
||||
{
|
||||
CCloseCaptionItem *i = m_Items[ 0 ];
|
||||
delete i;
|
||||
m_Items.Remove( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CloseCaptionTool::Process( char const *tokenname, float duration, int languageid )
|
||||
{
|
||||
bool valid = true;
|
||||
wchar_t stream[ 256 ];
|
||||
if ( !LookupUnicodeText( languageid, tokenname, stream, sizeof( stream ) / sizeof( wchar_t ) ) )
|
||||
{
|
||||
valid = false;
|
||||
g_pLocalize->ConvertANSIToUnicode( va( "--> Missing Caption[%s]", tokenname ), stream, sizeof( stream ) );
|
||||
}
|
||||
|
||||
if ( !wcsncmp( stream, L"!!!", wcslen( L"!!!" ) ) )
|
||||
{
|
||||
// It's in the text file, but hasn't been translated...
|
||||
valid = false;
|
||||
}
|
||||
|
||||
// Nothing to do...
|
||||
if ( wcslen( stream ) == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float delay = 0.0f;
|
||||
|
||||
wchar_t phrase[ 1024 ];
|
||||
wchar_t *out = phrase;
|
||||
|
||||
for ( const wchar_t *curpos = stream; curpos && *curpos != L'\0'; ++curpos )
|
||||
{
|
||||
wchar_t cmd[ 256 ];
|
||||
wchar_t args[ 256 ];
|
||||
|
||||
if ( SplitCommand( &curpos, cmd, args ) )
|
||||
{
|
||||
if ( !wcscmp( cmd, L"delay" ) )
|
||||
{
|
||||
|
||||
// End current phrase
|
||||
*out = L'\0';
|
||||
|
||||
if ( wcslen( phrase ) > 0 )
|
||||
{
|
||||
CCloseCaptionItem *item = new CCloseCaptionItem( phrase, duration + CAPTION_LINGER_TIME, delay, valid );
|
||||
m_Items.AddToTail( item );
|
||||
}
|
||||
|
||||
// Start new phrase
|
||||
out = phrase;
|
||||
|
||||
// Delay must be positive
|
||||
delay = max( 0.0f, (float)wcstod( args, NULL ) );
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
*out++ = *curpos;
|
||||
}
|
||||
|
||||
// End final phrase, if any
|
||||
*out = L'\0';
|
||||
if ( wcslen( phrase ) > 0 )
|
||||
{
|
||||
CCloseCaptionItem *item = new CCloseCaptionItem( phrase, duration + CAPTION_LINGER_TIME, delay, valid );
|
||||
m_Items.AddToTail( item );
|
||||
}
|
||||
}
|
||||
|
||||
bool CloseCaptionTool::LookupUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count )
|
||||
{
|
||||
wchar_t *outstr = g_pLocalize->Find( token );
|
||||
if ( !outstr )
|
||||
{
|
||||
wcsncpy( outbuf, L"<can't find entry>", count );
|
||||
return false;
|
||||
}
|
||||
|
||||
wcsncpy( outbuf, outstr, count );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CloseCaptionTool::LookupStrippedUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count )
|
||||
{
|
||||
wchar_t *outstr = g_pLocalize->Find( token );
|
||||
if ( !outstr )
|
||||
{
|
||||
wcsncpy( outbuf, L"<can't find entry>", count );
|
||||
return false;
|
||||
}
|
||||
|
||||
const wchar_t *curpos = outstr;
|
||||
wchar_t *out = outbuf;
|
||||
size_t outlen = 0;
|
||||
|
||||
for ( ;
|
||||
curpos && *curpos != L'\0' && outlen < count;
|
||||
++curpos )
|
||||
{
|
||||
wchar_t cmd[ 256 ];
|
||||
wchar_t args[ 256 ];
|
||||
|
||||
if ( SplitCommand( &curpos, cmd, args ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
*out++ = *curpos;
|
||||
++outlen;
|
||||
}
|
||||
|
||||
*out = L'\0';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CloseCaptionTool::SplitCommand( wchar_t const **ppIn, wchar_t *cmd, wchar_t *args ) const
|
||||
{
|
||||
const wchar_t *in = *ppIn;
|
||||
const wchar_t *oldin = in;
|
||||
|
||||
if ( in[0] != L'<' )
|
||||
{
|
||||
*ppIn += ( oldin - in );
|
||||
return false;
|
||||
}
|
||||
|
||||
args[ 0 ] = 0;
|
||||
cmd[ 0 ]= 0;
|
||||
wchar_t *out = cmd;
|
||||
in++;
|
||||
while ( *in != L'\0' && *in != L':' && *in != L'>' && !V_isspace( *in ) )
|
||||
{
|
||||
*out++ = *in++;
|
||||
}
|
||||
*out = L'\0';
|
||||
|
||||
if ( *in != L':' )
|
||||
{
|
||||
*ppIn += ( in - oldin );
|
||||
return true;
|
||||
}
|
||||
|
||||
in++;
|
||||
out = args;
|
||||
while ( *in != L'\0' && *in != L'>' )
|
||||
{
|
||||
*out++ = *in++;
|
||||
}
|
||||
*out = L'\0';
|
||||
|
||||
//if ( *in == L'>' )
|
||||
// in++;
|
||||
|
||||
*ppIn += ( in - oldin );
|
||||
return true;
|
||||
}
|
||||
|
||||
struct WorkUnitParams
|
||||
{
|
||||
WorkUnitParams()
|
||||
{
|
||||
Q_memset( stream, 0, sizeof( stream ) );
|
||||
out = stream;
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 0;
|
||||
bold = italic = false;
|
||||
clr = Color( 255, 255, 255 );
|
||||
newline = false;
|
||||
}
|
||||
|
||||
~WorkUnitParams()
|
||||
{
|
||||
}
|
||||
|
||||
void Finalize()
|
||||
{
|
||||
*out = L'\0';
|
||||
}
|
||||
|
||||
void Next()
|
||||
{
|
||||
// Restart output
|
||||
Q_memset( stream, 0, sizeof( stream ) );
|
||||
out = stream;
|
||||
|
||||
x += width;
|
||||
|
||||
width = 0;
|
||||
// Leave bold, italic and color alone!!!
|
||||
|
||||
if ( newline )
|
||||
{
|
||||
newline = false;
|
||||
x = 0;
|
||||
y += STREAM_LINEHEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
int GetFontNumber()
|
||||
{
|
||||
return CloseCaptionTool::GetFontNumber( bold, italic );
|
||||
}
|
||||
|
||||
wchar_t stream[ 1024 ];
|
||||
wchar_t *out;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
bool bold;
|
||||
bool italic;
|
||||
Color clr;
|
||||
bool newline;
|
||||
};
|
||||
|
||||
void CloseCaptionTool::AddWorkUnit( CCloseCaptionItem *item,
|
||||
WorkUnitParams& params )
|
||||
{
|
||||
params.Finalize();
|
||||
|
||||
if ( wcslen( params.stream ) > 0 )
|
||||
{
|
||||
CCloseCaptionWorkUnit *wu = new CCloseCaptionWorkUnit();
|
||||
|
||||
wu->SetStream( params.stream );
|
||||
wu->SetColor( params.clr );
|
||||
wu->SetBold( params.bold );
|
||||
wu->SetItalic( params.italic );
|
||||
wu->SetWidth( params.width );
|
||||
wu->SetHeight( STREAM_LINEHEIGHT );
|
||||
wu->SetPos( params.x, params.y );
|
||||
|
||||
|
||||
int curheight = item->GetHeight();
|
||||
int curwidth = item->GetWidth();
|
||||
|
||||
curheight = max( curheight, params.y + wu->GetHeight() );
|
||||
curwidth = max( curwidth, params.x + params.width );
|
||||
|
||||
item->SetHeight( curheight );
|
||||
item->SetWidth( curwidth );
|
||||
|
||||
// Add it
|
||||
item->AddWork( wu );
|
||||
|
||||
params.Next();
|
||||
}
|
||||
}
|
||||
|
||||
void CloseCaptionTool::ComputeStreamWork( CChoreoWidgetDrawHelper &helper, int available_width, CCloseCaptionItem *item )
|
||||
{
|
||||
// Start with a clean param block
|
||||
WorkUnitParams params;
|
||||
|
||||
const wchar_t *curpos = item->GetStream();
|
||||
|
||||
CUtlVector< Color > colorStack;
|
||||
|
||||
for ( ; curpos && *curpos != L'\0'; ++curpos )
|
||||
{
|
||||
wchar_t cmd[ 256 ];
|
||||
wchar_t args[ 256 ];
|
||||
|
||||
if ( SplitCommand( &curpos, cmd, args ) )
|
||||
{
|
||||
if ( !wcscmp( cmd, L"cr" ) )
|
||||
{
|
||||
params.newline = true;
|
||||
AddWorkUnit( item, params);
|
||||
}
|
||||
else if ( !wcscmp( cmd, L"clr" ) )
|
||||
{
|
||||
AddWorkUnit( item, params );
|
||||
|
||||
if ( args[0] == 0 && colorStack.Count()>= 2)
|
||||
{
|
||||
colorStack.Remove( colorStack.Count() - 1 );
|
||||
params.clr = colorStack[ colorStack.Count() - 1 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
int r, g, b;
|
||||
Color newcolor;
|
||||
if ( 3 == swscanf( args, L"%i,%i,%i", &r, &g, &b ) )
|
||||
{
|
||||
newcolor = Color( r, g, b );
|
||||
colorStack.AddToTail( newcolor );
|
||||
params.clr = colorStack[ colorStack.Count() - 1 ];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !wcscmp( cmd, L"playerclr" ) )
|
||||
{
|
||||
AddWorkUnit( item, params );
|
||||
|
||||
if ( args[0] == 0 && colorStack.Count()>= 2)
|
||||
{
|
||||
colorStack.Remove( colorStack.Count() - 1 );
|
||||
params.clr = colorStack[ colorStack.Count() - 1 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
// player and npc color selector
|
||||
// e.g.,. 255,255,255:200,200,200
|
||||
int pr, pg, pb, nr, ng, nb;
|
||||
Color newcolor;
|
||||
if ( 6 == swscanf( args, L"%i,%i,%i:%i,%i,%i", &pr, &pg, &pb, &nr, &ng, &nb ) )
|
||||
{
|
||||
// FIXME: nothing in .vcds is ever from the player...
|
||||
newcolor = /*item->IsFromPlayer()*/ false ? Color( pr, pg, pb ) : Color( nr, ng, nb );
|
||||
colorStack.AddToTail( newcolor );
|
||||
params.clr = colorStack[ colorStack.Count() - 1 ];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !wcscmp( cmd, L"I" ) )
|
||||
{
|
||||
AddWorkUnit( item, params );
|
||||
params.italic = !params.italic;
|
||||
}
|
||||
else if ( !wcscmp( cmd, L"B" ) )
|
||||
{
|
||||
AddWorkUnit( item, params );
|
||||
params.bold = !params.bold;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
HFONT useF = m_hFonts[ params.GetFontNumber() ];
|
||||
|
||||
int w = helper.CalcTextWidthW( useF, L"%c", *curpos );
|
||||
|
||||
if ( ( params.x + params.width ) + w > available_width )
|
||||
{
|
||||
params.newline = true;
|
||||
AddWorkUnit( item, params );
|
||||
}
|
||||
*params.out++ = *curpos;
|
||||
params.width += w;
|
||||
}
|
||||
|
||||
// Add the final unit.
|
||||
params.newline = true;
|
||||
AddWorkUnit( item, params );
|
||||
|
||||
item->SetSizeComputed( true );
|
||||
|
||||
// DumpWork( item );
|
||||
}
|
||||
|
||||
void CloseCaptionTool:: DumpWork( CCloseCaptionItem *item )
|
||||
{
|
||||
int c = item->GetNumWorkUnits();
|
||||
for ( int i = 0 ; i < c; ++i )
|
||||
{
|
||||
CCloseCaptionWorkUnit *wu = item->GetWorkUnit( i );
|
||||
wu->Dump();
|
||||
}
|
||||
}
|
||||
|
||||
void CloseCaptionTool::DrawStream( CChoreoWidgetDrawHelper &helper, RECT &rcText, CCloseCaptionItem *item )
|
||||
{
|
||||
int c = item->GetNumWorkUnits();
|
||||
|
||||
RECT rcOut;
|
||||
rcOut.left = rcText.left;
|
||||
|
||||
for ( int i = 0 ; i < c; ++i )
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
CCloseCaptionWorkUnit *wu = item->GetWorkUnit( i );
|
||||
|
||||
HFONT useF = m_hFonts[ wu->GetFontNumber() ];
|
||||
|
||||
wu->GetPos( x, y );
|
||||
|
||||
rcOut.left = rcText.left + x;
|
||||
rcOut.right = rcOut.left + wu->GetWidth();
|
||||
rcOut.top = rcText.top + y;
|
||||
rcOut.bottom = rcOut.top + wu->GetHeight();
|
||||
|
||||
Color useColor = wu->GetColor();
|
||||
|
||||
if ( !item->IsValid() )
|
||||
{
|
||||
useColor = Color( 255, 255, 255 );
|
||||
rcOut.right += 2;
|
||||
helper.DrawFilledRect( Color( 100, 100, 40 ), rcOut );
|
||||
}
|
||||
|
||||
helper.DrawColoredTextW( useF, useColor,
|
||||
rcOut, L"%s", wu->GetStream() );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int CloseCaptionTool::GetFontNumber( bool bold, bool italic )
|
||||
{
|
||||
if ( bold || italic )
|
||||
{
|
||||
if( bold && italic )
|
||||
{
|
||||
return CloseCaptionTool::CCFONT_ITALICBOLD;
|
||||
}
|
||||
|
||||
if ( bold )
|
||||
{
|
||||
return CloseCaptionTool::CCFONT_BOLD;
|
||||
}
|
||||
|
||||
if ( italic )
|
||||
{
|
||||
return CloseCaptionTool::CCFONT_ITALIC;
|
||||
}
|
||||
}
|
||||
|
||||
return CloseCaptionTool::CCFONT_NORMAL;
|
||||
}
|
||||
74
utils/hlfaceposer/CloseCaptionTool.h
Normal file
74
utils/hlfaceposer/CloseCaptionTool.h
Normal file
@@ -0,0 +1,74 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CLOSECAPTIONTOOL_H
|
||||
#define CLOSECAPTIONTOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "UtlVector.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
#include "iclosecaptionmanager.h"
|
||||
|
||||
class CCloseCaptionItem;
|
||||
struct WorkUnitParams;
|
||||
|
||||
class CloseCaptionTool : public mxWindow, public IFacePoserToolWindow, public ICloseCaptionManager
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
CloseCaptionTool( mxWindow *parent );
|
||||
~CloseCaptionTool( void );
|
||||
|
||||
// ICloseCaptionManager
|
||||
virtual void Reset( void );
|
||||
virtual void Process( char const *tokenname, float duration, int languageid );
|
||||
virtual bool LookupUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count );
|
||||
virtual bool LookupStrippedUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count );
|
||||
|
||||
// End ICloseCaptionManager
|
||||
|
||||
virtual void Think( float dt );
|
||||
|
||||
virtual int handleEvent( mxEvent *event );
|
||||
virtual void redraw( void );
|
||||
virtual bool PaintBackground();
|
||||
|
||||
enum
|
||||
{
|
||||
CCFONT_NORMAL = 0,
|
||||
CCFONT_ITALIC,
|
||||
CCFONT_BOLD,
|
||||
CCFONT_ITALICBOLD
|
||||
};
|
||||
|
||||
static int GetFontNumber( bool bold, bool italic );
|
||||
|
||||
private:
|
||||
void ComputeStreamWork( CChoreoWidgetDrawHelper &helper, int available_width, CCloseCaptionItem *item );
|
||||
void DrawStream( CChoreoWidgetDrawHelper &helper, RECT &rcText, CCloseCaptionItem *item );
|
||||
bool SplitCommand( const wchar_t **in, wchar_t *cmd, wchar_t *args ) const;
|
||||
|
||||
void ParseCloseCaptionStream( const wchar_t *in, int available_width );
|
||||
|
||||
void DumpWork( CCloseCaptionItem *item );
|
||||
|
||||
void AddWorkUnit(
|
||||
CCloseCaptionItem *item,
|
||||
WorkUnitParams& params );
|
||||
|
||||
CUtlVector< CCloseCaptionItem * > m_Items;
|
||||
|
||||
HFONT m_hFonts[ 4 ]; // normal, italic, bold, bold + italic
|
||||
|
||||
int m_nLastItemCount;
|
||||
};
|
||||
|
||||
extern CloseCaptionTool *g_pCloseCaptionTool;
|
||||
|
||||
#endif // CLOSECAPTIONTOOL_H
|
||||
271
utils/hlfaceposer/EdgeProperties.cpp
Normal file
271
utils/hlfaceposer/EdgeProperties.cpp
Normal file
@@ -0,0 +1,271 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EdgeProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "hlfaceposer.h"
|
||||
#include "choreoevent.h"
|
||||
#include "choreoscene.h"
|
||||
#include "expressions.h"
|
||||
#include "choreoactor.h"
|
||||
#include "ifaceposersound.h"
|
||||
#include "expclass.h"
|
||||
#include "scriplib.h"
|
||||
|
||||
static CEdgePropertiesParams g_Params;
|
||||
|
||||
void CEdgePropertiesParams::SetFromFlexTrack( CFlexAnimationTrack *track )
|
||||
{
|
||||
for ( int i = 0 ; i < 2; ++i )
|
||||
{
|
||||
m_bActive[ i ] = track->IsEdgeActive( i == 0 ? true : false );
|
||||
|
||||
int curveType = 0;
|
||||
track->GetEdgeInfo( i == 0 ? true : false, curveType, m_flValue[ i ] );
|
||||
|
||||
if ( i == 0 )
|
||||
{
|
||||
m_InterpolatorType[ i ] = GET_RIGHT_CURVE( curveType );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_InterpolatorType[ i ] = GET_LEFT_CURVE( curveType );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEdgePropertiesParams::ApplyToTrack( CFlexAnimationTrack *track )
|
||||
{
|
||||
for ( int i = 0 ; i < 2; ++i )
|
||||
{
|
||||
track->SetEdgeActive( i == 0 ? true : false, m_bActive[ i ] );
|
||||
|
||||
int curveType = 0;
|
||||
if ( i == 0 )
|
||||
{
|
||||
curveType = MAKE_CURVE_TYPE( 0, m_InterpolatorType[ i ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
curveType = MAKE_CURVE_TYPE( m_InterpolatorType[ i ], 0 );
|
||||
}
|
||||
|
||||
track->SetEdgeInfo( i == 0 ? true : false, curveType, m_flValue[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
void CEdgePropertiesParams::SetFromCurve( CCurveData *ramp )
|
||||
{
|
||||
for ( int i = 0 ; i < 2; ++i )
|
||||
{
|
||||
m_bActive[ i ] = ramp->IsEdgeActive( i == 0 ? true : false );
|
||||
|
||||
int curveType = 0;
|
||||
ramp->GetEdgeInfo( i == 0 ? true : false, curveType, m_flValue[ i ] );
|
||||
|
||||
if ( i == 0 )
|
||||
{
|
||||
m_InterpolatorType[ i ] = GET_RIGHT_CURVE( curveType );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_InterpolatorType[ i ] = GET_LEFT_CURVE( curveType );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEdgePropertiesParams::ApplyToCurve( CCurveData *ramp )
|
||||
{
|
||||
for ( int i = 0 ; i < 2; ++i )
|
||||
{
|
||||
ramp->SetEdgeActive( i == 0 ? true : false, m_bActive[ i ] );
|
||||
|
||||
int curveType = 0;
|
||||
if ( i == 0 )
|
||||
{
|
||||
curveType = MAKE_CURVE_TYPE( 0, m_InterpolatorType[ i ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
curveType = MAKE_CURVE_TYPE( m_InterpolatorType[ i ], 0 );
|
||||
}
|
||||
|
||||
ramp->SetEdgeInfo( i == 0 ? true : false, curveType, m_flValue[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void PopulateCurveType( HWND control, CEdgePropertiesParams *params, bool isLeftEdge )
|
||||
{
|
||||
SendMessage( control, CB_RESETCONTENT, 0, 0 );
|
||||
|
||||
for ( int i = 0; i < NUM_INTERPOLATE_TYPES; ++i )
|
||||
{
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)Interpolator_NameForInterpolator( i, true ) );
|
||||
}
|
||||
|
||||
SendMessage( control, CB_SETCURSEL , params->m_InterpolatorType[ isLeftEdge ? 0 : 1 ], 0 );
|
||||
|
||||
}
|
||||
|
||||
static void Reset( HWND hwndDlg, bool left )
|
||||
{
|
||||
SendMessage( GetDlgItem( hwndDlg, left ? IDC_LEFT_ACTIVE : IDC_RIGHT_ACTIVE ), BM_SETCHECK,
|
||||
( WPARAM )BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
SendMessage( GetDlgItem( hwndDlg, left ? IDC_LEFT_CURVETYPE : IDC_RIGHT_CURVETYPE ), CB_SETCURSEL, 0, 0 );
|
||||
SetDlgItemText( hwndDlg, left ? IDC_LEFT_ZEROVALUE : IDC_RIGHT_ZEROVALUE, "0.0" );
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_HOLD_OUT ), BM_SETCHECK,
|
||||
( WPARAM )BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EdgePropertiesDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
PopulateCurveType( GetDlgItem( hwndDlg, IDC_LEFT_CURVETYPE ), &g_Params, true );
|
||||
PopulateCurveType( GetDlgItem( hwndDlg, IDC_RIGHT_CURVETYPE ), &g_Params, false );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_LEFT_ZEROVALUE, va( "%f", g_Params.m_flValue[ 0 ] ) );
|
||||
SetDlgItemText( hwndDlg, IDC_RIGHT_ZEROVALUE, va( "%f", g_Params.m_flValue[ 1 ] ) );
|
||||
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_LEFT_ACTIVE ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bActive[ 0 ] ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_RIGHT_ACTIVE ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bActive[ 1 ] ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_LEFT_ZEROVALUE ) );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_LEFT_RESET:
|
||||
{
|
||||
Reset( hwndDlg, true );
|
||||
}
|
||||
break;
|
||||
case IDC_RIGHT_RESET:
|
||||
{
|
||||
Reset( hwndDlg, false );
|
||||
}
|
||||
break;
|
||||
case IDC_LEFT_CURVETYPE:
|
||||
{
|
||||
if ( HIWORD( wParam ) == CBN_SELCHANGE )
|
||||
{
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_LEFT_ACTIVE ), BM_SETCHECK,
|
||||
( WPARAM ) BST_CHECKED,
|
||||
( LPARAM )0 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_RIGHT_CURVETYPE:
|
||||
{
|
||||
if ( HIWORD( wParam ) == CBN_SELCHANGE )
|
||||
{
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_RIGHT_ACTIVE ), BM_SETCHECK,
|
||||
( WPARAM ) BST_CHECKED,
|
||||
( LPARAM )0 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_LEFT_ZEROVALUE:
|
||||
{
|
||||
if ( HIWORD( wParam ) == EN_CHANGE )
|
||||
{
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_LEFT_ACTIVE ), BM_SETCHECK,
|
||||
( WPARAM ) BST_CHECKED,
|
||||
( LPARAM )0 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_RIGHT_ZEROVALUE:
|
||||
{
|
||||
if ( HIWORD( wParam ) == EN_CHANGE )
|
||||
{
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_RIGHT_ACTIVE ), BM_SETCHECK,
|
||||
( WPARAM ) BST_CHECKED,
|
||||
( LPARAM )0 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDOK:
|
||||
{
|
||||
char sz[ 64 ];
|
||||
GetDlgItemText( hwndDlg, IDC_LEFT_ZEROVALUE, sz, sizeof( sz ) );
|
||||
g_Params.m_flValue[ 0 ] = clamp( Q_atof( sz ), 0.0f, 1.0f );
|
||||
GetDlgItemText( hwndDlg, IDC_RIGHT_ZEROVALUE, sz, sizeof( sz ) );
|
||||
g_Params.m_flValue[ 1 ] = clamp( Q_atof( sz ), 0.0f, 1.0f );
|
||||
|
||||
g_Params.m_bActive[ 0 ] = SendMessage( GetDlgItem( hwndDlg, IDC_LEFT_ACTIVE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
g_Params.m_bActive[ 1 ] = SendMessage( GetDlgItem( hwndDlg, IDC_RIGHT_ACTIVE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
|
||||
int interpolatorType;
|
||||
interpolatorType = SendMessage( GetDlgItem( hwndDlg, IDC_LEFT_CURVETYPE ), CB_GETCURSEL, 0, 0 );
|
||||
if ( interpolatorType != CB_ERR )
|
||||
{
|
||||
g_Params.m_InterpolatorType[ 0 ] = interpolatorType;
|
||||
}
|
||||
interpolatorType = SendMessage( GetDlgItem( hwndDlg, IDC_RIGHT_CURVETYPE ), CB_GETCURSEL, 0, 0 );
|
||||
if ( interpolatorType != CB_ERR )
|
||||
{
|
||||
g_Params.m_InterpolatorType[ 1 ] = interpolatorType;
|
||||
}
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EdgeProperties( CEdgePropertiesParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EDGEPROPERTIES ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EdgePropertiesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
42
utils/hlfaceposer/EdgeProperties.h
Normal file
42
utils/hlfaceposer/EdgeProperties.h
Normal file
@@ -0,0 +1,42 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EDGEPROPERTIES_H
|
||||
#define EDGEPROPERTIES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CCurveData;
|
||||
class ChoreoScene;
|
||||
class CChoreoEvent;
|
||||
class CFlexAnimationTrack;
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CEdgePropertiesParams : public CBaseDialogParams
|
||||
{
|
||||
// GlobalEvent descriptive name
|
||||
char m_szName[ 256 ];
|
||||
|
||||
void SetFromFlexTrack( CFlexAnimationTrack *track );
|
||||
void ApplyToTrack( CFlexAnimationTrack *track );
|
||||
|
||||
void SetFromCurve( CCurveData *ramp );
|
||||
void ApplyToCurve( CCurveData *ramp );
|
||||
|
||||
bool m_bActive[ 2 ];
|
||||
int m_InterpolatorType[ 2 ];
|
||||
float m_flValue[ 2 ];
|
||||
};
|
||||
|
||||
int EdgeProperties( CEdgePropertiesParams *params );
|
||||
|
||||
#endif // EDGEPROPERTIES_H
|
||||
82
utils/hlfaceposer/EditPhrase.cpp
Normal file
82
utils/hlfaceposer/EditPhrase.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#define UNICODE
|
||||
|
||||
#include "resource.h"
|
||||
#include "EditPhrase.h"
|
||||
#include "mxtk/mx.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CEditPhraseParams g_Params;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EditPhraseDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
|
||||
SetDlgItemTextW( hwndDlg, IDC_INPUTSTRING, g_Params.m_szInputText );
|
||||
SetDlgItemTextA( hwndDlg, IDC_STATIC_PROMPT, g_Params.m_szPrompt );
|
||||
|
||||
SetWindowTextA( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_INPUTSTRING ) );
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_INPUTSTRING ), EM_SETSEL, 0, MAKELONG(0, 0xffff) );
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
g_Params.m_szInputText[ 0 ] = 0;
|
||||
GetDlgItemTextW( hwndDlg, IDC_INPUTSTRING, g_Params.m_szInputText, sizeof( g_Params.m_szInputText ) );
|
||||
EndDialog( hwndDlg, 1 );
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EditPhrase( CEditPhraseParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EDITPHRASE ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EditPhraseDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
39
utils/hlfaceposer/EditPhrase.h
Normal file
39
utils/hlfaceposer/EditPhrase.h
Normal file
@@ -0,0 +1,39 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EDITPHRASE_H
|
||||
#define EDITPHRASE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CEditPhraseParams : public CBaseDialogParams
|
||||
{
|
||||
char m_szPrompt[ 256 ];
|
||||
|
||||
// i/o input text
|
||||
wchar_t m_szInputText[ 1024 ];
|
||||
};
|
||||
|
||||
// Display/create dialog
|
||||
int EditPhrase( CEditPhraseParams *params );
|
||||
|
||||
#endif // EDITPHRASE_H
|
||||
1986
utils/hlfaceposer/GestureTool.cpp
Normal file
1986
utils/hlfaceposer/GestureTool.cpp
Normal file
File diff suppressed because it is too large
Load Diff
174
utils/hlfaceposer/GestureTool.h
Normal file
174
utils/hlfaceposer/GestureTool.h
Normal file
@@ -0,0 +1,174 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GESTURETOOL_H
|
||||
#define GESTURETOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "studio.h"
|
||||
#include "UtlVector.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoWidgetDrawHelper;
|
||||
class CChoreoView;
|
||||
class CEventAbsoluteTag;
|
||||
|
||||
#define IDC_REDO_GT 1000
|
||||
#define IDC_UNDO_GT 1001
|
||||
#define IDC_GT_DELETE_TAG 1002
|
||||
#define IDC_GT_INSERT_TAG 1003
|
||||
#define IDC_GT_REVERT 1004
|
||||
|
||||
#define IDC_GT_CHANGESCALE 1005
|
||||
#define IDC_GESTUREHSCROLL 1006
|
||||
|
||||
class GestureTool : public mxWindow, public IFacePoserToolWindow
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
GestureTool( mxWindow *parent );
|
||||
~GestureTool( void );
|
||||
|
||||
virtual void Think( float dt );
|
||||
void ScrubThink( float dt, bool scrubbing );
|
||||
virtual bool IsScrubbing( void ) const;
|
||||
virtual bool IsProcessing( void );
|
||||
|
||||
virtual int handleEvent( mxEvent *event );
|
||||
virtual void redraw( void );
|
||||
virtual bool PaintBackground();
|
||||
|
||||
void SetEvent( CChoreoEvent *event );
|
||||
|
||||
void GetScrubHandleRect( RECT& rcHandle, float scrub, bool clipped = false );
|
||||
void GetScrubHandleReferenceRect( RECT& rcHandle, float scrub, bool clipped = false );
|
||||
|
||||
void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper, RECT& rcHandle, float scrub, bool reference );
|
||||
void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
|
||||
void DrawEventEnd( CChoreoWidgetDrawHelper& drawHelper );
|
||||
|
||||
void DrawAbsoluteTags( CChoreoWidgetDrawHelper& drawHelper );
|
||||
bool GetAbsTagRect( RECT& rcClient, CChoreoEvent *event, int tagtype, CEventAbsoluteTag *tag, RECT& rcTag );
|
||||
void GetTagTrayRect( RECT &rcClient, int tagtype, RECT& rcTray );
|
||||
|
||||
void SetMouseOverPos( int x, int y );
|
||||
void GetMouseOverPos( int &x, int& y );
|
||||
void GetMouseOverPosRect( RECT& rcPos );
|
||||
void DrawMouseOverPos( CChoreoWidgetDrawHelper& drawHelper, RECT& rcPos );
|
||||
void DrawMouseOverPos();
|
||||
|
||||
void DrawScrubHandles();
|
||||
|
||||
CChoreoEvent *GetSafeEvent( void );
|
||||
|
||||
bool IsMouseOverScrubHandle( mxEvent *event );
|
||||
void ForceScrubPosition( float newtime );
|
||||
void ForceScrubPositionFromSceneTime( float scenetime );
|
||||
|
||||
void SetScrubTime( float t );
|
||||
void SetScrubTargetTime( float t );
|
||||
virtual void OnModelChanged();
|
||||
|
||||
private:
|
||||
|
||||
void StartDragging( int dragtype, int startx, int starty, HCURSOR cursor );
|
||||
void AddFocusRect( RECT& rc );
|
||||
void OnMouseMove( mxEvent *event );
|
||||
void DrawFocusRect( void );
|
||||
void ShowContextMenu( mxEvent *event, bool include_track_menus );
|
||||
void GetWorkspaceLeftRight( int& left, int& right );
|
||||
void SetClickedPos( int x, int y );
|
||||
float GetTimeForClickedPos( void );
|
||||
|
||||
void ApplyBounds( int& mx, int& my );
|
||||
void CalcBounds( int movetype );
|
||||
void OnUndo( void );
|
||||
void OnRedo( void );
|
||||
|
||||
CEventAbsoluteTag *IsMouseOverTag( int mx, int my );
|
||||
int GetTagTypeForMouse( int mx, int my );
|
||||
|
||||
int GetTagTypeForTag( CEventAbsoluteTag const *tag );
|
||||
void OnInsertTag( void );
|
||||
void OnDeleteTag( void );
|
||||
void OnRevert( void );
|
||||
|
||||
void DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
|
||||
void DrawRelativeTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, CChoreoEvent *gesture, CChoreoEvent *event, float starttime, float endtime );
|
||||
|
||||
// Readjust slider
|
||||
void MoveTimeSliderToPos( int x );
|
||||
void OnChangeScale();
|
||||
int ComputeHPixelsNeeded( void );
|
||||
float GetPixelsPerSecond( void );
|
||||
void InvalidateLayout( void );
|
||||
void RepositionHSlider( void );
|
||||
void GetStartAndEndTime( float& st, float& ed );
|
||||
float GetEventEndTime();
|
||||
float GetTimeValueForMouse( int mx, bool clip = false );
|
||||
int GetPixelForTimeValue( float time, bool *clipped = NULL );
|
||||
|
||||
float m_flScrub;
|
||||
float m_flScrubTarget;
|
||||
|
||||
enum
|
||||
{
|
||||
DRAGTYPE_NONE = 0,
|
||||
DRAGTYPE_SCRUBBER,
|
||||
DRAGTYPE_ABSOLUTE_TIMING_TAG,
|
||||
};
|
||||
|
||||
int m_nFocusEventGlobalID;
|
||||
|
||||
int m_nMousePos[ 2 ];
|
||||
|
||||
bool m_bUseBounds;
|
||||
int m_nMinX;
|
||||
int m_nMaxX;
|
||||
|
||||
HCURSOR m_hPrevCursor;
|
||||
int m_nDragType;
|
||||
|
||||
int m_nStartX;
|
||||
int m_nStartY;
|
||||
int m_nLastX;
|
||||
int m_nLastY;
|
||||
|
||||
int m_nClickedX;
|
||||
int m_nClickedY;
|
||||
|
||||
struct CFocusRect
|
||||
{
|
||||
RECT m_rcOrig;
|
||||
RECT m_rcFocus;
|
||||
};
|
||||
CUtlVector < CFocusRect > m_FocusRects;
|
||||
CChoreoEvent *m_pLastEvent;
|
||||
|
||||
bool m_bSuppressLayout;
|
||||
// Height/width of scroll bars
|
||||
int m_nScrollbarHeight;
|
||||
float m_flLeftOffset;
|
||||
mxScrollbar *m_pHorzScrollBar;
|
||||
int m_nLastHPixelsNeeded;
|
||||
// How many pixels per second we are showing in the UI
|
||||
float m_flPixelsPerSecond;
|
||||
// Do we need to move controls?
|
||||
bool m_bLayoutIsValid;
|
||||
float m_flLastDuration;
|
||||
bool m_bInSetEvent;
|
||||
float m_flScrubberTimeOffset;
|
||||
|
||||
friend class CChoreoView;
|
||||
};
|
||||
|
||||
extern GestureTool *g_pGestureTool;
|
||||
#endif // GESTURETOOL_H
|
||||
33
utils/hlfaceposer/ICloseCaptionManager.h
Normal file
33
utils/hlfaceposer/ICloseCaptionManager.h
Normal file
@@ -0,0 +1,33 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ICLOSECAPTIONMANAGER_H
|
||||
#define ICLOSECAPTIONMANAGER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
typedef struct tagRECT RECT;
|
||||
class CSentence;
|
||||
class StudioModel;
|
||||
class CChoreoWidgetDrawHelper;
|
||||
|
||||
class ICloseCaptionManager
|
||||
{
|
||||
public:
|
||||
virtual void Reset( void ) = 0;
|
||||
|
||||
virtual void Process( char const *tokenname, float duration, int languageid ) = 0;
|
||||
|
||||
virtual bool LookupUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count ) = 0;
|
||||
// Same as above, except strips out <> command tokens
|
||||
virtual bool LookupStrippedUnicodeText( int languageId, char const *token, wchar_t *outbuf, size_t count ) = 0;
|
||||
};
|
||||
|
||||
extern ICloseCaptionManager *closecaptionmanager;
|
||||
|
||||
#endif // ICLOSECAPTIONMANAGER_H
|
||||
243
utils/hlfaceposer/ProgressDialog.cpp
Normal file
243
utils/hlfaceposer/ProgressDialog.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "resource.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "mxtk/mx.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "tier1/fmtstr.h"
|
||||
|
||||
#include <CommCtrl.h>
|
||||
|
||||
class CProgressDialog : public IProgressDialog
|
||||
{
|
||||
public:
|
||||
CProgressDialog();
|
||||
|
||||
void Start( char const *pchTitle, char const *pchText, bool bShowCancel );
|
||||
void Update( float flZeroToOneFraction );
|
||||
void UpdateText( char const *pchFmt, ... );
|
||||
bool IsCancelled();
|
||||
void Finish();
|
||||
|
||||
static BOOL CALLBACK ProgressDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
private:
|
||||
|
||||
BOOL ProgressDialogProcImpl( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
CUtlString m_sTitle;
|
||||
CUtlString m_sStatus;
|
||||
float m_flFraction;
|
||||
|
||||
bool m_bShowCancel;
|
||||
bool m_bWantsCancel;
|
||||
|
||||
HWND m_hwndDlg;
|
||||
|
||||
double m_flStartTime;
|
||||
};
|
||||
|
||||
static CProgressDialog g_ProgressDialog;
|
||||
IProgressDialog *g_pProgressDialog = &g_ProgressDialog;
|
||||
|
||||
CProgressDialog::CProgressDialog() :
|
||||
m_flFraction( 0.0f ), m_hwndDlg( 0 ), m_bShowCancel( false ), m_bWantsCancel( false ), m_flStartTime( 0.0f )
|
||||
{
|
||||
}
|
||||
|
||||
bool CProgressDialog::IsCancelled()
|
||||
{
|
||||
return m_bShowCancel && m_bWantsCancel;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL CALLBACK CProgressDialog::ProgressDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_ProgressDialog.ProgressDialogProcImpl( hwndDlg, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
void CProgressDialog::Start( char const *pchTitle, char const *pchText, bool bShowCancel )
|
||||
{
|
||||
if ( m_hwndDlg )
|
||||
{
|
||||
Finish();
|
||||
}
|
||||
Assert( NULL == m_hwndDlg );
|
||||
|
||||
m_sTitle = pchTitle;
|
||||
m_sStatus = pchText;
|
||||
m_flFraction = 0.0f;
|
||||
m_bShowCancel = bShowCancel;
|
||||
m_bWantsCancel = false;
|
||||
m_flStartTime = Plat_FloatTime();
|
||||
|
||||
m_hwndDlg = CreateDialog( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_PROGRESS ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)ProgressDialogProc );
|
||||
}
|
||||
|
||||
void CProgressDialog::Update( float flZeroToOneFraction )
|
||||
{
|
||||
m_flFraction = clamp( flZeroToOneFraction, 0.0f, 1.0f );
|
||||
|
||||
// Update the progress bar
|
||||
HWND pb = GetDlgItem( m_hwndDlg, IDC_FP_PROGRESS );
|
||||
int pos = clamp( (int)( 1000.0f * flZeroToOneFraction ), 0, 1000 );
|
||||
|
||||
SendMessage( pb, (UINT) PBM_SETPOS, pos, 0 );
|
||||
|
||||
HWND btn = GetDlgItem( m_hwndDlg, IDCANCEL );
|
||||
LRESULT lr = SendMessage( btn, BM_GETSTATE, 0, 0 );
|
||||
if ( lr & BST_PUSHED )
|
||||
{
|
||||
m_bWantsCancel = true;
|
||||
}
|
||||
|
||||
if ( GetAsyncKeyState( VK_ESCAPE ) )
|
||||
{
|
||||
m_bWantsCancel = true;
|
||||
}
|
||||
|
||||
mx::check();
|
||||
}
|
||||
|
||||
void CProgressDialog::UpdateText( char const *pchFmt, ... )
|
||||
{
|
||||
char buf[ 2048 ];
|
||||
va_list argptr;
|
||||
va_start( argptr, pchFmt );
|
||||
Q_vsnprintf( buf, sizeof( buf ), pchFmt, argptr );
|
||||
va_end( argptr );
|
||||
m_sStatus = buf;
|
||||
|
||||
SetDlgItemText( m_hwndDlg, IDC_FP_PROGRESS_TEXT, CFmtStr( "%s", m_sStatus.String() ) );
|
||||
SetDlgItemText( m_hwndDlg, IDC_FP_PROGRESS_PERCENT, CFmtStr( "%.2f %%", m_flFraction * 100.0f ) );
|
||||
|
||||
double elapsed = Plat_FloatTime() - m_flStartTime;
|
||||
double flPercentagePerSecond = 0.0f;
|
||||
if ( m_flFraction > 0.0f )
|
||||
{
|
||||
flPercentagePerSecond = elapsed / m_flFraction;
|
||||
}
|
||||
|
||||
double flSecondsRemaining = flPercentagePerSecond * ( 1.0f - m_flFraction );
|
||||
|
||||
int seconds = (int)flSecondsRemaining;
|
||||
|
||||
CFmtStr string;
|
||||
|
||||
int hours = 0;
|
||||
int minutes = seconds / 60;
|
||||
|
||||
if ( minutes > 0 )
|
||||
{
|
||||
seconds -= (minutes * 60);
|
||||
hours = minutes / 60;
|
||||
|
||||
if ( hours > 0 )
|
||||
{
|
||||
minutes -= (hours * 60);
|
||||
}
|
||||
}
|
||||
|
||||
if ( hours > 0 )
|
||||
{
|
||||
string.sprintf( "Time Remaining: %2i:%02i:%02i", hours, minutes, seconds );
|
||||
}
|
||||
else
|
||||
{
|
||||
string.sprintf( "Time Remaining: %02i:%02i", minutes, seconds );
|
||||
}
|
||||
|
||||
SetDlgItemText( m_hwndDlg, IDC_FP_PROGRESS_ETA, string.Access() );
|
||||
}
|
||||
|
||||
void CProgressDialog::Finish()
|
||||
{
|
||||
if ( !m_hwndDlg )
|
||||
return;
|
||||
DestroyWindow( m_hwndDlg );
|
||||
m_hwndDlg = NULL;
|
||||
}
|
||||
|
||||
BOOL CProgressDialog::ProgressDialogProcImpl( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
{
|
||||
RECT rcDlg;
|
||||
GetWindowRect( hwndDlg, &rcDlg );
|
||||
|
||||
// Get relative to primary monitor instead of actual window parent
|
||||
RECT rcParent;
|
||||
rcParent.left = 0;
|
||||
rcParent.right = rcParent.left + GetSystemMetrics( SM_CXFULLSCREEN );
|
||||
rcParent.top = 0;
|
||||
rcParent.bottom = rcParent.top + GetSystemMetrics( SM_CYFULLSCREEN );
|
||||
|
||||
int dialogw, dialogh;
|
||||
int parentw, parenth;
|
||||
|
||||
parentw = rcParent.right - rcParent.left;
|
||||
parenth = rcParent.bottom - rcParent.top;
|
||||
dialogw = rcDlg.right - rcDlg.left;
|
||||
dialogh = rcDlg.bottom - rcDlg.top;
|
||||
|
||||
int dlgleft, dlgtop;
|
||||
dlgleft = ( parentw - dialogw ) / 2;
|
||||
dlgtop = ( parenth - dialogh ) / 2;
|
||||
|
||||
MoveWindow( hwndDlg,
|
||||
dlgleft,
|
||||
dlgtop,
|
||||
dialogw,
|
||||
dialogh,
|
||||
TRUE
|
||||
);
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_FP_PROGRESS_TITLE, m_sTitle.String() );
|
||||
SetDlgItemText( hwndDlg, IDC_FP_PROGRESS_TEXT, m_sStatus.String() );
|
||||
|
||||
HWND pb = GetDlgItem( hwndDlg, IDC_FP_PROGRESS );
|
||||
SendMessage( pb, (UINT) PBM_SETRANGE, 0, MAKELPARAM( 0, 1000 ) );
|
||||
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDCANCEL ), m_bShowCancel ? SW_SHOW : SW_HIDE );
|
||||
|
||||
Update( 0.0f );
|
||||
}
|
||||
return FALSE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDCANCEL:
|
||||
m_bWantsCancel = true;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
26
utils/hlfaceposer/ProgressDialog.h
Normal file
26
utils/hlfaceposer/ProgressDialog.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef PROGRESSDIALOG_H
|
||||
#define PROGRESSDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class IProgressDialog
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Start( char const *pchTitle, char const *pchText, bool bShowCancel ) = 0;
|
||||
virtual void Update( float flZeroToOneFraction ) = 0;
|
||||
virtual void UpdateText( char const *pchFmt, ... ) = 0;
|
||||
virtual bool IsCancelled() = 0;
|
||||
virtual void Finish() = 0;
|
||||
};
|
||||
|
||||
extern IProgressDialog *g_pProgressDialog;
|
||||
|
||||
#endif // PROGRESSDIALOG_H
|
||||
2379
utils/hlfaceposer/RampTool.cpp
Normal file
2379
utils/hlfaceposer/RampTool.cpp
Normal file
File diff suppressed because it is too large
Load Diff
205
utils/hlfaceposer/RampTool.h
Normal file
205
utils/hlfaceposer/RampTool.h
Normal file
@@ -0,0 +1,205 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef RAMPTOOL_H
|
||||
#define RAMPTOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "studio.h"
|
||||
#include "UtlVector.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoWidgetDrawHelper;
|
||||
class CChoreoView;
|
||||
struct CExpressionSample;
|
||||
|
||||
#define IDC_REDO_RT 1000
|
||||
#define IDC_UNDO_RT 1001
|
||||
|
||||
#define IDC_RT_DELETE 1002
|
||||
#define IDC_RT_DESELECT 1003
|
||||
#define IDC_RT_SELECTALL 1004
|
||||
|
||||
#define IDC_RT_CHANGESCALE 1005
|
||||
#define IDC_RAMPHSCROLL 1006
|
||||
#define IDC_RT_EDGEPROPERTIES 1007
|
||||
|
||||
#define FP_RT_SELECTION_TOLERANCE 30.0f
|
||||
#define FP_RT_SELECTION_RECTANGLE_TOLERANCE 5.0f
|
||||
#define FP_RT_ADDSAMPLE_TOLERANCE 5.0f
|
||||
|
||||
template< class T > class CCurveEditorHelper;
|
||||
|
||||
class RampTool : public mxWindow, public IFacePoserToolWindow
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
RampTool( mxWindow *parent );
|
||||
~RampTool( void );
|
||||
|
||||
virtual void Think( float dt );
|
||||
void ScrubThink( float dt, bool scrubbing );
|
||||
virtual bool IsScrubbing( void ) const;
|
||||
virtual bool IsProcessing( void );
|
||||
|
||||
virtual int handleEvent( mxEvent *event );
|
||||
virtual void redraw( void );
|
||||
virtual bool PaintBackground();
|
||||
|
||||
void SetEvent( CChoreoEvent *event );
|
||||
|
||||
void GetScrubHandleRect( RECT& rcHandle, float scrub, bool clipped = false );
|
||||
|
||||
void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper, RECT& rcHandle, float scrub, bool reference );
|
||||
void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
|
||||
void DrawEventEnd( CChoreoWidgetDrawHelper& drawHelper );
|
||||
|
||||
void SetMouseOverPos( int x, int y );
|
||||
void GetMouseOverPos( int &x, int& y );
|
||||
void GetMouseOverPosRect( RECT& rcPos );
|
||||
void DrawMouseOverPos( CChoreoWidgetDrawHelper& drawHelper, RECT& rcPos );
|
||||
void DrawMouseOverPos();
|
||||
|
||||
void DrawScrubHandles();
|
||||
|
||||
CChoreoEvent *GetSafeEvent( void );
|
||||
|
||||
bool IsMouseOverScrubHandle( mxEvent *event );
|
||||
void ForceScrubPosition( float newtime );
|
||||
void ForceScrubPositionFromSceneTime( float scenetime );
|
||||
|
||||
void SetScrubTime( float t );
|
||||
void SetScrubTargetTime( float t );
|
||||
|
||||
void DrawSamplesSimple( CChoreoWidgetDrawHelper& drawHelper, CChoreoEvent *e, bool clearbackground, const Color& sampleColor, RECT &rcSamples );
|
||||
virtual void OnModelChanged();
|
||||
|
||||
void SetMousePositionForEvent( mxEvent *event );
|
||||
|
||||
int NumSamples();
|
||||
CExpressionSample *GetSample( int idx );
|
||||
void PreDataChanged( char const *undodescription );
|
||||
void PostDataChanged( char const *redodescription );
|
||||
CExpressionSample *GetSampleUnderMouse( int mx, int my, float tolerance = FP_RT_SELECTION_TOLERANCE );
|
||||
void GetWorkList( bool reflect, CUtlVector< RampTool * >& list );
|
||||
|
||||
private:
|
||||
|
||||
void GetSampleTrayRect( RECT& rc );
|
||||
void DrawSamples( CChoreoWidgetDrawHelper& drawHelper, RECT &rcSamples );
|
||||
|
||||
void SelectPoints( void );
|
||||
void DeselectAll();
|
||||
void SelectAll();
|
||||
void Delete( void );
|
||||
|
||||
int CountSelected( void );
|
||||
void MoveSelectedSamples( float dfdx, float dfdy );
|
||||
|
||||
void StartDragging( int dragtype, int startx, int starty, HCURSOR cursor );
|
||||
void AddFocusRect( RECT& rc );
|
||||
void OnMouseMove( mxEvent *event );
|
||||
void DrawFocusRect( void );
|
||||
void ShowContextMenu( mxEvent *event, bool include_track_menus );
|
||||
void GetWorkspaceLeftRight( int& left, int& right );
|
||||
void SetClickedPos( int x, int y );
|
||||
float GetTimeForClickedPos( void );
|
||||
|
||||
void DrawAutoHighlight( mxEvent *event );
|
||||
|
||||
void ApplyBounds( int& mx, int& my );
|
||||
void CalcBounds( int movetype );
|
||||
void OnUndo( void );
|
||||
void OnRedo( void );
|
||||
|
||||
//CEventAbsoluteTag *IsMouseOverTag( int mx, int my );
|
||||
void OnRevert( void );
|
||||
|
||||
void OnEdgeProperties();
|
||||
|
||||
void DrawTimingTags( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
|
||||
void DrawRelativeTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, CChoreoEvent *rampevent, CChoreoEvent *event, float starttime, float endtime );
|
||||
void DrawAbsoluteTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT &rc, CChoreoEvent *rampevent, CChoreoEvent *event, float starttime, float endtime );
|
||||
|
||||
|
||||
// Readjust slider
|
||||
void MoveTimeSliderToPos( int x );
|
||||
void OnChangeScale();
|
||||
int ComputeHPixelsNeeded( void );
|
||||
float GetPixelsPerSecond( void );
|
||||
void InvalidateLayout( void );
|
||||
void RepositionHSlider( void );
|
||||
void GetStartAndEndTime( float& st, float& ed );
|
||||
float GetEventEndTime();
|
||||
float GetTimeValueForMouse( int mx, bool clip = false );
|
||||
int GetPixelForTimeValue( float time, bool *clipped = NULL );
|
||||
|
||||
float m_flScrub;
|
||||
float m_flScrubTarget;
|
||||
|
||||
enum
|
||||
{
|
||||
DRAGTYPE_NONE = 0,
|
||||
DRAGTYPE_SCRUBBER,
|
||||
DRAGTYPE_MOVEPOINTS_VALUE,
|
||||
DRAGTYPE_MOVEPOINTS_TIME,
|
||||
DRAGTYPE_SELECTION,
|
||||
};
|
||||
|
||||
int m_nFocusEventGlobalID;
|
||||
|
||||
int m_nMousePos[ 2 ];
|
||||
|
||||
bool m_bUseBounds;
|
||||
int m_nMinX;
|
||||
int m_nMaxX;
|
||||
|
||||
HCURSOR m_hPrevCursor;
|
||||
int m_nDragType;
|
||||
|
||||
int m_nStartX;
|
||||
int m_nStartY;
|
||||
int m_nLastX;
|
||||
int m_nLastY;
|
||||
|
||||
int m_nClickedX;
|
||||
int m_nClickedY;
|
||||
|
||||
struct CFocusRect
|
||||
{
|
||||
RECT m_rcOrig;
|
||||
RECT m_rcFocus;
|
||||
};
|
||||
CUtlVector < CFocusRect > m_FocusRects;
|
||||
CChoreoEvent *m_pLastEvent;
|
||||
|
||||
bool m_bSuppressLayout;
|
||||
// Height/width of scroll bars
|
||||
int m_nScrollbarHeight;
|
||||
float m_flLeftOffset;
|
||||
mxScrollbar *m_pHorzScrollBar;
|
||||
int m_nLastHPixelsNeeded;
|
||||
// How many pixels per second we are showing in the UI
|
||||
float m_flPixelsPerSecond;
|
||||
// Do we need to move controls?
|
||||
bool m_bLayoutIsValid;
|
||||
float m_flLastDuration;
|
||||
bool m_bInSetEvent;
|
||||
float m_flScrubberTimeOffset;
|
||||
int m_nUndoSetup;
|
||||
|
||||
CCurveEditorHelper< RampTool > *m_pHelper;
|
||||
friend class CChoreoView;
|
||||
};
|
||||
|
||||
extern RampTool *g_pRampTool;
|
||||
|
||||
#endif // RAMPTOOL_H
|
||||
2244
utils/hlfaceposer/SceneRampTool.cpp
Normal file
2244
utils/hlfaceposer/SceneRampTool.cpp
Normal file
File diff suppressed because it is too large
Load Diff
201
utils/hlfaceposer/SceneRampTool.h
Normal file
201
utils/hlfaceposer/SceneRampTool.h
Normal file
@@ -0,0 +1,201 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SCENERAMPTOOL_H
|
||||
#define SCENERAMPTOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "studio.h"
|
||||
#include "UtlVector.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoScene;
|
||||
class CChoreoWidgetDrawHelper;
|
||||
class CChoreoView;
|
||||
struct CExpressionSample;
|
||||
|
||||
#define IDC_REDO_SRT 1000
|
||||
#define IDC_UNDO_SRT 1001
|
||||
|
||||
#define IDC_SRT_DELETE 1002
|
||||
#define IDC_SRT_DESELECT 1003
|
||||
#define IDC_SRT_SELECTALL 1004
|
||||
|
||||
#define IDC_SRT_CHANGESCALE 1005
|
||||
#define IDC_SRT_RAMPHSCROLL 1006
|
||||
|
||||
#define IDC_SRT_EDGEPROPERTIES 1007
|
||||
|
||||
#define FP_SRT_SELECTION_TOLERANCE 30.0f
|
||||
#define FP_SRT_SELECTION_RECTANGLE_TOLERANCE 5.0f
|
||||
#define FP_SRT_ADDSAMPLE_TOLERANCE 5.0f
|
||||
|
||||
template< class T > class CCurveEditorHelper;
|
||||
|
||||
class SceneRampTool : public mxWindow, public IFacePoserToolWindow
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
SceneRampTool( mxWindow *parent );
|
||||
~SceneRampTool( void );
|
||||
|
||||
virtual void Think( float dt );
|
||||
void ScrubThink( float dt, bool scrubbing );
|
||||
virtual bool IsScrubbing( void ) const;
|
||||
virtual bool IsProcessing( void );
|
||||
|
||||
virtual int handleEvent( mxEvent *event );
|
||||
virtual void redraw( void );
|
||||
virtual bool PaintBackground();
|
||||
|
||||
void GetScrubHandleRect( RECT& rcHandle, float scrub, bool clipped = false );
|
||||
|
||||
void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper, RECT& rcHandle, float scrub, bool reference );
|
||||
void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
|
||||
void DrawSceneEnd( CChoreoWidgetDrawHelper& drawHelper );
|
||||
|
||||
void SetMouseOverPos( int x, int y );
|
||||
void GetMouseOverPos( int &x, int& y );
|
||||
void GetMouseOverPosRect( RECT& rcPos );
|
||||
void DrawMouseOverPos( CChoreoWidgetDrawHelper& drawHelper, RECT& rcPos );
|
||||
void DrawMouseOverPos();
|
||||
|
||||
void DrawScrubHandles();
|
||||
|
||||
CChoreoScene *GetSafeScene( void );
|
||||
|
||||
bool IsMouseOverScrubHandle( mxEvent *event );
|
||||
void ForceScrubPosition( float newtime );
|
||||
void ForceScrubPositionFromSceneTime( float scenetime );
|
||||
|
||||
void SetScrubTime( float t );
|
||||
void SetScrubTargetTime( float t );
|
||||
|
||||
void DrawSamplesSimple( CChoreoWidgetDrawHelper& drawHelper, CChoreoScene *scene, bool clearbackground, const Color& sampleColor, RECT &rcSamples );
|
||||
|
||||
virtual void OnModelChanged();
|
||||
|
||||
void SetMousePositionForEvent( mxEvent *event );
|
||||
|
||||
int NumSamples();
|
||||
CExpressionSample *GetSample( int idx );
|
||||
void PreDataChanged( char const *undodescription );
|
||||
void PostDataChanged( char const *redodescription );
|
||||
CExpressionSample *GetSampleUnderMouse( int mx, int my, float tolerance = FP_SRT_SELECTION_TOLERANCE );
|
||||
void GetWorkList( bool reflect, CUtlVector< SceneRampTool * >& list );
|
||||
|
||||
private:
|
||||
|
||||
void GetSampleTrayRect( RECT& rc );
|
||||
void DrawSamples( CChoreoWidgetDrawHelper& drawHelper, RECT &rcSamples );
|
||||
|
||||
void SelectPoints( void );
|
||||
void DeselectAll();
|
||||
void SelectAll();
|
||||
void Delete( void );
|
||||
|
||||
int CountSelected( void );
|
||||
void MoveSelectedSamples( float dfdx, float dfdy );
|
||||
|
||||
void StartDragging( int dragtype, int startx, int starty, HCURSOR cursor );
|
||||
void AddFocusRect( RECT& rc );
|
||||
void OnMouseMove( mxEvent *event );
|
||||
void DrawFocusRect( void );
|
||||
void ShowContextMenu( mxEvent *event, bool include_track_menus );
|
||||
void GetWorkspaceLeftRight( int& left, int& right );
|
||||
void SetClickedPos( int x, int y );
|
||||
float GetTimeForClickedPos( void );
|
||||
|
||||
void DrawAutoHighlight( mxEvent *event );
|
||||
|
||||
void ApplyBounds( int& mx, int& my );
|
||||
void CalcBounds( int movetype );
|
||||
void OnUndo( void );
|
||||
void OnRedo( void );
|
||||
|
||||
void OnRevert( void );
|
||||
|
||||
void OnEdgeProperties();
|
||||
|
||||
void DrawTimingTags( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
|
||||
void DrawRelativeTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, CChoreoEvent *event, float starttime, float endtime );
|
||||
void DrawAbsoluteTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT &rc, CChoreoEvent *event, float starttime, float endtime );
|
||||
|
||||
|
||||
// Readjust slider
|
||||
void MoveTimeSliderToPos( int x );
|
||||
void OnChangeScale();
|
||||
int ComputeHPixelsNeeded( void );
|
||||
float GetPixelsPerSecond( void );
|
||||
void InvalidateLayout( void );
|
||||
void RepositionHSlider( void );
|
||||
void GetStartAndEndTime( float& st, float& ed );
|
||||
float GetEventEndTime();
|
||||
float GetTimeValueForMouse( int mx, bool clip = false );
|
||||
int GetPixelForTimeValue( float time, bool *clipped = NULL );
|
||||
|
||||
float m_flScrub;
|
||||
float m_flScrubTarget;
|
||||
|
||||
enum
|
||||
{
|
||||
DRAGTYPE_NONE = 0,
|
||||
DRAGTYPE_SCRUBBER,
|
||||
DRAGTYPE_MOVEPOINTS_VALUE,
|
||||
DRAGTYPE_MOVEPOINTS_TIME,
|
||||
DRAGTYPE_SELECTION,
|
||||
};
|
||||
|
||||
int m_nMousePos[ 2 ];
|
||||
|
||||
bool m_bUseBounds;
|
||||
int m_nMinX;
|
||||
int m_nMaxX;
|
||||
|
||||
HCURSOR m_hPrevCursor;
|
||||
int m_nDragType;
|
||||
|
||||
int m_nStartX;
|
||||
int m_nStartY;
|
||||
int m_nLastX;
|
||||
int m_nLastY;
|
||||
|
||||
int m_nClickedX;
|
||||
int m_nClickedY;
|
||||
|
||||
struct CFocusRect
|
||||
{
|
||||
RECT m_rcOrig;
|
||||
RECT m_rcFocus;
|
||||
};
|
||||
CUtlVector < CFocusRect > m_FocusRects;
|
||||
|
||||
bool m_bSuppressLayout;
|
||||
// Height/width of scroll bars
|
||||
int m_nScrollbarHeight;
|
||||
float m_flLeftOffset;
|
||||
mxScrollbar *m_pHorzScrollBar;
|
||||
int m_nLastHPixelsNeeded;
|
||||
// How many pixels per second we are showing in the UI
|
||||
float m_flPixelsPerSecond;
|
||||
// Do we need to move controls?
|
||||
bool m_bLayoutIsValid;
|
||||
float m_flLastDuration;
|
||||
float m_flScrubberTimeOffset;
|
||||
int m_nUndoSetup;
|
||||
|
||||
CCurveEditorHelper< SceneRampTool > *m_pHelper;
|
||||
|
||||
friend class CChoreoView;
|
||||
};
|
||||
|
||||
extern SceneRampTool *g_pSceneRampTool;
|
||||
|
||||
#endif // SCENERAMPTOOL_H
|
||||
77
utils/hlfaceposer/actorproperties.cpp
Normal file
77
utils/hlfaceposer/actorproperties.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "resource.h"
|
||||
#include "ActorProperties.h"
|
||||
#include "ChoreoView.h"
|
||||
#include "choreoactor.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CActorParams g_Params;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK ActorPropertiesDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_ACTORNAME, g_Params.m_szName );
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_ACTORNAME ) );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
g_Params.m_szName[ 0 ] = 0;
|
||||
GetDlgItemText( hwndDlg, IDC_ACTORNAME, g_Params.m_szName, 256 );
|
||||
EndDialog( hwndDlg, 1 );
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int ActorProperties( CActorParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_ACTORPROPERTIES ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)ActorPropertiesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
28
utils/hlfaceposer/actorproperties.h
Normal file
28
utils/hlfaceposer/actorproperties.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ACTORPROPERTIES_H
|
||||
#define ACTORPROPERTIES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CActorParams : public CBaseDialogParams
|
||||
{
|
||||
// i/o actor name
|
||||
char m_szName[ 256 ];
|
||||
};
|
||||
|
||||
// Display/create actor info
|
||||
int ActorProperties( CActorParams *params );
|
||||
|
||||
#endif // ACTORPROPERTIES_H
|
||||
164
utils/hlfaceposer/addsoundentry.cpp
Normal file
164
utils/hlfaceposer/addsoundentry.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include "mxtk/mx.h"
|
||||
#include "resource.h"
|
||||
#include "AddSoundEntry.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
static CAddSoundParams g_Params;
|
||||
|
||||
static void PopulateScriptList( HWND wnd )
|
||||
{
|
||||
HWND control = GetDlgItem( wnd, IDC_SOUNDSCRIPT );
|
||||
if ( !control )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SendMessage( control, CB_RESETCONTENT, 0, 0 );
|
||||
|
||||
int c = soundemitter->GetNumSoundScripts();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
// add text to combo box
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)soundemitter->GetSoundScriptName( i ) );
|
||||
|
||||
if ( i == 0 && !g_Params.m_szScriptName[ 0 ] )
|
||||
{
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)soundemitter->GetSoundScriptName( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( g_Params.m_szScriptName[ 0 ] )
|
||||
{
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)g_Params.m_szScriptName );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK AddSoundPropertiesDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
PopulateScriptList( hwndDlg );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_SOUNDNAME, g_Params.m_szSoundName );
|
||||
if ( g_Params.m_bReadOnlySoundName )
|
||||
{
|
||||
HWND ctrl = GetDlgItem( hwndDlg, IDC_SOUNDNAME );
|
||||
if ( ctrl )
|
||||
{
|
||||
SendMessage( ctrl, EM_SETREADONLY, (WPARAM)TRUE, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_SOUNDNAME ) );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
g_Params.m_szSoundName[ 0 ] = 0;
|
||||
g_Params.m_szScriptName[ 0 ] = 0;
|
||||
GetDlgItemText( hwndDlg, IDC_SOUNDNAME, g_Params.m_szSoundName, sizeof( g_Params.m_szSoundName ) );
|
||||
GetDlgItemText( hwndDlg, IDC_SOUNDSCRIPT, g_Params.m_szScriptName, sizeof( g_Params.m_szScriptName ) );
|
||||
|
||||
// Don't exit...
|
||||
if ( !g_Params.m_szSoundName[ 0 ] || !g_Params.m_szScriptName[ 0 ] )
|
||||
return TRUE;
|
||||
|
||||
// Don't stompt existing sounds
|
||||
int idx = soundemitter->GetSoundIndex( g_Params.m_szSoundName );
|
||||
if ( soundemitter->IsValidIndex( idx ) )
|
||||
{
|
||||
if ( !g_Params.m_bAllowExistingSound )
|
||||
{
|
||||
mxMessageBox( NULL, va( "Sound '%s' already exists",
|
||||
g_Params.m_szSoundName ), g_appTitle, MX_MB_OK );
|
||||
}
|
||||
else
|
||||
{
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Check out script
|
||||
if ( !filesystem->FileExists( g_Params.m_szScriptName ) )
|
||||
{
|
||||
mxMessageBox( NULL, va( "Script '%s' does not exist",
|
||||
g_Params.m_szScriptName ), g_appTitle, MX_MB_OK );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( !filesystem->IsFileWritable( g_Params.m_szScriptName ) )
|
||||
{
|
||||
mxMessageBox( NULL, va( "Script '%s' is read-only, you need to check it out of VSS",
|
||||
g_Params.m_szScriptName ), g_appTitle, MX_MB_OK );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Add the entry
|
||||
CSoundParametersInternal params;
|
||||
params.SetChannel( CHAN_VOICE );
|
||||
params.SetSoundLevel( SNDLVL_TALKING );
|
||||
|
||||
soundemitter->ExpandSoundNameMacros( params, g_Params.m_szWaveFile );
|
||||
soundemitter->AddSound( g_Params.m_szSoundName, g_Params.m_szScriptName, params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int AddSound( CAddSoundParams *params, HWND parent )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_ADDSOUNDENTRY ),
|
||||
parent,
|
||||
(DLGPROC)AddSoundPropertiesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
40
utils/hlfaceposer/addsoundentry.h
Normal file
40
utils/hlfaceposer/addsoundentry.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ADDSOUNDENTRY_H
|
||||
#define ADDSOUNDENTRY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basedialogparams.h"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CAddSoundParams : public CBaseDialogParams
|
||||
{
|
||||
CAddSoundParams()
|
||||
{
|
||||
m_szWaveFile[ 0 ] = 0;
|
||||
m_szSoundName[ 0 ] = 0;
|
||||
m_szScriptName[ 0 ] = 0;
|
||||
m_bAllowExistingSound = false;
|
||||
m_bReadOnlySoundName = false;
|
||||
}
|
||||
|
||||
char m_szWaveFile[ 256 ];
|
||||
|
||||
// i/o input text
|
||||
char m_szSoundName[ 256 ];
|
||||
char m_szScriptName[ 256 ];
|
||||
bool m_bAllowExistingSound;
|
||||
bool m_bReadOnlySoundName;
|
||||
};
|
||||
|
||||
// Display/create dialog
|
||||
int AddSound( CAddSoundParams *params, HWND parent );
|
||||
|
||||
#endif // ADDSOUNDENTRY_H
|
||||
127
utils/hlfaceposer/audiowaveoutput.h
Normal file
127
utils/hlfaceposer/audiowaveoutput.h
Normal file
@@ -0,0 +1,127 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef AUDIOWAVEOUTPUT_H
|
||||
#define AUDIOWAVEOUTPUT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "sound.h"
|
||||
#include "UtlVector.h"
|
||||
|
||||
#define OUTPUT_BUFFER_COUNT 32
|
||||
#define MAX_CHANNELS 16
|
||||
|
||||
class CAudioMixer;
|
||||
|
||||
class CAudioMixerState
|
||||
{
|
||||
public:
|
||||
CAudioMixer *mixer;
|
||||
int submit_mixer_sample;
|
||||
};
|
||||
|
||||
class CAudioBuffer
|
||||
{
|
||||
public:
|
||||
WAVEHDR *hdr;
|
||||
bool submitted;
|
||||
int submit_sample_count;
|
||||
|
||||
CUtlVector< CAudioMixerState > m_Referenced;
|
||||
};
|
||||
|
||||
#define OUTPUT_SAMPLE_RATE 44100
|
||||
#define PAINTBUFFER_SIZE 1024
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int left;
|
||||
int right;
|
||||
} portable_samplepair_t;
|
||||
|
||||
class CAudioDeviceSWMix : public IAudioDevice
|
||||
{
|
||||
public:
|
||||
virtual void Mix8Mono( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, int rateScaleFix, int outCount, int timecompress, bool forward = true );
|
||||
virtual void Mix8Stereo( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, int rateScaleFix, int outCount, int timecompress, bool forward = true );
|
||||
virtual void Mix16Mono( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, int rateScaleFix, int outCount, int timecompress, bool forward = true );
|
||||
virtual void Mix16Stereo( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, int rateScaleFix, int outCount, int timecompress, bool forward = true );
|
||||
virtual int MaxSampleCount( void );
|
||||
virtual void MixBegin( void );
|
||||
|
||||
void TransferBufferStereo16( short *pOutput, int sampleCount );
|
||||
|
||||
private:
|
||||
portable_samplepair_t m_paintbuffer[ PAINTBUFFER_SIZE ];
|
||||
};
|
||||
|
||||
class CAudioWaveOutput : public CAudioOutput
|
||||
{
|
||||
public:
|
||||
CAudioWaveOutput( void );
|
||||
~CAudioWaveOutput( void );
|
||||
|
||||
// returns the size of each sample in bytes
|
||||
virtual int SampleSize( void ) { return 2; }
|
||||
|
||||
// returns the sampling rate of the data
|
||||
virtual int SampleRate( void ) { return OUTPUT_SAMPLE_RATE; }
|
||||
|
||||
// returns the mono/stereo status of this device (true if stereo)
|
||||
virtual bool IsStereo( void ) { return true; }
|
||||
|
||||
// mix a buffer up to time (time is absolute)
|
||||
virtual void Update( float time );
|
||||
|
||||
virtual void Flush( void );
|
||||
|
||||
virtual void AddSource( CAudioMixer *pSource );
|
||||
virtual void StopSounds( void );
|
||||
virtual int FindSourceIndex( CAudioMixer *pSource );
|
||||
|
||||
virtual int GetOutputPosition( void );
|
||||
virtual float GetAmountofTimeAhead( void );
|
||||
virtual int GetNumberofSamplesAhead( void );
|
||||
|
||||
virtual CAudioMixer *GetMixerForSource( CAudioSource *pSource );
|
||||
|
||||
|
||||
private:
|
||||
void OpenDevice( void );
|
||||
bool ValidDevice( void ) { return m_deviceHandle != 0; }
|
||||
void ClearDevice( void ) { m_deviceHandle = NULL; }
|
||||
CAudioBuffer *GetEmptyBuffer( void );
|
||||
void SilenceBuffer( short *pSamples, int sampleCount );
|
||||
|
||||
void SetChannel( int channelIndex, CAudioMixer *pSource );
|
||||
void FreeChannel( int channelIndex );
|
||||
|
||||
void RemoveMixerChannelReferences( CAudioMixer *mixer );
|
||||
void AddToReferencedList( CAudioMixer *mixer, CAudioBuffer *buffer );
|
||||
void RemoveFromReferencedList( CAudioMixer *mixer, CAudioBuffer *buffer );
|
||||
bool IsSourceReferencedByActiveBuffer( CAudioMixer *mixer );
|
||||
bool IsSoundInReferencedList( CAudioMixer *mixer, CAudioBuffer *buffer );
|
||||
|
||||
// Compute how many samples we've mixed since most recent buffer submission
|
||||
void ComputeSampleAheadAmount( void );
|
||||
|
||||
HWAVEOUT m_deviceHandle;
|
||||
|
||||
float m_mixTime;
|
||||
float m_baseTime;
|
||||
int m_sampleIndex;
|
||||
CAudioBuffer m_buffers[ OUTPUT_BUFFER_COUNT ];
|
||||
|
||||
CAudioMixer *m_sourceList[MAX_CHANNELS];
|
||||
int m_nEstimatedSamplesAhead;
|
||||
public:
|
||||
CAudioDeviceSWMix m_audioDevice;
|
||||
|
||||
};
|
||||
#endif // AUDIOWAVEOUTPUT_H
|
||||
65
utils/hlfaceposer/basedialogparams.cpp
Normal file
65
utils/hlfaceposer/basedialogparams.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "tier0/dbg.h"
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : self -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseDialogParams::PositionSelf( void *self )
|
||||
{
|
||||
RECT rcDlg;
|
||||
HWND dlgWindow = (HWND)self;
|
||||
GetWindowRect( dlgWindow, &rcDlg );
|
||||
|
||||
// Get relative to primary monitor instead of actual window parent
|
||||
RECT rcParent;
|
||||
rcParent.left = 0;
|
||||
rcParent.right = rcParent.left + GetSystemMetrics( SM_CXFULLSCREEN );
|
||||
rcParent.top = 0;
|
||||
rcParent.bottom = rcParent.top + GetSystemMetrics( SM_CYFULLSCREEN );
|
||||
|
||||
int dialogw, dialogh;
|
||||
int parentw, parenth;
|
||||
|
||||
parentw = rcParent.right - rcParent.left;
|
||||
parenth = rcParent.bottom - rcParent.top;
|
||||
dialogw = rcDlg.right - rcDlg.left;
|
||||
dialogh = rcDlg.bottom - rcDlg.top;
|
||||
|
||||
int dlgleft, dlgtop;
|
||||
dlgleft = ( parentw - dialogw ) / 2;
|
||||
dlgtop = ( parenth - dialogh ) / 2;
|
||||
|
||||
if ( m_bPositionDialog )
|
||||
{
|
||||
int top = m_nTop - dialogh - 5;
|
||||
int left = m_nLeft;
|
||||
|
||||
MoveWindow( dlgWindow,
|
||||
left,
|
||||
top,
|
||||
dialogw,
|
||||
dialogh,
|
||||
TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MoveWindow( dlgWindow,
|
||||
dlgleft,
|
||||
dlgtop,
|
||||
dialogw,
|
||||
dialogh,
|
||||
TRUE
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
29
utils/hlfaceposer/basedialogparams.h
Normal file
29
utils/hlfaceposer/basedialogparams.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEDIALOGPARAMS_H
|
||||
#define BASEDIALOGPARAMS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/dbg.h"
|
||||
#include "tier1/strtools.h"
|
||||
|
||||
struct CBaseDialogParams
|
||||
{
|
||||
// i dialog title
|
||||
char m_szDialogTitle[ 128 ];
|
||||
|
||||
bool m_bPositionDialog;
|
||||
int m_nLeft;
|
||||
int m_nTop;
|
||||
|
||||
void PositionSelf( void * self );
|
||||
};
|
||||
|
||||
#endif // BASEDIALOGPARAMS_H
|
||||
22
utils/hlfaceposer/cbase.h
Normal file
22
utils/hlfaceposer/cbase.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CBASE_H
|
||||
#define CBASE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "hlfaceposer.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "vstdlib/random.h"
|
||||
#include "sharedInterface.h"
|
||||
#include "color.h"
|
||||
|
||||
extern class ISoundEmitterSystemBase *soundemitter;
|
||||
|
||||
#endif // CBASE_H
|
||||
238
utils/hlfaceposer/cclookup.cpp
Normal file
238
utils/hlfaceposer/cclookup.cpp
Normal file
@@ -0,0 +1,238 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <commctrl.h>
|
||||
#include "mxtk/mx.h"
|
||||
#include "resource.h"
|
||||
#include "CCLookup.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "addsoundentry.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
static CCloseCaptionLookupParams g_Params;
|
||||
|
||||
static HFONT g_UnicodeFont = NULL;
|
||||
|
||||
static void InsertTextColumn( HWND listcontrol, int column, int width, char const *label )
|
||||
{
|
||||
LVCOLUMN col;
|
||||
memset( &col, 0, sizeof( col ) );
|
||||
|
||||
col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_ORDER;
|
||||
col.iOrder = column;
|
||||
col.pszText = (char *)label;
|
||||
col.cchTextMax = 256;
|
||||
col.iSubItem = column;
|
||||
col.cx = width;
|
||||
|
||||
ListView_InsertColumn( listcontrol, column, &col );
|
||||
}
|
||||
|
||||
static void PopulateCloseCaptionTokenList( HWND wnd, CCloseCaptionLookupParams *params )
|
||||
{
|
||||
HWND control = GetDlgItem( wnd, IDC_CCTOKENLIST );
|
||||
if ( !control )
|
||||
return;
|
||||
|
||||
InsertTextColumn( control, 0, 200, "CloseCaption Token" );
|
||||
InsertTextColumn( control, 1, 800, "Text" );
|
||||
|
||||
|
||||
ListView_DeleteAllItems( control );
|
||||
|
||||
SendMessage( control, WM_SETFONT, (WPARAM)g_UnicodeFont, MAKELPARAM (TRUE, 0) );
|
||||
|
||||
StringIndex_t i = g_pLocalize->GetFirstStringIndex();
|
||||
int saveSelected = -1;
|
||||
|
||||
while ( INVALID_STRING_INDEX != i )
|
||||
{
|
||||
char const *name = g_pLocalize->GetNameByIndex( i );
|
||||
|
||||
LV_ITEMW lvItem;
|
||||
memset( &lvItem, 0, sizeof( lvItem ) );
|
||||
lvItem.iItem = ListView_GetItemCount( control );
|
||||
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
|
||||
lvItem.lParam = (LPARAM)i;
|
||||
|
||||
wchar_t label[ 256 ];
|
||||
g_pLocalize->ConvertANSIToUnicode( name, label, sizeof( label ) );
|
||||
|
||||
lvItem.pszText = label;
|
||||
lvItem.cchTextMax = 256;
|
||||
|
||||
SendMessage( control, LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW FAR*)(&lvItem));
|
||||
|
||||
lvItem.mask = LVIF_TEXT;
|
||||
lvItem.iSubItem = 1;
|
||||
|
||||
wchar_t *value = g_pLocalize->GetValueByIndex( i );
|
||||
|
||||
lvItem.pszText = (wchar_t *)value;
|
||||
lvItem.cchTextMax = 1024;
|
||||
|
||||
SendMessage( control, LVM_SETITEMW, 0, (LPARAM)(const LV_ITEMW FAR*)(&lvItem));
|
||||
|
||||
if ( !Q_stricmp( name, params->m_szCCToken ) )
|
||||
{
|
||||
ListView_SetItemState( control, lvItem.iItem, LVIS_SELECTED, LVIS_STATEIMAGEMASK );
|
||||
saveSelected = lvItem.iItem;
|
||||
}
|
||||
i = g_pLocalize->GetNextStringIndex( i );
|
||||
}
|
||||
|
||||
if ( saveSelected != -1 )
|
||||
{
|
||||
ListView_EnsureVisible(control, saveSelected, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK CloseCaptionLookupDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
HWND control = GetDlgItem( hwndDlg, IDC_CCTOKENLIST );
|
||||
DWORD exStyle = GetWindowLong( control, GWL_EXSTYLE );
|
||||
exStyle |= LVS_EX_FULLROWSELECT;
|
||||
SetWindowLong( control, GWL_EXSTYLE, exStyle );
|
||||
|
||||
PopulateCloseCaptionTokenList( hwndDlg, &g_Params );
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_CCTOKEN, g_Params.m_szCCToken );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_CCTOKENLIST ) );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
/*
|
||||
//int selindex = SendMessage( GetDlgItem( hwndDlg, IDC_CCTOKENLIST ), LB_GETCURSEL, 0, 0 );
|
||||
if ( selindex == LB_ERR )
|
||||
{
|
||||
mxMessageBox( NULL, "You must select an entry from the list", g_appTitle, MB_OK );
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CCTOKEN ), WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szCCToken ), (LPARAM)g_Params.m_szCCToken );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
if ( wParam == IDC_CCTOKENLIST )
|
||||
{
|
||||
NMHDR *hdr = ( NMHDR * )lParam;
|
||||
if ( hdr->code == LVN_ITEMCHANGED )
|
||||
{
|
||||
HWND control = GetDlgItem( hwndDlg, IDC_CCTOKENLIST );
|
||||
|
||||
NM_LISTVIEW *nmlv = ( NM_LISTVIEW * )lParam;
|
||||
|
||||
int item = nmlv->iItem;
|
||||
|
||||
if ( item >= 0 )
|
||||
{
|
||||
// look up the lparam value
|
||||
LVITEM lvi;
|
||||
memset( &lvi, 0, sizeof( lvi ) );
|
||||
lvi.mask = LVIF_PARAM;
|
||||
lvi.iItem = item;
|
||||
|
||||
if ( ListView_GetItem( control, &lvi ) )
|
||||
{
|
||||
char const *name = g_pLocalize->GetNameByIndex( lvi.lParam );
|
||||
if ( name )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szCCToken, name, sizeof( g_Params.m_szCCToken ) );
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CCTOKEN ), WM_SETTEXT, (WPARAM)sizeof( g_Params.m_szCCToken ), (LPARAM)g_Params.m_szCCToken );
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
if ( hdr->code == NM_DBLCLK )
|
||||
{
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CCTOKEN ), WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szCCToken ), (LPARAM)g_Params.m_szCCToken );
|
||||
EndDialog( hwndDlg, 1 );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CloseCaptionLookup( CCloseCaptionLookupParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
g_UnicodeFont = CreateFont(
|
||||
-10,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
FW_NORMAL,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
ANSI_CHARSET,
|
||||
OUT_TT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
ANTIALIASED_QUALITY,
|
||||
DEFAULT_PITCH,
|
||||
"Tahoma" );
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_CCLOOKUP ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)CloseCaptionLookupDialogProc );
|
||||
|
||||
DeleteObject( g_UnicodeFont );
|
||||
g_UnicodeFont = NULL;
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
27
utils/hlfaceposer/cclookup.h
Normal file
27
utils/hlfaceposer/cclookup.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CCLOOKUP_H
|
||||
#define CCLOOKUP_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basedialogparams.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CCloseCaptionLookupParams : public CBaseDialogParams
|
||||
{
|
||||
char m_szCCToken[ 1024 ];
|
||||
};
|
||||
|
||||
// Display/create dialog
|
||||
int CloseCaptionLookup( CCloseCaptionLookupParams *params );
|
||||
|
||||
#endif // CCLOOKUP_H
|
||||
124
utils/hlfaceposer/channelproperties.cpp
Normal file
124
utils/hlfaceposer/channelproperties.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "ChannelProperties.h"
|
||||
#include "ChoreoView.h"
|
||||
#include "choreoactor.h"
|
||||
#include "choreoscene.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CChannelParams g_Params;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK ChannelPropertiesDialogProc
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK ChannelPropertiesDialogProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_CHANNELNAME, g_Params.m_szName );
|
||||
|
||||
HWND control = GetDlgItem( hwndDlg, IDC_ACTORCHOICE );
|
||||
|
||||
if ( !g_Params.m_bShowActors )
|
||||
{
|
||||
// Hide the combo box
|
||||
if ( control )
|
||||
{
|
||||
ShowWindow( control, SW_HIDE );
|
||||
}
|
||||
control = GetDlgItem( hwndDlg, IDC_STATIC_ACTOR );
|
||||
if ( control )
|
||||
{
|
||||
ShowWindow( control, SW_HIDE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage( control, CB_RESETCONTENT, 0, 0 );
|
||||
|
||||
if ( g_Params.m_pScene )
|
||||
{
|
||||
for ( int i = 0 ; i < g_Params.m_pScene->GetNumActors() ; i++ )
|
||||
{
|
||||
CChoreoActor *actor = g_Params.m_pScene->GetActor( i );
|
||||
if ( actor )
|
||||
{
|
||||
// add text to combo box
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)actor->GetName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage( control, CB_SETCURSEL, (WPARAM)0, (LPARAM)0 );
|
||||
}
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_CHANNELNAME ) );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
g_Params.m_szName[ 0 ] = 0;
|
||||
GetDlgItemText( hwndDlg, IDC_CHANNELNAME, g_Params.m_szName, 256 );
|
||||
|
||||
if ( g_Params.m_bShowActors )
|
||||
{
|
||||
HWND control = GetDlgItem( hwndDlg, IDC_ACTORCHOICE );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szSelectedActor ), (LPARAM)g_Params.m_szSelectedActor );
|
||||
}
|
||||
}
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int ChannelProperties( CChannelParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_CHANNELPROPERTIES ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)ChannelPropertiesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
38
utils/hlfaceposer/channelproperties.h
Normal file
38
utils/hlfaceposer/channelproperties.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHANNELPROPERTIES_H
|
||||
#define CHANNELPROPERTIES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CChoreoScene;
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CChannelParams : public CBaseDialogParams
|
||||
{
|
||||
// i/o channel name
|
||||
char m_szName[ 256 ];
|
||||
|
||||
// For creating a new channel:
|
||||
// i
|
||||
bool m_bShowActors;
|
||||
// i/o
|
||||
char m_szSelectedActor[ 256 ];
|
||||
// i
|
||||
CChoreoScene *m_pScene;
|
||||
};
|
||||
|
||||
// set/create channel properties
|
||||
int ChannelProperties( CChannelParams *params );
|
||||
|
||||
#endif // CHANNELPROPERTIES_H
|
||||
125
utils/hlfaceposer/choiceproperties.cpp
Normal file
125
utils/hlfaceposer/choiceproperties.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "resource.h"
|
||||
#include "ChoiceProperties.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CChoiceParams g_Params;
|
||||
|
||||
static void PopulateChoiceList( HWND wnd, CChoiceParams *params )
|
||||
{
|
||||
HWND control = GetDlgItem( wnd, IDC_CHOICE );
|
||||
if ( !control )
|
||||
return;
|
||||
|
||||
SendMessage( control, CB_RESETCONTENT, 0, 0 );
|
||||
|
||||
int c = params->m_Choices.Count();
|
||||
|
||||
if ( params->m_nSelected == -1 )
|
||||
params->m_nSelected = 0;
|
||||
|
||||
if ( params->m_nSelected >= 0 && params->m_nSelected < c )
|
||||
{
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)params->m_Choices[ params->m_nSelected ].choice );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
char const *text = params->m_Choices[ i ].choice;
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)text );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK ChoicePropertiesDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
PopulateChoiceList( hwndDlg, &g_Params );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_STATIC_PROMPT, g_Params.m_szPrompt );
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
char selected[ MAX_CHOICE_TEXT_SIZE ];
|
||||
selected[ 0 ] = 0;
|
||||
HWND control = GetDlgItem( hwndDlg, IDC_CHOICE );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( selected ), (LPARAM)selected );
|
||||
}
|
||||
|
||||
g_Params.m_nSelected = -1;
|
||||
int c = g_Params.m_Choices.Count();
|
||||
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
char const *text = g_Params.m_Choices[ i ].choice;
|
||||
if ( stricmp( text, selected ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
g_Params.m_nSelected = i;
|
||||
break;
|
||||
}
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int ChoiceProperties( CChoiceParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_CHOICEDIALOG ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)ChoicePropertiesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
42
utils/hlfaceposer/choiceproperties.h
Normal file
42
utils/hlfaceposer/choiceproperties.h
Normal file
@@ -0,0 +1,42 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHOICEPROPERTIES_H
|
||||
#define CHOICEPROPERTIES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "UtlVector.h"
|
||||
|
||||
#define MAX_CHOICE_TEXT_SIZE 128
|
||||
|
||||
struct ChoiceText
|
||||
{
|
||||
char choice[ MAX_CHOICE_TEXT_SIZE ];
|
||||
};
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CChoiceParams : public CBaseDialogParams
|
||||
{
|
||||
|
||||
char m_szPrompt[ 256 ];
|
||||
|
||||
CUtlVector< ChoiceText > m_Choices;
|
||||
|
||||
// i/o active choice and output choice
|
||||
int m_nSelected; // -1 for none
|
||||
};
|
||||
|
||||
// Display/create dialog
|
||||
int ChoiceProperties( CChoiceParams *params );
|
||||
|
||||
#endif // CHOICEPROPERTIES_H
|
||||
415
utils/hlfaceposer/choreoactorwidget.cpp
Normal file
415
utils/hlfaceposer/choreoactorwidget.cpp
Normal file
@@ -0,0 +1,415 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#include <stdio.h>
|
||||
#include "hlfaceposer.h"
|
||||
#include "choreoactorwidget.h"
|
||||
#include "choreochannelwidget.h"
|
||||
#include "choreoactor.h"
|
||||
#include "choreoview.h"
|
||||
#include "choreowidgetdrawhelper.h"
|
||||
#include "mxBitmapButton.h"
|
||||
#include "choreoviewcolors.h"
|
||||
#include "choreochannel.h"
|
||||
#include "filesystem.h"
|
||||
#include "StudioModel.h"
|
||||
|
||||
#define ACTOR_NAME_HEIGHT 26
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *actor -
|
||||
// *parent -
|
||||
// x -
|
||||
// y -
|
||||
// w -
|
||||
// h -
|
||||
// 0 -
|
||||
// 0 -
|
||||
//-----------------------------------------------------------------------------
|
||||
CActorBitmapButton::CActorBitmapButton( CChoreoActorWidget *actor, mxWindow *parent, int x, int y, int w, int h, int id /*= 0*/, const char *bitmap /*= 0*/ )
|
||||
: mxBitmapButton( parent, x, y, w, h, id, bitmap )
|
||||
{
|
||||
m_pActor = actor;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActorWidget *CActorBitmapButton::GetActor( void )
|
||||
{
|
||||
return m_pActor;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CActorActiveCheckBox::CActorActiveCheckBox( CChoreoActorWidget *actor, mxWindow *parent, int x, int y, int w, int h, const char *label /*= 0*/, int id /*= 0*/ )
|
||||
: mxCheckBox( parent, x, y, w, h, label, id )
|
||||
{
|
||||
m_pActor = actor;
|
||||
}
|
||||
|
||||
CChoreoActorWidget *CActorActiveCheckBox::GetActor( void )
|
||||
{
|
||||
return m_pActor;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *parent -
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActorWidget::CChoreoActorWidget( CChoreoWidget *parent )
|
||||
: CChoreoWidget( parent )
|
||||
{
|
||||
m_pParent = parent;
|
||||
|
||||
m_pActor = NULL;
|
||||
|
||||
m_bShowChannels = true;
|
||||
|
||||
m_btnOpen = new CActorBitmapButton( this, m_pView, 0, 0, 0, 0, IDC_CHANNELOPEN, "gfx/hlfaceposer/channelopen.bmp" );
|
||||
m_btnClose = new CActorBitmapButton( this, m_pView, 0, 0, 0, 0, IDC_CHANNELCLOSE, "gfx/hlfaceposer/channelclose.bmp" );
|
||||
|
||||
ShowChannels( m_bShowChannels );
|
||||
|
||||
memset( m_rgCurrentSetting, 0, sizeof( m_rgCurrentSetting ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActorWidget::~CChoreoActorWidget( void )
|
||||
{
|
||||
for ( int i = 0 ; i < m_Channels.Count(); i++ )
|
||||
{
|
||||
CChoreoChannelWidget *c = m_Channels[ i ];
|
||||
delete c;
|
||||
}
|
||||
m_Channels.RemoveAll();
|
||||
|
||||
delete m_btnOpen;
|
||||
delete m_btnClose;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CChoreoActorWidget::GetShowChannels( void )
|
||||
{
|
||||
return m_bShowChannels;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Switch modes
|
||||
// Input : show -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::ShowChannels( bool show )
|
||||
{
|
||||
m_bShowChannels = show;
|
||||
|
||||
m_btnOpen->setVisible( !m_bShowChannels );
|
||||
m_btnClose->setVisible( m_bShowChannels );
|
||||
|
||||
m_pView->InvalidateLayout();
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::Create( void )
|
||||
{
|
||||
// Create objects for children
|
||||
Assert( m_pActor );
|
||||
|
||||
// Create objects for children
|
||||
for ( int i = 0; i < m_pActor->GetNumChannels(); i++ )
|
||||
{
|
||||
CChoreoChannel *channel = m_pActor->GetChannel( i );
|
||||
Assert( channel );
|
||||
if ( !channel )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CChoreoChannelWidget *channelWidget = new CChoreoChannelWidget( this );
|
||||
channelWidget->SetChannel( channel );
|
||||
channelWidget->Create();
|
||||
|
||||
AddChannel( channelWidget );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : rc -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::Layout( RECT& rc )
|
||||
{
|
||||
setBounds( rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top );
|
||||
|
||||
int buttonSize = 16;
|
||||
int ypos = rc.top + ( ACTOR_NAME_HEIGHT - buttonSize )/ 2;
|
||||
|
||||
m_btnOpen->setBounds( rc.left + 2, ypos, buttonSize, buttonSize );
|
||||
m_btnClose->setBounds( rc.left + 2, ypos, buttonSize, buttonSize );
|
||||
|
||||
bool buttonsVisible = ( ypos > m_pView->GetStartRow() && ( ypos + buttonSize ) < m_pView->GetEndRow() ) ? true : false;
|
||||
|
||||
if ( !buttonsVisible )
|
||||
{
|
||||
m_btnOpen->setVisible( false );
|
||||
m_btnClose->setVisible( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_btnOpen->setVisible( !m_bShowChannels );
|
||||
m_btnClose->setVisible( m_bShowChannels );
|
||||
}
|
||||
|
||||
RECT rcChannels;
|
||||
rcChannels = rc;
|
||||
rcChannels.top += ACTOR_NAME_HEIGHT;
|
||||
|
||||
// Create objects for children
|
||||
for ( int i = 0; i < m_Channels.Count(); i++ )
|
||||
{
|
||||
CChoreoChannelWidget *channel = m_Channels[ i ];
|
||||
Assert( channel );
|
||||
if ( !channel )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
rcChannels.bottom = rcChannels.top + channel->GetItemHeight();
|
||||
|
||||
channel->Layout( rcChannels );
|
||||
|
||||
OffsetRect( &rcChannels, 0, channel->GetItemHeight() );
|
||||
|
||||
channel->setVisible( m_bShowChannels );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoActorWidget::GetItemHeight( void )
|
||||
{
|
||||
int itemHeight = ACTOR_NAME_HEIGHT + 2;
|
||||
if ( m_bShowChannels )
|
||||
{
|
||||
for ( int i = 0; i < m_Channels.Count(); i++ )
|
||||
{
|
||||
CChoreoChannelWidget *channel = m_Channels[ i ];
|
||||
itemHeight += channel->GetItemHeight();
|
||||
}
|
||||
}
|
||||
return itemHeight;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::redraw( CChoreoWidgetDrawHelper& drawHelper )
|
||||
{
|
||||
if ( !getVisible() )
|
||||
return;
|
||||
|
||||
CChoreoActor *actor = GetActor();
|
||||
if ( !actor )
|
||||
return;
|
||||
|
||||
RECT rcClient = getBounds();
|
||||
|
||||
if ( !actor->GetActive() )
|
||||
{
|
||||
RECT rcBg = rcClient;
|
||||
rcBg.right = rcBg.left + m_pView->GetLabelWidth() ;
|
||||
InflateRect( &rcBg, -3, -5 );
|
||||
|
||||
drawHelper.DrawFilledRect( Color( 220, 220, 220 ), rcBg );
|
||||
}
|
||||
|
||||
RECT rcText;
|
||||
|
||||
rcText.left = rcClient.left;
|
||||
rcText.right = rcClient.left + m_pView->GetLabelWidth();
|
||||
rcText.top = rcClient.top;
|
||||
rcText.bottom = rcClient.top + ACTOR_NAME_HEIGHT;
|
||||
|
||||
drawHelper.DrawColoredLine( COLOR_CHOREO_ACTORLINE, PS_SOLID, 1, 0, rcText.top,
|
||||
rcClient.right, rcText.top );
|
||||
|
||||
drawHelper.DrawColoredLine( COLOR_CHOREO_ACTORLINE, PS_SOLID, 1, 0, rcClient.bottom-2,
|
||||
rcClient.right, rcClient.bottom-2 );
|
||||
drawHelper.DrawColoredLine( Color(200,206,255), PS_SOLID, 1, 0, rcClient.bottom-1,
|
||||
rcClient.right, rcClient.bottom-1 );
|
||||
|
||||
drawHelper.DrawColoredLine( COLOR_CHOREO_DIVIDER, PS_SOLID, 1, rcText.right, rcClient.top,
|
||||
rcText.right, rcClient.bottom-1 );
|
||||
|
||||
RECT rcName = rcText;
|
||||
|
||||
rcName.left += 18;
|
||||
char n[ 512 ];
|
||||
strcpy( n, actor->GetName() );
|
||||
|
||||
drawHelper.DrawColoredText( "Arial",
|
||||
m_pView->GetFontSize() + 5,
|
||||
1000,
|
||||
actor->GetActive() ? COLOR_CHOREO_ACTORNAME : COLOR_CHOREO_ACTORNAME_INACTIVE,
|
||||
rcName, n );
|
||||
|
||||
if ( !actor->GetActive() )
|
||||
{
|
||||
strcpy( n, "(inactive)" );
|
||||
|
||||
RECT rcInactive = rcName;
|
||||
int len = drawHelper.CalcTextWidth( "Arial", m_pView->GetFontSize() - 2, 500, n );
|
||||
rcInactive.left = rcInactive.right - len - 5;
|
||||
rcInactive.top += 3;
|
||||
rcInactive.bottom = rcInactive.top + m_pView->GetFontSize() - 2;
|
||||
|
||||
drawHelper.DrawColoredText( "Arial", m_pView->GetFontSize() - 2, 500,
|
||||
COLOR_CHOREO_ACTORNAME_INACTIVE, rcInactive, n );
|
||||
}
|
||||
|
||||
rcName.left -= 18;
|
||||
|
||||
|
||||
if ( actor->GetFacePoserModelName()[0] )
|
||||
{
|
||||
int textWidth = drawHelper.CalcTextWidth( "Arial", m_pView->GetFontSize() + 5, 1000, actor->GetName() );
|
||||
RECT rcModelName = rcName;
|
||||
rcModelName.left += ( 14 + textWidth + 2 );
|
||||
|
||||
int fontsize = m_pView->GetFontSize() - 2;
|
||||
|
||||
char shortname[ 512 ];
|
||||
Q_FileBase (actor->GetFacePoserModelName(), shortname, sizeof( shortname ) );
|
||||
strcat( shortname, ".mdl" );
|
||||
|
||||
int len = drawHelper.CalcTextWidth( "Arial", fontsize, FW_NORMAL, shortname );
|
||||
|
||||
rcModelName.left = rcModelName.right - len - 5;
|
||||
|
||||
rcModelName.top = rcModelName.bottom - fontsize;
|
||||
OffsetRect( &rcModelName, 0, -3 );
|
||||
drawHelper.DrawColoredText( "Arial", fontsize, FW_NORMAL, COLOR_CHOREO_LIGHTTEXT, rcModelName, shortname );
|
||||
}
|
||||
if ( m_bShowChannels )
|
||||
{
|
||||
for ( int j = 0; j < GetNumChannels(); j++ )
|
||||
{
|
||||
CChoreoChannelWidget *channel = GetChannel( j );
|
||||
if ( channel )
|
||||
{
|
||||
channel->redraw( drawHelper );
|
||||
}
|
||||
|
||||
RECT rcChannel = channel->getBounds();
|
||||
|
||||
drawHelper.DrawColoredLine( COLOR_CHOREO_ACTORLINE, PS_SOLID, 1, rcText.right+1, rcChannel.top,
|
||||
rcChannel.right, rcChannel.top );
|
||||
|
||||
drawHelper.DrawColoredLine( COLOR_CHOREO_ACTORLINE, PS_SOLID, 1, rcText.right+1, rcChannel.bottom,
|
||||
rcChannel.right, rcChannel.bottom );
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
OffsetRect( &rcName, m_pView->GetLabelWidth() + 10, 0 );
|
||||
rcName.right = w();
|
||||
|
||||
char sz[ 256 ];
|
||||
// count channels and events
|
||||
int ev = 0;
|
||||
for ( int i = 0; i < actor->GetNumChannels(); i++ )
|
||||
{
|
||||
CChoreoChannel *ch = actor->GetChannel( i );
|
||||
if ( ch )
|
||||
{
|
||||
ev += ch->GetNumEvents();
|
||||
}
|
||||
}
|
||||
sprintf( sz, "%i channels with %i events hidden", actor->GetNumChannels(), ev );
|
||||
drawHelper.DrawColoredText( "Arial", m_pView->GetFontSize(), FW_NORMAL, COLOR_CHOREO_ACTORNAME, rcName, sz );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : CChoreoActor
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoActor *CChoreoActorWidget::GetActor( void )
|
||||
{
|
||||
return m_pActor;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *actor -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::SetActor( CChoreoActor *actor )
|
||||
{
|
||||
m_pActor = actor;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::AddChannel( CChoreoChannelWidget *channel )
|
||||
{
|
||||
m_Channels.AddToTail( channel );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *channel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::RemoveChannel( CChoreoChannelWidget *channel )
|
||||
{
|
||||
m_Channels.FindAndRemove( channel );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : num -
|
||||
// Output : CChoreoChannelWidget
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoChannelWidget *CChoreoActorWidget::GetChannel( int num )
|
||||
{
|
||||
return m_Channels[ num ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoActorWidget::GetNumChannels( void )
|
||||
{
|
||||
return m_Channels.Count();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float *CChoreoActorWidget::GetSettings( void )
|
||||
{
|
||||
return m_rgCurrentSetting;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoActorWidget::ResetSettings( void )
|
||||
{
|
||||
memset( m_rgCurrentSetting, 0, sizeof( m_rgCurrentSetting ) );
|
||||
}
|
||||
118
utils/hlfaceposer/choreoactorwidget.h
Normal file
118
utils/hlfaceposer/choreoactorwidget.h
Normal file
@@ -0,0 +1,118 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOACTORWIDGET_H
|
||||
#define CHOREOACTORWIDGET_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "studio.h"
|
||||
#include "choreowidget.h"
|
||||
#include "utlvector.h"
|
||||
#include "mxBitmapButton.h"
|
||||
#include "expressions.h"
|
||||
|
||||
class CChoreoActor;
|
||||
class CChoreoChannelWidget;
|
||||
class mxCheckBox;
|
||||
class CChoreoActorWidget;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CActorBitmapButton : public mxBitmapButton
|
||||
{
|
||||
public:
|
||||
CActorBitmapButton( CChoreoActorWidget *actor, mxWindow *parent, int x, int y, int w, int h, int id = 0, const char *bitmap = 0 );
|
||||
|
||||
CChoreoActorWidget *GetActor( void );
|
||||
private:
|
||||
|
||||
CChoreoActorWidget *m_pActor;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CActorActiveCheckBox : public mxCheckBox
|
||||
{
|
||||
public:
|
||||
CActorActiveCheckBox( CChoreoActorWidget *actor, mxWindow *parent, int x, int y, int w, int h, const char *label = 0, int id = 0);
|
||||
|
||||
CChoreoActorWidget *GetActor( void );
|
||||
private:
|
||||
|
||||
CChoreoActorWidget *m_pActor;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The base actor ui widget. Owns the channels
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoActorWidget : public CChoreoWidget
|
||||
{
|
||||
public:
|
||||
typedef CChoreoWidget BaseClass;
|
||||
|
||||
// Construction / destruction
|
||||
CChoreoActorWidget( CChoreoWidget *parent );
|
||||
virtual ~CChoreoActorWidget( void );
|
||||
|
||||
virtual void Create( void );
|
||||
virtual void Layout( RECT& rc );
|
||||
|
||||
virtual void redraw(CChoreoWidgetDrawHelper& drawHelper);
|
||||
|
||||
// Accessors
|
||||
CChoreoActor *GetActor( void );
|
||||
void SetActor( CChoreoActor *actor );
|
||||
|
||||
// Manipulate channels
|
||||
void AddChannel( CChoreoChannelWidget *channel );
|
||||
void RemoveChannel( CChoreoChannelWidget *channel );
|
||||
CChoreoChannelWidget *GetChannel( int num );
|
||||
int GetNumChannels( void );
|
||||
|
||||
// Override height because we can be open/collapsed and we contain the channels
|
||||
virtual int GetItemHeight( void );
|
||||
|
||||
// UI interactions
|
||||
void DeleteChannel( void );
|
||||
void NewChannel( void );
|
||||
void MoveChannelUp( void );
|
||||
void MoveChannelDown( void );
|
||||
|
||||
// Expanded view or contracted view
|
||||
void ShowChannels( bool show );
|
||||
bool GetShowChannels( void );
|
||||
|
||||
float *GetSettings( void );
|
||||
|
||||
void ResetSettings( void );
|
||||
|
||||
private:
|
||||
// Context menu handler
|
||||
void ShowRightClickMenu( int mx, int my );
|
||||
|
||||
// The underlying actor
|
||||
CChoreoActor *m_pActor;
|
||||
|
||||
// Children
|
||||
CUtlVector < CChoreoChannelWidget * > m_Channels;
|
||||
|
||||
// Expanded mode?
|
||||
bool m_bShowChannels;
|
||||
|
||||
// Expand/collapse buttons
|
||||
CActorBitmapButton *m_btnOpen;
|
||||
CActorBitmapButton *m_btnClose;
|
||||
|
||||
CActorActiveCheckBox *m_cbActive;
|
||||
|
||||
float m_rgCurrentSetting[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
};
|
||||
|
||||
#endif // CHOREOACTORWIDGET_H
|
||||
1207
utils/hlfaceposer/choreochannelwidget.cpp
Normal file
1207
utils/hlfaceposer/choreochannelwidget.cpp
Normal file
File diff suppressed because it is too large
Load Diff
120
utils/hlfaceposer/choreochannelwidget.h
Normal file
120
utils/hlfaceposer/choreochannelwidget.h
Normal file
@@ -0,0 +1,120 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOCHANNELWIDGET_H
|
||||
#define CHOREOCHANNELWIDGET_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "choreowidget.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
class CChoreoEventWidget;
|
||||
class CChoreoActorWidget;
|
||||
class CChoreoChannel;
|
||||
class CChoreoChannelWidget;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The channel container
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoChannelWidget : public CChoreoWidget
|
||||
{
|
||||
public:
|
||||
typedef CChoreoWidget BaseClass;
|
||||
|
||||
enum
|
||||
{
|
||||
FULLMENU = 0,
|
||||
NEWEVENTMENU
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CLOSECAPTION_NONE = 0,
|
||||
CLOSECAPTION_EXPANDCOLLAPSE,
|
||||
CLOSECAPTION_PREVLANGUAGE,
|
||||
CLOSECAPTION_NEXTLANGUAGE,
|
||||
CLOSECAPTION_SELECTOR,
|
||||
CLOSECAPTION_CAPTION,
|
||||
};
|
||||
|
||||
// Construction
|
||||
CChoreoChannelWidget( CChoreoActorWidget *parent );
|
||||
virtual ~CChoreoChannelWidget( void );
|
||||
|
||||
virtual void Create( void );
|
||||
virtual void Layout( RECT& rc );
|
||||
|
||||
virtual int GetItemHeight( void );
|
||||
|
||||
virtual void redraw(CChoreoWidgetDrawHelper& drawHelper);
|
||||
virtual void redrawStatus( CChoreoWidgetDrawHelper& drawHelper, RECT& rcClient, int areaUnderMouse );
|
||||
|
||||
// Accessors
|
||||
CChoreoChannel *GetChannel( void );
|
||||
void SetChannel( CChoreoChannel *channel );
|
||||
|
||||
// Manipulate child events
|
||||
void AddEvent( CChoreoEventWidget *event );
|
||||
void RemoveEvent( CChoreoEventWidget *event );
|
||||
|
||||
void MoveEventToTail( CChoreoEventWidget *event );
|
||||
|
||||
CChoreoEventWidget *GetEvent( int num );
|
||||
int GetNumEvents( void );
|
||||
|
||||
// Determine time for click position
|
||||
float GetTimeForMousePosition( int mx );
|
||||
|
||||
int GetChannelItemUnderMouse( int mx, int my );
|
||||
|
||||
CChoreoEvent *GetCaptionClickedEvent();
|
||||
void GetMasterAndSlaves( CChoreoEvent *master, CUtlVector< CChoreoEvent * >& fulllist );
|
||||
|
||||
void HandleSelectorClicked();
|
||||
|
||||
private:
|
||||
|
||||
struct CloseCaptionInfo
|
||||
{
|
||||
bool isSelector;
|
||||
RECT rcSelector;
|
||||
RECT rcCaption;
|
||||
int eventindex;
|
||||
};
|
||||
|
||||
void GetCloseCaptionExpandCollapseRect( RECT& rc );
|
||||
void GetCloseCaptionLanguageRect( RECT& rc, bool previous );
|
||||
void GetCloseCaptions( CUtlVector< CloseCaptionInfo >& selectors );
|
||||
|
||||
int GetVerticalStackingCount( bool dolayout, RECT* rc );
|
||||
void LayoutEventInRow( CChoreoEventWidget *event, int row, RECT& rc );
|
||||
|
||||
void RenderCloseCaptionInfo( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventArea );
|
||||
void RenderCloseCaptions( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventArea );
|
||||
void RenderCloseCaptionExpandCollapseRect( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventArea );
|
||||
void RenderCloseCaptionSelectors( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventArea );
|
||||
|
||||
void SetUsingCombinedFieldByTokenName( char const *token, bool usingcombinedfile );
|
||||
|
||||
bool CheckHasAudio();
|
||||
|
||||
// The actor to whom we belong
|
||||
CChoreoActorWidget *m_pParent;
|
||||
|
||||
// The underlying scene object
|
||||
CChoreoChannel *m_pChannel;
|
||||
|
||||
// Children
|
||||
CUtlVector < CChoreoEventWidget * > m_Events;
|
||||
bool m_bHasAudio;
|
||||
int m_nBaseHeight;
|
||||
|
||||
int m_nSelectorEventIndex;
|
||||
};
|
||||
|
||||
#endif // CHOREOCHANNELWIDGET_H
|
||||
786
utils/hlfaceposer/choreoeventwidget.cpp
Normal file
786
utils/hlfaceposer/choreoeventwidget.cpp
Normal file
@@ -0,0 +1,786 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <stdio.h>
|
||||
#include "hlfaceposer.h"
|
||||
#include "choreoeventwidget.h"
|
||||
#include "choreochannelwidget.h"
|
||||
#include "choreowidgetdrawhelper.h"
|
||||
#include "choreoview.h"
|
||||
#include "choreoevent.h"
|
||||
#include "choreochannel.h"
|
||||
#include "choreoscene.h"
|
||||
#include "choreoviewcolors.h"
|
||||
#include "ifaceposersound.h"
|
||||
#include "snd_audio_source.h"
|
||||
#include "RampTool.h"
|
||||
|
||||
// Static members
|
||||
mxbitmapdata_t CChoreoEventWidget::m_Bitmaps[ FP_NUM_BITMAPS ];
|
||||
mxbitmapdata_t CChoreoEventWidget::m_ResumeConditionBitmap;
|
||||
mxbitmapdata_t CChoreoEventWidget::m_LockBodyFacingBitmap;
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *parent -
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoEventWidget::CChoreoEventWidget( CChoreoWidget *parent )
|
||||
: CChoreoWidget( parent )
|
||||
{
|
||||
m_pEvent = NULL;
|
||||
m_pParent = parent;
|
||||
m_pWaveFile = NULL;
|
||||
m_nDurationRightEdge= 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoEventWidget::~CChoreoEventWidget( void )
|
||||
{
|
||||
delete m_pWaveFile;
|
||||
m_pWaveFile = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::Create( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CChoreoEventWidget::GetLabelText( void )
|
||||
{
|
||||
static char label[ 256 ];
|
||||
if ( GetEvent()->GetType() == CChoreoEvent::EXPRESSION )
|
||||
{
|
||||
sprintf( label, "%s : %s", GetEvent()->GetParameters(), GetEvent()->GetParameters2() );
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy( label, GetEvent()->GetParameters() );
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoEventWidget::GetDurationRightEdge( void )
|
||||
{
|
||||
return m_nDurationRightEdge;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : rc -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::Layout( RECT& rc )
|
||||
{
|
||||
int requestedW = rc.right - rc.left;
|
||||
|
||||
m_nDurationRightEdge = requestedW;
|
||||
|
||||
setBounds( rc.left, rc.top, requestedW, rc.bottom - rc.top );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : drawHelper -
|
||||
// &rcWAV -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper, RECT &rcWAV, float length, CChoreoEvent *event )
|
||||
{
|
||||
for ( int i = 0; i < event->GetNumRelativeTags(); i++ )
|
||||
{
|
||||
CEventRelativeTag *tag = event->GetRelativeTag( i );
|
||||
if ( !tag )
|
||||
continue;
|
||||
|
||||
//
|
||||
int left = rcWAV.left + (int)( tag->GetPercentage() * ( float )( rcWAV.right - rcWAV.left ) + 0.5f );
|
||||
|
||||
RECT rcMark;
|
||||
rcMark = rcWAV;
|
||||
rcMark.top -= 2;
|
||||
rcMark.bottom = rcMark.top + 6;
|
||||
rcMark.left = left - 3;
|
||||
rcMark.right = left + 3;
|
||||
|
||||
drawHelper.DrawTriangleMarker( rcMark, Color( 0, 100, 250 ) );
|
||||
|
||||
RECT rcText;
|
||||
rcText = rcMark;
|
||||
rcText.top -= 12;
|
||||
|
||||
int len = drawHelper.CalcTextWidth( "Arial", 9, FW_NORMAL, tag->GetName() );
|
||||
rcText.left = left - len / 2;
|
||||
rcText.right = rcText.left + len + 2;
|
||||
|
||||
rcText.bottom = rcText.top + 10;
|
||||
|
||||
drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, Color( 0, 100, 200 ), rcText, tag->GetName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : drawHelper -
|
||||
// &rcWAV -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::DrawAbsoluteTags( CChoreoWidgetDrawHelper& drawHelper, RECT &rcWAV, float length, CChoreoEvent *event )
|
||||
{
|
||||
for ( int i = 0; i < event->GetNumAbsoluteTags( CChoreoEvent::PLAYBACK ); i++ )
|
||||
{
|
||||
CEventAbsoluteTag *tag = event->GetAbsoluteTag( CChoreoEvent::PLAYBACK, i );
|
||||
if ( !tag )
|
||||
continue;
|
||||
|
||||
//
|
||||
int left = rcWAV.left + (int)( tag->GetPercentage() * ( float )( rcWAV.right - rcWAV.left ) + 0.5f );
|
||||
|
||||
RECT rcMark;
|
||||
rcMark = rcWAV;
|
||||
rcMark.top -= 2;
|
||||
rcMark.bottom = rcMark.top + 6;
|
||||
rcMark.left = left - 3;
|
||||
rcMark.right = left + 3;
|
||||
|
||||
drawHelper.DrawTriangleMarker( rcMark, Color( 0, 100, 250 ) );
|
||||
|
||||
RECT rcText;
|
||||
rcText = rcMark;
|
||||
rcText.top -= 12;
|
||||
|
||||
int len = drawHelper.CalcTextWidth( "Arial", 9, FW_NORMAL, tag->GetName() );
|
||||
rcText.left = left - len / 2;
|
||||
rcText.right = rcText.left + len + 2;
|
||||
|
||||
rcText.bottom = rcText.top + 10;
|
||||
|
||||
drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, Color( 0, 100, 200 ), rcText, tag->GetName() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : drawHelper -
|
||||
// rcBounds -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::redrawStatus( CChoreoWidgetDrawHelper& drawHelper, RECT& rcClient )
|
||||
{
|
||||
if ( !getVisible() )
|
||||
return;
|
||||
|
||||
CChoreoEvent *event = GetEvent();
|
||||
if ( !event )
|
||||
return;
|
||||
|
||||
int deflateborder = 1;
|
||||
int fontsize = 9;
|
||||
|
||||
HDC dc = drawHelper.GrabDC();
|
||||
|
||||
// Now draw the label
|
||||
RECT rcEventLabel;
|
||||
rcEventLabel = rcClient;
|
||||
|
||||
InflateRect( &rcEventLabel, 0, -deflateborder );
|
||||
|
||||
// rcEventLabel.top += 2;
|
||||
rcEventLabel.left += 2;
|
||||
//rcEventLabel.top = rcEventLabel.bottom - 2 * ( fontsize + 2 ) - 1;
|
||||
//rcEventLabel.bottom = rcEventLabel.top + fontsize + 2;
|
||||
|
||||
int leftAdd = 16;
|
||||
|
||||
if ( CChoreoEventWidget::GetImage( event->GetType() ) )
|
||||
{
|
||||
mxbitmapdata_t *image = CChoreoEventWidget::GetImage( event->GetType() );
|
||||
if ( image )
|
||||
{
|
||||
RECT rcFixed = rcEventLabel;
|
||||
drawHelper.OffsetSubRect( rcFixed );
|
||||
DrawBitmapToDC( dc, rcFixed.left, rcFixed.top, leftAdd, leftAdd,
|
||||
*image );
|
||||
}
|
||||
}
|
||||
|
||||
OffsetRect( &rcEventLabel, leftAdd, 0 );
|
||||
|
||||
if ( event->IsResumeCondition() )
|
||||
{
|
||||
RECT rc = rcEventLabel;
|
||||
OffsetRect( &rcEventLabel, 16, 0 );
|
||||
rc.right = rc.left + leftAdd;
|
||||
rc.bottom = rc.top + leftAdd;
|
||||
|
||||
RECT rcFixed = rc;
|
||||
drawHelper.OffsetSubRect( rcFixed );
|
||||
DrawBitmapToDC( dc, rcFixed.left, rcFixed.top,
|
||||
rcFixed.right - rcFixed.left, rcFixed.bottom - rcFixed.top,
|
||||
*CChoreoEventWidget::GetPauseImage() );
|
||||
}
|
||||
|
||||
if ( event->IsLockBodyFacing() )
|
||||
{
|
||||
RECT rc = rcEventLabel;
|
||||
OffsetRect( &rcEventLabel, 16, 0 );
|
||||
rc.right = rc.left + leftAdd;
|
||||
rc.bottom = rc.top + leftAdd;
|
||||
|
||||
RECT rcFixed = rc;
|
||||
drawHelper.OffsetSubRect( rcFixed );
|
||||
DrawBitmapToDC( dc, rcFixed.left, rcFixed.top,
|
||||
rcFixed.right - rcFixed.left, rcFixed.bottom - rcFixed.top,
|
||||
*CChoreoEventWidget::GetLockImage() );
|
||||
}
|
||||
|
||||
// Draw Type Name:
|
||||
OffsetRect( &rcEventLabel, 2, 1 );
|
||||
|
||||
rcEventLabel.left = rcClient.left + 32;
|
||||
rcEventLabel.bottom = rcEventLabel.top + fontsize + 2;
|
||||
// OffsetRect( &rcEventLabel, 0, 2 );
|
||||
|
||||
drawHelper.CalcTextWidth( "Arial", fontsize, FW_NORMAL, "%s event \"%s\"", event->NameForType( event->GetType() ), event->GetName() );
|
||||
drawHelper.DrawColoredText( "Arial", fontsize, FW_NORMAL, COLOR_INFO_TEXT, rcEventLabel, "%s event \"%s\"", event->NameForType( event->GetType() ), event->GetName() );
|
||||
|
||||
OffsetRect( &rcEventLabel, 0, fontsize + 2 );
|
||||
|
||||
drawHelper.DrawColoredText( "Arial", fontsize, FW_NORMAL, COLOR_INFO_TEXT, rcEventLabel, "parameters \"%s\"", GetLabelText() );
|
||||
|
||||
}
|
||||
|
||||
Color CChoreoEventWidget::GrayOutColor( Color clr )
|
||||
{
|
||||
CChoreoEvent *event = GetEvent();
|
||||
if ( !event )
|
||||
return clr;
|
||||
if ( event->GetActive() )
|
||||
return clr;
|
||||
|
||||
int r, g, b;
|
||||
r = clr.r();
|
||||
g = clr.g();
|
||||
b = clr.b();
|
||||
int val = ( r + g + b ) / 3;
|
||||
val += ( 255 - val ) * 0.25f;
|
||||
|
||||
clr = Color( val, val, val );
|
||||
return clr;
|
||||
}
|
||||
|
||||
|
||||
void CChoreoEventWidget::DrawSpeakEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine )
|
||||
{
|
||||
if ( !m_pWaveFile )
|
||||
return;
|
||||
|
||||
bool ramponly = m_pView->IsRampOnly();
|
||||
|
||||
CChoreoEvent *event = GetEvent();
|
||||
Assert( event );
|
||||
|
||||
HDC dc = drawHelper.GrabDC();
|
||||
|
||||
HBRUSH brEvent = CreateSolidBrush( ColorToRGB( GrayOutColor( COLOR_CHOREO_EVENT ) ) );
|
||||
HBRUSH brBackground = CreateSolidBrush( ColorToRGB( GrayOutColor( COLOR_CHOREO_DARKBACKGROUND ) ) );
|
||||
|
||||
if ( !ramponly )
|
||||
{
|
||||
FillRect( dc, &rcEventLine, brBackground );
|
||||
}
|
||||
|
||||
// Only draw wav form here if selected
|
||||
if ( IsSelected() )
|
||||
{
|
||||
sound->RenderWavToDC( dc, rcEventLine, GrayOutColor( IsSelected() ? COLOR_CHOREO_EVENT_SELECTED : COLOR_CHOREO_EVENT ), 0.0, m_pWaveFile->GetRunningLength(), m_pWaveFile );
|
||||
}
|
||||
|
||||
//FrameRect( dc, &rcEventLine, brEvent );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( COLOR_CHOREO_EVENT ), PS_SOLID, 3,
|
||||
rcEventLine.left, rcEventLine.top, rcEventLine.left, rcEventLine.bottom );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( COLOR_CHOREO_EVENT ), PS_SOLID, 3,
|
||||
rcEventLine.right, rcEventLine.top, rcEventLine.right, rcEventLine.bottom );
|
||||
|
||||
DeleteObject( brBackground );
|
||||
DeleteObject( brEvent );
|
||||
|
||||
//rcEventLine.top -= 3;
|
||||
DrawRelativeTags( drawHelper, rcEventLine, m_pWaveFile->GetRunningLength(), event );
|
||||
}
|
||||
|
||||
void CChoreoEventWidget::DrawGestureEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine )
|
||||
{
|
||||
CChoreoEvent *event = GetEvent();
|
||||
Assert( event );
|
||||
|
||||
RECT rcEventLine2 = rcEventLine;
|
||||
/*
|
||||
float duration = event->GetDuration();
|
||||
// Crop eventline2
|
||||
if ( duration > 0.0f )
|
||||
{
|
||||
float attack_frac = 0.3; // ( event->GetAttackTime() ) / duration;
|
||||
float decay_frac = 0.7; // ( event->GetDecayTime() ) / duration;
|
||||
|
||||
float event_line_width = rcEventLine.right - rcEventLine.left;
|
||||
|
||||
rcEventLine2.left = rcEventLine.left + attack_frac * event_line_width;
|
||||
rcEventLine2.right = rcEventLine.left + decay_frac * event_line_width;
|
||||
}
|
||||
*/
|
||||
|
||||
bool ramponly = m_pView->IsRampOnly();
|
||||
|
||||
|
||||
HDC dc = drawHelper.GrabDC();
|
||||
|
||||
bool nullevent = false;
|
||||
|
||||
Color clrEvent = GrayOutColor( IsSelected() ? COLOR_CHOREO_EVENT_SELECTED : COLOR_CHOREO_EVENT );
|
||||
if ( !Q_stricmp( event->GetName(), "NULL" ) )
|
||||
{
|
||||
clrEvent = GrayOutColor( Color( 50, 50, 120 ) );
|
||||
nullevent = true;
|
||||
}
|
||||
|
||||
HBRUSH brEvent = CreateSolidBrush( ColorToRGB( clrEvent ) );
|
||||
|
||||
if ( !ramponly )
|
||||
{
|
||||
FillRect( dc, &rcEventLine2, brEvent );
|
||||
}
|
||||
|
||||
DeleteObject( brEvent );
|
||||
|
||||
if ( ramponly && IsSelected() )
|
||||
{
|
||||
drawHelper.DrawOutlinedRect( GrayOutColor( Color( 150, 180, 250 ) ), PS_SOLID, 1,
|
||||
rcEventLine2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine2.left, rcEventLine2.bottom,
|
||||
rcEventLine2.left, rcEventLine2.top );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine2.left, rcEventLine2.top,
|
||||
rcEventLine2.right, rcEventLine2.top );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 31, 31, 31 ) ), PS_SOLID, 1, rcEventLine2.right, rcEventLine2.top,
|
||||
rcEventLine2.right, rcEventLine2.bottom );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 0, 0, 0 ) ), PS_SOLID, 1, rcEventLine2.right, rcEventLine2.bottom,
|
||||
rcEventLine2.left, rcEventLine2.bottom );
|
||||
}
|
||||
|
||||
int rampstart = m_pView->GetPixelForTimeValue( event->GetStartTime( ) );
|
||||
int rampend = m_pView->GetPixelForTimeValue( event->GetEndTime( ) );
|
||||
|
||||
// Color clrBottom = Color( 180, 180, 180 );
|
||||
|
||||
// drawHelper.DrawColoredLine( clrBottom, PS_SOLID, 1, rampstart, rcEventLine2.bottom,
|
||||
// rcEventLine2.left, rcEventLine2.bottom );
|
||||
// drawHelper.DrawColoredLine( clrBottom, PS_SOLID, 1, rcEventLine2.right, rcEventLine2.bottom,
|
||||
// rampend, rcEventLine2.bottom );
|
||||
|
||||
if ( !nullevent )
|
||||
{
|
||||
drawHelper.DrawColoredRamp( clrEvent, PS_SOLID, 1,
|
||||
rampstart,
|
||||
rcEventLine2.bottom,
|
||||
rcEventLine2.left,
|
||||
rcEventLine2.top,
|
||||
0.0f,
|
||||
1.0f );
|
||||
drawHelper.DrawColoredRamp( clrEvent, PS_SOLID, 1,
|
||||
rcEventLine2.right,
|
||||
rcEventLine2.top,
|
||||
rampend,
|
||||
rcEventLine2.bottom,
|
||||
0.0f,
|
||||
1.0f );
|
||||
}
|
||||
|
||||
g_pRampTool->DrawSamplesSimple( drawHelper, event, false, GrayOutColor( Color( 63, 63, 63 ) ), rcEventLine );
|
||||
|
||||
DrawRelativeTags( drawHelper, rcEventLine, event->GetDuration(), event );
|
||||
DrawAbsoluteTags( drawHelper, rcEventLine, event->GetDuration(), event );
|
||||
}
|
||||
|
||||
void CChoreoEventWidget::DrawGenericEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine )
|
||||
{
|
||||
bool ramponly = m_pView->IsRampOnly();
|
||||
|
||||
CChoreoEvent *event = GetEvent();
|
||||
Assert( event );
|
||||
|
||||
HDC dc = drawHelper.GrabDC();
|
||||
|
||||
Color clrEvent = GrayOutColor( IsSelected() ? COLOR_CHOREO_EVENT_SELECTED : COLOR_CHOREO_EVENT );
|
||||
if ( event->GetType() == CChoreoEvent::SUBSCENE )
|
||||
{
|
||||
clrEvent = GrayOutColor( Color( 200, 180, 200 ) );
|
||||
}
|
||||
|
||||
HBRUSH brEvent = CreateSolidBrush( ColorToRGB( clrEvent ) );
|
||||
|
||||
if ( !ramponly )
|
||||
{
|
||||
FillRect( dc, &rcEventLine, brEvent );
|
||||
}
|
||||
|
||||
DeleteObject( brEvent );
|
||||
|
||||
if ( ramponly && IsSelected() )
|
||||
{
|
||||
drawHelper.DrawOutlinedRect( GrayOutColor( Color( 150, 180, 250 ) ), PS_SOLID, 1,
|
||||
rcEventLine );
|
||||
}
|
||||
else
|
||||
{
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine.left, rcEventLine.bottom,
|
||||
rcEventLine.left, rcEventLine.top );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 127, 127, 127 ) ), PS_SOLID, 1, rcEventLine.left, rcEventLine.top,
|
||||
rcEventLine.right, rcEventLine.top );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 31, 31, 31 ) ), PS_SOLID, 1, rcEventLine.right, rcEventLine.top,
|
||||
rcEventLine.right, rcEventLine.bottom );
|
||||
drawHelper.DrawColoredLine( GrayOutColor( Color( 0, 0, 0 ) ), PS_SOLID, 1, rcEventLine.right, rcEventLine.bottom,
|
||||
rcEventLine.left, rcEventLine.bottom );
|
||||
}
|
||||
|
||||
g_pRampTool->DrawSamplesSimple( drawHelper, event, false, GrayOutColor( Color( 63, 63, 63 ) ), rcEventLine );
|
||||
|
||||
DrawRelativeTags( drawHelper, rcEventLine, event->GetDuration(), event );
|
||||
DrawAbsoluteTags( drawHelper, rcEventLine, event->GetDuration(), event );
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: FIXME: This should either be embedded or we should draw the caption
|
||||
// here
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::redraw( CChoreoWidgetDrawHelper& drawHelper )
|
||||
{
|
||||
if ( !getVisible() )
|
||||
return;
|
||||
|
||||
CChoreoEvent *event = GetEvent();
|
||||
if ( !event )
|
||||
return;
|
||||
|
||||
int deflateborder = 1;
|
||||
int fontsize = 9;
|
||||
|
||||
HDC dc = drawHelper.GrabDC();
|
||||
RECT rcClient = getBounds();
|
||||
|
||||
RECT rcDC;
|
||||
drawHelper.GetClientRect( rcDC );
|
||||
|
||||
RECT dummy;
|
||||
if ( !IntersectRect( &dummy, &rcDC, &rcClient ) )
|
||||
return;
|
||||
|
||||
bool ramponly = m_pView->IsRampOnly();
|
||||
|
||||
if ( IsSelected() && !ramponly )
|
||||
{
|
||||
InflateRect( &rcClient, 3, 1 );
|
||||
//rcClient.bottom -= 1;
|
||||
rcClient.right += 1;
|
||||
|
||||
RECT rcFrame = rcClient;
|
||||
RECT rcBorder = rcClient;
|
||||
|
||||
rcFrame.bottom = rcFrame.top + 17;
|
||||
rcBorder.bottom = rcFrame.top + 17;
|
||||
|
||||
Color clrSelection = GrayOutColor( Color( 0, 63, 63 ) );
|
||||
Color clrBorder = GrayOutColor( Color( 100, 200, 255 ) );
|
||||
|
||||
HBRUSH brBorder = CreateSolidBrush( ColorToRGB( clrBorder ));
|
||||
HBRUSH brSelected = CreateHatchBrush( HS_FDIAGONAL, ColorToRGB( clrSelection ) );
|
||||
for ( int i = 0; i < 2; i++ )
|
||||
{
|
||||
FrameRect( dc, &rcFrame, brSelected );
|
||||
InflateRect( &rcFrame, -1, -1 );
|
||||
}
|
||||
FrameRect( dc, &rcBorder, brBorder );
|
||||
FrameRect( dc, &rcFrame, brBorder );
|
||||
|
||||
DeleteObject( brSelected );
|
||||
DeleteObject( brBorder );
|
||||
rcClient.right -= 1;
|
||||
//rcClient.bottom += 1;
|
||||
InflateRect( &rcClient, -3, -1 );
|
||||
}
|
||||
|
||||
RECT rcEvent;
|
||||
rcEvent = rcClient;
|
||||
|
||||
InflateRect( &rcEvent, 0, -deflateborder );
|
||||
|
||||
rcEvent.bottom = rcEvent.top + 10;
|
||||
|
||||
if ( event->GetType() == CChoreoEvent::SPEAK && m_pWaveFile && !event->HasEndTime() )
|
||||
{
|
||||
event->SetEndTime( event->GetStartTime() + m_pWaveFile->GetRunningLength() );
|
||||
rcEvent.right = ( int )( m_pWaveFile->GetRunningLength() * m_pView->GetPixelsPerSecond() );
|
||||
}
|
||||
|
||||
if ( event->HasEndTime() )
|
||||
{
|
||||
RECT rcEventLine = rcEvent;
|
||||
OffsetRect( &rcEventLine, 0, 1 );
|
||||
|
||||
switch ( event->GetType() )
|
||||
{
|
||||
case CChoreoEvent::SPEAK:
|
||||
{
|
||||
DrawSpeakEvent( drawHelper, rcEventLine );
|
||||
}
|
||||
break;
|
||||
case CChoreoEvent::GESTURE:
|
||||
{
|
||||
DrawGestureEvent( drawHelper, rcEventLine );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
DrawGenericEvent( drawHelper, rcEventLine );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RECT rcEventLine = rcEvent;
|
||||
OffsetRect( &rcEventLine, 0, 1 );
|
||||
|
||||
drawHelper.DrawColoredLine( GrayOutColor( COLOR_CHOREO_EVENT ), PS_SOLID, 3,
|
||||
rcEventLine.left - 1, rcEventLine.top, rcEventLine.left - 1, rcEventLine.bottom );
|
||||
}
|
||||
|
||||
if ( event->IsUsingRelativeTag() )
|
||||
{
|
||||
RECT rcTagName;
|
||||
rcTagName = rcClient;
|
||||
|
||||
int length = drawHelper.CalcTextWidth( "Arial", 9, FW_NORMAL, event->GetRelativeTagName() );
|
||||
|
||||
rcTagName.right = rcTagName.left;
|
||||
rcTagName.left = rcTagName.right - length - 4;
|
||||
rcTagName.top += 3;
|
||||
rcTagName.bottom = rcTagName.top + 10;
|
||||
|
||||
drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, GrayOutColor( Color( 0, 100, 200 ) ), rcTagName, event->GetRelativeTagName() );
|
||||
|
||||
drawHelper.DrawFilledRect( GrayOutColor( Color( 0, 100, 250 ) ), rcTagName.right-1, rcTagName.top-2,
|
||||
rcTagName.right+2, rcTagName.bottom + 2 );
|
||||
|
||||
}
|
||||
|
||||
// Now draw the label
|
||||
RECT rcEventLabel;
|
||||
rcEventLabel = rcClient;
|
||||
|
||||
InflateRect( &rcEventLabel, 0, -deflateborder );
|
||||
|
||||
rcEventLabel.top += 15; // rcEventLabel.bottom - 2 * ( fontsize + 2 ) - 1;
|
||||
rcEventLabel.bottom = rcEventLabel.top + fontsize + 2;
|
||||
rcEventLabel.left += 1;
|
||||
|
||||
//rcEventLabel.left -= 8;
|
||||
|
||||
int leftAdd = 16;
|
||||
|
||||
if ( CChoreoEventWidget::GetImage( event->GetType() ) )
|
||||
{
|
||||
mxbitmapdata_t *image = CChoreoEventWidget::GetImage( event->GetType() );
|
||||
if ( image )
|
||||
{
|
||||
DrawBitmapToDC( dc, rcEventLabel.left, rcEventLabel.top, leftAdd, leftAdd,
|
||||
*image );
|
||||
}
|
||||
}
|
||||
|
||||
OffsetRect( &rcEventLabel, leftAdd, 1 );
|
||||
|
||||
if ( event->IsResumeCondition() )
|
||||
{
|
||||
RECT rc = rcEventLabel;
|
||||
OffsetRect( &rcEventLabel, leftAdd, 0 );
|
||||
rc.right = rc.left + leftAdd;
|
||||
rc.bottom = rc.top + leftAdd;
|
||||
|
||||
DrawBitmapToDC( dc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
||||
*CChoreoEventWidget::GetPauseImage() );
|
||||
}
|
||||
|
||||
if ( event->IsLockBodyFacing() )
|
||||
{
|
||||
RECT rc = rcEventLabel;
|
||||
OffsetRect( &rcEventLabel, 16, 0 );
|
||||
rc.right = rc.left + leftAdd;
|
||||
rc.bottom = rc.top + leftAdd;
|
||||
|
||||
RECT rcFixed = rc;
|
||||
drawHelper.OffsetSubRect( rcFixed );
|
||||
DrawBitmapToDC( dc, rcFixed.left, rcFixed.top,
|
||||
rcFixed.right - rcFixed.left, rcFixed.bottom - rcFixed.top,
|
||||
*CChoreoEventWidget::GetLockImage() );
|
||||
}
|
||||
|
||||
OffsetRect( &rcEventLabel, 2, 1 );
|
||||
|
||||
int len = drawHelper.CalcTextWidth( "Arial", fontsize, FW_NORMAL, event->GetName() );
|
||||
|
||||
rcEventLabel.right = rcEventLabel.left + len + 2;
|
||||
drawHelper.DrawColoredText( "Arial", fontsize, FW_NORMAL, GrayOutColor( Color( 0, 0, 120 ) ),
|
||||
rcEventLabel, event->GetName() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : CChoreoEvent
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoEvent *CChoreoEventWidget::GetEvent( void )
|
||||
{
|
||||
return m_pEvent;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *event -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::SetEvent( CChoreoEvent *event )
|
||||
{
|
||||
sound->StopAll();
|
||||
|
||||
delete m_pWaveFile;
|
||||
m_pWaveFile = NULL;
|
||||
|
||||
m_pEvent = event;
|
||||
|
||||
if ( event->GetType() == CChoreoEvent::SPEAK )
|
||||
{
|
||||
m_pWaveFile = sound->LoadSound( va( "sound/%s", FacePoser_TranslateSoundName( event ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: If the user changes the association of .mdls to actors, then the gender could change and we could need to access a different .wav file
|
||||
// Input : -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::RecomputeWave()
|
||||
{
|
||||
if ( m_pEvent->GetType() == CChoreoEvent::SPEAK )
|
||||
{
|
||||
delete m_pWaveFile;
|
||||
m_pWaveFile = sound->LoadSound( va( "sound/%s", FacePoser_TranslateSoundName( m_pEvent ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::LoadImages( void )
|
||||
{
|
||||
for ( int i = 0; i < FP_NUM_BITMAPS; i++ )
|
||||
{
|
||||
m_Bitmaps[ i ].valid = false;
|
||||
}
|
||||
|
||||
m_ResumeConditionBitmap.valid = false;
|
||||
m_LockBodyFacingBitmap.valid = false;
|
||||
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_expression.bmp", m_Bitmaps[ CChoreoEvent::EXPRESSION ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_lookat.bmp", m_Bitmaps[ CChoreoEvent::LOOKAT ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_moveto.bmp", m_Bitmaps[ CChoreoEvent::MOVETO ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_speak.bmp", m_Bitmaps[ CChoreoEvent::SPEAK ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_gesture.bmp", m_Bitmaps[ CChoreoEvent::GESTURE ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_face.bmp", m_Bitmaps[ CChoreoEvent::FACE ] );
|
||||
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_firetrigger.bmp", m_Bitmaps[ CChoreoEvent::FIRETRIGGER ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_sequence.bmp", m_Bitmaps[ CChoreoEvent::SEQUENCE ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_flexanimation.bmp", m_Bitmaps[ CChoreoEvent::FLEXANIMATION ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_subscene.bmp", m_Bitmaps[ CChoreoEvent::SUBSCENE ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_loop.bmp", m_Bitmaps[ CChoreoEvent::LOOP ] );
|
||||
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/pause.bmp", m_ResumeConditionBitmap );
|
||||
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_interrupt.bmp", m_Bitmaps[ CChoreoEvent::INTERRUPT ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_stoppoint.bmp", m_Bitmaps[ CChoreoEvent::STOPPOINT ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_permit_response.bmp", m_Bitmaps[ CChoreoEvent::PERMIT_RESPONSES ] );
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_generic.bmp", m_Bitmaps[ CChoreoEvent::GENERIC ] );
|
||||
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/ev_generic.bmp", m_Bitmaps[ CChoreoEvent::CAMERA ] );
|
||||
|
||||
LoadBitmapFromFile( "gfx/hlfaceposer/lock.bmp", m_LockBodyFacingBitmap );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoEventWidget::DestroyImages( void )
|
||||
{
|
||||
for ( int i = 0; i < FP_NUM_BITMAPS; i++ )
|
||||
{
|
||||
if ( m_Bitmaps[ i ].valid )
|
||||
{
|
||||
m_Bitmaps[ i ].valid = false;
|
||||
DeleteObject( m_Bitmaps[ i ].image );
|
||||
m_Bitmaps[ i ].image = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_ResumeConditionBitmap.valid )
|
||||
{
|
||||
m_ResumeConditionBitmap.valid = false;
|
||||
DeleteObject( m_ResumeConditionBitmap.image );
|
||||
m_ResumeConditionBitmap.image = NULL;
|
||||
}
|
||||
|
||||
if ( m_LockBodyFacingBitmap.valid )
|
||||
{
|
||||
m_LockBodyFacingBitmap.valid = false;
|
||||
DeleteObject( m_LockBodyFacingBitmap.image );
|
||||
m_LockBodyFacingBitmap.image = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : type -
|
||||
// Output : mxbitmapdata_t
|
||||
//-----------------------------------------------------------------------------
|
||||
mxbitmapdata_t *CChoreoEventWidget::GetImage( int type )
|
||||
{
|
||||
return &m_Bitmaps[ type ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : mxbitmapdata_t
|
||||
//-----------------------------------------------------------------------------
|
||||
mxbitmapdata_t *CChoreoEventWidget::GetPauseImage( void )
|
||||
{
|
||||
return &m_ResumeConditionBitmap;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : mxbitmapdata_t
|
||||
//-----------------------------------------------------------------------------
|
||||
mxbitmapdata_t *CChoreoEventWidget::GetLockImage( void )
|
||||
{
|
||||
return &m_LockBodyFacingBitmap;
|
||||
}
|
||||
88
utils/hlfaceposer/choreoeventwidget.h
Normal file
88
utils/hlfaceposer/choreoeventwidget.h
Normal file
@@ -0,0 +1,88 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOEVENTWIDGET_H
|
||||
#define CHOREOEVENTWIDGET_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "mxbitmaptools.h"
|
||||
#include "choreowidget.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
class CChoreoChannelWidget;
|
||||
class CAudioSource;
|
||||
|
||||
#define FP_NUM_BITMAPS 20
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw event UI element and handle mouse interactions
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoEventWidget : public CChoreoWidget
|
||||
{
|
||||
public:
|
||||
typedef CChoreoWidget BaseClass;
|
||||
|
||||
// Construction/destruction
|
||||
CChoreoEventWidget( CChoreoWidget *parent );
|
||||
virtual ~CChoreoEventWidget( void );
|
||||
|
||||
// Create children
|
||||
virtual void Create( void );
|
||||
// Redo layout
|
||||
virtual void Layout( RECT& rc );
|
||||
// Screen refresh
|
||||
virtual void redraw(CChoreoWidgetDrawHelper& drawHelper);
|
||||
virtual void redrawStatus( CChoreoWidgetDrawHelper& drawHelper, RECT& rcClient );
|
||||
|
||||
virtual int GetDurationRightEdge( void );
|
||||
|
||||
// Access underlying object
|
||||
CChoreoEvent *GetEvent( void );
|
||||
void SetEvent( CChoreoEvent *event );
|
||||
|
||||
// If the user changes the association of .mdls to actors, then the gender could change and we could need to access a different .wav file
|
||||
// Call this to reconcile things
|
||||
void RecomputeWave();
|
||||
|
||||
// System wide icons for various event types ( indexed by CChoreEvent::m_fType )
|
||||
static void LoadImages( void );
|
||||
static void DestroyImages( void );
|
||||
static mxbitmapdata_t *GetImage( int type );
|
||||
static mxbitmapdata_t *GetPauseImage( void );
|
||||
static mxbitmapdata_t *GetLockImage( void );
|
||||
|
||||
private:
|
||||
|
||||
Color GrayOutColor( Color clr );
|
||||
|
||||
void DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper, RECT &rcWAV, float length, CChoreoEvent *event );
|
||||
void DrawAbsoluteTags( CChoreoWidgetDrawHelper& drawHelper, RECT &rcWAV, float length, CChoreoEvent *event );
|
||||
|
||||
const char *GetLabelText( void );
|
||||
|
||||
void DrawSpeakEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine );
|
||||
void DrawGestureEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine );
|
||||
void DrawGenericEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rcEventLine );
|
||||
// Parent widget
|
||||
CChoreoWidget *m_pParent;
|
||||
|
||||
// Underlying event
|
||||
CChoreoEvent *m_pEvent;
|
||||
|
||||
int m_nDurationRightEdge;
|
||||
|
||||
// For speak events
|
||||
CAudioSource *m_pWaveFile;
|
||||
|
||||
// Bitmaps for drawing event widgets
|
||||
static mxbitmapdata_t m_Bitmaps[ FP_NUM_BITMAPS ];
|
||||
static mxbitmapdata_t m_ResumeConditionBitmap;
|
||||
static mxbitmapdata_t m_LockBodyFacingBitmap;
|
||||
};
|
||||
|
||||
#endif // CHOREOEVENTWIDGET_H
|
||||
216
utils/hlfaceposer/choreoglobaleventwidget.cpp
Normal file
216
utils/hlfaceposer/choreoglobaleventwidget.cpp
Normal file
@@ -0,0 +1,216 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <stdio.h>
|
||||
#include "hlfaceposer.h"
|
||||
#include "choreoviewcolors.h"
|
||||
#include "choreoglobaleventwidget.h"
|
||||
#include "choreowidgetdrawhelper.h"
|
||||
#include "ChoreoView.h"
|
||||
#include "choreoevent.h"
|
||||
#include "choreoeventwidget.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *parent -
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoGlobalEventWidget::CChoreoGlobalEventWidget( CChoreoWidget *parent )
|
||||
: CChoreoWidget( parent )
|
||||
{
|
||||
m_pEvent = NULL;
|
||||
|
||||
m_bDragging = false;
|
||||
m_xStart = 0;
|
||||
m_hPrevCursor = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoGlobalEventWidget::~CChoreoGlobalEventWidget( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoGlobalEventWidget::Create( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : rc -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoGlobalEventWidget::Layout( RECT& rc )
|
||||
{
|
||||
setBounds( rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Redraw to screen
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoGlobalEventWidget::redraw( CChoreoWidgetDrawHelper& drawHelper )
|
||||
{
|
||||
if ( !getVisible() )
|
||||
return;
|
||||
|
||||
CChoreoEvent *event = GetEvent();
|
||||
if ( !event )
|
||||
return;
|
||||
|
||||
RECT rcTab;
|
||||
rcTab = getBounds();
|
||||
|
||||
bool isLoop = false;
|
||||
Color pointColor = COLOR_CHOREO_SEGMENTDIVIDER;
|
||||
Color clr = COLOR_CHOREO_SEGMENTDIVIDER_BG;
|
||||
switch ( event->GetType() )
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case CChoreoEvent::LOOP:
|
||||
{
|
||||
clr = COLOR_CHOREO_LOOPPOINT_BG;
|
||||
pointColor = COLOR_CHOREO_LOOPPOINT;
|
||||
isLoop = true;
|
||||
}
|
||||
break;
|
||||
case CChoreoEvent::STOPPOINT:
|
||||
{
|
||||
clr = COLOR_CHOREO_STOPPOINT_BG;
|
||||
pointColor = COLOR_CHOREO_STOPPOINT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ( IsSelected() )
|
||||
{
|
||||
InflateRect( &rcTab, 2, 2 );
|
||||
|
||||
drawHelper.DrawTriangleMarker( rcTab, pointColor );
|
||||
|
||||
InflateRect( &rcTab, -2, -2 );
|
||||
|
||||
drawHelper.DrawTriangleMarker( rcTab, Color( 240, 240, 220 ) );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
drawHelper.DrawTriangleMarker( rcTab, pointColor );
|
||||
}
|
||||
|
||||
RECT rcClient;
|
||||
drawHelper.GetClientRect( rcClient );
|
||||
|
||||
RECT rcLine = rcTab;
|
||||
rcLine.top = rcTab.bottom + 2;
|
||||
rcLine.bottom = rcClient.bottom;
|
||||
rcLine.left = ( rcLine.left + rcLine.right ) / 2;
|
||||
rcLine.right = rcLine.left;
|
||||
|
||||
if ( IsSelected() )
|
||||
{
|
||||
drawHelper.DrawColoredLine( clr, PS_DOT, 2, rcLine.left, rcLine.top, rcLine.right, rcLine.bottom );
|
||||
}
|
||||
else
|
||||
{
|
||||
drawHelper.DrawColoredLine( clr, PS_DOT, 1, rcLine.left, rcLine.top, rcLine.right, rcLine.bottom );
|
||||
}
|
||||
|
||||
if ( event->GetType() == CChoreoEvent::STOPPOINT )
|
||||
{
|
||||
OffsetRect( &rcTab, -4, 15 );
|
||||
|
||||
mxbitmapdata_t *image = CChoreoEventWidget::GetImage( event->GetType() );
|
||||
if ( image )
|
||||
{
|
||||
drawHelper.OffsetSubRect( rcTab );
|
||||
DrawBitmapToDC( drawHelper.GrabDC(), rcTab.left, rcTab.top, 16, 16, *image );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isLoop )
|
||||
return;
|
||||
|
||||
Color labelText = COLOR_INFO_TEXT;
|
||||
DrawLabel( drawHelper, labelText, rcLine.left, rcLine.top + 2, false );
|
||||
|
||||
// Figure out loop spot
|
||||
float looptime = (float)atof( event->GetParameters() );
|
||||
|
||||
// Find pixel for that
|
||||
bool clipped = false;
|
||||
int x = m_pView->GetPixelForTimeValue( looptime, &clipped );
|
||||
if ( clipped )
|
||||
return;
|
||||
|
||||
rcLine.left = x;
|
||||
rcLine.right = x;
|
||||
|
||||
clr = COLOR_CHOREO_LOOPPOINT_START_BG;
|
||||
drawHelper.DrawColoredLine( clr, PS_SOLID, 1, rcLine.left, rcLine.top, rcLine.right, rcLine.top + 28);
|
||||
|
||||
DrawLabel( drawHelper, labelText, rcLine.left, rcLine.top + 2, true );
|
||||
}
|
||||
|
||||
void CChoreoGlobalEventWidget::DrawLabel( CChoreoWidgetDrawHelper& drawHelper, const Color& clr, int x, int y, bool right )
|
||||
{
|
||||
CChoreoEvent *event = GetEvent();
|
||||
if ( !event )
|
||||
return;
|
||||
|
||||
int len = drawHelper.CalcTextWidth( "Arial", 9, FW_NORMAL, va( "%s", event->GetName() ) );
|
||||
|
||||
RECT rcText;
|
||||
rcText.top = y;
|
||||
rcText.bottom = y + 10;
|
||||
rcText.left = x - len / 2;
|
||||
rcText.right = rcText.left + len;
|
||||
|
||||
if ( !right )
|
||||
{
|
||||
drawHelper.DrawColoredTextCharset( "Marlett", 9, FW_NORMAL, SYMBOL_CHARSET, clr, rcText, "3" );
|
||||
OffsetRect( &rcText, 8, 0 );
|
||||
drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, clr, rcText, va( "%s", event->GetName() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
drawHelper.DrawColoredText( "Arial", 9, FW_NORMAL, clr, rcText, va( "%s", event->GetName() ) );
|
||||
OffsetRect( &rcText, len, 0 );
|
||||
drawHelper.DrawColoredTextCharset( "Marlett", 9, FW_NORMAL, SYMBOL_CHARSET, clr, rcText, "4" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoGlobalEventWidget::DrawFocusRect( void )
|
||||
{
|
||||
HDC dc = GetDC( NULL );
|
||||
|
||||
::DrawFocusRect( dc, &m_rcFocus );
|
||||
|
||||
ReleaseDC( NULL, dc );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : CChoreoEvent
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoEvent *CChoreoGlobalEventWidget::GetEvent( void )
|
||||
{
|
||||
return m_pEvent;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *event -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoGlobalEventWidget::SetEvent( CChoreoEvent *event )
|
||||
{
|
||||
m_pEvent = event;
|
||||
}
|
||||
59
utils/hlfaceposer/choreoglobaleventwidget.h
Normal file
59
utils/hlfaceposer/choreoglobaleventwidget.h
Normal file
@@ -0,0 +1,59 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOGLOBALEVENTWIDGET_H
|
||||
#define CHOREOGLOBALEVENTWIDGET_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "choreowidget.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: For section start/end
|
||||
// FIXME: Finish this
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoGlobalEventWidget : public CChoreoWidget
|
||||
{
|
||||
public:
|
||||
typedef CChoreoWidget BaseClass;
|
||||
|
||||
// Construction/destruction
|
||||
CChoreoGlobalEventWidget( CChoreoWidget *parent );
|
||||
virtual ~CChoreoGlobalEventWidget( void );
|
||||
|
||||
// Create children
|
||||
virtual void Create( void );
|
||||
// Redo layout
|
||||
virtual void Layout( RECT& rc );
|
||||
|
||||
// Screen refresh
|
||||
virtual void redraw(CChoreoWidgetDrawHelper& drawHelper);
|
||||
|
||||
// Access underlying scene object
|
||||
CChoreoEvent *GetEvent( void );
|
||||
void SetEvent( CChoreoEvent *event );
|
||||
|
||||
// Draw focus rect while mouse dragging is going on
|
||||
void DrawFocusRect( void );
|
||||
private:
|
||||
|
||||
void DrawLabel( CChoreoWidgetDrawHelper& drawHelper, const Color& clr, int x, int y, bool right );
|
||||
|
||||
// The underlying scene object
|
||||
CChoreoEvent *m_pEvent;
|
||||
|
||||
// For updating focus rect
|
||||
bool m_bDragging;
|
||||
int m_xStart;
|
||||
RECT m_rcFocus;
|
||||
RECT m_rcOrig;
|
||||
HCURSOR m_hPrevCursor;
|
||||
};
|
||||
|
||||
#endif // CHOREOGLOBALEVENTWIDGET_H
|
||||
11720
utils/hlfaceposer/choreoview.cpp
Normal file
11720
utils/hlfaceposer/choreoview.cpp
Normal file
File diff suppressed because it is too large
Load Diff
837
utils/hlfaceposer/choreoview.h
Normal file
837
utils/hlfaceposer/choreoview.h
Normal file
@@ -0,0 +1,837 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOVIEW_H
|
||||
#define CHOREOVIEW_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include <mxtk/mxWindow.h>
|
||||
#include "mxBitmapButton.h"
|
||||
#include "utlvector.h"
|
||||
#include "ChoreoWidget.h"
|
||||
#include "ichoreoeventcallback.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
#include "ChoreoEvent.h"
|
||||
#include "mathlib/mathlib.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
|
||||
#define IDC_CV_CC_LANGUAGESTART 5300
|
||||
|
||||
#define IDC_STOPSCENE 5000
|
||||
#define IDC_PLAYSCENE 5001
|
||||
#define IDC_PAUSESCENE 5002
|
||||
#define IDC_CHOREOVSCROLL 5003
|
||||
#define IDC_CHOREOHSCROLL 5004
|
||||
|
||||
#define IDC_ADDACTOR 5005
|
||||
#define IDC_DELETEACTOR 5006
|
||||
#define IDC_MOVEACTORUP 5007
|
||||
#define IDC_MOVEACTORDOWN 5008
|
||||
#define IDC_EDITACTOR 5009
|
||||
|
||||
#define IDC_EDITEVENT 5010
|
||||
#define IDC_DELETEEVENT 5011
|
||||
|
||||
#define IDC_ADDEVENT_EXPRESSION 5012
|
||||
#define IDC_ADDEVENT_GESTURE 5013
|
||||
#define IDC_ADDEVENT_LOOKAT 5014
|
||||
#define IDC_ADDEVENT_MOVETO 5015
|
||||
#define IDC_ADDEVENT_SPEAK 5016
|
||||
#define IDC_ADDEVENT_FACE 5017
|
||||
#define IDC_ADDEVENT_FIRETRIGGER 5018
|
||||
#define IDC_ADDEVENT_SEQUENCE 5019
|
||||
#define IDC_ADDEVENT_GENERIC 5020
|
||||
|
||||
#define IDC_CV_CHANGESCALE 5021
|
||||
|
||||
#define IDC_EDITGLOBALEVENT 5022
|
||||
#define IDC_DELETEGLOBALEVENT 5023
|
||||
#define IDC_ADDEVENT_PAUSE 5024
|
||||
|
||||
|
||||
#define IDC_ADDCHANNEL 5025
|
||||
#define IDC_EDITCHANNEL 5026
|
||||
#define IDC_DELETECHANNEL 5027
|
||||
#define IDC_MOVECHANNELUP 5028
|
||||
#define IDC_MOVECHANNELDOWN 5029
|
||||
|
||||
#define IDC_CHANNELOPEN 5030
|
||||
#define IDC_CHANNELCLOSE 5031
|
||||
#define IDC_CBACTORACTIVE 5032
|
||||
#define IDC_DELETERELATIVETAG 5033
|
||||
#define IDC_ADDTIMINGTAG 5034
|
||||
|
||||
#define IDC_SELECTALL 5035
|
||||
#define IDC_DESELECTALL 5036
|
||||
#define IDC_MOVETOBACK 5037
|
||||
|
||||
#define IDC_UNDO 5038
|
||||
#define IDC_REDO 5039
|
||||
|
||||
#define IDC_EXPRESSIONTOOL 5040
|
||||
#define IDC_ASSOCIATEBSP 5041
|
||||
|
||||
#define IDC_ADDEVENT_FLEXANIMATION 5042
|
||||
|
||||
#define IDC_COPYEVENTS 5043
|
||||
#define IDC_PASTEEVENTS 5044
|
||||
|
||||
#define IDC_IMPORTEVENTS 5045
|
||||
#define IDC_EXPORTEVENTS 5046
|
||||
|
||||
#define IDC_ADDEVENT_SUBSCENE 5047
|
||||
#define IDC_PLAYSCENE_BACKWARD 5048
|
||||
|
||||
#define IDC_ASSOCIATEMODEL 5049
|
||||
#define IDC_CHOREO_PLAYBACKRATE 5050
|
||||
|
||||
#define IDC_CV_CHECKSEQLENGTHS 5051
|
||||
#define IDC_CV_PROCESSSEQUENCES 5052
|
||||
|
||||
#define IDC_GESTURETOOL 5053
|
||||
|
||||
#define IDC_ADDEVENT_LOOP 5054
|
||||
#define IDC_CV_TOGGLERAMPONLY 5055
|
||||
|
||||
#define IDC_ADDEVENT_INTERRUPT 5056
|
||||
#define IDC_ADDEVENT_STOPPOINT 5067
|
||||
|
||||
#define SCENE_ACTION_UNKNOWN 0
|
||||
#define SCENE_ACTION_CANCEL 1
|
||||
#define SCENE_ACTION_RESUME 2
|
||||
|
||||
#define SCENE_ANIMLAYER_SEQUENCE 0
|
||||
#define SCENE_ANIMLAYER_GESTURE 1
|
||||
|
||||
#define IDC_ADDEVENT_NULLGESTURE 5068
|
||||
|
||||
#define IDC_SELECTEVENTS_ALL_BEFORE 5069
|
||||
#define IDC_SELECTEVENTS_ALL_AFTER 5070
|
||||
#define IDC_SELECTEVENTS_ACTIVE_BEFORE 5071
|
||||
#define IDC_SELECTEVENTS_ACTIVE_AFTER 5072
|
||||
#define IDC_SELECTEVENTS_CHANNEL_BEFORE 5073
|
||||
#define IDC_SELECTEVENTS_CHANNEL_AFTER 5074
|
||||
|
||||
#define IDC_INSERT_TIME 5075
|
||||
#define IDC_DELETE_TIME 5076
|
||||
|
||||
#define IDC_EXPORT_VCD 5077
|
||||
#define IDC_IMPORT_VCD 5078
|
||||
|
||||
#define IDC_ADDEVENT_PERMITRESPONSES 5079
|
||||
|
||||
#define IDC_CV_CC_SHOW 5080
|
||||
#define IDC_CV_COMBINESPEAKEVENTS 5081
|
||||
#define IDC_CV_REMOVESPEAKEVENTFROMGROUP 5082
|
||||
#define IDC_CV_CHANGECLOSECAPTIONTOKEN 5083
|
||||
#define IDC_CV_TOGGLECLOSECAPTIONS 5084
|
||||
|
||||
#define IDC_CV_ALIGN_LEFT 5085
|
||||
#define IDC_CV_ALIGN_RIGHT 5086
|
||||
#define IDC_CV_SAMESIZE_SMALLEST 5087
|
||||
#define IDC_CV_SAMESIZE_LARGEST 5088
|
||||
|
||||
#define IDC_CV_ALLEVENTS_CHANNEL 5089
|
||||
#define IDC_CV_ALLEVENTS_ACTOR 5090
|
||||
|
||||
#define IDC_CV_ENABLEEVENTS 5091
|
||||
#define IDC_CV_DISABLEEVENTS 5092
|
||||
|
||||
#define IDC_ADDEVENT_CAMERA 5093
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChoreoView window
|
||||
class CChoreoScene;
|
||||
class CChoreoEvent;
|
||||
class CChoreoActor;
|
||||
class CChoreoChannel;
|
||||
|
||||
class CChoreoActorWidget;
|
||||
class CChoreoChannelWidget;
|
||||
class CChoreoEventWidget;
|
||||
class CChoreoGlobalEventWidget;
|
||||
class CChoreoWidgetDrawHelper;
|
||||
|
||||
class PhonemeEditor;
|
||||
class CExpression;
|
||||
class CExpClass;
|
||||
class StudioModel;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The main view of the choreography data for a scene
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoView : public mxWindow, public IFacePoserToolWindow, public IChoreoEventCallback
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CChoreoView( mxWindow *parent, int x, int y, int w, int h, int id );
|
||||
virtual ~CChoreoView();
|
||||
|
||||
virtual void OnModelChanged();
|
||||
|
||||
virtual void OnDelete();
|
||||
virtual bool CanClose();
|
||||
|
||||
void InvalidateTrackLookup( void );
|
||||
|
||||
// Implements IChoreoEventCallback
|
||||
virtual void StartEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
|
||||
virtual void EndEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
|
||||
virtual void ProcessEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
|
||||
virtual bool CheckEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
|
||||
|
||||
void SetChoreoFile( char const *filename );
|
||||
char const *GetChoreoFile( void ) const;
|
||||
|
||||
// Scene load/unload
|
||||
void LoadSceneFromFile( const char *filename );
|
||||
CChoreoScene *LoadScene( char const *filename );
|
||||
void UnloadScene( void );
|
||||
|
||||
// UI
|
||||
void New( void );
|
||||
void Save( void );
|
||||
void SaveAs( void );
|
||||
void Load( void );
|
||||
void LoadNext( void );
|
||||
bool Close( void );
|
||||
|
||||
// Drag/drop from expression thumbnail
|
||||
|
||||
bool CreateExpressionEvent( int mx, int my, CExpClass *cl, CExpression *exp );
|
||||
bool CreateAnimationEvent( int mx, int my, char const *animationname );
|
||||
|
||||
void SelectAll( void );
|
||||
void DeselectAll( void );
|
||||
|
||||
struct SelectionParams_t
|
||||
{
|
||||
enum
|
||||
{
|
||||
SP_CHANNEL = 0,
|
||||
SP_ACTIVE,
|
||||
SP_ALL
|
||||
};
|
||||
|
||||
float time;
|
||||
bool forward;
|
||||
int type;
|
||||
};
|
||||
|
||||
void SelectEvents( SelectionParams_t& params );
|
||||
|
||||
// Channel/actor right click menu
|
||||
void NewChannel( void );
|
||||
void DeleteChannel( CChoreoChannel *channel );
|
||||
void MoveChannelUp( CChoreoChannel *channel );
|
||||
void MoveChannelDown( CChoreoChannel *channel );
|
||||
void EditChannel( CChoreoChannel *channel );
|
||||
void AddEvent( int type, int subtype = 0, char const *defaultparameters = NULL );
|
||||
|
||||
// Actor right click menu
|
||||
void NewActor( void );
|
||||
void DeleteActor( CChoreoActor *actor );
|
||||
void MoveActorUp( CChoreoActor *actor );
|
||||
void MoveActorDown( CChoreoActor *actor );
|
||||
void EditActor( CChoreoActor *actor );
|
||||
|
||||
// Event menu
|
||||
void EditEvent( CChoreoEvent *event );
|
||||
void DeleteSelectedEvents( void );
|
||||
void EnableSelectedEvents( bool state );
|
||||
void DeleteEventRelativeTag( CChoreoEvent *event, int tagnum );
|
||||
void AddEventRelativeTag( void );
|
||||
CChoreoEventWidget *FindWidgetForEvent( CChoreoEvent *event );
|
||||
CChoreoChannelWidget *FindChannelForEvent( CChoreoEvent *event );
|
||||
|
||||
void MoveEventToBack( CChoreoEvent *event );
|
||||
void OnExpressionTool( void );
|
||||
void OnGestureTool( void );
|
||||
|
||||
// Global event ( pause ) menu
|
||||
void EditGlobalEvent( CChoreoEvent *event );
|
||||
void DeleteGlobalEvent( CChoreoEvent *event );
|
||||
void AddGlobalEvent( CChoreoEvent::EVENTTYPE type );
|
||||
|
||||
void AssociateBSP( void );
|
||||
void AssociateModel( void );
|
||||
void AssociateModelToActor( CChoreoActor *actor, int modelindex );
|
||||
|
||||
// UI Layout
|
||||
void CreateSceneWidgets( void );
|
||||
void DeleteSceneWidgets( void );
|
||||
void LayoutScene( void );
|
||||
void InvalidateLayout( void );
|
||||
void ForceScrollBarsToRecompute( bool resetthumb );
|
||||
|
||||
// Layout data that children should obey
|
||||
int GetLabelWidth( void );
|
||||
int GetStartRow( void );
|
||||
int GetRowHeight( void );
|
||||
int GetFontSize( void );
|
||||
int GetEndRow( void );
|
||||
|
||||
// Simulation
|
||||
void PlayScene( bool forward );
|
||||
void PauseScene( void );
|
||||
|
||||
bool IsPlayingScene( void );
|
||||
void ResetTargetSettings( void );
|
||||
void UpdateCurrentSettings( void );
|
||||
|
||||
virtual void Think( float dt );
|
||||
virtual bool IsScrubbing( void ) const;
|
||||
virtual bool IsProcessing( void );
|
||||
|
||||
|
||||
bool ShouldProcessSpeak( void );
|
||||
|
||||
void SceneThink( float time );
|
||||
void PauseThink( void );
|
||||
void FinishSimulation( void );
|
||||
void StopScene();
|
||||
|
||||
float GetStartTime( void );
|
||||
float GetEndTime( void );
|
||||
void SetStartTime( float time );
|
||||
|
||||
void ProcessExpression( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessFlexAnimation( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessLookat( CChoreoScene *scene, CChoreoEvent *event );
|
||||
bool GetTarget( CChoreoScene *scene, CChoreoEvent *event, Vector &vecTarget, QAngle &vecAngle );
|
||||
void ProcessFace( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessGesture( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessSequence( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessMoveto( CChoreoScene *scene, CChoreoEvent *event );
|
||||
int GetMovetoSequence( CChoreoScene *scene, CChoreoEvent *event, StudioModel *model );
|
||||
void ProcessSubscene( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessPause( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessSpeak( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessLoop( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessInterrupt( CChoreoScene *scene, CChoreoEvent *event );
|
||||
void ProcessPermitResponses( CChoreoScene *scene, CChoreoEvent *event );
|
||||
|
||||
float GetPixelsPerSecond( void );
|
||||
|
||||
// mxWindow overrides
|
||||
virtual void redraw();
|
||||
virtual bool PaintBackground( void );
|
||||
virtual int handleEvent( mxEvent *event );
|
||||
|
||||
// Draw helpers
|
||||
void DrawSceneABTicks( CChoreoWidgetDrawHelper& drawHelper );
|
||||
void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
|
||||
void DrawBackground( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
|
||||
void DrawRelativeTagLines( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
|
||||
|
||||
// Remap click position to/from time value
|
||||
float GetTimeValueForMouse( int mx, bool clip = false );
|
||||
int GetPixelForTimeValue( float time, bool *clipped = NULL );
|
||||
float GetTimeDeltaForMouseDelta( int mx, int origmx );
|
||||
|
||||
// Readjust slider
|
||||
void MoveTimeSliderToPos( int x );
|
||||
|
||||
// Dirty flag for file save prompting
|
||||
|
||||
bool GetDirty( void );
|
||||
void SetDirty( bool dirty, bool clearundo = true );
|
||||
|
||||
void ShowContextMenu( int mx, int my );
|
||||
|
||||
// Caller must first translate mouse into screen coordinates
|
||||
bool IsMouseOverTimeline( int mx, int my );
|
||||
|
||||
CChoreoActorWidget *GetActorUnderCursorPos( int mx, int my );
|
||||
CChoreoChannelWidget *GetChannelUnderCursorPos( int mx, int my );
|
||||
CChoreoEventWidget *GetEventUnderCursorPos( int mx, int my );
|
||||
CChoreoGlobalEventWidget *GetGlobalEventUnderCursorPos( int mx, int my );
|
||||
int GetTagUnderCursorPos( CChoreoEventWidget *event, int mx, int my );
|
||||
CEventAbsoluteTag *GetAbsoluteTagUnderCursorPos( CChoreoEventWidget *event, int mx, int my );
|
||||
|
||||
|
||||
void GetObjectsUnderMouse( int mx, int my,
|
||||
CChoreoActorWidget **actor,
|
||||
CChoreoChannelWidget **channel,
|
||||
CChoreoEventWidget **event,
|
||||
CChoreoGlobalEventWidget **globalevent,
|
||||
int* clickedTag,
|
||||
CEventAbsoluteTag **absolutetag,
|
||||
int *clickedCCButton );
|
||||
|
||||
void OnDoubleClicked( void );
|
||||
|
||||
void ApplyBounds( int& mx, int& my );
|
||||
void CalcBounds( int movetype );
|
||||
|
||||
void MouseStartDrag( mxEvent *event, int mx, int my );
|
||||
void MouseContinueDrag( mxEvent *event, int mx, int my );
|
||||
void MouseFinishDrag( mxEvent *event, int mx, int my );
|
||||
void MouseMove( int mx, int my );
|
||||
|
||||
//void StartDraggingGlobalEvent( int mx, int my );
|
||||
void StartDraggingEvent( int mx, int my );
|
||||
//void FinishDraggingGlobalEvent( int mx, int my );
|
||||
void FinishDraggingEvent( mxEvent *event, int mx, int my );
|
||||
|
||||
// Draw focus rect while mouse dragging is going on
|
||||
void DrawFocusRect( void );
|
||||
int ComputeEventDragType( int mx, int my );
|
||||
|
||||
void SetCurrentWaveFile( const char *filename, CChoreoEvent *event );
|
||||
|
||||
void RecomputeWaves();
|
||||
|
||||
typedef void (CChoreoView::*CVMEMBERFUNC)( CChoreoWidget *widget, CChoreoWidget *param1 );
|
||||
|
||||
void TraverseWidgets( CVMEMBERFUNC pfn, CChoreoWidget *param1 );
|
||||
|
||||
int CountSelectedEvents( void );
|
||||
int CountSelectedGlobalEvents( void );
|
||||
int GetSelectedEvents( CUtlVector< CChoreoEvent * >& events );
|
||||
int GetSelectedEventWidgets( CUtlVector< CChoreoEventWidget * >& events );
|
||||
int GetEarliestEventIndex( CUtlVector< CChoreoEventWidget * >& events );
|
||||
int GetLatestEventIndex( CUtlVector< CChoreoEventWidget * >& events );
|
||||
|
||||
// Traversal functions
|
||||
void Deselect( CChoreoWidget *widget, CChoreoWidget *param1 );
|
||||
void Select( CChoreoWidget *widget, CChoreoWidget *param1 );
|
||||
void SelectInActor( CChoreoWidget *widget, CChoreoWidget *param1 );
|
||||
void SelectInChannel( CChoreoWidget *widget, CChoreoWidget *param1 );
|
||||
|
||||
void SelectAllEvents( CChoreoWidget *widget, CChoreoWidget *param1 );
|
||||
|
||||
void SelectAllEventsInActor( CChoreoActorWidget *actor );
|
||||
void SelectAllEventsInChannel( CChoreoChannelWidget *channel );
|
||||
|
||||
// Adjust scroll bars
|
||||
void RepositionVSlider( void );
|
||||
void RepositionHSlider( void );
|
||||
|
||||
void UpdateStatusArea( int mx, int my );
|
||||
void ClearStatusArea( void );
|
||||
void RedrawStatusArea( CChoreoWidgetDrawHelper& drawHelper, RECT& rcStatus );
|
||||
|
||||
void GetUndoLevels( int& current, int& number );
|
||||
|
||||
// Undo/Redo
|
||||
void Undo( void );
|
||||
void Redo( void );
|
||||
|
||||
bool CanUndo();
|
||||
bool CanRedo();
|
||||
|
||||
// Do push before changes
|
||||
void PushUndo( const char *description );
|
||||
// Do this push after changes, must match pushundo 1for1
|
||||
void PushRedo( const char *description );
|
||||
|
||||
void WipeUndo( void );
|
||||
void WipeRedo( void );
|
||||
|
||||
const char *GetUndoDescription( void );
|
||||
const char *GetRedoDescription( void );
|
||||
|
||||
CChoreoScene *GetScene( void );
|
||||
|
||||
void ReportSceneClearToTools( void );
|
||||
|
||||
void CopyEvents( void );
|
||||
void PasteEvents( void );
|
||||
void ImportEvents( void );
|
||||
void ExportEvents( void );
|
||||
|
||||
void ExportVCD();
|
||||
void ImportVCD();
|
||||
|
||||
void ExportVCDFile( char const *filename );
|
||||
void ImportVCDFile( char const *filename );
|
||||
|
||||
bool CanPaste( void );
|
||||
|
||||
bool IsMouseOverScrubHandle( mxEvent *event );
|
||||
bool IsMouseOverScrubArea( mxEvent *event );
|
||||
|
||||
void GetScrubHandleRect( RECT& rcHandle, bool clipped = false );
|
||||
void GetScrubAreaRect( RECT& rcArea );
|
||||
void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper );
|
||||
void DrawScrubHandle( void );
|
||||
void ScrubThink( float dt, bool scrubbing, IFacePoserToolWindow *invoker );
|
||||
|
||||
void ClampTimeToSelectionInterval( float& timeval );
|
||||
|
||||
void SetScrubTime( float t );
|
||||
void SetScrubTargetTime( float t );
|
||||
|
||||
void OnCheckSequenceLengths( void );
|
||||
|
||||
bool IsRampOnly( void ) const;
|
||||
|
||||
void SetTimeZoom( const char *tool, int tz, bool preserveFocus );
|
||||
int GetTimeZoom( const char *tool );
|
||||
template< class T >
|
||||
void SetPreservedTimeZoom( T *other, int tz );
|
||||
template< class T >
|
||||
int HandleZoomKey( T *other, int keyCode );
|
||||
|
||||
void OnInsertTime();
|
||||
void OnDeleteTime();
|
||||
|
||||
bool GetShowCloseCaptionData( void ) const;
|
||||
bool ValidateCombinedSoundCheckSum( CChoreoEvent *e );
|
||||
|
||||
void OnPlaceNextSpeakEvent();
|
||||
void SetScrubUnitSeconds( bool bUseSeconds);
|
||||
|
||||
private:
|
||||
|
||||
void CheckInsertTime( CChoreoEvent *e, float dt, float starttime, float endtime );
|
||||
void CheckDeleteTime( CChoreoEvent *d, float dt, float starttime, float endtime, bool& deleteEvent );
|
||||
|
||||
bool FixupSequenceDurations( CChoreoScene *scene, bool checkonly );
|
||||
bool CheckSequenceLength( CChoreoEvent *e, bool checkonly );
|
||||
bool CheckGestureLength( CChoreoEvent *e, bool checkonly );
|
||||
bool DefaultGestureLength( CChoreoEvent *e, bool checkonly );
|
||||
bool AutoaddGestureKeys( CChoreoEvent *e, bool checkonly );
|
||||
|
||||
void InvalidateTrackLookup_R( CChoreoScene *scene );
|
||||
|
||||
void ShowButtons( bool show );
|
||||
|
||||
// Compute full size of data in pixels, for setting up scroll bars
|
||||
int ComputeVPixelsNeeded( void );
|
||||
int ComputeHPixelsNeeded( void );
|
||||
void PositionControls();
|
||||
|
||||
void OnChangeScale();
|
||||
|
||||
float FindNextEventTime( CChoreoEvent::EVENTTYPE type, CChoreoChannel *channel, CChoreoEvent *e, bool forward );
|
||||
|
||||
bool ShouldSelectEvent( SelectionParams_t ¶ms, CChoreoEvent *event );
|
||||
|
||||
bool IsMouseOverSceneEndTime( int mx );
|
||||
|
||||
void StartDraggingSceneEndTime( int mx, int my );
|
||||
void FinishDraggingSceneEndTime( mxEvent *event, int mx, int my );
|
||||
|
||||
void SetShowCloseCaptionData( bool show );
|
||||
|
||||
void OnToggleCloseCaptionTags();
|
||||
void OnCombineSpeakEvents();
|
||||
void OnRemoveSpeakEventFromGroup();
|
||||
void OnChangeCloseCaptionToken( CChoreoEvent *e );
|
||||
|
||||
bool AreSelectedEventsCombinable();
|
||||
bool AreSelectedEventsInSpeakGroup();
|
||||
|
||||
void OnToggleCloseCaptionsForEvent();
|
||||
|
||||
bool GenerateCombinedFile( char const *outfilename, const char *cctoken, gender_t gender, CUtlRBTree< CChoreoEvent * >& sorted );
|
||||
bool ValidateCombinedFileCheckSum( char const *outfilename, char const *cctoken, gender_t gender, CUtlRBTree< CChoreoEvent * >& sorted );
|
||||
|
||||
void RememberSelectedEvents( CUtlVector< CChoreoEvent * >& list );
|
||||
void ReselectEvents( CUtlVector< CChoreoEvent * >& list );
|
||||
|
||||
void OnAlign( bool left );
|
||||
void OnMakeSameSize( bool smallest );
|
||||
|
||||
bool IsMouseOverEventEdge( CChoreoEventWidget *ew, bool bLeftEdge, int mx, int my );
|
||||
bool IsMouseOverEvent( CChoreoEventWidget *ew, int mx, int my );
|
||||
typedef struct
|
||||
{
|
||||
bool active;
|
||||
float time;
|
||||
} SCENEAB;
|
||||
|
||||
void PlaceABPoint( int mx );
|
||||
void ClearABPoints( void );
|
||||
|
||||
SCENEAB m_rgABPoints[ 2 ];
|
||||
int m_nCurrentABPoint;
|
||||
|
||||
bool m_bForward;
|
||||
|
||||
// The underlying scene we are editing
|
||||
CChoreoScene *m_pScene;
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_ACTORS = 32
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool expanded;
|
||||
} ACTORSTATE;
|
||||
|
||||
ACTORSTATE m_ActorExpanded[ MAX_ACTORS ];
|
||||
// The scene's ui actors
|
||||
CUtlVector < CChoreoActorWidget * > m_SceneActors;
|
||||
// The scenes segment markers
|
||||
CUtlVector < CChoreoGlobalEventWidget * > m_SceneGlobalEvents;
|
||||
|
||||
// How many pixels per second we are showing in the UI
|
||||
float m_flPixelsPerSecond;
|
||||
|
||||
// Do we need to move controls?
|
||||
bool m_bLayoutIsValid;
|
||||
|
||||
// Starting row of first actor
|
||||
int m_nStartRow;
|
||||
// How wide the actor/channel name area is
|
||||
int m_nLabelWidth;
|
||||
// Height between channel/actor names
|
||||
int m_nRowHeight;
|
||||
// Font size for drawing event labels
|
||||
int m_nFontSize;
|
||||
|
||||
// Height/width of scroll bars
|
||||
int m_nScrollbarHeight;
|
||||
// Height off info area for flyover info / help
|
||||
int m_nInfoHeight;
|
||||
|
||||
// Simulation info
|
||||
float m_flStartTime;
|
||||
float m_flEndTime;
|
||||
|
||||
float m_flFrameTime;
|
||||
bool m_bSimulating;
|
||||
bool m_bPaused;
|
||||
float m_flLastSpeedScale;
|
||||
bool m_bResetSpeedScale;
|
||||
bool m_bAutomated;
|
||||
int m_nAutomatedAction;
|
||||
float m_flAutomationDelay;
|
||||
float m_flAutomationTime;
|
||||
|
||||
// Some rectangles for the UI
|
||||
RECT m_rcTitles;
|
||||
RECT m_rcTimeLine;
|
||||
|
||||
// Play/pause buttons for simulation
|
||||
mxBitmapButton *m_btnPlay;
|
||||
mxBitmapButton *m_btnPause;
|
||||
mxBitmapButton *m_btnStop;
|
||||
|
||||
mxSlider *m_pPlaybackRate;
|
||||
float m_flPlaybackRate;
|
||||
|
||||
// The scroll bars
|
||||
mxScrollbar *m_pVertScrollBar;
|
||||
mxScrollbar *m_pHorzScrollBar;
|
||||
int m_nLastHPixelsNeeded;
|
||||
int m_nLastVPixelsNeeded;
|
||||
|
||||
// Current sb values
|
||||
int m_nTopOffset;
|
||||
float m_flLeftOffset;
|
||||
|
||||
// Need save?
|
||||
bool m_bDirty;
|
||||
// Currently loaded scene file
|
||||
char m_szChoreoFile[ 256 ];
|
||||
|
||||
CChoreoActorWidget *m_pClickedActor;
|
||||
CChoreoChannelWidget *m_pClickedChannel;
|
||||
CChoreoEventWidget *m_pClickedEvent;
|
||||
CChoreoGlobalEventWidget *m_pClickedGlobalEvent;
|
||||
// Relative to the clicked event
|
||||
int m_nClickedTag;
|
||||
CEventAbsoluteTag *m_pClickedAbsoluteTag;
|
||||
int m_nSelectedEvents;
|
||||
int m_nClickedX, m_nClickedY;
|
||||
int m_nClickedChannelCloseCaptionButton;
|
||||
|
||||
// For mouse dragging
|
||||
// How close to right or left edge the mouse has to be before the wider/shorten
|
||||
// cursor shows up
|
||||
enum
|
||||
{
|
||||
DRAG_EVENT_EDGE_TOLERANCE = 5,
|
||||
};
|
||||
|
||||
// When dragging, what time of action is being performed
|
||||
enum
|
||||
{
|
||||
DRAGTYPE_NONE = 0,
|
||||
DRAGTYPE_EVENT_MOVE,
|
||||
DRAGTYPE_EVENT_STARTTIME,
|
||||
DRAGTYPE_EVENT_STARTTIME_RESCALE,
|
||||
DRAGTYPE_EVENT_ENDTIME,
|
||||
DRAGTYPE_EVENT_ENDTIME_RESCALE,
|
||||
DRAGTYPE_EVENTTAG_MOVE,
|
||||
DRAGTYPE_EVENTABSTAG_MOVE,
|
||||
DRAGTYPE_SCRUBBER,
|
||||
DRAGTYPE_SCENE_ENDTIME,
|
||||
DRAGTYPE_RESCALELEFT,
|
||||
DRAGTYPE_RESCALERIGHT,
|
||||
};
|
||||
|
||||
float m_flScrub;
|
||||
int m_bScrubSeconds;
|
||||
float m_flScrubTarget;
|
||||
|
||||
bool m_bDragging;
|
||||
int m_xStart;
|
||||
int m_yStart;
|
||||
|
||||
bool m_bUseBounds;
|
||||
int m_nMinX;
|
||||
int m_nMaxX;
|
||||
|
||||
struct CFocusRect
|
||||
{
|
||||
RECT m_rcOrig;
|
||||
RECT m_rcFocus;
|
||||
};
|
||||
CUtlVector < CFocusRect > m_FocusRects;
|
||||
|
||||
int m_nDragType;
|
||||
HCURSOR m_hPrevCursor;
|
||||
|
||||
struct FLYOVER
|
||||
{
|
||||
CChoreoActorWidget *a;
|
||||
CChoreoChannelWidget *c;
|
||||
CChoreoEventWidget *e;
|
||||
CChoreoGlobalEventWidget *ge;
|
||||
int tag;
|
||||
CEventAbsoluteTag *at;
|
||||
int ccbutton;
|
||||
};
|
||||
|
||||
FLYOVER m_Flyover;
|
||||
|
||||
bool m_bCanDraw;
|
||||
|
||||
struct CVUndo
|
||||
{
|
||||
CChoreoScene *undo;
|
||||
CChoreoScene *redo;
|
||||
char *udescription;
|
||||
char *rdescription;
|
||||
};
|
||||
|
||||
CUtlVector< CVUndo * > m_UndoStack;
|
||||
int m_nUndoLevel;
|
||||
bool m_bRedoPending;
|
||||
|
||||
bool m_bProcessSequences;
|
||||
|
||||
float m_flLastMouseClickTime;
|
||||
|
||||
bool m_bSuppressLayout;
|
||||
|
||||
bool m_bRampOnly;
|
||||
float m_flScrubberTimeOffset;
|
||||
|
||||
bool m_bShowCloseCaptionData;
|
||||
|
||||
bool m_bForceProcess;
|
||||
|
||||
// cached version of the local directory when a scene is loaded
|
||||
CUtlVector< CUtlString > m_nextFileList;
|
||||
};
|
||||
|
||||
extern CChoreoView *g_pChoreoView;
|
||||
|
||||
template< class T >
|
||||
void CChoreoView::SetPreservedTimeZoom( T *other, int tz )
|
||||
{
|
||||
POINT pt;
|
||||
::GetCursorPos( &pt );
|
||||
::ScreenToClient( (HWND)other->getHandle(), &pt );
|
||||
|
||||
// Now figure out time under cursor at old zoom scale
|
||||
float t = other->GetTimeValueForMouse( pt.x, true );
|
||||
|
||||
// Call CChoreoView's version
|
||||
SetTimeZoom( other->GetToolName(), tz, false );
|
||||
|
||||
// Now figure out tie under pt.x
|
||||
float newT = other->GetTimeValueForMouse( pt.x, true );
|
||||
if ( newT != t )
|
||||
{
|
||||
// We need to scroll over a bit
|
||||
float pps = other->GetPixelsPerSecond();
|
||||
float movePixels = pps * ( newT - t );
|
||||
|
||||
float newOffset = other->m_flLeftOffset - movePixels;
|
||||
if ( newOffset < 0.0f )
|
||||
{
|
||||
newOffset = 0;
|
||||
}
|
||||
|
||||
float ed = other->GetEventEndTime();
|
||||
float flLastPixel = ed * pps;
|
||||
if ( newOffset + other->w2() > flLastPixel )
|
||||
{
|
||||
newOffset = flLastPixel - other->w2();
|
||||
}
|
||||
|
||||
other->m_flLeftOffset = newOffset;
|
||||
other->m_pHorzScrollBar->setValue( (int)( other->m_flLeftOffset ) );
|
||||
}
|
||||
|
||||
other->RepositionHSlider();
|
||||
}
|
||||
|
||||
template< class T >
|
||||
int CChoreoView::HandleZoomKey( T *other, int keyCode )
|
||||
{
|
||||
int iret = 1;
|
||||
switch ( keyCode )
|
||||
{
|
||||
default:
|
||||
{
|
||||
iret = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_HOME:
|
||||
{
|
||||
other->MoveTimeSliderToPos( 0 );
|
||||
}
|
||||
break;
|
||||
case VK_END:
|
||||
{
|
||||
float maxtime = other->GetEventEndTime();
|
||||
int pixels = max( 0, (int)( maxtime * other->GetPixelsPerSecond() ) - other->w2() );
|
||||
other->MoveTimeSliderToPos( pixels );
|
||||
}
|
||||
break;
|
||||
case VK_PRIOR: // PgUp
|
||||
{
|
||||
int window = other->w2();
|
||||
other->m_flLeftOffset = max( other->m_flLeftOffset - (float)window, 0.0f );
|
||||
other->MoveTimeSliderToPos( (int)other->m_flLeftOffset );
|
||||
}
|
||||
break;
|
||||
case VK_NEXT: // PgDown
|
||||
{
|
||||
int window = other->w2();
|
||||
float maxtime = other->GetEventEndTime();
|
||||
int pixels = max( 0, (int)( maxtime * other->GetPixelsPerSecond() ) - other->w2() );
|
||||
other->m_flLeftOffset = min( other->m_flLeftOffset + (float)window, (float)pixels );
|
||||
other->MoveTimeSliderToPos( (int)other->m_flLeftOffset );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
|
||||
float SnapTime( float input, float granularity );
|
||||
|
||||
class StudioModel;
|
||||
StudioModel *FindAssociatedModel( CChoreoScene *scene, CChoreoActor *a );
|
||||
|
||||
#endif // CHOREOVIEW_H
|
||||
50
utils/hlfaceposer/choreoviewcolors.h
Normal file
50
utils/hlfaceposer/choreoviewcolors.h
Normal file
@@ -0,0 +1,50 @@
|
||||
//========= Copyright Š 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHOREOVIEWCOLORS_H
|
||||
#define CHOREOVIEWCOLORS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Defines colors for choreo view
|
||||
#define COLOR_CHOREO_BACKGROUND Color( 240, 240, 220 )
|
||||
#define COLOR_CHOREO_DARKBACKGROUND Color( 230, 230, 200 )
|
||||
#define COLOR_CHOREO_TEXT Color( 0, 0, 0 )
|
||||
#define COLOR_CHOREO_LIGHTTEXT Color( 180, 180, 120 )
|
||||
|
||||
#define COLOR_CHOREO_EVENT Color( 250, 100, 100 )
|
||||
#define COLOR_CHOREO_EVENT_TRIGGERED Color( 32, 130, 150 )
|
||||
#define COLOR_CHOREO_EVENT_SELECTED Color( 220, 150, 150 )
|
||||
|
||||
#define COLOR_CHOREO_DIVIDER Color( 63, 63, 63 )
|
||||
#define COLOR_CHOREO_ACTORNAME Color( 80, 150, 150 )
|
||||
#define COLOR_CHOREO_ACTORNAME_INACTIVE Color( 150, 150, 150 )
|
||||
#define COLOR_CHOREO_ACTORLINE Color( 200, 200, 175 )
|
||||
#define COLOR_CHOREO_CHANNELNAME Color( 150, 150, 100 )
|
||||
#define COLOR_CHOREO_CHANNELLINE Color( 63, 63, 31 )
|
||||
#define COLOR_CHOREO_SEGMENTDIVIDER Color( 63, 120, 255 )
|
||||
#define COLOR_CHOREO_SEGMENTDIVIDER_BG Color( 170, 190, 230 )
|
||||
|
||||
#define COLOR_CHOREO_LOOPPOINT Color( 255, 120, 255 )
|
||||
#define COLOR_CHOREO_LOOPPOINT_BG Color( 255, 100, 150 )
|
||||
#define COLOR_CHOREO_LOOPPOINT_START_BG Color( 255, 150, 150 )
|
||||
|
||||
#define COLOR_CHOREO_STOPPOINT Color( 255, 31, 31 )
|
||||
#define COLOR_CHOREO_STOPPOINT_BG Color( 255, 0, 0 )
|
||||
|
||||
#define COLOR_CHOREO_PLAYBACKTICK Color( 180, 31, 31 )
|
||||
#define COLOR_CHOREO_TIMELINE Color( 31, 31, 127 )
|
||||
#define COLOR_CHOREO_ENDTIME Color( 0, 0, 255 )
|
||||
#define COLOR_CHOREO_PLAYBACKTICKTEXT Color( 127, 0, 0 )
|
||||
#define COLOR_CHOREO_TICKAB Color( 31, 120, 31 )
|
||||
|
||||
#define COLOR_INFO_BACKGROUND Color( 240, 240, 240 )
|
||||
#define COLOR_INFO_TEXT Color( 63, 31, 0 )
|
||||
#define COLOR_INFO_BORDER Color( 100, 100, 250 )
|
||||
|
||||
#endif // CHOREOVIEWCOLORS_H
|
||||
149
utils/hlfaceposer/choreowidget.cpp
Normal file
149
utils/hlfaceposer/choreowidget.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <stdio.h>
|
||||
#include "choreowidget.h"
|
||||
#include "choreoview.h"
|
||||
|
||||
// Static elements
|
||||
CChoreoScene *CChoreoWidget::m_pScene = NULL;
|
||||
CChoreoView *CChoreoWidget::m_pView = NULL;
|
||||
|
||||
static int widgets = 0;
|
||||
//-----------------------------------------------------------------------------
|
||||
// CChoreoWidget new/delete
|
||||
// All fields in the object are all initialized to 0.
|
||||
//-----------------------------------------------------------------------------
|
||||
void *CChoreoWidget::operator new( size_t stAllocateBlock )
|
||||
{
|
||||
widgets++;
|
||||
// call into engine to get memory
|
||||
Assert( stAllocateBlock != 0 );
|
||||
return calloc( 1, stAllocateBlock );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *pMem -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoWidget::operator delete( void *pMem )
|
||||
{
|
||||
widgets--;
|
||||
// set the memory to a known value
|
||||
int size = _msize( pMem );
|
||||
memset( pMem, 0xfe, size );
|
||||
|
||||
// get the engine to free the memory
|
||||
free( pMem );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Construct widget, all widgets clip their children and brethren
|
||||
// Input : *parent -
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoWidget::CChoreoWidget( CChoreoWidget *parent )
|
||||
{
|
||||
m_bSelected = false;
|
||||
m_pParent = parent;
|
||||
m_bVisible = true;
|
||||
|
||||
m_rcBounds.left = m_rcBounds.right = m_rcBounds.top = m_rcBounds.bottom = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CChoreoWidget::~CChoreoWidget( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Default implementation, just return base row height
|
||||
//-----------------------------------------------------------------------------
|
||||
int CChoreoWidget::GetItemHeight( void )
|
||||
{
|
||||
return m_pView->GetRowHeight();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : mx -
|
||||
// my -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoWidget::LocalToScreen( int& mx, int& my )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CChoreoWidget::IsSelected( void )
|
||||
{
|
||||
return m_bSelected;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : selected -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChoreoWidget::SetSelected( bool selected )
|
||||
{
|
||||
m_bSelected = selected;
|
||||
}
|
||||
|
||||
void CChoreoWidget::setBounds( int x, int y, int w, int h )
|
||||
{
|
||||
m_rcBounds.left = x;
|
||||
m_rcBounds.right = x + w;
|
||||
m_rcBounds.top = y;
|
||||
m_rcBounds.bottom = y + h;
|
||||
}
|
||||
|
||||
int CChoreoWidget::x( void )
|
||||
{
|
||||
return m_rcBounds.left;
|
||||
}
|
||||
|
||||
int CChoreoWidget::y( void )
|
||||
{
|
||||
return m_rcBounds.top;
|
||||
}
|
||||
|
||||
int CChoreoWidget::w( void )
|
||||
{
|
||||
return m_rcBounds.right - m_rcBounds.left;
|
||||
}
|
||||
|
||||
int CChoreoWidget::h( void )
|
||||
{
|
||||
return m_rcBounds.bottom - m_rcBounds.top;
|
||||
}
|
||||
|
||||
CChoreoWidget *CChoreoWidget::getParent( void )
|
||||
{
|
||||
return m_pParent;
|
||||
}
|
||||
|
||||
void CChoreoWidget::setVisible( bool visible )
|
||||
{
|
||||
m_bVisible = visible;
|
||||
}
|
||||
|
||||
bool CChoreoWidget::getVisible( void )
|
||||
{
|
||||
return m_bVisible;
|
||||
}
|
||||
|
||||
void CChoreoWidget::getBounds( RECT& bounds )
|
||||
{
|
||||
bounds = m_rcBounds;
|
||||
}
|
||||
|
||||
RECT &CChoreoWidget::getBounds( void )
|
||||
{
|
||||
return m_rcBounds;
|
||||
}
|
||||
79
utils/hlfaceposer/choreowidget.h
Normal file
79
utils/hlfaceposer/choreowidget.h
Normal file
@@ -0,0 +1,79 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#ifndef CHOREOWIDGET_H
|
||||
#define CHOREOWIDGET_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
|
||||
class CChoreoView;
|
||||
class CChoreoScene;
|
||||
class CChoreoWidgetDrawHelper;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: CChoreoWidgets are mxWindows that we show in the Choreography view area
|
||||
// so that we can manipulate them with the mouse. The widgets follow the scene
|
||||
// hierarchy of actors/channels/events, without having to hang off of the underlying
|
||||
// data. They are just for the UI.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoWidget
|
||||
{
|
||||
public:
|
||||
// memory handling, uses calloc so members are zero'd out on instantiation
|
||||
void *operator new( size_t stAllocateBlock );
|
||||
void operator delete( void *pMem );
|
||||
|
||||
CChoreoWidget( CChoreoWidget *parent );
|
||||
virtual ~CChoreoWidget( void );
|
||||
|
||||
// All widgets implement these pure virtuals
|
||||
|
||||
// Called to force a widget to create its children based on the scene data
|
||||
virtual void Create( void ) = 0;
|
||||
// Force widget to redo layout of self and any children
|
||||
virtual void Layout( RECT& rc ) = 0;
|
||||
// Redraw the widget
|
||||
virtual void redraw( CChoreoWidgetDrawHelper& drawHelper ) = 0;
|
||||
// Don't overdraw background
|
||||
virtual bool PaintBackground( void ) { return false; };
|
||||
// Determine height to reserver for widget ( Actors can be expanded or collapsed, e.g. )
|
||||
virtual int GetItemHeight( void );
|
||||
|
||||
virtual void LocalToScreen( int& mx, int& my );
|
||||
|
||||
virtual bool IsSelected( void );
|
||||
virtual void SetSelected( bool selected );
|
||||
|
||||
virtual void setBounds( int x, int y, int w, int h );
|
||||
virtual int x( void );
|
||||
virtual int y( void );
|
||||
virtual int w( void );
|
||||
virtual int h( void );
|
||||
virtual CChoreoWidget *getParent( void );
|
||||
virtual void setVisible( bool visible );
|
||||
virtual bool getVisible( void );
|
||||
|
||||
virtual void getBounds( RECT& bounds );
|
||||
virtual RECT &getBounds( void );
|
||||
|
||||
// Globally accessible scene and view pointers
|
||||
static CChoreoScene *m_pScene;
|
||||
static CChoreoView *m_pView;
|
||||
|
||||
private:
|
||||
bool m_bSelected;
|
||||
bool m_bVisible;
|
||||
|
||||
RECT m_rcBounds;
|
||||
|
||||
protected:
|
||||
CChoreoWidget *m_pParent;
|
||||
};
|
||||
|
||||
#endif // CHOREOWIDGET_H
|
||||
1073
utils/hlfaceposer/choreowidgetdrawhelper.cpp
Normal file
1073
utils/hlfaceposer/choreowidgetdrawhelper.cpp
Normal file
File diff suppressed because it is too large
Load Diff
123
utils/hlfaceposer/choreowidgetdrawhelper.h
Normal file
123
utils/hlfaceposer/choreowidgetdrawhelper.h
Normal file
@@ -0,0 +1,123 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHOREOWIDGETDRAWHELPER_H
|
||||
#define CHOREOWIDGETDRAWHELPER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "choreowidget.h"
|
||||
#include "utlvector.h"
|
||||
#include "color.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Helper class that automagically sets up and destroys a memory device-
|
||||
// context for flicker-free refershes
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChoreoWidgetDrawHelper
|
||||
{
|
||||
public:
|
||||
// Construction/destruction
|
||||
CChoreoWidgetDrawHelper( mxWindow *widget);
|
||||
CChoreoWidgetDrawHelper( mxWindow *widget, const Color& bgColor );
|
||||
CChoreoWidgetDrawHelper( mxWindow *widget, int x, int y, int w, int h, const Color& bgColor );
|
||||
CChoreoWidgetDrawHelper( mxWindow *widget, RECT& bounds );
|
||||
CChoreoWidgetDrawHelper( mxWindow *widget, RECT& bounds, const Color& bgColor );
|
||||
|
||||
CChoreoWidgetDrawHelper( mxWindow *widget, RECT& bounds, bool noPageFlip );
|
||||
|
||||
virtual ~CChoreoWidgetDrawHelper( void );
|
||||
|
||||
// Allow caller to draw onto the memory dc, too
|
||||
HDC GrabDC( void );
|
||||
|
||||
// Compute text size
|
||||
static int CalcTextWidth( const char *font, int pointsize, int weight, const char *fmt, ... );
|
||||
static int CalcTextWidth( HFONT font, const char *fmt, ... );
|
||||
|
||||
static int CalcTextWidthW( const char *font, int pointsize, int weight, const wchar_t *fmt, ... );
|
||||
static int CalcTextWidthW( HFONT font, const wchar_t *fmt, ... );
|
||||
|
||||
void DrawColoredTextW( const char *font, int pointsize, int weight, const Color& clr, RECT& rcText, const wchar_t *fmt, ... );
|
||||
void DrawColoredTextW( HFONT font, const Color& clr, RECT& rcText, const wchar_t *fmt, ... );
|
||||
void DrawColoredTextCharsetW( const char *font, int pointsize, int weight, DWORD charset, const Color& clr, RECT& rcText, const wchar_t *fmt, ... );
|
||||
|
||||
void CalcTextRect( const char *font, int pointsize, int weight, int maxwidth, RECT& rcText, const char *fmt, ... );
|
||||
|
||||
// Draw text
|
||||
void DrawColoredText( const char *font, int pointsize, int weight, const Color& clr, RECT& rcText, const char *fmt, ... );
|
||||
void DrawColoredText( HFONT font, const Color& clr, RECT& rcText, const char *fmt, ... );
|
||||
void DrawColoredTextCharset( const char *font, int pointsize, int weight, DWORD charset, const Color& clr, RECT& rcText, const char *fmt, ... );
|
||||
void DrawColoredTextMultiline( const char *font, int pointsize, int weight, const Color& clr, RECT& rcText, const char *fmt, ... );
|
||||
// Draw a line
|
||||
void DrawColoredLine( const Color& clr, int style, int width, int x1, int y1, int x2, int y2 );
|
||||
void DrawColoredPolyLine( const Color& clr, int style, int width, CUtlVector< POINT >& points );
|
||||
|
||||
// Draw a blending ramp
|
||||
POINTL DrawColoredRamp( const Color& clr, int style, int width, int x1, int y1, int x2, int y2, float rate, float sustain );
|
||||
// Draw a filled rect
|
||||
void DrawFilledRect( const Color& clr, int x1, int y1, int x2, int y2 );
|
||||
// Draw an outlined rect
|
||||
void DrawOutlinedRect( const Color& clr, int style, int width, int x1, int y1, int x2, int y2 );
|
||||
void DrawOutlinedRect( const Color& clr, int style, int width, RECT& rc );
|
||||
|
||||
void DrawFilledRect( HBRUSH br, RECT& rc );
|
||||
void DrawFilledRect( const Color& clr, RECT& rc );
|
||||
|
||||
void DrawGradientFilledRect( RECT& rc, const Color& clr1, const Color& clr2, bool vertical );
|
||||
|
||||
void DrawLine( int x1, int y1, int x2, int y2, const Color& clr, int thickness );
|
||||
|
||||
// Draw a triangle
|
||||
void DrawTriangleMarker( RECT& rc, const Color& fill, bool inverted = false );
|
||||
|
||||
void DrawCircle( const Color& clr, int x, int y, int radius, bool filled = true );
|
||||
|
||||
// Get width/height of draw area
|
||||
int GetWidth( void );
|
||||
int GetHeight( void );
|
||||
|
||||
// Get client rect for drawing
|
||||
void GetClientRect( RECT& rc );
|
||||
|
||||
void StartClipping( RECT& clipRect );
|
||||
void StopClipping( void );
|
||||
|
||||
// Remap rect if we're using a clipped viewport
|
||||
void OffsetSubRect( RECT& rc );
|
||||
|
||||
private:
|
||||
// Internal initializer
|
||||
void Init( mxWindow *widget, int x, int y, int w, int h, const Color& bgColor, bool noPageFlip );
|
||||
|
||||
void ClipToRects( void );
|
||||
|
||||
// The window we are drawing on
|
||||
HWND m_hWnd;
|
||||
// The final DC
|
||||
HDC m_dcReal;
|
||||
// The working DC
|
||||
HDC m_dcMemory;
|
||||
// Client area and offsets
|
||||
RECT m_rcClient;
|
||||
int m_x, m_y;
|
||||
int m_w, m_h;
|
||||
// Bitmap for drawing in the memory DC
|
||||
HBITMAP m_bmMemory;
|
||||
HBITMAP m_bmOld;
|
||||
// Remember the original default color
|
||||
Color m_clrOld;
|
||||
|
||||
CUtlVector < RECT > m_ClipRects;
|
||||
HRGN m_ClipRegion;
|
||||
|
||||
bool m_bNoPageFlip;
|
||||
};
|
||||
|
||||
#endif // CHOREOWIDGETDRAWHELPER_H
|
||||
976
utils/hlfaceposer/controlpanel.cpp
Normal file
976
utils/hlfaceposer/controlpanel.cpp
Normal file
@@ -0,0 +1,976 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "ControlPanel.h"
|
||||
#include "ViewerSettings.h"
|
||||
#include "StudioModel.h"
|
||||
#include "IStudioRender.h"
|
||||
#include "MatSysWin.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mxtk/mx.h>
|
||||
#include <mxtk/mxBmp.h>
|
||||
#include "FlexPanel.h"
|
||||
#include "mxExpressionTray.h"
|
||||
#include "PhonemeEditor.h"
|
||||
#include "hlfaceposer.h"
|
||||
#include "expclass.h"
|
||||
#include "mxExpressionTab.h"
|
||||
#include "ExpressionTool.h"
|
||||
#include "MDLViewer.h"
|
||||
#include "choreowidgetdrawhelper.h"
|
||||
#include "faceposer_models.h"
|
||||
#include "ifaceposerworkspace.h"
|
||||
#include "choreoview.h"
|
||||
#include "GestureTool.h"
|
||||
#include "RampTool.h"
|
||||
#include "SceneRampTool.h"
|
||||
#include "phonemeextractor/PhonemeExtractor.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
extern char g_appTitle[];
|
||||
|
||||
ControlPanel *g_pControlPanel = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: A simple subclass so we can paint the window background
|
||||
//-----------------------------------------------------------------------------
|
||||
class CControlPanelTabWindow : public mxWindow
|
||||
{
|
||||
public:
|
||||
CControlPanelTabWindow( mxWindow *parent, int x, int y, int w, int h ) :
|
||||
mxWindow( parent, x, y, w, h )
|
||||
{
|
||||
FacePoser_AddWindowStyle( this, WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
|
||||
};
|
||||
|
||||
virtual bool PaintBackground( void )
|
||||
{
|
||||
CChoreoWidgetDrawHelper drawHelper( this );
|
||||
|
||||
RECT rc;
|
||||
drawHelper.GetClientRect( rc );
|
||||
|
||||
drawHelper.DrawFilledRect( RGBToColor( GetSysColor( COLOR_BTNFACE ) ), rc );
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
ControlPanel::ControlPanel (mxWindow *parent)
|
||||
: IFacePoserToolWindow( "ControlPanel", "Control Panel" ), mxWindow( parent, 0, 0, 0, 0 ), tab( 0 )
|
||||
{
|
||||
// create tabcontrol with subdialog windows
|
||||
tab = new mxTab (this, 0, 0, 0, 0, IDC_TAB);
|
||||
|
||||
CControlPanelTabWindow *wRender = new CControlPanelTabWindow (this, 0, 0, 0, 0);
|
||||
tab->add (wRender, "Render");
|
||||
cRenderMode = new mxChoice (wRender, 5, 5, 100, 22, IDC_RENDERMODE);
|
||||
cRenderMode->add ("Wireframe");
|
||||
cRenderMode->add ("Flatshaded");
|
||||
cRenderMode->add ("Smoothshaded");
|
||||
cRenderMode->add ("Textured");
|
||||
cRenderMode->select (3);
|
||||
mxToolTip::add (cRenderMode, "Select Render Mode");
|
||||
|
||||
slModelGap = new mxSlider( wRender, 220, 5, 140, 20, IDC_MODELSPACING );
|
||||
slModelGap->setRange( 0.0f, 64.0f, 256 );
|
||||
slModelGap->setValue( 16 );
|
||||
mxToolTip::add (slModelGap, "Select Model Spacing" );
|
||||
new mxLabel (wRender, 220, 25, 140, 20, "Model Spacing");
|
||||
|
||||
cbAllWindowsDriveSpeech = new mxCheckBox( wRender, 220, 45, 140, 20, "All tools drive mouth", IDC_TOOLSDRIVEMOUTH );
|
||||
cbAllWindowsDriveSpeech->setChecked( g_viewerSettings.faceposerToolsDriveMouth );
|
||||
|
||||
cbGround = new mxCheckBox (wRender, 110, 5, 100, 20, "Ground", IDC_GROUND);
|
||||
cbGround->setEnabled( true );
|
||||
cbMovement = new mxCheckBox (wRender, 110, 25, 100, 20, "Movement", IDC_MOVEMENT);
|
||||
cbMovement->setEnabled( false );
|
||||
cbBackground = new mxCheckBox (wRender, 110, 45, 100, 20, "Background", IDC_BACKGROUND);
|
||||
cbBackground->setEnabled( false );
|
||||
new mxCheckBox (wRender, 110, 65, 100, 20, "Hit Boxes", IDC_HITBOXES);
|
||||
new mxCheckBox (wRender, 5, 65, 100, 20, "Bones", IDC_BONES);
|
||||
mxCheckBox *cbAttachments = new mxCheckBox (wRender, 5, 45, 100, 20, "Attachments", IDC_ATTACHMENTS);
|
||||
cbAttachments->setEnabled( false );
|
||||
|
||||
CControlPanelTabWindow *wSequence = new CControlPanelTabWindow (this, 0, 0, 0, 0);
|
||||
tab->add (wSequence, "Sequence");
|
||||
cSequence = new mxChoice (wSequence, 5, 5, 200, 22, IDC_SEQUENCE);
|
||||
mxToolTip::add (cSequence, "Select Sequence");
|
||||
|
||||
|
||||
slSpeedScale = new mxSlider (wSequence, 5, 32, 200, 18, IDC_SPEEDSCALE);
|
||||
slSpeedScale->setRange (0.0, 5.0 );
|
||||
slSpeedScale->setValue (0.0);
|
||||
mxToolTip::add (slSpeedScale, "Speed Scale");
|
||||
lSpeedScale = new mxLabel( wSequence, 5, 50, 200, 18 );
|
||||
lSpeedScale->setLabel( "Speed scale" );
|
||||
|
||||
CControlPanelTabWindow *wBody = new CControlPanelTabWindow (this, 0, 0, 0, 0);
|
||||
tab->add (wBody, "Body");
|
||||
cBodypart = new mxChoice (wBody, 5, 5, 100, 22, IDC_BODYPART);
|
||||
mxToolTip::add (cBodypart, "Choose a bodypart");
|
||||
cSubmodel = new mxChoice (wBody, 110, 5, 100, 22, IDC_SUBMODEL);
|
||||
mxToolTip::add (cSubmodel, "Choose a submodel of current bodypart");
|
||||
cController = new mxChoice (wBody, 5, 30, 100, 22, IDC_CONTROLLER);
|
||||
mxToolTip::add (cController, "Choose a bone controller");
|
||||
slController = new mxSlider (wBody, 105, 32, 100, 18, IDC_CONTROLLERVALUE);
|
||||
slController->setRange (0, 45);
|
||||
mxToolTip::add (slController, "Change current bone controller value");
|
||||
lModelInfo1 = new mxLabel (wBody, 220, 5, 120, 100, "No Model.");
|
||||
lModelInfo2 = new mxLabel (wBody, 340, 5, 120, 100, "");
|
||||
cSkin = new mxChoice (wBody, 5, 55, 100, 22, IDC_SKINS);
|
||||
mxToolTip::add (cSkin, "Choose a skin family");
|
||||
}
|
||||
|
||||
ControlPanel::~ControlPanel()
|
||||
{
|
||||
}
|
||||
|
||||
bool ControlPanel::CanClose( void )
|
||||
{
|
||||
workspacefiles->StartStoringFiles( IWorkspaceFiles::EXPRESSION );
|
||||
for ( int i = 0 ; i < expressions->GetNumClasses(); i++ )
|
||||
{
|
||||
CExpClass *cl = expressions->GetClass( i );
|
||||
if ( cl )
|
||||
{
|
||||
workspacefiles->StoreFile( IWorkspaceFiles::EXPRESSION, cl->GetFileName() );
|
||||
}
|
||||
}
|
||||
workspacefiles->FinishStoringFiles( IWorkspaceFiles::EXPRESSION );
|
||||
// Now close them all, or abort exit if user doesn't want to close any that have changed
|
||||
return Closeall();
|
||||
}
|
||||
|
||||
void ControlPanel::OnDelete()
|
||||
{
|
||||
}
|
||||
|
||||
void ControlPanel::PositionControls( int width, int height )
|
||||
{
|
||||
if ( tab )
|
||||
{
|
||||
tab->setBounds( 0, GetCaptionHeight(), width, height );
|
||||
}
|
||||
}
|
||||
|
||||
void ControlPanel::redraw()
|
||||
{
|
||||
if ( !ToolCanDraw() )
|
||||
return;
|
||||
|
||||
CChoreoWidgetDrawHelper helper( this, RGBToColor( GetSysColor( COLOR_BTNFACE ) ) );
|
||||
HandleToolRedraw( helper );
|
||||
|
||||
BaseClass::redraw();
|
||||
}
|
||||
|
||||
int
|
||||
ControlPanel::handleEvent (mxEvent *event)
|
||||
{
|
||||
MDLCACHE_CRITICAL_SECTION_( g_pMDLCache );
|
||||
|
||||
int iret = 0;
|
||||
|
||||
if ( HandleToolEvent( event ) )
|
||||
{
|
||||
return iret;
|
||||
}
|
||||
|
||||
switch ( event->event )
|
||||
{
|
||||
case mxEvent::Size:
|
||||
{
|
||||
PositionControls( event->width, event->height );
|
||||
iret = 1;
|
||||
}
|
||||
break;
|
||||
case mxEvent::Action:
|
||||
{
|
||||
iret = 1;
|
||||
switch (event->action)
|
||||
{
|
||||
case IDC_TOOLSDRIVEMOUTH:
|
||||
{
|
||||
g_viewerSettings.faceposerToolsDriveMouth = ((mxCheckBox *)event->widget)->isChecked();
|
||||
}
|
||||
break;
|
||||
case IDC_TAB:
|
||||
{
|
||||
g_viewerSettings.showTexture = (tab->getSelectedIndex() == 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_RENDERMODE:
|
||||
{
|
||||
int index = cRenderMode->getSelectedIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
setRenderMode (index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_GROUND:
|
||||
setShowGround (((mxCheckBox *) event->widget)->isChecked());
|
||||
break;
|
||||
|
||||
case IDC_MOVEMENT:
|
||||
setShowMovement (((mxCheckBox *) event->widget)->isChecked());
|
||||
break;
|
||||
|
||||
case IDC_BACKGROUND:
|
||||
setShowBackground (((mxCheckBox *) event->widget)->isChecked());
|
||||
break;
|
||||
|
||||
case IDC_HITBOXES:
|
||||
g_viewerSettings.showHitBoxes = ((mxCheckBox *) event->widget)->isChecked();
|
||||
break;
|
||||
|
||||
case IDC_PHYSICSMODEL:
|
||||
g_viewerSettings.showPhysicsModel = ((mxCheckBox *) event->widget)->isChecked();
|
||||
break;
|
||||
|
||||
case IDC_BONES:
|
||||
g_viewerSettings.showBones = ((mxCheckBox *) event->widget)->isChecked();
|
||||
break;
|
||||
|
||||
case IDC_ATTACHMENTS:
|
||||
g_viewerSettings.showAttachments = ((mxCheckBox *) event->widget)->isChecked();
|
||||
break;
|
||||
|
||||
case IDC_SEQUENCE:
|
||||
{
|
||||
int index = cSequence->getSelectedIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
setSequence ( index );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_SPEEDSCALE:
|
||||
{
|
||||
g_viewerSettings.speedScale = ((mxSlider *) event->widget)->getValue();
|
||||
lSpeedScale->setLabel( va( "Speed scale %.2f", g_viewerSettings.speedScale ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_PRIMARYBLEND:
|
||||
{
|
||||
setBlend( 0, ((mxSlider *) event->widget)->getValue() );
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_SECONDARYBLEND:
|
||||
{
|
||||
setBlend( 1, ((mxSlider *) event->widget)->getValue() );
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_BODYPART:
|
||||
{
|
||||
int index = cBodypart->getSelectedIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
setBodypart (index);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_SUBMODEL:
|
||||
{
|
||||
int index = cSubmodel->getSelectedIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
setSubmodel (index);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_CONTROLLER:
|
||||
{
|
||||
int index = cController->getSelectedIndex();
|
||||
if (index >= 0)
|
||||
setBoneController (index);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_CONTROLLERVALUE:
|
||||
{
|
||||
int index = cController->getSelectedIndex();
|
||||
if (index >= 0)
|
||||
setBoneControllerValue (index, slController->getValue());
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_SKINS:
|
||||
{
|
||||
int index = cSkin->getSelectedIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
models->GetActiveStudioModel()->SetSkin (index);
|
||||
g_viewerSettings.skin = index;
|
||||
g_pMatSysWindow->redraw();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
iret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
void ControlPanel::dumpModelInfo() { }
|
||||
|
||||
void ControlPanel::ChangeModel( const char *filename )
|
||||
{
|
||||
HCURSOR hPrevCursor = SetCursor( LoadCursor( NULL, IDC_WAIT ) );
|
||||
|
||||
// init all the selection tabs based on the current model
|
||||
initSequenceChoices();
|
||||
initBodypartChoices();
|
||||
initBoneControllerChoices();
|
||||
initSkinChoices();
|
||||
|
||||
setModelInfo();
|
||||
|
||||
SetCloseCaptionLanguageId( g_viewerSettings.cclanguageid, true );
|
||||
|
||||
g_viewerSettings.m_iEditAttachment = -1;
|
||||
|
||||
g_viewerSettings.enableIK = true;
|
||||
g_viewerSettings.enableTargetIK = false;
|
||||
|
||||
setSequence( models->GetActiveStudioModel()->GetSequence() );
|
||||
setSpeed( g_viewerSettings.speedScale );
|
||||
|
||||
mx_setcwd (mx_getpath (filename));
|
||||
|
||||
g_pFlexPanel->initFlexes();
|
||||
|
||||
// centerView();
|
||||
// CenterOnFace();
|
||||
|
||||
IFacePoserToolWindow::ModelChanged();
|
||||
|
||||
CExpClass *cl = expressions->GetActiveClass();
|
||||
if ( cl )
|
||||
{
|
||||
cl->SelectExpression( cl->GetSelectedExpression() );
|
||||
}
|
||||
|
||||
SetSuffix( va( " - %s.mdl", models->GetActiveModelName() ) );
|
||||
redraw();
|
||||
|
||||
SetCursor( hPrevCursor );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setRenderMode (int mode)
|
||||
{
|
||||
g_viewerSettings.renderMode = mode;
|
||||
g_pMatSysWindow->redraw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setHighlightBone( int index )
|
||||
{
|
||||
g_viewerSettings.highlightPhysicsBone = index;
|
||||
}
|
||||
|
||||
void
|
||||
ControlPanel::setShowGround (bool b)
|
||||
{
|
||||
g_viewerSettings.showGround = b;
|
||||
cbGround->setChecked (b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setShowMovement (bool b)
|
||||
{
|
||||
g_viewerSettings.showMovement = b;
|
||||
cbMovement->setChecked (b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setShowBackground (bool b)
|
||||
{
|
||||
g_viewerSettings.showBackground = b;
|
||||
cbBackground->setChecked (b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::initSequenceChoices()
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
cSequence->removeAll();
|
||||
for (int i = 0; i < hdr->GetNumSeq(); i++)
|
||||
{
|
||||
cSequence->add (hdr->pSeqdesc(i).pszLabel());
|
||||
}
|
||||
|
||||
cSequence->select (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setSequence (int index)
|
||||
{
|
||||
cSequence->select (index);
|
||||
models->GetActiveStudioModel()->SetSequence(index);
|
||||
|
||||
initPoseParameters( );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setSpeed( float value )
|
||||
{
|
||||
g_viewerSettings.speedScale = value;
|
||||
slSpeedScale->setValue( value );
|
||||
}
|
||||
|
||||
|
||||
void ControlPanel::setBlend(int index, float value )
|
||||
{
|
||||
models->GetActiveStudioModel()->SetPoseParameter( index, value );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::initBodypartChoices()
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
int i;
|
||||
mstudiobodyparts_t *pbodyparts = hdr->pBodypart(0);
|
||||
|
||||
cBodypart->removeAll();
|
||||
if (hdr->numbodyparts() > 0)
|
||||
{
|
||||
for (i = 0; i < hdr->numbodyparts(); i++)
|
||||
cBodypart->add (pbodyparts[i].pszName());
|
||||
|
||||
cBodypart->select (0);
|
||||
|
||||
cSubmodel->removeAll();
|
||||
for (i = 0; i < pbodyparts[0].nummodels; i++)
|
||||
{
|
||||
char str[64];
|
||||
sprintf (str, "Submodel %d", i + 1);
|
||||
cSubmodel->add (str);
|
||||
}
|
||||
cSubmodel->select (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setBodypart (int index)
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
//cBodypart->setEn
|
||||
cBodypart->select (index);
|
||||
if (index < hdr->numbodyparts())
|
||||
{
|
||||
mstudiobodyparts_t *pbodyparts = hdr->pBodypart(0);
|
||||
cSubmodel->removeAll();
|
||||
|
||||
for (int i = 0; i < pbodyparts[index].nummodels; i++)
|
||||
{
|
||||
char str[64];
|
||||
sprintf (str, "Submodel %d", i + 1);
|
||||
cSubmodel->add (str);
|
||||
}
|
||||
cSubmodel->select (0);
|
||||
//models->GetActiveStudioModel()->SetBodygroup (index, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setSubmodel (int index)
|
||||
{
|
||||
models->GetActiveStudioModel()->SetBodygroup (cBodypart->getSelectedIndex(), index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::initBoneControllerChoices()
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
cController->setEnabled (hdr->numbonecontrollers() > 0);
|
||||
slController->setEnabled (hdr->numbonecontrollers() > 0);
|
||||
cController->removeAll();
|
||||
|
||||
for (int i = 0; i < hdr->numbonecontrollers(); i++)
|
||||
{
|
||||
mstudiobonecontroller_t *pbonecontroller = hdr->pBonecontroller(i);
|
||||
char str[32];
|
||||
sprintf (str, "Controller %d", pbonecontroller->inputfield);
|
||||
cController->add (str);
|
||||
}
|
||||
|
||||
if (hdr->numbonecontrollers() > 0)
|
||||
{
|
||||
mstudiobonecontroller_t *pbonecontrollers = hdr->pBonecontroller(0);
|
||||
cController->select (0);
|
||||
slController->setRange (pbonecontrollers->start, pbonecontrollers->end);
|
||||
slController->setValue (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setBoneController (int index)
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
mstudiobonecontroller_t *pbonecontroller = hdr->pBonecontroller(index);
|
||||
slController->setRange ( pbonecontroller->start, pbonecontroller->end);
|
||||
slController->setValue (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setBoneControllerValue (int index, float value)
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
mstudiobonecontroller_t *pbonecontrollers = hdr->pBonecontroller(index);
|
||||
models->GetActiveStudioModel()->SetController (pbonecontrollers->inputfield, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::initPoseParameters()
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
for (int i = 0; i < hdr->GetNumPoseParameters(); i++)
|
||||
{
|
||||
setBlend( i, 0.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ControlPanel::initSkinChoices()
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
cSkin->setEnabled (hdr->numskinfamilies() > 0);
|
||||
cSkin->removeAll();
|
||||
|
||||
for (int i = 0; i < hdr->numskinfamilies(); i++)
|
||||
{
|
||||
char str[32];
|
||||
sprintf (str, "Skin %d", i + 1);
|
||||
cSkin->add (str);
|
||||
}
|
||||
|
||||
cSkin->select (0);
|
||||
models->GetActiveStudioModel()->SetSkin (0);
|
||||
g_viewerSettings.skin = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ControlPanel::setModelInfo()
|
||||
{
|
||||
static char str[2048];
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
|
||||
if (!hdr)
|
||||
return;
|
||||
|
||||
int hbcount = 0;
|
||||
for ( int s = 0; s < hdr->numhitboxsets(); s++ )
|
||||
{
|
||||
hbcount += hdr->iHitboxCount( s );
|
||||
}
|
||||
|
||||
sprintf (str,
|
||||
"Bones: %d\n"
|
||||
"Bone Controllers: %d\n"
|
||||
"Hit Boxes: %d in %d sets\n"
|
||||
"Sequences: %d\n",
|
||||
hdr->numbones(),
|
||||
hdr->numbonecontrollers(),
|
||||
hbcount,
|
||||
hdr->numhitboxsets(),
|
||||
hdr->GetNumSeq()
|
||||
);
|
||||
|
||||
lModelInfo1->setLabel (str);
|
||||
|
||||
sprintf (str,
|
||||
"Textures: %d\n"
|
||||
"Skin Families: %d\n"
|
||||
"Bodyparts: %d\n"
|
||||
"Attachments: %d\n",
|
||||
hdr->numtextures(),
|
||||
hdr->numskinfamilies(),
|
||||
hdr->numbodyparts(),
|
||||
hdr->GetNumAttachments());
|
||||
|
||||
lModelInfo2->setLabel (str);
|
||||
}
|
||||
|
||||
|
||||
void ControlPanel::CenterOnFace( void )
|
||||
{
|
||||
if ( !models->GetActiveStudioModel() )
|
||||
return;
|
||||
|
||||
StudioModel *mdl = models->GetActiveStudioModel();
|
||||
if ( !mdl )
|
||||
return;
|
||||
|
||||
CStudioHdr *hdr = mdl->GetStudioHdr();
|
||||
if ( !hdr )
|
||||
return;
|
||||
|
||||
setSpeed( 1.0f );
|
||||
|
||||
int oldSeq = models->GetActiveStudioModel()->GetSequence();
|
||||
|
||||
int seq = models->GetActiveStudioModel()->LookupSequence( "idle_suble" );
|
||||
if ( seq == -1 )
|
||||
seq = 0;
|
||||
|
||||
if ( seq != oldSeq )
|
||||
{
|
||||
Con_Printf( "Centering changed model sequence # to %d\n", seq );
|
||||
}
|
||||
|
||||
setSequence( seq );
|
||||
initPoseParameters( );
|
||||
|
||||
mdl->m_angles.Init();
|
||||
mdl->m_origin.Init();
|
||||
|
||||
Vector size;
|
||||
VectorSubtract( hdr->hull_max(), hdr->hull_min(), size );
|
||||
|
||||
float eyeheight = hdr->hull_min().z + 0.9 * size.z;
|
||||
|
||||
if ( hdr->GetNumAttachments() > 0 )
|
||||
{
|
||||
for (int i = 0; i < hdr->GetNumAttachments(); i++)
|
||||
{
|
||||
const mstudioattachment_t &attachment = hdr->pAttachment( i );
|
||||
int iBone = hdr->GetAttachmentBone( i );
|
||||
|
||||
if ( Q_stricmp( attachment.pszName(), "eyes" ) )
|
||||
continue;
|
||||
|
||||
const mstudiobone_t *bone = hdr->pBone( iBone );
|
||||
if ( !bone )
|
||||
continue;
|
||||
|
||||
matrix3x4_t boneToPose;
|
||||
MatrixInvert( bone->poseToBone, boneToPose );
|
||||
|
||||
matrix3x4_t attachmentPoseToLocal;
|
||||
ConcatTransforms( boneToPose, attachment.local, attachmentPoseToLocal );
|
||||
|
||||
Vector localSpaceEyePosition;
|
||||
VectorITransform( vec3_origin, attachmentPoseToLocal, localSpaceEyePosition );
|
||||
|
||||
// Not sure why this must be negative?
|
||||
eyeheight = -localSpaceEyePosition.z + hdr->hull_min().z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KeyValues *seqKeyValues = new KeyValues("");
|
||||
if ( seqKeyValues->LoadFromBuffer( mdl->GetFileName( ), mdl->GetKeyValueText( seq ) ) )
|
||||
{
|
||||
// Do we have a build point section?
|
||||
KeyValues *pkvAllFaceposer = seqKeyValues->FindKey("faceposer");
|
||||
if ( pkvAllFaceposer )
|
||||
{
|
||||
float flEyeheight = pkvAllFaceposer->GetFloat( "eye_height", -9999.0f );
|
||||
if ( flEyeheight != -9999.0f )
|
||||
{
|
||||
eyeheight = flEyeheight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
seqKeyValues->deleteThis();
|
||||
|
||||
mdl->m_origin.x = size.z * .65f;
|
||||
mdl->m_origin.z += eyeheight;
|
||||
|
||||
CUtlVector< StudioModel * > modellist;
|
||||
|
||||
modellist.AddToTail( models->GetActiveStudioModel() );
|
||||
|
||||
int i;
|
||||
if ( models->CountVisibleModels() > 0 )
|
||||
{
|
||||
modellist.RemoveAll();
|
||||
for ( i = 0; i < models->Count(); i++ )
|
||||
{
|
||||
if ( models->IsModelShownIn3DView( i ) )
|
||||
{
|
||||
modellist.AddToTail( models->GetStudioModel( i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int modelcount = modellist.Count();
|
||||
int countover2 = modelcount / 2;
|
||||
int ydelta = GetModelGap();
|
||||
int yoffset = -countover2 * ydelta;
|
||||
for ( i = 0 ; i < modelcount; i++ )
|
||||
{
|
||||
if ( models->GetStudioHeader( i ) == hdr )
|
||||
{
|
||||
mdl->m_origin.y = -yoffset;
|
||||
}
|
||||
yoffset += ydelta;
|
||||
}
|
||||
|
||||
g_pMatSysWindow->redraw();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float ControlPanel::GetModelGap( void )
|
||||
{
|
||||
return slModelGap->getValue();
|
||||
}
|
||||
|
||||
void
|
||||
ControlPanel::centerView()
|
||||
{
|
||||
StudioModel *pModel = models->GetActiveStudioModel();
|
||||
if ( !pModel )
|
||||
return;
|
||||
|
||||
Vector min, max;
|
||||
models->GetActiveStudioModel()->ExtractBbox (min, max);
|
||||
|
||||
float dx = max[0] - min[0];
|
||||
float dy = max[1] - min[1];
|
||||
float dz = max[2] - min[2];
|
||||
float d = dx;
|
||||
if (dy > d)
|
||||
d = dy;
|
||||
if (dz > d)
|
||||
d = dz;
|
||||
pModel->m_origin[0] = d * 1.0f;
|
||||
pModel->m_origin[1] = 0;
|
||||
pModel->m_origin[2] = min[2] + dz / 2;
|
||||
pModel->m_angles[0] = 0.0f;
|
||||
pModel->m_angles[1] = 0.0f;
|
||||
pModel->m_angles[2] = 0.0f;
|
||||
g_viewerSettings.lightrot.x = 0.f;
|
||||
g_viewerSettings.lightrot.y = -180.0f;
|
||||
g_viewerSettings.lightrot.z = 0.0f;
|
||||
g_pMatSysWindow->redraw();
|
||||
}
|
||||
|
||||
bool ControlPanel::Close()
|
||||
{
|
||||
int index = g_pExpressionClass->getSelectedIndex();
|
||||
CExpClass *cl = expressions->GetClass( index );
|
||||
if ( !cl )
|
||||
return true;
|
||||
|
||||
return expressions->CloseClass( cl );
|
||||
|
||||
}
|
||||
|
||||
bool ControlPanel::Closeall()
|
||||
{
|
||||
bool retval = true;
|
||||
|
||||
while ( expressions->GetNumClasses() > 0 )
|
||||
{
|
||||
CExpClass *cl = expressions->GetClass( 0 );
|
||||
if ( !cl )
|
||||
break;
|
||||
|
||||
if ( !expressions->CloseClass( cl ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ControlPanel::Copy( void )
|
||||
{
|
||||
g_pFlexPanel->CopyControllerSettings();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ControlPanel::Paste( void )
|
||||
{
|
||||
g_pFlexPanel->PasteControllerSettings();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ControlPanel::Undo( void )
|
||||
{
|
||||
CExpClass *active = expressions->GetActiveClass();
|
||||
if ( !active )
|
||||
return;
|
||||
int index = active->GetSelectedExpression();
|
||||
if ( index != -1 )
|
||||
{
|
||||
UndoExpression( index );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ControlPanel::Redo( void )
|
||||
{
|
||||
CExpClass *active = expressions->GetActiveClass();
|
||||
if ( !active )
|
||||
return;
|
||||
int index = active->GetSelectedExpression();
|
||||
if ( index != -1 )
|
||||
{
|
||||
RedoExpression( index );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ControlPanel::UndoExpression( int index )
|
||||
{
|
||||
if ( index == -1 )
|
||||
return;
|
||||
|
||||
CExpClass *active = expressions->GetActiveClass();
|
||||
if ( !active )
|
||||
return;
|
||||
|
||||
CExpression *exp = active->GetExpression( index );
|
||||
if ( exp )
|
||||
{
|
||||
exp->Undo();
|
||||
// Show the updated data
|
||||
active->SelectExpression( index );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void ControlPanel::RedoExpression( int index )
|
||||
{
|
||||
if ( index == -1 )
|
||||
return;
|
||||
|
||||
CExpClass *active = expressions->GetActiveClass();
|
||||
if ( !active )
|
||||
return;
|
||||
|
||||
CExpression *exp = active->GetExpression( index );
|
||||
if ( exp )
|
||||
{
|
||||
exp->Redo();
|
||||
// Show the updated data
|
||||
active->SelectExpression( index );
|
||||
}
|
||||
}
|
||||
|
||||
void ControlPanel::DeleteExpression( int index )
|
||||
{
|
||||
CExpClass *active = expressions->GetActiveClass();
|
||||
if ( !active )
|
||||
return;
|
||||
|
||||
CExpression *exp = active->GetExpression( index );
|
||||
if ( exp )
|
||||
{
|
||||
Con_Printf( "Deleting expression %s : %s\n", exp->name, exp->description );
|
||||
|
||||
g_pFlexPanel->DeleteExpression( index );
|
||||
|
||||
active->SelectExpression( max( 0, index - 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : dt -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ControlPanel::Think( float dt )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ControlPanel::AllToolsDriveSpeech( void )
|
||||
{
|
||||
return cbAllWindowsDriveSpeech->isChecked();
|
||||
}
|
||||
161
utils/hlfaceposer/controlpanel.h
Normal file
161
utils/hlfaceposer/controlpanel.h
Normal file
@@ -0,0 +1,161 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CONTROLPANEL_H
|
||||
#define CONTROLPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDED_MXWINDOW
|
||||
#include <mxtk/mxWindow.h>
|
||||
#endif
|
||||
|
||||
#include "faceposertoolwindow.h"
|
||||
|
||||
#define IDC_TAB 1901
|
||||
#define IDC_RENDERMODE 2001
|
||||
#define IDC_GROUND 2003
|
||||
#define IDC_MOVEMENT 2004
|
||||
#define IDC_BACKGROUND 2005
|
||||
#define IDC_HITBOXES 2006
|
||||
#define IDC_BONES 2007
|
||||
#define IDC_ATTACHMENTS 2008
|
||||
#define IDC_PHYSICSMODEL 2009
|
||||
#define IDC_PHYSICSHIGHLIGHT 2010
|
||||
#define IDC_MODELSPACING 2011
|
||||
#define IDC_TOOLSDRIVEMOUTH 2012
|
||||
|
||||
#define IDC_SEQUENCE 3001
|
||||
#define IDC_SPEEDSCALE 3002
|
||||
#define IDC_PRIMARYBLEND 3003
|
||||
#define IDC_SECONDARYBLEND 3004
|
||||
|
||||
#define IDC_BODYPART 4001
|
||||
#define IDC_SUBMODEL 4002
|
||||
#define IDC_CONTROLLER 4003
|
||||
#define IDC_CONTROLLERVALUE 4004
|
||||
#define IDC_SKINS 4005
|
||||
|
||||
#define IDC_EXPRESSIONCLASS 5001
|
||||
#define IDC_EXPRESSIONTRAY 5002
|
||||
#define IDC_ANIMATIONBROWSER 5003
|
||||
|
||||
class mxTab;
|
||||
class mxChoice;
|
||||
class mxCheckBox;
|
||||
class mxSlider;
|
||||
class mxLineEdit;
|
||||
class mxLabel;
|
||||
class mxButton;
|
||||
class MatSysWindow;
|
||||
class TextureWindow;
|
||||
class mxExpressionTray;
|
||||
class FlexPanel;
|
||||
class PhonemeEditor;
|
||||
class mxExpressionTab;
|
||||
class mxExpressionSlider;
|
||||
class ExpressionTool;
|
||||
class CChoreoView;
|
||||
|
||||
|
||||
class ControlPanel : public mxWindow, public IFacePoserToolWindow
|
||||
{
|
||||
typedef mxWindow BaseClass;
|
||||
|
||||
mxTab *tab;
|
||||
mxChoice *cRenderMode;
|
||||
mxCheckBox *cbGround, *cbMovement, *cbBackground;
|
||||
mxChoice *cSequence;
|
||||
mxSlider *slSpeedScale;
|
||||
mxLabel *lSpeedScale;
|
||||
mxChoice *cBodypart, *cController, *cSubmodel;
|
||||
mxSlider *slController;
|
||||
mxChoice *cSkin;
|
||||
mxLabel *lModelInfo1, *lModelInfo2;
|
||||
|
||||
mxLineEdit *leMeshScale, *leBoneScale;
|
||||
mxSlider *slModelGap;
|
||||
|
||||
mxCheckBox *cbAllWindowsDriveSpeech;
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
ControlPanel (mxWindow *parent);
|
||||
virtual ~ControlPanel ();
|
||||
|
||||
// MANIPULATORS
|
||||
|
||||
virtual int handleEvent (mxEvent *event);
|
||||
virtual void redraw();
|
||||
|
||||
virtual void OnDelete();
|
||||
virtual bool CanClose();
|
||||
|
||||
virtual void Think( float dt );
|
||||
|
||||
void dumpModelInfo ();
|
||||
void ChangeModel( const char *filename );
|
||||
|
||||
void setRenderMode (int mode);
|
||||
void setShowGround (bool b);
|
||||
void setShowMovement (bool b);
|
||||
void setShowBackground (bool b);
|
||||
void setHighlightBone( int index );
|
||||
|
||||
void initSequenceChoices( );
|
||||
void setSequence (int index);
|
||||
|
||||
void setSpeed( float value );
|
||||
|
||||
void initPoseParameters ();
|
||||
void setBlend(int index, float value );
|
||||
|
||||
void initBodypartChoices();
|
||||
void setBodypart (int index);
|
||||
void setSubmodel (int index);
|
||||
|
||||
void initBoneControllerChoices();
|
||||
void setBoneController (int index);
|
||||
void setBoneControllerValue (int index, float value);
|
||||
|
||||
void initSkinChoices();
|
||||
|
||||
void setModelInfo ();
|
||||
|
||||
void centerView ();
|
||||
|
||||
void fullscreen ();
|
||||
|
||||
void CenterOnFace( void );
|
||||
|
||||
void PositionControls( int width, int height );
|
||||
|
||||
bool CloseClass( int classindex );
|
||||
|
||||
bool Close();
|
||||
bool Closeall();
|
||||
|
||||
void Copy( void );
|
||||
void Paste( void );
|
||||
|
||||
void Undo( void );
|
||||
void Redo( void );
|
||||
|
||||
void UndoExpression( int index );
|
||||
void RedoExpression( int index );
|
||||
|
||||
void DeleteExpression( int index );
|
||||
|
||||
float GetModelGap( void );
|
||||
|
||||
bool AllToolsDriveSpeech( void );
|
||||
|
||||
};
|
||||
|
||||
extern ControlPanel *g_pControlPanel;
|
||||
|
||||
#endif // CONTROLPANEL_H
|
||||
370
utils/hlfaceposer/curveeditorhelpers.h
Normal file
370
utils/hlfaceposer/curveeditorhelpers.h
Normal file
@@ -0,0 +1,370 @@
|
||||
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CURVEEDITORHELPERS_H
|
||||
#define CURVEEDITORHELPERS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "mxtk/mx.h"
|
||||
|
||||
struct CExpressionSample;
|
||||
|
||||
template< class T >
|
||||
class CCurveEditorHelper
|
||||
{
|
||||
public:
|
||||
CCurveEditorHelper( T *outer );
|
||||
|
||||
int GetBestCurveTypeForSelectedSamples( bool reflect );
|
||||
int CountSelected( bool reflect );
|
||||
void ChangeCurveType( bool forward, bool shiftdown, bool altdown );
|
||||
void SetCurveTypeForSelectedSamples( bool reflect, int curvetype );
|
||||
void SetCurveTypeForSample( int curvetype, CExpressionSample *sample );
|
||||
void ToggleHoldTypeForSelectedSamples( bool reflect );
|
||||
void ToggleHoldTypeForSample( CExpressionSample *sample );
|
||||
|
||||
bool HelperHandleEvent( mxEvent *event );
|
||||
|
||||
private:
|
||||
T *GetOuter();
|
||||
|
||||
private:
|
||||
|
||||
T *m_pOuter;
|
||||
};
|
||||
|
||||
template< class T >
|
||||
CCurveEditorHelper<T>::CCurveEditorHelper( T *pOuter ) :
|
||||
m_pOuter( pOuter )
|
||||
{
|
||||
Assert( pOuter );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
T *CCurveEditorHelper<T>::GetOuter()
|
||||
{
|
||||
return m_pOuter;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
int CCurveEditorHelper<T>::GetBestCurveTypeForSelectedSamples( bool reflect )
|
||||
{
|
||||
int numSelected = CountSelected( reflect );
|
||||
if ( !numSelected )
|
||||
return CURVE_DEFAULT;
|
||||
|
||||
CUtlMap< int, int > counts( 0, 0, DefLessFunc( int ) );
|
||||
|
||||
CUtlVector< T * > workList;
|
||||
GetOuter()->GetWorkList( reflect, workList );
|
||||
|
||||
for ( int w = 0; w < workList.Count(); ++w )
|
||||
{
|
||||
int numSamples = workList[ w ]->NumSamples();
|
||||
if ( !numSamples )
|
||||
continue;
|
||||
|
||||
for ( int i = numSamples - 1; i >= 0 ; i-- )
|
||||
{
|
||||
CExpressionSample *sample = workList[ w ]->GetSample( i );
|
||||
if ( !sample->selected )
|
||||
continue;
|
||||
|
||||
int curveType = sample->GetCurveType();
|
||||
int idx = counts.Find( curveType );
|
||||
if ( idx == counts.InvalidIndex() )
|
||||
{
|
||||
idx = counts.Insert( curveType, 0 );
|
||||
}
|
||||
|
||||
counts[ idx ]++;
|
||||
}
|
||||
}
|
||||
|
||||
int maxType = CURVE_DEFAULT;
|
||||
int maxCount = -1;
|
||||
|
||||
for ( int i = counts.FirstInorder(); i != counts.InvalidIndex(); i = counts.NextInorder( i ) )
|
||||
{
|
||||
if ( counts[ i ] > maxType )
|
||||
{
|
||||
maxCount = counts[ i ];
|
||||
maxType = counts.Key( i );
|
||||
}
|
||||
}
|
||||
|
||||
return maxType;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
int CCurveEditorHelper<T>::CountSelected( bool reflect )
|
||||
{
|
||||
int numSelected = 0;
|
||||
|
||||
CUtlVector< T * > workList;
|
||||
GetOuter()->GetWorkList( reflect, workList );
|
||||
|
||||
for ( int w = 0; w < workList.Count(); ++w )
|
||||
{
|
||||
int numSamples = workList[ w ]->NumSamples();
|
||||
if ( !numSamples )
|
||||
continue;
|
||||
|
||||
for ( int i = 0 ; i < numSamples; ++i )
|
||||
{
|
||||
CExpressionSample *sample = workList[ w ]->GetSample( i );
|
||||
if ( !sample || !sample->selected )
|
||||
continue;
|
||||
|
||||
++numSelected;
|
||||
}
|
||||
}
|
||||
|
||||
return numSelected;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
void CCurveEditorHelper<T>::ChangeCurveType( bool forward, bool shiftdown, bool altdown )
|
||||
{
|
||||
// If holding ctrl and shift, only do inbound
|
||||
bool inbound = shiftdown;
|
||||
// if holding ctrl, shift + alt, do both inbound and outbound
|
||||
bool outbound = !shiftdown || altdown;
|
||||
// if holding ctrl + alt, do outbound
|
||||
// if holding just ctrl, do outbound
|
||||
|
||||
int numSelected = CountSelected( false );
|
||||
if ( !numSelected )
|
||||
return;
|
||||
|
||||
int curveType = GetBestCurveTypeForSelectedSamples( false );
|
||||
|
||||
int sides[ 2 ];
|
||||
Interpolator_CurveInterpolatorsForType( curveType, sides[ 0 ], sides[ 1 ] );
|
||||
|
||||
int dir = forward ? 1 : -1;
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
if ( i == 0 && !inbound )
|
||||
continue;
|
||||
if ( i == 1 && !outbound )
|
||||
continue;
|
||||
|
||||
sides[ i ] += dir;
|
||||
if ( sides[ i ] < 0 )
|
||||
{
|
||||
sides[ i ] = NUM_INTERPOLATE_TYPES - 1;
|
||||
}
|
||||
else if ( sides[ i ] >= NUM_INTERPOLATE_TYPES )
|
||||
{
|
||||
sides[ i ] = INTERPOLATE_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
curveType = MAKE_CURVE_TYPE( sides[ 0 ], sides[ 1 ] );
|
||||
SetCurveTypeForSelectedSamples( false, curveType );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
void CCurveEditorHelper<T>::SetCurveTypeForSelectedSamples( bool reflect, int curvetype )
|
||||
{
|
||||
int numSelected = CountSelected( reflect );
|
||||
if ( !numSelected )
|
||||
return;
|
||||
|
||||
GetOuter()->PreDataChanged( "Set curve type" );
|
||||
|
||||
CUtlVector< T * > workList;
|
||||
GetOuter()->GetWorkList( reflect, workList );
|
||||
|
||||
for ( int w = 0; w < workList.Count(); ++w )
|
||||
{
|
||||
int numSamples = workList[ w ]->NumSamples();
|
||||
|
||||
for ( int i = 0 ; i < numSamples; ++i )
|
||||
{
|
||||
CExpressionSample *sample = workList[ w ]->GetSample( i );
|
||||
if ( !sample->selected )
|
||||
continue;
|
||||
|
||||
sample->SetCurveType( curvetype );
|
||||
}
|
||||
}
|
||||
|
||||
GetOuter()->PostDataChanged( "Set curve type" );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
void CCurveEditorHelper<T>::SetCurveTypeForSample( int curvetype, CExpressionSample *sample )
|
||||
{
|
||||
GetOuter()->PreDataChanged( "Set curve type" );
|
||||
|
||||
sample->SetCurveType( curvetype );
|
||||
|
||||
GetOuter()->PostDataChanged( "Set curve type" );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
void CCurveEditorHelper<T>::ToggleHoldTypeForSelectedSamples( bool reflect )
|
||||
{
|
||||
int numSelected = CountSelected( reflect );
|
||||
if ( !numSelected )
|
||||
return;
|
||||
|
||||
GetOuter()->PreDataChanged( "Set hold out value" );
|
||||
|
||||
CUtlVector< T * > workList;
|
||||
GetOuter()->GetWorkList( reflect, workList );
|
||||
|
||||
for ( int w = 0; w < workList.Count(); ++w )
|
||||
{
|
||||
int numSamples = workList[ w ]->NumSamples();
|
||||
|
||||
int newValue = -1;
|
||||
|
||||
for ( int i = 0 ; i < numSamples; ++i )
|
||||
{
|
||||
CExpressionSample *sample = workList[ w ]->GetSample( i );
|
||||
if ( !sample->selected )
|
||||
continue;
|
||||
|
||||
// First one controls setting
|
||||
int l, r;
|
||||
Interpolator_CurveInterpolatorsForType( sample->GetCurveType(), l, r );
|
||||
|
||||
if ( newValue == -1 )
|
||||
{
|
||||
newValue = ( r == INTERPOLATE_HOLD ) ? 0 : 1;
|
||||
}
|
||||
|
||||
int newCurveType = MAKE_CURVE_TYPE( l, newValue == 1 ? INTERPOLATE_HOLD : l );
|
||||
sample->SetCurveType( newCurveType );
|
||||
}
|
||||
}
|
||||
|
||||
GetOuter()->PostDataChanged( "Set hold out value" );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
void CCurveEditorHelper<T>::ToggleHoldTypeForSample( CExpressionSample *sample )
|
||||
{
|
||||
GetOuter()->PreDataChanged( "Set hold out value" );
|
||||
|
||||
int l, r;
|
||||
Interpolator_CurveInterpolatorsForType( sample->GetCurveType(), l, r );
|
||||
|
||||
if ( r == INTERPOLATE_HOLD )
|
||||
{
|
||||
r = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = INTERPOLATE_HOLD;
|
||||
}
|
||||
|
||||
int newCurveType = MAKE_CURVE_TYPE( l, r );
|
||||
sample->SetCurveType( newCurveType );
|
||||
|
||||
GetOuter()->PostDataChanged( "Set hold out value" );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
bool CCurveEditorHelper<T>::HelperHandleEvent( mxEvent *event )
|
||||
{
|
||||
bool handled = false;
|
||||
|
||||
switch ( event->event )
|
||||
{
|
||||
case mxEvent::KeyDown:
|
||||
{
|
||||
switch ( event->key )
|
||||
{
|
||||
default:
|
||||
// Hotkey pressed
|
||||
if ( event->key >= '0' &&
|
||||
event->key <= '9' )
|
||||
{
|
||||
bool shiftdown = GetAsyncKeyState( VK_SHIFT ) ? true : false;
|
||||
|
||||
handled = true;
|
||||
// Get curve type
|
||||
int curveType = Interpolator_CurveTypeForHotkey( event->key );
|
||||
if ( curveType >= 0 )
|
||||
{
|
||||
if ( CountSelected( shiftdown ) <= 0 )
|
||||
{
|
||||
GetOuter()->SetMousePositionForEvent( event );
|
||||
|
||||
CExpressionSample *hover = GetOuter()->GetSampleUnderMouse( event->x, event->y, 0.0f );
|
||||
|
||||
// Deal with highlighted item
|
||||
if ( hover )
|
||||
{
|
||||
SetCurveTypeForSample( curveType, hover );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCurveTypeForSelectedSamples( shiftdown, curveType );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'H':
|
||||
{
|
||||
handled = true;
|
||||
|
||||
bool shiftdown = GetAsyncKeyState( VK_SHIFT ) ? true : false;
|
||||
|
||||
if ( CountSelected( shiftdown ) <= 0 )
|
||||
{
|
||||
GetOuter()->SetMousePositionForEvent( event );
|
||||
|
||||
CExpressionSample *hover = GetOuter()->GetSampleUnderMouse( event->x, event->y, 0.0f );
|
||||
|
||||
// Deal with highlighted item
|
||||
if ( hover )
|
||||
{
|
||||
ToggleHoldTypeForSample( hover );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleHoldTypeForSelectedSamples( shiftdown );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VK_UP:
|
||||
{
|
||||
bool shiftdown = GetAsyncKeyState( VK_SHIFT ) ? true : false;
|
||||
bool altdown = GetAsyncKeyState( VK_MENU ) ? true : false;
|
||||
if ( GetAsyncKeyState( VK_CONTROL ) )
|
||||
{
|
||||
ChangeCurveType( false, shiftdown, altdown );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VK_DOWN:
|
||||
{
|
||||
bool shiftdown = GetAsyncKeyState( VK_SHIFT ) ? true : false;
|
||||
bool altdown = GetAsyncKeyState( VK_MENU ) ? true : false;
|
||||
if ( GetAsyncKeyState( VK_CONTROL ) )
|
||||
{
|
||||
ChangeCurveType( true, shiftdown, altdown );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
#endif // CURVEEDITORHELPERS_H
|
||||
|
||||
660
utils/hlfaceposer/eventproperties.cpp
Normal file
660
utils/hlfaceposer/eventproperties.cpp
Normal file
@@ -0,0 +1,660 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "choreoevent.h"
|
||||
#include "choreoscene.h"
|
||||
#include "mathlib/mathlib.h"
|
||||
#include "choreochannel.h"
|
||||
#include "choreoactor.h"
|
||||
#include "FileSystem.h"
|
||||
#include "scriplib.h"
|
||||
|
||||
#include "eventproperties_expression.h"
|
||||
#include "eventproperties_face.h"
|
||||
#include "eventproperties_firetrigger.h"
|
||||
#include "eventproperties_flexanimation.h"
|
||||
#include "eventproperties_generic.h"
|
||||
#include "eventproperties_gesture.h"
|
||||
#include "eventproperties_interrupt.h"
|
||||
#include "eventproperties_lookat.h"
|
||||
#include "eventproperties_moveto.h"
|
||||
#include "eventproperties_permitresponses.h"
|
||||
#include "eventproperties_sequence.h"
|
||||
#include "eventproperties_speak.h"
|
||||
#include "eventproperties_subscene.h"
|
||||
#include "eventproperties_camera.h"
|
||||
|
||||
void CBaseEventPropertiesDialog::PopulateTagList( CEventParams *params )
|
||||
{
|
||||
CChoreoScene *scene = params->m_pScene;
|
||||
if ( !scene )
|
||||
return;
|
||||
|
||||
HWND control = GetControl( IDC_TAGS );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)va( "\"%s\" \"%s\"", params->m_szTagName, params->m_szTagWav ) );
|
||||
|
||||
for ( int i = 0; i < scene->GetNumActors(); i++ )
|
||||
{
|
||||
CChoreoActor *a = scene->GetActor( i );
|
||||
if ( !a )
|
||||
continue;
|
||||
|
||||
for ( int j = 0; j < a->GetNumChannels(); j++ )
|
||||
{
|
||||
CChoreoChannel *c = a->GetChannel( j );
|
||||
if ( !c )
|
||||
continue;
|
||||
|
||||
for ( int k = 0 ; k < c->GetNumEvents(); k++ )
|
||||
{
|
||||
CChoreoEvent *e = c->GetEvent( k );
|
||||
if ( !e )
|
||||
continue;
|
||||
|
||||
if ( e->GetNumRelativeTags() <= 0 )
|
||||
continue;
|
||||
|
||||
// add each tag to combo box
|
||||
for ( int t = 0; t < e->GetNumRelativeTags(); t++ )
|
||||
{
|
||||
CEventRelativeTag *tag = e->GetRelativeTag( t );
|
||||
if ( !tag )
|
||||
continue;
|
||||
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)va( "\"%s\" \"%s\"", tag->GetName(), e->GetParameters() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "mapentities.h"
|
||||
#include "UtlDict.h"
|
||||
|
||||
struct CMapEntityData
|
||||
{
|
||||
CMapEntityData()
|
||||
{
|
||||
origin.Init();
|
||||
angles.Init();
|
||||
}
|
||||
|
||||
Vector origin;
|
||||
QAngle angles;
|
||||
};
|
||||
|
||||
class CMapEntities : public IMapEntities
|
||||
{
|
||||
public:
|
||||
CMapEntities();
|
||||
~CMapEntities();
|
||||
|
||||
virtual void CheckUpdateMap( char const *mapname );
|
||||
virtual bool LookupOrigin( char const *name, Vector& origin, QAngle& angles )
|
||||
{
|
||||
int idx = FindNamedEntity( name );
|
||||
if ( idx == -1 )
|
||||
{
|
||||
origin.Init();
|
||||
angles.Init();
|
||||
return false;
|
||||
}
|
||||
|
||||
CMapEntityData *e = &m_Entities[ idx ];
|
||||
Assert( e );
|
||||
origin = e->origin;
|
||||
angles = e->angles;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int Count( void );
|
||||
virtual char const *GetName( int number );
|
||||
|
||||
int FindNamedEntity( char const *name );
|
||||
|
||||
private:
|
||||
char m_szCurrentMap[ 1024 ];
|
||||
|
||||
CUtlDict< CMapEntityData, int > m_Entities;
|
||||
};
|
||||
|
||||
static CMapEntities g_MapEntities;
|
||||
// Expose to rest of tool
|
||||
IMapEntities *mapentities = &g_MapEntities;
|
||||
|
||||
CMapEntities::CMapEntities()
|
||||
{
|
||||
m_szCurrentMap[ 0 ] = 0;
|
||||
}
|
||||
|
||||
CMapEntities::~CMapEntities()
|
||||
{
|
||||
m_Entities.RemoveAll();
|
||||
}
|
||||
|
||||
int CMapEntities::FindNamedEntity( char const *name )
|
||||
{
|
||||
char lowername[ 128 ];
|
||||
strcpy( lowername, name );
|
||||
_strlwr( lowername );
|
||||
|
||||
int index = m_Entities.Find( lowername );
|
||||
if ( index == m_Entities.InvalidIndex() )
|
||||
return -1;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
#include "bspfile.h"
|
||||
|
||||
void CMapEntities::CheckUpdateMap( char const *mapname )
|
||||
{
|
||||
if ( !mapname || !mapname[ 0 ] )
|
||||
return;
|
||||
|
||||
if ( !stricmp( mapname, m_szCurrentMap ) )
|
||||
return;
|
||||
|
||||
// Latch off the name of the map
|
||||
Q_strncpy( m_szCurrentMap, mapname, sizeof( m_szCurrentMap ) );
|
||||
|
||||
// Load names from map
|
||||
m_Entities.RemoveAll();
|
||||
|
||||
FileHandle_t hfile = filesystem->Open( mapname, "rb" );
|
||||
if ( hfile == FILESYSTEM_INVALID_HANDLE )
|
||||
return;
|
||||
|
||||
BSPHeader_t header;
|
||||
filesystem->Read( &header, sizeof( header ), hfile );
|
||||
|
||||
// Check the header
|
||||
if ( header.ident != IDBSPHEADER ||
|
||||
header.m_nVersion < MINBSPVERSION || header.m_nVersion > BSPVERSION )
|
||||
{
|
||||
Con_ErrorPrintf( "BSP file %s is wrong version (%i), expected (%i)\n",
|
||||
mapname,
|
||||
header.m_nVersion,
|
||||
BSPVERSION );
|
||||
|
||||
filesystem->Close( hfile );
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the LUMP_PAKFILE offset
|
||||
lump_t *entlump = &header.lumps[ LUMP_ENTITIES ];
|
||||
if ( entlump->filelen <= 0 )
|
||||
{
|
||||
Con_ErrorPrintf( "BSP file %s is missing entity lump\n", mapname );
|
||||
|
||||
// It's empty or only contains a file header ( so there are no entries ), so don't add to search paths
|
||||
filesystem->Close( hfile );
|
||||
return;
|
||||
}
|
||||
|
||||
// Seek to correct position
|
||||
filesystem->Seek( hfile, entlump->fileofs, FILESYSTEM_SEEK_HEAD );
|
||||
|
||||
char *buffer = new char[ entlump->filelen + 1 ];
|
||||
Assert( buffer );
|
||||
|
||||
filesystem->Read( buffer, entlump->filelen, hfile );
|
||||
|
||||
filesystem->Close( hfile );
|
||||
|
||||
buffer[ entlump->filelen ] = 0;
|
||||
|
||||
// Now we have entity buffer, now parse it
|
||||
ParseFromMemory( buffer, entlump->filelen );
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if (!GetToken (true))
|
||||
break;
|
||||
|
||||
if (Q_stricmp (token, "{") )
|
||||
Error ("ParseEntity: { not found");
|
||||
|
||||
char name[ 256 ];
|
||||
char origin[ 256 ];
|
||||
char angles[ 256 ];
|
||||
|
||||
name[ 0 ] = 0;
|
||||
origin[ 0 ] = 0;
|
||||
angles[ 0 ] = 0;
|
||||
|
||||
do
|
||||
{
|
||||
char key[ 256 ];
|
||||
char value[ 256 ];
|
||||
|
||||
if (!GetToken (true))
|
||||
{
|
||||
Error ("ParseEntity: EOF without closing brace");
|
||||
}
|
||||
|
||||
if (!Q_stricmp (token, "}") )
|
||||
break;
|
||||
|
||||
Q_strncpy( key, token, sizeof( key ) );
|
||||
|
||||
GetToken (false);
|
||||
|
||||
Q_strncpy( value, token, sizeof( value ) );
|
||||
|
||||
// Con_Printf( "Parsed %s -- %s\n", key, value );
|
||||
|
||||
if ( !Q_stricmp( key, "name" ) )
|
||||
{
|
||||
Q_strncpy( name, value, sizeof( name ) );
|
||||
}
|
||||
if ( !Q_stricmp( key, "targetname" ) )
|
||||
{
|
||||
Q_strncpy( name, value, sizeof( name ) );
|
||||
}
|
||||
if ( !Q_stricmp( key, "origin" ) )
|
||||
{
|
||||
Q_strncpy( origin, value, sizeof( origin ) );
|
||||
}
|
||||
if ( !Q_stricmp( key, "angles" ) )
|
||||
{
|
||||
Q_strncpy( angles, value, sizeof( angles ) );
|
||||
}
|
||||
|
||||
} while (1);
|
||||
|
||||
if ( name[ 0 ] )
|
||||
{
|
||||
if ( FindNamedEntity( name ) == - 1 )
|
||||
{
|
||||
CMapEntityData ent;
|
||||
|
||||
float org[3];
|
||||
if ( origin[ 0 ] )
|
||||
{
|
||||
if ( 3 == sscanf( origin, "%f %f %f", &org[ 0 ], &org[ 1 ], &org[ 2 ] ) )
|
||||
{
|
||||
ent.origin = Vector( org[ 0 ], org[ 1 ], org[ 2 ] );
|
||||
|
||||
// Con_Printf( "read %f %f %f for entity %s\n", org[0], org[1], org[2], name );
|
||||
}
|
||||
}
|
||||
if ( angles[ 0 ] )
|
||||
{
|
||||
if ( 3 == sscanf( angles, "%f %f %f", &org[ 0 ], &org[ 1 ], &org[ 2 ] ) )
|
||||
{
|
||||
ent.angles = QAngle( org[ 0 ], org[ 1 ], org[ 2 ] );
|
||||
|
||||
// Con_Printf( "read %f %f %f for entity %s\n", org[0], org[1], org[2], name );
|
||||
}
|
||||
}
|
||||
|
||||
m_Entities.Insert( name, ent );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
int CMapEntities::Count( void )
|
||||
{
|
||||
return m_Entities.Count();
|
||||
}
|
||||
|
||||
char const *CMapEntities::GetName( int number )
|
||||
{
|
||||
if ( number < 0 || number >= (int)m_Entities.Count() )
|
||||
return NULL;
|
||||
|
||||
return m_Entities.GetElementName( number );
|
||||
}
|
||||
|
||||
bool NameLessFunc( const char *const& name1, const char *const& name2 )
|
||||
{
|
||||
if ( Q_stricmp( name1, name2 ) < 0 )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CBaseEventPropertiesDialog::SetDialogTitle( CEventParams *params, char const *eventname, char const *desc )
|
||||
{
|
||||
char sz[ 256 ];
|
||||
Q_snprintf( sz, sizeof( sz ), " : %s", eventname );
|
||||
Q_strncat( params->m_szDialogTitle, sz, sizeof( params->m_szDialogTitle ), COPY_ALL_CHARACTERS );
|
||||
Q_snprintf( sz, sizeof( sz ), "%s:", desc );
|
||||
|
||||
// Set dialog title
|
||||
SetWindowText( m_hDialog, params->m_szDialogTitle );
|
||||
// Set type name field
|
||||
SetDlgItemText( m_hDialog, IDC_TYPENAME, sz );
|
||||
// Set event name
|
||||
SetDlgItemText( m_hDialog, IDC_EVENTNAME, params->m_szName );
|
||||
}
|
||||
|
||||
void CBaseEventPropertiesDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
// Special processing for various settings
|
||||
if ( !params->m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
|
||||
if ( params->m_bFixedLength )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
ShowWindow( GetControl( IDC_CHECK_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseEventPropertiesDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
SetDlgItemText( m_hDialog, IDC_STARTTIME, va( "%f", params->m_flStartTime ) );
|
||||
SetDlgItemText( m_hDialog, IDC_ENDTIME, va( "%f", params->m_flEndTime ) );
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_SETCHECK,
|
||||
( WPARAM ) params->m_bHasEndTime ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
if ( GetControl( IDC_CHECK_RESUMECONDITION ) != (HWND)0 )
|
||||
{
|
||||
SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_SETCHECK,
|
||||
( WPARAM ) params->m_bResumeCondition ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
}
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_DISABLED ), BM_SETCHECK,
|
||||
( WPARAM ) params->m_bDisabled ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
PopulateTagList( params );
|
||||
}
|
||||
|
||||
BOOL CBaseEventPropertiesDialog::InternalHandleMessage( CEventParams *params, HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& handled )
|
||||
{
|
||||
handled = false;
|
||||
switch(uMsg)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case IDC_CHECK_DISABLED:
|
||||
{
|
||||
params->m_bDisabled = SendMessage( GetControl( IDC_CHECK_DISABLED ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
handled = true;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CBaseEventPropertiesDialog::PopulateNamedActorList( HWND wnd, CEventParams *params )
|
||||
{
|
||||
int i;
|
||||
|
||||
char const *mapname = NULL;
|
||||
if ( params->m_pScene )
|
||||
{
|
||||
mapname = params->m_pScene->GetMapname();
|
||||
}
|
||||
|
||||
CUtlRBTree< char const *, int > m_SortedNames( 0, 0, NameLessFunc );
|
||||
|
||||
if ( mapname )
|
||||
{
|
||||
g_MapEntities.CheckUpdateMap( mapname );
|
||||
|
||||
for ( i = 0; i < g_MapEntities.Count(); i++ )
|
||||
{
|
||||
char const *name = g_MapEntities.GetName( i );
|
||||
if ( name && name[ 0 ] )
|
||||
{
|
||||
m_SortedNames.Insert( name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < params->m_pScene->GetNumActors() ; i++ )
|
||||
{
|
||||
CChoreoActor *actor = params->m_pScene->GetActor( i );
|
||||
if ( actor && actor->GetName() && actor->GetName()[0] )
|
||||
{
|
||||
if ( m_SortedNames.Find( actor->GetName() ) == m_SortedNames.InvalidIndex() )
|
||||
{
|
||||
m_SortedNames.Insert( actor->GetName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = m_SortedNames.FirstInorder();
|
||||
while ( i != m_SortedNames.InvalidIndex() )
|
||||
{
|
||||
char const *name = m_SortedNames[ i ];
|
||||
if ( name && name[ 0 ] )
|
||||
{
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)name );
|
||||
}
|
||||
|
||||
i = m_SortedNames.NextInorder( i );
|
||||
}
|
||||
|
||||
/*
|
||||
// Note have to do this here, after posting data to the control, since we are storing a raw string pointer in m_SortedNames!!!
|
||||
if ( allActors )
|
||||
{
|
||||
allActors->deleteThis();
|
||||
}
|
||||
*/
|
||||
|
||||
// These events can also be directed at another player or named target, too
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!player" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!enemy" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!self" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!friend" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!speechtarget" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target1" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target2" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target3" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target4" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target5" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target6" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target7" );
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)"!target8" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static void
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseEventPropertiesDialog::ParseTags( CEventParams *params )
|
||||
{
|
||||
strcpy( params->m_szTagName, "" );
|
||||
strcpy( params->m_szTagWav, "" );
|
||||
|
||||
if ( params->m_bUsesTag )
|
||||
{
|
||||
// Parse out the two tokens
|
||||
char selectedText[ 512 ];
|
||||
selectedText[ 0 ] = 0;
|
||||
HWND control = GetControl( IDC_TAGS );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( selectedText ), (LPARAM)selectedText );
|
||||
}
|
||||
|
||||
ParseFromMemory( selectedText, strlen( selectedText ) );
|
||||
if ( TokenAvailable() )
|
||||
{
|
||||
GetToken( false );
|
||||
char tagname[ 256 ];
|
||||
strcpy( tagname, token );
|
||||
if ( TokenAvailable() )
|
||||
{
|
||||
GetToken( false );
|
||||
char wavename[ 256 ];
|
||||
strcpy( wavename, token );
|
||||
|
||||
// Valid
|
||||
strcpy( params->m_szTagName, tagname );
|
||||
strcpy( params->m_szTagWav, wavename );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
params->m_bUsesTag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
params->m_bUsesTag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static void
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseEventPropertiesDialog::UpdateTagRadioButtons( CEventParams *params )
|
||||
{
|
||||
if ( params->m_bUsesTag )
|
||||
{
|
||||
SendMessage( GetControl( IDC_RELATIVESTART ), BM_SETCHECK, ( WPARAM )BST_CHECKED, (LPARAM)0 );
|
||||
SendMessage( GetControl( IDC_ABSOLUTESTART ), BM_SETCHECK, ( WPARAM )BST_UNCHECKED, (LPARAM)0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage( GetControl( IDC_ABSOLUTESTART ), BM_SETCHECK, ( WPARAM )BST_CHECKED, (LPARAM)0 );
|
||||
SendMessage( GetControl( IDC_RELATIVESTART ), BM_SETCHECK, ( WPARAM )BST_UNCHECKED, (LPARAM)0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseEventPropertiesDialog::GetSplineRect( HWND placeholder, RECT& rcOut )
|
||||
{
|
||||
GetWindowRect( placeholder, &rcOut );
|
||||
RECT rcDlg;
|
||||
GetWindowRect( m_hDialog, &rcDlg );
|
||||
|
||||
OffsetRect( &rcOut, -rcDlg.left, -rcDlg.top );
|
||||
}
|
||||
|
||||
void CBaseEventPropertiesDialog::DrawSpline( HDC hdc, HWND placeholder, CChoreoEvent *e )
|
||||
{
|
||||
RECT rcOut;
|
||||
|
||||
GetSplineRect( placeholder, rcOut );
|
||||
|
||||
HBRUSH bg = CreateSolidBrush( GetSysColor( COLOR_BTNFACE ) );
|
||||
FillRect( hdc, &rcOut, bg );
|
||||
DeleteObject( bg );
|
||||
|
||||
if ( !e )
|
||||
return;
|
||||
|
||||
// Draw spline
|
||||
float range = ( float )( rcOut.right - rcOut.left );
|
||||
if ( range <= 1.0f )
|
||||
return;
|
||||
|
||||
float height = ( float )( rcOut.bottom - rcOut.top );
|
||||
|
||||
HPEN pen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNTEXT ) );
|
||||
HPEN oldPen = (HPEN)SelectObject( hdc, pen );
|
||||
|
||||
float duration = e->GetDuration();
|
||||
float starttime = e->GetStartTime();
|
||||
|
||||
for ( int i = 0; i < (int)range; i++ )
|
||||
{
|
||||
float frac = ( float )i / ( range - 1 );
|
||||
|
||||
float scale = 1.0f - e->GetIntensity( starttime + frac * duration );
|
||||
|
||||
int h = ( int ) ( scale * ( height - 1 ) );
|
||||
|
||||
if ( i == 0 )
|
||||
{
|
||||
MoveToEx( hdc, rcOut.left + i, rcOut.top + h, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
LineTo( hdc, rcOut.left + i, rcOut.top + h );
|
||||
}
|
||||
}
|
||||
|
||||
SelectObject( hdc, oldPen );
|
||||
|
||||
HBRUSH frame = CreateSolidBrush( GetSysColor( COLOR_BTNSHADOW ) );
|
||||
InflateRect( &rcOut, 1, 1 );
|
||||
FrameRect( hdc, &rcOut, frame );
|
||||
DeleteObject( frame );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties( CEventParams *params )
|
||||
{
|
||||
int iret = 1;
|
||||
switch ( params->m_nType )
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case CChoreoEvent::EXPRESSION:
|
||||
return EventProperties_Expression( params );
|
||||
case CChoreoEvent::LOOKAT:
|
||||
return EventProperties_LookAt( params );
|
||||
case CChoreoEvent::MOVETO:
|
||||
return EventProperties_MoveTo( params );
|
||||
case CChoreoEvent::SPEAK:
|
||||
return EventProperties_Speak( params );
|
||||
case CChoreoEvent::GESTURE:
|
||||
return EventProperties_Gesture( params );
|
||||
case CChoreoEvent::SEQUENCE:
|
||||
return EventProperties_Sequence( params );
|
||||
case CChoreoEvent::FACE:
|
||||
return EventProperties_Face( params );
|
||||
case CChoreoEvent::FIRETRIGGER:
|
||||
return EventProperties_FireTrigger( params );
|
||||
case CChoreoEvent::FLEXANIMATION:
|
||||
return EventProperties_FlexAnimation( params );
|
||||
case CChoreoEvent::SUBSCENE:
|
||||
return EventProperties_SubScene( params );
|
||||
case CChoreoEvent::INTERRUPT:
|
||||
return EventProperties_Interrupt( params );
|
||||
case CChoreoEvent::PERMIT_RESPONSES:
|
||||
return EventProperties_PermitResponses( params );
|
||||
case CChoreoEvent::GENERIC:
|
||||
return EventProperties_Generic( params );
|
||||
case CChoreoEvent::CAMERA:
|
||||
return EventProperties_Camera( params );
|
||||
}
|
||||
|
||||
return iret;
|
||||
}
|
||||
105
utils/hlfaceposer/eventproperties.h
Normal file
105
utils/hlfaceposer/eventproperties.h
Normal file
@@ -0,0 +1,105 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_H
|
||||
#define EVENTPROPERTIES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
class CChoreoScene;
|
||||
class CChoreoEvent;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CEventParams : public CBaseDialogParams
|
||||
{
|
||||
public:
|
||||
// e.g. CChoreoEvent::GESTURE
|
||||
int m_nType;
|
||||
|
||||
// Event descriptive name
|
||||
char m_szName[ 256 ];
|
||||
|
||||
// Expression name/wav name/gesture name/look at name
|
||||
char m_szParameters[ 256 ];
|
||||
char m_szParameters2[ 256 ];
|
||||
char m_szParameters3[ 256 ];
|
||||
|
||||
CChoreoScene *m_pScene;
|
||||
|
||||
float m_flStartTime;
|
||||
float m_flEndTime;
|
||||
bool m_bHasEndTime;
|
||||
|
||||
CChoreoEvent *m_pEvent;
|
||||
|
||||
bool m_bDisabled;
|
||||
bool m_bFixedLength;
|
||||
|
||||
bool m_bResumeCondition;
|
||||
|
||||
bool m_bLockBodyFacing;
|
||||
float m_flDistanceToTarget;
|
||||
|
||||
bool m_bForceShortMovement;
|
||||
|
||||
bool m_bSyncToFollowingGesture;
|
||||
|
||||
bool m_bPlayOverScript;
|
||||
|
||||
bool m_bUsesTag;
|
||||
char m_szTagName[ 256 ];
|
||||
char m_szTagWav[ 256 ];
|
||||
|
||||
// For Lookat events
|
||||
int pitch;
|
||||
int yaw;
|
||||
bool usepitchyaw;
|
||||
|
||||
// For speak
|
||||
bool m_bCloseCaptionNoAttenuate;
|
||||
|
||||
};
|
||||
|
||||
int EventProperties( CEventParams *params );
|
||||
|
||||
class CBaseEventPropertiesDialog
|
||||
{
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg ) = 0;
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) = 0;
|
||||
virtual void SetTitle() = 0;
|
||||
|
||||
HWND GetControl( int id ) { return GetDlgItem( m_hDialog, id ); }
|
||||
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
protected:
|
||||
virtual BOOL InternalHandleMessage( CEventParams *params, HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& handled );
|
||||
|
||||
void SetDialogTitle( CEventParams *params, char const *eventname, char const *desc );
|
||||
|
||||
void UpdateTagRadioButtons( CEventParams *params );
|
||||
void PopulateTagList( CEventParams *params );
|
||||
void ParseTags( CEventParams *params );
|
||||
|
||||
void PopulateNamedActorList( HWND wnd, CEventParams *params );
|
||||
|
||||
void GetSplineRect( HWND placeholder, RECT& rcOut );
|
||||
void DrawSpline( HDC hdc, HWND placeholder, CChoreoEvent *e );
|
||||
|
||||
protected:
|
||||
|
||||
HWND m_hDialog;
|
||||
};
|
||||
|
||||
#endif // EVENTPROPERTIES_H
|
||||
291
utils/hlfaceposer/eventproperties_camera.cpp
Normal file
291
utils/hlfaceposer/eventproperties_camera.cpp
Normal file
@@ -0,0 +1,291 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "choreoevent.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesCameraDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
|
||||
void PopulateCamera( HWND control, CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesCameraDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Camera", "Camera AI Event (text)" );
|
||||
}
|
||||
|
||||
void CEventPropertiesCameraDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
HWND choices2 = GetControl( IDC_EVENTCHOICES2 );
|
||||
SendMessage( choices2, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices2, WM_SETTEXT , 0, (LPARAM)params->m_szParameters2 );
|
||||
|
||||
HWND choices3 = GetControl( IDC_EVENTCHOICES3 );
|
||||
SendMessage( choices3, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices3, WM_SETTEXT , 0, (LPARAM)params->m_szParameters3 );
|
||||
|
||||
SendMessage( GetControl( IDC_FILENAME ), WM_SETTEXT, sizeof( params->m_szParameters ), (LPARAM)params->m_szParameters );
|
||||
|
||||
PopulateCamera( choices1, params );
|
||||
PopulateNamedActorList( choices2, params );
|
||||
PopulateNamedActorList( choices3, params );
|
||||
}
|
||||
|
||||
void CEventPropertiesCameraDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesCameraDialog g_EventPropertiesCameraDialog;
|
||||
|
||||
void CEventPropertiesCameraDialog::PopulateCamera( HWND control, CEventParams *params )
|
||||
{
|
||||
// FIXME: this should load from a config file
|
||||
/*
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_BLINK" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_HOLSTER" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_UNHOLSTER" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_AIM" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMLOOK" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMFACEFLEX" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMHEADFLEX" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_IGNORECOLLISION" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_DISABLEAI" );
|
||||
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesCameraDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesCameraDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesCameraDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesCameraDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "%s", g_Params.m_szParameters );
|
||||
if ( g_Params.m_szParameters2[ 0 ] )
|
||||
{
|
||||
char szAdd[ 512 ];
|
||||
Q_snprintf( szAdd, sizeof( szAdd ), " to %s", g_Params.m_szParameters2 );
|
||||
Q_strncat( g_Params.m_szName, szAdd, sizeof( g_Params.m_szName ), COPY_ALL_CHARACTERS );
|
||||
}
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES2:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
char buf1[ 256 ];
|
||||
|
||||
SendMessage( GetControl( IDC_EVENTCHOICES2 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
|
||||
|
||||
Q_snprintf( g_Params.m_szParameters2, sizeof( g_Params.m_szParameters2 ), "%s", buf1 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES3:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
char buf1[ 256 ];
|
||||
|
||||
SendMessage( GetControl( IDC_EVENTCHOICES3 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
|
||||
|
||||
Q_snprintf( g_Params.m_szParameters3, sizeof( g_Params.m_szParameters3 ), "%s", buf1 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Camera( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_CAMERA ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesCameraDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_camera.h
Normal file
18
utils/hlfaceposer/eventproperties_camera.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_CAMERA_H
|
||||
#define EVENTPROPERTIES_CAMERA_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Camera( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_CAMERA_H
|
||||
298
utils/hlfaceposer/eventproperties_expression.cpp
Normal file
298
utils/hlfaceposer/eventproperties_expression.cpp
Normal file
@@ -0,0 +1,298 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "choreoevent.h"
|
||||
#include "expressions.h"
|
||||
#include "expclass.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesExpressionDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
private:
|
||||
|
||||
void PopulateExpressionList( HWND wnd );
|
||||
void PopulateExpressionClass( HWND control, CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesExpressionDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Expression", "Expression" );
|
||||
}
|
||||
|
||||
void CEventPropertiesExpressionDialog::PopulateExpressionList( HWND wnd )
|
||||
{
|
||||
for ( int i = 0 ; i < expressions->GetNumClasses() ; i++ )
|
||||
{
|
||||
CExpClass *cl = expressions->GetClass( i );
|
||||
if( !cl )
|
||||
continue;
|
||||
|
||||
// add text to combo box
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)cl->GetName() );
|
||||
}
|
||||
}
|
||||
|
||||
void CEventPropertiesExpressionDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
HWND choices2 = GetControl( IDC_EVENTCHOICES2 );
|
||||
SendMessage( choices2, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices2, WM_SETTEXT , 0, (LPARAM)params->m_szParameters2 );
|
||||
|
||||
PopulateExpressionList( choices1 );
|
||||
SendMessage( GetControl( IDC_CHOICES2PROMPT ), WM_SETTEXT, 0, (LPARAM)"Name:" );
|
||||
PopulateExpressionClass( choices2, params );
|
||||
}
|
||||
|
||||
void CEventPropertiesExpressionDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesExpressionDialog g_EventPropertiesExpressionDialog;
|
||||
|
||||
void CEventPropertiesExpressionDialog::PopulateExpressionClass( HWND control, CEventParams *params )
|
||||
{
|
||||
// Find parameter 1
|
||||
for ( int c = 0; c < expressions->GetNumClasses(); c++ )
|
||||
{
|
||||
CExpClass *cl = expressions->GetClass( c );
|
||||
if ( !cl )
|
||||
continue;
|
||||
|
||||
if ( Q_stricmp( cl->GetName(), params->m_szParameters ) )
|
||||
continue;
|
||||
|
||||
for ( int i = 0 ; i < cl->GetNumExpressions() ; i++ )
|
||||
{
|
||||
CExpression *exp = cl->GetExpression( i );
|
||||
if ( exp )
|
||||
{
|
||||
// add text to combo box
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)exp->name );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesExpressionDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesExpressionDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesExpressionDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesExpressionDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "%s/%s", g_Params.m_szParameters, g_Params.m_szParameters2 );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
|
||||
PopulateExpressionClass( GetControl( IDC_EVENTCHOICES2 ), &g_Params );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES2:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
if ( g_Params.m_nType != CChoreoEvent::MOVETO )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters2 ), (LPARAM)g_Params.m_szParameters2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf1[ 256 ];
|
||||
|
||||
SendMessage( GetControl( IDC_EVENTCHOICES2 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
|
||||
|
||||
Q_snprintf( g_Params.m_szParameters2, sizeof( g_Params.m_szParameters2 ), "%s", buf1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Expression( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_EXPRESSION ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesExpressionDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_expression.h
Normal file
18
utils/hlfaceposer/eventproperties_expression.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_EXPRESSION_H
|
||||
#define EVENTPROPERTIES_EXPRESSION_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Expression( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_EXPRESSION_H
|
||||
234
utils/hlfaceposer/eventproperties_face.cpp
Normal file
234
utils/hlfaceposer/eventproperties_face.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesFaceDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesFaceDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Face", "Face Actor" );
|
||||
}
|
||||
|
||||
void CEventPropertiesFaceDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
PopulateNamedActorList( choices1, params );
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_LOCKBODYFACING ), BM_SETCHECK,
|
||||
( WPARAM ) params->m_bLockBodyFacing ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CEventPropertiesFaceDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesFaceDialog g_EventPropertiesFaceDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesFaceDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesFaceDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesFaceDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesFaceDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "Face %s", g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_LOCKBODYFACING:
|
||||
{
|
||||
g_Params.m_bLockBodyFacing = SendMessage( GetControl( IDC_CHECK_LOCKBODYFACING ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Face( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_FACE ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesFaceDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_face.h
Normal file
18
utils/hlfaceposer/eventproperties_face.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_FACE_H
|
||||
#define EVENTPROPERTIES_FACE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Face( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_FACE_H
|
||||
240
utils/hlfaceposer/eventproperties_firetrigger.cpp
Normal file
240
utils/hlfaceposer/eventproperties_firetrigger.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesFireTriggerDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
|
||||
void PopulateTriggerList( HWND wnd );
|
||||
};
|
||||
|
||||
void CEventPropertiesFireTriggerDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "FireTrigger", "Scene Trigger" );
|
||||
}
|
||||
|
||||
void CEventPropertiesFireTriggerDialog::PopulateTriggerList( HWND wnd )
|
||||
{
|
||||
for ( int i = 0 ; i < 16; i++ )
|
||||
{
|
||||
char szName[256];
|
||||
|
||||
sprintf( szName, "%d", i + 1 );
|
||||
|
||||
// add text to combo box
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)szName );
|
||||
}
|
||||
}
|
||||
|
||||
void CEventPropertiesFireTriggerDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
PopulateTriggerList( choices1 );
|
||||
}
|
||||
|
||||
void CEventPropertiesFireTriggerDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesFireTriggerDialog g_EventPropertiesFireTriggerDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesFireTriggerDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesFireTriggerDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesFireTriggerDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesFireTriggerDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "Firetrigger %s", g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_FireTrigger( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_FIRETRIGGER ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesFireTriggerDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_firetrigger.h
Normal file
18
utils/hlfaceposer/eventproperties_firetrigger.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_FIRETRIGGER_H
|
||||
#define EVENTPROPERTIES_FIRETRIGGER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_FireTrigger( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_FIRETRIGGER_H
|
||||
203
utils/hlfaceposer/eventproperties_flexanimation.cpp
Normal file
203
utils/hlfaceposer/eventproperties_flexanimation.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesFlexAnimationDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesFlexAnimationDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "FlexAnimation", "Flex Controller Animation" );
|
||||
}
|
||||
|
||||
void CEventPropertiesFlexAnimationDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
}
|
||||
|
||||
void CEventPropertiesFlexAnimationDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesFlexAnimationDialog g_EventPropertiesFlexAnimationDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesFlexAnimationDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesFlexAnimationDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesFlexAnimationDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesFlexAnimationDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szName, "Facial Animation", sizeof( g_Params.m_szName ) );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_FlexAnimation( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_FLEXANIMATION ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesFlexAnimationDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_flexanimation.h
Normal file
18
utils/hlfaceposer/eventproperties_flexanimation.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_FLEXANIMATION_H
|
||||
#define EVENTPROPERTIES_FLEXANIMATION_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_FlexAnimation( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_FLEXANIMATION_H
|
||||
278
utils/hlfaceposer/eventproperties_generic.cpp
Normal file
278
utils/hlfaceposer/eventproperties_generic.cpp
Normal file
@@ -0,0 +1,278 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "choreoevent.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesGenericDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
|
||||
void PopulateAIGeneric( HWND control, CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesGenericDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Generic", "Generic AI Event (text)" );
|
||||
}
|
||||
|
||||
void CEventPropertiesGenericDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
HWND choices2 = GetControl( IDC_EVENTCHOICES2 );
|
||||
SendMessage( choices2, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices2, WM_SETTEXT , 0, (LPARAM)params->m_szParameters2 );
|
||||
|
||||
SendMessage( GetControl( IDC_FILENAME ), WM_SETTEXT, sizeof( params->m_szParameters ), (LPARAM)params->m_szParameters );
|
||||
|
||||
PopulateAIGeneric( choices1, params );
|
||||
PopulateNamedActorList( choices2, params );
|
||||
}
|
||||
|
||||
void CEventPropertiesGenericDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesGenericDialog g_EventPropertiesGenericDialog;
|
||||
|
||||
void CEventPropertiesGenericDialog::PopulateAIGeneric( HWND control, CEventParams *params )
|
||||
{
|
||||
// FIXME: this should load from a config file
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_BLINK" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_HOLSTER" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_UNHOLSTER" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_AIM" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMLOOK" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMFACEFLEX" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_RANDOMHEADFLEX" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_IGNORECOLLISION" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"AI_DISABLEAI" );
|
||||
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesGenericDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesGenericDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesGenericDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesGenericDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "%s", g_Params.m_szParameters );
|
||||
if ( g_Params.m_szParameters2[ 0 ] )
|
||||
{
|
||||
char szAdd[ 512 ];
|
||||
Q_snprintf( szAdd, sizeof( szAdd ), " to %s", g_Params.m_szParameters2 );
|
||||
Q_strncat( g_Params.m_szName, szAdd, sizeof( g_Params.m_szName ), COPY_ALL_CHARACTERS );
|
||||
}
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES2:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
if ( g_Params.m_nType != CChoreoEvent::MOVETO )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters2 ), (LPARAM)g_Params.m_szParameters2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf1[ 256 ];
|
||||
|
||||
SendMessage( GetControl( IDC_EVENTCHOICES2 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
|
||||
|
||||
Q_snprintf( g_Params.m_szParameters2, sizeof( g_Params.m_szParameters2 ), "%s", buf1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Generic( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_GENERIC ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesGenericDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_generic.h
Normal file
18
utils/hlfaceposer/eventproperties_generic.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_GENERIC_H
|
||||
#define EVENTPROPERTIES_GENERIC_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Generic( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_GENERIC_H
|
||||
297
utils/hlfaceposer/eventproperties_gesture.cpp
Normal file
297
utils/hlfaceposer/eventproperties_gesture.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "choreoevent.h"
|
||||
#include "StudioModel.h"
|
||||
#include "faceposer_models.h"
|
||||
#include "KeyValues.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesGestureDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
void PopulateGestureList( HWND wnd );
|
||||
|
||||
bool CheckSequenceType( StudioModel *model, int iSequence, char *szType );
|
||||
};
|
||||
|
||||
void CEventPropertiesGestureDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Gesture", "Gesture" );
|
||||
}
|
||||
|
||||
void CEventPropertiesGestureDialog::PopulateGestureList( HWND wnd )
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < hdr->GetNumSeq(); i++)
|
||||
{
|
||||
if (CheckSequenceType( models->GetActiveStudioModel(), i, "gesture" ))
|
||||
{
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)hdr->pSeqdesc(i).pszLabel() );
|
||||
}
|
||||
}
|
||||
for (i = 0; i < hdr->GetNumSeq(); i++)
|
||||
{
|
||||
if (CheckSequenceType( models->GetActiveStudioModel(), i, "posture" ))
|
||||
{
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)hdr->pSeqdesc(i).pszLabel() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEventPropertiesGestureDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_SYNCTOFOLLOWINGGESTURE ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bSyncToFollowingGesture ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
PopulateGestureList( choices1 );
|
||||
}
|
||||
|
||||
void CEventPropertiesGestureDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesGestureDialog g_EventPropertiesGestureDialog;
|
||||
|
||||
bool CEventPropertiesGestureDialog::CheckSequenceType( StudioModel *model, int iSequence, char *szType )
|
||||
{
|
||||
KeyValues *seqKeyValues = new KeyValues("");
|
||||
bool isType = false;
|
||||
if ( seqKeyValues->LoadFromBuffer( model->GetFileName( ), model->GetKeyValueText( iSequence ) ) )
|
||||
{
|
||||
// Do we have a build point section?
|
||||
KeyValues *pkvAllFaceposer = seqKeyValues->FindKey("faceposer");
|
||||
if ( pkvAllFaceposer )
|
||||
{
|
||||
KeyValues *pkvType = pkvAllFaceposer->FindKey("type");
|
||||
|
||||
if (pkvType)
|
||||
{
|
||||
isType = (stricmp( pkvType->GetString(), szType ) == 0) ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
seqKeyValues->deleteThis();
|
||||
|
||||
return isType;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesGestureDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
|
||||
// NULL Gesture doesn't have these controls either
|
||||
if ( g_Params.m_nType == CChoreoEvent::GESTURE &&
|
||||
!Q_stricmp( g_Params.m_szName, "NULL" ) )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_EVENTNAME ), SW_HIDE );
|
||||
ShowWindow( GetControl( IDC_TAGS ), SW_HIDE );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesGestureDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesGestureDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesGestureDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szName, g_Params.m_szParameters, sizeof( g_Params.m_szName ) );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_SYNCTOFOLLOWINGGESTURE:
|
||||
{
|
||||
g_Params.m_bSyncToFollowingGesture = SendMessage( GetControl( IDC_CHECK_SYNCTOFOLLOWINGGESTURE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Gesture( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_GESTURE ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesGestureDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_gesture.h
Normal file
18
utils/hlfaceposer/eventproperties_gesture.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_GESTURE_H
|
||||
#define EVENTPROPERTIES_GESTURE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Gesture( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_GESTURE_H
|
||||
217
utils/hlfaceposer/eventproperties_interrupt.cpp
Normal file
217
utils/hlfaceposer/eventproperties_interrupt.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesInterruptDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesInterruptDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Interrupt", "Interrupt" );
|
||||
}
|
||||
|
||||
void CEventPropertiesInterruptDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
}
|
||||
|
||||
void CEventPropertiesInterruptDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesInterruptDialog g_EventPropertiesInterruptDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesInterruptDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesInterruptDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesInterruptDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesInterruptDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szName, "Interrupt", sizeof( g_Params.m_szName ) );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Interrupt( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_INTERRUPT ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesInterruptDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_interrupt.h
Normal file
18
utils/hlfaceposer/eventproperties_interrupt.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_INTERRUPT_H
|
||||
#define EVENTPROPERTIES_INTERRUPT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Interrupt( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_INTERRUPT_H
|
||||
327
utils/hlfaceposer/eventproperties_lookat.cpp
Normal file
327
utils/hlfaceposer/eventproperties_lookat.cpp
Normal file
@@ -0,0 +1,327 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include <commctrl.h>
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesLookAtDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
|
||||
void SetupLookAtControls( CEventParams *params );
|
||||
void SetPitchYawText( CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesLookAtDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "LookAt", "Look At Actor" );
|
||||
}
|
||||
|
||||
void CEventPropertiesLookAtDialog::SetupLookAtControls( CEventParams *params )
|
||||
{
|
||||
SetPitchYawText( params );
|
||||
|
||||
if ( params->pitch != 0 ||
|
||||
params->yaw != 0 )
|
||||
{
|
||||
params->usepitchyaw = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
params->usepitchyaw = false;
|
||||
}
|
||||
|
||||
HWND control = GetControl( IDC_CHECK_LOOKAT );
|
||||
SendMessage( control, BM_SETCHECK, (WPARAM) params->usepitchyaw ? BST_CHECKED : BST_UNCHECKED, 0 );
|
||||
|
||||
// Set up sliders
|
||||
control = GetControl( IDC_SLIDER_PITCH );
|
||||
SendMessage( control, TBM_SETRANGE, 0, (LPARAM)MAKELONG( -100, 100 ) );
|
||||
SendMessage( control, TBM_SETPOS, 1, (LPARAM)(LONG)params->pitch );
|
||||
|
||||
control = GetControl( IDC_SLIDER_YAW );
|
||||
SendMessage( control, TBM_SETRANGE, 0, (LPARAM)MAKELONG( -100, 100 ) );
|
||||
SendMessage( control, TBM_SETPOS, 1, (LPARAM)(LONG)params->yaw );
|
||||
}
|
||||
|
||||
void CEventPropertiesLookAtDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
SetDlgItemText( m_hDialog, IDC_STARTTIME, va( "%f", g_Params.m_flStartTime ) );
|
||||
SetDlgItemText( m_hDialog, IDC_ENDTIME, va( "%f", g_Params.m_flEndTime ) );
|
||||
SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bHasEndTime ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bResumeCondition ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
PopulateTagList( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
SetupLookAtControls( params );
|
||||
PopulateNamedActorList( choices1, params );
|
||||
}
|
||||
|
||||
void CEventPropertiesLookAtDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesLookAtDialog g_EventPropertiesLookAtDialog;
|
||||
|
||||
void CEventPropertiesLookAtDialog::SetPitchYawText( CEventParams *params )
|
||||
{
|
||||
HWND control;
|
||||
|
||||
control = GetControl( IDC_STATIC_PITCHVAL );
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)va( "%i", params->pitch ) );
|
||||
control = GetControl( IDC_STATIC_YAWVAL );
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)va( "%i", params->yaw ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesLookAtDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesLookAtDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesLookAtDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesLookAtDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "Look at %s", g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_LOOKAT:
|
||||
{
|
||||
HWND control = GetControl( IDC_CHECK_LOOKAT );
|
||||
bool checked = SendMessage( control, BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !checked )
|
||||
{
|
||||
g_Params.yaw = 0;
|
||||
g_Params.pitch = 0;
|
||||
|
||||
SetPitchYawText( &g_Params );
|
||||
|
||||
control = GetControl( IDC_SLIDER_PITCH );
|
||||
SendMessage( control, TBM_SETPOS, 1, (LPARAM)(LONG)g_Params.pitch );
|
||||
|
||||
control = GetControl( IDC_SLIDER_YAW );
|
||||
SendMessage( control, TBM_SETPOS, 1, (LPARAM)(LONG)g_Params.yaw );
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control == GetControl( IDC_SLIDER_YAW ) ||
|
||||
control == GetControl( IDC_SLIDER_PITCH ) )
|
||||
{
|
||||
g_Params.yaw = (float)SendMessage( GetControl( IDC_SLIDER_YAW ), TBM_GETPOS, 0, 0 );
|
||||
g_Params.pitch = (float)SendMessage( GetControl( IDC_SLIDER_PITCH ), TBM_GETPOS, 0, 0 );
|
||||
|
||||
SetPitchYawText( &g_Params );
|
||||
|
||||
control = GetControl( IDC_CHECK_LOOKAT );
|
||||
if ( g_Params.pitch != 0 ||
|
||||
g_Params.yaw != 0 )
|
||||
{
|
||||
g_Params.usepitchyaw = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Params.usepitchyaw = false;
|
||||
}
|
||||
|
||||
SendMessage( control, BM_SETCHECK, (WPARAM) g_Params.usepitchyaw ? BST_CHECKED : BST_UNCHECKED, 0 );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_LookAt( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_LOOKAT ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesLookAtDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_lookat.h
Normal file
18
utils/hlfaceposer/eventproperties_lookat.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_LOOKAT_H
|
||||
#define EVENTPROPERTIES_LOOKAT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_LookAt( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_LOOKAT_H
|
||||
368
utils/hlfaceposer/eventproperties_moveto.cpp
Normal file
368
utils/hlfaceposer/eventproperties_moveto.cpp
Normal file
@@ -0,0 +1,368 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "choreoevent.h"
|
||||
#include "filesystem.h"
|
||||
#include <commctrl.h>
|
||||
#include "scriplib.h"
|
||||
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesMoveToDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
|
||||
void PopulateMovementStyle( HWND control, CEventParams *params );
|
||||
void SetDistanceToTargetText( CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesMoveToDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "MoveTo", "Move To Actor" );
|
||||
}
|
||||
|
||||
void CEventPropertiesMoveToDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
SetDlgItemText( m_hDialog, IDC_STARTTIME, va( "%f", g_Params.m_flStartTime ) );
|
||||
SetDlgItemText( m_hDialog, IDC_ENDTIME, va( "%f", g_Params.m_flEndTime ) );
|
||||
SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bHasEndTime ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bResumeCondition ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
PopulateTagList( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
HWND choices2 = GetControl( IDC_EVENTCHOICES2 );
|
||||
SendMessage( choices2, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices2, WM_SETTEXT , 0, (LPARAM)params->m_szParameters2 );
|
||||
|
||||
HWND choices3 = GetControl( IDC_EVENTCHOICES3 );
|
||||
SendMessage( choices3, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices3, WM_SETTEXT , 0, (LPARAM)params->m_szParameters3 );
|
||||
|
||||
HWND control = GetControl( IDC_SLIDER_DISTANCE );
|
||||
SendMessage( control, TBM_SETRANGE, 0, (LPARAM)MAKELONG( 0, 200 ) );
|
||||
SendMessage( control, TBM_SETPOS, 1, (LPARAM)(LONG)params->m_flDistanceToTarget );
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_FORCESHORTMOVEMENT ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bForceShortMovement ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
PopulateNamedActorList( choices1, params );
|
||||
|
||||
SendMessage( GetControl( IDC_CHOICES2PROMPT ), WM_SETTEXT, 0, (LPARAM)"Movement Style:" );
|
||||
|
||||
PopulateMovementStyle( choices2, params );
|
||||
|
||||
if (strlen( params->m_szParameters3 ) != 0)
|
||||
{
|
||||
// make sure blank is a valid choice
|
||||
SendMessage( choices3, CB_ADDSTRING, 0, (LPARAM)"" );
|
||||
}
|
||||
PopulateNamedActorList( choices3, params );
|
||||
|
||||
SetDistanceToTargetText( params );
|
||||
}
|
||||
|
||||
void CEventPropertiesMoveToDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesMoveToDialog g_EventPropertiesMoveToDialog;
|
||||
|
||||
void CEventPropertiesMoveToDialog::PopulateMovementStyle( HWND control, CEventParams *params )
|
||||
{
|
||||
char movement_style[ 256 ];
|
||||
char distance_to_target[ 256 ];
|
||||
|
||||
movement_style[0] = 0;
|
||||
distance_to_target[0]= 0;
|
||||
|
||||
ParseFromMemory( params->m_szParameters2, strlen( params->m_szParameters2 ) );
|
||||
if ( TokenAvailable() )
|
||||
{
|
||||
GetToken( false );
|
||||
strcpy( movement_style, token );
|
||||
if ( TokenAvailable() )
|
||||
{
|
||||
GetToken( false );
|
||||
strcpy( distance_to_target, token );
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"Walk" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"Run" );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"CrouchWalk" );
|
||||
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)movement_style );
|
||||
}
|
||||
|
||||
|
||||
void CEventPropertiesMoveToDialog::SetDistanceToTargetText( CEventParams *params )
|
||||
{
|
||||
HWND control;
|
||||
|
||||
control = GetControl( IDC_STATIC_DISTANCEVAL );
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)va( "%i", (int)params->m_flDistanceToTarget ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesMoveToDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesMoveToDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesMoveToDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesMoveToDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control == GetControl( IDC_SLIDER_DISTANCE ))
|
||||
{
|
||||
g_Params.m_flDistanceToTarget = (float)SendMessage( GetControl( IDC_SLIDER_DISTANCE ), TBM_GETPOS, 0, 0 );
|
||||
|
||||
SetDistanceToTargetText( &g_Params );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "Moveto %s", g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES2:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
if ( g_Params.m_nType != CChoreoEvent::MOVETO )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters2 ), (LPARAM)g_Params.m_szParameters2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf1[ 256 ];
|
||||
SendMessage( GetControl( IDC_EVENTCHOICES2 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
|
||||
|
||||
Q_snprintf( g_Params.m_szParameters2, sizeof( g_Params.m_szParameters2 ), "%s", buf1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES3:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
if ( g_Params.m_nType != CChoreoEvent::MOVETO )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters3 ), (LPARAM)g_Params.m_szParameters3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf1[ 256 ];
|
||||
SendMessage( GetControl( IDC_EVENTCHOICES3 ), WM_GETTEXT, (WPARAM)sizeof( buf1 ), (LPARAM)buf1 );
|
||||
|
||||
Q_snprintf( g_Params.m_szParameters3, sizeof( g_Params.m_szParameters3 ), "%s", buf1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_FORCESHORTMOVEMENT:
|
||||
{
|
||||
g_Params.m_bForceShortMovement = SendMessage( GetControl( IDC_CHECK_FORCESHORTMOVEMENT ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_MoveTo( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_MOVETO ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesMoveToDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_moveto.h
Normal file
18
utils/hlfaceposer/eventproperties_moveto.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_MOVETO_H
|
||||
#define EVENTPROPERTIES_MOVETO_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_MoveTo( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_MOVETO_H
|
||||
217
utils/hlfaceposer/eventproperties_permitresponses.cpp
Normal file
217
utils/hlfaceposer/eventproperties_permitresponses.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesPermitResponsesDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesPermitResponsesDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Permit Responses", "Permit Responses" );
|
||||
}
|
||||
|
||||
void CEventPropertiesPermitResponsesDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
}
|
||||
|
||||
void CEventPropertiesPermitResponsesDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesPermitResponsesDialog g_EventPropertiesPermitResponsesDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesPermitResponsesDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesPermitResponsesDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesPermitResponsesDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesPermitResponsesDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szName, "Permit Responses", sizeof( g_Params.m_szName ) );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_PermitResponses( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_PERMITRESPONSES ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesPermitResponsesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_permitresponses.h
Normal file
18
utils/hlfaceposer/eventproperties_permitresponses.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_PERMITRESPONSES_H
|
||||
#define EVENTPROPERTIES_PERMITRESPONSES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_PermitResponses( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_PERMITRESPONSES_H
|
||||
251
utils/hlfaceposer/eventproperties_sequence.cpp
Normal file
251
utils/hlfaceposer/eventproperties_sequence.cpp
Normal file
@@ -0,0 +1,251 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "StudioModel.h"
|
||||
#include "faceposer_models.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesSequenceDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
|
||||
void PopulateSequenceList( HWND wnd );
|
||||
};
|
||||
|
||||
void CEventPropertiesSequenceDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Sequence", "Sequence" );
|
||||
}
|
||||
|
||||
void CEventPropertiesSequenceDialog::PopulateSequenceList( HWND wnd )
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if (hdr)
|
||||
{
|
||||
for (int i = 0; i < hdr->GetNumSeq(); i++)
|
||||
{
|
||||
SendMessage( wnd, CB_ADDSTRING, 0, (LPARAM)hdr->pSeqdesc(i).pszLabel() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEventPropertiesSequenceDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
SendMessage( GetControl( IDC_CHECK_PLAYOVERSCRIPT ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bPlayOverScript ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
PopulateSequenceList( choices1 );
|
||||
}
|
||||
|
||||
void CEventPropertiesSequenceDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesSequenceDialog g_EventPropertiesSequenceDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesSequenceDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesSequenceDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesSequenceDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesSequenceDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES );
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szName, g_Params.m_szParameters, sizeof( g_Params.m_szName ) );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_PLAYOVERSCRIPT:
|
||||
{
|
||||
g_Params.m_bPlayOverScript = SendMessage( GetControl( IDC_CHECK_PLAYOVERSCRIPT ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Sequence( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_SEQUENCE ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesSequenceDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_sequence.h
Normal file
18
utils/hlfaceposer/eventproperties_sequence.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_SEQUENCE_H
|
||||
#define EVENTPROPERTIES_SEQUENCE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Sequence( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_SEQUENCE_H
|
||||
673
utils/hlfaceposer/eventproperties_speak.cpp
Normal file
673
utils/hlfaceposer/eventproperties_speak.cpp
Normal file
@@ -0,0 +1,673 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "choreoevent.h"
|
||||
#include "FileSystem.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
#include "AddSoundEntry.h"
|
||||
#include "SoundLookup.h"
|
||||
#include "ifaceposersound.h"
|
||||
#include "MatSysWin.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesSpeakDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
|
||||
public:
|
||||
|
||||
CEventPropertiesSpeakDialog()
|
||||
{
|
||||
m_bShowAll = false;
|
||||
m_szLastFilter[ 0 ] = 0;
|
||||
m_Timer = 0;
|
||||
m_flLastFilterUpdateTime;
|
||||
}
|
||||
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
|
||||
private:
|
||||
|
||||
void PopulateFilterList( bool resetCurrent );
|
||||
void OnCheckFilterUpdate();
|
||||
|
||||
void AddFilterToHistory( char const *filter );
|
||||
|
||||
void OnSoundSelected( CEventParams *params );
|
||||
|
||||
void PopulateSoundList( char const *current, HWND wnd );
|
||||
void PopulateVolumeLevels( HWND control, CEventParams *params );
|
||||
|
||||
void FindWaveInSoundEntries( CUtlVector< int >& entryList, char const *search );
|
||||
void OnCheckChangedVolumeLevel( CEventParams *params );
|
||||
|
||||
bool m_bShowAll;
|
||||
|
||||
CUtlVector< CUtlSymbol > m_FilterHistory;
|
||||
CUtlSymbolTable m_Symbols;
|
||||
|
||||
enum
|
||||
{
|
||||
TIMER_ID = 100,
|
||||
};
|
||||
|
||||
UINT m_Timer;
|
||||
char m_szLastFilter[ 256 ];
|
||||
float m_flLastFilterUpdateTime;
|
||||
};
|
||||
|
||||
void CEventPropertiesSpeakDialog::AddFilterToHistory( char const *filter )
|
||||
{
|
||||
CUtlSymbol sym = m_Symbols.AddString( filter );
|
||||
// Move it to front of list...
|
||||
m_FilterHistory.FindAndRemove( sym );
|
||||
m_FilterHistory.AddToHead( sym );
|
||||
|
||||
PopulateFilterList( false );
|
||||
|
||||
// Apply filter
|
||||
|
||||
PopulateSoundList( g_Params.m_szParameters, GetControl( IDC_SOUNDLIST ) );
|
||||
}
|
||||
|
||||
void CEventPropertiesSpeakDialog::PopulateFilterList( bool resetCurrent )
|
||||
{
|
||||
HWND control = GetControl( IDC_FILTER );
|
||||
|
||||
char oldf[ 256 ];
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( oldf ), (LPARAM)oldf );
|
||||
|
||||
SendMessage( control, CB_RESETCONTENT, 0, 0 );
|
||||
|
||||
int c = m_FilterHistory.Count();
|
||||
if ( c == 0 )
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
char const *str = m_Symbols.String( m_FilterHistory[ i ] );
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)str );
|
||||
}
|
||||
|
||||
char const *first = m_Symbols.String( m_FilterHistory[ 0 ] );
|
||||
if ( resetCurrent && first )
|
||||
{
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)first );
|
||||
SendMessage( control, CB_SETEDITSEL , 0, MAKELPARAM( Q_strlen(first), -1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)oldf );
|
||||
SendMessage( control, CB_SETEDITSEL , 0, MAKELPARAM( Q_strlen(oldf), -1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CEventPropertiesSpeakDialog::OnCheckFilterUpdate()
|
||||
{
|
||||
char curfilter[ 256 ];
|
||||
HWND control = GetControl( IDC_FILTER );
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( curfilter), (LPARAM)curfilter );
|
||||
|
||||
if ( Q_stricmp( curfilter, m_szLastFilter ) )
|
||||
{
|
||||
Q_strncpy( m_szLastFilter, curfilter, sizeof( m_szLastFilter ) );
|
||||
|
||||
AddFilterToHistory( m_szLastFilter );
|
||||
}
|
||||
}
|
||||
|
||||
void CEventPropertiesSpeakDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "Speak", "Speak Sound" );
|
||||
}
|
||||
|
||||
void CEventPropertiesSpeakDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
m_flLastFilterUpdateTime = (float)mx::getTickCount() / 1000.0f;
|
||||
|
||||
m_Timer = SetTimer( m_hDialog, TIMER_ID, 1, 0 );
|
||||
|
||||
HWND choices1 = GetControl( IDC_SOUNDLIST );
|
||||
SendMessage( choices1, LB_RESETCONTENT, 0, 0 );
|
||||
|
||||
HWND choices2 = GetControl( IDC_EVENTCHOICES2 );
|
||||
SendMessage( choices2, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices2, WM_SETTEXT , 0, (LPARAM)params->m_szParameters2 );
|
||||
|
||||
HWND attenuate = GetControl( IDC_CAPTION_ATTENUATION );
|
||||
SendMessage( attenuate, BM_SETCHECK, (WPARAM) params->m_bCloseCaptionNoAttenuate ? BST_CHECKED : BST_UNCHECKED, 0 );
|
||||
|
||||
PopulateSoundList( params->m_szParameters, choices1 );
|
||||
|
||||
OnSoundSelected( params );
|
||||
|
||||
PopulateFilterList( true );
|
||||
}
|
||||
|
||||
void CEventPropertiesSpeakDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesSpeakDialog g_EventPropertiesSpeakDialog;
|
||||
|
||||
void CEventPropertiesSpeakDialog::PopulateVolumeLevels( HWND control, CEventParams *params )
|
||||
{
|
||||
SendMessage( control, CB_RESETCONTENT, 0, 0 );
|
||||
|
||||
// Assume uneditable
|
||||
SendMessage( control, CB_ADDSTRING, 0, (LPARAM)"VOL_NORM" );
|
||||
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)"VOL_NORM" );
|
||||
|
||||
bool enabled = false;
|
||||
|
||||
if ( !Q_stristr( params->m_szParameters, ".wav" ) )
|
||||
{
|
||||
// Look up the sound level from the soundemitter system
|
||||
int soundindex = soundemitter->GetSoundIndex( params->m_szParameters );
|
||||
if ( soundindex >= 0 )
|
||||
{
|
||||
// Look up the sound level from the soundemitter system
|
||||
CSoundParametersInternal *params = soundemitter->InternalGetParametersForSound( soundindex );
|
||||
if ( params )
|
||||
{
|
||||
// Found it
|
||||
SendMessage( control, WM_SETTEXT , 0, (LPARAM)params->VolumeToString() );
|
||||
|
||||
//
|
||||
// See if the .txt file is writable
|
||||
char const *scriptfile = soundemitter->GetSourceFileForSound( soundindex );
|
||||
if ( scriptfile )
|
||||
{
|
||||
// See if it's writable
|
||||
if ( filesystem->FileExists( scriptfile ) &&
|
||||
filesystem->IsFileWritable( scriptfile ) )
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnableWindow( control, enabled ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// Output : static void
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEventPropertiesSpeakDialog::PopulateSoundList( char const *current, HWND wnd )
|
||||
{
|
||||
extern bool NameLessFunc( const char *const& name1, const char *const& name2 );
|
||||
|
||||
CUtlRBTree< char const *, int > m_SortedNames( 0, 0, NameLessFunc );
|
||||
|
||||
int c = soundemitter->GetSoundCount();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
char const *name = soundemitter->GetSoundName( i );
|
||||
|
||||
if ( name && name[ 0 ] )
|
||||
{
|
||||
bool add = true;
|
||||
if ( !m_bShowAll )
|
||||
{
|
||||
CSoundParameters params;
|
||||
if ( soundemitter->GetParametersForSound( name, params, GENDER_NONE ) )
|
||||
{
|
||||
if ( params.channel != CHAN_VOICE )
|
||||
{
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply filter
|
||||
if ( m_szLastFilter[ 0 ] != 0 )
|
||||
{
|
||||
if ( !Q_stristr( name, m_szLastFilter ) )
|
||||
{
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( add )
|
||||
{
|
||||
m_SortedNames.Insert( name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage( wnd, WM_SETREDRAW , (WPARAM)FALSE, (LPARAM)0 );
|
||||
|
||||
// Remove all
|
||||
SendMessage( wnd, LB_RESETCONTENT, 0, 0 );
|
||||
|
||||
int selectslot = 0;
|
||||
|
||||
int j = m_SortedNames.FirstInorder();
|
||||
while ( j != m_SortedNames.InvalidIndex() )
|
||||
{
|
||||
char const *name = m_SortedNames[ j ];
|
||||
if ( name && name[ 0 ] )
|
||||
{
|
||||
int temp = SendMessage( wnd, LB_ADDSTRING, 0, (LPARAM)name );
|
||||
|
||||
if ( !Q_stricmp( name, current ) )
|
||||
{
|
||||
selectslot = temp;
|
||||
}
|
||||
}
|
||||
|
||||
j = m_SortedNames.NextInorder( j );
|
||||
}
|
||||
|
||||
SendMessage( wnd, LB_SETCURSEL, (WPARAM)selectslot, 0 );
|
||||
|
||||
SendMessage( wnd, WM_SETREDRAW , (WPARAM)TRUE, (LPARAM)0 );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesSpeakDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
void CEventPropertiesSpeakDialog::FindWaveInSoundEntries( CUtlVector< int >& entryList, char const *search )
|
||||
{
|
||||
int c = soundemitter->GetSoundCount();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
CSoundParametersInternal *params = soundemitter->InternalGetParametersForSound( i );
|
||||
if ( !params )
|
||||
continue;
|
||||
|
||||
int waveCount = params->NumSoundNames();
|
||||
for ( int wave = 0; wave < waveCount; wave++ )
|
||||
{
|
||||
char const *waveName = soundemitter->GetWaveName( params->GetSoundNames()[ wave ].symbol );
|
||||
|
||||
if ( !Q_stricmp( waveName, search ) )
|
||||
{
|
||||
entryList.AddToTail( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEventPropertiesSpeakDialog::OnCheckChangedVolumeLevel( CEventParams *params )
|
||||
{
|
||||
HWND control = GetControl( IDC_EVENTCHOICES2 );
|
||||
if ( !IsWindowEnabled( control ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Q_stristr( params->m_szParameters, ".wav" ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int soundindex = soundemitter->GetSoundIndex( params->m_szParameters );
|
||||
if ( soundindex < 0 )
|
||||
return;
|
||||
|
||||
// Look up the sound level from the soundemitter system
|
||||
CSoundParametersInternal *soundparams = soundemitter->InternalGetParametersForSound( soundindex );
|
||||
if ( !params )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// See if it's writable, if not then bail
|
||||
char const *scriptfile = soundemitter->GetSourceFileForSound( soundindex );
|
||||
if ( !scriptfile ||
|
||||
!filesystem->FileExists( scriptfile ) ||
|
||||
!filesystem->IsFileWritable( scriptfile ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the parameters
|
||||
CSoundParametersInternal newparams;
|
||||
newparams.CopyFrom( *soundparams );
|
||||
|
||||
// Get the value from the control
|
||||
char newvolumelevel[ 256 ];
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( newvolumelevel ), (LPARAM)newvolumelevel );
|
||||
|
||||
newparams.VolumeFromString( newvolumelevel );
|
||||
|
||||
// No change
|
||||
if ( newparams == *soundparams )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
soundemitter->UpdateSoundParameters( params->m_szParameters , newparams );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesSpeakDialog( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesSpeakDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
void CEventPropertiesSpeakDialog::OnSoundSelected( CEventParams *params )
|
||||
{
|
||||
PopulateVolumeLevels( GetControl( IDC_EVENTCHOICES2 ), params );
|
||||
SendMessage( GetControl( IDC_SOUNDNAME ), WM_SETTEXT, 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
// Update script name and wavename fields
|
||||
HWND scriptname = GetControl( IDC_STATIC_SCRIPTFILE );
|
||||
HWND wavename = GetControl( IDC_STATIC_WAVEFILENAME );
|
||||
|
||||
SendMessage( scriptname, WM_SETTEXT, (WPARAM)1, (LPARAM)"" );
|
||||
SendMessage( wavename, WM_SETTEXT, (WPARAM)1, (LPARAM)"" );
|
||||
|
||||
int soundindex = soundemitter->GetSoundIndex( params->m_szParameters );
|
||||
if ( soundindex >= 0 )
|
||||
{
|
||||
char const *script = soundemitter->GetSourceFileForSound( soundindex );
|
||||
if ( script && script [ 0 ] )
|
||||
{
|
||||
SendMessage( scriptname, WM_SETTEXT, (WPARAM)Q_strlen( script ) + 1, (LPARAM)script );
|
||||
|
||||
// Look up the sound level from the soundemitter system
|
||||
CSoundParametersInternal *params = soundemitter->InternalGetParametersForSound( soundindex );
|
||||
if ( params )
|
||||
{
|
||||
// Get wave name
|
||||
char const *w = soundemitter->GetWaveName( params->GetSoundNames()[ 0 ].symbol );
|
||||
if ( w && w[ 0 ] )
|
||||
{
|
||||
SendMessage( wavename, WM_SETTEXT, (WPARAM)Q_strlen( w ) + 1, (LPARAM)w );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CEventPropertiesSpeakDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
case WM_TIMER:
|
||||
{
|
||||
g_pMatSysWindow->Frame();
|
||||
|
||||
float curtime = (float)mx::getTickCount() / 1000.0f;
|
||||
if ( curtime - m_flLastFilterUpdateTime > 0.5f )
|
||||
{
|
||||
m_flLastFilterUpdateTime = curtime;
|
||||
OnCheckFilterUpdate();
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
char sz[ 512 ];
|
||||
GetDlgItemText( m_hDialog, IDC_SOUNDNAME, sz, sizeof( sz ) );
|
||||
|
||||
Q_FixSlashes( sz );
|
||||
|
||||
// Strip off game directory stuff
|
||||
Q_strncpy( g_Params.m_szParameters, sz, sizeof( g_Params.m_szParameters ) );
|
||||
char *p = Q_strstr( sz, "\\sound\\" );
|
||||
if ( p )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szParameters, p + strlen( "\\sound\\" ), sizeof( g_Params.m_szParameters ) );
|
||||
}
|
||||
|
||||
OnCheckChangedVolumeLevel( &g_Params );
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szName, sz, sizeof( g_Params.m_szName ) );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
KillTimer( m_hDialog, m_Timer );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
{
|
||||
KillTimer( m_hDialog, m_Timer );
|
||||
EndDialog( hwndDlg, 0 );
|
||||
}
|
||||
break;
|
||||
case IDC_CAPTION_ATTENUATION:
|
||||
{
|
||||
HWND control = GetControl( IDC_CAPTION_ATTENUATION );
|
||||
g_Params.m_bCloseCaptionNoAttenuate = SendMessage( control, BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_PLAY_SOUND:
|
||||
{
|
||||
// Get sound name from soundemitter
|
||||
sound->PlaySound(
|
||||
NULL,
|
||||
1.0f,
|
||||
va( "sound/%s", FacePoser_TranslateSoundName( g_Params.m_szParameters ) ),
|
||||
NULL );
|
||||
}
|
||||
break;
|
||||
case IDC_OPENSOURCE:
|
||||
{
|
||||
// Look up the sound level from the soundemitter system
|
||||
int soundindex = soundemitter->GetSoundIndex( g_Params.m_szParameters );
|
||||
if ( soundindex >= 0 )
|
||||
{
|
||||
// Look up the sound level from the soundemitter system
|
||||
CSoundParametersInternal *params = soundemitter->InternalGetParametersForSound( soundindex );
|
||||
if ( params )
|
||||
{
|
||||
// See if the .txt file is writable
|
||||
char const *scriptfile = soundemitter->GetSourceFileForSound( soundindex );
|
||||
if ( scriptfile )
|
||||
{
|
||||
char relative_path[MAX_PATH];
|
||||
Q_snprintf( relative_path, MAX_PATH, "%s", scriptfile );
|
||||
|
||||
char full_path[MAX_PATH];
|
||||
if ( filesystem->GetLocalPath( relative_path, full_path, MAX_PATH ) )
|
||||
{
|
||||
ShellExecute( NULL, "open", full_path, NULL, NULL, SW_SHOWNORMAL );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_SHOW_ALL_SOUNDS:
|
||||
{
|
||||
m_bShowAll = SendMessage( GetControl( IDC_SHOW_ALL_SOUNDS ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
|
||||
PopulateSoundList( g_Params.m_szParameters, GetControl( IDC_EVENTCHOICES ) );
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_SOUNDLIST:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
int cursel = SendMessage( control, LB_GETCURSEL, 0, 0 );
|
||||
if ( cursel != LB_ERR )
|
||||
{
|
||||
SendMessage( control, LB_GETTEXT, cursel, (LPARAM)g_Params.m_szParameters );
|
||||
OnSoundSelected( &g_Params );
|
||||
|
||||
if ( HIWORD( wParam ) == LBN_DBLCLK )
|
||||
{
|
||||
// Get sound name from soundemitter
|
||||
sound->PlaySound(
|
||||
NULL,
|
||||
1.0f,
|
||||
va( "sound/%s", FacePoser_TranslateSoundName( g_Params.m_szParameters ) ),
|
||||
NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES2:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters2 ), (LPARAM)g_Params.m_szParameters2 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_Speak( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_SPEAK ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesSpeakDialog );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_speak.h
Normal file
18
utils/hlfaceposer/eventproperties_speak.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_SPEAK_H
|
||||
#define EVENTPROPERTIES_SPEAK_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_Speak( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_SPEAK_H
|
||||
234
utils/hlfaceposer/eventproperties_subscene.cpp
Normal file
234
utils/hlfaceposer/eventproperties_subscene.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "cbase.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "EventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "filesystem.h"
|
||||
#include "filesystem_init.h"
|
||||
|
||||
static CEventParams g_Params;
|
||||
|
||||
class CEventPropertiesSubSceneDialog : public CBaseEventPropertiesDialog
|
||||
{
|
||||
typedef CBaseEventPropertiesDialog BaseClass;
|
||||
public:
|
||||
virtual void InitDialog( HWND hwndDlg );
|
||||
virtual BOOL HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
virtual void SetTitle();
|
||||
virtual void ShowControlsForEventType( CEventParams *params );
|
||||
virtual void InitControlData( CEventParams *params );
|
||||
};
|
||||
|
||||
void CEventPropertiesSubSceneDialog::SetTitle()
|
||||
{
|
||||
SetDialogTitle( &g_Params, "SubScene", "Sub-scene" );
|
||||
}
|
||||
|
||||
void CEventPropertiesSubSceneDialog::InitControlData( CEventParams *params )
|
||||
{
|
||||
BaseClass::InitControlData( params );
|
||||
|
||||
HWND choices1 = GetControl( IDC_EVENTCHOICES );
|
||||
SendMessage( choices1, CB_RESETCONTENT, 0, 0 );
|
||||
SendMessage( choices1, WM_SETTEXT , 0, (LPARAM)params->m_szParameters );
|
||||
|
||||
SendMessage( GetControl( IDC_FILENAME ), WM_SETTEXT, sizeof( params->m_szParameters ), (LPARAM)params->m_szParameters );
|
||||
}
|
||||
|
||||
void CEventPropertiesSubSceneDialog::InitDialog( HWND hwndDlg )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
g_Params.PositionSelf( m_hDialog );
|
||||
|
||||
// Set working title for dialog, etc.
|
||||
SetTitle();
|
||||
|
||||
// Show/Hide dialog controls
|
||||
ShowControlsForEventType( &g_Params );
|
||||
InitControlData( &g_Params );
|
||||
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
|
||||
SetFocus( GetControl( IDC_EVENTNAME ) );
|
||||
}
|
||||
|
||||
static CEventPropertiesSubSceneDialog g_EventPropertiesSubSceneDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : wnd -
|
||||
// *params -
|
||||
// Output : static
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CEventPropertiesSubSceneDialog::ShowControlsForEventType( CEventParams *params )
|
||||
{
|
||||
BaseClass::ShowControlsForEventType( params );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK EventPropertiesSubSceneDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
return g_EventPropertiesSubSceneDialog.HandleMessage( hwndDlg, uMsg, wParam, lParam );
|
||||
};
|
||||
|
||||
BOOL CEventPropertiesSubSceneDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
m_hDialog = hwndDlg;
|
||||
|
||||
bool handled = false;
|
||||
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
|
||||
if ( handled )
|
||||
return bret;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
hdc = BeginPaint(hwndDlg, &ps);
|
||||
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_VSCROLL:
|
||||
{
|
||||
RECT rcOut;
|
||||
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
|
||||
|
||||
InvalidateRect( hwndDlg, &rcOut, TRUE );
|
||||
UpdateWindow( hwndDlg );
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
InitDialog( hwndDlg );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
char sz[ 512 ];
|
||||
GetDlgItemText( m_hDialog, IDC_FILENAME, sz, sizeof( sz ) );
|
||||
|
||||
// Strip off game directory stuff
|
||||
Q_strncpy( g_Params.m_szParameters, sz, sizeof( g_Params.m_szParameters ) );
|
||||
|
||||
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
if ( !g_Params.m_szName[ 0 ] )
|
||||
{
|
||||
Q_strncpy( g_Params.m_szName, g_Params.m_szParameters, sizeof( g_Params.m_szName ) );
|
||||
}
|
||||
|
||||
char szTime[ 32 ];
|
||||
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flEndTime = atof( szTime );
|
||||
|
||||
// Parse tokens from tags
|
||||
ParseTags( &g_Params );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
case IDC_SELECTWAV:
|
||||
{
|
||||
char filename[ 512 ];
|
||||
if ( FacePoser_ShowOpenFileNameDialog( filename, sizeof( filename ), "scenes", "*.vcd" ) )
|
||||
{
|
||||
SetDlgItemText( m_hDialog, IDC_FILENAME, filename );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_ENDTIME:
|
||||
{
|
||||
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
if ( !g_Params.m_bHasEndTime )
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_RESUMECONDITION:
|
||||
{
|
||||
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
}
|
||||
break;
|
||||
case IDC_EVENTCHOICES:
|
||||
{
|
||||
HWND control = (HWND)lParam;
|
||||
if ( control )
|
||||
{
|
||||
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_ABSOLUTESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = false;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
case IDC_RELATIVESTART:
|
||||
{
|
||||
g_Params.m_bUsesTag = true;
|
||||
UpdateTagRadioButtons( &g_Params );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int EventProperties_SubScene( CEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EVENTPROPERTIES_SUBSCENE ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)EventPropertiesSubSceneDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
18
utils/hlfaceposer/eventproperties_subscene.h
Normal file
18
utils/hlfaceposer/eventproperties_subscene.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EVENTPROPERTIES_SUBSCENE_H
|
||||
#define EVENTPROPERTIES_SUBSCENE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CEventParams;
|
||||
|
||||
int EventProperties_SubScene( CEventParams *params );
|
||||
|
||||
#endif // EVENTPROPERTIES_SUBSCENE_H
|
||||
735
utils/hlfaceposer/expclass.cpp
Normal file
735
utils/hlfaceposer/expclass.cpp
Normal file
@@ -0,0 +1,735 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "hlfaceposer.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include "expressions.h"
|
||||
#include "expclass.h"
|
||||
#include "hlfaceposer.h"
|
||||
#include "StudioModel.h"
|
||||
#include "FileSystem.h"
|
||||
#include "FlexPanel.h"
|
||||
#include "ControlPanel.h"
|
||||
#include "mxExpressionTray.h"
|
||||
#include "UtlBuffer.h"
|
||||
#include "FileSystem.h"
|
||||
#include "ExpressionTool.h"
|
||||
#include "faceposer_models.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "phonemeconverter.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "tier1/fmtstr.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
|
||||
#undef ALIGN16
|
||||
#undef ALIGN4
|
||||
#define ALIGN4( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3)
|
||||
#define ALIGN16( a ) a = (byte *)((int)((byte *)a + 15) & ~ 15)
|
||||
|
||||
char const *GetGlobalFlexControllerName( int index );
|
||||
int GetGlobalFlexControllerCount( void );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *classname -
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpClass::CExpClass( const char *classname )
|
||||
{
|
||||
Q_strncpy( m_szClassName, classname, sizeof( m_szClassName ) );
|
||||
Q_FileBase( m_szClassName, m_szBaseName, sizeof( m_szBaseName ) );
|
||||
m_szFileName[ 0 ] = 0;
|
||||
m_bDirty = false;
|
||||
m_nSelectedExpression = -1;
|
||||
m_bIsPhonemeClass = Q_strstr( classname, "phonemes" ) ? true : false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpClass::~CExpClass( void )
|
||||
{
|
||||
m_Expressions.Purge();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *exp -
|
||||
//-----------------------------------------------------------------------------
|
||||
int CExpClass::FindExpressionIndex( CExpression *exp )
|
||||
{
|
||||
for ( int i = 0 ; i < GetNumExpressions(); i++ )
|
||||
{
|
||||
CExpression *e = GetExpression( i );
|
||||
if ( e == exp )
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::Save( void )
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if ( !hdr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const char *filename = GetFileName();
|
||||
if ( !filename || !filename[ 0 ] )
|
||||
return;
|
||||
|
||||
Con_Printf( "Saving changes to %s to file %s\n", GetName(), GetFileName() );
|
||||
|
||||
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
|
||||
|
||||
int i, j;
|
||||
|
||||
int numflexmaps = 0;
|
||||
int flexmap[128]; // maps file local controlls into global controls
|
||||
|
||||
CExpression *expr = NULL;
|
||||
// find all used controllers
|
||||
int fc = GetGlobalFlexControllerCount();
|
||||
for ( j = 0; j < fc; ++j )
|
||||
{
|
||||
for (i = 0; i < GetNumExpressions(); i++)
|
||||
{
|
||||
expr = GetExpression( i );
|
||||
Assert( expr );
|
||||
|
||||
float *settings = expr->GetSettings();
|
||||
float *weights = expr->GetWeights();
|
||||
|
||||
if ( settings[j] != 0 ||
|
||||
weights[j] != 0 )
|
||||
{
|
||||
flexmap[ numflexmaps++ ] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buf.Printf( "$keys" );
|
||||
for (j = 0; j < numflexmaps; j++)
|
||||
{
|
||||
buf.Printf( " %s", GetGlobalFlexControllerName( flexmap[j] ) );
|
||||
}
|
||||
buf.Printf( "\n" );
|
||||
|
||||
buf.Printf( "$hasweighting\n" );
|
||||
|
||||
for (i = 0; i < GetNumExpressions(); i++)
|
||||
{
|
||||
expr = GetExpression( i );
|
||||
|
||||
buf.Printf( "\"%s\" ", expr->name );
|
||||
|
||||
// isalpha returns non zero for ents > 256
|
||||
if (expr->index <= 'z')
|
||||
{
|
||||
buf.Printf( "\"%c\" ", expr->index );
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.Printf( "\"0x%04x\" ", expr->index );
|
||||
}
|
||||
|
||||
float *settings = expr->GetSettings();
|
||||
float *weights = expr->GetWeights();
|
||||
Assert( settings );
|
||||
Assert( weights );
|
||||
|
||||
for (j = 0; j < numflexmaps; j++)
|
||||
{
|
||||
buf.Printf( "%.3f %.3f ", settings[flexmap[j]], weights[flexmap[j]] );
|
||||
}
|
||||
|
||||
if ( Q_strstr( expr->name, "Right Side Smile" ) )
|
||||
{
|
||||
Con_Printf( "wrote %s with checksum %s\n",
|
||||
expr->name, expr->GetBitmapCheckSum() );
|
||||
}
|
||||
|
||||
buf.Printf( "\"%s\"\n", expr->description );
|
||||
}
|
||||
|
||||
char relative[ 512 ];
|
||||
filesystem->FullPathToRelativePath( filename, relative, sizeof( relative ) );
|
||||
|
||||
MakeFileWriteable( relative );
|
||||
FileHandle_t fh = filesystem->Open( relative, "wt" );
|
||||
if ( !fh )
|
||||
{
|
||||
Con_ErrorPrintf( "Unable to write to %s (read-only?)\n", relative );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
filesystem->Write( buf.Base(), buf.TellPut(), fh );
|
||||
filesystem->Close(fh);
|
||||
}
|
||||
|
||||
SetDirty( false );
|
||||
|
||||
for (i = 0; i < GetNumExpressions(); i++)
|
||||
{
|
||||
expr = GetExpression( i );
|
||||
if ( expr )
|
||||
{
|
||||
expr->ResetUndo();
|
||||
expr->SetDirty( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::Export( void )
|
||||
{
|
||||
char vfefilename[ 512 ];
|
||||
Q_StripExtension( GetFileName(), vfefilename, sizeof( vfefilename ) );
|
||||
Q_DefaultExtension( vfefilename, ".vfe", sizeof( vfefilename ) );
|
||||
|
||||
Con_Printf( "Exporting %s to %s\n", GetName(), vfefilename );
|
||||
|
||||
int i, j;
|
||||
|
||||
int numflexmaps = 0;
|
||||
int flexmap[128]; // maps file local controlls into global controls
|
||||
CExpression *expr = NULL;
|
||||
|
||||
// find all used controllers
|
||||
int fc_count = GetGlobalFlexControllerCount();
|
||||
|
||||
for (j = 0; j < fc_count; j++)
|
||||
{
|
||||
int k = j;
|
||||
|
||||
for (i = 0; i < GetNumExpressions(); i++)
|
||||
{
|
||||
expr = GetExpression( i );
|
||||
Assert( expr );
|
||||
|
||||
float *settings = expr->GetSettings();
|
||||
float *weights = expr->GetWeights();
|
||||
Assert( settings );
|
||||
Assert( weights );
|
||||
|
||||
if ( settings[k] != 0 || weights[k] != 0 )
|
||||
{
|
||||
flexmap[numflexmaps++] = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte *pData = (byte *)calloc( 1024 * 1024, 1 );
|
||||
byte *pDataStart = pData;
|
||||
|
||||
flexsettinghdr_t *fhdr = (flexsettinghdr_t *)pData;
|
||||
|
||||
fhdr->id = ('V' << 16) + ('F' << 8) + ('E');
|
||||
fhdr->version = 0;
|
||||
V_strncpy( fhdr->name, vfefilename, sizeof( fhdr->name ) );
|
||||
|
||||
// allocate room for header
|
||||
pData += sizeof( flexsettinghdr_t );
|
||||
ALIGN4( pData );
|
||||
|
||||
// store flex settings
|
||||
flexsetting_t *pSetting = (flexsetting_t *)pData;
|
||||
fhdr->numflexsettings = GetNumExpressions();
|
||||
fhdr->flexsettingindex = pData - pDataStart;
|
||||
pData += sizeof( flexsetting_t ) * fhdr->numflexsettings;
|
||||
ALIGN4( pData );
|
||||
for (i = 0; i < fhdr->numflexsettings; i++)
|
||||
{
|
||||
expr = GetExpression( i );
|
||||
Assert( expr );
|
||||
|
||||
pSetting[i].index = expr->index;
|
||||
pSetting[i].settingindex = pData - (byte *)(&pSetting[i]);
|
||||
|
||||
flexweight_t *pFlexWeights = (flexweight_t *)pData;
|
||||
|
||||
float *settings = expr->GetSettings();
|
||||
float *weights = expr->GetWeights();
|
||||
Assert( settings );
|
||||
Assert( weights );
|
||||
|
||||
for (j = 0; j < numflexmaps; j++)
|
||||
{
|
||||
if (settings[flexmap[j]] != 0 || weights[flexmap[j]] != 0)
|
||||
{
|
||||
pSetting[i].numsettings++;
|
||||
pFlexWeights->key = j;
|
||||
pFlexWeights->weight = settings[flexmap[j]];
|
||||
pFlexWeights->influence = weights[flexmap[j]];
|
||||
pFlexWeights++;
|
||||
}
|
||||
pData = (byte *)pFlexWeights;
|
||||
ALIGN4( pData );
|
||||
}
|
||||
}
|
||||
|
||||
// store indexed table
|
||||
int numindexes = 1;
|
||||
for (i = 0; i < fhdr->numflexsettings; i++)
|
||||
{
|
||||
if (pSetting[i].index >= numindexes)
|
||||
numindexes = pSetting[i].index + 1;
|
||||
}
|
||||
|
||||
int *pIndex = (int *)pData;
|
||||
fhdr->numindexes = numindexes;
|
||||
fhdr->indexindex = pData - pDataStart;
|
||||
pData += sizeof( int ) * numindexes;
|
||||
ALIGN4( pData );
|
||||
for (i = 0; i < numindexes; i++)
|
||||
{
|
||||
pIndex[i] = -1;
|
||||
}
|
||||
for (i = 0; i < fhdr->numflexsettings; i++)
|
||||
{
|
||||
pIndex[pSetting[i].index] = i;
|
||||
}
|
||||
|
||||
// store flex setting names
|
||||
for (i = 0; i < fhdr->numflexsettings; i++)
|
||||
{
|
||||
expr = GetExpression( i );
|
||||
pSetting[i].nameindex = pData - (byte *)(&pSetting[i]);
|
||||
strcpy( (char *)pData, expr->name );
|
||||
pData += strlen( expr->name ) + 1;
|
||||
}
|
||||
ALIGN4( pData );
|
||||
|
||||
// store key names
|
||||
char **pKeynames = (char **)pData;
|
||||
fhdr->numkeys = numflexmaps;
|
||||
fhdr->keynameindex = pData - pDataStart;
|
||||
pData += sizeof( char *) * numflexmaps;
|
||||
|
||||
for (i = 0; i < numflexmaps; i++)
|
||||
{
|
||||
pKeynames[i] = (char *)(pData - pDataStart);
|
||||
strcpy( (char *)pData, GetGlobalFlexControllerName( flexmap[i] ) );
|
||||
pData += strlen( GetGlobalFlexControllerName( flexmap[i] ) ) + 1;
|
||||
}
|
||||
ALIGN4( pData );
|
||||
|
||||
// allocate room for remapping
|
||||
int *keymapping = (int *)pData;
|
||||
fhdr->keymappingindex = pData - pDataStart;
|
||||
pData += sizeof( int ) * numflexmaps;
|
||||
for (i = 0; i < numflexmaps; i++)
|
||||
{
|
||||
keymapping[i] = -1;
|
||||
}
|
||||
ALIGN4( pData );
|
||||
|
||||
fhdr->length = pData - pDataStart;
|
||||
|
||||
char relative[ 512 ];
|
||||
filesystem->FullPathToRelativePath( vfefilename, relative, sizeof( relative ) );
|
||||
|
||||
MakeFileWriteable( relative );
|
||||
FileHandle_t fh = filesystem->Open( relative, "wb" );
|
||||
if ( !fh )
|
||||
{
|
||||
Con_ErrorPrintf( "Unable to write to %s (read-only?)\n", relative );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
filesystem->Write( pDataStart, fhdr->length, fh );
|
||||
filesystem->Close(fh);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CExpClass::GetBaseName( void ) const
|
||||
{
|
||||
return m_szBaseName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CExpClass::GetName( void ) const
|
||||
{
|
||||
return m_szClassName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CExpClass::GetFileName( void ) const
|
||||
{
|
||||
return m_szFileName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::SetFileName( const char *filename )
|
||||
{
|
||||
strcpy( m_szFileName, filename );
|
||||
}
|
||||
|
||||
bool IsUsingPerPlayerExpressions();
|
||||
|
||||
void CExpClass::ReloadBitmaps( void )
|
||||
{
|
||||
bool bUsingPerPlayerOverrides = IsUsingPerPlayerExpressions();
|
||||
|
||||
int c = models->Count();
|
||||
for ( int model = 0; model < MAX_FP_MODELS; model++ )
|
||||
{
|
||||
// Only reload bitmaps for current model index
|
||||
if ( bUsingPerPlayerOverrides && model != models->GetActiveModelIndex() )
|
||||
continue;
|
||||
|
||||
models->ForceActiveModelIndex( model );
|
||||
|
||||
for ( int i = 0 ; i < GetNumExpressions(); i++ )
|
||||
{
|
||||
CExpression *e = GetExpression( i );
|
||||
if ( !e )
|
||||
continue;
|
||||
|
||||
if ( e->m_Bitmap[ model ].valid )
|
||||
{
|
||||
DeleteObject( e->m_Bitmap[ model ].image );
|
||||
e->m_Bitmap[ model ].valid = false;
|
||||
}
|
||||
|
||||
if ( model >= c )
|
||||
continue;
|
||||
|
||||
if ( !LoadBitmapFromFile( e->GetBitmapFilename( model ), e->m_Bitmap[ model ] ) )
|
||||
{
|
||||
e->CreateNewBitmap( model );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
models->UnForceActiveModelIndex();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
// *description -
|
||||
// *flexsettings -
|
||||
// selectnewitem -
|
||||
// Output : CExpression
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpression *CExpClass::AddExpression( const char *name, const char *description, float *flexsettings, float *flexweights, bool selectnewitem, bool bDirtyClass )
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if ( !hdr )
|
||||
return NULL;
|
||||
|
||||
CExpression *exp = FindExpression( name );
|
||||
if ( exp )
|
||||
{
|
||||
Con_ErrorPrintf( "Can't create, an expression with the name '%s' already exists.\n", name );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Add to end of list
|
||||
int idx = m_Expressions.AddToTail();
|
||||
|
||||
exp = &m_Expressions[ idx ];
|
||||
|
||||
float *settings = exp->GetSettings();
|
||||
float *weights = exp->GetWeights();
|
||||
Assert( settings );
|
||||
Assert( weights );
|
||||
|
||||
exp->SetExpressionClass( GetName() );
|
||||
strcpy( exp->name, name );
|
||||
strcpy( exp->description, description );
|
||||
memcpy( settings, flexsettings, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memcpy( weights, flexweights, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
exp->index = '_';
|
||||
|
||||
if ( IsPhonemeClass() )
|
||||
{
|
||||
exp->index = TextToPhoneme( name );
|
||||
}
|
||||
|
||||
exp->m_Bitmap[ models->GetActiveModelIndex() ].valid = false;
|
||||
if ( !LoadBitmapFromFile( exp->GetBitmapFilename( models->GetActiveModelIndex() ), exp->m_Bitmap[ models->GetActiveModelIndex() ] ) )
|
||||
{
|
||||
exp->CreateNewBitmap( models->GetActiveModelIndex() );
|
||||
}
|
||||
|
||||
if ( selectnewitem )
|
||||
{
|
||||
SelectExpression( idx );
|
||||
}
|
||||
|
||||
if ( bDirtyClass )
|
||||
{
|
||||
SetDirty( true );
|
||||
}
|
||||
|
||||
return exp;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
// Output : CExpression
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpression *CExpClass::FindExpression( const char *name )
|
||||
{
|
||||
for ( int i = 0 ; i < m_Expressions.Count(); i++ )
|
||||
{
|
||||
CExpression *exp = &m_Expressions[ i ];
|
||||
if ( !stricmp( exp->name, name ) )
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::DeleteExpression( const char *name )
|
||||
{
|
||||
|
||||
for ( int i = 0 ; i < m_Expressions.Count(); i++ )
|
||||
{
|
||||
CExpression *exp = &m_Expressions[ i ];
|
||||
if ( !stricmp( exp->name, name ) )
|
||||
{
|
||||
SetDirty( true );
|
||||
|
||||
m_Expressions.Remove( i );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CExpClass::GetNumExpressions( void )
|
||||
{
|
||||
return m_Expressions.Count();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : num -
|
||||
// Output : CExpression
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpression *CExpClass::GetExpression( int num )
|
||||
{
|
||||
if ( num < 0 || num >= m_Expressions.Count() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CExpression *exp = &m_Expressions[ num ];
|
||||
return exp;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpClass::GetDirty( void )
|
||||
{
|
||||
return m_bDirty;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : dirty -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::SetDirty( bool dirty )
|
||||
{
|
||||
m_bDirty = dirty;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CExpClass::GetIndex( void )
|
||||
{
|
||||
for ( int i = 0; i < expressions->GetNumClasses(); i++ )
|
||||
{
|
||||
CExpClass *cl = expressions->GetClass( i );
|
||||
if ( cl == this )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : num -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::SelectExpression( int num, bool deselect )
|
||||
{
|
||||
m_nSelectedExpression = num;
|
||||
|
||||
g_pFlexPanel->setExpression( num );
|
||||
g_pExpressionTrayTool->Select( num, deselect );
|
||||
g_pExpressionTrayTool->redraw();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CExpClass::GetSelectedExpression( void )
|
||||
{
|
||||
return m_nSelectedExpression;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::DeselectExpression( void )
|
||||
{
|
||||
m_nSelectedExpression = -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : exp1 -
|
||||
// exp2 -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::SwapExpressionOrder( int exp1, int exp2 )
|
||||
{
|
||||
CExpression temp1 = m_Expressions[ exp1 ];
|
||||
CExpression temp2 = m_Expressions[ exp2 ];
|
||||
|
||||
m_Expressions.Remove( exp1 );
|
||||
m_Expressions.InsertBefore( exp1, temp2 );
|
||||
m_Expressions.Remove( exp2 );
|
||||
m_Expressions.InsertBefore( exp2, temp1 );
|
||||
}
|
||||
|
||||
void CExpClass::BuildValidChecksums( CUtlRBTree< CRC32_t > &tree )
|
||||
{
|
||||
for ( int i = 0; i < m_Expressions.Count(); i++ )
|
||||
{
|
||||
CExpression *exp = &m_Expressions[ i ];
|
||||
if ( !exp )
|
||||
continue;
|
||||
|
||||
CRC32_t crc = exp->GetBitmapCRC();
|
||||
tree.Insert( crc );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: After a class is loaded, check the class directory and delete any bmp files that aren't
|
||||
// still referenced
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpClass::CheckBitmapConsistency( void )
|
||||
{
|
||||
char path[ 512 ];
|
||||
|
||||
Q_snprintf( path, sizeof( path ), "expressions/%s/%s/*.bmp", models->GetActiveModelName(), GetBaseName() );
|
||||
Q_FixSlashes( path );
|
||||
Q_strlower( path );
|
||||
|
||||
g_pProgressDialog->Start( CFmtStr( "%s / %s - Reconcile Expression Thumbnails", models->GetActiveModelName(), GetBaseName() ), "", true );
|
||||
|
||||
CUtlVector< CUtlString > workList;
|
||||
|
||||
FileFindHandle_t hFindFile;
|
||||
char const *fn = filesystem->FindFirstEx( path, "MOD", &hFindFile );
|
||||
if ( fn )
|
||||
{
|
||||
while ( fn )
|
||||
{
|
||||
// Don't do anything with directories
|
||||
if ( !filesystem->FindIsDirectory( hFindFile ) )
|
||||
{
|
||||
CUtlString s = fn;
|
||||
workList.AddToTail( s );
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn = filesystem->FindNext( hFindFile );
|
||||
}
|
||||
|
||||
filesystem->FindClose( hFindFile );
|
||||
}
|
||||
|
||||
CUtlRBTree< CRC32_t > tree( 0, 0, DefLessFunc( CRC32_t ) );
|
||||
BuildValidChecksums( tree );
|
||||
|
||||
for ( int i = 0 ; i < workList.Count(); ++i )
|
||||
{
|
||||
char testname[ 256 ];
|
||||
Q_StripExtension( workList[ i ].String(), testname, sizeof( testname ) );
|
||||
|
||||
g_pProgressDialog->UpdateText( "%s", testname );
|
||||
g_pProgressDialog->Update( (float)i / (float)workList.Count() );
|
||||
|
||||
CRC32_t check;
|
||||
Q_hextobinary( testname, Q_strlen( testname ), (byte *)&check, sizeof( check ) );
|
||||
|
||||
if ( tree.Find( check ) == tree.InvalidIndex() )
|
||||
{
|
||||
char kill[ 512 ];
|
||||
Q_snprintf( kill, sizeof( kill ), "expressions/%s/%s/%s", models->GetActiveModelName(), GetBaseName(), fn );
|
||||
Q_FixSlashes( kill );
|
||||
Q_strlower( kill );
|
||||
|
||||
// Delete it
|
||||
Con_ErrorPrintf( "Removing unused bitmap file '%s'\n", kill );
|
||||
|
||||
filesystem->RemoveFile( kill, "MOD" );
|
||||
}
|
||||
|
||||
if ( g_pProgressDialog->IsCancelled() )
|
||||
{
|
||||
Msg( "Cancelled\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_pProgressDialog->Finish();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Does this class have expression indices based on phoneme lookups
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpClass::IsPhonemeClass( void ) const
|
||||
{
|
||||
return m_bIsPhonemeClass;
|
||||
}
|
||||
74
utils/hlfaceposer/expclass.h
Normal file
74
utils/hlfaceposer/expclass.h
Normal file
@@ -0,0 +1,74 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EXPCLASS_H
|
||||
#define EXPCLASS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "utlvector.h"
|
||||
|
||||
class CExpression;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CExpClass
|
||||
{
|
||||
public:
|
||||
|
||||
CExpClass( const char *classname );
|
||||
virtual ~CExpClass( void );
|
||||
|
||||
void Save( void );
|
||||
void Export( void );
|
||||
|
||||
void CheckBitmapConsistency( void );
|
||||
void ReloadBitmaps( void );
|
||||
|
||||
const char *GetName() const;
|
||||
const char *GetBaseName() const;
|
||||
const char *GetFileName() const;
|
||||
void SetFileName( const char *filename );
|
||||
|
||||
CExpression *AddExpression( const char *name, const char *description, float *flexsettings, float *flexweights, bool selectnewitem, bool bDirtyClass );
|
||||
CExpression *FindExpression( const char *name );
|
||||
int FindExpressionIndex( CExpression *exp );
|
||||
void DeleteExpression( const char *name );
|
||||
|
||||
int GetNumExpressions( void );
|
||||
CExpression *GetExpression( int num );
|
||||
|
||||
bool GetDirty( void );
|
||||
void SetDirty( bool dirty );
|
||||
|
||||
void SelectExpression( int num, bool deselect = true );
|
||||
int GetSelectedExpression( void );
|
||||
void DeselectExpression( void );
|
||||
|
||||
void SwapExpressionOrder( int exp1, int exp2 );
|
||||
|
||||
// Get index of this class in the global class list
|
||||
int GetIndex( void );
|
||||
|
||||
bool IsPhonemeClass( void ) const;
|
||||
|
||||
private:
|
||||
|
||||
void BuildValidChecksums( CUtlRBTree< CRC32_t > &tree );
|
||||
|
||||
char m_szBaseName[ 128 ]; // name w/out any subdirectory names
|
||||
char m_szClassName[ 128 ];
|
||||
char m_szFileName[ 128 ];
|
||||
bool m_bDirty;
|
||||
int m_nSelectedExpression;
|
||||
CUtlVector < CExpression > m_Expressions;
|
||||
|
||||
bool m_bIsPhonemeClass;
|
||||
};
|
||||
#endif // EXPCLASS_H
|
||||
472
utils/hlfaceposer/expression.cpp
Normal file
472
utils/hlfaceposer/expression.cpp
Normal file
@@ -0,0 +1,472 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "hlfaceposer.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include "expressions.h"
|
||||
#include "StudioModel.h"
|
||||
#include "filesystem.h"
|
||||
#include "viewersettings.h"
|
||||
#include "matsyswin.h"
|
||||
#include "checksum_crc.h"
|
||||
#include "expclass.h"
|
||||
#include "ControlPanel.h"
|
||||
#include "faceposer_models.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static int g_counter = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpression::CExpression( void )
|
||||
{
|
||||
name[ 0 ] = 0;
|
||||
index = 0;
|
||||
description[ 0 ] = 0;
|
||||
memset( setting, 0, sizeof( setting ) );
|
||||
|
||||
for ( int i = 0; i < MAX_FP_MODELS; i++ )
|
||||
{
|
||||
m_Bitmap[ i ].valid = false;
|
||||
}
|
||||
|
||||
m_nUndoCurrent = 0;
|
||||
m_bModified = false;
|
||||
|
||||
m_bSelected = false;
|
||||
|
||||
m_bDirty = false;
|
||||
|
||||
expressionclass[ 0 ] = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Copy constructor
|
||||
// Input : from -
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpression::CExpression( const CExpression& from )
|
||||
{
|
||||
int i;
|
||||
|
||||
strcpy( name, from.name );
|
||||
index = from.index;
|
||||
strcpy( description, from.description );
|
||||
|
||||
for ( i = 0; i < MAX_FP_MODELS; i++ )
|
||||
{
|
||||
m_Bitmap[ i ] = from.m_Bitmap[ i ];
|
||||
}
|
||||
|
||||
m_bModified = from.m_bModified;
|
||||
|
||||
for ( i = 0 ; i < from.undo.Count(); i++ )
|
||||
{
|
||||
CExpUndoInfo *newUndo = new CExpUndoInfo();
|
||||
*newUndo = *from.undo[ i ];
|
||||
undo.AddToTail( newUndo );
|
||||
}
|
||||
|
||||
m_nUndoCurrent = from.m_nUndoCurrent;
|
||||
|
||||
m_bSelected = from.m_bSelected;
|
||||
|
||||
m_bDirty = from.m_bDirty;
|
||||
|
||||
strcpy( expressionclass, from.expressionclass );
|
||||
|
||||
memcpy( setting, from.setting, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memcpy( weight, from.weight, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpression::~CExpression( void )
|
||||
{
|
||||
ResetUndo();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpression::GetDirty( void )
|
||||
{
|
||||
return m_bDirty;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : dirty -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::SetDirty( bool dirty )
|
||||
{
|
||||
m_bDirty = dirty;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float *CExpression::GetSettings( void )
|
||||
{
|
||||
return setting;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float *CExpression::GetWeights( void )
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : mod -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::SetModified( bool mod )
|
||||
{
|
||||
m_bModified = mod;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpression::GetModified( void )
|
||||
{
|
||||
return m_bModified;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : selected -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::SetSelected( bool selected )
|
||||
{
|
||||
m_bSelected = selected;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpression::GetSelected( void )
|
||||
{
|
||||
return m_bSelected;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::ResetUndo( void )
|
||||
{
|
||||
CExpUndoInfo *u;
|
||||
for ( int i = 0; i < undo.Count(); i++ )
|
||||
{
|
||||
u = undo[ i ];
|
||||
delete u;
|
||||
}
|
||||
|
||||
undo.RemoveAll();
|
||||
m_nUndoCurrent = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpression::CanRedo( void )
|
||||
{
|
||||
if ( !undo.Count() )
|
||||
return false;
|
||||
|
||||
if ( m_nUndoCurrent == 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpression::CanUndo( void )
|
||||
{
|
||||
if ( !undo.Count() )
|
||||
return false;
|
||||
|
||||
if ( m_nUndoCurrent >= undo.Count() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CExpression::UndoLevels( void )
|
||||
{
|
||||
return undo.Count();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CExpression::UndoCurrent( void )
|
||||
{
|
||||
return m_nUndoCurrent;
|
||||
}
|
||||
|
||||
void ChecksumFlexControllers( bool bSpew, char const *name, CRC32_t &crc, const float *settings, const float *weights );
|
||||
|
||||
CRC32_t CExpression::GetBitmapCRC()
|
||||
{
|
||||
CRC32_t crc;
|
||||
|
||||
float *s = setting;
|
||||
float *w = weight;
|
||||
|
||||
// Note, we'll use the pristine values if this has changed
|
||||
if ( undo.Count() >= 1 )
|
||||
{
|
||||
s = undo[ undo.Count() - 1 ]->setting;
|
||||
w = undo[ undo.Count() - 1 ]->weight;
|
||||
}
|
||||
|
||||
// This walks the global controllers sorted by name and only includes values with a setting or value which is != 0.0f
|
||||
|
||||
ChecksumFlexControllers( false, name, crc, s, w );
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CExpression::GetBitmapCheckSum()
|
||||
{
|
||||
CRC32_t crc = GetBitmapCRC();
|
||||
|
||||
// Create string name out of binary data
|
||||
static char hex[ 9 ];
|
||||
Q_binarytohex( (byte *)&crc, sizeof( crc ), hex, sizeof( hex ) );
|
||||
return hex;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CExpression::GetBitmapFilename( int modelindex )
|
||||
{
|
||||
static char filename[ 256 ] = { 0 };
|
||||
|
||||
char const *classname = "error";
|
||||
CExpClass *cl = GetExpressionClass();
|
||||
if ( cl )
|
||||
{
|
||||
classname = cl->GetBaseName();
|
||||
}
|
||||
|
||||
char modelName[512], modelNameTemp[512];
|
||||
Q_strncpy( modelNameTemp, models->GetModelName( modelindex ), sizeof( modelNameTemp ) );
|
||||
|
||||
char const *in = modelNameTemp;
|
||||
char *out = modelName;
|
||||
|
||||
while ( *in )
|
||||
{
|
||||
if ( V_isalnum( *in ) ||
|
||||
*in == '_' ||
|
||||
*in == '\\' ||
|
||||
*in == '/' ||
|
||||
*in == '.' ||
|
||||
*in == ':' )
|
||||
{
|
||||
*out++ = *in;
|
||||
}
|
||||
in++;
|
||||
}
|
||||
*out = 0;
|
||||
|
||||
|
||||
sprintf( filename, "expressions/%s/%s/%s.bmp", modelName, classname, GetBitmapCheckSum() );
|
||||
|
||||
Q_FixSlashes( filename );
|
||||
strlwr( filename );
|
||||
|
||||
CreatePath( filename );
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
void CExpression::CreateNewBitmap( int modelindex )
|
||||
{
|
||||
MatSysWindow *pWnd = g_pMatSysWindow;
|
||||
if ( !pWnd )
|
||||
return;
|
||||
|
||||
StudioModel *model = models->GetStudioModel( modelindex );
|
||||
if ( !model )
|
||||
return;
|
||||
|
||||
CStudioHdr *hdr = models->GetStudioHeader( modelindex );
|
||||
if ( !hdr )
|
||||
return;
|
||||
|
||||
char filename[ 256 ];
|
||||
strcpy( filename, GetBitmapFilename( modelindex ) );
|
||||
if ( !Q_strstr( filename, ".bmp" ) )
|
||||
return;
|
||||
|
||||
models->CreateNewBitmap( modelindex, filename, 0, 128, true, this, &m_Bitmap[ modelindex ] );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *exp -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::PushUndoInformation( void )
|
||||
{
|
||||
SetModified( true );
|
||||
|
||||
// A real change to the data wipes out the redo counters
|
||||
WipeRedoInformation();
|
||||
|
||||
CExpUndoInfo *newundo = new CExpUndoInfo;
|
||||
|
||||
memcpy( newundo->setting, setting, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memset( newundo->redosetting, 0, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memcpy( newundo->weight, weight, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memset( newundo->redoweight, 0, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
|
||||
newundo->counter = g_counter++;
|
||||
|
||||
undo.AddToHead( newundo );
|
||||
|
||||
Assert( m_nUndoCurrent == 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *exp -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::PushRedoInformation( void )
|
||||
{
|
||||
Assert( undo.Count() >= 1 );
|
||||
|
||||
CExpUndoInfo *redo = undo[ 0 ];
|
||||
memcpy( redo->redosetting, setting, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memcpy( redo->redoweight, weight, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *exp -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::Undo( void )
|
||||
{
|
||||
if ( !CanUndo() )
|
||||
return;
|
||||
|
||||
Assert( m_nUndoCurrent < undo.Count() );
|
||||
|
||||
CExpUndoInfo *u = undo[ m_nUndoCurrent++ ];
|
||||
Assert( u );
|
||||
|
||||
memcpy( setting, u->setting, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memcpy( weight, u->weight, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *exp -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::Redo( void )
|
||||
{
|
||||
if ( !CanRedo() )
|
||||
return;
|
||||
|
||||
Assert( m_nUndoCurrent >= 1 );
|
||||
Assert( m_nUndoCurrent <= undo.Count() );
|
||||
|
||||
CExpUndoInfo *u = undo[ --m_nUndoCurrent ];
|
||||
Assert( u );
|
||||
|
||||
memcpy( setting, u->redosetting, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memcpy( weight, u->redoweight, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *exp -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::WipeRedoInformation( void )
|
||||
{
|
||||
// Wipe out all stuff newer then m_nUndoCurrent
|
||||
int level = 0;
|
||||
while ( level < m_nUndoCurrent )
|
||||
{
|
||||
CExpUndoInfo *u = undo[ 0 ];
|
||||
undo.Remove( 0 );
|
||||
Assert( u );
|
||||
delete u;
|
||||
level++;
|
||||
}
|
||||
|
||||
m_nUndoCurrent = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Revert to last saved state
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::Revert( void )
|
||||
{
|
||||
SetDirty( false );
|
||||
|
||||
if ( undo.Count() <= 0 )
|
||||
return;
|
||||
|
||||
// Go back to original data
|
||||
CExpUndoInfo *u = undo[ undo.Count() - 1 ];
|
||||
Assert( u );
|
||||
|
||||
memcpy( setting, u->setting, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
memcpy( weight, u->weight, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) );
|
||||
|
||||
ResetUndo();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : CExpClass
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpClass *CExpression::GetExpressionClass( void )
|
||||
{
|
||||
CExpClass *cl = expressions->FindClass( expressionclass, false );
|
||||
if ( !cl )
|
||||
{
|
||||
Assert( cl );
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *classname -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpression::SetExpressionClass( char const *classname )
|
||||
{
|
||||
strcpy( expressionclass, classname );
|
||||
}
|
||||
|
||||
115
utils/hlfaceposer/expression.h
Normal file
115
utils/hlfaceposer/expression.h
Normal file
@@ -0,0 +1,115 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EXPRESSION_H
|
||||
#define EXPRESSION_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "utlvector.h"
|
||||
#include "mxBitmapTools.h"
|
||||
#include "hlfaceposer.h"
|
||||
|
||||
#define GLOBAL_STUDIO_FLEX_CONTROL_COUNT ( MAXSTUDIOFLEXCTRL * 4 )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CExpUndoInfo
|
||||
{
|
||||
public:
|
||||
float setting[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
float weight[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
|
||||
float redosetting[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
float redoweight[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
|
||||
int counter;
|
||||
};
|
||||
|
||||
class CExpression;
|
||||
class CExpClass;
|
||||
|
||||
typedef uint32 CRC32_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CExpression
|
||||
{
|
||||
public:
|
||||
CExpression ( void );
|
||||
~CExpression ( void );
|
||||
|
||||
CExpression( const CExpression& from );
|
||||
|
||||
void SetModified( bool mod );
|
||||
bool GetModified( void );
|
||||
|
||||
void ResetUndo( void );
|
||||
|
||||
bool CanUndo( void );
|
||||
bool CanRedo( void );
|
||||
|
||||
int UndoLevels( void );
|
||||
int UndoCurrent( void );
|
||||
|
||||
const char *GetBitmapFilename( int modelindex );
|
||||
const char *GetBitmapCheckSum();
|
||||
CRC32_t GetBitmapCRC();
|
||||
void CreateNewBitmap( int modelindex );
|
||||
|
||||
void PushUndoInformation( void );
|
||||
void PushRedoInformation( void );
|
||||
|
||||
void Undo( void );
|
||||
void Redo( void );
|
||||
|
||||
void SetSelected( bool selected );
|
||||
bool GetSelected( void );
|
||||
|
||||
float *GetSettings( void );
|
||||
float *GetWeights( void );
|
||||
|
||||
bool GetDirty( void );
|
||||
void SetDirty( bool dirty );
|
||||
|
||||
void Revert( void );
|
||||
|
||||
CExpClass *GetExpressionClass( void );
|
||||
void SetExpressionClass( char const *classname );
|
||||
|
||||
// name of expression
|
||||
char name[32];
|
||||
int index;
|
||||
char description[128];
|
||||
|
||||
mxbitmapdata_t m_Bitmap[ MAX_FP_MODELS ];
|
||||
|
||||
bool m_bModified;
|
||||
|
||||
// Undo information
|
||||
CUtlVector< CExpUndoInfo * > undo;
|
||||
int m_nUndoCurrent;
|
||||
|
||||
bool m_bSelected;
|
||||
|
||||
bool m_bDirty;
|
||||
|
||||
private:
|
||||
// settings of fields
|
||||
float setting[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
float weight[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
|
||||
char expressionclass[ 128 ];
|
||||
|
||||
void WipeRedoInformation( void );
|
||||
};
|
||||
|
||||
#endif // EXPRESSION_H
|
||||
78
utils/hlfaceposer/expressionproperties.cpp
Normal file
78
utils/hlfaceposer/expressionproperties.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <mxtk/mx.h>
|
||||
#include "resource.h"
|
||||
#include "ExpressionProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
|
||||
static CExpressionParams g_Params;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK ExpressionPropertiesDialogProc
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK ExpressionPropertiesDialogProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
// Insert code here to put the string (to find and replace with)
|
||||
// into the edit controls.
|
||||
// ...
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_EXPRESSIONNAME, g_Params.m_szName );
|
||||
SetDlgItemText( hwndDlg, IDC_EXPRESSIONDESC, g_Params.m_szDescription );
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_EXPRESSIONNAME ) );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
g_Params.m_szName[ 0 ] = 0;
|
||||
GetDlgItemText( hwndDlg, IDC_EXPRESSIONNAME, g_Params.m_szName, 256 );
|
||||
GetDlgItemText( hwndDlg, IDC_EXPRESSIONDESC, g_Params.m_szDescription, 256 );
|
||||
EndDialog( hwndDlg, 1 );
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int ExpressionProperties( CExpressionParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_EXPRESSIONPROPERTIES ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)ExpressionPropertiesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
27
utils/hlfaceposer/expressionproperties.h
Normal file
27
utils/hlfaceposer/expressionproperties.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EXPRESSIONPROPERTIES_H
|
||||
#define EXPRESSIONPROPERTIES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CExpressionParams : public CBaseDialogParams
|
||||
{
|
||||
char m_szName[ 256 ];
|
||||
char m_szDescription[ 256 ];
|
||||
};
|
||||
|
||||
int ExpressionProperties( CExpressionParams *params );
|
||||
|
||||
#endif // EXPRESSIONPROPERTIES_H
|
||||
692
utils/hlfaceposer/expressions.cpp
Normal file
692
utils/hlfaceposer/expressions.cpp
Normal file
@@ -0,0 +1,692 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "hlfaceposer.h"
|
||||
#include "expressions.h"
|
||||
#include <mxtk/mx.h>
|
||||
#include "ControlPanel.h"
|
||||
#include "StudioModel.h"
|
||||
#include "expclass.h"
|
||||
#include "mxExpressionTab.h"
|
||||
#include "mxExpressionTray.h"
|
||||
#include "FileSystem.h"
|
||||
#include "faceposer_models.h"
|
||||
#include "UtlDict.h"
|
||||
#include "scriplib.h"
|
||||
#include "checksum_crc.h"
|
||||
|
||||
bool Sys_Error(const char *pMsg, ...);
|
||||
extern char g_appTitle[];
|
||||
|
||||
static CUtlVector< CUtlSymbol > g_GlobalFlexControllers;
|
||||
static CUtlDict< int, int > g_GlobalFlexControllerLookup;
|
||||
|
||||
void ChecksumFlexControllers( bool bSpew, char const *name, CRC32_t &crc, const float *settings, const float *weights )
|
||||
{
|
||||
CRC32_Init( &crc );
|
||||
|
||||
// Walk them alphabetically so that load order doesn't matter
|
||||
for ( int i = g_GlobalFlexControllerLookup.First() ;
|
||||
i != g_GlobalFlexControllerLookup.InvalidIndex();
|
||||
i = g_GlobalFlexControllerLookup.Next( i ) )
|
||||
{
|
||||
int controllerIndex = g_GlobalFlexControllerLookup[ i ];
|
||||
char const *pszName = g_GlobalFlexControllerLookup.GetElementName( i );
|
||||
|
||||
// Only count active controllers in checksum
|
||||
float s = settings[ controllerIndex ];
|
||||
float w = weights[ controllerIndex ];
|
||||
|
||||
if ( s == 0.0f && w == 0.0f )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CRC32_ProcessBuffer( &crc, (void *)pszName, Q_strlen( pszName ) );
|
||||
CRC32_ProcessBuffer( &crc, (void *)&s, sizeof( s ) );
|
||||
CRC32_ProcessBuffer( &crc, (void *)&w, sizeof( w ) );
|
||||
|
||||
if ( bSpew )
|
||||
{
|
||||
Msg( "[%d] %s == %f %f\n", controllerIndex, pszName, s, w );
|
||||
}
|
||||
}
|
||||
|
||||
CRC32_Final( &crc );
|
||||
|
||||
if ( bSpew )
|
||||
{
|
||||
char hex[ 17 ];
|
||||
Q_binarytohex( (const byte *)&crc, sizeof( crc ), hex, sizeof( hex ) );
|
||||
Msg( "%s checksum = %sf\n", name, hex );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : index -
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *GetGlobalFlexControllerName( int index )
|
||||
{
|
||||
return g_GlobalFlexControllers[ index ].String();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int GetGlobalFlexControllerCount( void )
|
||||
{
|
||||
return g_GlobalFlexControllers.Count();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Accumulates throughout runtime session, oh well
|
||||
// Input : *szName -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int AddGlobalFlexController( StudioModel *model, char *szName )
|
||||
{
|
||||
int idx = g_GlobalFlexControllerLookup.Find( szName );
|
||||
if ( idx != g_GlobalFlexControllerLookup.InvalidIndex() )
|
||||
{
|
||||
return g_GlobalFlexControllerLookup[ idx ];
|
||||
}
|
||||
|
||||
CUtlSymbol sym;
|
||||
sym = szName;
|
||||
idx = g_GlobalFlexControllers.AddToTail( sym );
|
||||
g_GlobalFlexControllerLookup.Insert( szName, idx );
|
||||
// Con_Printf( "Added global flex controller %i %s from %s\n", idx, szName, model->GetStudioHdr()->name );
|
||||
return idx;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *model -
|
||||
//-----------------------------------------------------------------------------
|
||||
void SetupModelFlexcontrollerLinks( StudioModel *model )
|
||||
{
|
||||
if ( !model )
|
||||
return;
|
||||
|
||||
CStudioHdr *hdr = model->GetStudioHdr();
|
||||
if ( !hdr )
|
||||
return;
|
||||
|
||||
if ( hdr->numflexcontrollers() <= 0 )
|
||||
return;
|
||||
|
||||
// Already set up!!!
|
||||
if ( hdr->pFlexcontroller( LocalFlexController_t(0) )->localToGlobal != -1 )
|
||||
return;
|
||||
|
||||
for (LocalFlexController_t i = LocalFlexController_t(0); i < hdr->numflexcontrollers(); i++)
|
||||
{
|
||||
int j = AddGlobalFlexController( model, hdr->pFlexcontroller( i )->pszName() );
|
||||
hdr->pFlexcontroller( i )->localToGlobal = j;
|
||||
model->SetFlexController( i, 0.0f );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CExpressionManager : public IExpressionManager
|
||||
{
|
||||
public:
|
||||
CExpressionManager( void );
|
||||
~CExpressionManager( void );
|
||||
|
||||
void Reset( void );
|
||||
|
||||
void ActivateExpressionClass( CExpClass *cl );
|
||||
|
||||
// File I/O
|
||||
void LoadClass( const char *filename );
|
||||
void CreateNewClass( const char *filename );
|
||||
bool CloseClass( CExpClass *cl );
|
||||
|
||||
CExpClass *AddCExpClass( const char *classname, const char *filename );
|
||||
int GetNumClasses( void );
|
||||
|
||||
CExpression *GetCopyBuffer( void );
|
||||
|
||||
bool CanClose( void );
|
||||
|
||||
CExpClass *GetActiveClass( void );
|
||||
CExpClass *GetClass( int num );
|
||||
CExpClass *FindClass( const char *classname, bool bMatchBaseNameOnly );
|
||||
|
||||
private:
|
||||
// Methods
|
||||
const char *GetClassnameFromFilename( const char *filename );
|
||||
|
||||
// UI
|
||||
void PopulateClassCB( CExpClass *cl );
|
||||
|
||||
void RemoveCExpClass( CExpClass *cl );
|
||||
|
||||
private:
|
||||
// Data
|
||||
CExpClass *m_pActiveClass;
|
||||
CUtlVector < CExpClass * > m_Classes;
|
||||
|
||||
CExpression m_CopyBuffer;
|
||||
};
|
||||
|
||||
// Expose interface
|
||||
static CExpressionManager g_ExpressionManager;
|
||||
IExpressionManager *expressions = &g_ExpressionManager;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpressionManager::CExpressionManager( void )
|
||||
{
|
||||
m_pActiveClass = NULL;
|
||||
Reset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpressionManager::~CExpressionManager( void )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpressionManager::Reset( void )
|
||||
{
|
||||
while ( m_Classes.Count() > 0 )
|
||||
{
|
||||
CExpClass *p = m_Classes[ 0 ];
|
||||
m_Classes.Remove( 0 );
|
||||
delete p;
|
||||
}
|
||||
|
||||
m_pActiveClass = NULL;
|
||||
|
||||
memset( &m_CopyBuffer, 0, sizeof( m_CopyBuffer ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpClass *CExpressionManager::GetActiveClass( void )
|
||||
{
|
||||
return m_pActiveClass;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : num -
|
||||
// Output : CExpClass
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpClass *CExpressionManager::GetClass( int num )
|
||||
{
|
||||
return m_Classes[ num ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *classname -
|
||||
// *filename -
|
||||
// Output : CExpClass *
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpClass * CExpressionManager::AddCExpClass( const char *classname, const char *filename )
|
||||
{
|
||||
Assert( !FindClass( classname, false ) );
|
||||
|
||||
CExpClass *pclass = new CExpClass( classname );
|
||||
if ( !pclass )
|
||||
return NULL;
|
||||
|
||||
m_Classes.AddToTail( pclass );
|
||||
|
||||
pclass->SetFileName( filename );
|
||||
|
||||
return pclass;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *cl -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpressionManager::RemoveCExpClass( CExpClass *cl )
|
||||
{
|
||||
for ( int i = 0; i < m_Classes.Count(); i++ )
|
||||
{
|
||||
CExpClass *p = m_Classes[ i ];
|
||||
if ( p == cl )
|
||||
{
|
||||
m_Classes.Remove( i );
|
||||
delete p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_Classes.Count() >= 1 )
|
||||
{
|
||||
ActivateExpressionClass( m_Classes[ 0 ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivateExpressionClass( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *cl -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpressionManager::ActivateExpressionClass( CExpClass *cl )
|
||||
{
|
||||
m_pActiveClass = cl;
|
||||
int select = 0;
|
||||
for ( int i = 0; i < GetNumClasses(); i++ )
|
||||
{
|
||||
CExpClass *c = GetClass( i );
|
||||
if ( cl == c )
|
||||
{
|
||||
select = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_pExpressionClass->select( select );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int CExpressionManager::GetNumClasses( void )
|
||||
{
|
||||
return m_Classes.Count();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *classname -
|
||||
// Output : CExpClass
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpClass *CExpressionManager::FindClass( const char *classname, bool bMatchBaseNameOnly )
|
||||
{
|
||||
char search[ 256 ];
|
||||
if ( bMatchBaseNameOnly )
|
||||
{
|
||||
Q_FileBase( classname, search, sizeof( search ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( search, classname, sizeof( search ) );
|
||||
}
|
||||
|
||||
Q_FixSlashes( search );
|
||||
Q_strlower( search );
|
||||
|
||||
for ( int i = 0; i < m_Classes.Count(); i++ )
|
||||
{
|
||||
CExpClass *cl = m_Classes[ i ];
|
||||
|
||||
if ( !Q_stricmp( search, bMatchBaseNameOnly ? cl->GetBaseName() : cl->GetName() ) )
|
||||
{
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
// Output : const char
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CExpressionManager::GetClassnameFromFilename( const char *filename )
|
||||
{
|
||||
char cleanname[ 256 ];
|
||||
static char classname[ 256 ];
|
||||
classname[ 0 ] = 0;
|
||||
|
||||
Assert( filename && filename[ 0 ] );
|
||||
|
||||
// Strip the .txt
|
||||
Q_StripExtension( filename, cleanname, sizeof( cleanname ) );
|
||||
|
||||
char *p = Q_stristr( cleanname, "expressions" );
|
||||
if ( p )
|
||||
{
|
||||
Q_strncpy( classname, p + Q_strlen( "expressions" ) + 1, sizeof( classname ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( 0 );
|
||||
Q_strncpy( classname, cleanname, sizeof( classname ) );
|
||||
}
|
||||
|
||||
Q_FixSlashes( classname );
|
||||
Q_strlower( classname );
|
||||
return classname;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : CExpression
|
||||
//-----------------------------------------------------------------------------
|
||||
CExpression *CExpressionManager::GetCopyBuffer( void )
|
||||
{
|
||||
return &m_CopyBuffer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpressionManager::CanClose( void )
|
||||
{
|
||||
for ( int i = 0; i < m_Classes.Count(); i++ )
|
||||
{
|
||||
CExpClass *pclass = m_Classes[ i ];
|
||||
if ( pclass->GetDirty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpressionManager::LoadClass( const char *inpath )
|
||||
{
|
||||
MDLCACHE_CRITICAL_SECTION_( g_pMDLCache );
|
||||
|
||||
if ( inpath[ 0 ] == '/' || inpath[ 0 ] == '\\' )
|
||||
++inpath;
|
||||
|
||||
char filename[ 512 ];
|
||||
Q_strncpy( filename, inpath, sizeof( filename ) );
|
||||
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if ( !hdr )
|
||||
{
|
||||
Con_ErrorPrintf( "Can't load expressions from %s, must load a .mdl file first!\n",
|
||||
filename );
|
||||
return;
|
||||
}
|
||||
|
||||
Con_Printf( "Loading expressions from %s\n", filename );
|
||||
|
||||
const char *classname = GetClassnameFromFilename( filename );
|
||||
|
||||
// Already loaded, don't do anything
|
||||
if ( FindClass( classname, false ) )
|
||||
return;
|
||||
|
||||
// Import actual data
|
||||
LoadScriptFile( filename, SCRIPT_USE_RELATIVE_PATH );
|
||||
|
||||
CExpClass *active = AddCExpClass( classname, filename );
|
||||
if ( !active )
|
||||
return;
|
||||
|
||||
ActivateExpressionClass( active );
|
||||
|
||||
int numflexmaps = 0;
|
||||
int flexmap[128]; // maps file local controls into global controls
|
||||
LocalFlexController_t localflexmap[128]; // maps file local controls into local controls
|
||||
bool bHasWeighting = false;
|
||||
bool bNormalized = false;
|
||||
|
||||
EnableStickySnapshotMode( );
|
||||
|
||||
while (1)
|
||||
{
|
||||
GetToken (true);
|
||||
if (endofscript)
|
||||
break;
|
||||
if (stricmp( token, "$keys" ) == 0)
|
||||
{
|
||||
numflexmaps = 0;
|
||||
while (TokenAvailable())
|
||||
{
|
||||
flexmap[numflexmaps] = -1;
|
||||
localflexmap[numflexmaps] = LocalFlexController_t(-1);
|
||||
|
||||
GetToken( false );
|
||||
bool bFound = false;
|
||||
for (LocalFlexController_t i = LocalFlexController_t(0); i < hdr->numflexcontrollers(); i++)
|
||||
{
|
||||
if (stricmp( hdr->pFlexcontroller(i)->pszName(), token ) == 0)
|
||||
{
|
||||
localflexmap[numflexmaps] = i;
|
||||
flexmap[numflexmaps] = AddGlobalFlexController( models->GetActiveStudioModel(),
|
||||
hdr->pFlexcontroller(i)->pszName() );
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !bFound )
|
||||
{
|
||||
flexmap[ numflexmaps ] = AddGlobalFlexController( models->GetActiveStudioModel(), token );
|
||||
}
|
||||
numflexmaps++;
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( token, "$hasweighting" ) )
|
||||
{
|
||||
bHasWeighting = true;
|
||||
}
|
||||
else if ( !stricmp( token, "$normalized" ) )
|
||||
{
|
||||
bNormalized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
float setting[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
float weight[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
char name[ 256 ];
|
||||
char desc[ 256 ];
|
||||
int index;
|
||||
|
||||
memset( setting, 0, sizeof( setting ) );
|
||||
memset( weight, 0, sizeof( weight ) );
|
||||
|
||||
strcpy( name, token );
|
||||
|
||||
// phoneme index
|
||||
GetToken( false );
|
||||
if (token[1] == 'x')
|
||||
{
|
||||
sscanf( &token[2], "%x", &index );
|
||||
}
|
||||
else
|
||||
{
|
||||
index = (int)token[0];
|
||||
}
|
||||
|
||||
// key values
|
||||
for (int i = 0; i < numflexmaps; i++)
|
||||
{
|
||||
if (flexmap[i] > -1)
|
||||
{
|
||||
GetToken( false );
|
||||
setting[flexmap[i]] = atof( token );
|
||||
if (bHasWeighting)
|
||||
{
|
||||
GetToken( false );
|
||||
weight[flexmap[i]] = atof( token );
|
||||
}
|
||||
else
|
||||
{
|
||||
weight[flexmap[i]] = 1.0;
|
||||
}
|
||||
|
||||
if ( bNormalized && localflexmap[ i ] > -1 )
|
||||
{
|
||||
mstudioflexcontroller_t *pFlex = hdr->pFlexcontroller( localflexmap[i] );
|
||||
if ( pFlex->min != pFlex->max )
|
||||
{
|
||||
setting[flexmap[i]] = Lerp( setting[flexmap[i]], pFlex->min, pFlex->max );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetToken( false );
|
||||
if (bHasWeighting)
|
||||
{
|
||||
GetToken( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// description
|
||||
GetToken( false );
|
||||
strcpy( desc, token );
|
||||
|
||||
CExpression *exp = active->AddExpression( name, desc, setting, weight, false, false );
|
||||
if ( active->IsPhonemeClass() && exp )
|
||||
{
|
||||
if ( exp->index != index )
|
||||
{
|
||||
Con_Printf( "CExpressionManager::LoadClass (%s): phoneme index for %s in .txt file is wrong (expecting %i got %i), ignoring...\n",
|
||||
classname, name, exp->index, index );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
active->CheckBitmapConsistency();
|
||||
|
||||
DisableStickySnapshotMode( );
|
||||
|
||||
PopulateClassCB( active );
|
||||
|
||||
active->DeselectExpression();
|
||||
|
||||
Assert( !active->GetDirty() );
|
||||
active->SetDirty( false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpressionManager::CreateNewClass( const char *filename )
|
||||
{
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if ( !hdr )
|
||||
{
|
||||
Con_ErrorPrintf( "Can't create new expression file %s, must load a .mdl file first!\n", filename );
|
||||
return;
|
||||
}
|
||||
|
||||
// Tell the use that the filename was loaded, expressions are empty for now
|
||||
const char *classname = GetClassnameFromFilename( filename );
|
||||
|
||||
// Already loaded, don't do anything
|
||||
if ( FindClass( classname, false ) )
|
||||
return;
|
||||
|
||||
Con_Printf( "Creating %s\n", filename );
|
||||
|
||||
CExpClass *active = AddCExpClass( classname, filename );
|
||||
if ( !active )
|
||||
return;
|
||||
|
||||
ActivateExpressionClass( active );
|
||||
|
||||
// Select the newly created class
|
||||
PopulateClassCB( active );
|
||||
|
||||
// Select first expression
|
||||
active->SelectExpression( 0 );
|
||||
|
||||
// Nothing has changed so far
|
||||
active->SetDirty( false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *cl -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CExpressionManager::CloseClass( CExpClass *cl )
|
||||
{
|
||||
if ( !cl )
|
||||
return true;
|
||||
|
||||
if ( cl->GetDirty() )
|
||||
{
|
||||
int retval = mxMessageBox( NULL, va( "Save changes to class '%s'?", cl->GetName() ), g_appTitle, MX_MB_YESNOCANCEL );
|
||||
if ( retval == 2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( retval == 0 )
|
||||
{
|
||||
Con_Printf( "Saving changes to %s : %s\n", cl->GetName(), cl->GetFileName() );
|
||||
cl->Save();
|
||||
}
|
||||
}
|
||||
|
||||
// The memory can be freed here, so be more careful
|
||||
char temp[ 256 ];
|
||||
strcpy( temp, cl->GetName() );
|
||||
|
||||
RemoveCExpClass( cl );
|
||||
|
||||
Con_Printf( "Closed expression class %s\n", temp );
|
||||
|
||||
CExpClass *active = GetActiveClass();
|
||||
if ( !active )
|
||||
{
|
||||
PopulateClassCB( NULL );
|
||||
g_pExpressionTrayTool->redraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Select the first remaining class
|
||||
PopulateClassCB( active );
|
||||
|
||||
// Select first expression
|
||||
active->DeselectExpression();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : classnum -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CExpressionManager::PopulateClassCB( CExpClass *current )
|
||||
{
|
||||
g_pExpressionClass->removeAll();
|
||||
int select = 0;
|
||||
for ( int i = 0; i < GetNumClasses(); i++ )
|
||||
{
|
||||
CExpClass *cl = GetClass( i );
|
||||
if ( !cl )
|
||||
continue;
|
||||
|
||||
g_pExpressionClass->add( cl->GetName() );
|
||||
|
||||
if ( cl == current )
|
||||
{
|
||||
select = i;
|
||||
}
|
||||
}
|
||||
|
||||
g_pExpressionClass->select( select );
|
||||
}
|
||||
51
utils/hlfaceposer/expressions.h
Normal file
51
utils/hlfaceposer/expressions.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#if !defined( EXPRESSIONS_H )
|
||||
#define EXPRESSIONS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "studio.h"
|
||||
#include "expression.h"
|
||||
|
||||
class FlexPanel;
|
||||
class ControlPanel;
|
||||
class MatSysWindow;
|
||||
class CExpClass;
|
||||
class ExpressionTool;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class IExpressionManager
|
||||
{
|
||||
public:
|
||||
virtual void Reset( void ) = 0;
|
||||
|
||||
// File i/o
|
||||
virtual void LoadClass( const char *filename ) = 0;
|
||||
virtual void CreateNewClass( const char *filename ) = 0;
|
||||
virtual bool CloseClass( CExpClass *cl ) = 0;
|
||||
virtual void ActivateExpressionClass( CExpClass *cl ) = 0;
|
||||
|
||||
virtual CExpClass *AddCExpClass( const char *classname, const char *filename ) = 0;
|
||||
virtual int GetNumClasses( void ) = 0;
|
||||
|
||||
virtual CExpression *GetCopyBuffer( void ) = 0;
|
||||
|
||||
virtual bool CanClose( void ) = 0;
|
||||
|
||||
virtual CExpClass *GetActiveClass( void ) = 0;
|
||||
virtual CExpClass *GetClass( int num ) = 0;
|
||||
virtual CExpClass *FindClass( const char *classname, bool bMatchBaseNameOnly ) = 0;
|
||||
|
||||
};
|
||||
|
||||
extern IExpressionManager *expressions;
|
||||
|
||||
#endif // EXPRESSIONS_H
|
||||
4816
utils/hlfaceposer/expressiontool.cpp
Normal file
4816
utils/hlfaceposer/expressiontool.cpp
Normal file
File diff suppressed because it is too large
Load Diff
368
utils/hlfaceposer/expressiontool.h
Normal file
368
utils/hlfaceposer/expressiontool.h
Normal file
@@ -0,0 +1,368 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef EXPRESSIONTOOL_H
|
||||
#define EXPRESSIONTOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "studio.h"
|
||||
#include "UtlVector.h"
|
||||
#include "tier1/utldict.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
|
||||
class CChoreoEvent;
|
||||
class TimelineItem;
|
||||
class CFlexAnimationTrack;
|
||||
class CExpClass;
|
||||
class CChoreoWidgetDrawHelper;
|
||||
class CExpressionToolWorkspace;
|
||||
class CChoreoView;
|
||||
class CFlexTimingTag;
|
||||
class CExpression;
|
||||
class mxSlider;
|
||||
|
||||
#define IDC_EXPRESSIONTOOLVSCROLL 1000
|
||||
#define IDC_ADDTRACKS 1001
|
||||
#define IDC_COLLAPSEALL 1002
|
||||
#define IDC_EXPANDALL 1003
|
||||
#define IDC_EXPANDVALID 1004
|
||||
#define IDC_INSERT_TIMING_TAG 1005
|
||||
#define IDC_DELETE_TIMING_TAG 1006
|
||||
#define IDC_LOCK_TIMING_TAG 1007
|
||||
#define IDC_UNLOCK_TIMING_TAG 1008
|
||||
|
||||
#define IDC_COPY_TO_FLEX 1009
|
||||
#define IDC_COPY_FROM_FLEX 1010
|
||||
|
||||
#define IDC_NEW_EXPRESSION_FROM_FLEXANIMATION 1011
|
||||
|
||||
#define IDC_EXPORT_FA 1012
|
||||
#define IDC_IMPORT_FA 1013
|
||||
|
||||
#define IDC_REDO_FA 1014
|
||||
#define IDC_UNDO_FA 1015
|
||||
|
||||
#define IDC_TL_COPY 1016
|
||||
#define IDC_TL_PASTE 1017
|
||||
#define IDC_TL_DELETE 1018
|
||||
#define IDC_TL_DESELECT 1019
|
||||
#define IDC_TL_SELECTALL 1020
|
||||
|
||||
#define IDC_TL_COLLAPSE 1021
|
||||
#define IDC_TL_EXPAND 1022
|
||||
#define IDC_TL_ENABLE 1023
|
||||
#define IDC_TL_DISABLE 1024
|
||||
|
||||
#define IDC_TL_EDITNORMAL 1025
|
||||
#define IDC_TL_EDITLEFTRIGHT 1026
|
||||
|
||||
#define IDC_COLLAPSE_ALL_EXCEPT 1027
|
||||
#define IDC_DISABLE_ALL_EXCEPT 1028
|
||||
#define IDC_ENABLE_ALL_VALID 1029
|
||||
|
||||
#define IDC_TL_SNAPSELECTED 1030
|
||||
#define IDC_TL_SNAPPOINTS 1031
|
||||
#define IDC_TL_DELETECOLUMN 1032
|
||||
#define IDC_TL_SNAPALL 1033
|
||||
|
||||
#define IDC_FLEX_CHANGESCALE 1034
|
||||
#define IDC_FLEXHSCROLL 1035
|
||||
|
||||
#define IDC_ET_SORT_BY_USED 1036
|
||||
#define IDC_ET_SORT_BY_NAME 1037
|
||||
|
||||
#define IDC_ET_SELECTION_DELETE 1038
|
||||
#define IDC_ET_SELECTION_EXCISE 1039
|
||||
|
||||
#define IDC_ET_RESET_ITEM_SIZE 1040
|
||||
#define IDC_ET_RESET_ALL_ITEM_SIZES 1041
|
||||
|
||||
#define IDC_FLEX_SCALESAMPLES 1042
|
||||
|
||||
#define IDC_TL_KB_TENSION 1050
|
||||
#define IDC_TL_KB_BIAS 1051
|
||||
#define IDC_TL_KB_CONTINUITY 1052
|
||||
|
||||
#define IDC_ET_EDGEPROPERTIES 1053
|
||||
#define IDC_ET_SELECTION_COPY 1054
|
||||
#define IDC_ET_SELECTION_PASTE 1055
|
||||
|
||||
#include "ExpressionSample.h"
|
||||
|
||||
class ExpressionTool : public mxWindow, public IFacePoserToolWindow
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
ExpressionTool( mxWindow *parent );
|
||||
~ExpressionTool( void );
|
||||
|
||||
virtual void Think( float dt );
|
||||
void ScrubThink( float dt, bool scrubbing );
|
||||
virtual bool IsScrubbing( void ) const;
|
||||
virtual bool IsProcessing( void );
|
||||
|
||||
|
||||
virtual int handleEvent( mxEvent *event );
|
||||
virtual void redraw( void );
|
||||
virtual bool PaintBackground();
|
||||
|
||||
bool SetFlexAnimationTrackFromExpression( int mx, int my, CExpClass *cl, CExpression *exp );
|
||||
|
||||
void SetEvent( CChoreoEvent *event );
|
||||
|
||||
bool HasCopyData( void );
|
||||
|
||||
void Copy( CFlexAnimationTrack *source );
|
||||
void Paste( CFlexAnimationTrack *destination );
|
||||
|
||||
void GetScrubHandleRect( RECT& rcHandle, bool clipped = false );
|
||||
void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper, RECT& rcHandle );
|
||||
void DrawEventEnd( CChoreoWidgetDrawHelper& drawHelper );
|
||||
|
||||
CChoreoEvent *GetSafeEvent( void );
|
||||
|
||||
void ExpandAll( void );
|
||||
void ExpandValid( void );
|
||||
|
||||
void LayoutItems( bool force = false );
|
||||
|
||||
void OnCopyToFlex( bool isEdited );
|
||||
void OnCopyFromFlex( bool isEdited );
|
||||
|
||||
void OnCopyToFlex( float scenetime, bool isEdited );
|
||||
void OnCopyFromFlex( float scenetime, bool isEdited );
|
||||
void OnSetSingleKeyFromFlex( char const *sliderName );
|
||||
|
||||
void OnNewExpression( void );
|
||||
void ShowContextMenu( mxEvent *event, bool include_track_menus );
|
||||
|
||||
void ForceScrubPosition( float newtime );
|
||||
void ForceScrubPositionFromSceneTime( float scenetime );
|
||||
|
||||
void SetScrubTime( float t );
|
||||
void SetScrubTargetTime( float t );
|
||||
|
||||
void DrawScrubHandles();
|
||||
|
||||
void SetClickedPos( int x, int y );
|
||||
float GetTimeForClickedPos( void );
|
||||
|
||||
void SetMouseOverPos( int x, int y );
|
||||
void GetMouseOverPos( int &x, int& y );
|
||||
void GetMouseOverPosRect( RECT& rcPos );
|
||||
void DrawMouseOverPos( CChoreoWidgetDrawHelper& drawHelper, RECT& rcPos );
|
||||
void DrawMouseOverPos();
|
||||
|
||||
|
||||
void MoveSelectedSamples( float dfdx, float dfdy, bool snap );
|
||||
void DeleteSelectedSamples( void );
|
||||
int CountSelectedSamples( void );
|
||||
void DeselectAll( void );
|
||||
|
||||
void RepositionHSlider( void );
|
||||
|
||||
bool IsFocusItem( TimelineItem *item );
|
||||
virtual void OnModelChanged();
|
||||
|
||||
float GetScrub() const { return m_flScrub; }
|
||||
float GetScrubberSceneTime();
|
||||
|
||||
void GetTimelineItems( CUtlVector< TimelineItem * >& list );
|
||||
void InvalidateLayout( void );
|
||||
|
||||
private:
|
||||
void DoTrackLookup( CChoreoEvent *event );
|
||||
|
||||
void AddFlexTimingTag( int mx );
|
||||
void DeleteFlexTimingTag( int mx, int my );
|
||||
|
||||
void OnSortByUsed( void );
|
||||
void OnSortByName( void );
|
||||
|
||||
void OnDeleteSelection( bool excise_time );
|
||||
void OnResetItemSize();
|
||||
void OnResetAllItemSizes();
|
||||
void ResampleControlPoints( CFlexTimingTag *tag, float newposition );
|
||||
|
||||
void OnScaleSamples();
|
||||
|
||||
void LockTimingTag( void );
|
||||
void UnlockTimingTag( void );
|
||||
|
||||
bool GetTimingTagRect( RECT& rcClient, CChoreoEvent *event, CFlexTimingTag *tag, RECT& rcTag );
|
||||
|
||||
// float MouseToFrac( int mx );
|
||||
//float MouseToTime( int mx );
|
||||
// int TimeToMouse( float t );
|
||||
|
||||
void GetWorkspaceLeftRight( int& left, int& right );
|
||||
|
||||
bool IsMouseOverScrubHandle( mxEvent *event );
|
||||
CFlexTimingTag *IsMouseOverTag( int mx, int my );
|
||||
|
||||
void DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper );
|
||||
|
||||
void DrawFocusRect( void );
|
||||
|
||||
void ApplyBounds( int& mx, int& my );
|
||||
void CalcBounds( int movetype );
|
||||
|
||||
void OnExportFlexAnimation( void );
|
||||
void OnImportFlexAnimation( void );
|
||||
|
||||
void OnUndo( void );
|
||||
void OnRedo( void );
|
||||
|
||||
void StartDragging( int dragtype, int startx, int starty, HCURSOR cursor );
|
||||
void GetWorkspaceRect( RECT &rc );
|
||||
void AddFocusRect( RECT& rc );
|
||||
void OnMouseMove( mxEvent *event );
|
||||
|
||||
// Mouse control over selected samples
|
||||
void SelectPoints( float starttime, float endtime );
|
||||
void FinishSelect( int startx, int mx );
|
||||
void FinishMoveSelection( int startx, int mx );
|
||||
void FinishMoveSelectionStart( int startx, int mx );
|
||||
void FinishMoveSelectionEnd( int startx, int mx );
|
||||
|
||||
// In general over the point area tray
|
||||
bool IsMouseOverPoints( int mx, int my );
|
||||
// Specifically over selected points
|
||||
bool IsMouseOverSelection( int mx, int my );
|
||||
bool IsMouseOverSelectionStartEdge( mxEvent *event );
|
||||
bool IsMouseOverSelectionEndEdge( mxEvent *event );
|
||||
|
||||
// Readjust slider
|
||||
void MoveTimeSliderToPos( int x );
|
||||
void OnChangeScale();
|
||||
int ComputeHPixelsNeeded( void );
|
||||
float GetTimeValueForMouse( int mx, bool clip = false );
|
||||
|
||||
void OnEdgeProperties();
|
||||
|
||||
public:
|
||||
int GetPixelForTimeValue( float time, bool *clipped = NULL );
|
||||
float GetPixelsPerSecond( void );
|
||||
void GetStartAndEndTime( float& st, float& ed );
|
||||
float GetEventEndTime();
|
||||
|
||||
private:
|
||||
|
||||
class CColumnCopier
|
||||
{
|
||||
public:
|
||||
class CTrackData
|
||||
{
|
||||
public:
|
||||
CTrackData() {};
|
||||
CTrackData( const CTrackData& other )
|
||||
{
|
||||
m_Samples[ 0 ].CopyArray( other.m_Samples[ 0 ].Base(), other.m_Samples[ 0 ].Count() );
|
||||
m_Samples[ 1 ].CopyArray( other.m_Samples[ 1 ].Base(), other.m_Samples[ 1 ].Count() );
|
||||
}
|
||||
CUtlVector< CExpressionSample > m_Samples[ 2 ];
|
||||
};
|
||||
|
||||
bool m_bActive;
|
||||
float m_flCopyTimes[ 2 ];
|
||||
CUtlDict< CTrackData, int > m_Data;
|
||||
|
||||
CColumnCopier() : m_bActive( false )
|
||||
{
|
||||
m_flCopyTimes[ 0 ] = m_flCopyTimes[ 1 ] = 0.0f;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_bActive = false;
|
||||
m_flCopyTimes[ 0 ] = m_flCopyTimes[ 1 ] = 0.0f;
|
||||
m_Data.Purge();
|
||||
}
|
||||
};
|
||||
|
||||
bool HasCopiedColumn();
|
||||
void OnCopyColumn();
|
||||
void OnPasteColumn();
|
||||
void ClearColumnCopy();
|
||||
|
||||
CColumnCopier m_ColumnCopy;
|
||||
|
||||
int m_nFocusEventGlobalID;
|
||||
|
||||
float m_flScrub;
|
||||
float m_flScrubTarget;
|
||||
|
||||
enum
|
||||
{
|
||||
DRAGTYPE_NONE = 0,
|
||||
DRAGTYPE_SCRUBBER,
|
||||
DRAGTYPE_FLEXTIMINGTAG,
|
||||
|
||||
DRAGTYPE_SELECTSAMPLES,
|
||||
DRAGTYPE_MOVESELECTION,
|
||||
DRAGTYPE_MOVESELECTIONSTART,
|
||||
DRAGTYPE_MOVESELECTIONEND,
|
||||
};
|
||||
|
||||
HCURSOR m_hPrevCursor;
|
||||
int m_nDragType;
|
||||
|
||||
int m_nStartX;
|
||||
int m_nStartY;
|
||||
int m_nLastX;
|
||||
int m_nLastY;
|
||||
|
||||
int m_nClickedX;
|
||||
int m_nClickedY;
|
||||
|
||||
bool m_bUseBounds;
|
||||
int m_nMinX;
|
||||
int m_nMaxX;
|
||||
|
||||
struct CFocusRect
|
||||
{
|
||||
RECT m_rcOrig;
|
||||
RECT m_rcFocus;
|
||||
};
|
||||
CUtlVector < CFocusRect > m_FocusRects;
|
||||
|
||||
CUtlVector< CExpressionSample > m_CopyData[2];
|
||||
|
||||
CExpressionToolWorkspace *m_pWorkspace;
|
||||
|
||||
CChoreoEvent *m_pLastEvent;
|
||||
|
||||
int m_nMousePos[ 2 ];
|
||||
|
||||
float m_flSelection[ 2 ];
|
||||
bool m_bSelectionActive;
|
||||
|
||||
bool m_bSuppressLayout;
|
||||
// Height/width of scroll bars
|
||||
int m_nScrollbarHeight;
|
||||
float m_flLeftOffset;
|
||||
mxScrollbar *m_pHorzScrollBar;
|
||||
int m_nLastHPixelsNeeded;
|
||||
// How many pixels per second we are showing in the UI
|
||||
float m_flPixelsPerSecond;
|
||||
// Do we need to move controls?
|
||||
bool m_bLayoutIsValid;
|
||||
float m_flLastDuration;
|
||||
bool m_bInSetEvent;
|
||||
float m_flScrubberTimeOffset;
|
||||
|
||||
friend class CChoreoView;
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern ExpressionTool *g_pExpressionTool;
|
||||
|
||||
#endif // EXPRESSIONTOOL_H
|
||||
1146
utils/hlfaceposer/faceposer_models.cpp
Normal file
1146
utils/hlfaceposer/faceposer_models.cpp
Normal file
File diff suppressed because it is too large
Load Diff
194
utils/hlfaceposer/faceposer_models.h
Normal file
194
utils/hlfaceposer/faceposer_models.h
Normal file
@@ -0,0 +1,194 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FACEPOSER_MODELS_H
|
||||
#define FACEPOSER_MODELS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class StudioModel;
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "mxbitmaptools.h"
|
||||
|
||||
typedef uint32 CRC32_t;
|
||||
|
||||
class IFaceposerModels
|
||||
{
|
||||
public:
|
||||
IFaceposerModels();
|
||||
virtual ~IFaceposerModels();
|
||||
|
||||
virtual int Count( void ) const;
|
||||
virtual char const *GetModelName( int index );
|
||||
virtual char const *GetModelFileName( int index );
|
||||
virtual int GetActiveModelIndex( void ) const;
|
||||
virtual char const *GetActiveModelName( void );
|
||||
virtual StudioModel *GetActiveStudioModel( void );
|
||||
virtual void ForceActiveModelIndex( int index );
|
||||
virtual void UnForceActiveModelIndex();
|
||||
virtual int FindModelByFilename( char const *filename );
|
||||
|
||||
virtual int LoadModel( char const *filename );
|
||||
virtual void FreeModel( int index );
|
||||
|
||||
virtual void CloseAllModels( void );
|
||||
|
||||
virtual StudioModel *GetStudioModel( int index );
|
||||
virtual CStudioHdr *GetStudioHeader( int index );
|
||||
virtual int GetIndexForStudioModel( StudioModel *model );
|
||||
|
||||
virtual int GetModelIndexForActor( char const *actorname );
|
||||
virtual StudioModel *GetModelForActor( char const *actorname );
|
||||
|
||||
virtual char const *GetActorNameForModel( int modelindex );
|
||||
virtual void SetActorNameForModel( int modelindex, char const *actorname );
|
||||
|
||||
virtual int CountVisibleModels( void );
|
||||
virtual void ShowModelIn3DView( int modelindex, bool show );
|
||||
virtual bool IsModelShownIn3DView( int modelindex );
|
||||
|
||||
virtual void SaveModelList( void );
|
||||
virtual void LoadModelList( void );
|
||||
|
||||
virtual void ReleaseModels( void );
|
||||
virtual void RestoreModels( void );
|
||||
|
||||
//virtual void RefreshModels( void );
|
||||
|
||||
virtual void CheckResetFlexes( void );
|
||||
virtual void ClearOverlaysSequences( void );
|
||||
|
||||
virtual mxbitmapdata_t *GetBitmapForSequence( int modelindex, int sequence );
|
||||
|
||||
virtual void RecreateAllAnimationBitmaps( int modelindex );
|
||||
virtual void RecreateAnimationBitmap( int modelindex, int sequence );
|
||||
|
||||
virtual void CreateNewBitmap( int modelindex, char const *pchBitmapFilename, int sequence, int nSnapShotSize, bool bZoomInOnFace, class CExpression *pExpression, mxbitmapdata_t *bitmap );
|
||||
|
||||
virtual int CountActiveSources();
|
||||
|
||||
virtual void SetSolveHeadTurn( int solve );
|
||||
|
||||
virtual void ClearModelTargets( bool force = false );
|
||||
|
||||
private:
|
||||
class CFacePoserModel
|
||||
{
|
||||
public:
|
||||
CFacePoserModel( char const *modelfile, StudioModel *model );
|
||||
~CFacePoserModel();
|
||||
|
||||
void LoadBitmaps();
|
||||
void FreeBitmaps();
|
||||
mxbitmapdata_t *GetBitmapForSequence( int sequence );
|
||||
|
||||
const char *GetBitmapChecksum( int sequence );
|
||||
CRC32_t GetBitmapCRC( int sequence );
|
||||
const char *GetBitmapFilename( int sequence );
|
||||
void RecreateAllAnimationBitmaps();
|
||||
void RecreateAnimationBitmap( int sequence, bool reconcile );
|
||||
|
||||
|
||||
void SetActorName( char const *actorname )
|
||||
{
|
||||
strcpy( m_szActorName, actorname );
|
||||
}
|
||||
|
||||
char const *GetActorName( void ) const
|
||||
{
|
||||
return m_szActorName;
|
||||
}
|
||||
|
||||
StudioModel *GetModel( void ) const
|
||||
{
|
||||
return m_pModel;
|
||||
}
|
||||
|
||||
char const *GetModelFileName( void ) const
|
||||
{
|
||||
return m_szModelFileName;
|
||||
}
|
||||
|
||||
char const *GetShortModelName( void ) const
|
||||
{
|
||||
return m_szShortName;
|
||||
}
|
||||
|
||||
void SetVisibleIn3DView( bool visible )
|
||||
{
|
||||
m_bVisibileIn3DView = visible;
|
||||
}
|
||||
|
||||
bool GetVisibleIn3DView( void ) const
|
||||
{
|
||||
return m_bVisibileIn3DView;
|
||||
}
|
||||
|
||||
// For material system purposes
|
||||
void Release( void );
|
||||
void Restore( void );
|
||||
|
||||
void Refresh( void )
|
||||
{
|
||||
// Forces a reload from disk
|
||||
Release();
|
||||
Restore();
|
||||
}
|
||||
|
||||
void CreateNewBitmap( char const *pchBitmapFilename, int sequence, int nSnapShotSize, bool bZoomInOnFace, class CExpression *pExpression, mxbitmapdata_t *bitmap );
|
||||
|
||||
private:
|
||||
|
||||
void LoadBitmapForSequence( mxbitmapdata_t *bitmap, int sequence );
|
||||
|
||||
void ReconcileAnimationBitmaps();
|
||||
void BuildValidChecksums( CUtlRBTree< CRC32_t > &tree );
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_ACTOR_NAME = 64,
|
||||
MAX_MODEL_FILE = 128,
|
||||
MAX_SHORT_NAME = 32,
|
||||
};
|
||||
|
||||
char m_szActorName[ MAX_ACTOR_NAME ];
|
||||
char m_szModelFileName[ MAX_MODEL_FILE ];
|
||||
char m_szShortName[ MAX_SHORT_NAME ];
|
||||
StudioModel *m_pModel;
|
||||
bool m_bVisibileIn3DView;
|
||||
|
||||
struct AnimBitmap
|
||||
{
|
||||
AnimBitmap()
|
||||
{
|
||||
needsload = false;
|
||||
bitmap = 0;
|
||||
}
|
||||
bool needsload;
|
||||
mxbitmapdata_t *bitmap;
|
||||
};
|
||||
|
||||
CUtlVector< AnimBitmap * > m_AnimationBitmaps;
|
||||
bool m_bFirstBitmapLoad;
|
||||
};
|
||||
|
||||
CFacePoserModel *GetEntry( int index );
|
||||
|
||||
CUtlVector< CFacePoserModel * > m_Models;
|
||||
|
||||
int m_nLastRenderFrame;
|
||||
int m_nForceModelIndex;
|
||||
};
|
||||
|
||||
extern IFaceposerModels *models;
|
||||
|
||||
void EnableStickySnapshotMode( void );
|
||||
void DisableStickySnapshotMode( void );
|
||||
|
||||
#endif // FACEPOSER_MODELS_H
|
||||
746
utils/hlfaceposer/faceposertoolwindow.cpp
Normal file
746
utils/hlfaceposer/faceposertoolwindow.cpp
Normal file
@@ -0,0 +1,746 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include "hlfaceposer.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
#include "UtlVector.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "MDLViewer.h"
|
||||
#include "choreowidgetdrawhelper.h"
|
||||
#include "StudioModel.h"
|
||||
#include "faceposer_models.h"
|
||||
|
||||
extern MDLViewer *g_MDLViewer;
|
||||
|
||||
static CUtlVector< IFacePoserToolWindow * > g_Tools;
|
||||
IFacePoserToolWindow *IFacePoserToolWindow::s_pActiveTool = NULL;
|
||||
|
||||
bool IFacePoserToolWindow::s_bToolsCanDraw;
|
||||
static CUtlVector< IFacePoserToolWindow * > s_NeedRedraw;
|
||||
|
||||
|
||||
IFacePoserToolWindow::IFacePoserToolWindow( char const *toolname, char const *displaynameroot )
|
||||
{
|
||||
m_bAutoProcess = false;
|
||||
m_bUseForMainWindowTitle = false;
|
||||
SetToolName( toolname );
|
||||
m_szPrefix[0]=0;
|
||||
m_szSuffix[0]=0;
|
||||
|
||||
SetDisplayNameRoot( displaynameroot );
|
||||
|
||||
g_Tools.AddToTail( this );
|
||||
|
||||
m_nToolFrameCount = 0;
|
||||
}
|
||||
|
||||
mxWindow *IFacePoserToolWindow::GetMxWindow( void )
|
||||
{
|
||||
return dynamic_cast< mxWindow * >( this );
|
||||
}
|
||||
|
||||
IFacePoserToolWindow *IFacePoserToolWindow::GetActiveTool( void )
|
||||
{
|
||||
if ( s_pActiveTool )
|
||||
return s_pActiveTool;
|
||||
|
||||
if ( GetToolCount() > 0 )
|
||||
return GetTool( 0 );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::SetActiveTool( IFacePoserToolWindow *tool )
|
||||
{
|
||||
if ( tool != s_pActiveTool && s_pActiveTool )
|
||||
{
|
||||
InvalidateRect( (HWND)s_pActiveTool->GetMxWindow()->getHandle(), NULL, TRUE );
|
||||
InvalidateRect( (HWND)tool->GetMxWindow()->getHandle(), NULL, TRUE );
|
||||
}
|
||||
s_pActiveTool = tool;
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::Think( float dt )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::SetToolName( char const *name )
|
||||
{
|
||||
Q_strncpy( m_szToolName, name, sizeof( m_szToolName ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *IFacePoserToolWindow::GetToolName( void ) const
|
||||
{
|
||||
return m_szToolName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *name -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::SetDisplayNameRoot( char const *name )
|
||||
{
|
||||
Q_snprintf( m_szDisplayRoot, sizeof( m_szDisplayRoot ), "%s", name );
|
||||
ComputeNewTitle();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *IFacePoserToolWindow::GetDisplayNameRoot( void ) const
|
||||
{
|
||||
return m_szDisplayRoot;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *suffix -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::SetSuffix( char const *suffix )
|
||||
{
|
||||
Q_snprintf( m_szSuffix, sizeof( m_szSuffix ), "%s", suffix );
|
||||
ComputeNewTitle();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *prefix -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::SetPrefix( char const *prefix )
|
||||
{
|
||||
Q_snprintf( m_szPrefix, sizeof( m_szPrefix ), "%s", prefix );
|
||||
ComputeNewTitle();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *IFacePoserToolWindow::GetWindowTitle( void ) const
|
||||
{
|
||||
return m_szWindowTitle;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : use -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::SetUseForMainWindowTitle( bool use )
|
||||
{
|
||||
m_bUseForMainWindowTitle = use;
|
||||
if ( use )
|
||||
{
|
||||
g_MDLViewer->setLabel( m_szWindowTitle );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::ComputeNewTitle( void )
|
||||
{
|
||||
Q_snprintf( m_szWindowTitle, sizeof( m_szWindowTitle ), "%s%s%s", m_szPrefix, m_szDisplayRoot, m_szSuffix );
|
||||
if ( GetMxWindow() )
|
||||
{
|
||||
GetMxWindow()->setLabel( m_szWindowTitle );
|
||||
}
|
||||
if ( !m_bUseForMainWindowTitle )
|
||||
return;
|
||||
|
||||
g_MDLViewer->setLabel( m_szWindowTitle );
|
||||
}
|
||||
|
||||
IFacePoserToolWindow::~IFacePoserToolWindow( void )
|
||||
{
|
||||
g_Tools.FindAndRemove( this );
|
||||
}
|
||||
|
||||
struct ToolTranslate
|
||||
{
|
||||
char const *toolname;
|
||||
float xfrac;
|
||||
float yfrac;
|
||||
float wfrac;
|
||||
float hfrac;
|
||||
bool locked;
|
||||
};
|
||||
|
||||
static ToolTranslate s_ToolTranslate[]=
|
||||
{
|
||||
{ "3D View", 0.0, 0.0, 0.4, 0.5, false },
|
||||
{ "ControlPanel", 0.4, 0.0, 0.2, 0.25, false },
|
||||
{ "FlexPanel", 0.6, 0.0, 0.4, 0.25, false },
|
||||
{ "RampTool", 0.4, 0.25, 0.6, 0.25, false },
|
||||
{ "CChoreoView", 0.0, 0.5, 1.0, 0.45, false },
|
||||
// { "Status Window", 0.0, 0.85, 1.0, 0.15, false },
|
||||
};
|
||||
|
||||
static bool TranslateToolPos( char const *toolname, int workspacew, int workspaceh, int& x, int& y, int &w, int &h, bool& locked )
|
||||
{
|
||||
int c = ARRAYSIZE( s_ToolTranslate );
|
||||
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
ToolTranslate& tt = s_ToolTranslate[ i ];
|
||||
|
||||
if ( !Q_stricmp( toolname, tt.toolname ) )
|
||||
{
|
||||
x = (int)((float)workspacew * tt.xfrac + 0.5f );
|
||||
y = (int)((float)workspaceh * tt.yfrac + 0.5f );
|
||||
w = (int)((float)workspacew * tt.wfrac + 0.5f );
|
||||
h = (int)((float)workspaceh * tt.hfrac + 0.5f );
|
||||
locked = tt.locked;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int s_nToolCount = 0;
|
||||
|
||||
void IFacePoserToolWindow::LoadPosition( void )
|
||||
{
|
||||
bool visible;
|
||||
bool locked;
|
||||
bool zoomed;
|
||||
int x, y, w, h;
|
||||
|
||||
FacePoser_LoadWindowPositions( GetToolName(), visible, x, y, w, h, locked, zoomed );
|
||||
|
||||
if ( w == 0 || h == 0 )
|
||||
{
|
||||
int idx = g_Tools.Find( this );
|
||||
Assert( idx != g_Tools.InvalidIndex() );
|
||||
if ( idx == 0 )
|
||||
{
|
||||
s_nToolCount = 0;
|
||||
}
|
||||
|
||||
zoomed = false;
|
||||
locked = false;
|
||||
visible = true;
|
||||
|
||||
// Just do a simple tiling
|
||||
w = g_MDLViewer->w2() * 0.5;
|
||||
h = g_MDLViewer->h2() * 0.5;
|
||||
|
||||
x = g_MDLViewer->w2() * 0.25f + s_nToolCount * 20;
|
||||
y = s_nToolCount * 20;
|
||||
|
||||
bool translated = TranslateToolPos
|
||||
(
|
||||
GetToolName(),
|
||||
g_MDLViewer->w2(),
|
||||
g_MDLViewer->h2(),
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
locked
|
||||
);
|
||||
if ( !translated )
|
||||
{
|
||||
++s_nToolCount;
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
GetMxWindow()->setBounds( x, y, w, h );
|
||||
if ( locked ^ IsLocked() )
|
||||
{
|
||||
ToggleLockedState();
|
||||
}
|
||||
GetMxWindow()->setVisible( visible );
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::SavePosition( void )
|
||||
{
|
||||
bool visible;
|
||||
int xpos, ypos, width, height;
|
||||
|
||||
visible = GetMxWindow()->isVisible();
|
||||
xpos = GetMxWindow()->x();
|
||||
ypos = GetMxWindow()->y();
|
||||
width = GetMxWindow()->w();
|
||||
height = GetMxWindow()->h();
|
||||
|
||||
// xpos and ypos are screen space
|
||||
POINT pt;
|
||||
pt.x = xpos;
|
||||
pt.y = ypos;
|
||||
|
||||
// Convert from screen space to relative to client area of parent window so
|
||||
// the setBounds == MoveWindow call will offset to the same location
|
||||
if ( GetMxWindow()->getParent() )
|
||||
{
|
||||
ScreenToClient( (HWND)GetMxWindow()->getParent()->getHandle(), &pt );
|
||||
xpos = (short)pt.x;
|
||||
ypos = (short)pt.y;
|
||||
}
|
||||
|
||||
FacePoser_SaveWindowPositions( GetToolName(), visible, xpos, ypos, width, height, IsLocked(), false );
|
||||
}
|
||||
|
||||
int IFacePoserToolWindow::GetToolCount( void )
|
||||
{
|
||||
return g_Tools.Count();
|
||||
}
|
||||
|
||||
IFacePoserToolWindow *IFacePoserToolWindow::GetTool( int index )
|
||||
{
|
||||
return g_Tools[ index ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::InitTools( void )
|
||||
{
|
||||
int c = GetToolCount();
|
||||
int i;
|
||||
for ( i = 0; i < c ; i++ )
|
||||
{
|
||||
IFacePoserToolWindow *tool = GetTool( i );
|
||||
|
||||
FacePoser_MakeToolWindow( tool->GetMxWindow(), true );
|
||||
tool->GetMxWindow()->setLabel( tool->GetWindowTitle() );
|
||||
}
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::ShutdownTools( void )
|
||||
{
|
||||
int c = GetToolCount();
|
||||
int i;
|
||||
for ( i = 0; i < c ; i++ )
|
||||
{
|
||||
IFacePoserToolWindow *tool = GetTool( i );
|
||||
tool->Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : dt -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::ToolThink( float dt )
|
||||
{
|
||||
int c = GetToolCount();
|
||||
int i;
|
||||
for ( i = 0; i < c ; i++ )
|
||||
{
|
||||
IFacePoserToolWindow *tool = GetTool( i );
|
||||
tool->Think( dt );
|
||||
}
|
||||
|
||||
// Don't self animate, all animation driven by thinking of various tools now
|
||||
|
||||
if ( !ShouldAutoProcess() )
|
||||
{
|
||||
c = models->Count();
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
StudioModel *m = models->GetStudioModel( i );
|
||||
if ( m )
|
||||
{
|
||||
m->AdvanceFrame ( dt );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IFacePoserToolWindow::IsLocked( void )
|
||||
{
|
||||
mxWindow *w = GetMxWindow();
|
||||
if ( !w )
|
||||
return false;
|
||||
|
||||
return !FacePoser_HasWindowStyle( w, WS_SYSMENU );
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::ToggleLockedState( void )
|
||||
{
|
||||
mxWindow *w = GetMxWindow();
|
||||
if ( !w )
|
||||
return;
|
||||
|
||||
bool visible = w->isVisible();
|
||||
|
||||
bool islocked = IsLocked();
|
||||
if ( islocked )
|
||||
{
|
||||
FacePoser_MakeToolWindow( w, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
FacePoser_RemoveWindowStyle( w, WS_OVERLAPPEDWINDOW );
|
||||
FacePoser_AddWindowExStyle( w, WS_EX_OVERLAPPEDWINDOW );
|
||||
}
|
||||
|
||||
w->setVisible( false );
|
||||
|
||||
// If visible, force it to redraw, etc.
|
||||
if ( visible )
|
||||
{
|
||||
w->setVisible( true );
|
||||
}
|
||||
}
|
||||
|
||||
#define LOCK_INSET 2
|
||||
#define LOCK_SIZE 8
|
||||
|
||||
void IFacePoserToolWindow:: GetLockRect( RECT& rc )
|
||||
{
|
||||
mxWindow *w = GetMxWindow();
|
||||
Assert( w );
|
||||
if ( !w )
|
||||
return;
|
||||
|
||||
GetCloseRect( rc );
|
||||
|
||||
OffsetRect( &rc, - ( LOCK_SIZE + 2 * LOCK_INSET ), 0 );
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::GetCloseRect( RECT& rc )
|
||||
{
|
||||
mxWindow *w = GetMxWindow();
|
||||
Assert( w );
|
||||
if ( !w )
|
||||
return;
|
||||
|
||||
rc.right = w->w2() - LOCK_INSET;
|
||||
rc.left = rc.right - LOCK_SIZE;
|
||||
rc.top = LOCK_INSET;
|
||||
rc.bottom = rc.top + LOCK_SIZE;
|
||||
}
|
||||
|
||||
bool IFacePoserToolWindow::HandleToolEvent( mxEvent *event )
|
||||
{
|
||||
bool handled = false;
|
||||
switch ( event->event )
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case mxEvent::Close:
|
||||
{
|
||||
g_MDLViewer->UpdateWindowMenu();
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
case mxEvent::ParentNotify:
|
||||
{
|
||||
mxWindow *w = GetMxWindow();
|
||||
if ( w )
|
||||
{
|
||||
HWND wnd = (HWND)w->getHandle();
|
||||
SetFocus( wnd );
|
||||
SetWindowPos( wnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
SetActiveTool( this );
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
case mxEvent::PosChanged:
|
||||
{
|
||||
SetActiveTool( this );
|
||||
mxWindow *w = GetMxWindow();
|
||||
if ( w )
|
||||
{
|
||||
SetFocus( (HWND)w->getHandle() );
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
case mxEvent::MouseDown:
|
||||
case mxEvent::MouseUp:
|
||||
{
|
||||
bool isup = event->event == mxEvent::MouseUp;
|
||||
|
||||
mxWindow *w = GetMxWindow();
|
||||
|
||||
if ( !isup && w )
|
||||
{
|
||||
SetFocus( (HWND)w->getHandle() );
|
||||
SetWindowPos( (HWND)w->getHandle(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
|
||||
SetActiveTool( this );
|
||||
}
|
||||
|
||||
if ( w && IsLocked() )
|
||||
{
|
||||
RECT captionRect;
|
||||
captionRect.left = 0;
|
||||
captionRect.right = w->w2();
|
||||
captionRect.top = 0;
|
||||
captionRect.bottom = GetCaptionHeight();
|
||||
|
||||
POINT pt;
|
||||
pt.x = (short)event->x;
|
||||
pt.y = (short)event->y;
|
||||
|
||||
if ( PtInRect( &captionRect, pt ) )
|
||||
{
|
||||
handled = !isup;
|
||||
|
||||
// Right button anywhere
|
||||
if ( event->buttons & mxEvent::MouseRightButton )
|
||||
{
|
||||
if ( isup )
|
||||
{
|
||||
ToggleLockedState();
|
||||
}
|
||||
}
|
||||
|
||||
// Left button on lock icon
|
||||
RECT lockRect, closeRect;
|
||||
GetLockRect( lockRect );
|
||||
GetCloseRect( closeRect );
|
||||
|
||||
if ( PtInRect( &lockRect, pt ) )
|
||||
{
|
||||
if ( isup )
|
||||
{
|
||||
ToggleLockedState();
|
||||
}
|
||||
}
|
||||
|
||||
if ( PtInRect( &closeRect, pt ) )
|
||||
{
|
||||
if ( isup )
|
||||
{
|
||||
w->setVisible( !w->isVisible() );
|
||||
g_MDLViewer->UpdateWindowMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mxEvent::NCMouseUp:
|
||||
{
|
||||
if ( event->buttons & mxEvent::MouseRightButton )
|
||||
{
|
||||
ToggleLockedState();
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case mxEvent::NCMouseDown:
|
||||
case mxEvent::Focus:
|
||||
{
|
||||
SetActiveTool( this );
|
||||
// don't mark handled = true, do this passively
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::HandleToolRedraw( CChoreoWidgetDrawHelper& helper )
|
||||
{
|
||||
if ( !IsLocked() )
|
||||
return;
|
||||
|
||||
mxWindow *w = GetMxWindow();
|
||||
if ( !w )
|
||||
return;
|
||||
|
||||
++m_nToolFrameCount;
|
||||
|
||||
RECT lockRect, closeRect;
|
||||
GetLockRect( lockRect );
|
||||
GetCloseRect( closeRect );
|
||||
|
||||
RECT captionRect;
|
||||
helper.GetClientRect( captionRect );
|
||||
RECT rcClient = captionRect;
|
||||
captionRect.bottom = captionRect.top + LOCK_SIZE + 2 * LOCK_INSET;
|
||||
|
||||
Color textColor = RGBToColor( GetSysColor( COLOR_MENUTEXT ) ); //GetSysColor( COLOR_INACTIVECAPTIONTEXT );
|
||||
|
||||
if ( IsActiveTool() )
|
||||
{
|
||||
helper.DrawFilledRect( RGBToColor( GetSysColor( COLOR_ACTIVECAPTION ) ), captionRect );
|
||||
}
|
||||
else
|
||||
{
|
||||
helper.DrawFilledRect( RGBToColor( GetSysColor( COLOR_INACTIVECAPTION ) ), captionRect );
|
||||
}
|
||||
|
||||
captionRect.top += 1;
|
||||
|
||||
InflateRect( &captionRect, -LOCK_INSET, 0 );
|
||||
|
||||
helper.DrawColoredText( "Small Fonts", 9, FW_NORMAL, textColor, captionRect,
|
||||
GetWindowTitle() );
|
||||
|
||||
//RECT rcFrame = captionRect;
|
||||
//rcFrame.left = rcFrame.right - 50;
|
||||
//rcFrame.right = rcFrame.left + 30;
|
||||
// helper.DrawColoredText( "Small Fonts", 9, FW_NORMAL, textColor, rcFrame, va( "%i", m_nToolFrameCount ) );
|
||||
|
||||
lockRect.bottom++;
|
||||
OffsetRect( &lockRect, 1, 1 );
|
||||
helper.DrawColoredTextCharset( "Marlett", 8, FW_NORMAL, SYMBOL_CHARSET, textColor, lockRect, "v" );
|
||||
|
||||
closeRect.bottom++;
|
||||
helper.DrawOutlinedRect( textColor, PS_SOLID, 1, closeRect );
|
||||
OffsetRect( &closeRect, 1, 1 );
|
||||
helper.DrawColoredTextCharset( "Marlett", 8, FW_NORMAL, SYMBOL_CHARSET, textColor, closeRect, "r" );
|
||||
|
||||
rcClient.top += captionRect.bottom;
|
||||
|
||||
helper.StartClipping( rcClient );
|
||||
}
|
||||
|
||||
int IFacePoserToolWindow::GetCaptionHeight( void )
|
||||
{
|
||||
if ( !IsLocked() )
|
||||
return 0;
|
||||
|
||||
return LOCK_SIZE + 2 * LOCK_INSET;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : autoprocess -
|
||||
//-----------------------------------------------------------------------------
|
||||
void IFacePoserToolWindow::SetAutoProcess( bool autoprocess )
|
||||
{
|
||||
m_bAutoProcess = autoprocess;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IFacePoserToolWindow::GetAutoProcess( void ) const
|
||||
{
|
||||
return m_bAutoProcess;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IFacePoserToolWindow::IsActiveTool( void )
|
||||
{
|
||||
if ( this == s_pActiveTool )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IFacePoserToolWindow::IsAnyToolScrubbing( void )
|
||||
{
|
||||
int c = GetToolCount();
|
||||
int i;
|
||||
for ( i = 0; i < c ; i++ )
|
||||
{
|
||||
IFacePoserToolWindow *tool = GetTool( i );
|
||||
if ( tool->IsScrubbing() )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IFacePoserToolWindow::IsAnyToolProcessing( void )
|
||||
{
|
||||
int c = GetToolCount();
|
||||
int i;
|
||||
for ( i = 0; i < c ; i++ )
|
||||
{
|
||||
IFacePoserToolWindow *tool = GetTool( i );
|
||||
if ( tool->IsProcessing() )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IFacePoserToolWindow::ShouldAutoProcess( void )
|
||||
{
|
||||
IFacePoserToolWindow *tool = GetActiveTool();
|
||||
if ( !tool )
|
||||
return false;
|
||||
|
||||
return tool->GetAutoProcess();
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::EnableToolRedraw( bool enabled )
|
||||
{
|
||||
MDLCACHE_CRITICAL_SECTION_( g_pMDLCache );
|
||||
|
||||
s_bToolsCanDraw = enabled;
|
||||
|
||||
if ( s_bToolsCanDraw )
|
||||
{
|
||||
int c = s_NeedRedraw.Count();
|
||||
int i;
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
IFacePoserToolWindow *tool = s_NeedRedraw[ i ];
|
||||
tool->GetMxWindow()->redraw();
|
||||
}
|
||||
|
||||
s_NeedRedraw.Purge();
|
||||
}
|
||||
}
|
||||
|
||||
bool IFacePoserToolWindow::ToolCanDraw()
|
||||
{
|
||||
if ( !s_bToolsCanDraw )
|
||||
{
|
||||
if ( s_NeedRedraw.Find( this ) == s_NeedRedraw.InvalidIndex() )
|
||||
{
|
||||
s_NeedRedraw.AddToTail( this );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::OnModelChanged()
|
||||
{
|
||||
}
|
||||
|
||||
void IFacePoserToolWindow::ModelChanged()
|
||||
{
|
||||
int c = GetToolCount();
|
||||
int i;
|
||||
for ( i = 0; i < c ; i++ )
|
||||
{
|
||||
IFacePoserToolWindow *tool = GetTool( i );
|
||||
tool->OnModelChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
108
utils/hlfaceposer/faceposertoolwindow.h
Normal file
108
utils/hlfaceposer/faceposertoolwindow.h
Normal file
@@ -0,0 +1,108 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FACEPOSERTOOLWINDOW_H
|
||||
#define FACEPOSERTOOLWINDOW_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mxtk/mx.h>
|
||||
#include "mxtk/mxWindow.h"
|
||||
|
||||
class CChoreoWidgetDrawHelper;
|
||||
|
||||
class IFacePoserToolWindow
|
||||
{
|
||||
public:
|
||||
IFacePoserToolWindow( char const *toolname, char const *displaynameroot );
|
||||
virtual ~IFacePoserToolWindow( void );
|
||||
|
||||
virtual mxWindow *GetMxWindow( void );
|
||||
virtual void Shutdown() { }
|
||||
|
||||
virtual void Think( float dt );
|
||||
virtual bool IsScrubbing( void ) const { return false; }
|
||||
virtual bool IsProcessing( void ) { return false; }
|
||||
|
||||
bool IsActiveTool( void );
|
||||
|
||||
virtual bool IsLocked( void );
|
||||
virtual bool HandleToolEvent( mxEvent *event );
|
||||
virtual void HandleToolRedraw( CChoreoWidgetDrawHelper& helper );
|
||||
virtual int GetCaptionHeight( void );
|
||||
void ToggleLockedState( void );
|
||||
|
||||
void LoadPosition( void );
|
||||
void SavePosition( void );
|
||||
|
||||
char const *GetToolName( void ) const;
|
||||
char const *GetWindowTitle( void ) const;
|
||||
char const *GetDisplayNameRoot( void ) const;
|
||||
|
||||
void SetDisplayNameRoot( char const *name );
|
||||
void SetSuffix( char const *suffix );
|
||||
void SetPrefix( char const *prefix );
|
||||
|
||||
void SetUseForMainWindowTitle( bool use );
|
||||
|
||||
void SetAutoProcess( bool autoprocess );
|
||||
bool GetAutoProcess( void ) const;
|
||||
|
||||
virtual void OnModelChanged();
|
||||
|
||||
static int GetToolCount( void );
|
||||
static IFacePoserToolWindow *GetTool( int index );
|
||||
|
||||
static IFacePoserToolWindow *GetActiveTool( void );
|
||||
static void SetActiveTool( IFacePoserToolWindow *tool );
|
||||
static IFacePoserToolWindow *s_pActiveTool;
|
||||
static void ToolThink( float dt );
|
||||
static void ModelChanged();
|
||||
static bool IsAnyToolScrubbing( void );
|
||||
static bool IsAnyToolProcessing( void );
|
||||
|
||||
static bool ShouldAutoProcess( void );
|
||||
|
||||
static void InitTools( void );
|
||||
static void ShutdownTools( void );
|
||||
|
||||
static void EnableToolRedraw( bool enabled );
|
||||
static bool s_bToolsCanDraw;
|
||||
|
||||
bool ToolCanDraw( void );
|
||||
|
||||
private:
|
||||
void GetLockRect( RECT& rc );
|
||||
void GetCloseRect( RECT& rc );
|
||||
|
||||
void ComputeNewTitle( void );
|
||||
|
||||
void SetToolName( char const *name );
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_TOOL_NAME = 128,
|
||||
PREFIX_LENGTH = 32,
|
||||
SUFFIX_LENGTH = 128,
|
||||
};
|
||||
|
||||
char m_szToolName[ MAX_TOOL_NAME ];
|
||||
char m_szDisplayRoot[ MAX_TOOL_NAME ];
|
||||
char m_szPrefix[ PREFIX_LENGTH ];
|
||||
char m_szSuffix[ SUFFIX_LENGTH ];
|
||||
|
||||
char m_szWindowTitle[ MAX_TOOL_NAME + PREFIX_LENGTH + PREFIX_LENGTH ];
|
||||
|
||||
bool m_bUseForMainWindowTitle;
|
||||
|
||||
bool m_bAutoProcess;
|
||||
|
||||
int m_nToolFrameCount;
|
||||
};
|
||||
|
||||
#endif // FACEPOSERTOOLWINDOW_H
|
||||
258
utils/hlfaceposer/faceposerworkspace.cpp
Normal file
258
utils/hlfaceposer/faceposerworkspace.cpp
Normal file
@@ -0,0 +1,258 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "tier1/strtools.h"
|
||||
#include "ifaceposerworkspace.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CWorkspaceFiles : public IWorkspaceFiles
|
||||
{
|
||||
public:
|
||||
CWorkspaceFiles( void );
|
||||
~CWorkspaceFiles( void );
|
||||
|
||||
virtual void Init( char const *pchShortName );
|
||||
|
||||
// Restore
|
||||
int GetNumStoredFiles( int type );
|
||||
const char *GetStoredFile( int type, int number );
|
||||
|
||||
// Save
|
||||
void StartStoringFiles( int type );
|
||||
void FinishStoringFiles( int type );
|
||||
void StoreFile( int type, const char *filename );
|
||||
|
||||
private:
|
||||
static const char *NameForType( int type );
|
||||
static int TypeForName( const char *name );
|
||||
|
||||
LONG CreateWorkspaceKey( char const *pchGameName, PHKEY phKey );
|
||||
bool ReadInt( const char *szSubKey, int *value );
|
||||
bool WriteInt( const char *szSubKey, int value );
|
||||
bool ReadString( const char *szSubKey, char *value, int bufferlen );
|
||||
bool WriteString( const char *szSubKey, const char *value );
|
||||
|
||||
HKEY m_hKeyMain;
|
||||
|
||||
int m_nStoredFiles[ NUM_FILE_TYPES ];
|
||||
};
|
||||
|
||||
static CWorkspaceFiles g_WorkspaceFiles;
|
||||
IWorkspaceFiles *workspacefiles = ( IWorkspaceFiles * )&g_WorkspaceFiles;
|
||||
|
||||
CWorkspaceFiles::CWorkspaceFiles( void ) :
|
||||
m_hKeyMain( (HKEY)0 )
|
||||
{
|
||||
memset( m_nStoredFiles, 0, sizeof( m_nStoredFiles ) );
|
||||
}
|
||||
|
||||
CWorkspaceFiles::~CWorkspaceFiles( void )
|
||||
{
|
||||
if ( (HKEY)0 != m_hKeyMain )
|
||||
{
|
||||
RegCloseKey( m_hKeyMain );
|
||||
}
|
||||
}
|
||||
|
||||
void CWorkspaceFiles::Init( char const *pchShortName )
|
||||
{
|
||||
CreateWorkspaceKey( pchShortName, &m_hKeyMain );
|
||||
}
|
||||
|
||||
const char *CWorkspaceFiles::NameForType( int type )
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case EXPRESSION:
|
||||
return "expressionfiles";
|
||||
case CHOREODATA:
|
||||
return "choreodatafiles";
|
||||
case MODELDATA:
|
||||
return "modelfiles";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
int CWorkspaceFiles::TypeForName( const char *name )
|
||||
{
|
||||
if ( !Q_stricmp( name, "expressionfiles" ) )
|
||||
{
|
||||
return EXPRESSION;
|
||||
}
|
||||
else if ( !Q_stricmp( name, "choreodatafiles" ) )
|
||||
{
|
||||
return CHOREODATA;
|
||||
}
|
||||
else if ( !Q_stricmp( name, "modelfiles" ) )
|
||||
{
|
||||
return MODELDATA;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int CWorkspaceFiles::GetNumStoredFiles( int type )
|
||||
{
|
||||
char szKeyName[ 256 ];
|
||||
Q_snprintf( szKeyName, sizeof( szKeyName ), "%s\\total", NameForType( type ) );
|
||||
|
||||
int num = 0;
|
||||
ReadInt( szKeyName, &num );
|
||||
return num;
|
||||
}
|
||||
|
||||
const char *CWorkspaceFiles::GetStoredFile( int type, int number )
|
||||
{
|
||||
char szKeyName[ 256 ];
|
||||
sprintf( szKeyName, "%s\\%04i", NameForType( type ), number );
|
||||
|
||||
static char filename[ 256 ];
|
||||
filename[ 0 ] = 0;
|
||||
ReadString( szKeyName, filename, 256 );
|
||||
return filename;
|
||||
}
|
||||
|
||||
void CWorkspaceFiles::StartStoringFiles( int type )
|
||||
{
|
||||
m_nStoredFiles[ type ] = 0;
|
||||
}
|
||||
|
||||
void CWorkspaceFiles::FinishStoringFiles( int type )
|
||||
{
|
||||
char szKeyName[ 256 ];
|
||||
sprintf( szKeyName, "%s\\total", NameForType( type ) );
|
||||
|
||||
WriteInt( szKeyName, m_nStoredFiles[ type ] );
|
||||
}
|
||||
|
||||
void CWorkspaceFiles::StoreFile( int type, const char *filename )
|
||||
{
|
||||
char szKeyName[ 256 ];
|
||||
sprintf( szKeyName, "%s\\%04i", NameForType( type ), m_nStoredFiles[ type ]++ );
|
||||
|
||||
WriteString( szKeyName, filename );
|
||||
}
|
||||
|
||||
LONG CWorkspaceFiles::CreateWorkspaceKey( char const *pchGameName, PHKEY phKey )
|
||||
{
|
||||
DWORD disp;
|
||||
|
||||
char sz[ 512 ];
|
||||
Q_snprintf( sz, sizeof( sz ), "Software\\Valve\\faceposer\\workspace\\%s", pchGameName );
|
||||
|
||||
return RegCreateKeyEx(
|
||||
HKEY_CURRENT_USER, // handle of open key
|
||||
sz, // address of name of subkey to open
|
||||
0, // DWORD ulOptions, // reserved
|
||||
NULL, // Type of value
|
||||
REG_OPTION_NON_VOLATILE, // Store permanently in reg.
|
||||
KEY_ALL_ACCESS, // REGSAM samDesired, // security access mask
|
||||
NULL,
|
||||
phKey, // Key we are creating
|
||||
&disp ); // Type of creation
|
||||
}
|
||||
|
||||
bool CWorkspaceFiles::ReadInt( const char *szSubKey, int *value )
|
||||
{
|
||||
LONG lResult; // Registry function result code
|
||||
DWORD dwType; // Type of key
|
||||
DWORD dwSize; // Size of element data
|
||||
|
||||
dwSize = sizeof( DWORD );
|
||||
|
||||
lResult = RegQueryValueEx(
|
||||
m_hKeyMain, // handle to key
|
||||
szSubKey, // value name
|
||||
0, // reserved
|
||||
&dwType, // type buffer
|
||||
(LPBYTE)value, // data buffer
|
||||
&dwSize ); // size of data buffer
|
||||
|
||||
if (lResult != ERROR_SUCCESS) // Failure
|
||||
return false;
|
||||
|
||||
if (dwType != REG_DWORD)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CWorkspaceFiles::WriteInt( const char *szSubKey, int value )
|
||||
{
|
||||
LONG lResult; // Registry function result code
|
||||
DWORD dwSize; // Size of element data
|
||||
|
||||
dwSize = sizeof( DWORD );
|
||||
|
||||
lResult = RegSetValueEx(
|
||||
m_hKeyMain, // handle to key
|
||||
szSubKey, // value name
|
||||
0, // reserved
|
||||
REG_DWORD, // type buffer
|
||||
(LPBYTE)&value, // data buffer
|
||||
dwSize ); // size of data buffer
|
||||
|
||||
if (lResult != ERROR_SUCCESS) // Failure
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWorkspaceFiles::ReadString( const char *szSubKey, char *value, int buffersize )
|
||||
{
|
||||
LONG lResult; // Registry function result code
|
||||
DWORD dwType; // Type of key
|
||||
DWORD dwSize; // Size of element data
|
||||
|
||||
dwSize = buffersize;
|
||||
|
||||
lResult = RegQueryValueEx(
|
||||
m_hKeyMain, // handle to key
|
||||
szSubKey, // value name
|
||||
0, // reserved
|
||||
&dwType, // type buffer
|
||||
(LPBYTE)value, // data buffer
|
||||
&dwSize ); // size of data buffer
|
||||
|
||||
if (lResult != ERROR_SUCCESS) // Failure
|
||||
return false;
|
||||
|
||||
if (dwType != REG_SZ)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CWorkspaceFiles::WriteString( const char *szSubKey, const char *value )
|
||||
{
|
||||
LONG lResult; // Registry function result code
|
||||
DWORD dwSize; // Size of element data
|
||||
|
||||
dwSize = strlen( value ) + 1;
|
||||
|
||||
lResult = RegSetValueEx(
|
||||
m_hKeyMain, // handle to key
|
||||
szSubKey, // value name
|
||||
0, // reserved
|
||||
REG_SZ, // type buffer
|
||||
(LPBYTE)value, // data buffer
|
||||
dwSize ); // size of data buffer
|
||||
|
||||
if (lResult != ERROR_SUCCESS) // Failure
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
378
utils/hlfaceposer/fileloaderthread.cpp
Normal file
378
utils/hlfaceposer/fileloaderthread.cpp
Normal file
@@ -0,0 +1,378 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#include "tier0/platform.h"
|
||||
#include "cbase.h"
|
||||
#include "sentence.h"
|
||||
#include "wavefile.h"
|
||||
#include "tier2/riff.h"
|
||||
#include "filesystem.h"
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include "IFileLoader.h"
|
||||
|
||||
bool SceneManager_LoadSentenceFromWavFileUsingIO( char const *wavfile, CSentence& sentence, IFileReadBinary& io );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Implements the RIFF i/o interface on stdio
|
||||
//-----------------------------------------------------------------------------
|
||||
class ThreadIOReadBinary : public IFileReadBinary
|
||||
{
|
||||
public:
|
||||
FileHandle_t open( const char *pFileName )
|
||||
{
|
||||
char filename[ 512 ];
|
||||
// POSSIBLE BUG: THIS MIGHT NOT BE THREAD SAFE!!!
|
||||
filesystem->RelativePathToFullPath( pFileName, "GAME", filename, sizeof( filename ) );
|
||||
return (FileHandle_t)_open( filename, _O_BINARY | _O_RDONLY );
|
||||
}
|
||||
|
||||
int read( void *pOutput, int size, FileHandle_t file )
|
||||
{
|
||||
if ( !file )
|
||||
return 0;
|
||||
|
||||
return _read( (int)(intp)file, pOutput, size );
|
||||
}
|
||||
|
||||
void seek( FileHandle_t file, int pos )
|
||||
{
|
||||
if ( !file )
|
||||
return;
|
||||
|
||||
_lseek( (int)(intp)file, pos, SEEK_SET );
|
||||
}
|
||||
|
||||
unsigned int tell( FileHandle_t file )
|
||||
{
|
||||
if ( !file )
|
||||
return 0;
|
||||
|
||||
return _tell( (int)(intp)file );
|
||||
}
|
||||
|
||||
unsigned int size( FileHandle_t file )
|
||||
{
|
||||
if ( !file )
|
||||
return 0;
|
||||
|
||||
long curpos = this->tell( file );
|
||||
_lseek( (int)(intp)file, 0, SEEK_END );
|
||||
int s = this->tell( file );
|
||||
_lseek( (int)(intp)file, curpos, SEEK_SET );
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void close( FileHandle_t file )
|
||||
{
|
||||
if ( !file )
|
||||
return;
|
||||
|
||||
_close( (int)(intp)file );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: All wavefile I/O occurs on a thread
|
||||
//-----------------------------------------------------------------------------
|
||||
class CFileLoaderThread : public IFileLoader
|
||||
{
|
||||
public:
|
||||
struct SentenceRequest
|
||||
{
|
||||
SentenceRequest()
|
||||
{
|
||||
filename[ 0 ] = 0;
|
||||
sentence.Reset();
|
||||
wavefile = NULL;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
char filename[ 256 ];
|
||||
CSentence sentence;
|
||||
|
||||
CWaveFile *wavefile;
|
||||
};
|
||||
|
||||
// Construction
|
||||
CFileLoaderThread( void );
|
||||
virtual ~CFileLoaderThread( void );
|
||||
|
||||
// Sockets add/remove themselves via their constructor
|
||||
virtual void AddWaveFilesToThread( CUtlVector< CWaveFile * >& wavefiles );
|
||||
|
||||
// Retrieve handle to shutdown event
|
||||
virtual HANDLE GetShutdownHandle( void );
|
||||
|
||||
// Caller should call lock before accessing any of these methods and unlock afterwards!!!
|
||||
virtual int ProcessCompleted();
|
||||
|
||||
int DoThreadWork();
|
||||
|
||||
virtual void Start();
|
||||
|
||||
virtual int GetPendingLoadCount();
|
||||
private:
|
||||
// Critical section used for synchronizing access to wavefile list
|
||||
CThreadFastMutex m_Mutex;
|
||||
|
||||
// List of wavefiles we are listening on
|
||||
CUtlVector< SentenceRequest * > m_FileList;
|
||||
|
||||
CUtlVector< SentenceRequest * > m_Pending;
|
||||
CUtlVector< SentenceRequest * > m_Completed;
|
||||
// Thread handle
|
||||
HANDLE m_hThread;
|
||||
// Thread id
|
||||
DWORD m_nThreadId;
|
||||
// Event to set when we want to tell the thread to shut itself down
|
||||
HANDLE m_hShutdown;
|
||||
|
||||
ThreadIOReadBinary m_ThreadIO;
|
||||
|
||||
int m_nTotalAdds;
|
||||
int m_nTotalCompleted;
|
||||
|
||||
CInterlockedInt m_nTotalPending;
|
||||
CInterlockedInt m_nTotalProcessed;
|
||||
|
||||
HANDLE m_hNewItems;
|
||||
};
|
||||
|
||||
// Singleton handler
|
||||
static CFileLoaderThread g_WaveLoader;
|
||||
extern IFileLoader *fileloader = &g_WaveLoader;
|
||||
|
||||
int CFileLoaderThread::DoThreadWork()
|
||||
{
|
||||
int i;
|
||||
// Check for shutdown event
|
||||
if ( WAIT_OBJECT_0 == WaitForSingleObject( GetShutdownHandle(), 0 ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// No changes to list right now
|
||||
{
|
||||
AUTO_LOCK_FM( m_Mutex );
|
||||
// Move new items to work list
|
||||
int newItems = m_FileList.Count();
|
||||
for ( i = 0; i < newItems; i++ )
|
||||
{
|
||||
// Move to pending and issue async i/o calls
|
||||
m_Pending.AddToHead( m_FileList[ i ] );
|
||||
|
||||
m_nTotalPending++;
|
||||
}
|
||||
m_FileList.RemoveAll();
|
||||
// Done adding new work items
|
||||
}
|
||||
|
||||
int remaining = m_Pending.Count();
|
||||
if ( !remaining )
|
||||
return 1;
|
||||
|
||||
int workitems = remaining; // min( remaining, 1000 );
|
||||
|
||||
CUtlVector< SentenceRequest * > transfer;
|
||||
|
||||
for ( i = 0; i < workitems; i++ )
|
||||
{
|
||||
SentenceRequest *r = m_Pending[ 0 ];
|
||||
m_Pending.Remove( 0 );
|
||||
|
||||
transfer.AddToTail( r );
|
||||
|
||||
// Do the work
|
||||
m_nTotalProcessed++;
|
||||
|
||||
bool load = false;
|
||||
{
|
||||
AUTO_LOCK_FM( m_Mutex );
|
||||
load = !r->wavefile->HasLoadedSentenceInfo();
|
||||
}
|
||||
|
||||
if ( load )
|
||||
{
|
||||
r->valid = SceneManager_LoadSentenceFromWavFileUsingIO( r->filename, r->sentence, m_ThreadIO );
|
||||
}
|
||||
else
|
||||
{
|
||||
r->valid = true;
|
||||
}
|
||||
|
||||
if ( WaitForSingleObject( m_hNewItems, 0 ) == WAIT_OBJECT_0 )
|
||||
{
|
||||
ResetEvent( m_hNewItems );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Now move to completed list
|
||||
{
|
||||
AUTO_LOCK_FM( m_Mutex );
|
||||
int c = transfer.Count();
|
||||
|
||||
for ( i = 0; i < c; ++i )
|
||||
{
|
||||
SentenceRequest *r = transfer[ i ];
|
||||
if ( r->valid )
|
||||
{
|
||||
|
||||
m_nTotalCompleted++;
|
||||
|
||||
|
||||
m_Completed.AddToTail( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CFileLoaderThread::ProcessCompleted()
|
||||
{
|
||||
AUTO_LOCK_FM( m_Mutex );
|
||||
int c = m_Completed.Count();
|
||||
for ( int i = c - 1; i >= 0 ; i-- )
|
||||
{
|
||||
SentenceRequest *r = m_Completed[ i ];
|
||||
|
||||
if ( !r->wavefile->HasLoadedSentenceInfo() )
|
||||
{
|
||||
r->wavefile->SetThreadLoadedSentence( r->sentence );
|
||||
}
|
||||
|
||||
delete r;
|
||||
}
|
||||
m_Completed.RemoveAll();
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Main winsock processing thread
|
||||
// Input : threadobject -
|
||||
// Output : static DWORD WINAPI
|
||||
//-----------------------------------------------------------------------------
|
||||
static DWORD WINAPI FileLoaderThreadFunc( LPVOID threadobject )
|
||||
{
|
||||
// Get pointer to CFileLoaderThread object
|
||||
CFileLoaderThread *wavefilethread = ( CFileLoaderThread * )threadobject;
|
||||
Assert( wavefilethread );
|
||||
if ( !wavefilethread )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Keep looking for data until shutdown event is triggered
|
||||
while ( 1 )
|
||||
{
|
||||
if( !wavefilethread->DoThreadWork() )
|
||||
break;
|
||||
|
||||
// Yield a small bit of time to main app
|
||||
Sleep( 10 );
|
||||
}
|
||||
|
||||
ExitThread( 0 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Construction
|
||||
//-----------------------------------------------------------------------------
|
||||
CFileLoaderThread::CFileLoaderThread( void )
|
||||
{
|
||||
m_nTotalAdds = 0;
|
||||
m_nTotalProcessed = 0;
|
||||
m_nTotalCompleted = 0;
|
||||
m_nTotalPending = 0;
|
||||
|
||||
m_hShutdown = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
Assert( m_hShutdown );
|
||||
|
||||
m_hThread = NULL;
|
||||
|
||||
m_hNewItems = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
|
||||
Start();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFileLoaderThread::Start()
|
||||
{
|
||||
m_hThread = CreateThread( NULL, 0, FileLoaderThreadFunc, (void *)this, 0, &m_nThreadId );
|
||||
Assert( m_hThread );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CFileLoaderThread::~CFileLoaderThread( void )
|
||||
{
|
||||
{
|
||||
AUTO_LOCK_FM( m_Mutex );
|
||||
SetEvent( m_hShutdown );
|
||||
Sleep( 2 );
|
||||
TerminateThread( m_hThread, 0 );
|
||||
}
|
||||
|
||||
// Kill the wavefile
|
||||
//!! need to validate this line
|
||||
// Assert( !m_FileList );
|
||||
|
||||
CloseHandle( m_hThread );
|
||||
|
||||
CloseHandle( m_hShutdown );
|
||||
|
||||
CloseHandle( m_hNewItems );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns handle of shutdown event
|
||||
// Output : HANDLE
|
||||
//-----------------------------------------------------------------------------
|
||||
HANDLE CFileLoaderThread::GetShutdownHandle( void )
|
||||
{
|
||||
return m_hShutdown;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Locks object and adds wavefile to thread
|
||||
// Input : *wavefile -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CFileLoaderThread::AddWaveFilesToThread( CUtlVector< CWaveFile * >& wavefiles )
|
||||
{
|
||||
AUTO_LOCK_FM( m_Mutex );
|
||||
int c = wavefiles.Count();
|
||||
for ( int i = 0; i < c; i++ )
|
||||
{
|
||||
SentenceRequest *request = new SentenceRequest;
|
||||
request->wavefile = wavefiles[ i ];
|
||||
Q_strncpy( request->filename, request->wavefile->GetFileName(), sizeof( request->filename ) );
|
||||
|
||||
m_FileList.AddToTail( request );
|
||||
|
||||
m_nTotalAdds++;
|
||||
}
|
||||
|
||||
SetEvent( m_hNewItems );
|
||||
}
|
||||
|
||||
int CFileLoaderThread::GetPendingLoadCount()
|
||||
{
|
||||
return m_nTotalPending - m_nTotalProcessed;
|
||||
}
|
||||
1092
utils/hlfaceposer/flexpanel.cpp
Normal file
1092
utils/hlfaceposer/flexpanel.cpp
Normal file
File diff suppressed because it is too large
Load Diff
144
utils/hlfaceposer/flexpanel.h
Normal file
144
utils/hlfaceposer/flexpanel.h
Normal file
@@ -0,0 +1,144 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FLEXPANEL_H
|
||||
#define FLEXPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDED_MXWINDOW
|
||||
#include <mxtk/mxWindow.h>
|
||||
#endif
|
||||
|
||||
#define IDC_FLEX 7001
|
||||
#define IDC_FLEXSCROLL 7101
|
||||
#define IDC_EXPRESSIONRESET 7102
|
||||
|
||||
// NOTE THIS THIS TAKES UP 4 * 96 entries (384)
|
||||
// #define NEXT_AVAIL 7457 ...etc.
|
||||
#define IDC_FLEXSCALE 7200
|
||||
|
||||
#define IDC_FLEXSCALE_LAST 7584
|
||||
|
||||
#define IDC_FP_UNCHECK_ALL 7800
|
||||
#define IDC_FP_CHECK_ALL 7801
|
||||
#define IDC_FP_INVERT 7802
|
||||
#define IDC_FP_MENU 7803
|
||||
|
||||
#include "studio.h"
|
||||
|
||||
class mxTab;
|
||||
class mxChoice;
|
||||
class mxCheckBox;
|
||||
class mxSlider;
|
||||
class mxScrollbar;
|
||||
class mxLineEdit;
|
||||
class mxLabel;
|
||||
class mxButton;
|
||||
class MatSysWindow;
|
||||
class TextureWindow;
|
||||
class mxExpressionSlider;
|
||||
|
||||
|
||||
#include "expressions.h"
|
||||
#include "faceposertoolwindow.h"
|
||||
|
||||
/*
|
||||
int nameindex;
|
||||
int numkeys;
|
||||
int keyindex;
|
||||
{ char key, char weight }
|
||||
*/
|
||||
|
||||
class ControlPanel;
|
||||
|
||||
class FlexPanel : public mxWindow, public IFacePoserToolWindow
|
||||
{
|
||||
typedef mxWindow BaseClass;
|
||||
|
||||
mxExpressionSlider *slFlexScale[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
|
||||
mxScrollbar *slScrollbar;
|
||||
|
||||
mxButton *btnResetSliders;
|
||||
mxButton *btnCopyToSliders;
|
||||
mxButton *btnCopyFromSliders;
|
||||
mxButton *btnMenu;
|
||||
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
FlexPanel (mxWindow *parent);
|
||||
virtual ~FlexPanel ();
|
||||
|
||||
virtual void redraw();
|
||||
virtual bool PaintBackground( void );
|
||||
|
||||
void SetEvent( CChoreoEvent *event );
|
||||
virtual void OnModelChanged();
|
||||
|
||||
// MANIPULATORS
|
||||
int handleEvent (mxEvent *event);
|
||||
|
||||
void initFlexes ();
|
||||
|
||||
bool IsValidSlider( int iFlexController ) const;
|
||||
|
||||
float GetSlider( int iFlexController );
|
||||
float GetSliderRawValue( int iFlexController );
|
||||
void GetSliderRange( int iFlexController, float& minvalue, float& maxvalue );
|
||||
|
||||
void SetSlider( int iFlexController, float value );
|
||||
float GetInfluence( int iFlexController );
|
||||
void SetInfluence( int iFlexController, float value );
|
||||
void SetEdited( int iFlexController, bool isEdited );
|
||||
bool IsEdited( int iFlexController );
|
||||
int LookupFlex( int iSlider, int barnum );
|
||||
int LookupPairedFlex( int iFlexController );
|
||||
|
||||
// maps global flex_controller index to UI slider
|
||||
int nFlexSliderIndex[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
int nFlexSliderBarnum[ GLOBAL_STUDIO_FLEX_CONTROL_COUNT ];
|
||||
|
||||
void PositionSliders( int sboffset );
|
||||
void PositionControls( int width, int height );
|
||||
|
||||
void EditExpression( void );
|
||||
void NewExpression( void );
|
||||
|
||||
void setExpression( int index );
|
||||
void DeleteExpression( int index );
|
||||
void SaveExpression( int index );
|
||||
void RevertExpression( int index );
|
||||
|
||||
void CopyControllerSettings( void );
|
||||
void PasteControllerSettings( void );
|
||||
|
||||
void ResetSliders( bool preserveundo, bool bDirtyClass );
|
||||
|
||||
void CopyControllerSettingsToStructure( CExpression *exp );
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
FP_STATE_UNCHECK = 0,
|
||||
FP_STATE_CHECK,
|
||||
FP_STATE_INVERT
|
||||
};
|
||||
|
||||
void OnSetAll( int state );
|
||||
void OnMenu();
|
||||
|
||||
bool m_bNewExpressionMode;
|
||||
|
||||
// Since we combine left/right into one, this will be less than hdr->numflexcontrollers
|
||||
int m_nViewableFlexControllerCount;
|
||||
};
|
||||
|
||||
extern FlexPanel *g_pFlexPanel;
|
||||
|
||||
#endif // FLEXPANEL_H
|
||||
205
utils/hlfaceposer/globaleventproperties.cpp
Normal file
205
utils/hlfaceposer/globaleventproperties.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <mxtk/mx.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "GlobalEventProperties.h"
|
||||
#include "mdlviewer.h"
|
||||
#include "hlfaceposer.h"
|
||||
#include "choreoevent.h"
|
||||
#include "choreoscene.h"
|
||||
#include "expressions.h"
|
||||
#include "choreoactor.h"
|
||||
#include "ifaceposersound.h"
|
||||
#include "expclass.h"
|
||||
#include "scriplib.h"
|
||||
|
||||
static CGlobalEventParams g_Params;
|
||||
|
||||
static void ExtractAutoStateFromParams( CGlobalEventParams *params )
|
||||
{
|
||||
ParseFromMemory( params->m_szAction, strlen( params->m_szAction ) );
|
||||
|
||||
params->m_bAutomate = false;
|
||||
if ( TokenAvailable() )
|
||||
{
|
||||
GetToken( false );
|
||||
params->m_bAutomate = !stricmp( token, "automate" ) ? true : false;
|
||||
}
|
||||
|
||||
if ( params->m_bAutomate )
|
||||
{
|
||||
params->m_szType[ 0 ] = 0;
|
||||
if ( TokenAvailable() )
|
||||
{
|
||||
GetToken( false );
|
||||
strcpy( params->m_szType, token );
|
||||
}
|
||||
|
||||
params->m_flWaitTime = 0.0f;
|
||||
if ( TokenAvailable() )
|
||||
{
|
||||
GetToken( false );
|
||||
params->m_flWaitTime = (float)atof( token );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateAutoStateFromControls( CGlobalEventParams *params )
|
||||
{
|
||||
if ( params->m_bAutomate )
|
||||
{
|
||||
sprintf( params->m_szAction, "automate %s %f", params->m_szType, params->m_flWaitTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( params->m_szAction, "noaction" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : hwndDlg -
|
||||
// uMsg -
|
||||
// wParam -
|
||||
// lParam -
|
||||
// Output : static BOOL CALLBACK
|
||||
//-----------------------------------------------------------------------------
|
||||
static BOOL CALLBACK GlobalEventPropertiesDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
g_Params.PositionSelf( hwndDlg );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_EVENTNAME, g_Params.m_szName );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_STARTTIME, va( "%f", g_Params.m_flStartTime ) );
|
||||
|
||||
switch ( g_Params.m_nType )
|
||||
{
|
||||
default:
|
||||
Assert(0);
|
||||
break;
|
||||
case CChoreoEvent::SECTION:
|
||||
{
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_LOOPCOUNT ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_LOOPCOUNT ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_LOOPTIME ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_LOOPTIME ), SW_HIDE );
|
||||
|
||||
ExtractAutoStateFromParams( &g_Params );
|
||||
}
|
||||
break;
|
||||
case CChoreoEvent::LOOP:
|
||||
{
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_LOOPCOUNT ), WM_SETTEXT , 0, (LPARAM)va( "%i", g_Params.m_nLoopCount ) );
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_LOOPTIME ), WM_SETTEXT , 0, (LPARAM)va( "%f", g_Params.m_flLoopTime ) );
|
||||
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CB_AUTOACTION ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_DURATION ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_AUTOCHECK ), SW_HIDE );
|
||||
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_AFTER ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_SECONDS ), SW_HIDE );
|
||||
}
|
||||
break;
|
||||
case CChoreoEvent::STOPPOINT:
|
||||
{
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_LOOPCOUNT ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_LOOPCOUNT ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_LOOPTIME ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_LOOPTIME ), SW_HIDE );
|
||||
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CB_AUTOACTION ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_DURATION ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK_AUTOCHECK ), SW_HIDE );
|
||||
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_AFTER ), SW_HIDE );
|
||||
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_SECONDS ), SW_HIDE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CHECK_AUTOCHECK ), BM_SETCHECK,
|
||||
( WPARAM ) g_Params.m_bAutomate ? BST_CHECKED : BST_UNCHECKED,
|
||||
( LPARAM )0 );
|
||||
|
||||
SetDlgItemText( hwndDlg, IDC_DURATION, va( "%f", g_Params.m_flWaitTime ) );
|
||||
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CB_AUTOACTION ), WM_SETTEXT , 0, (LPARAM)g_Params.m_szType );
|
||||
// add text to combo box
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CB_AUTOACTION ), CB_ADDSTRING, 0, (LPARAM)"Cancel" );
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CB_AUTOACTION ), CB_ADDSTRING, 0, (LPARAM)"Resume" );
|
||||
|
||||
|
||||
SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
|
||||
|
||||
SetFocus( GetDlgItem( hwndDlg, IDC_EVENTNAME ) );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
char szTime[ 32 ];
|
||||
|
||||
SendMessage( GetDlgItem( hwndDlg, IDC_CB_AUTOACTION ), WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szType ), (LPARAM)g_Params.m_szType );
|
||||
|
||||
GetDlgItemText( hwndDlg, IDC_DURATION, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flWaitTime = atof( szTime );
|
||||
|
||||
g_Params.m_bAutomate = SendMessage( GetDlgItem( hwndDlg, IDC_CHECK_AUTOCHECK ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
|
||||
|
||||
CreateAutoStateFromControls( &g_Params );
|
||||
|
||||
GetDlgItemText( hwndDlg, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
|
||||
|
||||
GetDlgItemText( hwndDlg, IDC_STARTTIME, szTime, sizeof( szTime ) );
|
||||
g_Params.m_flStartTime = atof( szTime );
|
||||
|
||||
char szLoop[ 32 ];
|
||||
GetDlgItemText( hwndDlg, IDC_LOOPCOUNT, szLoop, sizeof( szLoop ) );
|
||||
g_Params.m_nLoopCount = atoi( szLoop );
|
||||
GetDlgItemText( hwndDlg, IDC_LOOPTIME, szLoop, sizeof( szLoop ) );
|
||||
g_Params.m_flLoopTime = (float)atof( szLoop );
|
||||
|
||||
EndDialog( hwndDlg, 1 );
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog( hwndDlg, 0 );
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *view -
|
||||
// *actor -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int GlobalEventProperties( CGlobalEventParams *params )
|
||||
{
|
||||
g_Params = *params;
|
||||
|
||||
int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
|
||||
MAKEINTRESOURCE( IDD_GLOBALEVENTPROPERTIES ),
|
||||
(HWND)g_MDLViewer->getHandle(),
|
||||
(DLGPROC)GlobalEventPropertiesDialogProc );
|
||||
|
||||
*params = g_Params;
|
||||
|
||||
return retval;
|
||||
}
|
||||
48
utils/hlfaceposer/globaleventproperties.h
Normal file
48
utils/hlfaceposer/globaleventproperties.h
Normal file
@@ -0,0 +1,48 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GLOBALEVENTPROPERTIES_H
|
||||
#define GLOBALEVENTPROPERTIES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class CChoreoScene;
|
||||
|
||||
#include "basedialogparams.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CGlobalEventParams : public CBaseDialogParams
|
||||
{
|
||||
int m_nType;
|
||||
|
||||
// GlobalEvent descriptive name
|
||||
char m_szName[ 256 ];
|
||||
|
||||
// Pause start time
|
||||
float m_flStartTime;
|
||||
|
||||
// Pause Scene or Cancel Scene ( pause/cancel )
|
||||
char m_szAction[ 256 ];
|
||||
|
||||
bool m_bAutomate;
|
||||
|
||||
char m_szType[ 256 ];
|
||||
|
||||
// Idle/paused time before action is taken
|
||||
float m_flWaitTime;
|
||||
|
||||
// For loop events
|
||||
int m_nLoopCount;
|
||||
float m_flLoopTime;
|
||||
};
|
||||
|
||||
int GlobalEventProperties( CGlobalEventParams *params );
|
||||
|
||||
#endif // GLOBALEVENTPROPERTIES_H
|
||||
727
utils/hlfaceposer/hlfaceposer.cpp
Normal file
727
utils/hlfaceposer/hlfaceposer.cpp
Normal file
@@ -0,0 +1,727 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
#include "cbase.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include "filesystem.h"
|
||||
#include "mxtk/mx.h"
|
||||
#include "mxStatusWindow.h"
|
||||
#include "FileSystem.h"
|
||||
#include "StudioModel.h"
|
||||
#include "ControlPanel.h"
|
||||
#include "MDLViewer.h"
|
||||
#include "mxExpressionTray.H"
|
||||
#include "viewersettings.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "faceposer_models.h"
|
||||
#include "expressions.h"
|
||||
#include "choreoview.h"
|
||||
#include "choreoscene.h"
|
||||
#include "vstdlib/random.h"
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
#include "soundchars.h"
|
||||
#include "sentence.h"
|
||||
#include "PhonemeEditor.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "filesystem_init.h"
|
||||
#include "tier2/p4helpers.h"
|
||||
|
||||
|
||||
StudioModel *FindAssociatedModel( CChoreoScene *scene, CChoreoActor *a );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Takes a full path and determines if the file exists on the disk
|
||||
// Input : *filename -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool FPFullpathFileExists( const char *filename )
|
||||
{
|
||||
// Should be a full path
|
||||
Assert( strchr( filename, ':' ) );
|
||||
|
||||
struct _stat buf;
|
||||
int result = _stat( filename, &buf );
|
||||
if ( result != -1 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Utility functions mostly
|
||||
char *FacePoser_MakeWindowsSlashes( char *pname )
|
||||
{
|
||||
static char returnString[ 4096 ];
|
||||
strcpy( returnString, pname );
|
||||
pname = returnString;
|
||||
|
||||
while ( *pname )
|
||||
{
|
||||
if ( *pname == '/' )
|
||||
{
|
||||
*pname = '\\';
|
||||
}
|
||||
pname++;
|
||||
}
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int GetCloseCaptionLanguageId()
|
||||
{
|
||||
return g_viewerSettings.cclanguageid;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : id -
|
||||
//-----------------------------------------------------------------------------
|
||||
void SetCloseCaptionLanguageId( int id, bool force /* = false */ )
|
||||
{
|
||||
Assert( id >= 0 && id < CC_NUM_LANGUAGES );
|
||||
bool changed = g_viewerSettings.cclanguageid != id;
|
||||
g_viewerSettings.cclanguageid = id;
|
||||
if ( changed || force )
|
||||
{
|
||||
// Switch languages
|
||||
char const *suffix = CSentence::NameForLanguage( id );
|
||||
if ( Q_stricmp( suffix, "unknown_language" ) )
|
||||
{
|
||||
char fn[ MAX_PATH ];
|
||||
Q_snprintf( fn, sizeof( fn ), "resource/closecaption_%s.txt", suffix );
|
||||
|
||||
g_pLocalize->RemoveAll();
|
||||
|
||||
if ( Q_stricmp( suffix, "english" )&&
|
||||
filesystem->FileExists( "resource/closecaption_english.txt" ) )
|
||||
{
|
||||
g_pLocalize->AddFile( "resource/closecaption_english.txt", "GAME", true );
|
||||
}
|
||||
|
||||
if ( filesystem->FileExists( fn ) )
|
||||
{
|
||||
g_pLocalize->AddFile( fn, "GAME", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_ErrorPrintf( "PhonemeEditor::SetCloseCaptionLanguageId Warning, can't find localization file %s\n", fn );
|
||||
}
|
||||
|
||||
// Need to redraw the choreoview at least
|
||||
if ( g_pChoreoView )
|
||||
{
|
||||
g_pChoreoView->InvalidateLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( g_MDLViewer )
|
||||
{
|
||||
g_MDLViewer->UpdateLanguageMenu( id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *va( const char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
static char output[32][1024];
|
||||
static int outbuffer = 0;
|
||||
|
||||
outbuffer++;
|
||||
va_start( args, fmt );
|
||||
vprintf( fmt, args );
|
||||
vsprintf( output[ outbuffer & 31 ], fmt, args );
|
||||
return output[ outbuffer & 31 ];
|
||||
}
|
||||
|
||||
void Con_Printf( const char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
static char output[1024];
|
||||
|
||||
va_start( args, fmt );
|
||||
vprintf( fmt, args );
|
||||
vsprintf( output, fmt, args );
|
||||
|
||||
if ( !g_pStatusWindow )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_pStatusWindow->StatusPrint( CONSOLE_COLOR, false, output );
|
||||
}
|
||||
|
||||
void Con_ColorPrintf( const Color& rgb, const char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
static char output[1024];
|
||||
|
||||
va_start( args, fmt );
|
||||
vprintf( fmt, args );
|
||||
vsprintf( output, fmt, args );
|
||||
|
||||
if ( !g_pStatusWindow )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_pStatusWindow->StatusPrint( rgb, false, output );
|
||||
}
|
||||
|
||||
void Con_ErrorPrintf( const char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
static char output[1024];
|
||||
|
||||
va_start( args, fmt );
|
||||
vprintf( fmt, args );
|
||||
vsprintf( output, fmt, args );
|
||||
|
||||
if ( !g_pStatusWindow )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_pStatusWindow->StatusPrint( ERROR_COLOR, false, output );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
//-----------------------------------------------------------------------------
|
||||
void MakeFileWriteable( const char *filename )
|
||||
{
|
||||
Assert( filesystem );
|
||||
char pFullPathBuf[ 512 ];
|
||||
char *pFullPath;
|
||||
if ( !Q_IsAbsolutePath( filename ) )
|
||||
{
|
||||
pFullPath = (char*)filesystem->RelativePathToFullPath( filename, NULL, pFullPathBuf, sizeof(pFullPathBuf) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( pFullPathBuf, filename, sizeof(pFullPathBuf) );
|
||||
pFullPath = pFullPathBuf;
|
||||
}
|
||||
|
||||
if ( pFullPath )
|
||||
{
|
||||
Q_FixSlashes( pFullPath );
|
||||
SetFileAttributes( pFullPath, FILE_ATTRIBUTE_NORMAL );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *filename -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IsFileWriteable( const char *filename )
|
||||
{
|
||||
Assert( filesystem );
|
||||
char pFullPathBuf[ 512 ];
|
||||
char *pFullPath;
|
||||
if ( !Q_IsAbsolutePath( filename ) )
|
||||
{
|
||||
pFullPath = (char*)filesystem->RelativePathToFullPath( filename, NULL, pFullPathBuf, sizeof(pFullPathBuf) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( pFullPathBuf, filename, sizeof(pFullPathBuf) );
|
||||
pFullPath = pFullPathBuf;
|
||||
}
|
||||
|
||||
if ( pFullPath )
|
||||
{
|
||||
Q_FixSlashes( pFullPath );
|
||||
DWORD attrib = GetFileAttributes( pFullPath );
|
||||
return ( ( attrib & FILE_ATTRIBUTE_READONLY ) == 0 );
|
||||
}
|
||||
|
||||
// Doesn't seem to exist, so yeah, it's writable
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MakeFileWriteablePrompt( const char *filename, char const *promptTitle )
|
||||
{
|
||||
if ( !IsFileWriteable( filename ) )
|
||||
{
|
||||
int retval = mxMessageBox( NULL, va( "File '%s' is Read-Only, make writable?", filename ),
|
||||
promptTitle, MX_MB_WARNING | MX_MB_YESNO );
|
||||
|
||||
// Didn't pick yes, bail
|
||||
if ( retval != 0 )
|
||||
return false;
|
||||
|
||||
MakeFileWriteable( filename );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FPCopyFile( const char *source, const char *dest, bool bCheckOut )
|
||||
{
|
||||
Assert( filesystem );
|
||||
char fullpaths[ MAX_PATH ];
|
||||
char fullpathd[ MAX_PATH ];
|
||||
|
||||
if ( !Q_IsAbsolutePath( source ) )
|
||||
{
|
||||
filesystem->RelativePathToFullPath( source, NULL, fullpaths, sizeof(fullpaths) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( fullpaths, source, sizeof(fullpaths) );
|
||||
}
|
||||
|
||||
Q_strncpy( fullpathd, fullpaths, MAX_PATH );
|
||||
char *pSubdir = Q_stristr( fullpathd, source );
|
||||
if ( pSubdir )
|
||||
{
|
||||
*pSubdir = 0;
|
||||
}
|
||||
Q_AppendSlash( fullpathd, MAX_PATH );
|
||||
Q_strncat( fullpathd, dest, MAX_PATH, MAX_PATH );
|
||||
|
||||
Q_FixSlashes( fullpaths );
|
||||
Q_FixSlashes( fullpathd );
|
||||
|
||||
if ( bCheckOut )
|
||||
{
|
||||
CP4AutoEditAddFile checkout( fullpathd );
|
||||
CopyFile( fullpaths, fullpathd, FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyFile( fullpaths, fullpathd, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
bool FacePoser_HasWindowStyle( mxWindow *w, int bits )
|
||||
{
|
||||
HWND wnd = (HWND)w->getHandle();
|
||||
DWORD style = GetWindowLong( wnd, GWL_STYLE );
|
||||
return ( style & bits ) ? true : false;
|
||||
}
|
||||
|
||||
void FacePoser_AddWindowStyle( mxWindow *w, int addbits )
|
||||
{
|
||||
HWND wnd = (HWND)w->getHandle();
|
||||
DWORD style = GetWindowLong( wnd, GWL_STYLE );
|
||||
style |= addbits;
|
||||
SetWindowLong( wnd, GWL_STYLE, style );
|
||||
}
|
||||
|
||||
void FacePoser_AddWindowExStyle( mxWindow *w, int addbits )
|
||||
{
|
||||
HWND wnd = (HWND)w->getHandle();
|
||||
DWORD style = GetWindowLong( wnd, GWL_EXSTYLE );
|
||||
style |= addbits;
|
||||
SetWindowLong( wnd, GWL_EXSTYLE, style );
|
||||
}
|
||||
|
||||
void FacePoser_RemoveWindowStyle( mxWindow *w, int removebits )
|
||||
{
|
||||
HWND wnd = (HWND)w->getHandle();
|
||||
DWORD style = GetWindowLong( wnd, GWL_STYLE );
|
||||
style &= ~removebits;
|
||||
SetWindowLong( wnd, GWL_STYLE, style );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *w -
|
||||
//-----------------------------------------------------------------------------
|
||||
void FacePoser_MakeToolWindow( mxWindow *w, bool smallcaption )
|
||||
{
|
||||
FacePoser_AddWindowStyle( w, WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS );
|
||||
if ( smallcaption )
|
||||
{
|
||||
FacePoser_AddWindowExStyle( w, WS_EX_OVERLAPPEDWINDOW );
|
||||
FacePoser_AddWindowExStyle( w, WS_EX_TOOLWINDOW );
|
||||
}
|
||||
}
|
||||
|
||||
bool LoadViewerSettingsInt( char const *keyname, int *value );
|
||||
bool SaveViewerSettingsInt ( const char *keyname, int value );
|
||||
|
||||
void FacePoser_LoadWindowPositions( char const *name, bool& visible, int& x, int& y, int& w, int& h, bool& locked, bool& zoomed )
|
||||
{
|
||||
char subkey[ 512 ];
|
||||
int v;
|
||||
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - visible", name );
|
||||
LoadViewerSettingsInt( subkey, &v );
|
||||
visible = v ? true : false;
|
||||
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - locked", name );
|
||||
LoadViewerSettingsInt( subkey, &v );
|
||||
locked = v ? true : false;
|
||||
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - zoomed", name );
|
||||
LoadViewerSettingsInt( subkey, &v );
|
||||
zoomed = v ? true : false;
|
||||
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - x", name );
|
||||
LoadViewerSettingsInt( subkey, &x );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - y", name );
|
||||
LoadViewerSettingsInt( subkey, &y );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - width", name );
|
||||
LoadViewerSettingsInt( subkey, &w );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - height", name );
|
||||
LoadViewerSettingsInt( subkey, &h );
|
||||
}
|
||||
|
||||
void FacePoser_SaveWindowPositions( char const *name, bool visible, int x, int y, int w, int h, bool locked, bool zoomed )
|
||||
{
|
||||
char subkey[ 512 ];
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - visible", name );
|
||||
SaveViewerSettingsInt( subkey, visible );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - locked", name );
|
||||
SaveViewerSettingsInt( subkey, locked );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - x", name );
|
||||
SaveViewerSettingsInt( subkey, x );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - y", name );
|
||||
SaveViewerSettingsInt( subkey, y );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - width", name );
|
||||
SaveViewerSettingsInt( subkey, w );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - height", name );
|
||||
SaveViewerSettingsInt( subkey, h );
|
||||
Q_snprintf( subkey, sizeof( subkey ), "%s - zoomed", name );
|
||||
SaveViewerSettingsInt( subkey, zoomed );
|
||||
}
|
||||
|
||||
static char g_PhonemeRoot[ MAX_PATH ] = { 0 };
|
||||
void FacePoser_SetPhonemeRootDir( char const *pchRootDir )
|
||||
{
|
||||
Q_strncpy( g_PhonemeRoot, pchRootDir, sizeof( g_PhonemeRoot ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void FacePoser_EnsurePhonemesLoaded( void )
|
||||
{
|
||||
// Don't bother unless a model is loaded, at least...
|
||||
CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr();
|
||||
if ( !hdr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char const *ext[] =
|
||||
{
|
||||
"",
|
||||
"_strong",
|
||||
"_weak",
|
||||
};
|
||||
|
||||
for ( int i = 0 ; i < ARRAYSIZE( ext ); ++i )
|
||||
{
|
||||
char clname[ 256 ];
|
||||
Q_snprintf( clname, sizeof( clname ), "%sphonemes%s", g_PhonemeRoot, ext[ i ] );
|
||||
Q_FixSlashes( clname );
|
||||
Q_strlower( clname );
|
||||
|
||||
if ( !expressions->FindClass( clname, false ) )
|
||||
{
|
||||
char clfile[ MAX_PATH ];
|
||||
Q_snprintf( clfile, sizeof( clfile ), "expressions/%sphonemes%s.txt", g_PhonemeRoot, ext[ i ] );
|
||||
Q_FixSlashes( clfile );
|
||||
Q_strlower( clfile );
|
||||
|
||||
if ( g_pFileSystem->FileExists( clfile ) )
|
||||
{
|
||||
expressions->LoadClass( clfile );
|
||||
CExpClass *cl = expressions->FindClass( clname, false );
|
||||
if ( !cl )
|
||||
{
|
||||
Con_Printf( "FacePoser_EnsurePhonemesLoaded: %s missing!!!\n", clfile );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FacePoser_ShowFileNameDialog( bool openFile, char *relative, size_t bufsize, char const *subdir, char const *wildcard )
|
||||
{
|
||||
Assert( relative );
|
||||
relative[ 0 ] = 0 ;
|
||||
Assert( subdir );
|
||||
Assert( wildcard );
|
||||
|
||||
char workingdir[ 256 ];
|
||||
Q_getwd( workingdir, sizeof( workingdir ) );
|
||||
strlwr( workingdir );
|
||||
Q_FixSlashes( workingdir, '/' );
|
||||
|
||||
// Show file io
|
||||
bool inWorkingDirectoryAlready = false;
|
||||
if ( Q_stristr_slash( workingdir, va( "%s%s", GetGameDirectory(), subdir ) ) )
|
||||
{
|
||||
inWorkingDirectoryAlready = true;
|
||||
}
|
||||
|
||||
// Show file io
|
||||
const char *fullpath = NULL;
|
||||
|
||||
if ( openFile )
|
||||
{
|
||||
fullpath = mxGetOpenFileName(
|
||||
0,
|
||||
inWorkingDirectoryAlready ? "." : FacePoser_MakeWindowsSlashes( va( "%s%s/", GetGameDirectory(), subdir ) ),
|
||||
wildcard );
|
||||
}
|
||||
else
|
||||
{
|
||||
fullpath = mxGetSaveFileName(
|
||||
0,
|
||||
inWorkingDirectoryAlready ? "." : FacePoser_MakeWindowsSlashes( va( "%s%s/", GetGameDirectory(), subdir ) ),
|
||||
wildcard );
|
||||
}
|
||||
if ( !fullpath || !fullpath[ 0 ] )
|
||||
return false;
|
||||
|
||||
Q_strncpy( relative, fullpath, bufsize );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FacePoser_ShowOpenFileNameDialog( char *relative, size_t bufsize, char const *subdir, char const *wildcard )
|
||||
{
|
||||
return FacePoser_ShowFileNameDialog( true, relative, bufsize, subdir, wildcard );
|
||||
}
|
||||
|
||||
bool FacePoser_ShowSaveFileNameDialog( char *relative, size_t bufsize, char const *subdir, char const *wildcard )
|
||||
{
|
||||
return FacePoser_ShowFileNameDialog( false, relative, bufsize, subdir, wildcard );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: converts an english string to unicode
|
||||
//-----------------------------------------------------------------------------
|
||||
int ConvertANSIToUnicode(const char *ansi, wchar_t *unicode, int unicodeBufferSize)
|
||||
{
|
||||
return ::MultiByteToWideChar(CP_ACP, 0, ansi, -1, unicode, unicodeBufferSize);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: converts an unicode string to an english string
|
||||
//-----------------------------------------------------------------------------
|
||||
int ConvertUnicodeToANSI(const wchar_t *unicode, char *ansi, int ansiBufferSize)
|
||||
{
|
||||
return ::WideCharToMultiByte(CP_ACP, 0, unicode, -1, ansi, ansiBufferSize, NULL, NULL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: If FPS is set and "using grid", snap to proper fractional time value
|
||||
// Input : t -
|
||||
// Output : float
|
||||
//-----------------------------------------------------------------------------
|
||||
float FacePoser_SnapTime( float t )
|
||||
{
|
||||
if ( !g_pChoreoView )
|
||||
return t;
|
||||
|
||||
CChoreoScene *scene = g_pChoreoView->GetScene();
|
||||
if ( !scene )
|
||||
return t;
|
||||
|
||||
return scene->SnapTime( t );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : t -
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *FacePoser_DescribeSnappedTime( float t )
|
||||
{
|
||||
static char desc[ 128 ];
|
||||
Q_snprintf( desc, sizeof( desc ), "%.3f", t );
|
||||
|
||||
if ( !g_pChoreoView )
|
||||
return desc;
|
||||
|
||||
CChoreoScene *scene = g_pChoreoView->GetScene();
|
||||
if ( !scene )
|
||||
return desc;
|
||||
|
||||
t = scene->SnapTime( t );
|
||||
|
||||
int fps = scene->GetSceneFPS();
|
||||
|
||||
int ipart = (int)t;
|
||||
int fracpart = (int)( ( t - (float)ipart ) * (float)fps + 0.5f );
|
||||
|
||||
int frame = ipart * fps + fracpart;
|
||||
|
||||
if ( fracpart == 0 )
|
||||
{
|
||||
Q_snprintf( desc, sizeof( desc ), "frame %i (time %i s.)", frame, ipart );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_snprintf( desc, sizeof( desc ), "frame %i (time %i + %i/%i s.)",
|
||||
frame, ipart,fracpart, fps );
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int FacePoser_GetSceneFPS( void )
|
||||
{
|
||||
if ( !g_pChoreoView )
|
||||
return 1000;
|
||||
|
||||
CChoreoScene *scene = g_pChoreoView->GetScene();
|
||||
if ( !scene )
|
||||
return 1000;
|
||||
|
||||
return scene->GetSceneFPS();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool FacePoser_IsSnapping( void )
|
||||
{
|
||||
if ( !g_pChoreoView )
|
||||
return false;
|
||||
|
||||
CChoreoScene *scene = g_pChoreoView->GetScene();
|
||||
if ( !scene )
|
||||
return false;
|
||||
|
||||
return scene->IsUsingFrameSnap();
|
||||
}
|
||||
|
||||
char const *FacePoser_TranslateSoundNameGender( char const *soundname, gender_t gender )
|
||||
{
|
||||
if ( Q_stristr( soundname, ".wav" ) )
|
||||
return PSkipSoundChars( soundname );
|
||||
|
||||
return PSkipSoundChars( soundemitter->GetWavFileForSound( soundname, gender ) );
|
||||
}
|
||||
|
||||
char const *FacePoser_TranslateSoundName( char const *soundname, StudioModel *model /*= NULL*/ )
|
||||
{
|
||||
if ( Q_stristr( soundname, ".wav" ) )
|
||||
return PSkipSoundChars( soundname );
|
||||
|
||||
static char temp[ 256 ];
|
||||
|
||||
if ( model )
|
||||
{
|
||||
Q_strncpy( temp, PSkipSoundChars( soundemitter->GetWavFileForSound( soundname, model->GetFileName() ) ), sizeof( temp ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( temp, PSkipSoundChars( soundemitter->GetWavFileForSound( soundname, NULL ) ), sizeof( temp ) );
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
char const *FacePoser_TranslateSoundName( CChoreoEvent *event )
|
||||
{
|
||||
char const *soundname = event->GetParameters();
|
||||
if ( Q_stristr( soundname, ".wav" ) )
|
||||
return PSkipSoundChars( soundname );
|
||||
|
||||
// See if we can figure out the .mdl associated to this event's actor
|
||||
static char temp[ 256 ];
|
||||
temp[ 0 ] = 0;
|
||||
StudioModel *model = NULL;
|
||||
|
||||
CChoreoActor *a = event->GetActor();
|
||||
CChoreoScene *s = event->GetScene();
|
||||
|
||||
if ( a != NULL &&
|
||||
s != NULL )
|
||||
{
|
||||
model = FindAssociatedModel( s, a );
|
||||
}
|
||||
|
||||
Q_strncpy( temp, PSkipSoundChars( soundemitter->GetWavFileForSound( soundname, model ? model->GetFileName() : NULL ) ), sizeof( temp ) );
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
#if defined( _WIN32 ) || defined( WIN32 )
|
||||
#define PATHSEPARATOR(c) ((c) == '\\' || (c) == '/')
|
||||
#else //_WIN32
|
||||
#define PATHSEPARATOR(c) ((c) == '/')
|
||||
#endif //_WIN32
|
||||
|
||||
static bool charsmatch( char c1, char c2 )
|
||||
{
|
||||
if ( tolower( c1 ) == tolower( c2 ) )
|
||||
return true;
|
||||
if ( PATHSEPARATOR( c1 ) && PATHSEPARATOR( c2 ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
char *Q_stristr_slash( char const *pStr, char const *pSearch )
|
||||
{
|
||||
AssertValidStringPtr(pStr);
|
||||
AssertValidStringPtr(pSearch);
|
||||
|
||||
if (!pStr || !pSearch)
|
||||
return 0;
|
||||
|
||||
char const* pLetter = pStr;
|
||||
|
||||
// Check the entire string
|
||||
while (*pLetter != 0)
|
||||
{
|
||||
// Skip over non-matches
|
||||
if ( charsmatch( *pLetter, *pSearch ) )
|
||||
{
|
||||
// Check for match
|
||||
char const* pMatch = pLetter + 1;
|
||||
char const* pTest = pSearch + 1;
|
||||
while (*pTest != 0)
|
||||
{
|
||||
// We've run off the end; don't bother.
|
||||
if (*pMatch == 0)
|
||||
return 0;
|
||||
|
||||
if ( !charsmatch( *pMatch, *pTest ) )
|
||||
break;
|
||||
|
||||
++pMatch;
|
||||
++pTest;
|
||||
}
|
||||
|
||||
// Found a match!
|
||||
if (*pTest == 0)
|
||||
return (char *)pLetter;
|
||||
}
|
||||
|
||||
++pLetter;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CUniformRandomStream g_Random;
|
||||
IUniformRandomStream *random = &g_Random;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user