/// <summary> /// Create a new <see cref="CivPanel"/>. /// </summary> /// /// <param name="parent"> /// The parent within which the panel will be displayed. /// </param> /// <param name="civs"> /// The civs in the simulation. /// </param> public CivPanel(IPositionedElement parent, IEnumerable <Civilization> civs) : base(parent) { if (UIContentManager.TryGetInstance(out UIContentManager manager)) { _civTexturePairs = new Dictionary <Civilization, Entry>(); _scrollOffset = 0; Visible = true; Focused = true; _textFont = manager.GetFont("DebugFont"); _civText = new RelativeText(this, _textFont); _scrollbar = new Scrollbar(this) { AnchorPosition = AnchorPosition.TopRight, Size = new Point(15, Size.Y), RelativePosition = new Point(-15, 0) }; foreach (Civilization civ in civs) { _civTexturePairs.Add(civ, new Entry() { EntryHeight = 0, Texture = new RelativeTexture(this, new SpriteDefinition(manager.GetColorTexture(civ.Color), new Rectangle(0, 0, 1, 1))) }); } } else { throw new InvalidOperationException("UI Content manager does not exist."); } }
/// <summary> /// Create a new <see cref="InputNumberField"/>. /// Creates sub elements and sets default values. /// </summary> /// <param name="parent"></param> public InputNumberField(IPositionedElement parent) : base(parent) { if (UIContentManager.TryGetInstance(out UIContentManager contentManager)) { _background = new RelativeTexture(this, new SpriteDefinition(contentManager.GetColorTexture(Color.White), new Rectangle(Point.Zero, new Point(1, 1)))) { AnchorPosition = AnchorPosition.TopLeft, RelativePosition = Point.Zero, }; _renderText = new RelativeText(this, contentManager.GetFont("DebugFont")) { AnchorPosition = AnchorPosition.TopLeft, RelativePosition = new Point(1, 1) }; _textSb = new StringBuilder(); Visible = true; } else { throw new InvalidOperationException("UI content manager does not exist."); } }