Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
vxldbg.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/vxldbg.cpp 3 10/28/97 6:08p Greg_h $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando / G 3D Engine *
25 * *
26 * $Archive:: /Commando/Code/Tools/max2w3d/vxldbg.cpp $*
27 * *
28 * $Author:: Greg_h $*
29 * *
30 * $Modtime:: 10/14/97 3:07p $*
31 * *
32 * $Revision:: 3 $*
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38
39#include "vxldbg.h"
40#include "resource.h"
41#include "dllmain.h"
42
43/*
44** Static functions
45*/
46static BOOL CALLBACK _dialog_proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
47
48static PaletteClass _VoxelPalette;
49
51 CurLayer(0),
52 Bitmap(NULL),
53 Voxel(vxl),
54 WindowHWND(0),
55 ViewportHWND(0),
56 LayerSpin(NULL)
57{
58 _VoxelPalette[0] = RGBClass(0,0,0);
59 _VoxelPalette[1] = RGBClass(128,255,128);
60}
61
63{
64 ReleaseISpinner(LayerSpin);
65}
66
68{
69 DialogBoxParam
70 (
72 MAKEINTRESOURCE (IDD_VOXEL_DEBUG_DIALOG),
73 NULL,
74 (DLGPROC) _dialog_proc,
75 (LPARAM) this
76 );
77}
78
79
81(
82 HWND hWnd,
83 UINT message,
84 WPARAM wParam,
85 LPARAM
86)
87{
88 RECT crect;
89
90 switch (message ) {
91
92 /*******************************************************************
93 * WM_INITDIALOG
94 *
95 * Initialize all of the custom controls for the dialog box
96 *
97 *******************************************************************/
98 case WM_INITDIALOG:
99
100 // keep a handle to the window
101 WindowHWND = hWnd;
102
103 // keep a handle to the control that I'm using for the voxel viewport.
104 ViewportHWND = GetDlgItem(WindowHWND,IDC_VOXEL_VIEWPORT);
105
106 // create a DIB that will be drawn on top of the VOXEL_VIEWPORT control.
107 GetClientRect(ViewportHWND,&crect);
108 Bitmap = new SimpleDIBClass(ViewportHWND,Voxel->Get_Width(),Voxel->Get_Height(),_VoxelPalette);
109
110 // initialize the layer spinner
111 LayerSpin = SetupIntSpinner
112 (
113 hWnd,
116 0,
117 Voxel->Num_Layers(),
118 0
119 );
120
121 update_display();
122
123 SetCursor(LoadCursor (NULL, IDC_ARROW));
124
125 return 1;
126
127
128 /*******************************************************************
129 * WM_COMMAND
130 *
131 *
132 *******************************************************************/
133 case WM_COMMAND:
134
135 switch (LOWORD(wParam))
136 {
137 case IDOK:
138
139 // done!
140 SetCursor(LoadCursor (NULL, IDC_WAIT));
141 EndDialog(hWnd, 1);
142 break;
143 }
144 return 1;
145
146 /*******************************************************************
147 * CC_SPINNER_CHANGE
148 *
149 * Max custom spinner controls
150 *
151 *******************************************************************/
152 case CC_SPINNER_CHANGE:
153
154 switch (LOWORD(wParam) )
155 {
156 case IDC_LAYER_SPIN:
157
158 CurLayer = LayerSpin->GetIVal();
159 update_display();
160 break;
161 }
162
163
164 /*******************************************************************
165 * WM_PAINT
166 *
167 *
168 *******************************************************************/
169 case WM_PAINT:
170
171 update_display();
172
173 GetClientRect(ViewportHWND,&crect);
174 ValidateRect(ViewportHWND,&crect);
175
176 break;
177
178 }
179 return 0;
180}
181
182
183void VoxelDebugWindowClass::update_display(void)
184{
185 int i,j;
186
187 /*
188 ** Bail out if everything isn't right
189 */
190 if ((Bitmap == NULL) || (Voxel == NULL)) {
191 return;
192 }
193
194 /*
195 ** Update the contents of the DIB based on
196 ** the contents of the current voxel layer.
197 */
198
199 Bitmap->Clear(0);
200
201 for (j=0; j < Voxel->Get_Height(); j++) {
202 for (i=0; i < Voxel->Get_Width(); i++) {
203 if (Voxel->Is_Solid(i,j,CurLayer)) {
204 Bitmap->Set_Pixel(i,j,1);
205 }
206 }
207 }
208
209 /*
210 ** Blit the DIB onto the dialog box.
211 */
212 HDC hdcwindow = GetDC(ViewportHWND);
213 HDC hdcdib = CreateCompatibleDC(hdcwindow);
214 HBITMAP holdbitmap = (HBITMAP)SelectObject(hdcdib, Bitmap->Get_Handle());
215 RECT crect;
216
217 GetClientRect(ViewportHWND,&crect);
218 int cx = (crect.right - crect.left) / 2;
219 int cy = (crect.bottom - crect.top) / 2;
220 int x0 = 0; //cx - Bitmap->Get_Width();
221 int y0 = 0; //cy - Bitmap->Get_Height();
222 int x1 = 2 * Bitmap->Get_Width(); //cx + Bitmap->Get_Width();
223 int y1 = 2 * Bitmap->Get_Height(); //cy + Bitmap->Get_Height();
224
225// BitBlt(hdcwindow,0,0,Bitmap->Get_Width(),Bitmap->Get_Height(),hdcdib,0,0,SRCCOPY);
226 StretchBlt( hdcwindow, x0, y0, x1, y1,
227 hdcdib, 0, 0, Bitmap->Get_Width(), Bitmap->Get_Height(), SRCCOPY);
228
229 SelectObject(hdcdib, holdbitmap);
230
231 ReleaseDC(WindowHWND, hdcwindow);
232 DeleteDC(hdcdib);
233}
234
235
236BOOL CALLBACK _dialog_proc
237(
238 HWND hWnd,
239 UINT message,
240 WPARAM wParam,
241 LPARAM lParam
242)
243{
244 static VoxelDebugWindowClass * window = NULL;
245
246 if (message == WM_INITDIALOG) {
247 window = (VoxelDebugWindowClass *) lParam;
248 }
249
250 if (window) {
251 return window->Dialog_Proc(hWnd, message, wParam, lParam);
252 } else {
253 return FALSE;
254 }
255}
256
#define NULL
Definition BaseType.h:92
#define FALSE
Definition BaseType.h:113
unsigned int UINT
Definition bittype.h:63
#define IDC_VOXEL_VIEWPORT
Definition resource.h:125
#define IDC_LAYER_SPIN
Definition resource.h:199
#define IDC_LAYER_EDIT
Definition resource.h:148
#define IDD_VOXEL_DEBUG_DIALOG
Definition resource.h:67
#define BOOL
Definition Wnd_File.h:57
Definition RGB.H:53
~VoxelDebugWindowClass(void)
Definition vxldbg.cpp:62
bool Dialog_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM)
Definition vxldbg.cpp:81
void Display_Window(void)
Definition vxldbg.cpp:67
VoxelDebugWindowClass(VoxelClass *vxl)
Definition vxldbg.cpp:50
HINSTANCE AppInstance
Definition dllmain.cpp:67