/// <summary> /// Creates a text button /// </summary> /// <param name="text">the text</param> /// <param name="font">the font</param> /// <param name="verticalAlignment">vertical alignment of the image</param> /// <param name="horizontalAlignment">horizontal alignment of the image</param> /// <param name="position">absolute position on the screen</param> /// <param name="toggle">toggleable?</param> public TextButton(String text, String font, Horizontal horizontalAlignment, Vertical verticalAlignment, Boolean toggle = false, Vector2 position = new Vector2()) : base(toggle) { this.label = new Label(text, font, horizontalAlignment, verticalAlignment, position); this.font = font; this.ResetPosition(); this.toggle = toggle; FenrirGame.Instance.Properties.onResolutionChanged += new EventHandler(ResetPosition); }
/// <summary> /// Renders a Label /// </summary> /// <param name="label">the label to be rendered</param> public void Draw(Label label) { if (!this.isPrepared) { FenrirGame.Instance.Log(LogLevel.Warn, "tried to render " + label.Text + " without beeing prepared - aborting"); return; } FenrirGame.Instance.Properties.SpriteBatch.DrawString( label.Font, FenrirGame.Instance.Properties.ContentManager.getLocalization(label.Text), label.RenderPosition, label.Color, 0, new Vector2(), 1, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 1); }
public StatsPanel(Stats data) { this.data = data; this.nameLabel = new Label("#unit_name#", DataIdentifier.defaultFontSmall, Horizontal.Left, Vertical.Top); this.nameValue = new Label("", DataIdentifier.defaultFontSmall, Horizontal.Left, Vertical.Top); this.ageLabel = new Label("#unit_age#", DataIdentifier.defaultFontSmall, Horizontal.Left, Vertical.Top); this.ageValue = new Label("", DataIdentifier.defaultFontSmall, Horizontal.Left, Vertical.Top); this.miningLabel = new Label("#unit_mining#", DataIdentifier.defaultFontSmall, Horizontal.Left, Vertical.Top); this.miningValue = new Label("", DataIdentifier.defaultFontSmall, Horizontal.Left, Vertical.Top); this.AddUiElement(new Vector2(-200, 100), nameLabel); this.AddUiElement(new Vector2(-100, 100), nameValue); this.AddUiElement(new Vector2(-200, 130), ageLabel); this.AddUiElement(new Vector2(-100, 130), ageValue); this.AddUiElement(new Vector2(-200, 160), miningLabel); this.AddUiElement(new Vector2(-100, 160), miningValue); this.ResetPosition(new Vector2()); }
/// <summary> /// Creates the SelectionList /// </summary> /// <param name="yPos"></param> /// <param name="font"></param> /// <param name="label"></param> /// <param name="data"></param> /// <param name="dataIndex"></param> public SelectionList(String text, String font, List<String> data, int defaultIndex, Horizontal horizontalAlignment, Vertical verticalAlignment, Vector2 position = new Vector2()) { this.data = data; this.entries = new List<TextButton>(); this.font = font; this.index = defaultIndex; this.position = position; this.buildList(); this.label = new Label(text, font, Horizontal.Left, Vertical.Top); this.ResetPosition(position); }