add support for loading BmFont files for custom languages

This commit is contained in:
Jesse Plamondon-Willard 2021-11-25 23:01:14 -05:00
parent f87e65caf5
commit d1d09ae1df
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
3 changed files with 12 additions and 1 deletions

View File

@ -5,6 +5,7 @@
* For players:
* Updated for Stardew Valley 1.5.5.
* Updated compatibility list.
* Added support for loading BmFont `.fnt` files for [custom languages](https://stardewvalleywiki.com/Modding:Custom_languages) through the [content API](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Content).
* Added `set_farm_type` [console command](https://stardewvalleywiki.com/Modding:Console_commands#Console_commands) to change the current farm type.
* Fixed installer window closing immediately if the installer crashed.

View File

@ -2,6 +2,7 @@ using System;
using System.Globalization;
using System.IO;
using System.Linq;
using BmFont;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@ -129,6 +130,14 @@ namespace StardewModdingAPI.Framework.ContentManagers
}
break;
// unpacked Bitmap font
case ".fnt":
{
string source = File.ReadAllText(file.FullName);
asset = (T)(object)new XmlSource(source);
}
break;
// unpacked data
case ".json":
{
@ -171,7 +180,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
break;
default:
throw GetContentError($"unknown file extension '{file.Extension}'; must be one of '.json', '.png', '.tbin', or '.xnb'.");
throw GetContentError($"unknown file extension '{file.Extension}'; must be one of '.fnt', '.json', '.png', '.tbin', or '.xnb'.");
}
}
catch (Exception ex) when (!(ex is SContentLoadException))

View File

@ -31,6 +31,7 @@
<Reference Include="..\..\build\0Harmony.dll" Private="True" />
<Reference Include="Stardew Valley" HintPath="$(GamePath)\Stardew Valley.dll" Private="False" />
<Reference Include="StardewValley.GameData" HintPath="$(GamePath)\StardewValley.GameData.dll" Private="False" />
<Reference Include="BmFont" HintPath="$(GamePath)\BmFont.dll" Private="False" />
<Reference Include="GalaxyCSharp" HintPath="$(GamePath)\GalaxyCSharp.dll" Private="False" />
<Reference Include="Lidgren.Network" HintPath="$(GamePath)\Lidgren.Network.dll" Private="False" />
<Reference Include="MonoGame.Framework" HintPath="$(GamePath)\MonoGame.Framework.dll" Private="False" />