DebuggerApp.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "../../sys/win32/rc/debugger_resource.h"
  23. #include "DebuggerApp.h"
  24. /*
  25. ================
  26. rvDebuggerApp::rvDebuggerApp
  27. ================
  28. */
  29. rvDebuggerApp::rvDebuggerApp ( ) :
  30. mOptions ( "Software\\id Software\\DOOM3\\Tools\\Debugger" )
  31. {
  32. mInstance = NULL;
  33. mDebuggerWindow = NULL;
  34. mAccelerators = NULL;
  35. }
  36. /*
  37. ================
  38. rvDebuggerApp::~rvDebuggerApp
  39. ================
  40. */
  41. rvDebuggerApp::~rvDebuggerApp ( )
  42. {
  43. if ( mAccelerators )
  44. {
  45. DestroyAcceleratorTable ( mAccelerators );
  46. }
  47. }
  48. /*
  49. ================
  50. rvDebuggerApp::Initialize
  51. Initializes the debugger application by creating the debugger window
  52. ================
  53. */
  54. bool rvDebuggerApp::Initialize ( HINSTANCE instance )
  55. {
  56. INITCOMMONCONTROLSEX ex;
  57. ex.dwICC = ICC_USEREX_CLASSES | ICC_LISTVIEW_CLASSES | ICC_WIN95_CLASSES;
  58. ex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  59. mInstance = instance;
  60. mOptions.Load ( );
  61. mDebuggerWindow = new rvDebuggerWindow;
  62. if ( !mDebuggerWindow->Create ( instance ) )
  63. {
  64. delete mDebuggerWindow;
  65. return false;
  66. }
  67. // Initialize the network connection for the debugger
  68. if ( !mClient.Initialize ( ) )
  69. {
  70. return false;
  71. }
  72. mAccelerators = LoadAccelerators ( mInstance, MAKEINTRESOURCE(IDR_DBG_ACCELERATORS) );
  73. return true;
  74. }
  75. /*
  76. ================
  77. rvDebuggerApp::ProcessWindowMessages
  78. Process windows messages
  79. ================
  80. */
  81. bool rvDebuggerApp::ProcessWindowMessages ( void )
  82. {
  83. MSG msg;
  84. while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ) )
  85. {
  86. if ( !GetMessage (&msg, NULL, 0, 0) )
  87. {
  88. return false;
  89. }
  90. if ( !TranslateAccelerator ( &msg ) )
  91. {
  92. TranslateMessage(&msg);
  93. DispatchMessage(&msg);
  94. }
  95. }
  96. return true;
  97. }
  98. /*
  99. ================
  100. rvDebuggerApp::TranslateAccelerator
  101. Translate any accelerators destined for this window
  102. ================
  103. */
  104. bool rvDebuggerApp::TranslateAccelerator ( LPMSG msg )
  105. {
  106. if ( mDebuggerWindow && ::TranslateAccelerator ( mDebuggerWindow->GetWindow(), mAccelerators, msg ) )
  107. {
  108. return true;
  109. }
  110. return false;
  111. }
  112. /*
  113. ================
  114. rvDebuggerApp::Run
  115. Main Loop for the debugger application
  116. ================
  117. */
  118. int rvDebuggerApp::Run ( void )
  119. {
  120. // Main message loop:
  121. while ( ProcessWindowMessages ( ) )
  122. {
  123. mClient.ProcessMessages ( );
  124. Sleep ( 0 );
  125. }
  126. mClient.Shutdown ( );
  127. mOptions.Save ( );
  128. delete mDebuggerWindow;
  129. return 1;
  130. }