Ejemplo n.º 1
0
        public static GuiButton createButtonWithLabel(GuiLabel label, string spriteName)
        {
            Rectangle bounds = new Rectangle(label.Bounds.Location - new Point(2, 2), label.Bounds.Size + new Point(4, 4));
            GuiButton retVal = new GuiButton(bounds, spriteName);

            retVal.label = label;
            return(retVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new black <code>GuiLabel</code>, based on the position, the text and the font supplied.
        /// </summary>
        /// <param name="position">The screen coords to place this <code>GuiLabel</code>.</param>
        /// <param name="labelText">The text this <code>GuiLabel</code> should display.</param>
        /// <param name="fontName">The name of the <code>SpriteFont</code> this <code>GuiLabel</code> should use.</param>
        /// <param name="labelColor">The <code>Color</code> this <code>GuiLabel</code> should be.</param>
        /// <returns>The <code>GuiLabel</code> to create.</returns>
        public static GuiLabel createNewLabel(Vector2 position, string labelText, string fontName, Color labelColor)
        {
            GuiLabel label = new GuiLabel(new Rectangle(), labelText, fontName, labelColor);

            label.loadContent(AssetManager.Instance);
            label.calculateBounds(position);
            return(label);
        }
Ejemplo n.º 3
0
        private static Vector2 getLabelSize(GuiLabel label)
        {
            // Make sure the font exists; no font means just padding
            if (label.font == null)
            {
                return(PaddingSize);
            }

            // Get the size of the string and add the padding
            Vector2 stringSize = label.font.MeasureString(label.labelText);

            return(PaddingSize + stringSize);
        }
Ejemplo n.º 4
0
        public static GuiButton createButtonWithLabel(Point topLeft, string text, string spriteName, string fontName)
        {
            GuiLabel label = GuiLabel.createNewLabel(topLeft.ToVector2() + new Vector2(2, 2), text, fontName);

            return(createButtonWithLabel(label, spriteName));
        }
Ejemplo n.º 5
0
        // TODO: see if this works as intended
        public void removeLabel(GuiLabel label)
        {
            int index = allElements.FindIndex(gl => label.Equals(gl));

            removeElement(index);
        }