-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMissileDlg.cpp
293 lines (256 loc) · 7.81 KB
/
MissileDlg.cpp
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
289
290
291
292
293
// MissileDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ICE.h"
#include "corestruct.h"
#include "MissileDlg.h"
#include ".\missiledlg.h"
// CMissileDlg dialog
IMPLEMENT_DYNAMIC(CMissileDlg, CDialog)
CMissileDlg::CMissileDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMissileDlg::IDD, pParent)
{
pmissile = NULL;
}
CMissileDlg::~CMissileDlg()
{
}
void CMissileDlg::DoDataExchange(CDataExchange* pDX)
{
CString name,model,ldbmp,type,icon,descr;
CString todo1 = "";
int ss1,ss3,ss4,useflags;
int uid;
if (!pmissile) return;
ASSERT(sArtPath != "");
CComboBox *cbse = (CComboBox *)CWnd::GetDlgItem(IDC_SEFFECT);
PtrCorePart prox = pcore->ProxyGet(pmissile->uid);
int uidprox = prox->uid;
if (!pDX->m_bSaveAndValidate) // data to dialog
{
name = pmissile->name;
model = pmissile->model;
icon = pmissile->icon;
mdlbmp.LoadMDLFile(sArtPath +"\\"+ icon + "bmp.mdl");
ldbmp = pmissile->ldbmp;
mdlbmp2.LoadMDLFile(sArtPath +"\\l"+ ldbmp + "bmp.mdl");
descr = pmissile->description;
type = pmissile->type;
uid = pmissile->uid;
cbse->SetCurSel(pmissile->special_effect);
useflags = pmissile->use_flags;
for (int i=0;i<16;i++)
{
CButton *cbb = (CButton *)CWnd::GetDlgItem(IDC_USEM0+i);
cbb->SetCheck((useflags & (1<<i))?BST_CHECKED:BST_UNCHECKED);
cbb->EnableWindow(TRUE);
}
OnBnClickedUsem0();
ss1 = pmissile->stats_ss1;
CComboBox *cbdm = (CComboBox *)GetDlgItem(IDC_DM);
cbdm->SetCurSel(pmissile->DM);
CComboBox *cbac = (CComboBox *)GetDlgItem(IDC_AC);
cbac->SetCurSel(pmissile->AC);
ss3 = pmissile->stats_ss3;
ss4 = pmissile->stats_ss4;
}
DDX_Text(pDX, IDC_NAME, name);
DDX_Text(pDX, IDC_MODEL, model);
DDX_Text(pDX, IDC_UKBMP, ldbmp);
DDX_Text(pDX, IDC_ICONE, icon);
DDX_Text(pDX, IDC_TYPE, type);
DDX_Text(pDX, IDC_DESCRIPTION, descr);
// DDX_Text(pDX, IDC_TODO1, todo1);
DDX_Text(pDX, IDC_SS1, ss1);
DDX_Text(pDX, IDC_SS3, ss3);
DDX_Text(pDX, IDC_SS4, ss4);
DDX_Text(pDX, IDC_USEFLAGS, useflags);
DDX_Text(pDX, IDC_S1, pmissile->stats_s1);
DDX_Text(pDX, IDC_S2, pmissile->stats_s2);
DDX_Text(pDX, IDC_S3, pmissile->stats_s3);
DDX_Text(pDX, IDC_S4, pmissile->stats_s4);
DDX_Text(pDX, IDC_S5, pmissile->stats_s5);
DDX_Text(pDX, IDC_S6, pmissile->stats_s6);
DDX_Text(pDX, IDC_S7, pmissile->stats_s7);
DDX_Text(pDX, IDC_S8, pmissile->stats_s8);
DDX_Text(pDX, IDC_S9, pmissile->stats_s9);
DDX_Text(pDX, IDC_S10, pmissile->stats_s10);
DDX_Text(pDX, IDC_S11, pmissile->stats_s11);
DDX_Text(pDX, IDC_S12, pmissile->stats_s12);
DDX_Text(pDX, IDC_S13, pmissile->stats_s13);
DDX_Text(pDX, IDC_S14, pmissile->stats_s14);
DDX_Text(pDX, IDC_S15, pmissile->stats_s15);
DDX_Text(pDX, IDC_S16, pmissile->stats_s16);
DDX_Text(pDX, IDC_DAMAGE, pmissile->stats_damage);
DDX_Text(pDX, IDC_DAMAGE_RADIUS, pmissile->stats_damage_radius);
DDX_Text(pDX, IDC_SIG, pmissile->stats_sig);
DDX_Text(pDX, IDC_COST, pmissile->cost);
DDX_Text(pDX, IDC_UID, uid);
DDX_Text(pDX, IDC_UIDPROX, uidprox);
DDX_Text(pDX, IDC_OVUIDPROX, prox->overriding_uid);
DDX_Text(pDX, IDC_LAUNCHCOUNT, prox->type);
DDX_Text(pDX, IDC_AMOUNT,prox->suk2);
if (pDX->m_bSaveAndValidate) // dialog to data
{
strcpy(pmissile->name,name);
strcpy(pmissile->model,model);
strcpy(pmissile->ldbmp,ldbmp);
strcpy(pmissile->type,type);
strncpy(pmissile->description,descr,IGC_DESCRIPTIONMAX);
pmissile->special_effect = cbse->GetCurSel();
CComboBox *cbdm = (CComboBox *)GetDlgItem(IDC_DM);
pmissile->DM = cbdm->GetCurSel();
CComboBox *cbac = (CComboBox *)GetDlgItem(IDC_AC);
pmissile->AC = cbac->GetCurSel();
//pmissile->use_flags = useflags;
pmissile->use_flags = 0;
for (int i=0;i<16;i++)
{
CButton *cbb = (CButton *)CWnd::GetDlgItem(IDC_USEM0+i);
pmissile->use_flags += cbb->GetCheck()?(1<<i):0;
}
if (pmissile->use_flags == 0)
{
MessageBox("Warning usage mask is zero");
}
pmissile->stats_ss1 = ss1;
pmissile->stats_ss3 = ss3;
pmissile->stats_ss4 = ss4;
}
CDialog::DoDataExchange(pDX);
}
void CMissileDlg::OnClickedDecodesel(void)
{
CEdit *cetodo = (CEdit *) CWnd::GetDlgItem(IDC_TODO1);
int i,j;
cetodo->GetSel(i,j);
// NT SPECIFIC
HLOCAL h = cetodo->GetHandle();
LPCTSTR lpszText = (LPCTSTR)LocalLock(h);
char res[1000];
strncpy(res,&(lpszText[i]),j-i);
SetDlgItemText(IDC_DECDEC,res);
float f;
unsigned char *pf;
unsigned int b1,b2,b3,b4;
pf = (unsigned char *)&f;
sscanf(res,"%x %x %x %x",&b1,&b2,&b3,&b4);
pf[0] = b1;
pf[1] = b2;
pf[2] = b3;
pf[3] = b4;
CString sres;
sres.Format("%g",f);
SetDlgItemText(IDC_DECFLOAT,sres);
LocalUnlock(h);
// END OF NT SPECIFIC
}
void CMissileDlg::OnClickedDecodeh(void)
{
CEdit *cetodo = (CEdit *) CWnd::GetDlgItem(IDC_TODO1);
int i,j;
cetodo->GetSel(i,j);
// NT SPECIFIC
HLOCAL h = cetodo->GetHandle();
LPCTSTR lpszText = (LPCTSTR)LocalLock(h);
char res[1000];
strncpy(res,&(lpszText[i]),j-i);
SetDlgItemText(IDC_DECDEC,res);
unsigned short f;
unsigned char *pf;
unsigned int b1,b2;
pf = (unsigned char *)&f;
sscanf(res,"%x %x",&b1,&b2);
pf[0] = b1;
pf[1] = b2;
CString sres;
sres.Format("%04X = %d",f,f);
SetDlgItemText(IDC_DECFLOAT,sres);
LocalUnlock(h);
// END OF NT SPECIFIC
}
BOOL CMissileDlg::OnInitDialog(void)
{
CDialog::OnInitDialog();
VERIFY(mdlbmp.SubclassDlgItem(IDC_PICT, this));
VERIFY(mdlbmp2.SubclassDlgItem(IDC_PICT2, this));
CComboBox *cbse = (CComboBox *)CWnd::GetDlgItem(IDC_SEFFECT);
for (int i=0;i<IGCMISSILE_EFFECT_NBVALS;i++)
cbse->AddString(ICGMissileEffects[i]);
CComboBox *cbdm = (CComboBox *)GetDlgItem(IDC_DM);
cbdm->ResetContent();
for (int i=0;i<IGCDMMAX;i++)
{
CString s;
s.Format("DM%02d",i);
cbdm->AddString(s);
}
CComboBox *cbac = (CComboBox *)GetDlgItem(IDC_AC);
cbac->ResetContent();
for (int i=0;i<IGCACMAX;i++)
cbac->AddString(IGCArmorClasses[i]);
((CEdit *)GetDlgItem(IDC_DESCRIPTION))->SetLimitText(IGC_DESCRIPTIONMAX);
((CEdit *)GetDlgItem(IDC_NAME))->SetLimitText(IGC_NAMEMAX);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMissileDlg::OnClickedOk(void)
{
CString oldname = pmissile->name;
UpdateData(TRUE);
CString newname = pmissile->name;
if (oldname != newname)
GetParent()->UpdateData(TRUE);
UpdateData(FALSE);
}
void CMissileDlg::OnClickedCancel(void)
{
UpdateData(FALSE);
}
BEGIN_MESSAGE_MAP(CMissileDlg, CDialog)
ON_BN_CLICKED(IDC_DECODEH, OnClickedDecodeh)
ON_BN_CLICKED(IDC_DECODESEL, OnClickedDecodesel)
ON_BN_CLICKED(IDOK, OnClickedOk)
ON_BN_CLICKED(IDCANCEL, OnClickedCancel)
ON_BN_CLICKED(IDC_USEM0, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM1, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM2, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM3, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM4, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM5, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM6, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM7, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM8, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM9, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM10, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM11, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM12, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM13, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM14, OnBnClickedUsem0)
ON_BN_CLICKED(IDC_USEM15, OnBnClickedUsem0)
END_MESSAGE_MAP()
// CMissileDlg message handlers
// display other missiles with same usemask
void CMissileDlg::OnBnClickedUsem0()
{
// compute currently displayed umask
unsigned short umask = 0;
for (int i=0;i<16;i++)
{
CButton *cbb = (CButton *)CWnd::GetDlgItem(IDC_USEM0+i);
umask += cbb->GetCheck()?(1<<i):0;
}
CListBox *clb = (CListBox *)CWnd::GetDlgItem(IDC_UMLIST);
clb->ResetContent();
// get all parts that use umask
for (int j=0;j<pcore->cl_Missiles.GetSize();j++)
{
PtrCoreMissile pp = pcore->cl_Missiles.GetAt(j);
if ((pp->use_flags & umask) && (pp->uid != pmissile->uid))
{
CString s;
s.Format("%s (%d)",pp->name,pp->uid);
clb->AddString(s);
}
}
}