forked from CnCNet/WorldAlteringEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriggersWindow.cs
More file actions
2328 lines (1920 loc) · 105 KB
/
TriggersWindow.cs
File metadata and controls
2328 lines (1920 loc) · 105 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
using Microsoft.Xna.Framework;
using Rampastring.Tools;
using Rampastring.XNAUI;
using Rampastring.XNAUI.XNAControls;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using TSMapEditor.CCEngine;
using TSMapEditor.Models;
using TSMapEditor.Models.Enums;
using TSMapEditor.Rendering;
using TSMapEditor.UI.Controls;
using TSMapEditor.UI.CursorActions;
namespace TSMapEditor.UI.Windows
{
public enum TriggerSortMode
{
ID,
Name,
Color,
ColorThenName,
}
public class TriggersWindow : INItializableWindow
{
public TriggersWindow(WindowManager windowManager, Map map, EditorState editorState, ICursorActionTarget cursorActionTarget) : base(windowManager)
{
this.map = map;
this.editorState = editorState;
this.cursorActionTarget = cursorActionTarget;
placeCellTagCursorAction = new PlaceCellTagCursorAction(cursorActionTarget);
changeAttachedTagCursorAction = new ChangeAttachedTagCursorAction(cursorActionTarget);
}
public event EventHandler<TeamTypeEventArgs> TeamTypeOpened;
private readonly Map map;
private readonly ICursorActionTarget cursorActionTarget;
private readonly PlaceCellTagCursorAction placeCellTagCursorAction;
private readonly ChangeAttachedTagCursorAction changeAttachedTagCursorAction;
private readonly EditorState editorState;
private readonly TriggerParamType[] supportedGoToSourceTriggerParamTypes =
{
TriggerParamType.Trigger,
TriggerParamType.TeamType,
TriggerParamType.Waypoint,
TriggerParamType.WaypointZZ
};
private XNADropDown ddActions;
// Trigger list
private EditorListBox lbTriggers;
private EditorSuggestionTextBox tbFilter;
// General trigger settings
private EditorTextBox tbName;
private XNADropDown ddHouseType;
private XNADropDown ddType;
private EditorPopUpSelector selAttachedTrigger;
private XNADropDown ddTriggerColor;
private XNACheckBox chkDisabled;
private XNACheckBox chkEasy;
private XNACheckBox chkMedium;
private XNACheckBox chkHard;
// Events
private EditorListBox lbEvents;
private EditorPopUpSelector selEventType;
private EditorDescriptionPanel panelEventDescription;
private EditorListBox lbEventParameters;
private EditorTextBox tbEventParameterValue;
private XNAContextMenu ctxEventParameterPresetValues;
// Actions
private EditorListBox lbActions;
private EditorPopUpSelector selActionType;
private EditorDescriptionPanel panelActionDescription;
private EditorListBox lbActionParameters;
private EditorTextBox tbActionParameterValue;
private EditorButton btnActionGoToTarget;
private XNAContextMenu ctxActionParameterPresetValues;
private SelectEventWindow selectEventWindow;
private SelectActionWindow selectActionWindow;
private SelectAnimationWindow selectAnimationWindow;
private SelectBuildingTypeWindow selectBuildingTypeWindow;
private SelectTeamTypeWindow selectTeamTypeWindow;
private SelectTriggerWindow selectTriggerWindow;
private SelectGlobalVariableWindow selectGlobalVariableWindow;
private SelectLocalVariableWindow selectLocalVariableWindow;
private SelectHouseWindow selectHouseWindow;
private SelectHouseTypeWindow selectHouseTypeWindow;
private SelectTutorialLineWindow selectTutorialLineWindow;
private SelectThemeWindow selectThemeWindow;
private SelectTechnoTypeWindow selectTechnoTypeWindow;
private SelectTagWindow selectTagWindow;
private SelectStringWindow selectStringWindow;
private SelectSpeechWindow selectSpeechWindow;
private SelectSoundWindow selectSoundWindow;
private SelectParticleSystemTypeWindow selectParticleSystemTypeWindow;
private XNAContextMenu actionContextMenu;
private XNAContextMenu eventContextMenu;
private Trigger editedTrigger;
/// <summary>
/// Used to determine what we should do when the trigger selection window closes.
/// (apply selected trigger to a parameter for an action or attach selected trigger to our trigger)
/// </summary>
private bool isAttachingTrigger;
private TriggerSortMode _triggerSortMode;
private TriggerSortMode TriggerSortMode
{
get => _triggerSortMode;
set
{
if (value != _triggerSortMode)
{
_triggerSortMode = value;
ListTriggers();
}
}
}
public override void Initialize()
{
Name = nameof(TriggersWindow);
base.Initialize();
lbTriggers = FindChild<EditorListBox>(nameof(lbTriggers));
tbName = FindChild<EditorTextBox>(nameof(tbName));
tbName.AllowComma = false;
tbFilter = FindChild<EditorSuggestionTextBox>(nameof(tbFilter));
tbFilter.TextChanged += TbFilter_TextChanged;
ddHouseType = FindChild<XNADropDown>(nameof(ddHouseType));
ddType = FindChild<XNADropDown>(nameof(ddType));
selAttachedTrigger = FindChild<EditorPopUpSelector>(nameof(selAttachedTrigger));
chkDisabled = FindChild<XNACheckBox>(nameof(chkDisabled));
chkEasy = FindChild<XNACheckBox>(nameof(chkEasy));
chkMedium = FindChild<XNACheckBox>(nameof(chkMedium));
chkHard = FindChild<XNACheckBox>(nameof(chkHard));
// Init color dropdown options
ddTriggerColor = FindChild<XNADropDown>(nameof(ddTriggerColor));
ddTriggerColor.AddItem("None");
Array.ForEach(Trigger.SupportedColors, sc =>
{
ddTriggerColor.AddItem(sc.Name, sc.Value);
});
lbEvents = FindChild<EditorListBox>(nameof(lbEvents));
selEventType = FindChild<EditorPopUpSelector>(nameof(selEventType));
panelEventDescription = FindChild<EditorDescriptionPanel>(nameof(panelEventDescription));
lbEventParameters = FindChild<EditorListBox>(nameof(lbEventParameters));
tbEventParameterValue = FindChild<EditorTextBox>(nameof(tbEventParameterValue));
btnActionGoToTarget = FindChild<EditorButton>(nameof(btnActionGoToTarget));
ctxEventParameterPresetValues = new XNAContextMenu(WindowManager);
ctxEventParameterPresetValues.Name = nameof(ctxEventParameterPresetValues);
ctxEventParameterPresetValues.Width = 150;
AddChild(ctxEventParameterPresetValues);
ctxEventParameterPresetValues.OptionSelected += CtxEventParameterPresetValues_OptionSelected;
lbActions = FindChild<EditorListBox>(nameof(lbActions));
selActionType = FindChild<EditorPopUpSelector>(nameof(selActionType));
panelActionDescription = FindChild<EditorDescriptionPanel>(nameof(panelActionDescription));
lbActionParameters = FindChild<EditorListBox>(nameof(lbActionParameters));
tbActionParameterValue = FindChild<EditorTextBox>(nameof(tbActionParameterValue));
ctxActionParameterPresetValues = new XNAContextMenu(WindowManager);
ctxActionParameterPresetValues.Name = nameof(ctxActionParameterPresetValues);
ctxActionParameterPresetValues.Width = 150;
AddChild(ctxActionParameterPresetValues);
ctxActionParameterPresetValues.OptionSelected += CtxActionParameterPresetValues_OptionSelected;
ddType.AddItem("0 - one-time, single-object condition");
ddType.AddItem("1 - one-time, multi-object condition");
ddType.AddItem("2 - repeating, single-object condition");
lbEvents.AllowMultiLineItems = false;
lbActions.AllowMultiLineItems = false;
var triggerContextMenu = new EditorContextMenu(WindowManager);
triggerContextMenu.Name = nameof(triggerContextMenu);
triggerContextMenu.Width = 270;
triggerContextMenu.AddItem("Place CellTag", PlaceCellTag);
triggerContextMenu.AddItem("Clear CellTags", ClearCellTags);
triggerContextMenu.AddItem("Attach to Objects", AttachTagToObjects);
triggerContextMenu.AddItem("View References", ShowReferences);
if (!Constants.IsRA2YR)
{
triggerContextMenu.AddItem("Wrap in EVA disable/enable actions", WrapInEVADisableAndEnableActions);
}
triggerContextMenu.AddItem("Clone for Easier Diffs", CloneForEasierDifficulties);
triggerContextMenu.AddItem("Clone for Easier Diffs (No Dependencies)", CloneForEasierDifficultiesWithoutDependencies);
AddChild(triggerContextMenu);
FindChild<EditorButton>("btnNewTrigger").LeftClick += BtnNewTrigger_LeftClick;
FindChild<EditorButton>("btnDeleteTrigger").LeftClick += BtnDeleteTrigger_LeftClick;
FindChild<EditorButton>("btnCloneTrigger").LeftClick += BtnCloneTrigger_LeftClick;
ddActions = FindChild<XNADropDown>(nameof(ddActions));
ddActions.AddItem("Advanced...");
// Add context menu options to Advanced menu for backwards compatibility
for (int i = 0; i < triggerContextMenu.Items.Count; i++)
{
var contextMenuOption = triggerContextMenu.Items[i];
ddActions.AddItem(new XNADropDownItem() { Text = contextMenuOption.Text, Tag = contextMenuOption.SelectAction });
}
ddActions.AddItem(new XNADropDownItem() { Text = "Re-generate Trigger IDs", Tag = new Action(RegenerateIDs) });
ddActions.SelectedIndex = 0;
ddActions.SelectedIndexChanged += DdActions_SelectedIndexChanged;
FindChild<EditorButton>("btnAddEvent").LeftClick += BtnAddEvent_LeftClick;
FindChild<EditorButton>("btnDeleteEvent").LeftClick += BtnDeleteEvent_LeftClick;
FindChild<EditorButton>("btnCloneEvent").LeftClick += BtnCloneEvent_LeftClick;
FindChild<EditorButton>("btnAddAction").LeftClick += BtnAddAction_LeftClick;
FindChild<EditorButton>("btnDeleteAction").LeftClick += BtnDeleteAction_LeftClick;
FindChild<EditorButton>("btnCloneAction").LeftClick += BtnCloneAction_LeftClick;
FindChild<EditorButton>("btnActionParameterValuePreset").LeftClick += BtnActionParameterValuePreset_LeftClick;
FindChild<EditorButton>("btnEventParameterValuePreset").LeftClick += BtnEventParameterValuePreset_LeftClick;
btnActionGoToTarget.LeftClick += btnActionGoToTarget_LeftClick;
selectEventWindow = new SelectEventWindow(WindowManager, map);
var eventWindowDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectEventWindow);
eventWindowDarkeningPanel.Hidden += EventWindowDarkeningPanel_Hidden;
selectActionWindow = new SelectActionWindow(WindowManager, map);
var actionWindowDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectActionWindow);
actionWindowDarkeningPanel.Hidden += ActionWindowDarkeningPanel_Hidden;
selectAnimationWindow = new SelectAnimationWindow(WindowManager, map);
var animationWindowDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectAnimationWindow);
animationWindowDarkeningPanel.Hidden += AnimationWindowDarkeningPanel_Hidden;
selectBuildingTypeWindow = new SelectBuildingTypeWindow(WindowManager, map);
var buildingTypeWindowDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectBuildingTypeWindow);
buildingTypeWindowDarkeningPanel.Hidden += BuildingTypeWindowDarkeningPanel_Hidden;
selectTeamTypeWindow = new SelectTeamTypeWindow(WindowManager, map);
var teamTypeWindowDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectTeamTypeWindow);
teamTypeWindowDarkeningPanel.Hidden += TeamTypeWindowDarkeningPanel_Hidden;
selectTriggerWindow = new SelectTriggerWindow(WindowManager, map);
var triggerWindowDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectTriggerWindow);
triggerWindowDarkeningPanel.Hidden += TriggerWindowDarkeningPanel_Hidden;
selectGlobalVariableWindow = new SelectGlobalVariableWindow(WindowManager, map);
var globalVariableDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectGlobalVariableWindow);
globalVariableDarkeningPanel.Hidden += GlobalVariableDarkeningPanel_Hidden;
selectLocalVariableWindow = new SelectLocalVariableWindow(WindowManager, map);
var localVariableDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectLocalVariableWindow);
localVariableDarkeningPanel.Hidden += LocalVariableDarkeningPanel_Hidden;
selectHouseWindow = new SelectHouseWindow(WindowManager, map);
var houseDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectHouseWindow);
houseDarkeningPanel.Hidden += HouseDarkeningPanel_Hidden;
selectHouseTypeWindow = new SelectHouseTypeWindow(WindowManager, map);
var houseTypeDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectHouseTypeWindow);
houseTypeDarkeningPanel.Hidden += HouseTypeDarkeningPanel_Hidden;
selectTutorialLineWindow = new SelectTutorialLineWindow(WindowManager, map);
var tutorialDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectTutorialLineWindow);
tutorialDarkeningPanel.Hidden += TutorialDarkeningPanel_Hidden;
selectThemeWindow = new SelectThemeWindow(WindowManager, map, false);
var themeDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectThemeWindow);
themeDarkeningPanel.Hidden += ThemeDarkeningPanel_Hidden;
selectTechnoTypeWindow = new SelectTechnoTypeWindow(WindowManager, map);
var technoTypeDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectTechnoTypeWindow);
technoTypeDarkeningPanel.Hidden += TechnoTypeDarkeningPanel_Hidden;
selectTagWindow = new SelectTagWindow(WindowManager, map);
var tagDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectTagWindow);
tagDarkeningPanel.Hidden += TagDarkeningPanel_Hidden;
selectStringWindow = new SelectStringWindow(WindowManager, map);
var stringDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectStringWindow);
stringDarkeningPanel.Hidden += StringDarkeningPanel_Hidden;
selectSpeechWindow = new SelectSpeechWindow(WindowManager, map);
var speechDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectSpeechWindow);
speechDarkeningPanel.Hidden += SpeechDarkeningPanel_Hidden;
selectSoundWindow = new SelectSoundWindow(WindowManager, map);
var soundDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectSoundWindow);
soundDarkeningPanel.Hidden += SoundDarkeningPanel_Hidden;
selectParticleSystemTypeWindow = new SelectParticleSystemTypeWindow(WindowManager, map);
var particleSystemTypeDarkeningPanel = DarkeningPanel.InitializeAndAddToParentControlWithChild(WindowManager, Parent, selectParticleSystemTypeWindow);
particleSystemTypeDarkeningPanel.Hidden += ParticleSystemTypeDarkeningPanel_Hidden;
eventContextMenu = new EditorContextMenu(WindowManager);
eventContextMenu.Name = nameof(eventContextMenu);
eventContextMenu.Width = lbEvents.Width;
eventContextMenu.AddItem("Move Up", EventContextMenu_MoveUp, () => editedTrigger != null && lbEvents.SelectedItem != null && lbEvents.SelectedIndex > 0);
eventContextMenu.AddItem("Move Down", EventContextMenu_MoveDown, () => editedTrigger != null && lbEvents.SelectedItem != null && lbEvents.SelectedIndex < lbEvents.Items.Count - 1);
eventContextMenu.AddItem("Clone Event", EventContextMenu_CloneEvent, () => editedTrigger != null && lbEvents.SelectedItem != null);
eventContextMenu.AddItem("Delete Event", () => BtnDeleteEvent_LeftClick(this, EventArgs.Empty), () => editedTrigger != null && lbEvents.SelectedItem != null);
AddChild(eventContextMenu);
lbEvents.AllowRightClickUnselect = false;
lbEvents.RightClick += (s, e) => { if (editedTrigger != null) { lbEvents.OnMouseLeftDown(); eventContextMenu.Open(GetCursorPoint()); } };
actionContextMenu = new EditorContextMenu(WindowManager);
actionContextMenu.Name = nameof(actionContextMenu);
actionContextMenu.Width = lbActions.Width;
actionContextMenu.AddItem("Move Up", ActionContextMenu_MoveUp, () => editedTrigger != null && lbActions.SelectedItem != null && lbActions.SelectedIndex > 0);
actionContextMenu.AddItem("Move Down", ActionContextMenu_MoveDown, () => editedTrigger != null && lbActions.SelectedItem != null && lbActions.SelectedIndex < lbActions.Items.Count - 1);
actionContextMenu.AddItem("Clone Action", ActionContextMenu_CloneAction, () => editedTrigger != null && lbActions.SelectedItem != null);
actionContextMenu.AddItem("Delete Action", () => BtnDeleteAction_LeftClick(this, EventArgs.Empty), () => editedTrigger != null && lbActions.SelectedItem != null);
AddChild(actionContextMenu);
lbActions.AllowRightClickUnselect = false;
lbActions.RightClick += (s, e) => { if (editedTrigger != null) { lbActions.OnMouseLeftDown(); actionContextMenu.Open(GetCursorPoint()); } };
var sortContextMenu = new EditorContextMenu(WindowManager);
sortContextMenu.Name = nameof(sortContextMenu);
sortContextMenu.Width = lbTriggers.Width;
sortContextMenu.AddItem("Sort by ID", () => TriggerSortMode = TriggerSortMode.ID);
sortContextMenu.AddItem("Sort by Name", () => TriggerSortMode = TriggerSortMode.Name);
sortContextMenu.AddItem("Sort by Color", () => TriggerSortMode = TriggerSortMode.Color);
sortContextMenu.AddItem("Sort by Color, then by Name", () => TriggerSortMode = TriggerSortMode.ColorThenName);
AddChild(sortContextMenu);
FindChild<EditorButton>("btnSortOptions").LeftClick += (s, e) => sortContextMenu.Open(GetCursorPoint());
lbTriggers.AllowRightClickUnselect = false;
lbTriggers.RightClick += (s, e) => { lbTriggers.SelectedIndex = lbTriggers.HoveredIndex; if (lbTriggers.SelectedItem != null) triggerContextMenu.Open(GetCursorPoint()); };
lbTriggers.SelectedIndexChanged += LbTriggers_SelectedIndexChanged;
WindowManager.WindowSizeChangedByUser += WindowManager_WindowSizeChangedByUser;
}
private void WindowManager_WindowSizeChangedByUser(object sender, EventArgs e)
{
RefreshLayout();
ListTriggers();
}
public override void Kill()
{
WindowManager.WindowSizeChangedByUser -= WindowManager_WindowSizeChangedByUser;
base.Kill();
}
private void DdActions_SelectedIndexChanged(object sender, EventArgs e)
{
var item = ddActions.SelectedItem;
if (item == null)
return;
if (item.Tag == null)
return;
if (item.Tag is Action action)
action();
ddActions.SelectedIndexChanged -= DdActions_SelectedIndexChanged;
ddActions.SelectedIndex = 0;
ddActions.SelectedIndexChanged += DdActions_SelectedIndexChanged;
}
private void PlaceCellTag()
{
if (editedTrigger == null)
return;
Tag tag = map.Tags.Find(t => t.Trigger == editedTrigger);
if (tag == null)
return;
placeCellTagCursorAction.Tag = tag;
editorState.CursorAction = placeCellTagCursorAction;
}
private void ClearCellTags()
{
if (editedTrigger == null)
return;
Tag tag = map.Tags.Find(t => t.Trigger == editedTrigger);
if (tag == null)
return;
var messageBox = EditorMessageBox.Show(WindowManager, "Are you sure?",
$"This will delete all CellTags related to trigger \"{editedTrigger.Name}\". No un-do is available. Do you want to continue?",
MessageBoxButtons.YesNo);
messageBox.YesClickedAction = _ =>
{
var cellTagsCopy = new List<CellTag>(map.CellTags);
foreach (var cellTag in cellTagsCopy)
{
if (cellTag.Tag == tag)
{
map.RemoveCellTagFrom(cellTag.Position);
}
}
cursorActionTarget.InvalidateMap();
};
}
private void AttachTagToObjects()
{
if (editedTrigger == null)
return;
Tag tag = map.Tags.Find(t => t.Trigger == editedTrigger);
if (tag == null)
{
EditorMessageBox.Show(WindowManager, "No tag found",
$"The selected trigger '{editedTrigger.Name}' has no" +
$"associated tag. As such, it cannot be attached to any objects." + Environment.NewLine + Environment.NewLine +
"This should never happen, have you modified the map with another editor?",
MessageBoxButtons.OK);
return;
}
changeAttachedTagCursorAction.TagToAttach = tag;
editorState.CursorAction = changeAttachedTagCursorAction;
}
#region Viewing linked objects
private void ShowReferences()
{
if (editedTrigger == null)
return;
var stringBuilder = new StringBuilder();
var tag = map.Tags.Find(t => t.Trigger == editedTrigger);
if (tag == null)
{
stringBuilder.Append($"The selected trigger {editedTrigger.Name} has no associated tag. As such, it is not attached to any objects.");
}
else
{
var objectList = new List<TechnoBase>();
map.Infantry.ForEach(inf => AddObjectToListIfLinkedToTag(inf, objectList, tag));
map.Units.ForEach(unit => AddObjectToListIfLinkedToTag(unit, objectList, tag));
map.Structures.ForEach(structure => AddObjectToListIfLinkedToTag(structure, objectList, tag));
map.Aircraft.ForEach(aircraft => AddObjectToListIfLinkedToTag(aircraft, objectList, tag));
if (objectList.Count > 0)
{
stringBuilder.Append($"The selected trigger '{editedTrigger.Name}' is linked to the following objects:\r\n");
objectList.ForEach(techno =>
{
switch (techno.WhatAmI())
{
case RTTIType.Aircraft:
AppendToStringBuilder((Aircraft)techno, stringBuilder);
break;
case RTTIType.Building:
AppendToStringBuilder((Structure)techno, stringBuilder);
break;
case RTTIType.Infantry:
AppendToStringBuilder((Infantry)techno, stringBuilder);
break;
case RTTIType.Unit:
AppendToStringBuilder((Unit)techno, stringBuilder);
break;
default:
throw new NotImplementedException("Unknown RTTI type encountered when listing linked objects for a trigger.");
}
});
stringBuilder.Append(Environment.NewLine);
}
var teamTypes = map.TeamTypes.FindAll(tt => tt.Tag == tag);
if (teamTypes.Count > 0)
{
foreach (var teamType in teamTypes)
{
stringBuilder.Append($"The trigger is linked to TeamType '{teamType.Name}' ({teamType.ININame}).");
stringBuilder.Append(Environment.NewLine);
}
}
var celltag = map.CellTags.Find(ct => ct.Tag == tag);
if (celltag != null)
{
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append("The trigger is linked to one or more celltags (first match at " + celltag.Position + ").");
}
}
// Check other triggers to see whether this trigger is referenced by them
var allReferringTriggers = map.Triggers.FindAll(trig => {
foreach (var triggerAction in trig.Actions)
{
var actionType = map.EditorConfig.TriggerActionTypes[triggerAction.ActionIndex];
for (int i = 0; i < triggerAction.Parameters.Length && i < actionType.Parameters.Length; i++)
{
string paramValue = triggerAction.Parameters[i];
if (actionType.Parameters[i].TriggerParamType == TriggerParamType.Trigger && paramValue == editedTrigger.ID)
{
return true;
}
}
}
if (trig.LinkedTrigger == editedTrigger)
return true;
return false;
});
if (allReferringTriggers.Count > 0)
{
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append("The trigger is referenced by the following other triggers:");
allReferringTriggers.ForEach(trig => stringBuilder.Append(Environment.NewLine + $" - {trig.Name} ({trig.ID})"));
}
if (stringBuilder.Length == 0)
{
EditorMessageBox.Show(WindowManager, "Linked Objects",
$"The selected trigger '{editedTrigger.Name}' is not linked to any objects, CellTags or other triggers.",
MessageBoxButtons.OK);
}
else
{
if (stringBuilder[0] == Environment.NewLine[0])
stringBuilder.Remove(0, Environment.NewLine.Length);
EditorMessageBox.Show(WindowManager, "Linked Objects", stringBuilder.ToString(), MessageBoxButtons.OK);
}
return;
}
private void AppendToStringBuilder<T>(Techno<T> techno, StringBuilder stringBuilder) where T : TechnoType
{
string rtti = techno.WhatAmI().ToString();
string name = techno.ObjectType.Name;
string position = techno.Position.ToString();
stringBuilder.Append($" - {rtti}: {name} at {position}{Environment.NewLine}");
}
private void AddObjectToListIfLinkedToTag(TechnoBase techno, List<TechnoBase> technoList, Tag tag)
{
if (techno.AttachedTag == tag)
technoList.Add(techno);
}
private void WrapInEVADisableAndEnableActions()
{
if (editedTrigger == null)
return;
const int TSDisableSpeechActionIndex = 102;
const int TSEnableSpeechActionIndex = 103;
if (!map.EditorConfig.TriggerActionTypes.TryGetValue(TSDisableSpeechActionIndex, out TriggerActionType disableSpeechTriggerActionType))
{
EditorMessageBox.Show(WindowManager, "Trigger action type not found", $"Could not find trigger action type for \"Disable Speech\" {TSDisableSpeechActionIndex}", MessageBoxButtons.OK);
return;
}
if (!map.EditorConfig.TriggerActionTypes.TryGetValue(TSEnableSpeechActionIndex, out TriggerActionType enableSpeechTriggerActionType))
{
EditorMessageBox.Show(WindowManager, "Trigger action type not found", $"Could not find trigger action type for \"Enable Speech\" {TSEnableSpeechActionIndex}", MessageBoxButtons.OK);
return;
}
editedTrigger.Actions.Insert(0, CreateTriggerAction(disableSpeechTriggerActionType));
editedTrigger.Actions.Add(CreateTriggerAction(enableSpeechTriggerActionType));
EditTrigger(editedTrigger);
}
#endregion
private void RegenerateIDs()
{
var messageBox = EditorMessageBox.Show(WindowManager, "Are you sure?",
"This will re-generate the internal IDs (01000000, 01000001 etc.) for ALL* of your map's script elements" + Environment.NewLine +
"that start their ID with 0100 (all editor-generated script elements do)." + Environment.NewLine + Environment.NewLine +
"It might make the list more sensible in case there are deleted triggers. However, this feature is" + Environment.NewLine +
"experimental and if it goes wrong, it can destroy all of your scripting. Do you want to continue?",
MessageBoxButtons.YesNo);
messageBox.YesClickedAction = _ => map.RegenerateInternalIds();
ListTriggers();
LbTriggers_SelectedIndexChanged(this, EventArgs.Empty);
}
private void CloneForEasierDifficulties()
{
if (editedTrigger == null)
return;
var messageBox = EditorMessageBox.Show(WindowManager,
"Are you sure?",
"Cloning this trigger for easier difficulties will create duplicate instances" + Environment.NewLine +
"of this trigger for Medium and Easy difficulties, replacing Hard-mode globals" + Environment.NewLine +
"with respective globals of easier difficulties." + Environment.NewLine + Environment.NewLine +
"In case the trigger references TeamTypes, duplicates of the TeamTypes" + Environment.NewLine +
"and their TaskForces are also created for the easier-difficulty triggers." + Environment.NewLine + Environment.NewLine +
"No un-do is available. Do you want to continue?", MessageBoxButtons.YesNo);
messageBox.YesClickedAction = _ => DoCloneForEasierDifficulties(true);
}
private void CloneForEasierDifficultiesWithoutDependencies()
{
if (editedTrigger == null)
return;
var messageBox = EditorMessageBox.Show(WindowManager,
"Are you sure?",
"Cloning this trigger for easier difficulties will create duplicate instances" + Environment.NewLine +
"of this trigger for Medium and Easy difficulties, replacing Hard-mode globals" + Environment.NewLine +
"with respective globals of easier difficulties." + Environment.NewLine + Environment.NewLine +
"No un-do is available. Do you want to continue?", MessageBoxButtons.YesNo);
messageBox.YesClickedAction = _ => DoCloneForEasierDifficulties(false);
}
private TeamType FindOrCloneTeamTypeForDifficulty(TeamType hardTeamType, Difficulty targetDifficulty)
{
string targetDiffTeamTypeName = Helpers.ConvertNameToNewDifficulty(hardTeamType.Name, Difficulty.Hard, targetDifficulty);
TeamType targetDiffTeamType = map.TeamTypes.Find(tt => tt.Name == targetDiffTeamTypeName);
// Only create new TeamType and TaskForce if they weren't already found
if (targetDiffTeamType == null)
{
string targetDiffTaskForceName = Helpers.ConvertNameToNewDifficulty(hardTeamType.TaskForce.Name, Difficulty.Hard, targetDifficulty);
TaskForce targetDiffTaskForce = map.TaskForces.Find(tt => tt.Name == targetDiffTaskForceName);
if (targetDiffTaskForce == null)
{
targetDiffTaskForce = hardTeamType.TaskForce.Clone(map.GetNewUniqueInternalId());
targetDiffTaskForce.Name = targetDiffTaskForceName;
map.AddTaskForce(targetDiffTaskForce);
}
targetDiffTeamType = hardTeamType.Clone(map.GetNewUniqueInternalId());
targetDiffTeamType.Name = targetDiffTeamTypeName;
targetDiffTeamType.TaskForce = targetDiffTaskForce;
map.AddTeamType(targetDiffTeamType);
}
return targetDiffTeamType;
}
private void DoCloneForEasierDifficulties(bool cloneDependencies)
{
var originalTag = map.Tags.Find(t => t.Trigger == editedTrigger);
var mediumDifficultyTrigger = editedTrigger.Clone(map.GetNewUniqueInternalId());
mediumDifficultyTrigger.Hard = false;
mediumDifficultyTrigger.Normal = true;
mediumDifficultyTrigger.Easy = false;
map.AddTrigger(mediumDifficultyTrigger);
var easyDifficultyTrigger = editedTrigger.Clone(map.GetNewUniqueInternalId());
easyDifficultyTrigger.Hard = false;
easyDifficultyTrigger.Normal = false;
easyDifficultyTrigger.Easy = true;
map.AddTrigger(easyDifficultyTrigger);
if (editedTrigger.Name.Contains("Hard"))
{
mediumDifficultyTrigger.Name = editedTrigger.Name.Replace("Hard", "Medium");
easyDifficultyTrigger.Name = editedTrigger.Name.Replace("Hard", "Easy");
}
else if (editedTrigger.Name.StartsWith("H "))
{
mediumDifficultyTrigger.Name = "M " + editedTrigger.Name[2..];
easyDifficultyTrigger.Name = "E " + editedTrigger.Name[2..];
}
else if (editedTrigger.Name.EndsWith(" H"))
{
mediumDifficultyTrigger.Name = editedTrigger.Name[..^2] + " M";
easyDifficultyTrigger.Name = editedTrigger.Name[..^2] + " E";
}
map.Tags.Add(new Tag()
{
ID = map.GetNewUniqueInternalId(),
Name = mediumDifficultyTrigger.Name + " (tag)",
Trigger = mediumDifficultyTrigger,
Repeating = originalTag == null ? 0 : originalTag.Repeating
});
map.Tags.Add(new Tag()
{
ID = map.GetNewUniqueInternalId(),
Name = easyDifficultyTrigger.Name + " (tag)",
Trigger = easyDifficultyTrigger,
Repeating = originalTag == null ? 0 : originalTag.Repeating
});
int mediumDiffGlobalVariableIndex = map.Rules.GlobalVariables.FindIndex(gv => gv.Name == "Difficulty Medium");
int easyDiffGlobalVariableIndex = map.Rules.GlobalVariables.FindIndex(gv => gv.Name == "Difficulty Easy");
if (mediumDiffGlobalVariableIndex < 0)
{
Logger.Log($"{nameof(TriggersWindow)}.{nameof(DoCloneForEasierDifficulties)}: Medium difficulty global variable not found!");
}
if (easyDiffGlobalVariableIndex < 0)
{
Logger.Log($"{nameof(TriggersWindow)}.{nameof(DoCloneForEasierDifficulties)}: Easy difficulty global variable not found!");
}
// Go through used events. If there's a reference to the
// "Difficulty Hard" global, replace it
// with references to the Medium and Easy globals.
for (int i = 0; i < editedTrigger.Conditions.Count; i++)
{
TriggerCondition condition = editedTrigger.Conditions[i];
if (map.EditorConfig.TriggerEventTypes[condition.ConditionIndex].Parameters[1].TriggerParamType == TriggerParamType.GlobalVariable)
{
int paramValue = Conversions.IntFromString(condition.Parameters[1], 0);
if (!map.Rules.GlobalVariables.Exists(gv => gv.Index == paramValue))
continue;
if (map.Rules.GlobalVariables.Find(gv => gv.Index == paramValue).Name == "Difficulty Hard")
{
if (mediumDiffGlobalVariableIndex > -1)
{
mediumDifficultyTrigger.Conditions[i].Parameters[1] = mediumDiffGlobalVariableIndex.ToString();
}
if (easyDiffGlobalVariableIndex > -1)
{
easyDifficultyTrigger.Conditions[i].Parameters[1] = easyDiffGlobalVariableIndex.ToString();
}
}
}
}
if (cloneDependencies)
{
// Go through used actions and their parameters.
// If they refer to any TeamTypes, clone the TeamTypes and replace the references.
for (int i = 0; i < editedTrigger.Actions.Count; i++)
{
TriggerAction action = editedTrigger.Actions[i];
TriggerActionType triggerActionType = map.EditorConfig.TriggerActionTypes[action.ActionIndex];
for (int j = 0; j < triggerActionType.Parameters.Length; j++)
{
var param = triggerActionType.Parameters[j];
if (param != null && param.TriggerParamType == TriggerParamType.TeamType)
{
TeamType teamType = map.TeamTypes.Find(tt => tt.ININame == action.ParamToString(j));
if (teamType != null && teamType.TaskForce != null)
{
TeamType mediumTeamType = FindOrCloneTeamTypeForDifficulty(teamType, Difficulty.Medium);
TeamType easyTeamType = FindOrCloneTeamTypeForDifficulty(teamType, Difficulty.Easy);
mediumDifficultyTrigger.Actions[i].Parameters[j] = mediumTeamType.ININame;
easyDifficultyTrigger.Actions[i].Parameters[j] = easyTeamType.ININame;
}
}
}
}
}
ListTriggers();
}
#region Event and action context menus
private void ActionContextMenu_MoveUp() => MoveUpEventOrAction(lbActions, editedTrigger?.Actions);
private void EventContextMenu_MoveUp() => MoveUpEventOrAction(lbEvents, editedTrigger?.Conditions);
private void MoveUpEventOrAction<T>(XNAListBox listBox, List<T> objectList)
{
if (editedTrigger == null || objectList == null || listBox.SelectedItem == null || listBox.SelectedIndex < 1)
return;
var tmp = objectList[listBox.SelectedIndex - 1];
objectList[listBox.SelectedIndex - 1] = objectList[listBox.SelectedIndex];
objectList[listBox.SelectedIndex] = tmp;
EditTrigger(editedTrigger);
listBox.SelectedIndex--;
}
private void ActionContextMenu_MoveDown() => MoveDownEventOrAction(lbActions, editedTrigger?.Actions);
private void EventContextMenu_MoveDown() => MoveDownEventOrAction(lbEvents, editedTrigger?.Conditions);
private void MoveDownEventOrAction<T>(XNAListBox listBox, List<T> objectList)
{
if (editedTrigger == null || listBox.SelectedItem == null || listBox.SelectedIndex >= listBox.Items.Count - 1)
return;
var tmp = objectList[listBox.SelectedIndex + 1];
objectList[listBox.SelectedIndex + 1] = objectList[listBox.SelectedIndex];
objectList[listBox.SelectedIndex] = tmp;
EditTrigger(editedTrigger);
listBox.SelectedIndex++;
}
private void EventContextMenu_CloneEvent() => CloneEventOrAction(lbEvents, editedTrigger?.Conditions);
private void ActionContextMenu_CloneAction() => CloneEventOrAction(lbActions, editedTrigger?.Actions);
private void CloneEventOrAction<T>(XNAListBox listBox, List<T> objectList) where T : ICloneable
{
if (editedTrigger == null || listBox.SelectedItem == null)
return;
var tag = (T)listBox.SelectedItem.Tag;
var clone = (T)tag.Clone();
objectList.Insert(listBox.SelectedIndex + 1, clone);
EditTrigger(editedTrigger);
listBox.SelectedIndex++;
}
#endregion
private void BtnEventParameterValuePreset_LeftClick(object sender, EventArgs e)
{
if (editedTrigger == null || lbEvents.SelectedItem == null || lbEventParameters.SelectedItem == null)
return;
var triggerEvent = (TriggerCondition)lbEvents.SelectedItem.Tag;
var triggerEventType = GetTriggerEventType(triggerEvent.ConditionIndex);
int paramIndex = (int)lbEventParameters.SelectedItem.Tag;
if (triggerEventType == null)
return;
int paramValue;
switch (triggerEventType.Parameters[paramIndex].TriggerParamType)
{
case TriggerParamType.GlobalVariable:
ctxEventParameterPresetValues.ClearItems();
ctxEventParameterPresetValues.Width = 250;
map.Rules.GlobalVariables.ForEach(globalVariable => ctxEventParameterPresetValues.AddItem(globalVariable.Index.ToString(CultureInfo.InvariantCulture) + " " + globalVariable.Name));
ctxEventParameterPresetValues.Open(GetCursorPoint());
// GlobalVariable existingGlobalVariable = map.Rules.GlobalVariables.Find(gv => gv.Index == Conversions.IntFromString(triggerEvent.Parameters[paramIndex], -1));
// selectGlobalVariableWindow.IsForEvent = true;
// selectGlobalVariableWindow.Open(existingGlobalVariable);
break;
case TriggerParamType.LocalVariable:
ctxEventParameterPresetValues.ClearItems();
ctxEventParameterPresetValues.Width = 250;
map.LocalVariables.ForEach(localVariable => ctxEventParameterPresetValues.AddItem(localVariable.Index.ToString(CultureInfo.InvariantCulture) + " " + localVariable.Name));
ctxEventParameterPresetValues.Open(GetCursorPoint());
// LocalVariable existingLocalVariable = map.LocalVariables.Find(lv => lv.Index == Conversions.IntFromString(triggerEvent.Parameters[paramIndex], -1));
// selectLocalVariableWindow.IsForEvent = true;
// selectLocalVariableWindow.Open(existingLocalVariable);
break;
case TriggerParamType.HouseType:
selectHouseTypeWindow.IsForEvent = true;
paramValue = Conversions.IntFromString(triggerEvent.Parameters[paramIndex], -1);
if (paramValue > -1 && paramValue < map.GetHouseTypes().Count)
selectHouseTypeWindow.Open(map.GetHouseTypes()[paramValue]);
else
selectHouseTypeWindow.Open(null);
break;
case TriggerParamType.House:
selectHouseWindow.IsForEvent = true;
paramValue = Conversions.IntFromString(triggerEvent.Parameters[paramIndex], -1);
if (paramValue > -1 && paramValue < map.GetHouses().Count)
selectHouseWindow.Open(map.GetHouses()[paramValue]);
else
selectHouseWindow.Open(null);
break;
case TriggerParamType.Building:
paramValue = Conversions.IntFromString(triggerEvent.Parameters[paramIndex], -1);
BuildingType existingBuilding = paramValue < 0 || paramValue >= map.Rules.BuildingTypes.Count ? null : map.Rules.BuildingTypes[paramValue];
selectBuildingTypeWindow.IsForEvent = true;
selectBuildingTypeWindow.Tag = TriggerParamType.Building;
selectBuildingTypeWindow.Open(existingBuilding);
break;
case TriggerParamType.Techno:
TechnoType existingTechno = map.GetAllTechnoTypes().Find(t => t.ININame == triggerEvent.Parameters[paramIndex]);
selectTechnoTypeWindow.IsForEvent = true;
selectTechnoTypeWindow.Open(existingTechno);
break;
case TriggerParamType.Waypoint:
case TriggerParamType.WaypointZZ:
ctxEventParameterPresetValues.ClearItems();
ctxEventParameterPresetValues.Width = 100;
map.Waypoints.ForEach(wp => ctxEventParameterPresetValues.AddItem(wp.Identifier.ToString(CultureInfo.InvariantCulture)));
ctxEventParameterPresetValues.Open(GetCursorPoint());
break;
case TriggerParamType.SuperWeapon:
ctxEventParameterPresetValues.ClearItems();
ctxEventParameterPresetValues.Width = 250;
map.Rules.SuperWeaponTypes.ForEach(sw => ctxEventParameterPresetValues.AddItem(sw.GetDisplayString()));
ctxEventParameterPresetValues.Open(GetCursorPoint());
break;
case TriggerParamType.TeamType:
TeamType existingTeamType = map.TeamTypes.Find(tt => tt.ININame == triggerEvent.Parameters[paramIndex]);
selectTeamTypeWindow.IsForEvent = true;
selectTeamTypeWindow.Open(existingTeamType);
break;
default:
break;
}
}
private void CtxActionParameterPresetValues_OptionSelected(object sender, ContextMenuItemSelectedEventArgs e)
{
tbActionParameterValue.Text = ctxActionParameterPresetValues.Items[e.ItemIndex].Text;
}
private void BtnActionParameterValuePreset_LeftClick(object sender, EventArgs e)
{
if (editedTrigger == null || lbActions.SelectedItem == null || lbActionParameters.SelectedItem == null)
return;
var triggerAction = (TriggerAction)lbActions.SelectedItem.Tag;
var triggerActionType = GetTriggerActionType(triggerAction.ActionIndex);
int paramIndex = (int)lbActionParameters.SelectedItem.Tag;
if (triggerActionType == null)
return;
TriggerActionParam parameter = triggerActionType.Parameters[paramIndex];
// If the parameter has preset options defined, then show them in a context menu instead of opening a window
if (parameter.PresetOptions != null && parameter.PresetOptions.Count > 0)
{
ctxActionParameterPresetValues.ClearItems();
parameter.PresetOptions.ForEach(ctxActionParameterPresetValues.AddItem);
ctxActionParameterPresetValues.Open(GetCursorPoint());
return;
}
switch (parameter.TriggerParamType)
{
case TriggerParamType.Animation:
AnimType existingAnimType = map.Rules.AnimTypes.Find(at => at.Index == Conversions.IntFromString(triggerAction.Parameters[paramIndex], -1));
selectAnimationWindow.IsForEvent = false;
selectAnimationWindow.Open(existingAnimType);
break;
case TriggerParamType.TeamType:
TeamType existingTeamType = map.TeamTypes.Find(tt => tt.ININame == triggerAction.Parameters[paramIndex]);
selectTeamTypeWindow.IsForEvent = false;
selectTeamTypeWindow.Open(existingTeamType);
break;
case TriggerParamType.Trigger:
Trigger existingTrigger = map.Triggers.Find(tt => tt.ID == triggerAction.Parameters[paramIndex]);
isAttachingTrigger = false;
selectTriggerWindow.Open(existingTrigger);
break;
case TriggerParamType.GlobalVariable:
ctxActionParameterPresetValues.ClearItems();
ctxActionParameterPresetValues.Width = 250;
map.Rules.GlobalVariables.ForEach(globalVariable => ctxActionParameterPresetValues.AddItem(globalVariable.Index.ToString(CultureInfo.InvariantCulture) + " " + globalVariable.Name));
ctxActionParameterPresetValues.Open(GetCursorPoint());
// GlobalVariable existingGlobalVariable = map.Rules.GlobalVariables.Find(gv => gv.Index == Conversions.IntFromString(triggerAction.Parameters[paramIndex], -1));
// selectGlobalVariableWindow.IsForEvent = false;
// selectGlobalVariableWindow.Open(existingGlobalVariable);
break;
case TriggerParamType.LocalVariable:
ctxActionParameterPresetValues.ClearItems();
ctxActionParameterPresetValues.Width = 250;
map.LocalVariables.ForEach(localVariable => ctxActionParameterPresetValues.AddItem(localVariable.Index.ToString(CultureInfo.InvariantCulture) + " " + localVariable.Name));
ctxActionParameterPresetValues.Open(GetCursorPoint());
// LocalVariable existingLocalVariable = map.LocalVariables.Find(lv => lv.Index == Conversions.IntFromString(triggerAction.Parameters[paramIndex], -1));