summaryrefslogtreecommitdiff
path: root/utils/hlfaceposer/choiceproperties.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/choiceproperties.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/hlfaceposer/choiceproperties.cpp')
-rw-r--r--utils/hlfaceposer/choiceproperties.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/utils/hlfaceposer/choiceproperties.cpp b/utils/hlfaceposer/choiceproperties.cpp
new file mode 100644
index 0000000..30956c1
--- /dev/null
+++ b/utils/hlfaceposer/choiceproperties.cpp
@@ -0,0 +1,125 @@
+//========= Copyright 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;
+} \ No newline at end of file