Team Fortress 2 Source Code as on 22/4/2020
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.

137 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "resource.h"
  9. #include "MultipleRequest.h"
  10. #include "workspacemanager.h"
  11. static CMultipleParams g_Params;
  12. //-----------------------------------------------------------------------------
  13. // Purpose:
  14. // Input : hwndDlg -
  15. // uMsg -
  16. // wParam -
  17. // lParam -
  18. // Output : static BOOL CALLBACK
  19. //-----------------------------------------------------------------------------
  20. static BOOL CALLBACK MultipleRequestDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  21. {
  22. switch(uMsg)
  23. {
  24. case WM_INITDIALOG:
  25. // Insert code here to put the string (to find and replace with)
  26. // into the edit controls.
  27. // ...
  28. {
  29. g_Params.PositionSelf( hwndDlg );
  30. SetDlgItemText( hwndDlg, IDC_PROMPT, g_Params.m_szPrompt );
  31. SetWindowText( hwndDlg, g_Params.m_szDialogTitle );
  32. SetFocus( GetDlgItem( hwndDlg, IDC_INPUTSTRING ) );
  33. SendMessage( GetDlgItem( hwndDlg, IDC_INPUTSTRING ), EM_SETSEL, 0, MAKELONG(0, 0xffff) );
  34. }
  35. return FALSE;
  36. case WM_COMMAND:
  37. switch (LOWORD(wParam))
  38. {
  39. case IDC_YESALL:
  40. EndDialog( hwndDlg, CMultipleParams::YES_ALL );
  41. break;
  42. case IDC_YES:
  43. EndDialog( hwndDlg, CMultipleParams::YES );
  44. break;
  45. case IDC_NOSINGLE:
  46. EndDialog( hwndDlg, CMultipleParams::NO );
  47. break;
  48. case IDC_NOALL:
  49. EndDialog( hwndDlg, CMultipleParams::NO_ALL );
  50. break;
  51. //case IDCANCEL:
  52. // EndDialog( hwndDlg, CMultipleParams::CANCEL );
  53. // break;
  54. }
  55. return TRUE;
  56. }
  57. return FALSE;
  58. }
  59. static int g_MRContext = 1;
  60. static int g_MRCurrentContext;
  61. static int g_MRLastResult = -1;
  62. void MultipleRequestChangeContext()
  63. {
  64. ++g_MRContext;
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Purpose:
  68. // Input : *view -
  69. // *actor -
  70. // Output : int
  71. //-----------------------------------------------------------------------------
  72. int _MultipleRequest( CMultipleParams *params )
  73. {
  74. int retval = -1;
  75. if ( g_MRCurrentContext == g_MRContext &&
  76. g_MRLastResult != -1 )
  77. {
  78. if ( g_MRLastResult == CMultipleParams::YES_ALL )
  79. {
  80. retval = 0;
  81. }
  82. if ( g_MRLastResult == CMultipleParams::NO_ALL )
  83. {
  84. retval = 1;
  85. }
  86. }
  87. if ( retval == -1 )
  88. {
  89. g_Params = *params;
  90. retval = DialogBox( (HINSTANCE)GetModuleHandle( 0 ),
  91. MAKEINTRESOURCE( IDD_MULTIPLEQUESTION ),
  92. (HWND)GetWorkspaceManager()->getHandle(),
  93. (DLGPROC)MultipleRequestDialogProc );
  94. *params = g_Params;
  95. }
  96. g_MRCurrentContext = g_MRContext;
  97. g_MRLastResult = retval;
  98. switch ( retval )
  99. {
  100. case CMultipleParams::YES_ALL:
  101. case CMultipleParams::YES:
  102. return 0;
  103. case CMultipleParams::NO_ALL:
  104. case CMultipleParams::NO:
  105. return 1;
  106. default:
  107. case CMultipleParams::CANCEL:
  108. return 2;
  109. }
  110. Assert( 0 );
  111. return 1;
  112. }
  113. int MultipleRequest( char const *prompt )
  114. {
  115. CMultipleParams params;
  116. memset( &params, 0, sizeof( params ) );
  117. Q_strcpy( params.m_szDialogTitle, g_appTitle );
  118. Q_strncpy( params.m_szPrompt, prompt, sizeof( params.m_szPrompt ) );
  119. return _MultipleRequest( &params );
  120. }