[516d32]: AreaInt.cpp Maximize Restore History

Download this file

AreaInt.cpp    295 lines (255 with data), 7.1 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
289
290
291
292
293
294
// AreaInt.cpp : implementation file
//
#include "stdafx.h"
#include "chitem.h"
#include "AreaInt.h"
#include "options.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAreaInt dialog
CAreaInt::CAreaInt(CWnd* pParent /*=NULL*/)
: CDialog(CAreaInt::IDD, pParent)
{
//{{AFX_DATA_INIT(CAreaInt)
m_text = _T("");
//}}AFX_DATA_INIT
m_crenum=0;
}
void CAreaInt::RefreshInt()
{
CString tmpstr;
int i;
m_spawnnumpicker.ResetContent();
for(i=0;i<the_area.intheader.creaturecnt;i++)
{
tmpstr.Format("%d %-.8s",i+1,the_area.intheader.creatures[i]);
m_spawnnumpicker.AddString(tmpstr);
}
m_spawnnumpicker.SetCurSel(m_crenum);
m_text=resolve_tlk_text(the_area.intheader.strrefs[m_crenum]);
}
BOOL CAreaInt::OnInitDialog()
{
CDialog::OnInitDialog();
RefreshInt();
UpdateData(UD_DISPLAY);
return TRUE;
}
void CAreaInt::DoDataExchange(CDataExchange* pDX)
{
CString tmpstr;
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAreaInt)
DDX_Control(pDX, IDC_SPAWNNUMPICKER, m_spawnnumpicker);
DDX_Text(pDX, IDC_TEXT, m_text);
//}}AFX_DATA_MAP
RetrieveVariable(tmpstr,the_area.intheader.intname);
DDX_Text(pDX, IDC_SECTION, tmpstr);
DDV_MaxChars(pDX, tmpstr, 32);
StoreVariable(tmpstr,the_area.intheader.intname);
tmpstr.Format("/ %d", the_area.intheader.creaturecnt);
DDX_Text(pDX, IDC_MAXCRE, tmpstr);
RetrieveResref(tmpstr,the_area.intheader.creatures[m_crenum]);
DDX_Text(pDX, IDC_CRERES, tmpstr);
DDV_MaxChars(pDX, tmpstr, 8);
StoreResref(tmpstr,the_area.intheader.creatures[m_crenum]);
DDX_Text(pDX, IDC_STRREF, the_area.intheader.strrefs[m_crenum]);
DDX_Text(pDX, IDC_UNKNOWN9A, the_area.intheader.unknown9a);
DDX_Text(pDX, IDC_UNKNOWN9C, the_area.intheader.unknown9c);
DDX_Text(pDX, IDC_UNKNOWNA0, the_area.intheader.unknowna0);
DDX_Text(pDX, IDC_UNKNOWNA2, the_area.intheader.unknowna2);
DDX_Text(pDX, IDC_MAX, the_area.intheader.maxnumber);
DDX_Text(pDX, IDC_MIN, the_area.intheader.unknowna6);
DDX_Text(pDX, IDC_UNKNOWNA8, the_area.intheader.unknowna8);
DDX_Text(pDX, IDC_UNKNOWNAA, the_area.intheader.unknownaa);
DDX_Text(pDX, IDC_UNKNOWNAC, the_area.intheader.unknownac);
DDX_Text(pDX, IDC_UNKNOWNAE, the_area.intheader.unknownae);
}
BEGIN_MESSAGE_MAP(CAreaInt, CDialog)
//{{AFX_MSG_MAP(CAreaInt)
ON_EN_KILLFOCUS(IDC_SECTION, OnKillfocusSection)
ON_EN_KILLFOCUS(IDC_MIN, OnKillfocusMin)
ON_EN_KILLFOCUS(IDC_MAX, OnKillfocusMax)
ON_EN_KILLFOCUS(IDC_CRERES, OnKillfocusCreres)
ON_EN_KILLFOCUS(IDC_STRREF, OnKillfocusStrref)
ON_EN_KILLFOCUS(IDC_TEXT, OnKillfocusText)
ON_EN_KILLFOCUS(IDC_UNKNOWN9A, OnKillfocusUnknown9a)
ON_EN_KILLFOCUS(IDC_UNKNOWN9C, OnKillfocusUnknown9c)
ON_EN_KILLFOCUS(IDC_UNKNOWNA0, OnKillfocusUnknowna0)
ON_EN_KILLFOCUS(IDC_UNKNOWNA2, OnKillfocusUnknowna2)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_BN_CLICKED(IDC_ADDCRE, OnAddcre)
ON_BN_CLICKED(IDC_DELCRE, OnDelcre)
ON_EN_KILLFOCUS(IDC_UNKNOWNA8, OnKillfocusUnknowna8)
ON_EN_KILLFOCUS(IDC_UNKNOWNAA, OnKillfocusUnknownaa)
ON_CBN_KILLFOCUS(IDC_SPAWNNUMPICKER, OnKillfocusSpawnnumpicker)
ON_CBN_SELCHANGE(IDC_SPAWNNUMPICKER, OnSelchangeSpawnnumpicker)
ON_BN_CLICKED(IDC_CLEAR, OnClear)
ON_EN_KILLFOCUS(IDC_UNKNOWNAC, OnKillfocusUnknownac)
ON_EN_KILLFOCUS(IDC_UNKNOWNAE, OnKillfocusUnknownae)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAreaInt message handlers
void CAreaInt::OnKillfocusSection()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusMin()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusMax()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusCreres()
{
UpdateData(UD_RETRIEVE);
RefreshInt();
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusStrref()
{
UpdateData(UD_RETRIEVE);
RefreshInt();
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusText()
{
CString tmpstr;
UpdateData(UD_RETRIEVE);
tmpstr=resolve_tlk_text(the_area.intheader.strrefs[m_crenum]);
if(tmpstr!=m_text)
{
if(editflg&TLKCHANGE)
{
if(MessageBox("Do you want to update dialog.tlk?","Area editor",MB_YESNO)!=IDYES)
{
return;
}
}
the_area.intheader.strrefs[m_crenum]=store_tlk_text(the_area.intheader.strrefs[m_crenum],m_text);
}
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknown9a()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknown9c()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknowna0()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknowna2()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknowna8()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknownaa()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknownac()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusUnknownae()
{
UpdateData(UD_RETRIEVE);
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnBrowse()
{
if(m_crenum<0) return;
pickerdlg.m_restype=REF_CRE;
RetrieveResref(pickerdlg.m_picked,the_area.intheader.creatures[m_crenum]);
if(pickerdlg.DoModal()==IDOK)
{
StoreResref(pickerdlg.m_picked,the_area.intheader.creatures[m_crenum]);
}
RefreshInt();
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnAddcre()
{
if(the_area.intheader.creaturecnt<10)
{
the_area.intheader.creaturecnt++;
}
RefreshInt();
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnDelcre()
{
if(m_crenum>=0 && m_crenum<=9)
{
memcpy(the_area.intheader.creatures+m_crenum,
the_area.intheader.creatures+m_crenum+1,
(9-m_crenum)*8);
memset(the_area.intheader.creatures[9],0,8);
}
the_area.intheader.creaturecnt--;
m_crenum=the_area.intheader.creaturecnt-1;
RefreshInt();
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnKillfocusSpawnnumpicker()
{
// TODO: Add your control notification handler code here
CString tmpstr;
int x;
m_spawnnumpicker.GetWindowText(tmpstr);
x=strtonum(tmpstr)-1;
if(x>=0 && x<=the_area.intheader.creaturecnt)
{
m_crenum=x;
}
RefreshInt();
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnSelchangeSpawnnumpicker()
{
int x;
x=m_spawnnumpicker.GetCurSel();
if(x>=0 && x<=the_area.intheader.creaturecnt) m_crenum=x;
RefreshInt();
UpdateData(UD_DISPLAY);
}
void CAreaInt::OnClear()
{
int i;
memset(&the_area.intheader,0,sizeof(area_int));
for(i=0;i<10;i++)
{
the_area.intheader.strrefs[i]=10134; //seems to be ok for BG2/IWD2
}
the_area.intheader.unknown9a=2;
the_area.intheader.unknown9c=the_area.intheader.unknowna0=the_area.intheader.unknowna2=1000;
the_area.intheader.unknowna6=1;
the_area.intheader.maxnumber=1;
the_area.intheader.unknowna8=the_area.intheader.unknownaa=10;
RefreshInt();
UpdateData(UD_DISPLAY);
}