summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/CommandManager.cs1
-rw-r--r--src/SMAPI/Framework/Content/AssetData.cs7
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForImage.cs13
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForMap.cs5
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForObject.cs15
-rw-r--r--src/SMAPI/Framework/Content/AssetInfo.cs9
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs5
-rw-r--r--src/SMAPI/Framework/ContentManagers/BaseContentManager.cs2
-rw-r--r--src/SMAPI/Framework/ContentManagers/ModContentManager.cs6
-rw-r--r--src/SMAPI/Framework/ContentPack.cs34
-rw-r--r--src/SMAPI/Framework/CursorPosition.cs11
-rw-r--r--src/SMAPI/Framework/DeprecationLevel.cs2
-rw-r--r--src/SMAPI/Framework/DeprecationManager.cs1
-rw-r--r--src/SMAPI/Framework/Events/EventManager.cs2
-rw-r--r--src/SMAPI/Framework/Events/ManagedEvent.cs43
-rw-r--r--src/SMAPI/Framework/Events/ModGameLoopEvents.cs1
-rw-r--r--src/SMAPI/Framework/GameVersion.cs2
-rw-r--r--src/SMAPI/Framework/IModMetadata.cs14
-rw-r--r--src/SMAPI/Framework/Input/GamePadStateBuilder.cs31
-rw-r--r--src/SMAPI/Framework/Input/IInputStateBuilder.cs4
-rw-r--r--src/SMAPI/Framework/Input/KeyboardStateBuilder.cs17
-rw-r--r--src/SMAPI/Framework/Input/MouseStateBuilder.cs39
-rw-r--r--src/SMAPI/Framework/Input/SInputState.cs157
-rw-r--r--src/SMAPI/Framework/InternalExtensions.cs4
-rw-r--r--src/SMAPI/Framework/Logging/ConsoleInterceptionManager.cs59
-rw-r--r--src/SMAPI/Framework/Logging/InterceptingTextWriter.cs55
-rw-r--r--src/SMAPI/Framework/Logging/LogManager.cs600
-rw-r--r--src/SMAPI/Framework/ModHelpers/BaseHelper.cs4
-rw-r--r--src/SMAPI/Framework/ModHelpers/CommandHelper.cs13
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentHelper.cs44
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs13
-rw-r--r--src/SMAPI/Framework/ModHelpers/DataHelper.cs34
-rw-r--r--src/SMAPI/Framework/ModHelpers/InputHelper.cs14
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModHelper.cs32
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs15
-rw-r--r--src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs19
-rw-r--r--src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs34
-rw-r--r--src/SMAPI/Framework/ModHelpers/TranslationHelper.cs13
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs31
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/EventFinder.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/FieldFinder.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/MethodFinder.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/PropertyFinder.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/ReferenceToMissingMemberFinder.cs17
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/TypeAssemblyFinder.cs6
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/TypeFinder.cs6
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/BaseInstructionHandler.cs23
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs67
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RewriteHelper.cs24
-rw-r--r--src/SMAPI/Framework/ModLoading/IInstructionHandler.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/ModFailReason.cs27
-rw-r--r--src/SMAPI/Framework/ModLoading/ModMetadata.cs95
-rw-r--r--src/SMAPI/Framework/ModLoading/ModResolver.cs48
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs35
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs65
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/Harmony1AssemblyRewriter.cs13
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs106
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/HeuristicMethodRewriter.cs109
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs9
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/StaticFieldToConstantRewriter.cs74
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/TypeReferenceRewriter.cs6
-rw-r--r--src/SMAPI/Framework/Models/SConfig.cs4
-rw-r--r--src/SMAPI/Framework/Monitor.cs32
-rw-r--r--src/SMAPI/Framework/Networking/MultiplayerPeer.cs18
-rw-r--r--src/SMAPI/Framework/Networking/MultiplayerPeerMod.cs6
-rw-r--r--src/SMAPI/Framework/Reflection/ReflectedField.cs7
-rw-r--r--src/SMAPI/Framework/Reflection/ReflectedMethod.cs9
-rw-r--r--src/SMAPI/Framework/Reflection/ReflectedProperty.cs7
-rw-r--r--src/SMAPI/Framework/Reflection/Reflector.cs2
-rw-r--r--src/SMAPI/Framework/Rendering/SXnaDisplayDevice.cs8
-rw-r--r--src/SMAPI/Framework/RequestExitDelegate.cs2
-rw-r--r--src/SMAPI/Framework/SCore.cs1443
-rw-r--r--src/SMAPI/Framework/SGame.cs2008
-rw-r--r--src/SMAPI/Framework/SGameConstructorHack.cs43
-rw-r--r--src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs1
-rw-r--r--src/SMAPI/Framework/Utilities/Countdown.cs2
-rw-r--r--src/SMAPI/Framework/WatcherCore.cs7
78 files changed, 2826 insertions, 2961 deletions
diff --git a/src/SMAPI/Framework/CommandManager.cs b/src/SMAPI/Framework/CommandManager.cs
index 2b91d394..4a99fd4d 100644
--- a/src/SMAPI/Framework/CommandManager.cs
+++ b/src/SMAPI/Framework/CommandManager.cs
@@ -119,6 +119,7 @@ namespace StardewModdingAPI.Framework
command.Callback.Invoke(name, arguments);
return true;
}
+
return false;
}
diff --git a/src/SMAPI/Framework/Content/AssetData.cs b/src/SMAPI/Framework/Content/AssetData.cs
index cacc6078..5c90d83b 100644
--- a/src/SMAPI/Framework/Content/AssetData.cs
+++ b/src/SMAPI/Framework/Content/AssetData.cs
@@ -16,7 +16,7 @@ namespace StardewModdingAPI.Framework.Content
/*********
** Accessors
*********/
- /// <summary>The content data being read.</summary>
+ /// <inheritdoc />
public TValue Data { get; protected set; }
@@ -36,10 +36,7 @@ namespace StardewModdingAPI.Framework.Content
this.OnDataReplaced = onDataReplaced;
}
- /// <summary>Replace the entire content value with the given value. This is generally not recommended, since it may break compatibility with other mods or different versions of the game.</summary>
- /// <param name="value">The new content value.</param>
- /// <exception cref="ArgumentNullException">The <paramref name="value"/> is null.</exception>
- /// <exception cref="InvalidCastException">The <paramref name="value"/>'s type is not compatible with the loaded asset's type.</exception>
+ /// <inheritdoc />
public void ReplaceWith(TValue value)
{
if (value == null)
diff --git a/src/SMAPI/Framework/Content/AssetDataForImage.cs b/src/SMAPI/Framework/Content/AssetDataForImage.cs
index 44a97136..5f91610e 100644
--- a/src/SMAPI/Framework/Content/AssetDataForImage.cs
+++ b/src/SMAPI/Framework/Content/AssetDataForImage.cs
@@ -28,13 +28,7 @@ namespace StardewModdingAPI.Framework.Content
public AssetDataForImage(string locale, string assetName, Texture2D data, Func<string, string> getNormalizedPath, Action<Texture2D> onDataReplaced)
: base(locale, assetName, data, getNormalizedPath, onDataReplaced) { }
- /// <summary>Overwrite part of the image.</summary>
- /// <param name="source">The image to patch into the content.</param>
- /// <param name="sourceArea">The part of the <paramref name="source"/> to copy (or <c>null</c> to take the whole texture). This must be within the bounds of the <paramref name="source"/> texture.</param>
- /// <param name="targetArea">The part of the content to patch (or <c>null</c> to patch the whole texture). The original content within this area will be erased. This must be within the bounds of the existing spritesheet.</param>
- /// <param name="patchMode">Indicates how an image should be patched.</param>
- /// <exception cref="ArgumentNullException">One of the arguments is null.</exception>
- /// <exception cref="ArgumentOutOfRangeException">The <paramref name="targetArea"/> is outside the bounds of the spritesheet.</exception>
+ /// <inheritdoc />
public void PatchImage(Texture2D source, Rectangle? sourceArea = null, Rectangle? targetArea = null, PatchMode patchMode = PatchMode.Replace)
{
// get texture
@@ -104,10 +98,7 @@ namespace StardewModdingAPI.Framework.Content
target.SetData(0, targetArea, sourceData, 0, pixelCount);
}
- /// <summary>Extend the image if needed to fit the given size. Note that this is an expensive operation, creates a new texture instance, and that extending a spritesheet horizontally may cause game errors or bugs.</summary>
- /// <param name="minWidth">The minimum texture width.</param>
- /// <param name="minHeight">The minimum texture height.</param>
- /// <returns>Whether the texture was resized.</returns>
+ /// <inheritdoc />
public bool ExtendImage(int minWidth, int minHeight)
{
if (this.Data.Width >= minWidth && this.Data.Height >= minHeight)
diff --git a/src/SMAPI/Framework/Content/AssetDataForMap.cs b/src/SMAPI/Framework/Content/AssetDataForMap.cs
index dee5b034..e80c6e53 100644
--- a/src/SMAPI/Framework/Content/AssetDataForMap.cs
+++ b/src/SMAPI/Framework/Content/AssetDataForMap.cs
@@ -24,10 +24,7 @@ namespace StardewModdingAPI.Framework.Content
public AssetDataForMap(string locale, string assetName, Map data, Func<string, string> getNormalizedPath, Action<Map> onDataReplaced)
: base(locale, assetName, data, getNormalizedPath, onDataReplaced) { }
- /// <summary>Copy layers, tiles, and tilesheets from another map onto the asset.</summary>
- /// <param name="source">The map from which to copy.</param>
- /// <param name="sourceArea">The tile area within the source map to copy, or <c>null</c> for the entire source map size. This must be within the bounds of the <paramref name="source"/> map.</param>
- /// <param name="targetArea">The tile area within the target map to overwrite, or <c>null</c> to patch the whole map. The original content within this area will be erased. This must be within the bounds of the existing map.</param>
+ /// <inheritdoc />
/// <remarks>Derived from <see cref="StardewValley.GameLocation.ApplyMapOverride"/> with a few changes:
/// - can be applied directly to the maps when loading, before the location is created;
/// - added support for source/target areas;
diff --git a/src/SMAPI/Framework/Content/AssetDataForObject.cs b/src/SMAPI/Framework/Content/AssetDataForObject.cs
index f00ba124..b7e8dfeb 100644
--- a/src/SMAPI/Framework/Content/AssetDataForObject.cs
+++ b/src/SMAPI/Framework/Content/AssetDataForObject.cs
@@ -26,32 +26,25 @@ namespace StardewModdingAPI.Framework.Content
public AssetDataForObject(IAssetInfo info, object data, Func<string, string> getNormalizedPath)
: this(info.Locale, info.AssetName, data, getNormalizedPath) { }
- /// <summary>Get a helper to manipulate the data as a dictionary.</summary>
- /// <typeparam name="TKey">The expected dictionary key.</typeparam>
- /// <typeparam name="TValue">The expected dictionary balue.</typeparam>
- /// <exception cref="InvalidOperationException">The content being read isn't a dictionary.</exception>
+ /// <inheritdoc />
public IAssetDataForDictionary<TKey, TValue> AsDictionary<TKey, TValue>()
{
return new AssetDataForDictionary<TKey, TValue>(this.Locale, this.AssetName, this.GetData<IDictionary<TKey, TValue>>(), this.GetNormalizedPath, this.ReplaceWith);
}
- /// <summary>Get a helper to manipulate the data as an image.</summary>
- /// <exception cref="InvalidOperationException">The content being read isn't an image.</exception>
+ /// <inheritdoc />
public IAssetDataForImage AsImage()
{
return new AssetDataForImage(this.Locale, this.AssetName, this.GetData<Texture2D>(), this.GetNormalizedPath, this.ReplaceWith);
}
- /// <summary>Get a helper to manipulate the data as a map.</summary>
- /// <exception cref="InvalidOperationException">The content being read isn't a map.</exception>
+ /// <inheritdoc />
public IAssetDataForMap AsMap()
{
return new AssetDataForMap(this.Locale, this.AssetName, this.GetData<Map>(), this.GetNormalizedPath, this.ReplaceWith);
}
- /// <summary>Get the data as a given type.</summary>
- /// <typeparam name="TData">The expected data type.</typeparam>
- /// <exception cref="InvalidCastException">The data can't be converted to <typeparamref name="TData"/>.</exception>
+ /// <inheritdoc />
public TData GetData<TData>()
{
if (!(this.Data is TData))
diff --git a/src/SMAPI/Framework/Content/AssetInfo.cs b/src/SMAPI/Framework/Content/AssetInfo.cs
index ed009499..d8106439 100644
--- a/src/SMAPI/Framework/Content/AssetInfo.cs
+++ b/src/SMAPI/Framework/Content/AssetInfo.cs
@@ -16,13 +16,13 @@ namespace StardewModdingAPI.Framework.Content
/*********
** Accessors
*********/
- /// <summary>The content's locale code, if the content is localized.</summary>
+ /// <inheritdoc />
public string Locale { get; }
- /// <summary>The normalized asset name being read. The format may change between platforms; see <see cref="AssetNameEquals"/> to compare with a known path.</summary>
+ /// <inheritdoc />
public string AssetName { get; }
- /// <summary>The content data type.</summary>
+ /// <inheritdoc />
public Type DataType { get; }
@@ -42,8 +42,7 @@ namespace StardewModdingAPI.Framework.Content
this.GetNormalizedPath = getNormalizedPath;
}
- /// <summary>Get whether the asset name being loaded matches a given name after normalization.</summary>
- /// <param name="path">The expected asset path, relative to the game's content folder and without the .xnb extension or locale suffix (like 'Data\ObjectInformation').</param>
+ /// <inheritdoc />
public bool AssetNameEquals(string path)
{
path = this.GetNormalizedPath(path);
diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs
index 479ffa7f..93371415 100644
--- a/src/SMAPI/Framework/ContentCoordinator.cs
+++ b/src/SMAPI/Framework/ContentCoordinator.cs
@@ -9,7 +9,6 @@ using Microsoft.Xna.Framework.Content;
using StardewModdingAPI.Framework.Content;
using StardewModdingAPI.Framework.ContentManagers;
using StardewModdingAPI.Framework.Reflection;
-using StardewModdingAPI.Framework.StateTracking.Comparers;
using StardewModdingAPI.Metadata;
using StardewModdingAPI.Toolkit.Serialization;
using StardewModdingAPI.Toolkit.Utilities;
@@ -96,7 +95,7 @@ namespace StardewModdingAPI.Framework
this.ContentManagers.Add(
this.MainContentManager = new GameContentManager("Game1.content", serviceProvider, rootDirectory, currentCulture, this, monitor, reflection, this.OnDisposing, onLoadingFirstAsset)
);
- this.CoreAssets = new CoreAssetPropagator(this.MainContentManager.AssertAndNormalizeAssetName, reflection, monitor);
+ this.CoreAssets = new CoreAssetPropagator(this.MainContentManager.AssertAndNormalizeAssetName, reflection);
}
/// <summary>Get a new content manager which handles reading files from the game content folder with support for interception.</summary>
@@ -237,7 +236,7 @@ namespace StardewModdingAPI.Framework
{
foreach (var entry in contentManager.InvalidateCache(predicate, dispose))
{
- if (!removedAssets.TryGetValue(entry.Key, out Type type))
+ if (!removedAssets.ContainsKey(entry.Key))
removedAssets[entry.Key] = entry.Value.GetType();
}
}
diff --git a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs
index a8de013a..6bc3a505 100644
--- a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs
@@ -76,7 +76,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
/// <param name="onDisposing">A callback to invoke when the content manager is being disposed.</param>
/// <param name="isNamespaced">Whether this content manager handles managed asset keys (e.g. to load assets from a mod folder).</param>
protected BaseContentManager(string name, IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture, ContentCoordinator coordinator, IMonitor monitor, Reflector reflection, Action<BaseContentManager> onDisposing, bool isNamespaced)
- : base(serviceProvider, rootDirectory, currentCulture)
+ : base(serviceProvider, rootDirectory, currentCulture)
{
// init
this.Name = name;
diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
index 26ddb067..12d672cf 100644
--- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
@@ -250,7 +250,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
if (pixel.A == byte.MinValue || pixel.A == byte.MaxValue)
continue; // no need to change fully transparent/opaque pixels
- data[i] = new Color(pixel.R * pixel.A / byte.MaxValue, pixel.G * pixel.A / byte.MaxValue, pixel.B * pixel.A / byte.MaxValue, pixel.A); // slower version: Color.FromNonPremultiplied(data[i].ToVector4())
+ data[i] = new Color(pixel.R * pixel.A / byte.MaxValue, pixel.G * pixel.A / byte.MaxValue, pixel.B * pixel.A / byte.MaxValue, pixel.A); // slower version: Color.FromNonPremultiplied(data[i].ToVector4())
}
texture.SetData(data);
@@ -275,12 +275,12 @@ namespace StardewModdingAPI.Framework.ContentManagers
/// * If the location is indoors or the desert, or the image source contains 'path' or 'object', it's loaded
/// as-is relative to the <c>Content</c> folder.
/// * Else it's loaded from <c>Content\Maps</c> with a seasonal prefix.
- ///
+ ///
/// That logic doesn't work well in our case, mainly because we have no location metadata at this point.
/// Instead we use a more heuristic approach: check relative to the map file first, then relative to
/// <c>Content\Maps</c>, then <c>Content</c>. If the image source filename contains a seasonal prefix, try for a
/// seasonal variation and then an exact match.
- ///
+ ///
/// While that doesn't exactly match the game logic, it's close enough that it's unlikely to make a difference.
/// </remarks>
private void FixCustomTilesheetPaths(Map map, string relativeMapPath)
diff --git a/src/SMAPI/Framework/ContentPack.cs b/src/SMAPI/Framework/ContentPack.cs
index 9c0bb9d1..55c1a0b2 100644
--- a/src/SMAPI/Framework/ContentPack.cs
+++ b/src/SMAPI/Framework/ContentPack.cs
@@ -1,10 +1,7 @@
using System;
using System.IO;
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Toolkit.Serialization;
using StardewModdingAPI.Toolkit.Utilities;
-using xTile;
namespace StardewModdingAPI.Framework
{
@@ -24,13 +21,13 @@ namespace StardewModdingAPI.Framework
/*********
** Accessors
*********/
- /// <summary>The full path to the content pack's folder.</summary>
+ /// <inheritdoc />
public string DirectoryPath { get; }
- /// <summary>The content pack's manifest.</summary>
+ /// <inheritdoc />
public IManifest Manifest { get; }
- /// <summary>Provides translations stored in the content pack's <c>i18n</c> folder. See <see cref="IModHelper.Translation"/> for more info.</summary>
+ /// <inheritdoc />
public ITranslationHelper Translation { get; }
@@ -52,8 +49,7 @@ namespace StardewModdingAPI.Framework
this.JsonHelper = jsonHelper;
}
- /// <summary>Get whether a given file exists in the content pack.</summary>