doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DebuggerApp.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 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.
23 
24 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.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "../../sys/win32/rc/debugger_resource.h"
33 #include "DebuggerApp.h"
34 
35 /*
36 ================
37 rvDebuggerApp::rvDebuggerApp
38 ================
39 */
41  mOptions ( "Software\\id Software\\DOOM3\\Tools\\Debugger" )
42 {
43  mInstance = NULL;
46 }
47 
48 /*
49 ================
50 rvDebuggerApp::~rvDebuggerApp
51 ================
52 */
53 rvDebuggerApp::~rvDebuggerApp ( )
54 {
55  if ( mAccelerators )
56  {
57  DestroyAcceleratorTable ( mAccelerators );
58  }
59 }
60 
61 /*
62 ================
63 rvDebuggerApp::Initialize
64 
65 Initializes the debugger application by creating the debugger window
66 ================
67 */
68 bool rvDebuggerApp::Initialize ( HINSTANCE instance )
69 {
70  INITCOMMONCONTROLSEX ex;
71  ex.dwICC = ICC_USEREX_CLASSES | ICC_LISTVIEW_CLASSES | ICC_WIN95_CLASSES;
72  ex.dwSize = sizeof(INITCOMMONCONTROLSEX);
73 
74  mInstance = instance;
75 
76  mOptions.Load ( );
77 
79 
80  if ( !mDebuggerWindow->Create ( instance ) )
81  {
82  delete mDebuggerWindow;
83  return false;
84  }
85 
86  // Initialize the network connection for the debugger
87  if ( !mClient.Initialize ( ) )
88  {
89  return false;
90  }
91 
92  mAccelerators = LoadAccelerators ( mInstance, MAKEINTRESOURCE(IDR_DBG_ACCELERATORS) );
93 
94  return true;
95 }
96 
97 /*
98 ================
99 rvDebuggerApp::ProcessWindowMessages
100 
101 Process windows messages
102 ================
103 */
105 {
106  MSG msg;
107 
108  while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ) )
109  {
110  if ( !GetMessage (&msg, NULL, 0, 0) )
111  {
112  return false;
113  }
114 
115  if ( !TranslateAccelerator ( &msg ) )
116  {
117  TranslateMessage(&msg);
118  DispatchMessage(&msg);
119  }
120  }
121 
122  return true;
123 }
124 
125 /*
126 ================
127 rvDebuggerApp::TranslateAccelerator
128 
129 Translate any accelerators destined for this window
130 ================
131 */
133 {
135  {
136  return true;
137  }
138 
139  return false;
140 }
141 
142 /*
143 ================
144 rvDebuggerApp::Run
145 
146 Main Loop for the debugger application
147 ================
148 */
149 int rvDebuggerApp::Run ( void )
150 {
151  // Main message loop:
152  while ( ProcessWindowMessages ( ) )
153  {
155 
156  Sleep ( 0 );
157  }
158 
159  mClient.Shutdown ( );
160  mOptions.Save ( );
161 
162  delete mDebuggerWindow;
163 
164  return 1;
165 }
166 
rvRegistryOptions mOptions
Definition: DebuggerApp.h:73
HWND GetWindow(void)
void Sleep(const int time)
bool TranslateAccelerator(LPMSG msg)
bool ProcessWindowMessages(void)
bool Create(HINSTANCE hInstance)
int Run(void)
#define NULL
Definition: Lib.h:88
bool ProcessMessages(void)
HINSTANCE mInstance
Definition: DebuggerApp.h:75
#define IDR_DBG_ACCELERATORS
bool Initialize(void)
rvDebuggerWindow * mDebuggerWindow
Definition: DebuggerApp.h:74
rvDebuggerClient mClient
Definition: DebuggerApp.h:76
bool Initialize(HINSTANCE hInstance)
Definition: DebuggerApp.cpp:68
HACCEL mAccelerators
Definition: DebuggerApp.h:77