From d977d72274b2a6a666b6b66201a0bbe29359e6b2 Mon Sep 17 00:00:00 2001 From: Ronen Date: Thu, 28 Sep 2023 22:03:12 +0300 Subject: [PATCH] fixed typos and added option to load image from path --- .gitignore | 3 ++- GeonBit.UI/Content/GeonBit.UI.DataTypes.dll | Bin 7680 -> 8192 bytes GeonBit.UI/Source/Entities/Entity.cs | 2 +- GeonBit.UI/Source/Entities/Icon.cs | 2 +- GeonBit.UI/Source/Entities/Image.cs | 19 ++++++++++++++---- .../Source/Input/DefaultInputProvider.cs | 2 +- GeonBit.UI/Source/Input/IMouseInput.cs | 2 +- GeonBit.UI/Source/Resources.cs | 10 +++++++++ README.md | 2 ++ 9 files changed, 33 insertions(+), 9 deletions(-) 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 fa3d4b4ded742f2fd42524406c848373bd295a51..baceb2b56c7a5479a608f4b10d37a6bb58d2f49f 100644 GIT binary patch delta 2633 zcmZWrYiv|S6h1R^@9uVYDQvg9ebB2D zOIu@FL2bG4hY+MHNJ)$(Ya}QSNyNk-L_$KMf`-OOBF2bB2{DHF&D`6ijhozW&Uen4 zZ|0ntd)tFA9IPH1i0qkN{sY;+dlU(ISQ$|!91hFbSvh>JB{i#(Xt{J$6CD-9VZV1H zkr%wIf@qZ)=5x(fmhavfge!z6(|n5+vuyJ-md|FHKe0$wBNXIs2_8;5ZHp0oHG_zm z*MbX-2roz@a#K;8ZSah@XCjyv6er@0NGn=25fK05T*mkEU|hh!pvhr&bzGNYfnVuj zReu?yF}Vf&_<1)8sVm=C!^Rwi91myfIGAse*%$_2ELvY8XUkRW-LN}xU(zJq{DY>~a zS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,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