Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
genmtlnamesdialog.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/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : Max2W3D *
24 * *
25 * $Archive:: /Commando/Code/Tools/max2w3d/genmtlnamesdialog.cpp $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Greg_h $*
30 * *
31 * $Modtime:: 10/10/00 11:12a $*
32 * *
33 * $Revision:: 1 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * GenMtlNamesDialogClass::GenMtlNamesDialogClass -- Constructor *
38 * GenMtlNamesDialogClass::~GenMtlNamesDialogClass -- Destructor *
39 * GenMtlNamesDialogClass::Get_Options -- present the dialog, get user input *
40 * GenMtlNamesDialogClass::Ok_To_Exit -- verify that the input is valid *
41 * GenMtlNamesDialogClass::Dialog_Proc -- windows message handling *
42 * _gen_mtl_names_dialog_proc -- windows dialog proc for GenMtlNamesDialog *
43 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
44
45#include "genmtlnamesdialog.h"
46#include "dllmain.h"
47#include "resource.h"
48#include "w3d_file.h"
49#include <Max.h>
50
51static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam);
52
53
54/**********************************************************************************************
55**
56** GenMtlNamesDialogClass Implementation
57**
58**********************************************************************************************/
59
60
61/***********************************************************************************************
62 * GenMtlNamesDialogClass::GenMtlNamesDialogClass -- Constructor *
63 * *
64 * INPUT: *
65 * *
66 * OUTPUT: *
67 * *
68 * WARNINGS: *
69 * *
70 * HISTORY: *
71 *=============================================================================================*/
73 Hwnd(NULL),
74 Options(NULL),
75 MaxInterface(maxinterface),
76 NameIndexSpin(NULL)
77{
78}
79
80
81/***********************************************************************************************
82 * GenMtlNamesDialogClass::~GenMtlNamesDialogClass -- Destructor *
83 * *
84 * INPUT: *
85 * *
86 * OUTPUT: *
87 * *
88 * WARNINGS: *
89 * *
90 * HISTORY: *
91 * 10/10/2000 gth : Created. *
92 *=============================================================================================*/
94{
95 ReleaseISpinner(NameIndexSpin);
96}
97
98
99/***********************************************************************************************
100 * GenMtlNamesDialogClass::Get_Options -- present the dialog, get user input *
101 * *
102 * INPUT: *
103 * options - pointer to structure to hold the user's input *
104 * *
105 * OUTPUT: *
106 * true - user pressed ok and the input is valid *
107 * *
108 * WARNINGS: *
109 * *
110 * HISTORY: *
111 * 10/10/2000 gth : Created. *
112 *=============================================================================================*/
114{
115 Options = options;
116
117 // Put up the options dialog box.
118 BOOL result = DialogBoxParam
119 (
121 MAKEINTRESOURCE (IDD_GENERATE_MTL_NAMES_DIALOG),
122 MaxInterface->GetMAXHWnd(),
124 (LPARAM) this
125 );
126
127 if (result == TRUE) {
128 return true;
129 } else {
130 return false;
131 }
132}
133
134
135/***********************************************************************************************
136 * GenMtlNamesDialogClass::Ok_To_Exit -- verify that the input is valid *
137 * *
138 * INPUT: *
139 * *
140 * OUTPUT: *
141 * *
142 * WARNINGS: *
143 * *
144 * HISTORY: *
145 * 10/10/2000 gth : Created. *
146 *=============================================================================================*/
148{
149 // just check that the user entered a name
150 char buf[W3D_NAME_LEN];
151 GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf,sizeof(buf));
152
153 if (strlen(buf) == 0) {
154 MessageBox(Hwnd,"Please enter a root name to use.\n","Error",MB_OK);
155 return false;
156 } else {
157 return true;
158 }
159
160 return true;
161}
162
163
164/***********************************************************************************************
165 * GenMtlNamesDialogClass::Dialog_Proc -- windows message handling *
166 * *
167 * INPUT: *
168 * *
169 * OUTPUT: *
170 * *
171 * WARNINGS: *
172 * *
173 * HISTORY: *
174 * 10/10/2000 gth : Created. *
175 *=============================================================================================*/
176bool GenMtlNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM)
177{
178 switch (message ) {
179
180 case WM_INITDIALOG:
181
182 NameIndexSpin = SetupIntSpinner
183 (
184 Hwnd,
188 );
189
190 // limit the edit box characters
191 SendDlgItemMessage(Hwnd,IDC_BASE_NAME_EDIT,EM_LIMITTEXT,MAX_ROOT_NAME_LEN,0);
192
193 // set initial name to root of the filename
194 char buf[_MAX_FNAME];
195 _splitpath(MaxInterface->GetCurFileName(),NULL,NULL,buf,NULL);
196 buf[MAX_ROOT_NAME_LEN+1] = 0;
197 SetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf);
198
199 // init radio buttons
200 CheckDlgButton(Hwnd,IDC_AFFECT_ALL_RADIO,BST_UNCHECKED);
201 CheckDlgButton(Hwnd,IDC_AFFECT_SELECTED_RADIO,BST_CHECKED);
202
203 return 1;
204
205 case WM_COMMAND:
206
207 switch (LOWORD(wParam))
208 {
209 case IDOK:
210 if (Ok_To_Exit()) {
211 // general options
212 Options->OnlyAffectSelected = (IsDlgButtonChecked(Hwnd,IDC_AFFECT_SELECTED_RADIO) == BST_CHECKED);
213
214 // naming options
215 Options->NameIndex = NameIndexSpin->GetIVal();
216 GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),Options->RootName,sizeof(Options->RootName));
217
218 EndDialog(Hwnd, 1);
219 }
220 break;
221
222 case IDCANCEL:
223 EndDialog(Hwnd, 0);
224 break;
225
226 }
227 return 1;
228 }
229 return 0;
230}
231
232
233/***********************************************************************************************
234 * _gen_mtl_names_dialog_proc -- windows dialog proc for GenMtlNamesDialog *
235 * *
236 * INPUT: *
237 * *
238 * OUTPUT: *
239 * *
240 * WARNINGS: *
241 * *
242 * HISTORY: *
243 * 10/10/2000 gth : Created. *
244 *=============================================================================================*/
245static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
246{
247 static GenMtlNamesDialogClass * dialog = NULL;
248
249 if (message == WM_INITDIALOG) {
250 dialog = (GenMtlNamesDialogClass *)lparam;
251 dialog->Hwnd = hwnd;
252 }
253
254 if (dialog) {
255 return dialog->Dialog_Proc(hwnd, message, wparam, lparam);
256 } else {
257 return FALSE;
258 }
259}
260
#define NULL
Definition BaseType.h:92
#define TRUE
Definition BaseType.h:109
#define FALSE
Definition BaseType.h:113
#define W3D_NAME_LEN
Definition w3d_file.h:319
unsigned int UINT
Definition bittype.h:63
#define IDC_BASE_NAME_EDIT
Definition resource.h:288
#define IDC_AFFECT_ALL_RADIO
Definition resource.h:295
#define IDD_GENERATE_MTL_NAMES_DIALOG
Definition resource.h:90
#define IDC_AFFECT_SELECTED_RADIO
Definition resource.h:296
#define IDC_NAME_INDEX_SPIN
Definition resource.h:205
#define IDC_NAME_INDEX_EDIT
Definition resource.h:152
#define BOOL
Definition Wnd_File.h:57
bool Dialog_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM)
GenMtlNamesDialogClass(Interface *maxinterface)
bool Get_Options(OptionsStruct *options)
friend BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
HINSTANCE AppInstance
Definition dllmain.cpp:67