@@ -61,6 +61,7 @@ public ScriptsWindow(WindowManager windowManager, Map map, EditorState editorSta
6161 private EditorContextMenu actionListContextMenu ;
6262
6363 private SelectBuildingTargetWindow selectBuildingTargetWindow ;
64+ private SelectAnimationWindow selectAnimationWindow ;
6465
6566 private Script editedScript ;
6667
@@ -157,6 +158,11 @@ public override void Initialize()
157158 var buildingTargetWindowDarkeningPanel = DarkeningPanel . InitializeAndAddToParentControlWithChild ( WindowManager , Parent , selectBuildingTargetWindow ) ;
158159 buildingTargetWindowDarkeningPanel . Hidden += BuildingTargetWindowDarkeningPanel_Hidden ;
159160
161+ selectAnimationWindow = new SelectAnimationWindow ( WindowManager , map ) ;
162+ selectAnimationWindow . IncludeNone = false ;
163+ var animationWindowDarkeningPanel = DarkeningPanel . InitializeAndAddToParentControlWithChild ( WindowManager , Parent , selectAnimationWindow ) ;
164+ animationWindowDarkeningPanel . Hidden += AnimationWindowDarkeningPanel_Hidden ;
165+
160166 selTypeOfAction . MouseLeftDown += SelTypeOfAction_MouseLeftDown ;
161167
162168 FindChild < EditorButton > ( "btnAddScript" ) . LeftClick += BtnAddScript_LeftClick ;
@@ -185,6 +191,18 @@ public override void Initialize()
185191 lbActions . RightClick += ( s , e ) => { if ( editedScript != null ) { lbActions . SelectedIndex = lbActions . HoveredIndex ; actionListContextMenu . Open ( GetCursorPoint ( ) ) ; } } ;
186192 }
187193
194+ private void AnimationWindowDarkeningPanel_Hidden ( object sender , EventArgs e )
195+ {
196+ if ( editedScript == null || lbActions . SelectedItem == null )
197+ return ;
198+
199+ if ( selectAnimationWindow . SelectedObject != null )
200+ {
201+ editedScript . Actions [ lbActions . SelectedIndex ] . Argument = selectAnimationWindow . SelectedObject . Index ;
202+ RefreshParameterEntryText ( ) ;
203+ }
204+ }
205+
188206 private void BuildingTargetWindowDarkeningPanel_Hidden ( object sender , EventArgs e )
189207 {
190208 if ( editedScript == null || lbActions . SelectedItem == null )
@@ -302,6 +320,11 @@ private void BtnEditorPresetValues_LeftClick(object sender, EventArgs e)
302320 var ( index , property ) = SplitBuildingWithProperty ( entry . Argument ) ;
303321 selectBuildingTargetWindow . Open ( index , property ) ;
304322 }
323+ else if ( action . ParamType == TriggerParamType . Animation )
324+ {
325+ var animType = entry . Argument > - 1 && entry . Argument < map . Rules . AnimTypes . Count ? map . Rules . AnimTypes [ entry . Argument ] : null ;
326+ selectAnimationWindow . Open ( animType ) ;
327+ }
305328 }
306329
307330 private void BtnEditorPresetValuesWindow_LeftClick ( object sender , EventArgs e )
@@ -536,6 +559,18 @@ private void SelectScriptActionPresetDarkeningPanel_Hidden(object sender, EventA
536559 tbParameterValue . Text = selectScriptActionPresetOptionWindow . GetSelectedItemText ( ) ;
537560 }
538561
562+ private void RefreshParameterEntryText ( )
563+ {
564+ if ( lbActions . SelectedItem == null || editedScript == null )
565+ return ;
566+
567+ ScriptActionEntry entry = editedScript . Actions [ lbActions . SelectedIndex ] ;
568+ ScriptAction action = map . EditorConfig . ScriptActions . GetValueOrDefault ( entry . Action ) ;
569+ tbParameterValue . TextChanged -= TbParameterValue_TextChanged ;
570+ SetParameterEntryText ( entry , action ) ;
571+ tbParameterValue . TextChanged += TbParameterValue_TextChanged ;
572+ }
573+
539574 private void LbActions_SelectedIndexChanged ( object sender , EventArgs e )
540575 {
541576 if ( lbActions . SelectedItem == null || editedScript == null )
@@ -592,6 +627,15 @@ private void SetParameterEntryText(ScriptActionEntry scriptActionEntry, ScriptAc
592627 tbParameterValue . Text = GetBuildingWithPropertyText ( scriptActionEntry . Argument ) ;
593628 return ;
594629 }
630+ else if ( action . ParamType == TriggerParamType . Animation )
631+ {
632+ if ( scriptActionEntry . Argument > - 1 && scriptActionEntry . Argument < map . Rules . AnimTypes . Count )
633+ tbParameterValue . Text = scriptActionEntry . Argument . ToString ( CultureInfo . InvariantCulture ) + " - " + map . Rules . AnimTypes [ scriptActionEntry . Argument ] . ININame ;
634+ else
635+ tbParameterValue . Text = scriptActionEntry . Argument . ToString ( CultureInfo . InvariantCulture ) + " - unknown animation" ;
636+
637+ return ;
638+ }
595639
596640 int presetIndex = action . PresetOptions . FindIndex ( p => p . Value == scriptActionEntry . Argument ) ;
597641
0 commit comments