Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
2.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "resource.h"
  8. #include "ChoiceProperties.h"
  9. #include <mxtk/mx.h>
  10. #include "mdlviewer.h"
  11. static CChoiceParams g_Params;
  12. static void PopulateChoiceList( HWND wnd, CChoiceParams *params )
  13. {
  14. HWND control = GetDlgItem( wnd, IDC_CHOICE );
  15. if ( !control )
  16. return;
  17. SendMessage( control, CB_RESETCONTENT, 0, 0 );
  18. int c = params->m_Choices.Count();
  19. if ( params->m_nSelected == -1 )
  20. params->m_nSelected = 0;
  21. if ( params->m_nSelected >= 0 && params->m_nSelected < c )
  22. {
  23. SendMessage( control, WM_SETTEXT , 0, (LPARAM)params->m_Choices[ params->m_nSelected ].choice );
  24. }
  25. for ( int i = 0; i < c; i++ )
  26. {
  27. char const *text = params->m_Choices[ i ].choice;
  28. SendMessage( control, CB_ADDSTRING, 0, (LPARAM)text );
  29. }
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose:
  33. // Input : hwndDlg -
  34. // uMsg -
  35. // wParam -
  36. // lParam -
  37. // Output : static BOOL CALLBACK
  38. //-----------------------------------------------------------------------------
  39. static BOOL CALLBACK ChoicePropertiesDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  40. {
  41. switch(uMsg)
  42. {
  43. case WM_INITDIALOG:
  44. // Insert code here to put the string (to find and replace with)
  45. // into the edit controls.
  46. // ...
  47. {
  48. g_Params.PositionSelf( hwndDlg );
  49. PopulateChoiceList( hwndDlg, &g_Params );
  50. SetDlgItemText( hwndDlg, IDC_STATIC_PROMPT, g_Params.m_szPrompt );
  51. SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
  52. }
  53. return TRUE;
  54. case WM_COMMAND:
  55. switch (LOWORD(wParam))
  56. {
  57. case IDOK:
  58. {
  59. char selected[ MAX_CHOICE_TEXT_SIZE ];
  60. selected[ 0 ] = 0;
  61. HWND control = GetDlgItem( hwndDlg, IDC_CHOICE );
  62. if ( control )
  63. {
  64. SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( selected ), (LPARAM)selected );
  65. }
  66. g_Params.m_nSelected = -1;
  67. int c = g_Params.m_Choices.Count();
  68. for ( int i = 0; i < c; i++ )
  69. {
  70. char const *text = g_Params.m_Choices[ i ].choice;
  71. if ( stricmp( text, selected ) )
  72. {
  73. continue;
  74. }
  75. g_Params.m_nSelected = i;
  76. break;
  77. }
  78. EndDialog( hwndDlg, 1 );
  79. }
  80. break;
  81. case IDCANCEL:
  82. EndDialog( hwndDlg, 0 );
  83. break;
  84. }
  85. return TRUE;
  86. }
  87. return FALSE;
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Purpose:
  91. // Input : *view -
  92. // *actor -
  93. // Output : int
  94. //-----------------------------------------------------------------------------
  95. int ChoiceProperties( CChoiceParams *params )
  96. {
  97. g_Params = *params;
  98. int retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
  99. MAKEINTRESOURCE( IDD_CHOICEDIALOG ),
  100. (HWND)g_MDLViewer->getHandle(),
  101. (DLGPROC)ChoicePropertiesDialogProc );
  102. *params = g_Params;
  103. return retval;
  104. }