diff options
| author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-02-07 20:50:41 -0500 |
|---|---|---|
| committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-02-07 20:50:41 -0500 |
| commit | 95a93a05b39d2b27b538ecdb0e6a18f28096c5c2 (patch) | |
| tree | d225096d50f0b952c8ca80bac80a34209ee85ea4 /src | |
| parent | 99d0450b2cb291d565cb836de9f132ca657472c1 (diff) | |
| download | SMAPI-95a93a05b39d2b27b538ecdb0e6a18f28096c5c2.tar.gz SMAPI-95a93a05b39d2b27b538ecdb0e6a18f28096c5c2.tar.bz2 SMAPI-95a93a05b39d2b27b538ecdb0e6a18f28096c5c2.zip | |
remove oldest deprecated code (#231)
Since Stardew Valley 1.2 breaks most mods anyway, this commits removes the oldest deprecations and fixes the issues that are easiest for mods to update. See documentation for details.
Diffstat (limited to 'src')
20 files changed, 90 insertions, 826 deletions
diff --git a/src/StardewModdingAPI/Command.cs b/src/StardewModdingAPI/Command.cs index 1fa18d49..6195bd8b 100644 --- a/src/StardewModdingAPI/Command.cs +++ b/src/StardewModdingAPI/Command.cs @@ -69,15 +69,6 @@ namespace StardewModdingAPI ****/ /// <summary>Parse a command string and invoke it if valid.</summary> /// <param name="input">The command to run, including the command name and any arguments.</param> - [Obsolete("Use the overload which passes in your mod's monitor")] - public static void CallCommand(string input) - { - Program.DeprecationManager.Warn($"an old version of {nameof(Command)}.{nameof(Command.CallCommand)}", "1.1", DeprecationLevel.Notice); - Command.CallCommand(input, Program.GetLegacyMonitorForMod()); - } - - /// <summary>Parse a command string and invoke it if valid.</summary> - /// <param name="input">The command to run, including the command name and any arguments.</param> /// <param name="monitor">Encapsulates monitoring and logging.</param> public static void CallCommand(string input, IMonitor monitor) { diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs index a62a0d58..d3c2ddcc 100644 --- a/src/StardewModdingAPI/Constants.cs +++ b/src/StardewModdingAPI/Constants.cs @@ -26,11 +26,7 @@ namespace StardewModdingAPI ** Accessors *********/ /// <summary>SMAPI's current semantic version.</summary> - [Obsolete("Use " + nameof(Constants) + "." + nameof(ApiVersion))] - public static readonly Version Version = (Version)Constants.ApiVersion; - - /// <summary>SMAPI's current semantic version.</summary> - public static ISemanticVersion ApiVersion => new Version(1, 8, 0, null, suppressDeprecationWarning: true); + public static ISemanticVersion ApiVersion => new SemanticVersion(1, 8, 0, null); /// <summary>The minimum supported version of Stardew Valley.</summary> public const string MinimumGameVersion = "1.1"; diff --git a/src/StardewModdingAPI/Entities/SPlayer.cs b/src/StardewModdingAPI/Entities/SPlayer.cs deleted file mode 100644 index 66c7ba44..00000000 --- a/src/StardewModdingAPI/Entities/SPlayer.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using StardewModdingAPI.Framework; -using StardewValley; - -namespace StardewModdingAPI.Entities -{ - /// <summary>Static class for integrating with the player.</summary> - [Obsolete("This API was never officially documented and will be removed soon.")] - public class SPlayer - { - /********* - ** Accessors - *********/ - /// <summary>Obsolete.</summary> - [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.getAllFarmers) + " instead")] - public static List<Farmer> AllFarmers - { - get - { - Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); - return Game1.getAllFarmers(); - } - } - - /// <summary>Obsolete.</summary> - [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.player) + " instead")] - public static Farmer CurrentFarmer - { - get - { - Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); - return Game1.player; - } - } - - /// <summary>Obsolete.</summary> - [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.player) + " instead")] - public static Farmer Player - { - get - { - Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); - return Game1.player; - } - } - - /// <summary>Obsolete.</summary> - [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.player) + "." + nameof(Farmer.currentLocation) + " instead")] - public static GameLocation CurrentFarmerLocation - { - get - { - Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); - return Game1.player.currentLocation; - } - } - } -}
\ No newline at end of file diff --git a/src/StardewModdingAPI/Inheritance/ChangeType.cs b/src/StardewModdingAPI/Events/ChangeType.cs index 94eb33ed..4b207f08 100644 --- a/src/StardewModdingAPI/Inheritance/ChangeType.cs +++ b/src/StardewModdingAPI/Events/ChangeType.cs @@ -1,4 +1,4 @@ -namespace StardewModdingAPI.Inheritance +namespace StardewModdingAPI.Events { /// <summary>Indicates how an inventory item changed.</summary> public enum ChangeType diff --git a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs index 40c77419..11cbcedf 100644 --- a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using StardewModdingAPI.Inheritance; using StardewValley; namespace StardewModdingAPI.Events diff --git a/src/StardewModdingAPI/Events/GraphicsEvents.cs b/src/StardewModdingAPI/Events/GraphicsEvents.cs index 5f4feeac..c3236c0a 100644 --- a/src/StardewModdingAPI/Events/GraphicsEvents.cs +++ b/src/StardewModdingAPI/Events/GraphicsEvents.cs @@ -15,7 +15,7 @@ namespace StardewModdingAPI.Events /// <summary>Raised after the game window is resized.</summary> public static event EventHandler Resize; - /// <summary>Raised when drawing debug information to the screen (when <see cref="StardewModdingAPI.Inheritance.SGame.Debug"/> is true). This is called after the sprite batch is begun. If you just want to add debug info, use <see cref="StardewModdingAPI.Inheritance.SGame.DebugMessageQueue" /> in your update loop.</summary> + /// <summary>Raised when drawing debug information to the screen (when <see cref="SGame.Debug"/> is true). This is called after the sprite batch is begun. If you just want to add debug info, use <see cref="SGame.DebugMessageQueue" /> in your update loop.</summary> public static event EventHandler DrawDebug; /// <summary>Obsolete.</summary> diff --git a/src/StardewModdingAPI/Inheritance/ItemStackChange.cs b/src/StardewModdingAPI/Events/ItemStackChange.cs index 8d15b894..f9ae6df6 100644 --- a/src/StardewModdingAPI/Inheritance/ItemStackChange.cs +++ b/src/StardewModdingAPI/Events/ItemStackChange.cs @@ -1,6 +1,6 @@ -using StardewValley; +using StardewValley; -namespace StardewModdingAPI.Inheritance +namespace StardewModdingAPI.Events { /// <summary>Represents an inventory slot that changed.</summary> public class ItemStackChange diff --git a/src/StardewModdingAPI/Events/PlayerEvents.cs b/src/StardewModdingAPI/Events/PlayerEvents.cs index dd3ff220..6e65f5ae 100644 --- a/src/StardewModdingAPI/Events/PlayerEvents.cs +++ b/src/StardewModdingAPI/Events/PlayerEvents.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using StardewModdingAPI.Framework; -using StardewModdingAPI.Inheritance; using StardewValley; namespace StardewModdingAPI.Events diff --git a/src/StardewModdingAPI/Extensions.cs b/src/StardewModdingAPI/Extensions.cs deleted file mode 100644 index 0e9dbbf7..00000000 --- a/src/StardewModdingAPI/Extensions.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; -using StardewModdingAPI.Framework; - -namespace StardewModdingAPI -{ - /// <summary>Provides general utility extensions.</summary> - public static class Extensions - { - /********* - ** Properties - *********/ - /// <summary>The backing field for <see cref="Random"/>.</summary> - private static readonly Random _random = new Random(); - - - /********* - ** Accessors - *********/ - /// <summary>A pseudo-random number generator.</summary> - public static Random Random - { - get - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.Random)}", "1.0", DeprecationLevel.PendingRemoval); - return Extensions._random; - } - } - - - /********* - ** Public methods - *********/ - /// <summary>Get whether the given key is currently being pressed.</summary> - /// <param name="key">The key to check.</param> - public static bool IsKeyDown(this Keys key) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsKeyDown)}", "1.0", DeprecationLevel.PendingRemoval); - - return Keyboard.GetState().IsKeyDown(key); - } - - /// <summary>Get a random color.</summary> - public static Color RandomColour() - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.RandomColour)}", "1.0", DeprecationLevel.PendingRemoval); - - return new Color(Extensions.Random.Next(0, 255), Extensions.Random.Next(0, 255), Extensions.Random.Next(0, 255)); - } - - /// <summary>Concatenate an enumeration into a delimiter-separated string.</summary> - /// <param name="ienum">The values to concatenate.</param> - /// <param name="split">The value separator.</param> - [Obsolete("The usage of ToSingular has changed. Please update your call to use ToSingular<T>")] - public static string ToSingular(this IEnumerable ienum, string split = ", ") - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.ToSingular)}", "0.39.3", DeprecationLevel.PendingRemoval); - return ""; - } - - /// <summary>Concatenate an enumeration into a delimiter-separated string.</summary> - /// <typeparam name="T">The enumerated value type.</typeparam> - /// <param name="ienum">The values to concatenate.</param> - /// <param name="split">The value separator.</param> - public static string ToSingular<T>(this IEnumerable<T> ienum, string split = ", ") - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.ToSingular)}", "1.0", DeprecationLevel.PendingRemoval); - - //Apparently Keys[] won't split normally :l - if (typeof(T) == typeof(Keys)) - { - return string.Join(split, ienum.ToArray()); - } - return string.Join(split, ienum); - } - - /// <summary>Get whether the value can be parsed as a number.</summary> - /// <param name="o">The value.</param> - public static bool IsInt32(this object o) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsInt32)}", "1.0", DeprecationLevel.PendingRemoval); - - int i; - return int.TryParse(o.ToString(), out i); - } - - /// <summary>Get the numeric representation of a value.</summary> - /// <param name="o">The value.</param> - public static int AsInt32(this object o) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.AsInt32)}", "1.0", DeprecationLevel.PendingRemoval); - - return int.Parse(o.ToString()); - } - - /// <summary>Get whether the value can be parsed as a boolean.</summary> - /// <param name="o">The value.</param> - public static bool IsBool(this object o) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.IsBool)}", "1.0", DeprecationLevel.PendingRemoval); - - bool b; - return bool.TryParse(o.ToString(), out b); - } - - /// <summary>Get the boolean representation of a value.</summary> - /// <param name="o">The value.</param> - public static bool AsBool(this object o) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.AsBool)}", "1.0", DeprecationLevel.PendingRemoval); - - return bool.Parse(o.ToString()); - } - - /// <summary>Get a list hash calculated from the hashes of the values it contains.</summary> - /// <param name="enumerable">The values to hash.</param> - public static int GetHash(this IEnumerable enumerable) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetHash)}", "1.0", DeprecationLevel.PendingRemoval); - - var hash = 0; - foreach (var v in enumerable) - hash ^= v.GetHashCode(); - return hash; - } - - /// <summary>Cast a value to the given type. This returns <c>null</c> if the value can't be cast.</summary> - /// <typeparam name="T">The type to which to cast.</typeparam> - /// <param name="o">The value.</param> - public static T Cast<T>(this object o) where T : class - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.Cast)}", "1.0", DeprecationLevel.PendingRemoval); - - return o as T; - } - - /// <summary>Get all private types on an object.</summary> - /// <param name="o">The object to scan.</param> - public static FieldInfo[] GetPrivateFields(this object o) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetPrivateFields)}", "1.0", DeprecationLevel.PendingRemoval); - return o.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static); - } - - /// <summary>Get metadata for a private field.</summary> - /// <param name="t">The type to scan.</param> - /// <param name="name">The name of the field to find.</param> - public static FieldInfo GetBaseFieldInfo(this Type t, string name) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetBaseFieldValue)}", "1.0", DeprecationLevel.PendingRemoval); - return t.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static); - } - - /// <summary>Get the value of a private field.</summary> - /// <param name="t">The type to scan.</param> - /// <param name="o">The instance for which to get a value.</param> - /// <param name="name">The name of the field to find.</param> - public static T GetBaseFieldValue<T>(this Type t, object o, string name) where T : class - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.GetBaseFieldValue)}", "1.0", DeprecationLevel.PendingRemoval); - return t.GetBaseFieldInfo(name).GetValue(o) as T; - } - - /// <summary>Set the value of a private field.</summary> - /// <param name="t">The type to scan.</param> - /// <param name="o">The instance for which to set a value.</param> - /// <param name="name">The name of the field to find.</param> - /// <param name="newValue">The value to set.</param> - public static void SetBaseFieldValue<T>(this Type t, object o, string name, object newValue) where T : class - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.SetBaseFieldValue)}", "1.0", DeprecationLevel.PendingRemoval); - t.GetBaseFieldInfo(name).SetValue(o, newValue as T); - } - - /// <summary>Get a copy of the string with only alphanumeric characters. (Numbers are not removed, despite the name.)</summary> - /// <param name="st">The string to copy.</param> - public static string RemoveNumerics(this string st) - { - Program.DeprecationManager.Warn($"{nameof(Extensions)}.{nameof(Extensions.RemoveNumerics)}", "1.0", DeprecationLevel.PendingRemoval); - var s = st; - foreach (var c in s) - { - if (!char.IsLetterOrDigit(c)) - s = s.Replace(c.ToString(), ""); - } - return s; - } - } -}
\ No newline at end of file diff --git a/src/StardewModdingAPI/Inheritance/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index 69c20244..2486e376 100644 --- a/src/StardewModdingAPI/Inheritance/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -7,7 +7,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using StardewModdingAPI.Events; -using StardewModdingAPI.Framework; using StardewValley; using StardewValley.BellsAndWhistles; using StardewValley.Locations; @@ -16,10 +15,10 @@ using StardewValley.Tools; using xTile.Dimensions; using Rectangle = Microsoft.Xna.Framework.Rectangle; -namespace StardewModdingAPI.Inheritance +namespace StardewModdingAPI.Framework { /// <summary>SMAPI's extension of the game's core <see cref="Game1"/>, used to inject events.</summary> - public class SGame : Game1 + internal class SGame : Game1 { /********* ** Properties diff --git a/src/StardewModdingAPI/Framework/Serialisation/SemanticVersionConverter.cs b/src/StardewModdingAPI/Framework/Serialisation/SemanticVersionConverter.cs new file mode 100644 index 00000000..52ec999e --- /dev/null +++ b/src/StardewModdingAPI/Framework/Serialisation/SemanticVersionConverter.cs @@ -0,0 +1,51 @@ +using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace StardewModdingAPI.Framework.Serialisation +{ + /// <summary>Overrides how SMAPI reads and writes <see cref="ISemanticVersion"/>.</summary> + internal class SemanticVersionConverter : JsonConverter + { + /********* + ** Accessors + *********/ + /// <summary>Whether this converter can write JSON.</summary> + public override bool CanWrite => false; + + + /********* + ** Public methods + *********/ + /// <summary>Get whether this instance can convert the specified object type.</summary> + /// <param name="objectType">The object type.</param> + public override bool CanConvert(Type objectType) + { + return objectType == typeof(ISemanticVersion); + } + + /// <summary>Reads the JSON representation of the object.</summary> + /// <param name="reader">The JSON reader.</param> + /// <param name="objectType">The object type.</param> + /// <param name="existingValue">The object being read.</param> + /// <param name="serializer">The calling serializer.</param> + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + JObject obj = JObject.Load(reader); + int major = obj.Value<int>("MajorVersion"); + int minor = obj.Value<int>("MinorVersion"); + int patch = obj.Value<int>("PatchVersion"); + string build = obj.Value<string>("Build"); + return new SemanticVersion(major, minor, patch, build); + } + + /// <summary>Writes the JSON representation of the object.</summary> + /// <param name="writer">The JSON writer.</param> + /// <param name="value">The value.</param> + /// <param name="serializer">The calling serializer.</param> + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new InvalidOperationException("This converter does not write JSON."); + } + } +} diff --git a/src/StardewModdingAPI/Inheritance/SObject.cs b/src/StardewModdingAPI/Inheritance/SObject.cs deleted file mode 100644 index 0b0a7ec9..00000000 --- a/src/StardewModdingAPI/Inheritance/SObject.cs +++ /dev/null @@ -1,249 +0,0 @@ -using System; -using System.Xml.Serialization; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI.Framework; -using StardewValley; -using Object = StardewValley.Object; - -#pragma warning disable 1591 -namespace StardewModdingAPI.Inheritance -{ - /// <summary>Provides access to the game's <see cref="Object"/> internals.</summary> - [Obsolete("This class is deprecated and will be removed in a future version.")] - public class SObject : Object - { - /********* - ** Accessors - *********/ - public string Description { get; set; } - public Texture2D Texture { get; set; } - public string CategoryName { get; set; } - public Color CategoryColour { get; set; } - public bool IsPassable { get; set; } - public bool IsPlaceable { get; set; } - public bool HasBeenRegistered { get; set; } - public int RegisteredId { get; set; } - - public int MaxStackSize { get; set; } - - public bool WallMounted { get; set; } - public Vector2 DrawPosition { get; set; } - - public bool FlaggedForPickup { get; set; } - - [XmlIgnore] - public Vector2 CurrentMouse { get; protected set; } - - [XmlIgnore] - public Vector2 PlacedAt { get; protected set; } - - public override int Stack - { - get { return this.stack; } - set { this.stack = value; } - } - - /********* - ** Public methods - *********/ - public SObject() - { - Program.DeprecationManager.Warn(nameof(SObject), "0.39.3", DeprecationLevel.PendingRemoval); - - this.name = "Modded Item Name"; - this.Description = "Modded Item Description"; - this.CategoryName = "Modded Item Category"; - this.Category = 4163; - this.CategoryColour = Color.White; - this.IsPassable = false; - this.IsPlaceable = false; - this.boundingBox = new Rectangle(0, 0, 64, 64); - this.MaxStackSize = 999; - - this.type = "interactive"; - } - - public override string Name - { - get { return this.name; } - set { this.name = value; } - } - - public override string getDescription() - { - return this.Description; - } - - public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) - { - if (this.Texture != null) - { - spriteBatch.Draw(this.Texture, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * Game1.tileSize + Game1.tileSize / 2 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0), y * Game1.tileSize + Game1.tileSize / 2 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0))), Game1.currentLocation.getSourceRectForObject(this.ParentSheetIndex), Color.White * alpha, 0f, new Vector2(8f, 8f), this.scale.Y > 1f ? this.getScale().Y : Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.isPassable() ? this.getBoundingBox(new Vector2(x, y)).Top : this.getBoundingBox(new Vector2(x, y)).Bottom) / 10000f); - } - } - - public new void drawAsProp(SpriteBatch b) - { - } - - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber) - { - if (this.isRecipe) - { - transparency = 0.5f; - scaleSize *= 0.75f; - } - - if (this.Texture != null) - { - var targSize = (int) (64 * scaleSize * 0.9f); - var midX = (int) (location.X + 32); - var midY = (int) (location.Y + 32); - - var targX = midX - targSize / 2; - var targY = midY - targSize / 2; - - spriteBatch.Draw(this.Texture, new Rectangle(targX, targY, targSize, targSize), null, new Color(255, 255, 255, transparency), 0, Vector2.Zero, SpriteEffects.None, layerDepth); - } - if (drawStackNumber) - { - var _scale = 0.5f + scaleSize; - Game1.drawWithBorder(this.stack.ToString(), Color.Black, Color.White, location + new Vector2(Game1.tileSize - Game1.tinyFont.MeasureString(string.Concat(this.stack.ToString())).X * _scale, Game1.tileSize - (float) ((double) Game1.tinyFont.MeasureString(string.Concat(this.stack.ToString())).Y * 3.0f / 4.0f) * _scale), 0.0f, _scale, 1f, true); - } - } - - public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) - { - if (this.Texture != null) - { - var targSize = 64; - var midX = (int) (objectPosition.X + 32); - var midY = (int) (objectPosition.Y + 32); - - var targX = midX - targSize / 2; - var targY = midY - targSize / 2; - - spriteBatch.Draw(this.Texture, new Rectangle(targX, targY, targSize, targSize), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (f.getStandingY() + 2) / 10000f); - } - } - - public override Color getCategoryColor() - { - return this.CategoryColour; - } - - public override string getCategoryName() - { - if (string.IsNullOrEmpty(this.CategoryName)) - return "Modded Item"; - return this.CategoryName; - } - - public override bool isPassable() - { - return this.IsPassable; - } - - public override bool isPlaceable() - { - return this.IsPlaceable; - } - - public override int maximumStackSize() - { - return this.MaxStackSize; - } - - public SObject Clone() - { - var toRet = new SObject - { - Name = this.Name, - CategoryName = this.CategoryName, - Description = this.Description, - Texture = this.Texture, - IsPassable = this.IsPassable, - IsPlaceable = this.IsPlaceable, - quality = this.quality, - scale = this.scale, - isSpawnedObject = this.isSpawnedObject, - isRecipe = this.isRecipe, - questItem = this.questItem, - stack = 1, - HasBeenRegistered = this.HasBeenRegistered, - RegisteredId = this.RegisteredId - }; - - - return toRet; - } - - public override Item getOne() - { - return this.Clone(); - } - - public override void actionWhenBeingHeld(Farmer who) - { - var x = Game1.oldMouseState.X + Game1.viewport.X; - var y = Game1.oldMouseState.Y + Game1.viewport.Y; - - x = x / Game1.tileSize; - y = y / Game1.tileSize; - - this.CurrentMouse = new Vector2(x, y); - //Program.LogDebug(canBePlacedHere(Game1.currentLocation, CurrentMouse)); - base.actionWhenBeingHeld(who); - } - - public override bool canBePlacedHere(GameLocation l, Vector2 tile) - { - //Program.LogDebug(CurrentMouse.ToString().Replace("{", "").Replace("}", "")); - if (!l.objects.ContainsKey(tile)) - return true; - - return false; - } - - public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) - { - if (Game1.didPlayerJustRightClick()) - return false; - - x = x / Game1.tileSize; - y = y / Game1.tileSize; - - var key = new Vector2(x, y); - - if (!this.canBePlacedHere(location, key)) - return false; - - var s = this.Clone(); - - s.PlacedAt = key; - s.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); - - location.objects.Add(key, s); - - return true; - } - - public override void actionOnPlayerEntry() - { - //base.actionOnPlayerEntry(); - } - - public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) - { - if (this.canBePlacedHere(location, this.CurrentMouse)) - { - var targSize = Game1.tileSize; - - var x = Game1.oldMouseState.X + Game1.viewport.X; - var y = Game1.oldMouseState.Y + Game1.viewport.Y; - spriteBatch.Draw(Game1.mouseCursors, new Vector2(x / Game1.tileSize * Game1.tileSize - Game1.viewport.X, y / Game1.tileSize * Game1.tileSize - Game1.viewport.Y), new Rectangle(Utility.playerCanPlaceItemHere(location, this, x, y, Game1.player) ? 194 : 210, 388, 16, 16), Color.White, 0.0f, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 0.01f); - } - } - } -}
\ No newline at end of file diff --git a/src/StardewModdingAPI/LogWriter.cs b/src/StardewModdingAPI/LogWriter.cs deleted file mode 100644 index e22759a7..00000000 --- a/src/StardewModdingAPI/LogWriter.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using StardewModdingAPI.Framework; - -namespace StardewModdingAPI -{ - /// <summary>A log writer which queues messages for output, and periodically flushes them to the console and log file.</summary> - /// <remarks>Only one instance should be created.</remarks> - [Obsolete("This class is internal and should not be referenced outside SMAPI. It will no longer be exposed in a future version.")] - public class LogWriter - { - /********* - ** Properties - *********/ - /// <summary>Manages reading and writing to the log file.</summary> - private readonly LogFileManager LogFile; - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="logFile">Manages reading and writing to the log file.</param> - internal LogWriter(LogFileManager logFile) - { - this.WarnDeprecated(); - this.LogFile = logFile; - } - - /// <summary>Queue a message for output.</summary> - /// <param name="message">The message to log.</param> - public void WriteToLog(string message) - { - |
