summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-02-20 21:12:00 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-02-20 21:12:00 -0500
commit6a9bf10a81f4557d44668666117d99440d99d873 (patch)
tree915ab2b89956e016d160a70f4fabe7a8f77b89c9 /src/SMAPI/Framework
parenteff29d94fbf41f0992ffac7bb5a04a08b71f3453 (diff)
downloadSMAPI-6a9bf10a81f4557d44668666117d99440d99d873.tar.gz
SMAPI-6a9bf10a81f4557d44668666117d99440d99d873.tar.bz2
SMAPI-6a9bf10a81f4557d44668666117d99440d99d873.zip
migrate to new method in SMAPI 3.3
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForImage.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/Content/AssetDataForImage.cs b/src/SMAPI/Framework/Content/AssetDataForImage.cs
index aa615a0b..44a97136 100644
--- a/src/SMAPI/Framework/Content/AssetDataForImage.cs
+++ b/src/SMAPI/Framework/Content/AssetDataForImage.cs
@@ -1,6 +1,7 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
+using StardewValley;
namespace StardewModdingAPI.Framework.Content
{
@@ -102,5 +103,21 @@ namespace StardewModdingAPI.Framework.Content
// patch target texture
target.SetData(0, targetArea, sourceData, 0, pixelCount);
}
+
+ /// <summary>Extend the image if needed to fit the given size. Note that this is an expensive operation, creates a new texture instance, and that extending a spritesheet horizontally may cause game errors or bugs.</summary>
+ /// <param name="minWidth">The minimum texture width.</param>
+ /// <param name="minHeight">The minimum texture height.</param>
+ /// <returns>Whether the texture was resized.</returns>
+ public bool ExtendImage(int minWidth, int minHeight)
+ {
+ if (this.Data.Width >= minWidth && this.Data.Height >= minHeight)
+ return false;
+
+ Texture2D original = this.Data;
+ Texture2D texture = new Texture2D(Game1.graphics.GraphicsDevice, Math.Max(original.Width, minWidth), Math.Max(original.Height, minHeight));
+ this.ReplaceWith(texture);
+ this.PatchImage(original);
+ return true;
+ }
}
}