コード例 #1
0
 // Useful for texts that is linked with buttons
 public Text(string text, UIElement parentUIElement, Vector2 offset, Color colour, string name, string spriteFont = "Fonts/TextFont")
     : base("", parentUIElement.Position, name)
 {
     LinesOfStrings = new List<string>() { text };
     FontAsset = spriteFont;
     ParentUIElement = parentUIElement;
     ParentOffset = offset;
     Colour = colour;
 }
コード例 #2
0
        public void AddUIElement(UIElement uielement, Vector2 positionRelativeToPanelCentre)
        {
            uielement.SetPosition(positionRelativeToPanelCentre + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
コード例 #3
0
        public void AddUIElement(UIElement uielement)
        {
            uielement.SetPosition(uielement.Position + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
コード例 #4
0
        // Experimental Function - still needs work
        private void UpdateDimensions(UIElement uielement)
        {
            float increaseWidth = 0, increaseHeight = 0;

            // The left hand side of the object - padding lies to the left of the bounds so we need to increase the bounds
            if (Bounds.Left > uielement.Bounds.Left)
            {
                // Increase the width by twice this much - add on the same amount to both sides
                increaseWidth = 2 * (Bounds.Left - uielement.Bounds.Left);
            }
            // Top of the uielement has gone over the bounds of the panel
            if (Bounds.Top > uielement.Bounds.Top)
            {
                increaseHeight = 2 * (Bounds.Top - uielement.Bounds.Top);
            }
            // Right of the uielement has gone over the right of the panel
            if (Bounds.Right < uielement.Bounds.Right)
            {
                increaseWidth = (float)Math.Max(increaseWidth, 2 * (uielement.Bounds.Right - Bounds.Right));
            }
            if (Bounds.Bottom < uielement.Bounds.Bottom)
            {
                increaseHeight = (float)Math.Max(increaseHeight, 2 * (uielement.Bounds.Bottom - Bounds.Bottom));
            }

            Dimensions += new Vector2(increaseWidth, increaseHeight);
            Scale = new Vector2(Dimensions.X / Texture.Width, Dimensions.Y / Texture.Height);

            if (ActiveUIElements.Count == 1)
            {
                SetPosition(Position - paddingVector);
            }
            else
            {
                SetPosition(Position + new Vector2(0, paddingVector.Y) + new Vector2(0, uielement.Bounds.Height / 2));
            }
        }
コード例 #5
0
        public void LoadAndAddUIElementRelativeTo(UIElement uielementToAdd, string uielementRelativeToName, Vector2 offset)
        {
            UIElement elementRelativeTo = ActiveUIElements.Find(x => x.Name == uielementRelativeToName);

            if (elementRelativeTo != null)
            {
                LoadAndAddUIElementRelativeTo(uielementToAdd, elementRelativeTo, offset);
            }
        }
コード例 #6
0
        public void LoadAndAddUIElementRelativeTo(UIElement uielementToAdd, UIElement uielementRelativeTo, Vector2 offset)
        {
            uielementToAdd.LoadContent(ScreenManager.Content);
            uielementToAdd.SetPosition(uielementRelativeTo.Position + offset);
            UIElementsToAdd.Add(uielementToAdd);

            // UpdateDimensions(uielementToAdd);
        }
コード例 #7
0
        public void LoadAndAddUIElementRelativeTo(UIElement uielementToAdd, string uielementRelativeToName)
        {
            UIElement elementRelativeTo = ActiveUIElements.Find(x => x.Name == uielementRelativeToName);

            if (elementRelativeTo != null)
            {
                LoadAndAddUIElementRelativeTo(uielementToAdd, elementRelativeTo, uielementToAdd.Position);
            }
        }
コード例 #8
0
        public void LoadAndAddUIElement(UIElement uielement, Vector2 positionRelativeToPanelCentre)
        {
            uielement.LoadContent(ScreenManager.Content);
            uielement.SetPosition(positionRelativeToPanelCentre + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
コード例 #9
0
        public void LoadAndAddUIElement(UIElement uielement)
        {
            uielement.LoadContent(ScreenManager.Content);
            uielement.SetPosition(uielement.Position + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
コード例 #10
0
        public void AddUIElementRelativeTo(UIElement uielementToAdd, UIElement uielementRelativeTo, Vector2 offset)
        {
            uielementToAdd.SetPosition(uielementRelativeTo.Position + offset);
            UIElementsToAdd.Add(uielementToAdd);

            // UpdateDimensions(uielementToAdd);
        }
コード例 #11
0
        public void AddUIElementRelativeTo(UIElement uielementToAdd, UIElement uielementRelativeTo)
        {
            uielementToAdd.SetPosition(uielementRelativeTo.Position + uielementToAdd.Position);
            UIElementsToAdd.Add(uielementToAdd);

            // UpdateDimensions(uielementToAdd);
        }
コード例 #12
0
 public bool IsVisible(UIElement uielement)
 {
     if (ViewRectangle.Intersects(uielement.Bounds))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #13
0
        // Remove a specific UIElement from the screen's Screen UIElements
        public bool RemoveScreenUIElement(UIElement ui)
        {
            if (ScreenUIElements.Contains(ui))
            {
                ScreenUIElementsToRemove.Add(ui);
                return true;
            }

            return false;
        }
コード例 #14
0
        // Remove a specific UIElement from the screen's Screen UIElements
        public bool RemoveInGameUIElement(UIElement ui)
        {
            if (InGameUIElements.Contains(ui))
            {
                InGameUIElementsToRemove.Add(ui);
                return true;
            }

            return false;
        }
コード例 #15
0
 // Add a camera independent Screen UIElement
 public void AddScreenUIElement(UIElement ui)
 {
     ui.LoadContent(ScreenManager.Content);
     ScreenUIElementsToAdd.Add(ui);
 }