-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObSelectRecordDlg.cpp
841 lines (672 loc) · 29.1 KB
/
ObSelectRecordDlg.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
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
/*===========================================================================
*
* File: Obselectrecorddlg.CPP
* Author: Dave Humphrey ([email protected])
* Created On: September 26, 2006
*
* Description
*
*=========================================================================*/
/* Include Files */
#include "stdafx.h"
#include "resource.h"
#include "ObSelectRecordDlg.h"
/*===========================================================================
*
* Begin Local Definitions
*
*=========================================================================*/
//#ifdef _DEBUG
// #define new DEBUG_NEW
// #undef THIS_FILE
// static char THIS_FILE[] = __FILE__;
//#endif
/*===========================================================================
* End of Local Definitions
*=========================================================================*/
/*===========================================================================
*
* Begin CObSelectRecordDlg Message Map
*
*=========================================================================*/
BEGIN_MESSAGE_MAP(CObSelectRecordDlg, CDialog)
//{{AFX_MSG_MAP(CObSelectRecordDlg)
ON_BN_CLICKED(ID_CLEAR_BUTTON, OnClearButton)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_RECORDLIST, OnItemchangedRecordlist)
ON_MESSAGE(ID_OBRECORDLIST_ACTIVATE, OnEditRecord)
ON_EN_CHANGE(IDC_CURRENT_TEXT, OnChangeCurrentText)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*===========================================================================
* End of CObSelectRecordDlg Message Map
*=========================================================================*/
/*===========================================================================
*
* Begin Script Dialog Data
*
*=========================================================================*/
static obreclistcolinit_t s_ScptListInit[] = {
{ OB_FIELD_EDITORID, 200, LVCFMT_LEFT },
{ OB_FIELD_FORMID, 75, LVCFMT_LEFT },
{ OB_FIELD_FLAGS, 60, LVCFMT_CENTER },
{ OB_FIELD_TYPE, 75, LVCFMT_CENTER },
{ OB_FIELD_NONE, 0, 0 }
};
bool s_IsTypeScript (CObRecord* pRecord, long UserData) {
CObScptRecord* pScript = ObCastClass(CObScptRecord, pRecord);
if (pScript == NULL) return (false);
return (pScript->GetType() == (dword)UserData);
}
static obselrecdlginfo_t s_ItemScriptSelDlg = {
&OB_NAME_SCPT, NULL, _T("Select Item Script..."), s_ScptListInit, &CObScptRecord::s_FieldMap, OB_FIELD_FLAGS, s_IsTypeScript, OB_SCRIPTTYPE_OBJECT };
/*===========================================================================
* End of Script Dialog Data
*=========================================================================*/
/*===========================================================================
*
* Begin Enchantment Dialog Data
*
*=========================================================================*/
static obreclistcolinit_t s_EnchListInit[] = {
{ OB_FIELD_EDITORID, 200, LVCFMT_LEFT },
{ OB_FIELD_FORMID, 75, LVCFMT_LEFT },
{ OB_FIELD_FLAGS, 50, LVCFMT_CENTER },
{ OB_FIELD_TYPE, 75, LVCFMT_CENTER },
{ OB_FIELD_CHARGE, 60, LVCFMT_CENTER },
{ OB_FIELD_COST, 60, LVCFMT_CENTER },
{ OB_FIELD_AUTOCALC, 50, LVCFMT_CENTER },
{ OB_FIELD_EFFECTCOUNT, 80, LVCFMT_CENTER },
{ OB_FIELD_NONE, 0, 0 }
};
bool s_IsTypeEnchant (CObRecord* pRecord, long UserData) {
CObEnchRecord* pEnchant = ObCastClass(CObEnchRecord, pRecord);
if (pEnchant == NULL) return (false);
return (pEnchant->GetType() == (dword)UserData);
}
static obselrecdlginfo_t s_ApparelEnchantSelDlg = {
&OB_NAME_ENCH, NULL, _T("Select Apparel Enchantment..."), s_EnchListInit, &CObEnchRecord::s_FieldMap, OB_FIELD_FLAGS, s_IsTypeEnchant, OB_ENCHTYPE_APPAREL };
static obselrecdlginfo_t s_ScrollEnchantSelDlg = {
&OB_NAME_ENCH, NULL, _T("Select Scroll Enchantment..."), s_EnchListInit, &CObEnchRecord::s_FieldMap, OB_FIELD_FLAGS, s_IsTypeEnchant, OB_ENCHTYPE_SCROLL };
static obselrecdlginfo_t s_StaffEnchantSelDlg = {
&OB_NAME_ENCH, NULL, _T("Select Staff Enchantment..."), s_EnchListInit, &CObEnchRecord::s_FieldMap, OB_FIELD_FLAGS, s_IsTypeEnchant, OB_ENCHTYPE_STAFF };
static obselrecdlginfo_t s_WeaponEnchantSelDlg = {
&OB_NAME_ENCH, NULL, _T("Select Weapon Enchantment..."), s_EnchListInit, &CObEnchRecord::s_FieldMap, OB_FIELD_FLAGS, s_IsTypeEnchant, OB_ENCHTYPE_WEAPON };
/*===========================================================================
* End of Enchantment Dialog Data
*=========================================================================*/
/*===========================================================================
*
* Begin Actor Dialog Data
*
*=========================================================================*/
static obreclistcolinit_t s_ActorListInit[] = {
{ OB_FIELD_EDITORID, 200, LVCFMT_LEFT },
{ OB_FIELD_FORMID, 75, LVCFMT_LEFT },
{ OB_FIELD_FLAGS, 60, LVCFMT_CENTER },
{ OB_FIELD_FULLNAME, 120, LVCFMT_CENTER },
{ OB_FIELD_NONE, 0, 0 }
};
static const obrectype_t* s_ActorTypes[] = { &OB_NAME_NPC_, &OB_NAME_CREA, NULL };
static obselrecdlginfo_t s_ActorSelDlg = {
NULL, s_ActorTypes, _T("Select Actor..."), s_ActorListInit, &CObNpcRecord::s_FieldMap, OB_FIELD_EDITORID, NULL, 0 };
/*===========================================================================
* End of Actor Dialog Data
*=========================================================================*/
/*===========================================================================
*
* Begin Ingrediant Dialog Data
*
*=========================================================================*/
static obreclistcolinit_t s_IngrediantListInit[] = {
{ OB_FIELD_EDITORID, 200, LVCFMT_LEFT },
{ OB_FIELD_FORMID, 75, LVCFMT_LEFT },
{ OB_FIELD_FLAGS, 60, LVCFMT_CENTER },
{ OB_FIELD_FULLNAME, 120, LVCFMT_CENTER },
{ OB_FIELD_NONE, 0, 0 }
};
static obselrecdlginfo_t s_IngrediantSelDlg = {
&OB_NAME_INGR, NULL, _T("Select Ingrediant..."), s_IngrediantListInit, &CObIngrRecord::s_FieldMap, OB_FIELD_EDITORID, NULL, 0 };
/*===========================================================================
* End of Ingrediant Dialog Data
*=========================================================================*/
/*===========================================================================
*
* Begin Sound Dialog Data
*
*=========================================================================*/
static obreclistcolinit_t s_SoundListInit[] = {
{ OB_FIELD_EDITORID, 200, LVCFMT_LEFT },
{ OB_FIELD_FORMID, 75, LVCFMT_LEFT },
{ OB_FIELD_FLAGS, 60, LVCFMT_CENTER },
{ OB_FIELD_FULLNAME, 120, LVCFMT_CENTER },
{ OB_FIELD_NONE, 0, 0 }
};
static obselrecdlginfo_t s_SoundSelDlg = {
&OB_NAME_SOUN, NULL, _T("Select Sound..."), s_SoundListInit, &CObIdRecord::s_FieldMap, OB_FIELD_EDITORID, NULL, 0 };
/*===========================================================================
* End of Sound Dialog Data
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Constructor
*
*=========================================================================*/
CObSelectRecordDlg::CObSelectRecordDlg (CWnd* pParent) : CDialog(CObSelectRecordDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CObSelectRecordDlg)
//}}AFX_DATA_INIT
m_pRecordHandler = NULL;
m_pPrevRecord = NULL;
m_pCurrentRecord = NULL;
m_IsInitialized = false;
m_EditorIDCheck = OB_CHECKRESULT_NOCHANGE;
m_UpdateListOnChange = false;
m_InitialFormID = OB_FORMID_NULL;
m_CurrentFormID = OB_FORMID_NULL;
}
/*===========================================================================
* End of Class CObSelectRecordDlg Constructor
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - void DoDataExchange (pDX);
*
*=========================================================================*/
void CObSelectRecordDlg::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CObSelectRecordDlg)
DDX_Control(pDX, IDC_CURRENT_FORMID, m_CurrentFormIDText);
DDX_Control(pDX, IDC_PREVIOUS_FORMID, m_PreviousFormIDText);
DDX_Control(pDX, ID_CLEAR_BUTTON, m_ClearButton);
DDX_Control(pDX, IDC_CURRENT_TEXT, m_CurrentText);
DDX_Control(pDX, IDC_PREVIOUS_TEXT, m_PreviousText);
DDX_Control(pDX, IDC_RECORDLIST, m_RecordList);
//}}AFX_DATA_MAP
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::DoDataExchange()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - void AddListColumns (void);
*
*=========================================================================*/
void CObSelectRecordDlg::AddListColumns (void) {
m_RecordList.DeleteAllColumns();
if (m_DlgInfo.pListColumns == NULL || m_DlgInfo.pFieldMap == NULL) return;
if (m_DlgInfo.pRecordType != NULL)
m_RecordList.SetupList(*m_DlgInfo.pRecordType, m_DlgInfo.pListColumns, m_DlgInfo.pFieldMap);
else if (m_DlgInfo.ppRecordArray != NULL && m_DlgInfo.ppRecordArray[0] != NULL)
m_RecordList.SetupList(*m_DlgInfo.ppRecordArray[0], m_DlgInfo.pListColumns, m_DlgInfo.pFieldMap);
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::AddListColumns()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - void FillRecordList (RecordType);
*
*=========================================================================*/
void CObSelectRecordDlg::FillRecordList (const obrectype_t RecordType) {
CObTypeGroup* pGroup;
CObBaseRecord* pBaseRecord;
CObRecord* pRecord;
dword Index;
bool Result;
/* Get the type group for the given record type */
pGroup = m_pRecordHandler->GetTopGroup()->GetTypeGroup(RecordType);
if (pGroup == NULL) return;
/* Add all matching records in the group */
for (Index = 0; Index < pGroup->GetNumRecords(); ++Index) {
pBaseRecord = pGroup->GetRecord(Index);
pRecord = ObCastRecord(pBaseRecord);
if (pRecord == NULL) continue;
/* Use the callback check function if present */
if (m_DlgInfo.pCheckFunc != NULL) {
Result = m_DlgInfo.pCheckFunc(pRecord, m_DlgInfo.UserData);
if (!Result) continue;
}
/* Add the record */
m_RecordList.AddRecord(pRecord);
}
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::FillRecordList()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - void FillRecordList (void);
*
*=========================================================================*/
void CObSelectRecordDlg::FillRecordList (void) {
dword Index;
/* Clear the current content */
m_RecordList.DeleteAllItems();
/* Ensure a valid object state */
if (m_pRecordHandler == NULL) return;
/* Add a single record type */
if (m_DlgInfo.pRecordType != NULL) FillRecordList(*m_DlgInfo.pRecordType);
/* Add several record types */
if (m_DlgInfo.ppRecordArray != NULL) {
for (Index = 0; m_DlgInfo.ppRecordArray[Index] != NULL; ++Index) {
FillRecordList(*m_DlgInfo.ppRecordArray[Index]);
}
}
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::FillRecordList()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - void GetControlData (void);
*
*=========================================================================*/
void CObSelectRecordDlg::GetControlData (void) {
m_pCurrentRecord = m_RecordList.GetSelectedRecord();
if (m_pCurrentRecord == NULL)
m_CurrentFormID = OB_FORMID_NULL;
else
m_CurrentFormID = m_pCurrentRecord->GetFormID();
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::GetControlData()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Event - void OnClearButton ();
*
*=========================================================================*/
void CObSelectRecordDlg::OnClearButton() {
m_pCurrentRecord = NULL;
m_CurrentFormID = OB_FORMID_NULL;
m_CurrentEditorID.Empty();
EndDialog(IDOK);
//UpdateCurrentRecord();
}
/*===========================================================================
* End of Class Event CObSelectRecordDlg::OnClearButton()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Event - LRESULT OnEditRecord (lParam, wParam);
*
*=========================================================================*/
LRESULT CObSelectRecordDlg::OnEditRecord (WPARAM lParam, LPARAM wParam) {
CObRecord* pRecord = (CObRecord *) lParam;
OnOK();
return (0);
}
/*===========================================================================
* End of Class Event CObSelectRecordDlg::OnEditRecord()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Event - BOOL OnInitDialog ();
*
*=========================================================================*/
BOOL CObSelectRecordDlg::OnInitDialog() {
CDialog::OnInitDialog();
m_UpdateListOnChange = false;
SetWindowText(m_DlgInfo.pTitle);
m_ClearButton.ShowWindow(m_AllowNullRecord ? SW_SHOW : SW_HIDE);
if (m_pRecordHandler != NULL) {
if (!m_InitialEditorID.IsEmpty()) {
m_pPrevRecord = m_pRecordHandler->FindEditorID(m_InitialEditorID);
}
else {
m_pPrevRecord = m_pRecordHandler->FindFormID(m_InitialFormID);
}
m_pCurrentRecord = m_pPrevRecord;
}
/* Initialize the record list */
m_RecordList.SetListName("SelectRecordList");
m_RecordList.DefaultSettings();
AddListColumns();
FillRecordList();
SetControlData();
m_RecordList.SetFocus();
m_IsInitialized = true;
m_UpdateListOnChange = true;
return (false);
}
/*===========================================================================
* End of Class Event CObSelectRecordDlg::OnInitDialog()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Event - void OnItemchangedRecordlist (pNMHDR, pResult);
*
*=========================================================================*/
void CObSelectRecordDlg::OnItemchangedRecordlist (NMHDR* pNMHDR, LRESULT* pResult) {
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
if (!m_IsInitialized) return;
if (!m_UpdateListOnChange) return;
GetControlData();
UpdateCurrentRecord();
}
/*===========================================================================
* End of Class Event CObSelectRecordDlg::OnItemchangedRecordlist()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Event - void OnOK ();
*
*=========================================================================*/
void CObSelectRecordDlg::OnOK() {
//GetControlData();
CDialog::OnOK();
}
/*===========================================================================
* End of Class Event CObSelectRecordDlg::OnOK()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - void SetControlData (void);
*
*=========================================================================*/
void CObSelectRecordDlg::SetControlData (void) {
CString Buffer;
CString EditorID;
CObIdRecord* pIdRecord;
m_RecordList.SortList(OB_FIELD_EDITORID);
if (m_DlgInfo.SortField != OB_FIELD_EDITORID) m_RecordList.SortList(m_DlgInfo.SortField);
m_RecordList.SelectRecord(m_pCurrentRecord);
if (m_pPrevRecord == NULL) {
m_PreviousText.SetWindowText("");
m_PreviousFormIDText.SetWindowText("0x00000000");
}
else {
pIdRecord = ObCastClass(CObIdRecord, m_pPrevRecord);
if (pIdRecord != NULL) EditorID = pIdRecord->GetEditorID();
Buffer.Format("%s", EditorID);
m_PreviousText.SetWindowText(Buffer);
Buffer.Format("0x%08X", m_pPrevRecord->GetFormID());
m_PreviousFormIDText.SetWindowText(Buffer);
}
UpdateCurrentRecord();
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::SetControlData()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - void UpdateCurrentRecord (void);
*
*=========================================================================*/
void CObSelectRecordDlg::UpdateCurrentRecord (void) {
CString Buffer;
CObIdRecord* pIdRecord;
//m_pCurrentRecord = m_RecordList.GetSelectedRecord();
m_CurrentEditorID.Empty();
if (m_pCurrentRecord == NULL) {
m_CurrentText.SetWindowText("");
m_CurrentFormIDText.SetWindowText("0x00000000");
}
else {
pIdRecord = ObCastClass(CObIdRecord, m_pCurrentRecord);
if (pIdRecord != NULL) m_CurrentEditorID = pIdRecord->GetEditorID();
Buffer.Format("%s", m_CurrentEditorID);
m_CurrentText.SetWindowText(Buffer);
Buffer.Format("0x%08X", m_pCurrentRecord->GetFormID());
m_CurrentFormIDText.SetWindowText(Buffer);
}
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::UpdateCurrentRecord()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Event - void OnChangeCurrentText ();
*
*=========================================================================*/
void CObSelectRecordDlg::OnChangeCurrentText() {
CString Buffer;
int Result;
int ListIndex;
Result = UpdateEditorID();
if (Result != m_EditorIDCheck) {
m_EditorIDCheck = Result;
m_CurrentText.RedrawWindow();
}
if (m_UpdateListOnChange) {
m_UpdateListOnChange = false;
m_CurrentText.GetWindowText(Buffer);
ListIndex = m_RecordList.FindEditorID(Buffer);
if (ListIndex >= 0) m_RecordList.SelectRecord(ListIndex);
/*
int StartSel;
int EndSel;
CObRecord* pRecord = m_RecordList.GetRecord(ListIndex);
CObIdRecord* pIdRecord = NULL;
if (pRecord != NULL) pIdRecord = ObCastClass(CObIdRecord, pRecord);
if (pIdRecord != NULL) {
m_CurrentText.GetSel(StartSel, EndSel);
m_CurrentText.SetWindowText(pIdRecord->GetEditorID());
m_CurrentText.SetSel(StartSel, -1);
} /*/
m_UpdateListOnChange = true;
}
}
/*===========================================================================
* End of Class Event CObSelectRecordDlg::OnChangeCurrentText()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Event - HBRUSH OnCtlColor (pDC, pWnd, nCtlColor);
*
*=========================================================================*/
HBRUSH CObSelectRecordDlg::OnCtlColor (CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
HBRUSH hBrush = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_EDIT && pWnd == &m_CurrentText) {
switch (m_EditorIDCheck) {
case OB_CHECKRESULT_NOCHANGE:
hBrush = CreateSolidBrush(RGB(255,255,255));
pDC->SetBkColor(RGB(255,255,255));
break;
case OB_CHECKRESULT_OK:
hBrush = CreateSolidBrush(RGB(204,255,204));
pDC->SetBkColor(RGB(204,255,204));
break;
case OB_CHECKRESULT_ERROR:
hBrush = CreateSolidBrush(RGB(255,204,204));
pDC->SetBkColor(RGB(255,204,204));
break;
}
}
return (hBrush);
}
/*===========================================================================
* End of Class Event CObSelectRecordDlg::OnCtlColor()
*=========================================================================*/
/*===========================================================================
*
* Class CObSelectRecordDlg Method - int UpdateEditorID (void);
*
*=========================================================================*/
int CObSelectRecordDlg::UpdateEditorID (void) {
CString Buffer;
CSString EditorID;
CObIdRecord* pIdRecord;
int ListIndex;
m_CurrentText.GetWindowText(Buffer);
EditorID = Buffer;
ObPrepareEditorID(EditorID);
if (EditorID.IsEmpty()) {
m_CurrentFormID = 0;
}
else {
pIdRecord = m_pRecordHandler->FindEditorID(EditorID);
if (pIdRecord == NULL) return (OB_CHECKRESULT_ERROR);
ListIndex = m_RecordList.FindRecord(pIdRecord);
if (ListIndex < 0) return (OB_CHECKRESULT_ERROR);
m_CurrentFormID = pIdRecord->GetFormID();
}
if (m_CurrentFormID == m_InitialFormID) return (OB_CHECKRESULT_NOCHANGE);
Buffer.Format(_T("0x%08X"), m_CurrentFormID);
m_CurrentFormIDText.SetWindowText(Buffer);
return (OB_CHECKRESULT_OK);
}
/*===========================================================================
* End of Class Method CObSelectRecordDlg::UpdateEditorID()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectActor (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectActor (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_ActorSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectActor()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectItemScript (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectItemScript (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_ItemScriptSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectItemScript()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectIngrediant (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectIngrediant (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_IngrediantSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectIngrediant()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectApparelEnchant (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectApparelEnchant (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_ApparelEnchantSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectApparelEnchant()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectScrollEnchant (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectScrollEnchant (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_ScrollEnchantSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectScrollEnchant()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectSound (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectSound (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_SoundSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectSound()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectStaffEnchant (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectStaffEnchant (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_StaffEnchantSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectStaffEnchant()
*=========================================================================*/
/*===========================================================================
*
* Function - bool ObSelectWeaponEnchant (EditorID, pRecordHandler);
*
*=========================================================================*/
bool ObSelectWeaponEnchant (CString& EditorID, CObRecordHandler* pRecordHandler) {
CObSelectRecordDlg Dlg;
int Result;
Dlg.SetInitialEditorID(EditorID);
Dlg.SetRecordHandler(pRecordHandler);
Dlg.SetDlgInfo(s_WeaponEnchantSelDlg);
Dlg.SetAllowNull(true);
Result = Dlg.DoModal();
if (Result != IDOK) return (false);
EditorID = Dlg.GetCurrentEditorID();
return (true);
}
/*===========================================================================
* End of Function ObSelectWeaponEnchant()
*=========================================================================*/