-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDMCharacterSelectorDialog.cpp
More file actions
274 lines (220 loc) · 6.96 KB
/
Copy pathDMCharacterSelectorDialog.cpp
File metadata and controls
274 lines (220 loc) · 6.96 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
// DMCharacterSelectorDialog.cpp : implementation file
//
#include "stdafx.h"
#include "DM Helper.h"
#include "DM Helper Common.h"
#include "DMPartyDialog.h"
#include "DMInventoryDialog.h"
#include "DMCharSpellsDialog.h"
#include "DMCharViewDialog.h"
#include "DMNPCViewDialog.h"
#include "cDMMapViewDialog.h"
#include "DMCharacterSelectorDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DMCharacterSelectorDialog dialog
DMCharacterSelectorDialog::DMCharacterSelectorDialog(DWORD *pdwReturnedID, DWORD _dwParentPartyID, DWORD _dwSubPartyID, DND_SELECTOR_TYPES _SelectorType, DND_CHARACTER_CLASSES _SelectorClass, DWORD dwExcludeID, CWnd* pParent /*=NULL*/)
: CDialog(DMCharacterSelectorDialog::IDD, pParent)
, m_szComment(_T("* Note: New characters must be saved before they will appear in this list !"))
{
//{{AFX_DATA_INIT(DMCharacterSelectorDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pApp = (CDMHelperApp *)AfxGetApp();
m_dwParentPartyID = _dwParentPartyID;
m_dwSubPartyID = _dwSubPartyID;
m_SelectorType = _SelectorType;
m_SelectorClass = _SelectorClass;
m_dwExcludeID = dwExcludeID;
m_pdwReturnedID = pdwReturnedID;
}
void DMCharacterSelectorDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DMCharacterSelectorDialog)
DDX_Control(pDX, IDC_CHARACTER_LIST, m_cCharacterList);
//}}AFX_DATA_MAP
DDX_Text(pDX, IDC_COMMENT, m_szComment);
}
BEGIN_MESSAGE_MAP(DMCharacterSelectorDialog, CDialog)
//{{AFX_MSG_MAP(DMCharacterSelectorDialog)
ON_LBN_DBLCLK(IDC_CHARACTER_LIST, OnDblclkCharacterList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DMCharacterSelectorDialog message handlers
void DMCharacterSelectorDialog::OnOK()
{
// TODO: Add extra validation here
UpdateData(FALSE);
int nCursor = m_cCharacterList.GetCurSel();
if(nCursor != -1)
{
*m_pdwReturnedID = m_cCharacterList.GetItemData(nCursor);
}
CDialog::OnOK();
}
void DMCharacterSelectorDialog::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL DMCharacterSelectorDialog::OnInitDialog()
{
CDialog::OnInitDialog();
int nRow = 0;
WORD wID;
DND_CHARACTER_CLASSES _SelectorClass = m_SelectorClass;
DMPartyDialog *pPartyDlg = NULL;
if (FALSE == m_pApp->m_PartyViewMap.Lookup((WORD)m_dwParentPartyID, pPartyDlg))
{
pPartyDlg = NULL;
}
switch(m_SelectorType)
{
case DND_SELECTOR_CHARACTER:
case DND_SELECTOR_CHARACTER_CASTER:
case DND_SELECTOR_PARTY_MEMBER:
case DND_SELECTOR_SUBPARTY_MEMBER:
case DND_SELECTOR_SUBPARTY_REMOVE_MEMBER:
{
SetWindowText("Select Character:");
if (m_SelectorType == DND_SELECTOR_CHARACTER_CASTER)
{
m_szComment = _T("Select the character into whose spellbook this spell will be copied");
}
for (POSITION pos = m_pApp->m_CharacterViewMap.GetStartPosition(); pos != NULL; )
{
PDNDCHARVIEWDLG pCharDlg = NULL;
m_pApp->m_CharacterViewMap.GetNextAssoc(pos,wID,pCharDlg);
if(pCharDlg != NULL && pCharDlg->m_pCharacter != NULL && pCharDlg->m_pCharacter->m_dwCharacterID)
{
if (pCharDlg->m_pCharacter->m_dwCharacterID == m_dwExcludeID)
{
continue;
}
if (m_SelectorType == DND_SELECTOR_PARTY_MEMBER && pPartyDlg != NULL)
{
if (pPartyDlg->m_pParty->CharacterIsPartyMember(pCharDlg->m_pCharacter->m_dwCharacterID))
{
continue;
}
}
if (m_SelectorType == DND_SELECTOR_SUBPARTY_MEMBER && pPartyDlg != NULL)
{
if (pCharDlg->m_pCharacter->m_dwSubPartyID == m_dwSubPartyID)
{
continue;
}
}
if (m_SelectorType == DND_SELECTOR_SUBPARTY_REMOVE_MEMBER)
{
if (pCharDlg->m_pCharacter->m_dwSubPartyID != m_dwSubPartyID)
{
continue;
}
}
// pCharDlg->m_pCharacter->m_dwSubPartyID = 0;
if (m_SelectorType == DND_SELECTOR_CHARACTER_CASTER)
{
DND_CHARACTER_CLASSES _SpellClasses[4];
for (int i = 0; i < 4; ++i)
{
_SpellClasses[i] = pCharDlg->m_pCharacter->m_SpellClasses[i];
if (_SpellClasses[i] == DND_CHARACTER_SPELL_CLASS_RANGER_MAGE)
{
_SpellClasses[i] = DND_CHARACTER_CLASS_MAGE;
}
}
if (_SpellClasses[0] != _SelectorClass &&
_SpellClasses[1] != _SelectorClass &&
_SpellClasses[2] != _SelectorClass &&
_SpellClasses[3] != _SelectorClass)
{
continue;
}
}
m_cCharacterList.InsertString(nRow, pCharDlg->m_pCharacter->m_szCharacterName);
m_cCharacterList.SetItemData(nRow, pCharDlg->m_pCharacter->m_dwCharacterID);
++nRow;
}
}
if (m_SelectorClass == DND_CHARACTER_CLASS_UNDEF)
{
for (pos = m_pApp->m_NPCViewMap.GetStartPosition(); pos != NULL;)
{
PDNDNPCVIEWDLG pNPCDlg = NULL;
m_pApp->m_NPCViewMap.GetNextAssoc(pos, wID, pNPCDlg);
if (pNPCDlg != NULL && pNPCDlg->m_pNPC != NULL && pNPCDlg->m_pNPC->m_dwCharacterID && !pNPCDlg->m_pNPC->m_bIsCache)
{
for (int i = 0; i < m_cCharacterList.GetCount(); ++i)
{
if (m_cCharacterList.GetItemData(i) == pNPCDlg->m_pNPC->m_dwCharacterID)
{
pNPCDlg = NULL;
break;
}
}
if (pNPCDlg != NULL)
{
if (m_SelectorType == DND_SELECTOR_PARTY_MEMBER && pPartyDlg != NULL)
{
if (pPartyDlg->m_pParty->CharacterIsPartyMember(pNPCDlg->m_pNPC->m_dwCharacterID))
{
continue;
}
}
if (m_SelectorType == DND_SELECTOR_SUBPARTY_MEMBER && pPartyDlg != NULL)
{
if (pNPCDlg->m_pNPC->m_dwSubPartyID == m_dwSubPartyID)
{
continue;
}
}
if (m_SelectorType == DND_SELECTOR_SUBPARTY_REMOVE_MEMBER && pPartyDlg != NULL)
{
if (pNPCDlg->m_pNPC->m_dwSubPartyID != m_dwSubPartyID)
{
continue;
}
}
m_cCharacterList.InsertString(nRow, pNPCDlg->m_pNPC->m_szCharacterName);
m_cCharacterList.SetItemData(nRow, pNPCDlg->m_pNPC->m_dwCharacterID);
++nRow;
}
}
}
}
break;
}
case DND_SELECTOR_MAP:
{
m_szComment = _T("");
SetWindowText("Select Map:");
for (POSITION pos = m_pApp->m_MapViewMap.GetStartPosition(); pos != NULL; )
{
PDNDMAPVIEWDLG pMapDlg = NULL;
m_pApp->m_MapViewMap.GetNextAssoc(pos,wID,pMapDlg);
if(pMapDlg != NULL && pMapDlg->m_pDNDMap != NULL && pMapDlg->m_pDNDMap->m_dwMapID)
{
m_cCharacterList.InsertString(nRow, pMapDlg->m_pDNDMap->m_szMapName);
m_cCharacterList.SetItemData(nRow, pMapDlg->m_pDNDMap->m_dwMapID);
++nRow;
}
}
break;
}
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void DMCharacterSelectorDialog::OnDblclkCharacterList()
{
// TODO: Add your control notification handler code here
OnOK();
}