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.

153 lines
3.5 KiB

  1. #include <windows.h>
  2. #include "wintab.h"
  3. #include "Mgrtest.h"
  4. #include "resource.h"
  5. static const unsigned textfield[1] = { IDC_MMTEXT };
  6. static const char * pk_tags[] = {
  7. "PK_CONTEXT", "PK_STATUS", "PK_TIME", "PK_CHANGED", "PK_SERIAL_NUMBER", "PK_CURSOR", "PK_BUTTONS",
  8. "PK_X", "PK_Y", "PK_Z", "PK_NORMAL_PRESSURE", "PK_TANGENT_PRESSURE", "PK_ORIENTATION", "PK_ROTATION", 0 };
  9. extern HANDLE hInst;
  10. static void MoveMask_DisplayBits( HWND hDlg, DWORD MoveMask )
  11. {
  12. char buf[33];
  13. unsigned j;
  14. buf[32] = 0;
  15. for( j = 0; j < 32; j++ )
  16. buf[j] = '0' + (char)((MoveMask >> j) & 0x01);
  17. SetWindowText(GetDlgItem(hDlg, IDC_MMTEXT), buf);
  18. }
  19. BOOL
  20. CALLBACK MoveMask_DlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LONG lParam)
  21. {
  22. static DWORD * MoveMask;
  23. BOOL fResult;
  24. int i;
  25. LRESULT val;
  26. switch (Msg) {
  27. case WM_INITDIALOG:
  28. MoveMask = (DWORD *)lParam;
  29. /* List the available cursors, and highlight them if their Csrmask bits are set */
  30. i = 0;
  31. while( pk_tags[i] != NULL ) {
  32. SendDlgItemMessage( hDlg, IDC_LST, LB_ADDSTRING, 0, (LPARAM)((char far *)pk_tags[i]) );
  33. i++;
  34. }
  35. /* for Unknown Reason, sending LB_SETSEL right after LB_ADDSTRING doesn't work reliably */
  36. i = 0;
  37. while( pk_tags[i] != NULL ) {
  38. /* Highlight the name in the selection box */
  39. SendDlgItemMessage( hDlg, IDC_LST, LB_SETSEL, (WPARAM)((*MoveMask >> i) & 0x01), i );
  40. i++;
  41. }
  42. /* Display the Csrmask bitfield bits */
  43. MoveMask_DisplayBits( hDlg, *MoveMask );
  44. fResult = TRUE;
  45. break;
  46. case WM_LBUTTONDOWN:
  47. /* If clicked on a number in IDC_TEXT?, then change it's corrisponding bit */
  48. i = test_bitboxes( hDlg, lParam, 32, 1, textfield );
  49. if( i > -1 ) {
  50. /* Flip the bit */
  51. *MoveMask ^= 1 << i;
  52. MoveMask_DisplayBits( hDlg, *MoveMask );
  53. /* Highlight the corrisponding cursor in the listbox appropriately */
  54. SendDlgItemMessage( hDlg, IDC_LST, LB_SETSEL, (WPARAM)((*MoveMask >> i) & 0x01), i );
  55. }
  56. fResult = TRUE;
  57. break;
  58. case WM_COMMAND:
  59. switch( wParam ) {
  60. case IDOK:
  61. EndDialog(hDlg, wParam);
  62. fResult = TRUE;
  63. break;
  64. case IDCANCEL:
  65. EndDialog(hDlg, wParam);
  66. fResult = TRUE;
  67. break;
  68. default:
  69. if( HIWORD(wParam) == LBN_SELCHANGE || wParam == IDC_LST ) {
  70. /* Set all of the bits according to the selection box selections until error */
  71. i = 0;
  72. fResult = FALSE;
  73. while( !fResult ) {
  74. val = SendMessage( (HWND)lParam, LB_GETSEL, i, 0 );
  75. if( val > 0 )
  76. *MoveMask |= 1 << i;
  77. else
  78. if( val == 0 )
  79. *MoveMask &= ~(1 << i);
  80. else
  81. fResult = TRUE;
  82. if( i == 31 )
  83. fResult = TRUE;
  84. i++;
  85. }
  86. /* Redisplay the bits */
  87. MoveMask_DisplayBits( hDlg, *MoveMask );
  88. }
  89. break;
  90. }
  91. break;
  92. default:
  93. fResult = FALSE;
  94. break;
  95. }
  96. return fResult;
  97. }
  98. void
  99. set_ctx_MoveMask( HWND hWnd, HMGR hMgr, HCTX hCtx )
  100. {
  101. FARPROC fpProc;
  102. int id;
  103. LOGCONTEXT lc;
  104. /* Read the button masks */
  105. if( !WTGet( hCtx, &lc ) ) {
  106. MessageBox( hWnd, "WTGet failed.", "MgrTest", MB_ICONHAND | MB_OK );
  107. return;
  108. }
  109. /* Do the button bit dialog */
  110. fpProc = MakeProcInstance( (FARPROC)MoveMask_DlgProc, hInst );
  111. id = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MOVEMASK), hWnd, fpProc, (LPARAM)((DWORD FAR *)&lc.lcMoveMask));
  112. FreeProcInstance(fpProc);
  113. /* Set the new button masks */
  114. if( id == IDOK ) {
  115. if( !WTSet( hCtx, &lc ) )
  116. MessageBox( hWnd, "WTSet failed.", "MgrTest", MB_ICONHAND | MB_OK );
  117. }
  118. }