Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
logdlg.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program 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**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/* $Header: /Commando/Code/Tools/max2w3d/logdlg.cpp 5 11/07/00 5:40p Greg_h $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando Tools - W3D export *
25 * *
26 * $Archive:: /Commando/Code/Tools/max2w3d/logdlg.cpp $*
27 * *
28 * $Author:: Greg_h $*
29 * *
30 * $Modtime:: 11/07/00 4:24p $*
31 * *
32 * $Revision:: 5 $*
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38#include "logdlg.h"
39#include "resource.h"
40#include "dllmain.h"
41#include "w3dexp.h"
42#include "util.h"
43#include "rawfile.h"
44#include "units.h"
45
46
47/*
48** Static functions
49*/
50static BOOL CALLBACK _logdata_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam);
51static DWORD WINAPI _logdata_thread_function(LPVOID log_obj_ptr);
52
53
54/***********************************************************************************************
55 * LogDataDialogClass::LogDataDialogClass -- constructor for the options dialog object *
56 * *
57 * INPUT: *
58 * *
59 * OUTPUT: *
60 * *
61 * WARNINGS: *
62 * *
63 * HISTORY: *
64 * 02/09/2000 JGA : Created. *
65 *=============================================================================================*/
67 Hwnd(NULL),
68 ParentHwnd(parent),
69 buffer_index(0),
70 last_buffer_index(0),
71 status(0)
72{
73 ThreadHandle = CreateThread(NULL, 0, _logdata_thread_function, (LPVOID)this, 0, &ThreadID);
74
75 if (ThreadHandle) {
76 while (status == 0) {
77 // sync, wait for init
78 }
79 }
80}
81
83{
84 status = 3;
85 if (::IsWindow(Hwnd)) {
86 SendMessage( Hwnd, WM_CLOSE, 0, 0 );
87 }
88}
89
90
91/***********************************************************************************************
92 * LogDataDialogClass::printf -- handles doing printfs into the current log window *
93 * *
94 * INPUT: *
95 * *
96 * OUTPUT: *
97 * *
98 * WARNINGS: *
99 * *
100 * HISTORY: *
101 * 02/11/2000 JGA : Created. *
102 *=============================================================================================*/
103void LogDataDialogClass::printf(char *text, ...)
104{
105 va_list arguments;
106 va_start(arguments, text);
107} // printf
108
109void LogDataDialogClass::printf(char * text, const va_list & args)
110{
111 static char string_buffer[256];
112
113 vsprintf(string_buffer, text, args);
114
115 HWND ctrlHwnd = GetDlgItem(Hwnd, IDC_ANIM_LOG_RICHEDIT);
116
117 SendMessage(ctrlHwnd, EM_SETSEL, -1, -1 );
118 SendMessage(ctrlHwnd, EM_REPLACESEL, FALSE, (long)string_buffer);
119
120 last_buffer_index = buffer_index;
121 buffer_index+=strlen(string_buffer);
122
123 //int min,max,pos;
124 //GetScrollRange(ctrlHwnd, SB_VERT, &min, &max);
125 //pos = GetScrollPos(ctrlHwnd, SB_VERT);
126
127 //if (pos == max) {
128 SendMessage(GetDlgItem(Hwnd,IDC_ANIM_LOG_RICHEDIT), EM_SCROLLCARET, 0, 0);
129 //}
130
131
132}
133
134/***********************************************************************************************
135 * LogDataDialogClass::rprintf -- replace last printf, with this new printf *
136 * *
137 * INPUT: *
138 * *
139 * OUTPUT: *
140 * *
141 * WARNINGS: *
142 * *
143 * HISTORY: *
144 * 02/14/2000 JGA : Created. *
145 *=============================================================================================*/
146void LogDataDialogClass::rprintf(char *text, ...)
147{
148 va_list arguments;
149 va_start(arguments, text);
150
151 rprintf(text,arguments);
152}
153
154void LogDataDialogClass::rprintf(char *text, const va_list & args)
155{
156 static char string_buffer[256];
157 vsprintf(string_buffer, text, args);
158
159 HWND ctrlHwnd = GetDlgItem(Hwnd, IDC_ANIM_LOG_RICHEDIT);
160
161 SendMessage(ctrlHwnd, EM_SETSEL, last_buffer_index, buffer_index );
162 SendMessage(ctrlHwnd, EM_REPLACESEL, FALSE, (long)string_buffer);
163
164 buffer_index = strlen(string_buffer) + last_buffer_index;
165
166 //int min,max,pos;
167 //GetScrollRange(ctrlHwnd, SB_VERT, &min, &max);
168 //pos = GetScrollPos(ctrlHwnd, SB_VERT);
169
170 //SendMessage(GetDlgItem(Hwnd,IDC_ANIM_LOG_RICHEDIT), EM_SCROLLCARET, 0, 0);
171
172} // rprintf
173
174
175/***********************************************************************************************
176 * LogDataDialogClass::updatebar - send message to progress meter *
177 * *
178 * INPUT: *
179 * *
180 * OUTPUT: *
181 * *
182 * WARNINGS: *
183 * *
184 * HISTORY: *
185 * 02/14/2000 JGA : Created. *
186 *=============================================================================================*/
187void LogDataDialogClass::updatebar(float position, float total)
188{
189 int pos;
190
191 pos = ((position / total) * 100.0f);
192
193 HWND ctrlHwnd = GetDlgItem(Hwnd, IDC_ANIM_COMPRESS_PROGRESS);
194
195 SendMessage(ctrlHwnd, PBM_SETPOS, pos, 0 );
196
197} // updatebar
198
199
200/***********************************************************************************************
201 * LogDataDialogClass::Wait_OK - Give user a chance to review log, then hit ok *
202 * *
203 * INPUT: *
204 * *
205 * OUTPUT: *
206 * *
207 * WARNINGS: *
208 * *
209 * HISTORY: *
210 * 02/14/2000 JGA : Created. *
211 *=============================================================================================*/
213{
214 ::EnableWindow(GetDlgItem(Hwnd,IDOK),TRUE);
215 ::SetForegroundWindow(Hwnd);
216
217 while (status < 2) {
218 // wait for the OK
219 }
220
221} // Wait_OK
222
223
224
225/***********************************************************************************************
226 * LogDataDialogClass::Dialog_Proc -- Handles the windows message for the options dialog *
227 * *
228 * INPUT: *
229 * *
230 * OUTPUT: *
231 * *
232 * WARNINGS: *
233 * *
234 * HISTORY: *
235 * 07/24/1997 GH : Created. *
236 *=============================================================================================*/
238(
239 HWND hwnd,
240 UINT message,
241 WPARAM wParam,
242 LPARAM
243)
244{
245 int code = HIWORD(wParam);
246
247 switch (message ) {
248
249 /*******************************************************************
250 * WM_INITDIALOG
251 *
252 * Initialize all of the custom controls for the dialog box
253 *
254 *******************************************************************/
255 case WM_INITDIALOG:
256
257 Dialog_Init();
258 return TRUE;
259
260
261 /*******************************************************************
262 * WM_COMMAND
263 *
264 *
265 *******************************************************************/
266 case WM_COMMAND:
267
268 switch (LOWORD(wParam))
269 {
270 case IDOK:
271
272 status = 2;
273
274 EndDialog(Hwnd, 1);
275 Hwnd = NULL;
276 return TRUE;
277 break;
278
279 }
280 break;
281
282 //case WM_VSCROLL:
283 // return TRUE;
284 // break;
285
286 case WM_CLOSE:
287
288 if (status >= 2) {
289 EndDialog(Hwnd, 1);
290 Hwnd = NULL;
291 }
292
293 return TRUE;
294 break;
295
296 }
297 return FALSE;
298
299} // Dialog_Proc
300
301void LogDataDialogClass::Dialog_Init()
302{
303
304 SetCursor(LoadCursor (NULL, IDC_ARROW));
305
306 RECT desktop;
307 RECT ourwin;
308
309 GetWindowRect(GetDesktopWindow(), &desktop);
310 GetWindowRect(Hwnd, &ourwin);
311
312 int sx,sy,cx,cy;
313
314 sx = ourwin.right - ourwin.left;
315 sy = ourwin.bottom - ourwin.top;
316
317 cx = (((desktop.right - desktop.left) - sx)/2) + desktop.left;
318 cy = (((desktop.bottom - desktop.top) - sy)/2) + desktop.top;
319
320 //SetWindowPos(Hwnd, HWND_TOPMOST, cx, cy, 0, 0, SWP_NOSIZE);
321 SetWindowPos(Hwnd, HWND_TOP, cx, cy, 0, 0, SWP_NOSIZE);
322
323 EnableWindow(GetDlgItem(Hwnd,IDOK),FALSE);
324
325 status = 1; // signal init
326
327
328} // Dialog_Init
329
330
331
332/***********************************************************************************************
333 * _logdata_dialog_proc -- thunks into the logdata dialog class's windows message handler *
334 * *
335 * INPUT: *
336 * *
337 * OUTPUT: *
338 * *
339 * WARNINGS: *
340 * *
341 * HISTORY: *
342 * 02/09/2000 JGA : Created. *
343 *=============================================================================================*/
344BOOL CALLBACK _logdata_dialog_proc
345(
346 HWND hwnd,
347 UINT message,
348 WPARAM wParam,
349 LPARAM lParam
350)
351{
352 if (message == WM_INITDIALOG) {
353 LogDataDialogClass * log = (LogDataDialogClass *)lParam;
354 log->Hwnd = hwnd;
355 ::SetProp(hwnd,"LogDataDialogClass",(HANDLE)log);
356 }
357
358 LogDataDialogClass * log = (LogDataDialogClass *)::GetProp(hwnd,"LogDataDialogClass");
359
360 if (message == WM_DESTROY) {
361 ::RemoveProp(hwnd,"LogDataDialogClass");
362 }
363
364 if (log) {
365 return log->Dialog_Proc(hwnd,message,wParam,lParam);
366 } else {
367 return FALSE;
368 }
369
370} // _logdata_dialog_proc
371
372
373DWORD WINAPI _logdata_thread_function(LPVOID log_obj_ptr)
374{
375 // put logdata dialog box (lpParameter is the "this" pointer of the object)
376 DialogBoxParam( AppInstance,
377 MAKEINTRESOURCE(IDD_W3D_LOG),
378 ((LogDataDialogClass*)log_obj_ptr)->ParentHwnd,
379 (DLGPROC) _logdata_dialog_proc,
380 (LPARAM) log_obj_ptr);
381
382
383 // When this exits it should terminate the thread
384 return(0);
385}
386
387
388// EOF - logdlg.cpp
#define NULL
Definition BaseType.h:92
#define TRUE
Definition BaseType.h:109
#define FALSE
Definition BaseType.h:113
unsigned int UINT
Definition bittype.h:63
unsigned long DWORD
Definition bittype.h:57
LPVOID(__stdcall *SnmpUtilMemAllocPtr)(IN DWORD bytes)
#define IDC_ANIM_LOG_RICHEDIT
Definition resource.h:363
#define IDD_W3D_LOG
Definition resource.h:97
#define IDC_ANIM_COMPRESS_PROGRESS
Definition resource.h:362
#define BOOL
Definition Wnd_File.h:57
void rprintf(char *,...)
Definition logdlg.cpp:146
bool Dialog_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM)
Definition logdlg.cpp:238
void updatebar(float position, float total)
Definition logdlg.cpp:187
LogDataDialogClass(HWND parent)
Definition logdlg.cpp:66
void printf(char *,...)
Definition logdlg.cpp:103
HINSTANCE AppInstance
Definition dllmain.cpp:67