From 840552ebe658ba205322555e046c7a652ae0bc9c Mon Sep 17 00:00:00 2001 From: Entoarox Date: Thu, 4 Jul 2019 10:50:28 +0200 Subject: [PATCH] EF 2.4.3 release --- Framework/Core/EntoaroxFrameworkMod.cs | 19 +- Framework/IContentHelperExtensions.cs | 2 + Framework/RELEASE-NOTES.md | 7 +- Framework/manifest.json | 2 +- SundropCity/SundropCityMod.cs | 43 ++- .../Hotel/Data/GenericFurnitureTypes.json | 3 - .../assets/Hotel/Data/SetFurnitureTypes.json | 303 ------------------ .../assets/Hotel/Data/Sets/LemonCreamPie.json | 14 - SundropCity/i18n/default.json | 15 - 9 files changed, 61 insertions(+), 347 deletions(-) delete mode 100644 SundropCity/assets/Hotel/Data/GenericFurnitureTypes.json delete mode 100644 SundropCity/assets/Hotel/Data/SetFurnitureTypes.json delete mode 100644 SundropCity/assets/Hotel/Data/Sets/LemonCreamPie.json delete mode 100644 SundropCity/i18n/default.json diff --git a/Framework/Core/EntoaroxFrameworkMod.cs b/Framework/Core/EntoaroxFrameworkMod.cs index 14d7f70..e075f6a 100644 --- a/Framework/Core/EntoaroxFrameworkMod.cs +++ b/Framework/Core/EntoaroxFrameworkMod.cs @@ -32,6 +32,7 @@ internal class EntoaroxFrameworkMod : Mod /********* ** Fields *********/ + private static bool SkipSerializer = false; private static readonly List Farms = new List { "standard", "river", "forest", "hilltop", "wilderniss" }; private static string Verify; internal static JsonSerializer Serializer; @@ -123,6 +124,9 @@ internal class EntoaroxFrameworkMod : Mod /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { + // Check if the serializer override should be skipped + if (typeof(SaveGame).GetField("contract") == null) + SkipSerializer = true; Serializer = new JsonSerializer(); Serializer.Converters.Add(new RectangleConverter()); Serializer.Formatting = Formatting.None; @@ -150,12 +154,20 @@ public override void Entry(IModHelper helper) .Add("player_warp", "player_warp | Warps the player to the given position in the game.", this.Commands); } - helper.Events.GameLoop.GameLaunched += this.OnGameLaunched; + helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; helper.Events.GameLoop.Saving += this.OnSaving; helper.Events.GameLoop.Saved += this.OnSaved; helper.Events.Input.ButtonReleased += this.OnButtonReleased; + + if (SkipSerializer) + { + this.Monitor.Log("Detected incompatible SDV version for serializer function, function is disabled.", LogLevel.Warn); + return; + } + helper.Events.GameLoop.GameLaunched += this.OnGameLaunched; + helper.Events.GameLoop.UpdateTicked += this.EnforceSerializer; } /// Get an API that other mods can access. This is always called after . @@ -465,7 +477,6 @@ private void OnGameLaunched(object sender, GameLaunchedEventArgs e) /// The event arguments. private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { - this.EnforceSerializer(); if (!Context.IsWorldReady) return; if (Game1.player.CurrentItem == null && this.PrevItem != null || Game1.player.CurrentItem != null && !Game1.player.CurrentItem.Equals(this.PrevItem)) @@ -857,10 +868,10 @@ private void SetupSerializer() this.FarmerSerializer = new XmlSerializer(typeof(Farmer), EntoaroxFrameworkMod.FarmerTypes.Concat(EntoaroxFrameworkMod.SerializerTypes).ToArray()); this.LocationSerializer = new XmlSerializer(typeof(GameLocation), EntoaroxFrameworkMod.LocationTypes.Concat(EntoaroxFrameworkMod.SerializerTypes).ToArray()); EntoaroxFrameworkMod.SerializerInjected = true; - this.EnforceSerializer(); + this.EnforceSerializer(null, null); } - private void EnforceSerializer() + private void EnforceSerializer(object sender, UpdateTickedEventArgs e) { SaveGame.serializer = this.MainSerializer; SaveGame.farmerSerializer = this.FarmerSerializer; diff --git a/Framework/IContentHelperExtensions.cs b/Framework/IContentHelperExtensions.cs index 970e6ea..56eafc7 100644 --- a/Framework/IContentHelperExtensions.cs +++ b/Framework/IContentHelperExtensions.cs @@ -19,8 +19,10 @@ public static class IContentHelperExtensions /// Allows you to add a new type to the serializer, provided the serializer has not yet been initialized. /// The Type to add /// The this extension method is attached to + [Obsolete("Deprecated, use save events to add/remove custom content instead.")] public static void RegisterSerializerType(this IContentHelper helper) { + EntoaroxFrameworkMod.Logger.Log($"[IContentHelper] The `{Globals.GetModName(helper)}` mod uses deprecated serializer injection, this will be removed in a future update.", LogLevel.Alert); if (EntoaroxFrameworkMod.SerializerInjected) EntoaroxFrameworkMod.Logger.Log($"[IContentHelper] The `{Globals.GetModName(helper)}` mod failed to augment the serializer, serializer has already been created.", LogLevel.Error); else if (!EntoaroxFrameworkMod.SerializerTypes.Contains(typeof(T))) diff --git a/Framework/RELEASE-NOTES.md b/Framework/RELEASE-NOTES.md index a754f15..4b0ce82 100644 --- a/Framework/RELEASE-NOTES.md +++ b/Framework/RELEASE-NOTES.md @@ -1,8 +1,11 @@ ## Release notes ## 2.4.3 -Not yet released +Released 04 July 2019 +* Updated for the upcoming SMAPI 3.0 again. +* Detect when a SDV version uses a different serializer mechanic and disable the custom serializer on those versions (Android & similar) +* Deprecated the ability to add types to the save serializer * Added new `world_reset` command with `bushes` and `characters` options, enables reloading relevant data from disk when triggered in a active save. -* Restored some lost ICustomItem supported types (`TerrainFeature` & `GameLocation`), due to technical limits ``Building` support is not yet back. +* Restored some lost ICustomItem supported types (`TerrainFeature` & `GameLocation`), due to technical limits `Building` support is not yet back. ## 2.4.2 Released 28 December 2018. (Thanks to Pathoschild!) diff --git a/Framework/manifest.json b/Framework/manifest.json index 3057625..fc2fb12 100644 --- a/Framework/manifest.json +++ b/Framework/manifest.json @@ -1,7 +1,7 @@ { "Name": "Entoarox Framework", "Author": "Entoarox", - "Version": "2.4.3-beta.1", + "Version": "2.4.3", "Description": "A collection of APIs to make modding easier.", "UniqueID": "Entoarox.EntoaroxFramework", "EntryDll": "EntoaroxFramework.dll", diff --git a/SundropCity/SundropCityMod.cs b/SundropCity/SundropCityMod.cs index 6c3db35..9104385 100644 --- a/SundropCity/SundropCityMod.cs +++ b/SundropCity/SundropCityMod.cs @@ -12,6 +12,8 @@ using SundropCity.TerrainFeatures; using xTile; +using xTile.Dimensions; +using xTile.ObjectModel; using xTile.Layers; using xTile.Tiles; @@ -48,6 +50,7 @@ public override void Entry(IModHelper helper) helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; helper.Events.GameLoop.Saved += this.OnSaved; helper.Events.GameLoop.Saving += this.OnSaving; + helper.Events.Input.ButtonReleased += this.OnButtonReleased; // Handle ALL not providing extra layer drawing if (!helper.ModRegistry.IsLoaded("Entoarox.AdvancedLocationLoader") || helper.ModRegistry.Get("Entoarox.AdvancedLocationLoader").Manifest.Version.IsOlderThan("1.5.0")) @@ -170,11 +173,6 @@ private void Setup() toLayer.Tiles[x, y] = new StaticTile(toLayer, town.map.GetTileSheet(tile.TileSheet.Id), BlendMode.Additive, tile.TileIndex); } } - // Setup warps to sundrop [TEMP: Will become warps to SundropBusStop map in the future] - town.warps.Add(new Warp(120, 55, "SundropPromenade", 1, 29, false)); - town.warps.Add(new Warp(120, 56, "SundropPromenade", 1, 30, false)); - town.warps.Add(new Warp(120, 57, "SundropPromenade", 1, 31, false)); - town.warps.Add(new Warp(120, 58, "SundropPromenade", 1, 32, false)); // Add new locations foreach (string map in this.Maps) { @@ -191,6 +189,16 @@ private void Setup() } } var promenade = Game1.getLocationFromName("SundropPromenade"); + if(promenade==null) + { + this.Monitor.Log("Promenade failed to load, cancelling further setup as a result.", LogLevel.Error); + return; + } + // Setup warps to sundrop [TEMP: Will become warps to SundropBusStop map in the future] + town.warps.Add(new Warp(120, 55, "SundropPromenade", 1, 29, false)); + town.warps.Add(new Warp(120, 56, "SundropPromenade", 1, 30, false)); + town.warps.Add(new Warp(120, 57, "SundropPromenade", 1, 31, false)); + town.warps.Add(new Warp(120, 58, "SundropPromenade", 1, 32, false)); // Add warp back to Pelican [TEMP: Will be removed once proper travel is implemented] promenade.setTileProperty(3, 37, "Buildings", "Action", "Warp 119 56 Town"); // Temp NPC spawns @@ -271,6 +279,31 @@ private void SpawnCars(GameLocation location, double chance) } + private void OnButtonReleased(object sender, ButtonReleasedEventArgs e) + { + if (e.Button.IsActionButton() && Game1.activeClickableMenu == null && !Game1.player.UsingTool && !Game1.pickingTool && !Game1.menuUp && (!Game1.eventUp || Game1.currentLocation.currentEvent.playerControlSequence) && !Game1.nameSelectUp && Game1.numberOfSelectedItems == -1 && !Game1.fadeToBlack) + { + Vector2 grabTile = new Vector2(Game1.getOldMouseX() + Game1.viewport.X, Game1.getOldMouseY() + Game1.viewport.Y) / Game1.tileSize; + if (!Utility.tileWithinRadiusOfPlayer((int)grabTile.X, (int)grabTile.Y, 1, Game1.player)) + grabTile = Game1.player.GetGrabTile(); + Tile tile = Game1.currentLocation.map.GetLayer("Buildings").PickTile(new Location((int)grabTile.X * Game1.tileSize, (int)grabTile.Y * Game1.tileSize), Game1.viewport.Size); + PropertyValue propertyValue = null; + tile?.Properties.TryGetValue("Action", out propertyValue); + if (propertyValue != null) + { + string[] split = ((string)propertyValue).Split(' '); + string[] args = new string[split.Length - 1]; + Array.Copy(split, 1, args, 0, args.Length); + switch(split[0]) + { + case "SundropMessage": + + break; + } + } + } + } + private void OnSaveLoaded(object s, EventArgs e) { this.Setup(); diff --git a/SundropCity/assets/Hotel/Data/GenericFurnitureTypes.json b/SundropCity/assets/Hotel/Data/GenericFurnitureTypes.json deleted file mode 100644 index 0db3279..0000000 --- a/SundropCity/assets/Hotel/Data/GenericFurnitureTypes.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} diff --git a/SundropCity/assets/Hotel/Data/SetFurnitureTypes.json b/SundropCity/assets/Hotel/Data/SetFurnitureTypes.json deleted file mode 100644 index a3e075a..0000000 --- a/SundropCity/assets/Hotel/Data/SetFurnitureTypes.json +++ /dev/null @@ -1,303 +0,0 @@ -{ - "BedLarge": [ - { - "ImageRect": [ 0, 0, 3, 4 ], - "TileSize": [ 3, 3 ] - } - ], - "BedSmall": [ - { - "ImageRect": [ 3, 0, 2, 4 ], - "TileSize": [ 2, 3 ] - } - ], - "Chair1": [ - { - "ImageRect": [ 5, 0, 1, 2 ], - "TileSize": [ 1, 1 ] - }, - { - "ImageRect": [ 6, 0, 1, 2 ], - "TileSize": [ 1, 1 ] - }, - { - "ImageRect": [ 7, 0, 1, 2 ], - "TileSize": [ 1, 1 ] - }, - { - "ImageRect": [ 6, 0, 1, 2 ], - "TileSize": [ 1, 1 ], - "Flipped": true - } - ], - "Chair2": [ - { - "ImageRect": [ 5, 2, 1, 2 ], - "TileSize": [ 1, 1 ] - }, - { - "ImageRect": [ 6, 2, 1, 2 ], - "TileSize": [ 1, 1 ] - }, - { - "ImageRect": [ 7, 2, 1, 2 ], - "TileSize": [ 1, 1 ] - }, - { - "ImageRect": [ 6, 2, 1, 2 ], - "TileSize": [ 1, 1 ], - "Flipped": true - } - ], - "WallLamp1": [ - { - "ImageRect": [ 8, 0, 1, 1 ], - "TileSize": [ 1, 1 ], - "NeedsWall": true, - "IsLamp": true - } - ], - "WallLamp2": [ - { - "ImageRect": [ 8, 1, 1, 1 ], - "TileSize": [ 1, 1 ], - "NeedsWall": true, - "IsLamp": true - } - ], - "Stool1": [ - { - "ImageRect": [ 8, 2, 1, 2 ], - "TileSize": [ 1, 1 ] - } - ], - "Stool2": [ - { - "ImageRect": [ 9, 2, 1, 2 ], - "TileSize": [ 1, 1 ] - } - ], - "SideTable": [ - { - "ImageRect": [ 0, 4, 1, 2 ], - "TileSize": [ 1, 1 ], - "HasSlot": true, - "Slots": [ - [ 0, 3 ] - ] - }, - { - "ImageRect": [ 1, 4, 1, 2 ], - "TileSize": [ 1, 1 ], - "HasSlots": true, - "Slots": [ - [ 0, 19 ] - ] - } - ], - "TableLamp": [ - { - "ImageRect": [ 4, 2, 1, 2 ], - "TileSize": [ 1, 1 ], - "CanSlot": true, - "IsLamp": true - } - ], - "FloorLamp": [ - { - "ImageRect": [ 4, 4, 1, 3 ], - "TileSize": [ 1, 1 ], - "IsLamp": true - } - ], - "Television": [ - { - "ImageRect": [ 6, 4, 2, 3 ], - "TileSize": [ 2, 2 ] - } - ], - "Bookcase": [ - { - "ImageRect": [ 8, 4, 2, 3 ], - "TileSize": [ 2, 1 ] - } - ], - "Dresser": [ - { - "ImageRect": [ 7, 0, 2, 2 ], - "TileSize": [ 2, 1 ] - }, - { - "ImageRect": [ 7, 2, 1, 3 ], - "TileSize": [ 1, 2 ] - }, - { - "ImageRect": [ 7, 3, 2, 2 ], - "TileSize": [ 2, 1 ] - }, - { - "ImageRect": [ 7, 2, 1, 3 ], - "TileSize": [ 1, 2 ], - "Flipped": true - } - ], - "Decor": [ - { - "ImageRect": [ 5, 7, 1, 2 ], - "TileSize": [ 1, 1 ], - "CanSlot": true - }, - { - "ImageRect": [ 6, 7, 1, 2 ], - "TileSize": [ 1, 1 ], - "CanSlot": true - }, - { - "ImageRect": [ 7, 7, 1, 2 ], - "TileSize": [ 1, 1 ], - "CanSlot": true - }, - { - "ImageRect": [ 8, 7, 1, 2 ], - "TileSize": [ 1, 1 ], - "CanSlot": true - }, - { - "ImageRect": [ 9, 7, 1, 2 ], - "TileSize": [ 1, 1 ], - "CanSlot": true - } - ], - "Couch": [ - { - "ImageRect": [ 0, 10, 3, 2 ], - "TileSize": [ 3, 1 ] - }, - { - "ImageRect": [ 3, 10, 2, 3 ], - "TileSize": [ 2, 2 ] - }, - { - "ImageRect": [ 5, 10, 3, 2 ], - "TileSize": [ 3, 1 ] - }, - { - "ImageRect": [ 3, 10, 2, 3 ], - "TileSize": [ 2, 2 ], - "Flipped": true - } - ], - "Frame1x1a": [ - { - "ImageRect": [ 8, 9, 1, 1 ], - "TileSize": [ 1, 1 ], - "NeedsWall": true, - "IsFrame": true - } - ], - "Frame1x1b": [ - { - "ImageRect": [ 8, 10, 1, 1 ], - "TileSize": [ 1, 1 ], - "NeedsWall": true, - "IsFrame": true - } - ], - "Frame1x2": [ - { - "ImageRect": [ 9, 9, 1, 2 ], - "TileSize": [ 1, 2 ], - "NeedsWall": true, - "IsFrame": true - } - ], - "Frame2x2": [ - { - "ImageRect": [ 8, 11, 2, 2 ], - "TileSize": [ 2, 2 ], - "NeedsWall": true, - "IsFrame": true - } - ], - "Frame3x2": [ - { - "ImageRect": [ 7, 13, 3, 2 ], - "TileSize": [ 3, 2 ], - "NeedsWall": true, - "IsFrame": true - } - ], - "Armchair": [ - { - "ImageRect": [ 0, 13, 2, 2 ], - "TileSize": [ 2, 2 ] - }, - { - "ImageRect": [ 2, 13, 2, 2 ], - "TileSize": [ 2, 2 ] - }, - { - "ImageRect": [ 4, 13, 2, 2 ], - "TileSize": [ 2, 2 ] - }, - { - "ImageRect": [ 2, 13, 2, 2 ], - "TileSize": [ 2, 2 ], - "Flipped": true - } - ], - "Carpet1": [ - { - "ImageRect": [ 0, 16, 3, 2 ], - "TileSize": [ 3, 2 ], - "IsCarpet": true - }, - { - "ImageRect": [ 3, 15, 2, 3 ], - "TileSize": [ 2, 3 ], - "IsCarpet": true - } - ], - "Carpet2": [ - { - "ImageRect": [ 5, 16, 3, 2 ], - "TileSize": [ 3, 2 ], - "IsCarpet": true - }, - { - "ImageRect": [ 8, 15, 2, 3 ], - "TileSize": [ 2, 3 ], - "IsCarpet": true - } - ], - "SmallTable1": [ - { - "ImageRect": [0,18,2,3], - "TileSize": [ 2, 2 ], - "HasSlots": true, - "Slots": [ - [ 8, 16 ] - ] - } - ], - "SmallTable2": [ - { - "ImageRect": [ 3, 18, 2, 3 ], - "TileSize": [ 2, 2 ], - "HasSlots": true, - "Slots": [ - [ 8, 16 ] - ] - } - ], - "DinerTable": [ - { - "ImageRect": [ 5, 18, 3, 3 ], - "TileSize": [ 3, 2 ] - }, - { - "ImageRect": [ 8, 18, 2, 3 ], - "TileSize": [ 2, 3 ] - } - ] -} diff --git a/SundropCity/assets/Hotel/Data/Sets/LemonCreamPie.json b/SundropCity/assets/Hotel/Data/Sets/LemonCreamPie.json deleted file mode 100644 index 0844f03..0000000 --- a/SundropCity/assets/Hotel/Data/Sets/LemonCreamPie.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Bonus": { - "Comfort": 0.01, - "Popularity": 0.01 - }, - "Pieces": { - "BedLarge": { - "Comfort": 10, - "Popularity": 2, - "Upkeep": 3 - } - /* ... */ - } -} diff --git a/SundropCity/i18n/default.json b/SundropCity/i18n/default.json deleted file mode 100644 index fe602ca..0000000 --- a/SundropCity/i18n/default.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Hotel.Properties.Comfort": "Comfort: {{Comfort}}", - "Hotel.Properties.Upkeep": "Upkeep: {{Upkeep}}", - "Hotel.Properties.Popularity": "Popularity: {{Popularity}}", - "Hotel.Properties.Capacity": "Capacity: {{Capacity}}", - "Hotel.Properties.StarLevel": "Star Level: {{StarLevel}}", - "Hotel.Properties.Revenue": "Revenue: {{Revenue}}", - - "Hotel.Info.Set": "Set: {{SetName}}", - "Hotel.SetNames.LemonCreamPie": "Lemon Cream Pie", - "Hotel.SetFurniture.LemonCreamPie.LargeBed/Name": "Large Bed", - "Hotel.SetFurniture.LemonCreamPie.LargeBed/Description": "A large bed, suitable for 2 people to sleep in.", - "Hotel.SetFurniture.LemonCreamPie.SmallBed/Name": "Small Bed", - "Hotel.SetFurniture.LemonCreamPie.SmallBed/Description": "A small bed, suitable for 1 person to sleep in." -}