Пример #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            foreach (var group in GroupElements.ToArray())
            {
                group.UIElement.Update(gameTime);
            }
        }
Пример #2
0
        /// <summary>
        /// Adds a new UI Element to the <see cref="GroupElements"/> list with the specified local position set as the <see cref="Core.GameObject.Position"/>.
        /// </summary>
        public T AddUIElement <T>(T uiElement) where T : UIElement
        {
            GroupElements.Add(new UIGroupElement(uiElement, uiElement.Transform.Position));

            //Add the UI Element to the screen's clickable items.
            screen.AddInteractable(uiElement); //Returns false if it wasn't an interactable.
            screen.AddScrollable(uiElement);   //Returns false if it wasn't a scrollable.

            CalculatePositions();

            return(uiElement);
        }
Пример #3
0
        /// <summary>
        /// Adds multiple new UI Elements to the <see cref="GroupElements"/> list with the specified local position set as the <see cref="Core.GameObject.Position"/>.
        /// </summary>
        public void AddUIElements(params UIElement[] uiElements)
        {
            for (int i = 0; i < uiElements.Length; i++)
            {
                GroupElements.Add(new UIGroupElement(uiElements[i], uiElements[i].Transform.Position));

                //Add the UI Element to the screen's clickable items.
                screen.AddInteractable(uiElements[i]); //Returns false if it wasn't an interactable.
                screen.AddScrollable(uiElements[i]);   //Returns false if it wasn't a scrollable.
            }

            CalculatePositions();
        }
Пример #4
0
 /// <summary>
 /// Remove UIElement from group.
 /// </summary>
 public void RemoveUIElement(UIElement uiElement)
 {
     GroupElements.RemoveAll(ge => ge.UIElement == uiElement); //Only remove the items that have the same UIElement reference as parameter uiElement.
 }
Пример #5
0
 /// <summary>
 /// Returns the <see cref="UIGroupElement"/> that has the <paramref name="uiElement"/>.
 /// Returns null if none were found.
 /// </summary>
 public UIGroupElement GetGroupElement(UIElement uiElement)
 {
     return(GroupElements.FirstOrDefault(ge => ge.UIElement == uiElement));
 }