forked from TheSuperHackers/GeneralsGameCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpherePropertySheet.cpp
More file actions
289 lines (248 loc) · 6.69 KB
/
SpherePropertySheet.cpp
File metadata and controls
289 lines (248 loc) · 6.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*
** Command & Conquer Renegade(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// SpherePropertySheet.cpp : implementation file
//
#include "StdAfx.h"
#include "W3DView.h"
#include "SpherePropertySheet.h"
#include "Utils.h"
#include "W3DViewDoc.h"
#include "assetmgr.h"
#include "DataTreeView.h"
#ifdef RTS_DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(SpherePropertySheetClass, CPropertySheet)
/////////////////////////////////////////////////////////////////////////////
//
// SpherePropertySheetClass
//
/////////////////////////////////////////////////////////////////////////////
SpherePropertySheetClass::SpherePropertySheetClass
(
SphereRenderObjClass * sphere,
UINT nIDCaption,
CWnd * pParentWnd,
UINT iSelectPage
)
: m_RenderObj (NULL),
CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
REF_PTR_SET (m_RenderObj, sphere);
Initialize ();
return ;
}
/////////////////////////////////////////////////////////////////////////////
//
// SpherePropertySheetClass
//
/////////////////////////////////////////////////////////////////////////////
SpherePropertySheetClass::SpherePropertySheetClass
(
SphereRenderObjClass * sphere,
LPCTSTR pszCaption,
CWnd * pParentWnd,
UINT iSelectPage
)
: m_RenderObj (NULL),
CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
REF_PTR_SET (m_RenderObj, sphere);
Initialize ();
return ;
}
/////////////////////////////////////////////////////////////////////////////
//
// ~SpherePropertySheetClass
//
/////////////////////////////////////////////////////////////////////////////
SpherePropertySheetClass::~SpherePropertySheetClass (void)
{
REF_PTR_RELEASE (m_RenderObj);
return ;
}
BEGIN_MESSAGE_MAP(SpherePropertySheetClass, CPropertySheet)
//{{AFX_MSG_MAP(SpherePropertySheetClass)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SpherePropertySheetClass
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//
// WindowProc
//
/////////////////////////////////////////////////////////////
LRESULT
SpherePropertySheetClass::WindowProc
(
UINT message,
WPARAM wParam,
LPARAM lParam
)
{
switch (message)
{
// Is a control sending us an oldstyle notification?
case WM_COMMAND:
{
// What control sent the notification?
switch (LOWORD (wParam))
{
case IDCANCEL:
{
::GetCurrentDocument ()->Reload_Displayed_Object ();
}
break;
/*case IDOK:
{
// If the apply button isn't enabled, then don't do the apply operation.
if (::IsWindowEnabled (::GetDlgItem (m_hWnd, ID_APPLY_NOW)) == FALSE) {
break;
}
}*/
case IDOK:
case ID_APPLY_NOW:
{
// Did the user click the button?
if (HIWORD (wParam) == BN_CLICKED) {
LRESULT lresult = CPropertySheet::WindowProc (message, wParam, lParam);
// If all the pages contain valid data, then update the emitter
if ( m_GeneralPage.Is_Data_Valid () &&
m_ColorPage.Is_Data_Valid () &&
m_ScalePage.Is_Data_Valid ())
{
// Update the current emitter to match the data
Update_Object ();
}
return lresult;
}
}
break;
}
break;
}
break;
}
// Allow the base class to process this message
return CPropertySheet::WindowProc (message, wParam, lParam);
}
/////////////////////////////////////////////////////////////
//
// Add_Object_To_Viewer
//
/////////////////////////////////////////////////////////////
void
SpherePropertySheetClass::Add_Object_To_Viewer (void)
{
CW3DViewDoc *doc = ::GetCurrentDocument ();
if ((doc != NULL) && (m_RenderObj != NULL)) {
//
// Create a new prototype for this object
//
SpherePrototypeClass *prototype = new SpherePrototypeClass (m_RenderObj);
//
// Update the asset manager with the new prototype
//
if (m_LastSavedName.GetLength () > 0) {
WW3DAssetManager::Get_Instance()->Remove_Prototype (m_LastSavedName);
}
WW3DAssetManager::Get_Instance()->Add_Prototype (prototype);
//
// Add this object to the data tree
//
CDataTreeView *data_tree = doc->GetDataTreeView ();
data_tree->Refresh_Asset (m_RenderObj->Get_Name (), m_LastSavedName, TypePrimitives);
//
// Display the object
//
doc->Reload_Displayed_Object ();
m_LastSavedName = m_RenderObj->Get_Name ();
REF_PTR_SET (m_RenderObj, (SphereRenderObjClass *)doc->GetDisplayedObject ());
//
// Pass the object along to the pages
//
m_GeneralPage.Set_Sphere (m_RenderObj);
m_ColorPage.Set_Sphere (m_RenderObj);
m_ScalePage.Set_Sphere (m_RenderObj);
}
return ;
}
/////////////////////////////////////////////////////////////
//
// Update_Object
//
/////////////////////////////////////////////////////////////
void
SpherePropertySheetClass::Update_Object (void)
{
Add_Object_To_Viewer ();
return ;
}
/////////////////////////////////////////////////////////////
//
// Initialize
//
/////////////////////////////////////////////////////////////
void
SpherePropertySheetClass::Initialize (void)
{
if (m_RenderObj == NULL) {
Create_New_Object ();
} else {
m_LastSavedName = m_RenderObj->Get_Name ();
}
//
// Pass the object along to the pages
//
m_GeneralPage.Set_Sphere (m_RenderObj);
m_ColorPage.Set_Sphere (m_RenderObj);
m_ScalePage.Set_Sphere (m_RenderObj);
//
// Add the pages to the sheet
//
AddPage (&m_GeneralPage);
AddPage (&m_ColorPage);
AddPage (&m_ScalePage);
//
// Force the pages to be created up front
//
m_GeneralPage.m_psp.dwFlags |= PSP_PREMATURE;
m_ColorPage.m_psp.dwFlags |= PSP_PREMATURE;
m_ScalePage.m_psp.dwFlags |= PSP_PREMATURE;
return ;
}
/////////////////////////////////////////////////////////////
//
// Create_New_Object
//
/////////////////////////////////////////////////////////////
void
SpherePropertySheetClass::Create_New_Object (void)
{
m_RenderObj = new SphereRenderObjClass;
m_RenderObj->Set_Name ("Sphere");
//
// Display the new object
//
::GetCurrentDocument ()->DisplayObject (m_RenderObj);
return ;
}