@@ -52,10 +52,12 @@ public ScriptsWindow(WindowManager windowManager, Map map, EditorState editorSta
5252 private XNALabel lblParameterDescription ;
5353 private EditorNumberTextBox tbParameterValue ;
5454 private MenuButton btnEditorPresetValues ;
55+ private EditorButton btnEditorPresetValuesWindow ;
5556 private XNALabel lblActionDescriptionValue ;
5657 private XNADropDown ddScriptColor ;
5758
5859 private SelectScriptActionWindow selectScriptActionWindow ;
60+ private SelectScriptActionPresetOptionWindow selectScriptActionPresetOptionWindow ;
5961 private EditorContextMenu actionListContextMenu ;
6062
6163 private SelectBuildingTargetWindow selectBuildingTargetWindow ;
@@ -92,6 +94,7 @@ public override void Initialize()
9294 lblParameterDescription = FindChild < XNALabel > ( nameof ( lblParameterDescription ) ) ;
9395 tbParameterValue = FindChild < EditorNumberTextBox > ( nameof ( tbParameterValue ) ) ;
9496 btnEditorPresetValues = FindChild < MenuButton > ( nameof ( btnEditorPresetValues ) ) ;
97+ btnEditorPresetValuesWindow = FindChild < EditorButton > ( nameof ( btnEditorPresetValuesWindow ) ) ;
9598 lblActionDescriptionValue = FindChild < XNALabel > ( nameof ( lblActionDescriptionValue ) ) ;
9699 ddScriptColor = FindChild < XNADropDown > ( nameof ( ddScriptColor ) ) ;
97100
@@ -109,6 +112,9 @@ public override void Initialize()
109112 btnEditorPresetValues . ContextMenu . OptionSelected += ContextMenu_OptionSelected ;
110113 btnEditorPresetValues . LeftClick += BtnEditorPresetValues_LeftClick ;
111114
115+ btnEditorPresetValuesWindow . LeftClick += BtnEditorPresetValuesWindow_LeftClick ;
116+ btnEditorPresetValuesWindow . Disable ( ) ;
117+
112118 tbName . TextChanged += TbName_TextChanged ;
113119 tbParameterValue . TextChanged += TbParameterValue_TextChanged ;
114120 lbScriptTypes . SelectedIndexChanged += LbScriptTypes_SelectedIndexChanged ;
@@ -143,6 +149,10 @@ public override void Initialize()
143149 var selectScriptActionDarkeningPanel = DarkeningPanel . InitializeAndAddToParentControlWithChild ( WindowManager , Parent , selectScriptActionWindow ) ;
144150 selectScriptActionDarkeningPanel . Hidden += SelectScriptActionDarkeningPanel_Hidden ;
145151
152+ selectScriptActionPresetOptionWindow = new SelectScriptActionPresetOptionWindow ( WindowManager , map ) ;
153+ var selectScriptActionPresetDarkeningPanel = DarkeningPanel . InitializeAndAddToParentControlWithChild ( WindowManager , Parent , selectScriptActionPresetOptionWindow ) ;
154+ selectScriptActionPresetDarkeningPanel . Hidden += SelectScriptActionPresetDarkeningPanel_Hidden ;
155+
146156 selectBuildingTargetWindow = new SelectBuildingTargetWindow ( WindowManager , map ) ;
147157 var buildingTargetWindowDarkeningPanel = DarkeningPanel . InitializeAndAddToParentControlWithChild ( WindowManager , Parent , selectBuildingTargetWindow ) ;
148158 buildingTargetWindowDarkeningPanel . Hidden += BuildingTargetWindowDarkeningPanel_Hidden ;
@@ -294,6 +304,18 @@ private void BtnEditorPresetValues_LeftClick(object sender, EventArgs e)
294304 }
295305 }
296306
307+ private void BtnEditorPresetValuesWindow_LeftClick ( object sender , EventArgs e )
308+ {
309+ if ( editedScript == null )
310+ return ;
311+
312+ if ( lbActions . SelectedItem == null )
313+ return ;
314+
315+ var item = selectScriptActionPresetOptionWindow . GetMatchingItem ( tbParameterValue . Text ) ;
316+ selectScriptActionPresetOptionWindow . Open ( item ) ;
317+ }
318+
297319 private void ShowScriptReferences ( )
298320 {
299321 if ( editedScript == null )
@@ -502,6 +524,18 @@ private void SelectScriptActionDarkeningPanel_Hidden(object sender, EventArgs e)
502524 InputIgnoreTime = TimeSpan . FromSeconds ( Constants . UIAccidentalClickPreventionTime ) ;
503525 }
504526
527+
528+ private void SelectScriptActionPresetDarkeningPanel_Hidden ( object sender , EventArgs e )
529+ {
530+ if ( lbActions . SelectedItem == null || editedScript == null )
531+ {
532+ return ;
533+ }
534+
535+ if ( selectScriptActionPresetOptionWindow . SelectedObject != null )
536+ tbParameterValue . Text = selectScriptActionPresetOptionWindow . GetSelectedItemText ( ) ;
537+ }
538+
505539 private void LbActions_SelectedIndexChanged ( object sender , EventArgs e )
506540 {
507541 if ( lbActions . SelectedItem == null || editedScript == null )
@@ -526,7 +560,23 @@ private void LbActions_SelectedIndexChanged(object sender, EventArgs e)
526560 lblParameterDescription . Text = action == null ? "Parameter:" : action . ParamDescription + ":" ;
527561 lblActionDescriptionValue . Text = GetActionDescriptionFromIndex ( entry . Action ) ;
528562
529- FillPresetContextMenu ( entry , action ) ;
563+ string text = null ;
564+
565+ if ( action . UseWindowSelection && action . PresetOptions . Count > 0 )
566+ {
567+ btnEditorPresetValues . Disable ( ) ;
568+ btnEditorPresetValuesWindow . Enable ( ) ;
569+ text = selectScriptActionPresetOptionWindow . FillPresetOptions ( entry , action ) ;
570+ }
571+ else
572+ {
573+ btnEditorPresetValues . Enable ( ) ;
574+ btnEditorPresetValuesWindow . Disable ( ) ;
575+ text = FillPresetContextMenu ( entry , action ) ;
576+ }
577+
578+ if ( text != null )
579+ tbParameterValue . Text = text ;
530580 }
531581
532582 private void SetParameterEntryText ( ScriptActionEntry scriptActionEntry , ScriptAction action )
@@ -585,13 +635,13 @@ private string GetBuildingWithPropertyText(int argument)
585635 return GetBuildingWithPropertyText ( index , property ) ;
586636 }
587637
588- private void FillPresetContextMenu ( ScriptActionEntry entry , ScriptAction action )
638+ private string FillPresetContextMenu ( ScriptActionEntry entry , ScriptAction action )
589639 {
590640 btnEditorPresetValues . ContextMenu . ClearItems ( ) ;
591641
592642 if ( action == null )
593643 {
594- return ;
644+ return null ;
595645 }
596646
597647 action . PresetOptions . ForEach ( p => btnEditorPresetValues . ContextMenu . AddItem ( new XNAContextMenuItem ( ) { Text = p . GetOptionText ( ) } ) ) ;
@@ -630,7 +680,9 @@ private void FillPresetContextMenu(ScriptActionEntry entry, ScriptAction action)
630680 fittingItem = btnEditorPresetValues . ContextMenu . Items . Find ( item => item . Text . StartsWith ( entry . Argument . ToString ( ) ) ) ;
631681
632682 if ( fittingItem != null )
633- tbParameterValue . Text = fittingItem . Text ;
683+ return fittingItem . Text ;
684+
685+ return null ;
634686 }
635687
636688 private void LbScriptTypes_SelectedIndexChanged ( object sender , EventArgs e ) => RefreshSelectedScript ( ) ;
@@ -734,9 +786,9 @@ private void EditScript(Script script)
734786 for ( int i = 0 ; i < editedScript . Actions . Count ; i ++ )
735787 {
736788 var actionEntry = editedScript . Actions [ i ] ;
737- lbActions . AddItem ( new XNAListBoxItem ( )
738- {
739- Text = GetActionEntryText ( i , actionEntry ) ,
789+ lbActions . AddItem ( new XNAListBoxItem ( )
790+ {
791+ Text = GetActionEntryText ( i , actionEntry ) ,
740792 Tag = actionEntry
741793 } ) ;
742794 }
@@ -754,7 +806,7 @@ private string GetActionEntryText(int index, ScriptActionEntry entry)
754806 {
755807 ScriptAction action = GetScriptAction ( entry . Action ) ;
756808 if ( action == null )
757- return "#" + index + " - Unknown (" + entry . Argument . ToString ( CultureInfo . InvariantCulture ) + ")" ;
809+ return "#" + index + " - Unknown (" + entry . Argument . ToString ( CultureInfo . InvariantCulture ) + ")" ;
758810
759811 return "#" + index + " - " + action . Name + " (" + entry . Argument . ToString ( CultureInfo . InvariantCulture ) + ")" ;
760812 }
0 commit comments