diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-16 19:15:28 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-16 19:15:28 -0400 |
commit | 11569dac318a60bedd460b29a3a7991d21db32d3 (patch) | |
tree | 081d244fc7bfc5e998e9315b9b833de2d83bd2a8 | |
parent | f4a2d8100fa6553b79d3f91dfd7b2011ce453b79 (diff) | |
download | SMAPI-11569dac318a60bedd460b29a3a7991d21db32d3.tar.gz SMAPI-11569dac318a60bedd460b29a3a7991d21db32d3.tar.bz2 SMAPI-11569dac318a60bedd460b29a3a7991d21db32d3.zip |
fix maps not recognising custom tilesheets added through the SMAPI content API
-rw-r--r-- | release-notes.md | 5 | ||||
-rw-r--r-- | src/StardewModdingAPI/Framework/SGame.cs | 17 |
2 files changed, 19 insertions, 3 deletions
diff --git a/release-notes.md b/release-notes.md index d10ce4e1..abcce4d8 100644 --- a/release-notes.md +++ b/release-notes.md @@ -22,13 +22,14 @@ For players: * Updated mod compatibility list for Stardew Valley 1.2. For mod developers: +* SMAPI now logs basic context info to simplify troubleshooting. * Added a `Context.IsWorldReady` flag. - _<small>This is set to `true` when the player has loaded a save and the world is finished initialising. This is set at the same point that `SaveEvents.AfterLoad` and `TimeEvents.AfterDayStarted` are raised, and is mainly useful with events which can be raised before the world is loaded.</small>_ -* Added log entries for basic context changes (e.g. loaded save) to simplify troubleshooting. + _<small>This flag is true when a save is loaded and the world is finished initialising, which starts at the same point that `SaveEvents.AfterLoad` and `TimeEvents.AfterDayStarted` are raised. This is mainly useful with events which can be raised before the world is loaded (like update tick).</small>_ * Added a `debug` console command to TrainerMod which lets you pass debug commands to the game (e.g. `debug warp FarmHouse 1 1` warps the player to the farmhouse). * Added a deprecation warning for mods that don't set the `Name`, `Version`, or `UniqueID` manifest fields. These will be required in SMAPI 2.0. * Mods can now override `Dispose` if they need to release unmanaged resources. * Deprecated `GameEvents.GameLoaded` and `GameEvents.FirstUpdateTick`, since any logic in the mod's `Entry` method will happen after the game is loaded. +* Fixed maps not recognising custom tilesheets added through the SMAPI content API. ## 1.12 See [log](https://github.com/Pathoschild/SMAPI/compare/1.11...1.12). diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index 4f3a29fc..a340b995 100644 --- a/src/StardewModdingAPI/Framework/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -168,7 +168,7 @@ namespace StardewModdingAPI.Framework private static Stopwatch _fpsStopwatch => SGame.Reflection.GetPrivateField<Stopwatch>(typeof(Game1), nameof(SGame._fpsStopwatch)).GetValue(); private static float _fps { - set { SGame.Reflection.GetPrivateField<float>(typeof(Game1), nameof(_fps)).SetValue(value); } + set => SGame.Reflection.GetPrivateField<float>(typeof(Game1), nameof(_fps)).SetValue(value); } private static Task _newDayTask => SGame.Reflection.GetPrivateField<Task>(typeof(Game1), nameof(_newDayTask)).GetValue(); private Color bgColor => SGame.Reflection.GetPrivateField<Color>(this, nameof(bgColor)).GetValue(); @@ -202,6 +202,15 @@ namespace StardewModdingAPI.Framework SGame.Reflection = reflection; Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef; // required by Stardew Valley + + // The game uses the default content manager instead of Game1.CreateContentManager in + // several cases (See http://community.playstarbound.com/threads/130058/page-27#post-3159274). + // The workaround is... + // 1. Override the default content manager. + // 2. Since Game1.content isn't initialised yet, and we need one main instance to + // support custom map tilesheets, detect when Game1.content is being initialised + // and use the same instance. + this.Content = new SContentManager(this.Content.ServiceProvider, this.Content.RootDirectory, this.Monitor); } /**** @@ -212,6 +221,12 @@ namespace StardewModdingAPI.Framework /// <param name="rootDirectory">The root directory to search for content.</param> protected override LocalizedContentManager CreateContentManager(IServiceProvider serviceProvider, string rootDirectory) { + // When Game1.content is being initialised, use SMAPI's main content manager instance. + // See comment in SGame constructor. + if (Game1.content == null && this.Content is SContentManager mainContentManager) + return mainContentManager; + + // build new instance return new SContentManager(this.Content.ServiceProvider, this.Content.RootDirectory, this.Monitor); } |