diff --git a/.gitignore b/.gitignore
index c79d4de..e6c95dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -275,4 +275,5 @@ __pycache__/
# Cake - Uncomment if you are using it
# tools/
-nuget.exe
\ No newline at end of file
+nuget.exe
+GeonBit.UI/Content/GeonBit.UI.DataTypes.dll
diff --git a/GeonBit.UI/Content/GeonBit.UI.DataTypes.dll b/GeonBit.UI/Content/GeonBit.UI.DataTypes.dll
index fa3d4b4..baceb2b 100644
Binary files a/GeonBit.UI/Content/GeonBit.UI.DataTypes.dll and b/GeonBit.UI/Content/GeonBit.UI.DataTypes.dll differ
diff --git a/GeonBit.UI/Source/Entities/Entity.cs b/GeonBit.UI/Source/Entities/Entity.cs
index e8b686f..820c063 100644
--- a/GeonBit.UI/Source/Entities/Entity.cs
+++ b/GeonBit.UI/Source/Entities/Entity.cs
@@ -529,7 +529,7 @@ public Rectangle InternalDestRect
/// Create the entity.
///
/// Entity size, in pixels.
- /// Poisition anchor.
+ /// Position anchor.
/// Offset from anchor position.
public Entity(Vector2? size = null, Anchor anchor = Anchor.Auto, Vector2? offset = null)
{
diff --git a/GeonBit.UI/Source/Entities/Icon.cs b/GeonBit.UI/Source/Entities/Icon.cs
index 9371e5d..02aaa0a 100644
--- a/GeonBit.UI/Source/Entities/Icon.cs
+++ b/GeonBit.UI/Source/Entities/Icon.cs
@@ -173,7 +173,7 @@ public IconType IconType
/// Whether or not to show icon inventory-like background.
/// Offset from anchor position.
public Icon(IconType icon, Anchor anchor = Anchor.Auto, float scale = 1.0f, bool background = false, Vector2? offset = null) :
- base(null, USE_DEFAULT_SIZE, ImageDrawMode.Stretch, anchor, offset)
+ base((Texture2D)null, USE_DEFAULT_SIZE, ImageDrawMode.Stretch, anchor, offset)
{
// set scale and basic properties
Scale = scale;
diff --git a/GeonBit.UI/Source/Entities/Image.cs b/GeonBit.UI/Source/Entities/Image.cs
index 1c830f0..040a12b 100644
--- a/GeonBit.UI/Source/Entities/Image.cs
+++ b/GeonBit.UI/Source/Entities/Image.cs
@@ -7,10 +7,8 @@
// Since: 2016.
//-----------------------------------------------------------------------------
#endregion
-using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
-using GeonBit.UI.DataTypes;
namespace GeonBit.UI.Entities
{
@@ -71,7 +69,7 @@ public string TextureName
/// Image texture.
/// Image size.
/// How to draw the image (see ImageDrawMode for more info).
- /// Poisition anchor.
+ /// Position anchor.
/// Offset from anchor position.
public Image(Texture2D texture, Vector2? size = null, ImageDrawMode drawMode = ImageDrawMode.Stretch, Anchor anchor = Anchor.Auto, Vector2? offset = null) :
base(size, anchor, offset)
@@ -84,10 +82,23 @@ public Image(Texture2D texture, Vector2? size = null, ImageDrawMode drawMode = I
UpdateStyle(DefaultStyle);
}
+ ///
+ /// Create image from texture path.
+ ///
+ /// Texture path, under active theme folder.
+ /// Image size.
+ /// How to draw the image (see ImageDrawMode for more info).
+ /// Position anchor.
+ /// Offset from anchor position.
+ public Image(string texture, Vector2? size = null, ImageDrawMode drawMode = ImageDrawMode.Stretch, Anchor anchor = Anchor.Auto, Vector2? offset = null) :
+ this(Resources.Instance.LoadTexture(texture), size, drawMode, anchor, offset)
+ {
+ }
+
///
/// Create image without texture.
///
- public Image() : this(null)
+ public Image() : this((Texture2D)null)
{
}
diff --git a/GeonBit.UI/Source/Input/DefaultInputProvider.cs b/GeonBit.UI/Source/Input/DefaultInputProvider.cs
index 23c6d79..226375a 100644
--- a/GeonBit.UI/Source/Input/DefaultInputProvider.cs
+++ b/GeonBit.UI/Source/Input/DefaultInputProvider.cs
@@ -471,7 +471,7 @@ public string GetTextInput(string txt, int lineWidth, ref int pos)
}
///
- /// Get current mouse poisition.
+ /// Get current mouse Position.
///
public Vector2 MousePosition
{
diff --git a/GeonBit.UI/Source/Input/IMouseInput.cs b/GeonBit.UI/Source/Input/IMouseInput.cs
index 86b5f56..5b8c7da 100644
--- a/GeonBit.UI/Source/Input/IMouseInput.cs
+++ b/GeonBit.UI/Source/Input/IMouseInput.cs
@@ -42,7 +42,7 @@ public interface IMouseInput
void Update(GameTime gameTime);
///
- /// Get current mouse poisition.
+ /// Get current mouse Position.
///
Vector2 MousePosition { get; }
diff --git a/GeonBit.UI/Source/Resources.cs b/GeonBit.UI/Source/Resources.cs
index aeef691..2012b4c 100644
--- a/GeonBit.UI/Source/Resources.cs
+++ b/GeonBit.UI/Source/Resources.cs
@@ -498,6 +498,16 @@ private void LoadDefaultStyles(StyleSheet sheet, string entityName, string theme
FillDefaultStyles(sheet, EntityState.MouseDown, LoadXmlStyles($"{stylesheetBase}-MouseDown", content));
}
+ ///
+ /// Load texture from path.
+ ///
+ /// Texture path, under theme folder.
+ /// Texture instance.
+ public Texture2D LoadTexture(string path)
+ {
+ return _content.Load(System.IO.Path.Combine(_root, path));
+ }
+
///
/// Fill a set of default styles into a given stylesheet.
///
diff --git a/README.md b/README.md
index 54a0b32..fc0a9f5 100644
--- a/README.md
+++ b/README.md
@@ -2098,6 +2098,8 @@ For older MonoGame versions, see [tag 2.1.0.0](https://github.com/RonenNess/Geon
- - In addition, renamed 'DropDown.SelectedPanelHeight' to 'DropDown.DefaultSelectedTextPanelHeight', and this property will only be used if 'DropDownSelectedPanel' stylesheet is missing, or define default height to 1 or 0.
- Removed compile warnings by adding defaults and `= null!`.
- Changed Slider and Progress bar Min and Max properties to support negative numbers. Now sliders can go negative!
+- Fixed typos.
+- Added option to create Image from path.
## Credits