summaryrefslogtreecommitdiff
path: root/utils/hlfaceposer/soundlookup.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/hlfaceposer/soundlookup.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/hlfaceposer/soundlookup.cpp')
-rw-r--r--utils/hlfaceposer/soundlookup.cpp140
1 files changed, 140 insertions, 0 deletions
diff --git a/utils/hlfaceposer/soundlookup.cpp b/utils/hlfaceposer/soundlookup.cpp
new file mode 100644
index 0000000..128e340
--- /dev/null
+++ b/utils/hlfaceposer/soundlookup.cpp
@@ -0,0 +1,140 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+#include "cbase.h"
+#include "mxtk/mx.h"
+#include "resource.h"
+#include "SoundLookup.h"
+#include "mdlviewer.h"
+#include "SoundEmitterSystem/isoundemittersystembase.h"
+#include "addsoundentry.h"
+
+static CSoundLookupParams g_Params;
+
+static void PopulateSoundEntryList( HWND wnd, CSoundLookupParams *params )
+{
+ HWND control = GetDlgItem( wnd, IDC_SOUNDENTRYLIST );
+ if ( !control )
+ return;
+
+ SendMessage( control, LB_RESETCONTENT, 0, 0 );
+ SendMessage( control, WM_SETFONT, (WPARAM) (HFONT) GetStockObject (ANSI_FIXED_FONT), MAKELPARAM (TRUE, 0) );
+
+ int c = params->entryList->Count();
+ for ( int i = 0; i < c; i++ )
+ {
+ int soundindex = (*params->entryList)[ i ];
+ char text[ 128 ];
+ text[ 0 ] = 0;
+ Q_strncpy( text, soundemitter->GetSoundName( soundindex ), sizeof( text ) );
+ if ( text[0] )
+ {
+ char const *script = soundemitter->GetSourceFileForSound( soundindex );
+
+ int idx = SendMessage( control, LB_ADDSTRING, 0, (LPARAM)va( "%20s: '%s'", script, text ) );
+ SendMessage( control, LB_SETITEMDATA, idx, (LPARAM)soundindex );
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : hwndDlg -
+// uMsg -
+// wParam -
+// lParam -
+// Output : static BOOL CALLBACK
+//-----------------------------------------------------------------------------
+static BOOL CALLBACK SoundLookupDialogProc( 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 );
+
+ PopulateSoundEntryList( hwndDlg, &g_Params );
+
+ SetDlgItemText( hwndDlg, IDC_STATIC_PROMPT, g_Params.m_szPrompt );
+
+ SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
+
+ SetFocus( GetDlgItem( hwndDlg, IDC_SOUNDENTRYLIST ) );
+ }
+ return FALSE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ {
+ int selindex = SendMessage( GetDlgItem( hwndDlg, IDC_SOUNDENTRYLIST ), LB_GETCURSEL, 0, 0 );
+ if ( selindex == LB_ERR )
+ {
+ mxMessageBox( NULL, "You must select an entry from the list", g_appTitle, MB_OK );
+ return TRUE;
+ }
+
+ int soundindex = SendMessage( GetDlgItem( hwndDlg, IDC_SOUNDENTRYLIST ), LB_GETITEMDATA, selindex, 0 );
+
+ Assert( soundindex != LB_ERR );
+
+ Q_strncpy( g_Params.m_szSoundName, soundemitter->GetSoundName( soundindex ), sizeof ( g_Params.m_szSoundName ) );
+ EndDialog( hwndDlg, 1 );
+ }
+ break;
+ case IDCANCEL:
+ EndDialog( hwndDlg, 0 );
+ break;
+ case IDC_ADDENTRY:
+ {
+ // Create a new sound entry for this sound
+ CAddSoundParams params;
+ Q_memset( &params, 0, sizeof( params ) );
+ Q_strcpy( params.m_szDialogTitle, "Add Sound Entry" );
+ Q_strcpy( params.m_szWaveFile, g_Params.m_szWaveFile );
+
+ if ( AddSound( &params, hwndDlg ) )
+ {
+ // Add it to soundemitter and check out script files
+ if ( params.m_szSoundName[ 0 ] &&
+ params.m_szScriptName[ 0 ] )
+ {
+ Q_strcpy( g_Params.m_szSoundName, params.m_szSoundName );
+ // Press the OK button for the user...
+ EndDialog( hwndDlg, 1 );
+ }
+ }
+ }
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *view -
+// *actor -
+// Output : int
+//-----------------------------------------------------------------------------
+int SoundLookup( CSoundLookupParams *params, HWND parent )
+{
+ g_Params = *params;
+
+ int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
+ MAKEINTRESOURCE( IDD_WAVELOOKUP ),
+ parent,
+ (DLGPROC)SoundLookupDialogProc );
+
+ *params = g_Params;
+
+ return retval;
+} \ No newline at end of file