Debian Codegraph @

editor/ScriptParmDialog.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
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 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/ScriptParmDialog.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:39 $
23 * $Author: kevinb $
24 *
25 * Script parameter dialog
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 6 10/08/98 4:24p Kevin
30 * Changed code to comply with memory library usage. Always use mem_malloc
31 * , mem_free and mem_strdup
32 *
33 * 5 2/11/98 12:21p Samir
34 * Fixed bug when pasting object ids.
35 *
36 * $NoKeywords: $
37 */
38
39 // ScriptParmDialog.cpp : implementation file
40 //
41
42 #include "stdafx.h"
43 #include "editor.h"
44 #include "ScriptParmDialog.h"
45 #include "ObjectListDialog.h"
46 #include "mem.h"
47
48 #include "d3x.h"
49 #include "pserror.h"
50
51 #ifdef _DEBUG
52 #define new DEBUG_NEW
53 #undef THIS_FILE
54 static char THIS_FILE[] = __FILE__;
55 #endif
56
57 #define POPUP_PASTEID 0x60
58
59 /////////////////////////////////////////////////////////////////////////////
60 // CScriptParmDialog dialog
61
62 CScriptParmDialog::CScriptParmDialog(CWnd *pParent /*=NULL*/) : CDialog(CScriptParmDialog::IDD, pParent) {
63 //{{AFX_DATA_INIT(CScriptParmDialog)
64 m_Parm1 = _T("");
65 m_Parm2 = _T("");
66 m_Parm3 = _T("");
67 m_Parm4 = _T("");
68 m_Parm5 = _T("");
69 m_Parm6 = _T("");
70 m_Parm7 = _T("");
71 m_Parm8 = _T("");
72 m_ParmEdit1 = _T("");
73 m_ParmEdit2 = _T("");
74 m_ParmEdit3 = _T("");
75 m_ParmEdit4 = _T("");
76 m_ParmEdit5 = _T("");
77 m_ParmEdit6 = _T("");
78 m_ParmEdit7 = _T("");
79 m_ParmEdit8 = _T("");
80 //}}AFX_DATA_INIT
81 }
82
83 void CScriptParmDialog::DoDataExchange(CDataExchange *pDX) {
84 CDialog::DoDataExchange(pDX);
85 //{{AFX_DATA_MAP(CScriptParmDialog)
86 DDX_Text(pDX, IDC_PARM1, m_Parm1);
87 DDX_Text(pDX, IDC_PARM2, m_Parm2);
88 DDX_Text(pDX, IDC_PARM3, m_Parm3);
89 DDX_Text(pDX, IDC_PARM4, m_Parm4);
90 DDX_Text(pDX, IDC_PARM5, m_Parm5);
91 DDX_Text(pDX, IDC_PARM6, m_Parm6);
92 DDX_Text(pDX, IDC_PARM7, m_Parm7);
93 DDX_Text(pDX, IDC_PARM8, m_Parm8);
94 DDX_Text(pDX, IDC_PARMEDIT1, m_ParmEdit1);
95 DDX_Text(pDX, IDC_PARMEDIT2, m_ParmEdit2);
96 DDX_Text(pDX, IDC_PARMEDIT3, m_ParmEdit3);
97 DDX_Text(pDX, IDC_PARMEDIT4, m_ParmEdit4);
98 DDX_Text(pDX, IDC_PARMEDIT5, m_ParmEdit5);
99 DDX_Text(pDX, IDC_PARMEDIT6, m_ParmEdit6);
100 DDX_Text(pDX, IDC_PARMEDIT7, m_ParmEdit7);
101 DDX_Text(pDX, IDC_PARMEDIT8, m_ParmEdit8);
102 //}}AFX_DATA_MAP
103 }
104
105 void CScriptParmDialog::ConvertToScriptParameter(tScriptParm *parm, const char *type, const char *text) {
106 #if 0 // LGT: ->type and ZERO_SCRIPT_PARM undefined
107 ZERO_SCRIPT_PARM(parm);
108
109 if (!type || !text)
110 return;
111
112 if (strcmp(type, "vector") == 0) {
113 parm->type = PARMTYPE_VECTOR;
114 Int3(); // not yet implemented - samir
115 }
116 else if (strcmp(type, "number") == 0) {
117 parm->type = PARMTYPE_NUMBER;
118 sscanf(text, "%f", &parm->val.x);
119 }
120 else {
121 int num;
122 char *str;
123 parm->type = PARMTYPE_REF;
124 str = _strlwr(mem_strdup(text));
125 if (strstr(str, "0x"))
126 sscanf(str+2, "%x",&num);
127 else
128 sscanf(str, "%d",&num);
129 *((int *)&parm->val.x) = num;
130 }
131 #endif
132 }
133
134 void CScriptParmDialog::ConvertParamToText(CString &text, tScriptParm *parm) {
135 #if 0 // LGT: ->type undefined
136 if (parm->type == PARMTYPE_VECTOR) {
137 Int3(); // get samir.
138 }
139 else if (parm->type == PARMTYPE_NUMBER) {
140 text.Format("%f",parm->val.x);
141 }
142 else {
143 text.Format("0x%x",*((int *)&parm->val.x));
144 }
145 #endif
146 }
147
148 BEGIN_MESSAGE_MAP(CScriptParmDialog, CDialog)
149 //{{AFX_MSG_MAP(CScriptParmDialog)
150 ON_BN_CLICKED(IDC_PARAMLIST, OnParamlist)
151 ON_BN_CLICKED(IDC_PARAMLIST2, OnParamlist2)
152 ON_BN_CLICKED(IDC_PARAMLIST3, OnParamlist3)
153 ON_BN_CLICKED(IDC_PARAMLIST4, OnParamlist4)
154 ON_BN_CLICKED(IDC_PARAMLIST5, OnParamlist5)
155 ON_BN_CLICKED(IDC_PARAMLIST6, OnParamlist6)
156 ON_BN_CLICKED(IDC_PARAMLIST7, OnParamlist7)
157 ON_BN_CLICKED(IDC_PARAMLIST8, OnParamlist8)
158 //}}AFX_MSG_MAP
159 END_MESSAGE_MAP()
160
161 /////////////////////////////////////////////////////////////////////////////
162 // CScriptParmDialog message handlers
163
164 BOOL CScriptParmDialog::OnInitDialog() {
165 CDialog::OnInitDialog();
166
167 if (!m_Parm1.IsEmpty()) {
168 GetDlgItem(IDC_PARMEDIT1)->EnableWindow(TRUE);
169 GetDlgItem(IDC_PARAMLIST)->EnableWindow(TRUE);
170 }
171 if (!m_Parm2.IsEmpty()) {
172 GetDlgItem(IDC_PARMEDIT2)->EnableWindow(TRUE);
173 GetDlgItem(IDC_PARAMLIST2)->EnableWindow(TRUE);
174 }
175 if (!m_Parm3.IsEmpty()) {
176 GetDlgItem(IDC_PARMEDIT3)->EnableWindow(TRUE);
177 GetDlgItem(IDC_PARAMLIST3)->EnableWindow(TRUE);
178 }
179 if (!m_Parm4.IsEmpty()) {
180 GetDlgItem(IDC_PARMEDIT4)->EnableWindow(TRUE);
181 GetDlgItem(IDC_PARAMLIST4)->EnableWindow(TRUE);
182 }
183 if (!m_Parm5.IsEmpty()) {
184 GetDlgItem(IDC_PARMEDIT5)->EnableWindow(TRUE);
185 GetDlgItem(IDC_PARAMLIST5)->EnableWindow(TRUE);
186 }
187 if (!m_Parm6.IsEmpty()) {
188 GetDlgItem(IDC_PARMEDIT6)->EnableWindow(TRUE);
189 GetDlgItem(IDC_PARAMLIST6)->EnableWindow(TRUE);
190 }
191 if (!m_Parm7.IsEmpty()) {
192 GetDlgItem(IDC_PARMEDIT7)->EnableWindow(TRUE);
193 GetDlgItem(IDC_PARAMLIST7)->EnableWindow(TRUE);
194 }
195 if (!m_Parm8.IsEmpty()) {
196 GetDlgItem(IDC_PARMEDIT8)->EnableWindow(TRUE);
197 GetDlgItem(IDC_PARAMLIST8)->EnableWindow(TRUE);
198 }
199
200 return TRUE; // return TRUE unless you set the focus to a control
201 // EXCEPTION: OCX Property Pages should return FALSE
202 }
203
204 //@@void CScriptParmDialog::OnContextMenu(CWnd* pWnd, CPoint point)
205 //@@{
206 //@@ CMenu popup;
207 //@@
208 //@@ if(popup.CreatePopupMenu()) {
209 //@@ popup.AppendMenu(MF_STRING,POPUP_PASTEID,"Paste UID");
210 //@@
211 //@@ if (Copied_object_id == 0)
212 //@@ popup.EnableMenuItem(POPUP_PASTEID,MF_GRAYED);
213 //@@
214 //@@ m_ContextWnd = pWnd;
215 //@@ if(!popup.TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this,NULL)) {
216 //@@ mprintf(0,"TrackPopupMenu error!\n");
217 //@@ }
218 //@@ }
219 //@@ else {
220 //@@ mprintf(1, "Failed to create shortcut menu!\n");
221 //@@ }
222 //@@}
223
224 BOOL CScriptParmDialog::OnCommand(WPARAM wParam, LPARAM lParam) {
225 //@@ if(HIWORD(wParam)==0) {
226 //@@ switch (LOWORD(wParam))
227 //@@ {
228 //@@ case POPUP_PASTEID:
229 //@@ {
230 //@@ char str[32];
231 //@@ sprintf(str, "%x", Copied_object_id);
232 //@@ m_ContextWnd->SetWindowText(str);
233 //@@ }
234 //@@ }
235 //@@ }
236 //@@
237 return CDialog::OnCommand(wParam, lParam);
238 }
239
240 void CScriptParmDialog::OnParamlist() {
241 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT1);
242 char buf[32];
243 sprintf(buf, "0x%x", Copied_object_id);
244 edit->SetWindowText(buf);
245 }
246
247 void CScriptParmDialog::OnParamlist2() {
248 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT2);
249 char buf[32];
250 sprintf(buf, "0x%x", Copied_object_id);
251 edit->SetWindowText(buf);
252 }
253
254 void CScriptParmDialog::OnParamlist3() {
255 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT3);
256 char buf[32];
257 sprintf(buf, "0x%x", Copied_object_id);
258 edit->SetWindowText(buf);
259 }
260
261 void CScriptParmDialog::OnParamlist4() {
262 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT4);
263 char buf[32];
264 sprintf(buf, "0x%x", Copied_object_id);
265 edit->SetWindowText(buf);
266 }
267
268 void CScriptParmDialog::OnParamlist5() {
269 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT5);
270 char buf[32];
271 sprintf(buf, "0x%x", Copied_object_id);
272 edit->SetWindowText(buf);
273 }
274
275 void CScriptParmDialog::OnParamlist6() {
276 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT6);
277 char buf[32];
278 sprintf(buf, "0x%x", Copied_object_id);
279 edit->SetWindowText(buf);
280 }
281
282 void CScriptParmDialog::OnParamlist7() {
283 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT7);
284 char buf[32];
285 sprintf(buf, "0x%x", Copied_object_id);
286 edit->SetWindowText(buf);
287 }
288
289 void CScriptParmDialog::OnParamlist8() {
290 CEdit *edit = (CEdit *)GetDlgItem(IDC_PARMEDIT8);
291 char buf[32];
292 sprintf(buf, "0x%x", Copied_object_id);
293 edit->SetWindowText(buf);
294 }