diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index 113440c5..441a138c 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -110,13 +110,30 @@ namespace StardewModdingAPI.Framework.ModLoading // detect broken assembly reference foreach (AssemblyNameReference reference in assembly.Definition.MainModule.AssemblyReferences) { - if (!(reference.Name.StartsWith("System.") || reference.Name.Equals("System")) && !this.IsAssemblyLoaded(reference)) + try { + if (!this.IsAssemblyLoaded(reference)) + { + this.Monitor.LogOnce(loggedMessages, $" Broken code in {assembly.File.Name}: reference to missing assembly '{reference.FullName}'."); + if (!assumeCompatible) + throw new IncompatibleInstructionException($"Found a reference to missing assembly '{reference.FullName}' while loading assembly {assembly.File.Name}."); + mod.SetWarning(ModWarning.BrokenCodeLoaded); + break; + } + } + catch { - this.Monitor.LogOnce(loggedMessages, $" Broken code in {assembly.File.Name}: reference to missing assembly '{reference.FullName}'."); - if (!assumeCompatible) - throw new IncompatibleInstructionException($"Found a reference to missing assembly '{reference.FullName}' while loading assembly {assembly.File.Name}."); - mod.SetWarning(ModWarning.BrokenCodeLoaded); - break; + if (!reference.Name.StartsWith("System.")) + { + this.Monitor.LogOnce(loggedMessages, $" Broken code in {assembly.File.Name}: reference to missing assembly '{reference.FullName}'."); + if (!assumeCompatible) + throw new IncompatibleInstructionException($"Found a reference to missing assembly '{reference.FullName}' while loading assembly {assembly.File.Name}."); + mod.SetWarning(ModWarning.BrokenCodeLoaded); + break; + } + else + { + this.Monitor.LogOnce(loggedMessages, $" Probably broken code in {assembly.File.Name}: reference to missing assembly '{reference.FullName}'."); + } } } diff --git a/src/SMAPI/Framework/RewriteFacades/DialogueBoxMethods.cs b/src/SMAPI/Framework/RewriteFacades/DialogueBoxMethods.cs new file mode 100644 index 00000000..9d6727ae --- /dev/null +++ b/src/SMAPI/Framework/RewriteFacades/DialogueBoxMethods.cs @@ -0,0 +1,12 @@ +using StardewValley.Menus; + +namespace StardewModdingAPI.Framework.RewriteFacades +{ + public class DialogueBoxMethods : DialogueBox + { + public DialogueBoxMethods(string dialogue) + : base(dialogue) + { + } + } +} diff --git a/src/SMAPI/Framework/RewriteFacades/InventoryMenuMethods.cs b/src/SMAPI/Framework/RewriteFacades/InventoryMenuMethods.cs index f9bb75e7..9c4b37b6 100644 --- a/src/SMAPI/Framework/RewriteFacades/InventoryMenuMethods.cs +++ b/src/SMAPI/Framework/RewriteFacades/InventoryMenuMethods.cs @@ -18,5 +18,51 @@ namespace StardewModdingAPI.Framework.RewriteFacades { return base.rightClick(x, y, toAddTo, playSound); } + + public List GetBorder(BorderSide side) + { + List clickableComponentList = new List(); + int num = this.capacity / this.rows; + switch (side) + { + case BorderSide.Top: + for (int index = 0; index < this.inventory.Count; ++index) + { + if (index < num) + clickableComponentList.Add(this.inventory[index]); + } + break; + case BorderSide.Left: + for (int index = 0; index < this.inventory.Count; ++index) + { + if (index % num == 0) + clickableComponentList.Add(this.inventory[index]); + } + break; + case BorderSide.Right: + for (int index = 0; index < this.inventory.Count; ++index) + { + if (index % num == num - 1) + clickableComponentList.Add(this.inventory[index]); + } + break; + case BorderSide.Bottom: + for (int index = 0; index < this.inventory.Count; ++index) + { + if (index >= this.actualInventory.Count - num) + clickableComponentList.Add(this.inventory[index]); + } + break; + } + return clickableComponentList; + } + + public enum BorderSide + { + Top, + Left, + Right, + Bottom, + } } } diff --git a/src/SMAPI/Framework/RewriteFacades/ShopMenuMethods.cs b/src/SMAPI/Framework/RewriteFacades/ShopMenuMethods.cs index d5970b89..4beca4c8 100644 --- a/src/SMAPI/Framework/RewriteFacades/ShopMenuMethods.cs +++ b/src/SMAPI/Framework/RewriteFacades/ShopMenuMethods.cs @@ -63,6 +63,18 @@ namespace StardewModdingAPI.Framework.RewriteFacades typeof(ShopMenu).GetField("categoriesToSellHere", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).SetValue(this, value); } } + public Dictionary ItemPriceAndStockProp + { + get + { + return (Dictionary)typeof(ShopMenu).GetField("itemPriceAndStock", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(this); + } + set + { + typeof(ShopMenu).GetField("itemPriceAndStock", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).SetValue(this, value); + } + } + public ShopMenuMethods(Dictionary itemPriceAndStock, int currency = 0, string who = null, Func on_purchase = null, Func on_sell = null, string context = null) : base(itemPriceAndStock, currency, who, on_purchase, on_sell, context) { } diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index e22d8317..a629407e 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -60,11 +60,13 @@ namespace StardewModdingAPI.Metadata yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "hoverPrice", "HoverPriceProp"); yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "hoverText", "HoverTextProp"); yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "categoriesToSellHere", "CategoriesToSellHereProp"); + yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "itemPriceAndStock", "ItemPriceAndStockProp"); yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(MenuWithInventory), typeof(MenuWithInventoryMethods), "trashCan", "TrashCanProp"); yield return new TypeFieldToAnotherTypePropertyRewriter(typeof(ItemGrabMenu), typeof(ItemGrabMenuMethods), "fillStacksButton", "FillStacksButtonProp"); // Rewrite Missing Type yield return new TypeReferenceRewriter("StardewValley.Menus.CraftingPage", typeof(CraftingPageMobile)); + yield return new TypeReferenceRewriter("StardewValley.Menus.InventoryMenu/BorderSide", typeof(InventoryMenuMethods.BorderSide)); //Method Rewrites yield return new MethodParentRewriter(typeof(Game1), typeof(Game1Methods)); @@ -87,6 +89,7 @@ namespace StardewModdingAPI.Metadata yield return new MethodParentRewriter(typeof(MenuWithInventory), typeof(MenuWithInventoryMethods)); yield return new MethodParentRewriter(typeof(GameMenu), typeof(GameMenuMethods)); yield return new MethodParentRewriter(typeof(CraftingPageMobile), typeof(CraftingPageMobileMethods)); + yield return new MethodParentRewriter(typeof(DialogueBox), typeof(DialogueBoxMethods)); //Field Rewriters yield return new FieldReplaceRewriter(typeof(ItemGrabMenu), "context", "specialObject"); diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index b239959a..291f1246 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -265,6 +265,7 @@ +