public static GuiLabel createNewLabel(Vector2 position, string labelText, string fontName, Color labelColor) { GuiLabel label = new GuiLabel(new Rectangle(), labelText, fontName, labelColor); label.loadContent(RPGGame.AssetManager); label.calculateBounds(position); return(label); }
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); }
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); }
public void addLabel(GuiLabel label, int index = -1) { // Add the label, possibly at a specified index if (index < 0 || index >= labelList.Count) { labelList.Add(label); } else { labelList.Insert(index, label); } // Make sure all labels are in the correct positions calculateLabelPositions(); }
// TODO: see if this works as intended public void removeLabel(GuiLabel label) { int index = labelList.FindIndex(gl => label.Equals(gl)); removeLabel(index); }
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)); }