Browse Source

Fixed constructor and override warnings

Jean-David Moisan 3 năm trước cách đây
mục cha
commit
ff8860397f

+ 2 - 2
Source/Dock.cs

@@ -86,7 +86,7 @@ namespace Apos.Gui {
         public virtual IComponent GetNext(IComponent c) {
             return Parent?.GetNext(this) ?? this;
         }
-        public virtual IComponent GetLast() {
+        public override IComponent GetLast() {
             return Child?.GetLast() ?? this;
         }
 
@@ -94,7 +94,7 @@ namespace Apos.Gui {
             Parent?.SendToTop(this);
         }
 
-        public static new Dock Put(float left, float top, float right, float bottom, [CallerLineNumber] int id = 0, bool isAbsoluteId = false) {
+        public static Dock Put(float left, float top, float right, float bottom, [CallerLineNumber] int id = 0, bool isAbsoluteId = false) {
             // 1. Check if dock with id already exists.
             //      a. If already exists. Get it.
             //      b  If not, create it.

+ 2 - 2
Source/FloatingWindow.cs

@@ -53,7 +53,7 @@ namespace Apos.Gui {
             base.Draw(gameTime);
         }
 
-        public static FloatingWindow Push([CallerLineNumber] int id = 0, bool isAbsoluteId = false) {
+        public static new FloatingWindow Push([CallerLineNumber] int id = 0, bool isAbsoluteId = false) {
             // 1. Check if window with id already exists.
             //      a. If already exists. Get it.
             //      b  If not, create it.
@@ -82,7 +82,7 @@ namespace Apos.Gui {
 
             return a;
         }
-        public static void Pop() {
+        public static new void Pop() {
             GuiHelper.CurrentIMGUI.Pop();
         }
 

+ 1 - 1
Source/Horizontal.cs

@@ -181,7 +181,7 @@ namespace Apos.Gui {
         /// <summary>
         /// Returns the last child in this component tree.
         /// </summary>
-        public virtual IComponent GetLast() {
+        public override IComponent GetLast() {
             return _children.Count > 0 ? _children.Last().GetLast() : this;
         }
 

+ 18 - 0
Source/IComponent.cs

@@ -3,6 +3,9 @@ using Microsoft.Xna.Framework;
 using MonoGame.Extended;
 
 namespace Apos.Gui {
+    /// <summary>
+    /// Base API for components.
+    /// </summary>
     public interface IComponent {
         /// <summary>
         /// Managed automatically when a component is created. Used by an IParent to keep track of it's children.
@@ -65,8 +68,17 @@ namespace Apos.Gui {
         /// </summary>
         RectangleF Clip { get; set; }
 
+        /// <summary>
+        /// X and Y positions in the UI coordinate system.
+        /// </summary>
         Vector2 XY { get; set; }
+        /// <summary>
+        /// Width and Height of the component given by it's parent.
+        /// </summary>
         Vector2 Size { get; set; }
+        /// <summary>
+        /// The component's preferred width and height. It's up to the parent to respect that.
+        /// </summary>
         Vector2 PrefSize { get; set; }
         /// <summary>
         /// X
@@ -105,8 +117,14 @@ namespace Apos.Gui {
         /// This is where everything that doesn't rely on inputs gets updated.
         /// </summary>
         void Update(GameTime gameTime);
+        /// <summary>
+        /// Draws the component. The component should draw itself within it's clip rectangle.
+        /// </summary>
         void Draw(GameTime gameTime);
 
+        /// <summary>
+        /// The component's parent once one has been assigned.
+        /// </summary>
         IParent? Parent { get; set; }
         /// <summary>
         /// Used for focus cycling. The component tree is flattened. This returns the component before the current one.

+ 2 - 2
Source/IMGUI.cs

@@ -145,7 +145,7 @@ namespace Apos.Gui {
         /// <summary>
         /// Removes a parent from the top of the parent stack.
         /// </summary>
-        public new void Pop() {
+        public void Pop() {
             var pop = _parents.Pop();
             _currentParent = pop.Parent;
             _maxChildren = pop.MaxChildren;
@@ -320,7 +320,7 @@ namespace Apos.Gui {
         /// <summary>
         /// Returns the last child in this component tree.
         /// </summary>
-        public virtual IComponent GetLast() {
+        public override IComponent GetLast() {
             return _children.Count > 0 ? _children.Last().GetLast() : this;
         }
 

+ 1 - 1
Source/Label.cs

@@ -87,7 +87,7 @@ namespace Apos.Gui {
             return a;
         }
 
-        protected string _text;
+        protected string _text = null!;
         protected int _fontSize;
         protected Vector2 _cachedSize;
 

+ 2 - 2
Source/Slider.cs

@@ -106,12 +106,12 @@ namespace Apos.Gui {
 
         protected void SlideValue(ICondition condition, int direction) {
             if (condition.Pressed()) {
-                Value = MathHelper.Max(MathHelper.Min(Value + direction * Step.Value, Max), Min);
+                Value = MathHelper.Max(MathHelper.Min(Value + direction * Step!.Value, Max), Min);
                 _inputDelay = _inputDelayInitialSpeed;
             }
             if (condition.HeldOnly()) {
                 if (_inputDelay <= 0) {
-                    Value = MathHelper.Max(MathHelper.Min(Value + direction * Step.Value, Max), Min);
+                    Value = MathHelper.Max(MathHelper.Min(Value + direction * Step!.Value, Max), Min);
                     _inputDelay = _inputDelaySpeed;
                 }
             }

+ 1 - 1
Source/Textbox.cs

@@ -199,7 +199,7 @@ namespace Apos.Gui {
             return currentPosition;
         }
 
-        protected string _text;
+        protected string _text = null!;
         protected Vector2 _size;
 
         protected int _fontSize;

+ 1 - 1
Source/Vertical.cs

@@ -181,7 +181,7 @@ namespace Apos.Gui {
         /// <summary>
         /// Returns the last child in this component tree.
         /// </summary>
-        public virtual IComponent GetLast() {
+        public override IComponent GetLast() {
             return _children.Count > 0 ? _children.Last().GetLast() : this;
         }