-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDMPCDetailsDialog.cpp
More file actions
329 lines (261 loc) · 8.73 KB
/
Copy pathDMPCDetailsDialog.cpp
File metadata and controls
329 lines (261 loc) · 8.73 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
// DMPCDetailsDialog.cpp : implementation file
//
#include "stdafx.h"
#include "DM Helper.h"
#include "DMInventoryDialog.h"
#include "DMCharSpellsDialog.h"
#include "DMCharViewDialog.h"
#include "DMNPCViewDialog.h"
#include "DMPCDetailsDialog.h"
#include "DMCharacterNotesDialog.h"
// CDMPCDetailsDialog dialog
IMPLEMENT_DYNAMIC(CDMPCDetailsDialog, CDialog)
CDMPCDetailsDialog::CDMPCDetailsDialog(CWnd* pParent /*=NULL*/)
: CDialog(CDMPCDetailsDialog::IDD, pParent)
, m_szPlayerWillTitle(_T(""))
, m_szPlayerWill(_T(""))
, m_szPlayerName(_T(""))
, m_szDateCreated(_T(""))
, m_szPatronDeity(_T(""))
, m_szPlaceofOrigin(_T(""))
, m_szReligion(_T(""))
, m_szHeight(_T(""))
, m_szWeight(_T(""))
, m_szAge(_T(""))
, m_szDOBMonth(_T(""))
, m_szDOBDay(_T(""))
, m_szDOBYear(_T(""))
, m_szAgeAdjust(_T(""))
, m_szHairColor(_T(""))
, m_szEyeColor(_T(""))
{
m_pParentWindow = (DMInventoryDialog *)pParent;
m_pPC = m_pParentWindow->m_pCharacter;
Create(CDMPCDetailsDialog::IDD, pParent);
}
CDMPCDetailsDialog::~CDMPCDetailsDialog()
{
}
void CDMPCDetailsDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_WILL_STATIC, m_szPlayerWillTitle);
DDX_Text(pDX, IDC_PLAYER_WILL_EDIT, m_szPlayerWill);
DDV_MaxChars(pDX, m_szPlayerWill, 256);
DDX_Text(pDX, IDC_PLAYER_NAME_EDIT, m_szPlayerName);
DDV_MaxChars(pDX, m_szPlayerName, 31);
DDX_Text(pDX, IDC_CHAR_CREATE_DATE_EDIT, m_szDateCreated);
DDV_MaxChars(pDX, m_szDateCreated, 15);
DDX_Text(pDX, IDC_PLAYER_DEITY_EDIT, m_szPatronDeity);
DDV_MaxChars(pDX, m_szPatronDeity, 31);
DDX_Text(pDX, IDC_CHAR_ORIGIN_EDIT, m_szPlaceofOrigin);
DDV_MaxChars(pDX, m_szPlaceofOrigin, 31);
DDX_Text(pDX, IDC_PLAYER_RELIGION_EDIT, m_szReligion);
DDV_MaxChars(pDX, m_szReligion, 31);
DDX_Text(pDX, IDC_CHAR_HEIGHT_EDIT, m_szHeight);
DDV_MaxChars(pDX, m_szHeight, 3);
DDX_Text(pDX, IDC_CHAR_WEIGHT_EDIT, m_szWeight);
DDV_MaxChars(pDX, m_szWeight, 4);
DDX_Text(pDX, IDC_CHAR_AGE_EDIT, m_szAge);
DDV_MaxChars(pDX, m_szAge, 4);
DDX_Text(pDX, IDC_CHAR_DOB_MONTH_EDIT, m_szDOBMonth);
DDV_MaxChars(pDX, m_szDOBMonth, 2);
DDX_Text(pDX, IDC_CHAR_DOB_DAY_EDIT, m_szDOBDay);
DDV_MaxChars(pDX, m_szDOBDay, 2);
DDX_Text(pDX, IDC_CHAR_DOB_YEAR_EDIT, m_szDOBYear);
DDV_MaxChars(pDX, m_szDOBYear, 5);
DDX_Text(pDX, IDC_CHAR_AGE_ADJUST_EDIT, m_szAgeAdjust);
DDV_MaxChars(pDX, m_szAgeAdjust, 4);
DDX_Text(pDX, IDC_CHAR_HAIR_COLOR_EDIT, m_szHairColor);
DDV_MaxChars(pDX, m_szHairColor, 15);
DDX_Text(pDX, IDC_CHAR_EYE_COLOR_EDIT, m_szEyeColor);
DDV_MaxChars(pDX, m_szEyeColor, 15);
}
BEGIN_MESSAGE_MAP(CDMPCDetailsDialog, CDialog)
ON_BN_CLICKED(IDOK, &CDMPCDetailsDialog::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CDMPCDetailsDialog::OnBnClickedCancel)
ON_WM_PAINT()
ON_EN_CHANGE(IDC_CHAR_AGE_EDIT, &CDMPCDetailsDialog::OnEnChangeCharAgeEdit)
ON_EN_CHANGE(IDC_PLAYER_NAME_EDIT, &CDMPCDetailsDialog::OnEnChangePlayerNameEdit)
ON_EN_CHANGE(IDC_CHAR_CREATE_DATE_EDIT, &CDMPCDetailsDialog::OnEnChangeCharCreateDateEdit)
ON_EN_CHANGE(IDC_PLAYER_DEITY_EDIT, &CDMPCDetailsDialog::OnEnChangePlayerDeityEdit)
ON_EN_CHANGE(IDC_CHAR_ORIGIN_EDIT, &CDMPCDetailsDialog::OnEnChangeCharOriginEdit)
ON_EN_CHANGE(IDC_PLAYER_RELIGION_EDIT, &CDMPCDetailsDialog::OnEnChangePlayerReligionEdit)
ON_EN_CHANGE(IDC_CHAR_HEIGHT_EDIT, &CDMPCDetailsDialog::OnEnChangeCharHeightEdit)
ON_EN_CHANGE(IDC_CHAR_WEIGHT_EDIT, &CDMPCDetailsDialog::OnEnChangeCharWeightEdit)
ON_EN_CHANGE(IDC_CHAR_DOB_MONTH_EDIT, &CDMPCDetailsDialog::OnEnChangeCharDobMonthEdit)
ON_EN_CHANGE(IDC_CHAR_DOB_DAY_EDIT, &CDMPCDetailsDialog::OnEnChangeCharDobDayEdit)
ON_EN_CHANGE(IDC_CHAR_AGE_ADJUST_EDIT, &CDMPCDetailsDialog::OnEnChangeCharAgeAdjustEdit)
ON_EN_CHANGE(IDC_CHAR_HAIR_COLOR_EDIT, &CDMPCDetailsDialog::OnEnChangeCharHairColorEdit)
ON_EN_CHANGE(IDC_CHAR_EYE_COLOR_EDIT, &CDMPCDetailsDialog::OnEnChangeCharEyeColorEdit)
ON_EN_CHANGE(IDC_PLAYER_WILL_EDIT, &CDMPCDetailsDialog::OnEnChangePlayerWillEdit)
ON_EN_CHANGE(IDC_CHAR_DOB_YEAR_EDIT, &CDMPCDetailsDialog::OnEnChangeCharDobYearEdit)
ON_BN_CLICKED(IDC_NOTES_BUTTON, &CDMPCDetailsDialog::OnBnClickedNotesButton)
ON_WM_CLOSE()
END_MESSAGE_MAP()
// CDMPCDetailsDialog message handlers
BOOL CDMPCDetailsDialog::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowPos(NULL, m_pParentWindow->m_nDetailsPosX, m_pParentWindow->m_nDetailsPosY, 0, 0, SW_SHOW);
ShowWindow(SW_SHOW);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDMPCDetailsDialog::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CDMPCDetailsDialog::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
OnCancel();
}
void CDMPCDetailsDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
}
void CDMPCDetailsDialog::Init(BOOL bAgeEdit)
{
m_szPlayerName = m_pPC->m_szPlayerName;
m_szDateCreated = m_pPC->m_szDateCreated;
m_szPatronDeity = m_pPC->m_szPatronDeity;
m_szPlaceofOrigin = m_pPC->m_szPlaceofOrigin;
m_szReligion = m_pPC->m_szReligion;
m_szHeight.Format("%d", m_pPC->m_nHeight);
m_szWeight.Format("%d", m_pPC->m_nWeight);
m_szAge.Format("%d", m_pPC->m_nAge);
m_szDOBMonth.Format("%d", m_pPC->m_nDOBMonth);
m_szDOBDay.Format("%d", m_pPC->m_nDOBDay);
if(bAgeEdit == FALSE)
{
if(m_pPC->m_nDOBYear == 0)
m_szDOBYear = _T("?");
else
m_szDOBYear.Format("%d", m_pPC->m_nDOBYear);
}
m_szAgeAdjust.Format("%d", m_pPC->m_nAgeAdj);
m_szHairColor = m_pPC->m_szHairColor;
m_szEyeColor = m_pPC->m_szEyeColor;
m_szPlayerWill = m_pPC->m_szWill;
m_szPlayerWillTitle.Format("I %s do hereby:", m_pParentWindow->m_pCharacter->m_szCharacterName);
//give all of my stuff to the rest of my party unless they can use it to resurrect me
UpdateData(FALSE);
}
void CDMPCDetailsDialog::Refresh(BOOL bCharacterChanged, BOOL bClosing)
{
UpdateData(TRUE);
strcpy(m_pPC->m_szPlayerName, m_szPlayerName.Left(31));
strcpy(m_pPC->m_szDateCreated, m_szDateCreated.Left(15));
strcpy(m_pPC->m_szPatronDeity, m_szPatronDeity.Left(31));
strcpy(m_pPC->m_szPlaceofOrigin, m_szPlaceofOrigin.Left(31));
strcpy(m_pPC->m_szReligion, m_szReligion.Left(31));
m_pPC->m_nHeight = atoi(m_szHeight.GetBuffer(0));
m_pPC->m_nWeight = atoi(m_szWeight.GetBuffer(0));
m_pPC->m_nAge = atoi(m_szAge.GetBuffer(0));
m_pPC->m_nDOBMonth = atoi(m_szDOBMonth.GetBuffer(0));
m_pPC->m_nDOBDay = atoi(m_szDOBDay.GetBuffer(0));
m_pPC->m_nDOBYear = atoi(m_szDOBYear.GetBuffer(0));
m_pPC->m_nAgeAdj = atoi(m_szAgeAdjust.GetBuffer(0));
strcpy(m_pPC->m_szHairColor, m_szHairColor.Left(15));
strcpy(m_pPC->m_szEyeColor, m_szEyeColor.Left(15));
strcpy(m_pPC->m_szWill, m_szPlayerWill.Left(255));
if(bClosing == FALSE)
{
if(m_pParentWindow->m_pPCVWindow != NULL)
{
m_pParentWindow->m_pPCVWindow->InvalidateRect(NULL);
m_pParentWindow->m_pPCVWindow->ProcessCharStats();
m_pParentWindow->m_pPCVWindow->Refresh();
}
}
if(bCharacterChanged)
{
m_pPC->MarkChanged();
}
}
void CDMPCDetailsDialog::OnEnChangeCharAgeEdit()
{
UpdateData(TRUE);
m_pPC->m_nAge = atoi(m_szAge.GetBuffer(0));
if(m_pParentWindow->m_pPCVWindow != NULL && m_pParentWindow->m_pPCVWindow->m_nYear != 0)
{
m_pPC->m_nDOBYear = m_pParentWindow->m_pPCVWindow->m_nYear - m_pPC->m_nAge;
//not past birthday yet ?
if(m_pParentWindow->m_pPCVWindow->m_nMonth < m_pPC->m_nDOBMonth || (m_pParentWindow->m_pPCVWindow->m_nMonth == m_pPC->m_nDOBMonth && m_pParentWindow->m_pPCVWindow->m_nDayofMonth < m_pPC->m_nDOBDay))
{
m_pPC->m_nDOBYear -= 1;
}
Init();
Refresh();
}
}
void CDMPCDetailsDialog::OnEnChangePlayerNameEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharCreateDateEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangePlayerDeityEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharOriginEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangePlayerReligionEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharHeightEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharWeightEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharDobMonthEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharDobDayEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharAgeAdjustEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharHairColorEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharEyeColorEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangePlayerWillEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnEnChangeCharDobYearEdit()
{
Refresh();
}
void CDMPCDetailsDialog::OnBnClickedNotesButton()
{
CDMCharacterNotesDialog *pDlg = new CDMCharacterNotesDialog(m_pPC);
pDlg->DoModal();
delete pDlg;
}
void CDMPCDetailsDialog::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose();
}