From 6604212934103fcc84d50a032c466ea5146d327a Mon Sep 17 00:00:00 2001 From: E3245 Date: Thu, 15 Sep 2022 16:49:26 -0500 Subject: [PATCH] AnimateIn() fixes (#83) --- XComGame/Classes/UIPanel.uc | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/XComGame/Classes/UIPanel.uc b/XComGame/Classes/UIPanel.uc index e628cab..51030df 100644 --- a/XComGame/Classes/UIPanel.uc +++ b/XComGame/Classes/UIPanel.uc @@ -788,7 +788,7 @@ simulated function RemoveTweens() simulated function AnimateIn(optional float Delay = -1.0) { if( Delay == -1.0 && ParentPanel != none) - Delay = ParentPanel.GetChildIndex(self) * class'UIUtilities'.const.INTRO_ANIMATION_DELAY_PER_INDEX; + Delay = ParentPanel.GetDirectChildIndex(self) * class'UIUtilities'.const.INTRO_ANIMATION_DELAY_PER_INDEX; // HELIOS Issue #83 (WotC CHL Issue #341) AddTweenBetween("_alpha", 0, Alpha, class'UIUtilities'.const.INTRO_ANIMATION_TIME, Delay); } @@ -796,7 +796,7 @@ simulated function AnimateIn(optional float Delay = -1.0) simulated function AnimateOut(optional float Delay = -1.0) { if( Delay == -1.0 && ParentPanel != none ) - Delay = ParentPanel.GetChildIndex(self) * class'UIUtilities'.const.INTRO_ANIMATION_DELAY_PER_INDEX; + Delay = ParentPanel.GetDirectChildIndex(self) * class'UIUtilities'.const.INTRO_ANIMATION_DELAY_PER_INDEX; // HELIOS Issue #83 (WotC CHL Issue #341) AddTweenBetween("_alpha", Alpha, 0, class'UIUtilities'.const.INTRO_ANIMATION_TIME, Delay); } @@ -933,6 +933,31 @@ simulated function int GetChildIndex(UIPanel Child, optional bool ErrorIfNotFoun return -1; } +// Start HELIOS Issue #83 (WotC CHL Issue #341): Function to be used when actually getting the "direct" child index. +// UIScreens get all their recursive child panels added, so GetChildIndex is unusable for AnimateIn +simulated function int GetDirectChildIndex(UIPanel Child, optional bool ErrorIfNotFound = true) +{ + local int i, index; + + for(i = 0; i < ChildPanels.Length; ++i) + { + if( ChildPanels[i] == Child ) + return index; + + if (ChildPanels[i].ParentPanel == self) + index++; + } + + // Don't print errors when recursing through children. + if( ErrorIfNotFound ) + { + ScriptTrace(); + `warn("UI ERROR: could not find Index of the child control '" $ Child.MCName $ "' in '" $ self.MCName $ "'."); + } + return -1; +} +// End HELIOS Issue #83 (WotC CHL Issue #341) + // TODO: Nativize simulated function GetChildrenOfType(class ClassType, out array ChildrenOfType) {