Esempio n. 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;
 }
Esempio n. 2
0
        public void AddUIElement(UIElement uielement, Vector2 positionRelativeToPanelCentre)
        {
            uielement.SetPosition(positionRelativeToPanelCentre + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
Esempio n. 3
0
        public void AddUIElement(UIElement uielement)
        {
            uielement.SetPosition(uielement.Position + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
Esempio n. 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));
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 8
0
        public void LoadAndAddUIElement(UIElement uielement, Vector2 positionRelativeToPanelCentre)
        {
            uielement.LoadContent(ScreenManager.Content);
            uielement.SetPosition(positionRelativeToPanelCentre + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
Esempio n. 9
0
        public void LoadAndAddUIElement(UIElement uielement)
        {
            uielement.LoadContent(ScreenManager.Content);
            uielement.SetPosition(uielement.Position + Position - paddingVector);
            UIElementsToAdd.Add(uielement);

            // UpdateDimensions(uielement);
        }
Esempio n. 10
0
        public void AddUIElementRelativeTo(UIElement uielementToAdd, UIElement uielementRelativeTo, Vector2 offset)
        {
            uielementToAdd.SetPosition(uielementRelativeTo.Position + offset);
            UIElementsToAdd.Add(uielementToAdd);

            // UpdateDimensions(uielementToAdd);
        }
Esempio n. 11
0
        public void AddUIElementRelativeTo(UIElement uielementToAdd, UIElement uielementRelativeTo)
        {
            uielementToAdd.SetPosition(uielementRelativeTo.Position + uielementToAdd.Position);
            UIElementsToAdd.Add(uielementToAdd);

            // UpdateDimensions(uielementToAdd);
        }
 public bool IsVisible(UIElement uielement)
 {
     if (ViewRectangle.Intersects(uielement.Bounds))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 15
0
 // Add a camera independent Screen UIElement
 public void AddScreenUIElement(UIElement ui)
 {
     ui.LoadContent(ScreenManager.Content);
     ScreenUIElementsToAdd.Add(ui);
 }