migrate to new method in SMAPI 3.3
This commit is contained in:
parent
eff29d94fb
commit
6a9bf10a81
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
* For modders:
|
* For modders:
|
||||||
* Added support for [message sending](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations#Message_sending) to mods on the current computer.
|
* Added support for [message sending](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations#Message_sending) to mods on the current computer.
|
||||||
|
* Added `ExtendImage` method to content API when editing files to resize textures.
|
||||||
* Added `helper.Input.GetStatus` to get the low-level status of a button.
|
* Added `helper.Input.GetStatus` to get the low-level status of a button.
|
||||||
* **[Breaking change]** Map tilesheets are no loaded from `Content` if they can't be found in `Content/Maps`. This reflects an upcoming change in the game to delete map tilesheets under `Content`.
|
* **[Breaking change]** Map tilesheets are no loaded from `Content` if they can't be found in `Content/Maps`. This reflects an upcoming change in the game to delete map tilesheets under `Content`.
|
||||||
* Improved map tilesheet errors so they provide more info.
|
* Improved map tilesheet errors so they provide more info.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Framework.Content
|
namespace StardewModdingAPI.Framework.Content
|
||||||
{
|
{
|
||||||
|
@ -102,5 +103,21 @@ namespace StardewModdingAPI.Framework.Content
|
||||||
// patch target texture
|
// patch target texture
|
||||||
target.SetData(0, targetArea, sourceData, 0, pixelCount);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,11 @@ namespace StardewModdingAPI
|
||||||
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="targetArea"/> is outside the bounds of the spritesheet.</exception>
|
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="targetArea"/> is outside the bounds of the spritesheet.</exception>
|
||||||
/// <exception cref="InvalidOperationException">The content being read isn't an image.</exception>
|
/// <exception cref="InvalidOperationException">The content being read isn't an image.</exception>
|
||||||
void PatchImage(Texture2D source, Rectangle? sourceArea = null, Rectangle? targetArea = null, PatchMode patchMode = PatchMode.Replace);
|
void PatchImage(Texture2D source, Rectangle? sourceArea = null, Rectangle? targetArea = null, PatchMode patchMode = PatchMode.Replace);
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
bool ExtendImage(int minWidth, int minHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue