Skip to content

Commit

Permalink
Marked the AutoTiling system as deprecated for removal in a future ve…
Browse files Browse the repository at this point in the history
…rsion
  • Loading branch information
Ellpeck committed Feb 2, 2025
1 parent 0f740e2 commit f010375
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 90 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Fixes

Removals
- Marked SpriteBatchExtensions GenerateTexture and GenerateSquareTexture as obsolete in favor of their more clearly named replacements
- Marked the AutoTiling system as deprecated for removal in a future version

### MLEM.Ui
Additions
Expand Down
76 changes: 0 additions & 76 deletions Demos/AutoTilingDemo.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Demos/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@
/processorParam:TextureFormat=Color
/build:Textures/Anim.png

#begin Textures/AutoTiling.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AutoTiling.png

#begin Textures/Test.png
/importer:TextureImporter
/processor:TextureProcessor
Expand All @@ -112,4 +100,3 @@
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/Tree.png

Binary file removed Demos/Content/Textures/AutoTiling.png
Binary file not shown.
1 change: 0 additions & 1 deletion Demos/GameImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ static GameImpl() {
GameImpl.Demos.Add("Easings", ("An example of MLEM's Easings class, an adaptation of easings.net", game => new EasingsDemo(game)));
GameImpl.Demos.Add("Pathfinding", ("An example of MLEM's A* pathfinding implementation in 2D", game => new PathfindingDemo(game)));
GameImpl.Demos.Add("Animation and Texture Atlas", ("An example of UniformTextureAtlases, SpriteAnimations and SpriteAnimationGroups", game => new AnimationDemo(game)));
GameImpl.Demos.Add("Auto Tiling", ("A demonstration of the AutoTiling class that MLEM provides", game => new AutoTilingDemo(game)));
}

public GameImpl() {
Expand Down
12 changes: 12 additions & 0 deletions MLEM/Graphics/AutoTiling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace MLEM.Graphics {
/// This class contains a <see cref="DrawAutoTile"/> method that allows users to easily draw a tile with automatic connections, as well as a more complex <see cref="DrawExtendedAutoTile(Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,MLEM.Textures.TextureRegion,MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float,float)"/> method.
/// Note that <see cref="StaticSpriteBatch"/> can also be used for drawing by using the <see cref="AddAutoTile"/> and <see cref="AddExtendedAutoTile(MLEM.Graphics.StaticSpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,MLEM.Textures.TextureRegion,MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float,float,System.Collections.Generic.ICollection{MLEM.Graphics.StaticSpriteBatch.Item})"/> methods instead.
/// </summary>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static class AutoTiling {

/// <summary>
Expand All @@ -34,6 +35,7 @@ public static class AutoTiling {
/// <param name="origin">The origin to draw from.</param>
/// <param name="scale">The scale to draw with.</param>
/// <param name="layerDepth">The layer depth to draw with.</param>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion texture, ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) {
var orig = origin ?? Vector2.Zero;
var sc = scale ?? Vector2.One;
Expand All @@ -45,6 +47,7 @@ public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion te
}

/// <inheritdoc cref="DrawAutoTile"/>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void AddAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion texture, ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null) {
var orig = origin ?? Vector2.Zero;
var sc = scale ?? Vector2.One;
Expand Down Expand Up @@ -86,6 +89,7 @@ public static void AddAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegi
/// <param name="scale">The scale to draw with.</param>
/// <param name="layerDepth">The layer depth to draw with.</param>
/// <param name="overlayDepthOffset">An optional depth offset from <paramref name="layerDepth"/> that the overlay should be drawn with</param>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0) {
if (backgroundTexture != null)
batch.Draw(backgroundTexture, pos, backgroundColor, 0, origin ?? Vector2.Zero, scale ?? Vector2.One, SpriteEffects.None, layerDepth);
Expand All @@ -111,13 +115,15 @@ public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureR
/// <param name="origin">The origin to draw from.</param>
/// <param name="scale">The scale to draw with.</param>
/// <param name="layerDepth">The layer depth to draw with.</param>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void DrawExtendedAutoTileCorner(SpriteBatch batch, Vector2 pos, TextureRegion overlayTexture, ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) {
var src = AutoTiling.CalculateExtendedAutoTile(overlayTexture.Area, connectsTo, corner);
if (src != Rectangle.Empty)
batch.Draw(overlayTexture.Texture, pos, src, overlayColor, 0, origin ?? Vector2.Zero, scale ?? Vector2.One, SpriteEffects.None, layerDepth);
}

/// <inheritdoc cref="DrawExtendedAutoTile(Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,MLEM.Textures.TextureRegion,MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float,float)"/>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, Func<int, TextureRegion> overlayTextures, ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0) {
if (backgroundTexture != null)
batch.Draw(backgroundTexture, pos, backgroundColor, 0, origin ?? Vector2.Zero, scale ?? Vector2.One, SpriteEffects.None, layerDepth);
Expand All @@ -129,6 +135,7 @@ public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureR
}

/// <inheritdoc cref="DrawExtendedAutoTileCorner(Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Direction2,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float)"/>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void DrawExtendedAutoTileCorner(SpriteBatch batch, Vector2 pos, Func<int, TextureRegion> overlayTextures, ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) {
var src = AutoTiling.CalculateExtendedAutoTileOffset(connectsTo, corner);
if (src >= 0) {
Expand All @@ -139,6 +146,7 @@ public static void DrawExtendedAutoTileCorner(SpriteBatch batch, Vector2 pos, Fu
}

/// <inheritdoc cref="DrawExtendedAutoTile(Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,MLEM.Textures.TextureRegion,MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float,float)"/>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0, ICollection<StaticSpriteBatch.Item> items = null) {
if (backgroundTexture != null) {
var background = batch.Add(backgroundTexture, pos, backgroundColor, 0, origin ?? Vector2.Zero, scale ?? Vector2.One, SpriteEffects.None, layerDepth);
Expand All @@ -152,6 +160,7 @@ public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, Tex
}

/// <inheritdoc cref="DrawExtendedAutoTileCorner(Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Direction2,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float)"/>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void AddExtendedAutoTileCorner(StaticSpriteBatch batch, Vector2 pos, TextureRegion overlayTexture, ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null) {
var src = AutoTiling.CalculateExtendedAutoTile(overlayTexture.Area, connectsTo, corner);
if (src != Rectangle.Empty) {
Expand All @@ -161,6 +170,7 @@ public static void AddExtendedAutoTileCorner(StaticSpriteBatch batch, Vector2 po
}

/// <inheritdoc cref="DrawExtendedAutoTile(Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,Func{int,MLEM.Textures.TextureRegion},MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework.Color,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float,float)"/>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, Func<int, TextureRegion> overlayTextures, ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0, ICollection<StaticSpriteBatch.Item> items = null) {
if (backgroundTexture != null) {
var background = batch.Add(backgroundTexture, pos, backgroundColor, 0, origin ?? Vector2.Zero, scale ?? Vector2.One, SpriteEffects.None, layerDepth);
Expand All @@ -174,6 +184,7 @@ public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, Tex
}

/// <inheritdoc cref="DrawExtendedAutoTileCorner(Microsoft.Xna.Framework.Graphics.SpriteBatch,Microsoft.Xna.Framework.Vector2,MLEM.Textures.TextureRegion,MLEM.Graphics.AutoTiling.ConnectsTo,Microsoft.Xna.Framework.Color,Direction2,System.Nullable{Microsoft.Xna.Framework.Vector2},System.Nullable{Microsoft.Xna.Framework.Vector2},float)"/>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public static void AddExtendedAutoTileCorner(StaticSpriteBatch batch, Vector2 pos, Func<int, TextureRegion> overlayTextures, ConnectsTo connectsTo, Color overlayColor, Direction2 corner, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null) {
var src = AutoTiling.CalculateExtendedAutoTileOffset(connectsTo, corner);
if (src >= 0) {
Expand Down Expand Up @@ -240,6 +251,7 @@ private static Rectangle CalculateExtendedAutoTile(Rectangle textureRegion, Conn
/// </summary>
/// <param name="xOff">The x offset</param>
/// <param name="yOff">The y offset</param>
[Obsolete("MLEM's auto-tiling system is deprecated and will be removed in a future version. It is recommended to switch to a custom approach or a more robust library.")]
public delegate bool ConnectsTo(int xOff, int yOff);

}
Expand Down

0 comments on commit f010375

Please sign in to comment.