public static void AssertNearRightOf(this ILayoutComponent element, ILayoutComponent secondElement)
        {
            var actualDistance = CalculateRightOfDistance(element, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance > 0, $"{element.ComponentName} should be near right from {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedNearRightOfNoExpectedValueEvent?.Invoke(element, new LayoutTwoComponentsNoExpectedActionEventArgs(element, secondElement));
        }
示例#2
0
        private void DetectChildChanges(ILayoutComponent layout)
        {
            var transform = layout.RectTransform;

            // If we're waiting to spool a change, wait for the child count to settle so we don't spam.
            if (_childrenChanged)
            {
                if (_childCount == transform.childCount)
                {
                    _childConstantFrames += 1;
                    if (_childConstantFrames > UpdateThresholdFrames)
                    {
                        _childrenChanged = false;
                        collectChildren  = true;
                        applyLayout      = true;
                    }
                }
                else
                {
                    _childCount          = transform.childCount;
                    _childConstantFrames = 0;
                }

                return;
            }

            // Otherwise, start watching if it changed
            if (transform.childCount != _children.Count)
            {
                _childrenChanged     = true;
                _childCount          = transform.childCount;
                _childConstantFrames = 1;
            }
        }
示例#3
0
        private void ExecuteLayout(ILayoutComponent layout)
        {
            if (!applyLayout)
            {
                return;
            }
            applyLayout = false;

            var state = layout.Prepare();

            var activeChildren = _children.Where(i =>
            {
                try
                {
                    return(i.Transform.transform.gameObject.activeInHierarchy);
                }
                catch (Exception)
                {
                    return(false);
                }
            }).ToList();

            var count = activeChildren.Count;

            state.Count = count;

            for (var i = 0; i < count; i++)
            {
                state.Child  = activeChildren[i];
                state.Offset = i;
                layout.Apply(state);
            }

            layout.Complete(state);
        }
示例#4
0
        public static void AssertRightInsideOfLessThanOrEqual(this ILayoutComponent innerElement, ILayoutComponent outerElement, double right)
        {
            double actualRightDistance = CalculateRightInsideOfDistance(innerElement, outerElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualRightDistance <= right, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} right padding <= {right} px but was {actualRightDistance} px.");
            AssertedRightInsideOfLessOrEqualThanEvent?.Invoke(innerElement, new LayoutTwoComponentsActionEventArgs(innerElement, outerElement, right));
        }
示例#5
0
        public static void AssertAboveOf(this ILayoutComponent element, ILayoutComponent secondElement)
        {
            double actualDistance = CalculateAboveOfDistance(element, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance >= -1, $"{element.ComponentName} should be above of {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedAboveOfNoExpectedValueEvent?.Invoke(element, new LayoutTwoComponentsNoExpectedActionEventArgs(element, secondElement));
        }
示例#6
0
 public static void AssertCenteredInsideOfApproximate(this ILayoutComponent innerElement, ILayoutComponent outerElement, double distance, double percent)
 {
     AssertLeftInsideOfApproximate(innerElement, outerElement, distance, percent);
     AssertRightInsideOfApproximate(innerElement, outerElement, distance, percent);
     AssertTopInsideOfApproximate(innerElement, outerElement, distance, percent);
     AssertBottomInsideOfApproximate(innerElement, outerElement, distance, percent);
 }
示例#7
0
        public static void AssertRightInsideOf(this ILayoutComponent innerElement, ILayoutComponent outerElement, double right)
        {
            double actualRightDistance = CalculateRightInsideOfDistance(innerElement, outerElement);

            BA.Assert.AreEqual <LayoutAssertFailedException, double>(right, actualRightDistance, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} right padding = {right} px but was {actualRightDistance} px.");
            AssertedRightInsideOfEvent?.Invoke(innerElement, new LayoutTwoComponentsActionEventArgs(innerElement, outerElement, right));
        }
示例#8
0
        public static void AssertTopInsideOfLessThanOrEqual(this ILayoutComponent innerElement, ILayoutComponent outerElement, double top)
        {
            double actualTopDistance = CalculateTopInsideOfDistance(innerElement, outerElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualTopDistance <= top, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} top padding <= {top} px but was {actualTopDistance} px.");
            AssertedTopInsideOfLessOrEqualThanEvent?.Invoke(innerElement, new LayoutTwoComponentsActionEventArgs(innerElement, outerElement, top));
        }
示例#9
0
        public static void AssertLeftInsideOfLessThan(this ILayoutComponent innerElement, ILayoutComponent outerElement, double left)
        {
            double actualLeftDistance = CalculateLeftInsideOfDistance(innerElement, outerElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualLeftDistance < left, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} left padding < {left} px but was {actualLeftDistance} px.");
            AssertedLeftInsideOfLessThanEvent?.Invoke(innerElement, new LayoutTwoComponentsActionEventArgs(innerElement, outerElement, left));
        }
        public static void AssertBottomInsideOfLessThanOrEqual(this ILayoutComponent innerElement, ILayoutComponent outerElement, double bottom)
        {
            double actualBottomDistance = CalculateBottomInsideOfDistance(innerElement, outerElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualBottomDistance <= bottom, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} bottom padding <= {bottom} px but was {actualBottomDistance} px.");
            AssertedBottomInsideOfLessOrEqualThanEvent?.Invoke(innerElement, new LayoutTwoComponentsActionEventArgs(innerElement, outerElement, bottom));
        }
示例#11
0
        public static void AssertNearTopOfGreaterThan(this ILayoutComponent component, ILayoutComponent secondElement, double expected)
        {
            var actualDistance = CalculateAboveOfDistance(component, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance > expected, $"{component.ComponentName} should be > {expected} px near top of {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedNearTopOfGreaterThanEvent?.Invoke(component, new LayoutTwoComponentsActionEventArgs(component, secondElement, expected));
        }
        public static void AssertBottomInsideOf(this ILayoutComponent innerElement, ILayoutComponent outerElement, double bottom)
        {
            double actualBottomDistance = CalculateBottomInsideOfDistance(innerElement, outerElement);

            BA.Assert.AreEqual <LayoutAssertFailedException, double>(bottom, actualBottomDistance, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} bottom padding = {bottom} px but was {actualBottomDistance} px.");
            AssertedBottomInsideOfEvent?.Invoke(innerElement, new LayoutTwoComponentsActionEventArgs(innerElement, outerElement, bottom));
        }
        public static void AssertWidthApproximate(this ILayoutComponent layoutComponent, ILayoutComponent secondElement, double expectedPercentDifference)
        {
            var actualPercentDifference = CalculatePercentDifference(layoutComponent.Size.Width, secondElement.Size.Width);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualPercentDifference <= expectedPercentDifference, $"The width % difference between {layoutComponent.ComponentName} and {secondElement.ComponentName} was greater than {expectedPercentDifference}%, it was {actualPercentDifference} px.");
            AssertedWidthApproximateSecondElementEvent?.Invoke(layoutComponent, new LayoutTwoComponentsActionEventArgs(layoutComponent, secondElement, expectedPercentDifference.ToString()));
        }
        public static void AssertNearRightOfGreaterThanOrEqual(this ILayoutComponent element, ILayoutComponent secondElement, double expected)
        {
            var actualDistance = CalculateRightOfDistance(element, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance >= expected, $"{element.ComponentName} should be >= {expected} px near right from {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedNearRightOfGreaterOrEqualThanEvent?.Invoke(element, new LayoutTwoComponentsActionEventArgs(element, secondElement, expected));
        }
示例#15
0
 public static void AssertCenteredInsideOfBetween(this ILayoutComponent innerElement, ILayoutComponent outerElement, double from, double to)
 {
     AssertLeftInsideOfBetween(innerElement, outerElement, from, to);
     AssertRightInsideOfBetween(innerElement, outerElement, from, to);
     AssertTopInsideOfBetween(innerElement, outerElement, from, to);
     AssertBottomInsideOfBetween(innerElement, outerElement, from, to);
 }
示例#16
0
 public static void AssertInsideOf(this ILayoutComponent innerElement, ILayoutComponent outerElement, double left, double right, double top, double bottom)
 {
     AssertLeftInsideOf(innerElement, outerElement, left);
     AssertRightInsideOf(innerElement, outerElement, right);
     AssertTopInsideOf(innerElement, outerElement, top);
     AssertBottomInsideOf(innerElement, outerElement, bottom);
 }
示例#17
0
 public static void AssertCenteredInsideOfLessThanOrEqual(this ILayoutComponent innerElement, ILayoutComponent outerElement, double distance)
 {
     AssertLeftInsideOfLessThanOrEqual(innerElement, outerElement, distance);
     AssertRightInsideOfLessThanOrEqual(innerElement, outerElement, distance);
     AssertTopInsideOfLessThanOrEqual(innerElement, outerElement, distance);
     AssertBottomInsideOfLessThanOrEqual(innerElement, outerElement, distance);
 }
示例#18
0
        public static void AssertAboveOfLessThanOrEqual(this ILayoutComponent element, ILayoutComponent secondElement, double expected)
        {
            var actualDistance = CalculateAboveOfDistance(element, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance <= expected, $"{element.ComponentName} should be <= {expected} px above of {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedAboveOfLessOrEqualThanEvent?.Invoke(element, new LayoutTwoComponentsActionEventArgs(element, secondElement, expected));
        }
示例#19
0
        public static void AssertRightInsideOf(this ILayoutComponent innerElement, ILayoutComponent outerElement)
        {
            double actualRightDistance = CalculateRightInsideOfDistance(innerElement, outerElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualRightDistance >= 0, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} right padding but was {actualRightDistance} px.");
            AssertedRightInsideOfNoExpectedValueEvent?.Invoke(innerElement, new LayoutTwoComponentsNoExpectedActionEventArgs(innerElement, outerElement));
        }
示例#20
0
        public static void AssertAboveOfBetween(this ILayoutComponent element, ILayoutComponent secondElement, double from, double to)
        {
            var actualDistance = CalculateAboveOfDistance(element, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance >= from && actualDistance <= to, $"{element.ComponentName} should be between {from}-{to} px above of {secondElement.ComponentName}, but {actualDistance}.");
            AssertedAboveOfBetweenEvent?.Invoke(element, new LayoutTwoComponentsActionTwoValuesEventArgs(element, secondElement, from, to));
        }
示例#21
0
        public static void AssertRightInsideOfBetween(this ILayoutComponent innerElement, ILayoutComponent outerElement, double from, double to)
        {
            double actualRightDistance = CalculateRightInsideOfDistance(innerElement, outerElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualRightDistance >= from && actualRightDistance <= to, $"{innerElement.ComponentName} should be inside of {outerElement.ComponentName} right padding between {from}-{to} px but was {actualRightDistance} px.");
            AssertedRightInsideOfBetweenEvent?.Invoke(innerElement, new LayoutTwoComponentsActionTwoValuesEventArgs(innerElement, outerElement, from, to));
        }
示例#22
0
        public static void AssertAboveOf(this ILayoutComponent element, ILayoutComponent secondElement, double expected)
        {
            double actualDistance = CalculateAboveOfDistance(element, secondElement);

            BA.Assert.AreEqual <LayoutAssertFailedException, double>(expected, actualDistance, $"{element.ComponentName} should be {expected} px above of {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedAboveOfEvent?.Invoke(element, new LayoutTwoComponentsActionEventArgs(element, secondElement, expected));
        }
示例#23
0
        public static void AssertNearBottomOfLessThan(this ILayoutComponent element, ILayoutComponent secondElement, double expected)
        {
            var actualDistance = CalculateBelowOfDistance(element, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance < expected, $"{element.ComponentName} should be < {expected} px below of {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedNearBottomOfLessThanEvent?.Invoke(element, new LayoutTwoComponentsActionEventArgs(element, secondElement, expected));
        }
示例#24
0
 public static void AssertCenteredInsideOf(this ILayoutComponent innerElement, ILayoutComponent outerElement)
 {
     AssertLeftInsideOf(innerElement, outerElement);
     AssertRightInsideOf(innerElement, outerElement);
     AssertTopInsideOf(innerElement, outerElement);
     AssertBottomInsideOf(innerElement, outerElement);
 }
示例#25
0
        public static void AssertRightInsideOfApproximate(this ILayoutComponent innerElement, ILayoutComponent outerElement, double right, double percent)
        {
            double actualRightDistance     = CalculateRightInsideOfDistance(innerElement, outerElement);
            var    actualPercentDifference = CalculatePercentDifference(right, actualRightDistance);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualPercentDifference <= percent, $"{innerElement.ComponentName} should be <= {percent}% of {right} px right padding of {outerElement.ComponentName} but was {actualRightDistance} px.");
            AssertedRightInsideOfApproximateEvent?.Invoke(innerElement, new LayoutTwoComponentsActionTwoValuesEventArgs(innerElement, outerElement, right, percent));
        }
示例#26
0
        public static void AssertAboveOfApproximate(this ILayoutComponent element, ILayoutComponent secondElement, double expected, double percent)
        {
            var actualDistance          = CalculateAboveOfDistance(element, secondElement);
            var actualPercentDifference = CalculatePercentDifference(expected, actualDistance);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualPercentDifference <= percent, $"{element.ComponentName} should be <= {percent}% of {expected} px above of {secondElement.ComponentName} but was {actualDistance} px.");
            AssertedAboveOfApproximateEvent?.Invoke(element, new LayoutTwoComponentsActionTwoValuesEventArgs(element, secondElement, expected, percent));
        }
示例#27
0
 public static void AssertInsideOf(this ILayoutComponent innerElement, ILayoutComponent outerElement)
 {
     Console.WriteLine("Coordinates:");
     Console.WriteLine(innerElement.Location);
     Console.WriteLine(outerElement.Location);
     AssertLeftInsideOf(innerElement, outerElement);
     AssertRightInsideOf(innerElement, outerElement);
     AssertTopInsideOf(innerElement, outerElement);
     AssertBottomInsideOf(innerElement, outerElement);
 }
示例#28
0
        public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode)
        {
            IList <ILayoutComponent> components = lvstate.Layout.LayoutComponents;
            bool hasMapDisplay = false;

            for (int i = components.Count - 1; i >= 0; i--)
            {
                ILayoutComponent component = components[i];
                if (component.Component is OriMapDisplayComponent)
                {
                    if (!settings.ShowMapDisplay || hasMapDisplay)
                    {
                        components.Remove(component);
                    }
                    hasMapDisplay = true;
                }
                else if (component.Component is OriComponent && invalidator == null && width == 0 && height == 0)
                {
                    components.Remove(component);

                    if (!hasMapDisplay && settings.ShowMapDisplay)
                    {
                        components.Insert(i, mapDisplay);
                        hasMapDisplay = true;
                    }
                }
            }

            if (settings.ShowMapDisplay && !hasMapDisplay)
            {
                components.Add(mapDisplay);
            }

            if (Model == null)
            {
                Model = new TimerModel()
                {
                    CurrentState = lvstate
                };
                lvstate.OnReset     += OnReset;
                lvstate.OnPause     += OnPause;
                lvstate.OnResume    += OnResume;
                lvstate.OnStart     += OnStart;
                lvstate.OnSplit     += OnSplit;
                lvstate.OnUndoSplit += OnUndoSplit;
                lvstate.OnSkipSplit += OnSkipSplit;
            }

            GetValues();
        }
        public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode)
        {
            IList <ILayoutComponent> components = lvstate.Layout.LayoutComponents;

            for (int i = components.Count - 1; i >= 0; i--)
            {
                ILayoutComponent component = components[i];
                if (component.Component is SteamWorldComponent && invalidator == null && width == 0 && height == 0)
                {
                    components.Remove(component);
                }
            }

            GetValues();
        }
示例#30
0
        public void Update(ILayoutComponent layout)
        {
            if (requireManual && !executeManual)
            {
                return;
            }
            if (executeManual)
            {
                executeManual = false;
            }

            DetectChildChanges(layout);
            CollectChildrenForLayout(layout);
            ExecuteLayout(layout);
        }