This repository was archived by the owner on Mar 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPropertyComboBar.cpp
More file actions
2034 lines (1907 loc) · 77.1 KB
/
PropertyComboBar.cpp
File metadata and controls
2034 lines (1907 loc) · 77.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
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
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
// PropertyComboBar.cpp : implementation file
//
#include "StdH.h"
#include "PropertyComboBar.h"
#ifdef _DEBUG
#undef new
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropertyComboBar dialog
BOOL CPropertyComboBar::Create( CWnd* pParentWnd, UINT nIDTemplate,
UINT nStyle, UINT nID, BOOL bChange)
{
if(!CDialogBar::Create(pParentWnd,nIDTemplate,nStyle,nID))
{
return FALSE;
}
m_Size = m_sizeDefault;
// subclass property combo box
m_PropertyComboBox.SubclassDlgItem( IDC_PROPERTYCOMBO, this);
// subclass enum combo box
m_EditEnumComboBox.SubclassDlgItem( IDC_EDIT_ENUM, this);
// subclass edit string control
m_EditStringCtrl.SubclassDlgItem( IDC_EDIT_STRING, this);
// subclass edit float control
m_EditFloatCtrl.SubclassDlgItem( IDC_EDIT_FLOAT, this);
// for andgle 3D
m_EditHeading.SubclassDlgItem( IDC_EDIT_HEADING, this);
m_EditPitch.SubclassDlgItem( IDC_EDIT_PITCH, this);
m_EditBanking.SubclassDlgItem( IDC_EDIT_BANKING, this);
// subclass edit BBox control
m_XCtrlAxisRadio.SubclassDlgItem( IDC_AXIS_X, this);
m_YCtrlAxisRadio.SubclassDlgItem( IDC_AXIS_Y, this);
m_ZCtrlAxisRadio.SubclassDlgItem( IDC_AXIS_Z, this);
m_EditBBoxMinCtrl.SubclassDlgItem( IDC_EDIT_BBOX_MIN, this);
m_EditBBoxMaxCtrl.SubclassDlgItem( IDC_EDIT_BBOX_MAX, this);
// subclass edit index control
m_EditIndexCtrl.SubclassDlgItem( IDC_EDIT_INDEX, this);
// subclass edit boolean control
m_EditBoolCtrl.SubclassDlgItem( IDC_EDIT_BOOL, this);
// subclass edit color control
m_EditColorCtrl.SetPickerType( CColoredButton::PT_MFC);
m_EditColorCtrl.SubclassDlgItem( IDC_EDIT_COLOR, this);
// subclass flag field property ctrl
m_ctrlEditFlags.SubclassDlgItem( ID_FLAGS_PROPERTY, this);
// subclass browse file control
m_BrowseFileCtrl.SubclassDlgItem( IDC_BROWSE_FILE, this);
// subclass difficulty spawn flags
m_EditEasySpawn.SubclassDlgItem( IDC_EASY, this);
m_EditNormalSpawn.SubclassDlgItem( IDC_NORMAL, this);
m_EditHardSpawn.SubclassDlgItem( IDC_HARD, this);
m_EditExtremeSpawn.SubclassDlgItem( IDC_EXTREME, this);
m_EditDifficulty_1.SubclassDlgItem( IDC_DIFFICULTY_1, this);
m_EditDifficulty_2.SubclassDlgItem( IDC_DIFFICULTY_2, this);
m_EditDifficulty_3.SubclassDlgItem( IDC_DIFFICULTY_3, this);
m_EditDifficulty_4.SubclassDlgItem( IDC_DIFFICULTY_4, this);
m_EditDifficulty_5.SubclassDlgItem( IDC_DIFFICULTY_5, this);
// subclass game mode spawn flags
m_EditSingleSpawn.SubclassDlgItem( IDC_SINGLE, this);
m_EditCooperativeSpawn.SubclassDlgItem( IDC_COOPERATIVE, this);
m_EditDeathMatchSpawn.SubclassDlgItem( IDC_DEATHMATCH, this);
m_EditGameMode_1.SubclassDlgItem( IDC_GAME_MODE_1, this);
m_EditGameMode_2.SubclassDlgItem( IDC_GAME_MODE_2, this);
m_EditGameMode_3.SubclassDlgItem( IDC_GAME_MODE_3, this);
m_EditGameMode_4.SubclassDlgItem( IDC_GAME_MODE_4, this);
m_EditGameMode_5.SubclassDlgItem( IDC_GAME_MODE_5, this);
m_EditGameMode_6.SubclassDlgItem( IDC_GAME_MODE_6, this);
// set dialog ptrs to controls
m_PropertyComboBox.SetDialogPtr( this);
m_EditEnumComboBox.SetDialogPtr( this);
m_EditStringCtrl.SetDialogPtr( this);
m_EditFloatCtrl.SetDialogPtr( this);
m_EditHeading.SetDialogPtr( this);
m_EditPitch.SetDialogPtr( this);
m_EditBanking.SetDialogPtr( this);
m_EditIndexCtrl.SetDialogPtr( this);
m_EditBBoxMinCtrl.SetDialogPtr( this);
m_EditBBoxMaxCtrl.SetDialogPtr( this);
m_XCtrlAxisRadio.SetDialogPtr( this);
m_YCtrlAxisRadio.SetDialogPtr( this);
m_ZCtrlAxisRadio.SetDialogPtr( this);
m_EditBoolCtrl.SetDialogPtr( this);
m_BrowseFileCtrl.SetDialogPtr( this);
m_EditEasySpawn.SetDialogPtr( this);
m_EditNormalSpawn.SetDialogPtr( this);
m_EditHardSpawn.SetDialogPtr( this);
m_EditExtremeSpawn.SetDialogPtr( this);
m_EditDifficulty_1.SetDialogPtr( this);
m_EditDifficulty_2.SetDialogPtr( this);
m_EditDifficulty_3.SetDialogPtr( this);
m_EditDifficulty_4.SetDialogPtr( this);
m_EditDifficulty_5.SetDialogPtr( this);
m_EditSingleSpawn.SetDialogPtr( this);
m_EditCooperativeSpawn.SetDialogPtr( this);
m_EditDeathMatchSpawn.SetDialogPtr( this);
m_EditGameMode_1.SetDialogPtr( this);
m_EditGameMode_2.SetDialogPtr( this);
m_EditGameMode_3.SetDialogPtr( this);
m_EditGameMode_4.SetDialogPtr( this);
m_EditGameMode_5.SetDialogPtr( this);
m_EditGameMode_6.SetDialogPtr( this);
m_ctrlEditFlags.SetDialogPtr( this);
// set font for properties combo
m_PropertyComboBox.SetFont(&theApp.m_Font);
// set font for enum combo
m_EditEnumComboBox.SetFont(&theApp.m_Font);
return TRUE;
}
BEGIN_MESSAGE_MAP(CPropertyComboBar, CDialogBar)
//{{AFX_MSG_MAP(CPropertyComboBar)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
ON_UPDATE_COMMAND_UI(IDC_BROWSE_FILE, OnUpdateBrowseFile)
ON_UPDATE_COMMAND_UI(IDC_NO_FILE, OnUpdateNoFile)
ON_UPDATE_COMMAND_UI(IDC_NO_TARGET, OnUpdateNoTarget)
ON_UPDATE_COMMAND_UI(IDC_EDIT_COLOR, OnUpdateEditColor)
ON_UPDATE_COMMAND_UI(ID_FLAGS_PROPERTY, OnUpdateEditFlags)
ON_COMMAND(IDC_NO_FILE, OnNoFile)
ON_COMMAND(IDC_NO_TARGET, OnNoTarget)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropertyComboBar message handlers
//--------------------------------------------------------------------------------------------
void CPropertyComboBar::SelectAxisRadio(CWnd *pwndToSelect)
{
// deselect all three axis radios
m_XCtrlAxisRadio.SetCheck( 0);
m_YCtrlAxisRadio.SetCheck( 0);
m_ZCtrlAxisRadio.SetCheck( 0);
// select right one
if( pwndToSelect == &m_XCtrlAxisRadio) {m_XCtrlAxisRadio.SetCheck( 1); m_iXYZAxis=1;};
if( pwndToSelect == &m_YCtrlAxisRadio) {m_YCtrlAxisRadio.SetCheck( 1); m_iXYZAxis=2;};
if( pwndToSelect == &m_ZCtrlAxisRadio) {m_ZCtrlAxisRadio.SetCheck( 1); m_iXYZAxis=3;};
}
void CPropertyComboBar::DoDataExchange(CDataExchange* pDX)
{
CWorldEditorDoc *pDoc = theApp.GetDocument();
if( pDoc == NULL)
{
return;
}
// if dialog is recieving data
if( pDX->m_bSaveAndValidate == FALSE)
{
SetIntersectingEntityClassName();
SetIntersectingFileName();
// set spawn flags...
// obtain selected property ID ptr
CPropertyID *ppidProperty = GetSelectedProperty();
// if there is valid property selected
if( ppidProperty != NULL)
{
// reset selection entities spawn on and off masks
ULONG ulSpawnOn = MAX_ULONG;
ULONG ulSpawnOff = MAX_ULONG;
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// intersect current mask with spawn mask of all selected entities
ulSpawnOn &= iten->GetSpawnFlags();
ulSpawnOff&= ~iten->GetSpawnFlags();
}
#define SET_SPAWN_FLAG( flag, ctrl) \
if((ulSpawnOn & (flag)) && !(ulSpawnOff & (flag))) ctrl.SetCheck( 1); \
else if(!(ulSpawnOn & (flag)) && (ulSpawnOff & (flag))) ctrl.SetCheck( 0); \
else ctrl.SetCheck( 2);
// set states of all spawn flags using calculated selected entities masks
SET_SPAWN_FLAG( SPF_EASY, m_EditEasySpawn);
SET_SPAWN_FLAG( SPF_NORMAL, m_EditNormalSpawn);
SET_SPAWN_FLAG( SPF_HARD, m_EditHardSpawn);
SET_SPAWN_FLAG( SPF_EXTREME, m_EditExtremeSpawn);
SET_SPAWN_FLAG( SPF_EXTREME<<1, m_EditDifficulty_1);
SET_SPAWN_FLAG( SPF_EXTREME<<2, m_EditDifficulty_2);
SET_SPAWN_FLAG( SPF_EXTREME<<3, m_EditDifficulty_3);
SET_SPAWN_FLAG( SPF_EXTREME<<4, m_EditDifficulty_4);
SET_SPAWN_FLAG( SPF_EXTREME<<5, m_EditDifficulty_5);
SET_SPAWN_FLAG( SPF_SINGLEPLAYER, m_EditSingleSpawn);
SET_SPAWN_FLAG( SPF_DEATHMATCH, m_EditDeathMatchSpawn);
SET_SPAWN_FLAG( SPF_COOPERATIVE, m_EditCooperativeSpawn);
SET_SPAWN_FLAG( SPF_COOPERATIVE<<1, m_EditGameMode_1);
SET_SPAWN_FLAG( SPF_COOPERATIVE<<2, m_EditGameMode_2);
SET_SPAWN_FLAG( SPF_COOPERATIVE<<3, m_EditGameMode_3);
SET_SPAWN_FLAG( SPF_COOPERATIVE<<4, m_EditGameMode_4);
SET_SPAWN_FLAG( SPF_COOPERATIVE<<5, m_EditGameMode_5);
SET_SPAWN_FLAG( SPF_COOPERATIVE<<6, m_EditGameMode_6);
}
}
DDX_Text(pDX, IDC_FLOAT_RANGE_T, m_strFloatRange);
DDX_Text(pDX, IDC_INDEX_RANGE_T, m_strIndexRange);
DDX_Text(pDX, IDC_CHOOSE_COLOR_T, m_strChooseColor);
DDX_Text(pDX, IDC_FILE_NAME_T, m_strFileName);
DDX_Text(pDX, IDC_ENTITY_CLASS, m_strEntityClass);
DDX_Text(pDX, IDC_ENTITY_NAME, m_strEntityName);
DDX_Text(pDX, IDC_ENTITY_DESCRIPTION, m_strEntityDescription);
if( m_EditBBoxMinCtrl.IsWindowVisible())
{
DDX_SkyFloat(pDX, IDC_EDIT_BBOX_MIN, m_fEditingBBoxMin);
DDX_SkyFloat(pDX, IDC_EDIT_BBOX_MAX, m_fEditingBBoxMax);
}
if( m_EditStringCtrl.IsWindowVisible())
{
DDX_Text(pDX, IDC_EDIT_STRING, m_strEditingString);
}
if( m_EditFloatCtrl.IsWindowVisible())
{
DDX_SkyFloat(pDX, IDC_EDIT_FLOAT, m_fEditingFloat);
}
if( m_EditHeading.IsWindowVisible())
{
DDX_SkyFloat(pDX, IDC_EDIT_HEADING, m_fEditingHeading);
}
if( m_EditPitch.IsWindowVisible())
{
DDX_SkyFloat(pDX, IDC_EDIT_PITCH, m_fEditingPitch);
}
if( m_EditBanking.IsWindowVisible())
{
DDX_SkyFloat(pDX, IDC_EDIT_BANKING, m_fEditingBanking);
}
if( m_EditIndexCtrl.IsWindowVisible())
{
DDX_Text(pDX, IDC_EDIT_INDEX, m_iEditingIndex);
}
// if dialog is giving data
if( pDX->m_bSaveAndValidate != FALSE)
{
// obtain selected property ID ptr
CPropertyID *ppidProperty = GetSelectedProperty();
// if there is valid property selected
if( ppidProperty != NULL)
{
// see type of changing property
switch( ppidProperty->pid_eptType)
{
// if we are changing flag field
case CEntityProperty::EPT_FLAGS:
{
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new flag value
m_ctrlEditFlags.ApplyChange( ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, ULONG));
// apply new entity settings
iten->Initialize();
}
break;
}
// if we are changing enum property
case CEntityProperty::EPT_ENUM:
{
// get currently selected combo member
INDEX iSelectedComboMember = m_EditEnumComboBox.GetCurSel();
// it must exist
if( iSelectedComboMember == CB_ERR) return;
// get enum ID to be set for all entities
INDEX iSelectedEnumID = m_EditEnumComboBox.GetItemData(iSelectedComboMember);
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new enum value
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, INDEX) = iSelectedEnumID;
// apply new entity settings
iten->Initialize();
}
break;
}
case CEntityProperty::EPT_ANIMATION:
{
// get currently selected combo member
INDEX iSelectedComboMember = m_EditEnumComboBox.GetCurSel();
// it must exist
if( iSelectedComboMember == CB_ERR) return;
// get animation to be set for all entities
INDEX iSelectedAnimation = m_EditEnumComboBox.GetItemData(iSelectedComboMember);
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new animation
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, INDEX) = iSelectedAnimation;
// apply new entity settings
iten->Initialize();
}
break;
}
// if we are changing illumination type property
case CEntityProperty::EPT_ILLUMINATIONTYPE:
{
// get currently selected combo member
INDEX iSelectedComboMember = m_EditEnumComboBox.GetCurSel();
// it must exist
if( iSelectedComboMember == CB_ERR) return;
// get illumination type to be set for all entities
INDEX iIlluminationType = m_EditEnumComboBox.GetItemData(iSelectedComboMember);
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new illumination type value
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, INDEX) = iIlluminationType;
// apply new entity settings
iten->Initialize();
}
break;
}
// if we are changing string property
case CEntityProperty::EPT_STRING:
case CEntityProperty::EPT_STRINGTRANS:
{
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new string
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, CTString) = MfcStringToCT(m_strEditingString);
// apply new entity settings
iten->Initialize();
}
// mark that document changed so that OnIdle on CSG destination combo would
// refresh combo entries (because we could be changing world name)
pDoc->m_chDocument.MarkChanged();
break;
}
// if we are changing float, range or angle property
case CEntityProperty::EPT_FLOAT:
case CEntityProperty::EPT_RANGE:
case CEntityProperty::EPT_ANGLE:
case CEntityProperty::EPT_ANGLE3D:
{
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// discard old entity settings
iten->End();
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// if we are editing angle property
if( ppidProperty->pid_eptType == CEntityProperty::EPT_ANGLE3D)
{
// set new angle 3d
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, ANGLE3D) =
ANGLE3D(AngleDeg(m_fEditingHeading), AngleDeg(m_fEditingPitch),
AngleDeg(m_fEditingBanking));
}
else if(ppidProperty->pid_eptType == CEntityProperty::EPT_ANGLE)
{
// set new angle
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, FLOAT) = AngleDeg(m_fEditingFloat);
}
else
{
// set new float or range
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, FLOAT) = m_fEditingFloat;
}
// apply new entity settings
iten->Initialize();
}
break;
}
case CEntityProperty::EPT_FLOATAABBOX3D:
{
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// get old (pre-changed) value for bounding box
FLOATaabbox3D bboxOld = ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset,
FLOATaabbox3D);
// get its min and max vectors
FLOAT3D vMin = bboxOld.Min();
FLOAT3D vMax = bboxOld.Max();
// set new min and max bbox values for currently selected axis
vMin( m_iXYZAxis) = m_fEditingBBoxMin;
vMax( m_iXYZAxis) = m_fEditingBBoxMax;
// create new bbox and set it into property
FLOATaabbox3D bboxNew( vMin, vMax);
// discard old entity settings
iten->End();
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, FLOATaabbox3D) = bboxNew;
// apply new entity settings
iten->Initialize();
}
break;
}
case CEntityProperty::EPT_INDEX:
{
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
INDEX iNewValue = m_iEditingIndex;
// discard old entity settings
iten->End();
// set new index
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, INDEX) = iNewValue;
// apply new entity settings
iten->Initialize();
}
break;
}
// if we are changing file name property
case CEntityProperty::EPT_FILENAME:
{
// file name changing function is done inside CBrowseFile.cpp
break;
}
case CEntityProperty::EPT_COLOR:
{
break;
}
// if we are changing bool property
case CEntityProperty::EPT_BOOL:
{
// get state of check box
INDEX iCheckBox = m_EditBoolCtrl.GetCheck();
// must be 0 or 1
if( iCheckBox != 2)
{
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new boolean value
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, BOOL) = iCheckBox;
// apply new entity settings
iten->Initialize();
}
}
break;
}
// if we are changing entity ptr property
case CEntityProperty::EPT_ENTITYPTR:
case CEntityProperty::EPT_PARENT:
{
// get currently selected combo member
INDEX iSelectedComboMember = m_EditEnumComboBox.GetCurSel();
// it must exist
if( iSelectedComboMember == CB_ERR) return;
// get entity ptr to be set for all entities
CEntity *penEntity = (CEntity *)m_EditEnumComboBox.GetItemData(iSelectedComboMember);
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
if( ppidProperty->pid_eptType == CEntityProperty::EPT_PARENT)
{
iten->SetParent( penEntity);
}
else
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new entity ptr value
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, CEntityPointer) = penEntity;
// apply new entity settings
iten->Initialize();
}
}
break;
}
// if we are changing entity ptr property
case CEntityProperty::EPT_SPAWNFLAGS:
{
// obtain spawn on and off masks
ULONG ulBitsToClear = MAX_ULONG;
ULONG ulBitsToSet = 0;
#define GET_SPAWN_MASKS( flag, ctrl) \
if( ctrl.GetCheck() == 0) ulBitsToClear &= ~(flag); \
if( ctrl.GetCheck() == 1) ulBitsToSet |= (flag);
// look at spawn checks and create masks of bits to set and to clear
GET_SPAWN_MASKS( SPF_EASY, m_EditEasySpawn);
GET_SPAWN_MASKS( SPF_NORMAL, m_EditNormalSpawn);
GET_SPAWN_MASKS( SPF_HARD, m_EditHardSpawn);
GET_SPAWN_MASKS( SPF_EXTREME, m_EditExtremeSpawn);
GET_SPAWN_MASKS( SPF_EXTREME<<1, m_EditDifficulty_1);
GET_SPAWN_MASKS( SPF_EXTREME<<2, m_EditDifficulty_2);
GET_SPAWN_MASKS( SPF_EXTREME<<3, m_EditDifficulty_3);
GET_SPAWN_MASKS( SPF_EXTREME<<4, m_EditDifficulty_4);
GET_SPAWN_MASKS( SPF_EXTREME<<5, m_EditDifficulty_5);
GET_SPAWN_MASKS( SPF_SINGLEPLAYER, m_EditSingleSpawn);
GET_SPAWN_MASKS( SPF_DEATHMATCH, m_EditDeathMatchSpawn);
GET_SPAWN_MASKS( SPF_COOPERATIVE, m_EditCooperativeSpawn);
GET_SPAWN_MASKS( SPF_COOPERATIVE<<1, m_EditGameMode_1);
GET_SPAWN_MASKS( SPF_COOPERATIVE<<2, m_EditGameMode_2);
GET_SPAWN_MASKS( SPF_COOPERATIVE<<3, m_EditGameMode_3);
GET_SPAWN_MASKS( SPF_COOPERATIVE<<4, m_EditGameMode_4);
GET_SPAWN_MASKS( SPF_COOPERATIVE<<5, m_EditGameMode_5);
GET_SPAWN_MASKS( SPF_COOPERATIVE<<6, m_EditGameMode_6);
// for each of the selected entities set spawn flags
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// clear and set curently selected spawn flags to all selected entities
iten->SetSpawnFlags(iten->GetSpawnFlags() & ulBitsToClear);
iten->SetSpawnFlags(iten->GetSpawnFlags() | ulBitsToSet);
}
break;
}
default:
{
ASSERTALWAYS("Unknown property type");
}
}
// mark that document is changed
pDoc->SetModifiedFlag( TRUE);
// redraw all views
pDoc->UpdateAllViews( NULL);
}
}
CDialogBar::DoDataExchange(pDX);
}
//--------------------------------------------------------------------------------------------
CSize CPropertyComboBar::CalcDynamicLayout(int nLength, DWORD nMode)
{
CSize csResult;
// Return default if it is being docked or floated
if ((nMode & LM_VERTDOCK) || (nMode & LM_HORZDOCK))
{
if (nMode & LM_STRETCH) // if not docked stretch to fit
{
csResult = CSize((nMode & LM_HORZ) ? 32767 : m_Size.cx,
(nMode & LM_HORZ) ? m_Size.cy : 32767);
}
else
{
csResult = m_Size;
}
}
else if (nMode & LM_MRUWIDTH)
{
csResult = m_Size;
}
// In all other cases, accept the dynamic length
else
{
if (nMode & LM_LENGTHY)
{
// Note that we don't change m_Size.cy because we disabled vertical sizing
csResult = CSize( m_Size.cx, m_Size.cy = nLength);
}
else
{
csResult = CSize( m_Size.cx = nLength, m_Size.cy);
}
}
#define CTRLS_LINE_H 22
#define CTRLS_RW 40
#define CTRLS_RH 44
#define CTRLS_YS 38+CTRLS_RH
#define CTRLS_YE (CTRLS_YS+CTRLS_LINE_H)
#define CTRLS_YRS 28+CTRLS_RH
#define CTRLS_YRE (CTRLS_YRS+CTRLS_RH)
#define CTRLS_YTS 44+CTRLS_RH
#define CTRLS_YTE (CTRLS_YTS+CTRLS_LINE_H)
#define CTRLS_YCMRS CTRLS_YS-4 // y color radio mode start
#define CTRLS_YCSS CTRLS_YCMRS+26 // y color sliders start
#define CTRLS_YNTS 64+CTRLS_RH // no target button
#define CTRLS_YNTE (CTRLS_YNTS+CTRLS_LINE_H)
#define CTRLS_BUTTONW 40
// set entity class text position
GetDlgItem( IDC_ENTITY_CLASS)->MoveWindow( CRect( 8, 4, csResult.cx - 8, 4+14));
// set entity name text position
GetDlgItem( IDC_ENTITY_NAME)->MoveWindow( CRect( 8, 18, csResult.cx - 8, 18+14));
// set entity description text position
GetDlgItem( IDC_ENTITY_DESCRIPTION)->MoveWindow( CRect( 8, 32, csResult.cx - 8, 32+14));
// set property combo size and position
m_PropertyComboBox.MoveWindow( CRect( 8, 5+CTRLS_RH, csResult.cx - 8, 120+CTRLS_RH));
// set enum combo size and position
m_EditEnumComboBox.MoveWindow( CRect( 8, CTRLS_YS, csResult.cx - 8, 120+CTRLS_RH));
// set edit string control size and position
m_EditStringCtrl.MoveWindow( CRect( 8, CTRLS_YS, csResult.cx - 8, CTRLS_YE));
// set edit float control size and position
m_EditFloatCtrl.MoveWindow( CRect( csResult.cx/2, CTRLS_YS, csResult.cx - 8, CTRLS_YE));
// set edit BBox controls size and position
GetDlgItem( IDC_AXIS_X)->MoveWindow( CRect( csResult.cx/2-CTRLS_RW*3/2, CTRLS_YRS,
csResult.cx/2-CTRLS_RW/2, CTRLS_YRE));
GetDlgItem( IDC_AXIS_Y)->MoveWindow( CRect( csResult.cx/2-CTRLS_RW/2, CTRLS_YRS,
csResult.cx/2+CTRLS_RW/2, CTRLS_YRE) );
GetDlgItem( IDC_AXIS_Z)->MoveWindow( CRect( csResult.cx/2+CTRLS_RW/2, CTRLS_YRS,
csResult.cx/2+CTRLS_RW*3/2, CTRLS_YRE) );
m_EditBBoxMinCtrl.MoveWindow( CRect( 8, CTRLS_YRE,
csResult.cx/2-8, CTRLS_YRE+CTRLS_LINE_H) );
m_EditBBoxMaxCtrl.MoveWindow( CRect( csResult.cx/2+8, CTRLS_YRE,
csResult.cx-8, CTRLS_YRE+CTRLS_LINE_H) );
// select x axis by default for editing bbox
SelectAxisRadio( &m_XCtrlAxisRadio);
// set edit index control size and position
m_EditIndexCtrl.MoveWindow( CRect( csResult.cx/2, CTRLS_YS, csResult.cx - 8, CTRLS_YE));
// set float range description message size and position
GetDlgItem( IDC_FLOAT_RANGE_T)->MoveWindow( CRect( 8, CTRLS_YTS, csResult.cx/2, CTRLS_YTE));
// set index range description message size and position
GetDlgItem( IDC_INDEX_RANGE_T)->MoveWindow( CRect( 8, CTRLS_YTS, csResult.cx/2, csResult.cy));
// set edit boolean control size and position
m_EditBoolCtrl.MoveWindow( CRect( 8, CTRLS_YS, csResult.cx - 8, CTRLS_YE));
// set float range description message size and position
GetDlgItem( IDC_ANGLE3D_T)->MoveWindow( CRect( 8, CTRLS_YTS+4, csResult.cx/4-4, CTRLS_YTE+4));
GetDlgItem( IDC_EDIT_HEADING)->MoveWindow( CRect( csResult.cx/4-4, CTRLS_YTS, csResult.cx/4*2-4, CTRLS_YTE));
GetDlgItem( IDC_EDIT_PITCH)->MoveWindow( CRect( csResult.cx/4*2-4, CTRLS_YTS, csResult.cx/4*3-4, CTRLS_YTE));
GetDlgItem( IDC_EDIT_BANKING)->MoveWindow( CRect( csResult.cx/4*3-4, CTRLS_YTS, csResult.cx-4, CTRLS_YTE));
// set size and position of color picker
m_EditColorCtrl.MoveWindow( CRect( 8, CTRLS_YCMRS, 128, CTRLS_YCMRS+(CTRLS_LINE_H*1.25)));
// set size and position of flags array
m_ctrlEditFlags.MoveWindow( CRect( 8, CTRLS_YCMRS+12, csResult.cx-4, CTRLS_YCMRS+(CTRLS_LINE_H*1.0)+12));
// set color description message size and position
GetDlgItem( IDC_CHOOSE_COLOR_T)->MoveWindow( CRect( 4, CTRLS_YCSS-4, 16, csResult.cy-4));
// set browse file button size and position
m_BrowseFileCtrl.MoveWindow( CRect( csResult.cx-CTRLS_BUTTONW-16, CTRLS_YS, csResult.cx - 24, CTRLS_YE));
GetDlgItem( IDC_NO_FILE)->MoveWindow( CRect( csResult.cx-24, CTRLS_YS, csResult.cx - 8, CTRLS_YE));
GetDlgItem( IDC_NO_TARGET)->MoveWindow( CRect( 8, CTRLS_YNTS, csResult.cx - 8, CTRLS_YNTE));
// set browse file description message size and position
GetDlgItem( IDC_FILE_NAME_T)->MoveWindow( CRect( 8, CTRLS_YTS, csResult.cx - CTRLS_BUTTONW-16, CTRLS_YTE));
return csResult;
}
CPropertyID *CPropertyComboBar::GetSelectedProperty()
{
INDEX iSelectedProperty = m_PropertyComboBox.GetCurSel();
if( (iSelectedProperty == CB_ERR) || ( iSelectedProperty < 0) )
{
//ASSERTALWAYS( "GetSelectedProperty() must not be called if there are no joined properties");
return NULL;
}
CPropertyID *ppidProperty = (CPropertyID *)
m_PropertyComboBox.GetItemData( iSelectedProperty);
ASSERT( ppidProperty != (CPropertyID *) -1);
return ppidProperty;
}
void CPropertyComboBar::SetFirstValidEmptyTargetProperty(CEntity *penTarget)
{
CWorldEditorDoc *pDoc = theApp.GetDocument();
if( pDoc == NULL) return;
for( INDEX iItem=0; iItem<m_PropertyComboBox.GetCount(); iItem++)
{
CPropertyID *ppidProperty = (CPropertyID *) m_PropertyComboBox.GetItemData( iItem);
ASSERT( ppidProperty != (CPropertyID *) -1);
if( ppidProperty->pid_eptType == CEntityProperty::EPT_ENTITYPTR)
{
// for each of the selected entities
{FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// check that all entities with this property target NULL and that supposed target is valid
CEntity *penOldTarget = ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, CEntityPointer);
BOOL bValidTarget = iten->IsTargetValid( penpProperty->ep_slOffset, penTarget);
// if this ptr is already set
if( penOldTarget==penTarget)
{
// don't do anything
return;
}
// stop checking if ptr isn't NULL or if not valid target
if( penOldTarget!=NULL || !bValidTarget)
{
continue;
}
// for each of the selected entities
{FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// discard old entity settings
iten->End();
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// set clicked entity as one that selected entity points to
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, CEntityPointer) = penTarget;
// apply new entity settings
iten->Initialize();
}}
m_PropertyComboBox.SetCurSel(iItem);
m_PropertyComboBox.SelectProperty();
pDoc->m_chSelections.MarkChanged();
return;
}}
}
}
}
void CPropertyComboBar::SelectPreviousEmptyTarget(void)
{
CircleTargetProperties( -1, TRUE);
}
void CPropertyComboBar::SelectPreviousProperty(void)
{
CircleTargetProperties( -1, FALSE);
}
void CPropertyComboBar::SelectNextEmptyTarget(void)
{
CircleTargetProperties( 1, TRUE);
}
void CPropertyComboBar::SelectNextProperty(void)
{
CircleTargetProperties( 1, FALSE);
}
void CPropertyComboBar::CircleTargetProperties(INDEX iDirection, BOOL bOnlyEmptyTargets)
{
CWorldEditorDoc *pDoc = theApp.GetDocument();
if( pDoc == NULL)
{
return;
}
INDEX ctProperties = m_PropertyComboBox.GetCount();
// if no properties
if( ctProperties == 0) return;
// if selected is invalid
INDEX iSelectedProperty = m_PropertyComboBox.GetCurSel();
if( (iSelectedProperty == CB_ERR) || ( iSelectedProperty < 0) ) return;
// set invalid result
INDEX iToSelect = -1;
// browse trough entities
for( INDEX iItem=1; iItem<ctProperties; iItem++)
{
// we will use next/previos item for selecting
INDEX iToTest = (iSelectedProperty+ctProperties+iDirection*iItem)%ctProperties;
// if there is valid property selected
CPropertyID *ppidProperty = (CPropertyID *) m_PropertyComboBox.GetItemData( iToTest);
if( ppidProperty == NULL)
{
ASSERTALWAYS("Null property found!");
return;
}
// if null-ptr target is requested
if( bOnlyEmptyTargets)
{
// if this is entity pointer property
if( ppidProperty->pid_eptType == CEntityProperty::EPT_ENTITYPTR)
{
// obtain property ptr
CEntity *pen = pDoc->m_selEntitySelection.GetFirstInSelection();
CEntityProperty *penpProperty = ppidProperty->pid_penpProperty;
CEntity *penTarget = ENTITYPROPERTY( pen, penpProperty->ep_slOffset, CEntityPointer);
// if it is NULL
if( penTarget == NULL)
{
// set this property as one to select
iToSelect = iToTest;
continue;
}
}
}
else
{
// if null-ptr target isn't requested, each property is valid
iToSelect = iToTest;
continue;
}
}
// if we have valid result
if( iToSelect != -1)
{
// select it
m_PropertyComboBox.SetCurSel( iToSelect);
m_PropertyComboBox.SelectProperty();
}
}
void CPropertyComboBar::SetIntersectingFileName()
{
if( m_BrowseFileCtrl.IsWindowVisible())
{
// get entity selection's intesecting file name
CTFileName fnIntersectingFile = m_BrowseFileCtrl.GetIntersectingFile();
if( fnIntersectingFile != "")
{
m_strFileName = "...\\" + fnIntersectingFile.FileName() + fnIntersectingFile.FileExt();
}
else
{
m_strFileName = "";
}
}
}
void CPropertyComboBar::SetColorPropertyToEntities( COLOR colNewColor)
{
CWorldEditorDoc *pDoc = theApp.GetDocument();
// obtain curently selected property ID
CPropertyID *ppidProperty = GetSelectedProperty();
if( ppidProperty == NULL) return;
// change curently selected color property in the selected entities
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// discard old entity settings
iten->End();
// set new color value
ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, COLOR) = colNewColor;
// apply new entity settings
iten->Initialize();
}
// mark that document is changed
pDoc->SetModifiedFlag( TRUE);
}
BOOL CPropertyComboBar::OnIdle(LONG lCount)
{
CWorldEditorDoc *pDoc = theApp.GetDocument();
m_PropertyComboBox.OnIdle( lCount);
// if we are curently changing color
if( m_EditColorCtrl.IsWindowVisible())
{
COLOR colCurrentColor = m_EditColorCtrl.GetColor();
if( colCurrentColor != m_colLastColor)
{
SetColorPropertyToEntities( colCurrentColor);
m_colLastColor = colCurrentColor;
// update all views
pDoc->UpdateAllViews( NULL);
}
}
return TRUE;
}
/*
* Arranges (using show/hide) controls depending upon editing property type
*/
void CPropertyComboBar::ArrangeControls()
{
// array to receive description message
char strMessage[ 128];
// spawn flags are grayed
BOOL bEnableSpawn = FALSE;
// mark all controls for hiding
int iEnum = SW_HIDE;
int iString = SW_HIDE;
int iFloat = SW_HIDE;
int iBBox = SW_HIDE;
int iIndex = SW_HIDE;
int iBool = SW_HIDE;
int iColor = SW_HIDE;
int iBrowse = SW_HIDE;
int iX = SW_HIDE;
int iNoTarget = SW_HIDE;
int iFloatRangeText = SW_HIDE;
int iAngle3D = SW_HIDE;
int iIndexRangeText = SW_HIDE;
int iChooseColorText = SW_HIDE;
int iFileNameText = SW_HIDE;
int iFlags = SW_HIDE;
// get active document
CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
// if view does not exist, return
if( pDoc != NULL)
{
m_strFloatRange = "";
m_strChooseColor = "";
m_strFileName = "";
// obtain selected property ID ptr
INDEX iSelectedProperty = m_PropertyComboBox.GetCurSel();
CPropertyID *ppidProperty = (CPropertyID *) m_PropertyComboBox.GetItemData( iSelectedProperty);
// if there is valid property selected
if( ppidProperty != NULL)
{
// show controls acording to property type
switch( ppidProperty->pid_eptType)
{
case CEntityProperty::EPT_FLAGS:
{
iFlags = SW_SHOW;
CEntity *pen = pDoc->m_selEntitySelection.GetFirstInSelection();
CEntityProperty *penpProperty = pen->PropertyForName( ppidProperty->pid_strName);
m_ctrlEditFlags.SetFlags( ENTITYPROPERTY( pen, penpProperty->ep_slOffset, ULONG));
// obtain enum property description object
CEntityPropertyEnumType *epEnum = penpProperty->ep_pepetEnumType;
// create mask of editable bits
ULONG ulEditable=0;
// for all enumerated members
for( INDEX iEnum = 0; iEnum<epEnum->epet_ctValues; iEnum++)
{
if( epEnum->epet_aepevValues[ iEnum].epev_strName!="")
{
ulEditable|=(1UL)<<epEnum->epet_aepevValues[ iEnum].epev_iValue;
CTString strBitName=epEnum->epet_aepevValues[ iEnum].epev_strName;
m_ctrlEditFlags.SetBitDescription(iEnum, strBitName);
}
}
m_ctrlEditFlags.SetEditableMask(ulEditable);
// for each of the selected entities
FOREACHINDYNAMICCONTAINER(pDoc->m_selEntitySelection, CEntity, iten)
{
// obtain property ptr
CEntityProperty *penpProperty = iten->PropertyForName( ppidProperty->pid_strName);
// it is, get string as one that others will compare with
m_ctrlEditFlags.MergeFlags( ENTITYPROPERTY( &*iten, penpProperty->ep_slOffset, ULONG));
}
break;
}
case CEntityProperty::EPT_ENUM:
case CEntityProperty::EPT_ENTITYPTR:
case CEntityProperty::EPT_PARENT:
case CEntityProperty::EPT_ANIMATION:
case CEntityProperty::EPT_ILLUMINATIONTYPE:
{
// obtain property ptr
CEntityProperty *penpProperty = ppidProperty->pid_penpProperty;
// remove all combo entries
m_EditEnumComboBox.ResetContent();
// combo control is to be shown
iEnum = SW_SHOW;
// for enum type of property
if( ppidProperty->pid_eptType == CEntityProperty::EPT_ENUM)
{
// obtain enum property description object
CEntityPropertyEnumType *epEnum = penpProperty->ep_pepetEnumType;