From 1a4cdd71a5d5bd69a76d67c346562fdc2ccef22b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 2 Apr 2021 21:18:18 -0400 Subject: fix asset propagation for localized movie data --- src/SMAPI/Metadata/CoreAssetPropagator.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 52da3946..83ed52ad 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -286,6 +286,10 @@ namespace StardewModdingAPI.Metadata Game1.clothingInformation = content.Load>(key); return true; + case "data\\concessions": // MovieTheater.GetConcessions + MovieTheater.ClearCachedLocalizedData(); + return true; + case "data\\concessiontastes": // MovieTheater.GetConcessionTasteForCharacter this.Reflection .GetField>(typeof(MovieTheater), "_concessionTastes") @@ -306,16 +310,9 @@ namespace StardewModdingAPI.Metadata case "data\\hairdata": // Farmer.GetHairStyleMetadataFile return this.ReloadHairData(); - case "data\\moviesreactions": // MovieTheater.GetMovieReactions - this.Reflection - .GetField>(typeof(MovieTheater), "_genericReactions") - .SetValue(content.Load>(key)); - return true; - case "data\\movies": // MovieTheater.GetMovieData - this.Reflection - .GetField>(typeof(MovieTheater), "_movieData") - .SetValue(content.Load>(key)); + case "data\\moviesreactions": // MovieTheater.GetMovieReactions + MovieTheater.ClearCachedLocalizedData(); return true; case "data\\npcdispositions": // NPC constructor -- cgit From 3fa0433c9862d1922cd0540848d2bd8716934d1f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 2 Apr 2021 21:30:55 -0400 Subject: add initial support for 64-bit Windows hack (#767) --- src/SMAPI/Constants.cs | 56 ++++++++++++++++--------------- src/SMAPI/Framework/Logging/LogManager.cs | 3 ++ src/SMAPI/Framework/SCore.cs | 2 +- src/SMAPI/SMAPI.csproj | 6 +++- 4 files changed, 38 insertions(+), 29 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 8b0c952d..af9b7aa2 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -38,6 +38,14 @@ namespace StardewModdingAPI /// The target game platform. internal static GamePlatform Platform { get; } = (GamePlatform)Enum.Parse(typeof(GamePlatform), LowLevelEnvironmentUtility.DetectPlatform()); + /// Whether SMAPI is being compiled for Windows with a 64-bit Linux version of the game. This is highly specialized and shouldn't be used in most cases. + internal static bool IsWindows64BitHack { get; } = +#if SMAPI_FOR_WINDOWS_64BIT_HACK + true; +#else + false; +#endif + /// The game framework running the game. internal static GameFramework GameFramework { get; } = #if SMAPI_FOR_XNA @@ -47,7 +55,7 @@ namespace StardewModdingAPI #endif /// The game's assembly name. - internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows ? "Stardew Valley" : "StardewValley"; + internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows && !EarlyConstants.IsWindows64BitHack ? "Stardew Valley" : "StardewValley"; /// The value which should appear in the SMAPI log, if any. internal static int? LogScreenId { get; set; } @@ -231,33 +239,27 @@ namespace StardewModdingAPI targetAssemblies.Add(typeof(StardewModdingAPI.IManifest).Assembly); // get changes for platform - switch (targetPlatform) + if (Constants.Platform != Platform.Windows || EarlyConstants.IsWindows64BitHack) { - case Platform.Linux: - case Platform.Mac: - removeAssemblyReferences.AddRange(new[] - { - "Netcode", - "Stardew Valley" - }); - targetAssemblies.Add( - typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/Mac - ); - break; - - case Platform.Windows: - removeAssemblyReferences.Add( - "StardewValley" - ); - targetAssemblies.AddRange(new[] - { - typeof(Netcode.NetBool).Assembly, - typeof(StardewValley.Game1).Assembly - }); - break; - - default: - throw new InvalidOperationException($"Unknown target platform '{targetPlatform}'."); + removeAssemblyReferences.AddRange(new[] + { + "Netcode", + "Stardew Valley" + }); + targetAssemblies.Add( + typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/Mac + ); + } + else + { + removeAssemblyReferences.Add( + "StardewValley" + ); + targetAssemblies.AddRange(new[] + { + typeof(Netcode.NetBool).Assembly, + typeof(StardewValley.Game1).Assembly + }); } // get changes for game framework diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index 243ca3ae..38d561e5 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -287,6 +287,9 @@ namespace StardewModdingAPI.Framework.Logging string platformLabel = EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform); if ((Constants.GameFramework == GameFramework.Xna) != (Constants.Platform == Platform.Windows)) platformLabel += $" with {Constants.GameFramework}"; +#if SMAPI_FOR_WINDOWS_64BIT_HACK + platformLabel += " 64-bit hack"; +#endif // init logging this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {platformLabel}", LogLevel.Info); diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index ebb21555..22c58099 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -419,7 +419,7 @@ namespace StardewModdingAPI.Framework Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice); // log GPU info -#if SMAPI_FOR_WINDOWS +#if SMAPI_FOR_WINDOWS && !SMAPI_FOR_WINDOWS_64BIT_HACK this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? ""}"); #endif } diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index ceef33df..413d9f33 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -14,6 +14,10 @@ + + x64 + + @@ -34,7 +38,7 @@ - + -- cgit From 60b563267ea7bc308d7eda55477f61fa063b069a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 2 Apr 2021 21:30:55 -0400 Subject: fix asset key normalization for 64-bit hack (#767) --- src/SMAPI/Framework/Content/ContentCache.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/Content/ContentCache.cs b/src/SMAPI/Framework/Content/ContentCache.cs index 7edc9ab9..5c7ad778 100644 --- a/src/SMAPI/Framework/Content/ContentCache.cs +++ b/src/SMAPI/Framework/Content/ContentCache.cs @@ -57,6 +57,8 @@ namespace StardewModdingAPI.Framework.Content IReflectedMethod method = reflection.GetMethod(typeof(TitleContainer), "GetCleanPath"); this.NormalizeAssetNameForPlatform = path => method.Invoke(path); } + else if (EarlyConstants.IsWindows64BitHack) + this.NormalizeAssetNameForPlatform = PathUtilities.NormalizePath; else this.NormalizeAssetNameForPlatform = key => key.Replace('\\', '/'); // based on MonoGame's ContentManager.Load logic } -- cgit From 2d8f916053a1b4b039a41a8bbe8018ebe2654022 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 3 Apr 2021 11:39:58 -0400 Subject: log failed root dependencies in their own group --- src/SMAPI/Framework/IModMetadata.cs | 5 + src/SMAPI/Framework/Logging/LogManager.cs | 163 +++++++++++++++++--------- src/SMAPI/Framework/ModLoading/ModMetadata.cs | 53 +++++++-- 3 files changed, 155 insertions(+), 66 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/IModMetadata.cs b/src/SMAPI/Framework/IModMetadata.cs index 5d2f352d..f5babafb 100644 --- a/src/SMAPI/Framework/IModMetadata.cs +++ b/src/SMAPI/Framework/IModMetadata.cs @@ -117,6 +117,11 @@ namespace StardewModdingAPI.Framework /// Only return valid update keys. IEnumerable GetUpdateKeys(bool validOnly = true); + /// Get whether the given mod ID must be installed to load this mod. + /// The mod ID to check. + /// Whether to include optional dependencies. + bool HasRequiredModId(string modId, bool includeOptional); + /// Get the mod IDs that must be installed to load this mod. /// Whether to include optional dependencies. IEnumerable GetRequiredModIds(bool includeOptional = false); diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index 38d561e5..4ba4fffc 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -429,67 +429,38 @@ namespace StardewModdingAPI.Framework.Logging // log skipped mods if (skippedMods.Any()) { - // get logging logic - HashSet loggedDuplicateIds = new HashSet(); - void LogSkippedMod(IModMetadata mod) - { - string message = $" - {mod.DisplayName}{(mod.Manifest?.Version != null ? " " + mod.Manifest.Version.ToString() : "")} because {mod.Error}"; + var loggedDuplicateIds = new HashSet(); - // handle duplicate mods - // (log first duplicate only, don't show redundant version) - if (mod.FailReason == ModFailReason.Duplicate && mod.HasManifest()) + this.Monitor.Log(" Skipped mods", LogLevel.Error); + this.Monitor.Log(" " + "".PadRight(50, '-'), LogLevel.Error); + this.Monitor.Log(" These mods could not be added to your game.", LogLevel.Error); + this.Monitor.Newline(); + foreach (var list in this.GroupFailedModsByPriority(skippedMods)) + { + if (list.Any()) { - if (!loggedDuplicateIds.Add(mod.Manifest.UniqueID)) - return; // already logged + foreach (IModMetadata mod in list.OrderBy(p => p.DisplayName)) + { + string message = $" - {mod.DisplayName}{(" " + mod.Manifest?.Version?.ToString()).TrimEnd()} because {mod.Error}"; - message = $" - {mod.DisplayName} because {mod.Error}"; - } + // duplicate mod: log first one only, don't show redundant version + if (mod.FailReason == ModFailReason.Duplicate && mod.HasManifest()) + { + if (loggedDuplicateIds.Add(mod.Manifest.UniqueID)) + continue; // already logged - // log message - this.Monitor.Log(message, LogLevel.Error); - if (mod.ErrorDetails != null) - this.Monitor.Log($" ({mod.ErrorDetails})"); - } + message = $" - {mod.DisplayName} because {mod.Error}"; + } - // group mods - List skippedDependencies = new List(); - List otherSkippedMods = new List(); - { - // track broken dependencies - HashSet skippedDependencyIds = new HashSet(StringComparer.OrdinalIgnoreCase); - HashSet skippedModIds = new HashSet(from mod in skippedMods where mod.HasID() select mod.Manifest.UniqueID, StringComparer.OrdinalIgnoreCase); - foreach (IModMetadata mod in skippedMods) - { - foreach (string requiredId in skippedModIds.Intersect(mod.GetRequiredModIds())) - skippedDependencyIds.Add(requiredId); - } + // log message + this.Monitor.Log(message, LogLevel.Error); + if (mod.ErrorDetails != null) + this.Monitor.Log($" ({mod.ErrorDetails})"); + } - // collect mod groups - foreach (IModMetadata mod in skippedMods) - { - if (mod.HasID() && skippedDependencyIds.Contains(mod.Manifest.UniqueID)) - skippedDependencies.Add(mod); - else - otherSkippedMods.Add(mod); + this.Monitor.Newline(); } } - - // log skipped mods - this.Monitor.Log(" Skipped mods", LogLevel.Error); - this.Monitor.Log(" " + "".PadRight(50, '-'), LogLevel.Error); - this.Monitor.Log(" These mods could not be added to your game.", LogLevel.Error); - this.Monitor.Newline(); - - if (skippedDependencies.Any()) - { - foreach (IModMetadata mod in skippedDependencies.OrderBy(p => p.DisplayName)) - LogSkippedMod(mod); - this.Monitor.Newline(); - } - - foreach (IModMetadata mod in otherSkippedMods.OrderBy(p => p.DisplayName)) - LogSkippedMod(mod); - this.Monitor.Newline(); } // log warnings @@ -561,6 +532,92 @@ namespace StardewModdingAPI.Framework.Logging } } + /// Group failed mods by the priority players should update them, where mods in earlier groups are more likely to fix multiple mods. + /// The failed mods to group. + private IEnumerable> GroupFailedModsByPriority(IList failedMods) + { + var failedOthers = failedMods.ToList(); + var skippedModIds = new HashSet(from mod in failedMods where mod.HasID() select mod.Manifest.UniqueID, StringComparer.OrdinalIgnoreCase); + + // group B: dependencies which failed + var failedOtherDependencies = new List(); + { + // get failed dependency IDs + var skippedDependencyIds = new HashSet(StringComparer.OrdinalIgnoreCase); + foreach (IModMetadata mod in failedMods) + { + foreach (string requiredId in skippedModIds.Intersect(mod.GetRequiredModIds())) + skippedDependencyIds.Add(requiredId); + } + + // group matching mods + this.FilterThrough( + fromList: failedOthers, + toList: failedOtherDependencies, + match: mod => mod.HasID() && skippedDependencyIds.Contains(mod.Manifest.UniqueID) + ); + } + + // group A: failed root dependencies which other dependencies need + var failedRootDependencies = new List(); + { + var skippedDependencyIds = new HashSet(failedOtherDependencies.Select(p => p.Manifest.UniqueID)); + this.FilterThrough( + fromList: failedOtherDependencies, + toList: failedRootDependencies, + match: mod => + { + // has no failed dependency + foreach (string requiredId in mod.GetRequiredModIds()) + { + if (skippedDependencyIds.Contains(requiredId)) + return false; + } + + // another dependency depends on this mod + bool isDependedOn = false; + foreach (IModMetadata other in failedOtherDependencies) + { + if (other.HasRequiredModId(mod.Manifest.UniqueID, includeOptional: false)) + { + isDependedOn = true; + break; + } + } + + return isDependedOn; + } + ); + } + + // return groups + return new[] + { + failedRootDependencies, + failedOtherDependencies, + failedOthers + }; + } + + /// Filter matching items from one list and add them to the other. + /// The list item type. + /// The list to filter. + /// The list to which to add filtered items. + /// Matches items to filter through. + private void FilterThrough(IList fromList, IList toList, Func match) + { + for (int i = 0; i < fromList.Count; i++) + { + TItem item = fromList[i]; + if (match(item)) + { + toList.Add(item); + fromList.RemoveAt(i); + i--; + } + } + } + /// Write a mod warning group to the console and log. /// The mods to search. /// Matches mods to include in the warning group. diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index b4de3d6c..0d89fd20 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -19,6 +19,9 @@ namespace StardewModdingAPI.Framework.ModLoading /// The non-error issues with the mod, including warnings suppressed by the data record. private ModWarning ActualWarnings = ModWarning.None; + /// The mod IDs which are listed as a requirement by this mod. The value for each pair indicates whether the dependency is required (i.e. not an optional dependency). + private Lazy> Dependencies; + /********* ** Accessors @@ -100,6 +103,8 @@ namespace StardewModdingAPI.Framework.ModLoading this.Manifest = manifest; this.DataRecord = dataRecord; this.IsIgnored = isIgnored; + + this.Dependencies = new Lazy>(this.ExtractDependencies); } /// @@ -199,23 +204,21 @@ namespace StardewModdingAPI.Framework.ModLoading } /// - public IEnumerable GetRequiredModIds(bool includeOptional = false) + public bool HasRequiredModId(string modId, bool includeOptional) { - HashSet required = new HashSet(StringComparer.OrdinalIgnoreCase); + return + this.Dependencies.Value.TryGetValue(modId, out bool isRequired) + && (includeOptional || isRequired); + } - // yield dependencies - if (this.Manifest?.Dependencies != null) + /// + public IEnumerable GetRequiredModIds(bool includeOptional = false) + { + foreach (var pair in this.Dependencies.Value) { - foreach (var entry in this.Manifest?.Dependencies) - { - if ((entry.IsRequired || includeOptional) && required.Add(entry.UniqueID)) - yield return entry.UniqueID; - } + if (includeOptional || pair.Value) + yield return pair.Key; } - - // yield content pack parent - if (this.Manifest?.ContentPackFor?.UniqueID != null && required.Add(this.Manifest.ContentPackFor.UniqueID)) - yield return this.Manifest.ContentPackFor.UniqueID; } /// @@ -237,5 +240,29 @@ namespace StardewModdingAPI.Framework.ModLoading string rootFolderName = Path.GetFileName(this.RootPath) ?? ""; return Path.Combine(rootFolderName, this.RelativeDirectoryPath); } + + + /********* + ** Private methods + *********/ + /// Extract mod IDs from the manifest that must be installed to load this mod. + /// Returns a dictionary of mod ID => is required (i.e. not an optional dependency). + public IDictionary ExtractDependencies() + { + var ids = new Dictionary(StringComparer.OrdinalIgnoreCase); + + // yield dependencies + if (this.Manifest?.Dependencies != null) + { + foreach (var entry in this.Manifest?.Dependencies) + ids[entry.UniqueID] = entry.IsRequired; + } + + // yield content pack parent + if (this.Manifest?.ContentPackFor?.UniqueID != null) + ids[this.Manifest.ContentPackFor.UniqueID] = true; + + return ids; + } } } -- cgit From 222183c651c5b5d9e402db1b8009e2e0a0681b06 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Apr 2021 11:37:11 -0400 Subject: standardize spelling of 'macOS' --- src/SMAPI/Constants.cs | 2 +- src/SMAPI/Framework/Content/AssetDataForImage.cs | 4 ++-- src/SMAPI/Framework/ContentPack.cs | 2 +- src/SMAPI/Framework/Logging/LogFileManager.cs | 2 +- src/SMAPI/Framework/Logging/LogManager.cs | 2 +- src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs | 2 +- src/SMAPI/Framework/ModLoading/RewriteFacades/SpriteBatchFacade.cs | 4 ++-- src/SMAPI/Framework/SCore.cs | 4 ++-- src/SMAPI/Framework/Serialization/ColorConverter.cs | 2 +- src/SMAPI/Framework/Serialization/PointConverter.cs | 2 +- src/SMAPI/Framework/Serialization/RectangleConverter.cs | 2 +- src/SMAPI/Framework/Serialization/Vector2Converter.cs | 2 +- src/SMAPI/GamePlatform.cs | 2 +- src/SMAPI/SMAPI.config.json | 4 ++-- 14 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index af9b7aa2..079c9251 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -247,7 +247,7 @@ namespace StardewModdingAPI "Stardew Valley" }); targetAssemblies.Add( - typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/Mac + typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/macOS ); } else diff --git a/src/SMAPI/Framework/Content/AssetDataForImage.cs b/src/SMAPI/Framework/Content/AssetDataForImage.cs index 5f91610e..529fb93a 100644 --- a/src/SMAPI/Framework/Content/AssetDataForImage.cs +++ b/src/SMAPI/Framework/Content/AssetDataForImage.cs @@ -12,7 +12,7 @@ namespace StardewModdingAPI.Framework.Content ** Fields *********/ /// The minimum value to consider non-transparent. - /// On Linux/Mac, fully transparent pixels may have an alpha up to 4 for some reason. + /// On Linux/macOS, fully transparent pixels may have an alpha up to 4 for some reason. private const byte MinOpacity = 5; @@ -82,7 +82,7 @@ namespace StardewModdingAPI.Framework.Content // premultiplied by the content pipeline. The formula is derived from // https://blogs.msdn.microsoft.com/shawnhar/2009/11/06/premultiplied-alpha/. // Note: don't use named arguments here since they're different between - // Linux/Mac and Windows. + // Linux/macOS and Windows. float alphaBelow = 1 - (above.A / 255f); newData[i] = new Color( (int)(above.R + (below.R * alphaBelow)), // r diff --git a/src/SMAPI/Framework/ContentPack.cs b/src/SMAPI/Framework/ContentPack.cs index a6835dbe..0660a367 100644 --- a/src/SMAPI/Framework/ContentPack.cs +++ b/src/SMAPI/Framework/ContentPack.cs @@ -18,7 +18,7 @@ namespace StardewModdingAPI.Framework /// Encapsulates SMAPI's JSON file parsing. private readonly JsonHelper JsonHelper; - /// A cache of case-insensitive => exact relative paths within the content pack, for case-insensitive file lookups on Linux/Mac. + /// A cache of case-insensitive => exact relative paths within the content pack, for case-insensitive file lookups on Linux/macOS. private readonly IDictionary RelativePaths = new Dictionary(StringComparer.OrdinalIgnoreCase); diff --git a/src/SMAPI/Framework/Logging/LogFileManager.cs b/src/SMAPI/Framework/Logging/LogFileManager.cs index 6b5babcd..6ab2bdfb 100644 --- a/src/SMAPI/Framework/Logging/LogFileManager.cs +++ b/src/SMAPI/Framework/Logging/LogFileManager.cs @@ -44,7 +44,7 @@ namespace StardewModdingAPI.Framework.Logging public void WriteLine(string message) { // always use Windows-style line endings for convenience - // (Linux/Mac editors are fine with them, Windows editors often require them) + // (Linux/macOS editors are fine with them, Windows editors often require them) this.Stream.Write(message + "\r\n"); } diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index 4ba4fffc..0cc2da9f 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -527,7 +527,7 @@ namespace StardewModdingAPI.Framework.Logging // not crossplatform this.LogModWarningGroup(modsWithWarnings, ModWarning.UsesDynamic, LogLevel.Debug, "Not crossplatform", - "These mods use the 'dynamic' keyword, and won't work on Linux/Mac." + "These mods use the 'dynamic' keyword, and won't work on Linux/macOS." ); } } diff --git a/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs b/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs index a948213b..baffc50e 100644 --- a/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs +++ b/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs @@ -20,7 +20,7 @@ namespace StardewModdingAPI.Framework.ModLoading /// The instruction is compatible, but affects the save serializer in a way that may make saves unloadable without the mod. DetectedSaveSerializer, - /// The instruction is compatible, but uses the dynamic keyword which won't work on Linux/Mac. + /// The instruction is compatible, but uses the dynamic keyword which won't work on Linux/macOS. DetectedDynamic, /// The instruction is compatible, but references or which may impact stability. diff --git a/src/SMAPI/Framework/ModLoading/RewriteFacades/SpriteBatchFacade.cs b/src/SMAPI/Framework/ModLoading/RewriteFacades/SpriteBatchFacade.cs index cf71af77..aefd1c20 100644 --- a/src/SMAPI/Framework/ModLoading/RewriteFacades/SpriteBatchFacade.cs +++ b/src/SMAPI/Framework/ModLoading/RewriteFacades/SpriteBatchFacade.cs @@ -4,10 +4,10 @@ using Microsoft.Xna.Framework.Graphics; namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades { - /// Provides method signatures that can be injected into mod code for compatibility between Linux/Mac or Windows. + /// Provides method signatures that can be injected into mod code for compatibility between Linux/macOS or Windows. /// This is public to support SMAPI rewriting and should not be referenced directly by mods. [SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Used via assembly rewriting")] - [SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Linux/Mac.")] + [SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Linux/macOS.")] [SuppressMessage("ReSharper", "CS1591", Justification = "Documentation not needed for facade classes.")] public class SpriteBatchFacade : SpriteBatch { diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 22c58099..e8c8a8e5 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -187,7 +187,7 @@ namespace StardewModdingAPI.Framework #if SMAPI_FOR_WINDOWS if (Constants.Platform != Platform.Windows) { - this.Monitor.Log("Oops! You're running Windows, but this version of SMAPI is for Linux or Mac. Please reinstall SMAPI to fix this.", LogLevel.Error); + this.Monitor.Log("Oops! You're running Windows, but this version of SMAPI is for Linux or macOS. Please reinstall SMAPI to fix this.", LogLevel.Error); this.LogManager.PressAnyKeyToExit(); } #else @@ -1259,7 +1259,7 @@ namespace StardewModdingAPI.Framework // create client string url = this.Settings.WebApiBaseUrl; #if !SMAPI_FOR_WINDOWS - url = url.Replace("https://", "http://"); // workaround for OpenSSL issues with the game's bundled Mono on Linux/Mac + url = url.Replace("https://", "http://"); // workaround for OpenSSL issues with the game's bundled Mono on Linux/macOS #endif WebApiClient client = new WebApiClient(url, Constants.ApiVersion); this.Monitor.Log("Checking for updates..."); diff --git a/src/SMAPI/Framework/Serialization/ColorConverter.cs b/src/SMAPI/Framework/Serialization/ColorConverter.cs index 7315f1a5..3b3720b5 100644 --- a/src/SMAPI/Framework/Serialization/ColorConverter.cs +++ b/src/SMAPI/Framework/Serialization/ColorConverter.cs @@ -8,7 +8,7 @@ namespace StardewModdingAPI.Framework.Serialization { /// Handles deserialization of for crossplatform compatibility. /// - /// - Linux/Mac format: { "B": 76, "G": 51, "R": 25, "A": 102 } + /// - Linux/macOS format: { "B": 76, "G": 51, "R": 25, "A": 102 } /// - Windows format: "26, 51, 76, 102" /// internal class ColorConverter : SimpleReadOnlyConverter diff --git a/src/SMAPI/Framework/Serialization/PointConverter.cs b/src/SMAPI/Framework/Serialization/PointConverter.cs index 6cf795dc..21d1f845 100644 --- a/src/SMAPI/Framework/Serialization/PointConverter.cs +++ b/src/SMAPI/Framework/Serialization/PointConverter.cs @@ -8,7 +8,7 @@ namespace StardewModdingAPI.Framework.Serialization { /// Handles deserialization of for crossplatform compatibility. /// - /// - Linux/Mac format: { "X": 1, "Y": 2 } + /// - Linux/macOS format: { "X": 1, "Y": 2 } /// - Windows format: "1, 2" /// internal class PointConverter : SimpleReadOnlyConverter diff --git a/src/SMAPI/Framework/Serialization/RectangleConverter.cs b/src/SMAPI/Framework/Serialization/RectangleConverter.cs index 8f7318b3..31f3ad77 100644 --- a/src/SMAPI/Framework/Serialization/RectangleConverter.cs +++ b/src/SMAPI/Framework/Serialization/RectangleConverter.cs @@ -9,7 +9,7 @@ namespace StardewModdingAPI.Framework.Serialization { /// Handles deserialization of for crossplatform compatibility. /// - /// - Linux/Mac format: { "X": 1, "Y": 2, "Width": 3, "Height": 4 } + /// - Linux/macOS format: { "X": 1, "Y": 2, "Width": 3, "Height": 4 } /// - Windows format: "{X:1 Y:2 Width:3 Height:4}" /// internal class RectangleConverter : SimpleReadOnlyConverter diff --git a/src/SMAPI/Framework/Serialization/Vector2Converter.cs b/src/SMAPI/Framework/Serialization/Vector2Converter.cs index 3e2ab776..589febf8 100644 --- a/src/SMAPI/Framework/Serialization/Vector2Converter.cs +++ b/src/SMAPI/Framework/Serialization/Vector2Converter.cs @@ -8,7 +8,7 @@ namespace StardewModdingAPI.Framework.Serialization { /// Handles deserialization of for crossplatform compatibility. /// - /// - Linux/Mac format: { "X": 1, "Y": 2 } + /// - Linux/macOS format: { "X": 1, "Y": 2 } /// - Windows format: "1, 2" /// internal class Vector2Converter : SimpleReadOnlyConverter diff --git a/src/SMAPI/GamePlatform.cs b/src/SMAPI/GamePlatform.cs index b64595e4..cce5ed8d 100644 --- a/src/SMAPI/GamePlatform.cs +++ b/src/SMAPI/GamePlatform.cs @@ -11,7 +11,7 @@ namespace StardewModdingAPI /// The Linux version of the game. Linux = Platform.Linux, - /// The Mac version of the game. + /// The macOS version of the game. Mac = Platform.Mac, /// The Windows version of the game. diff --git a/src/SMAPI/SMAPI.config.json b/src/SMAPI/SMAPI.config.json index 034eceed..b8179207 100644 --- a/src/SMAPI/SMAPI.config.json +++ b/src/SMAPI/SMAPI.config.json @@ -71,7 +71,7 @@ copy all the settings, or you may cause bugs due to overridden changes in future /** * The base URL for SMAPI's web API, used to perform update checks. - * Note: the protocol will be changed to http:// on Linux/Mac due to OpenSSL issues with the + * Note: the protocol will be changed to http:// on Linux/macOS due to OpenSSL issues with the * game's bundled Mono. */ "WebApiBaseUrl": "https://smapi.io/api/", @@ -85,7 +85,7 @@ copy all the settings, or you may cause bugs due to overridden changes in future * The colors to use for text written to the SMAPI console. * * The possible values for 'UseScheme' are: - * - AutoDetect: SMAPI will assume a light background on Mac, and detect the background color + * - AutoDetect: SMAPI will assume a light background on macOS, and detect the background color * automatically on Linux or Windows. * - LightBackground: use darker text colors that look better on a white or light background. * - DarkBackground: use lighter text colors that look better on a black or dark background. -- cgit From 2b1b3b19a507876e106a444c93b4c33aca35c353 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Apr 2021 11:40:08 -0400 Subject: improve error-handling during asset propagation --- src/SMAPI/Framework/ContentCoordinator.cs | 2 +- src/SMAPI/Metadata/CoreAssetPropagator.cs | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs index 2920e670..d0e759c2 100644 --- a/src/SMAPI/Framework/ContentCoordinator.cs +++ b/src/SMAPI/Framework/ContentCoordinator.cs @@ -132,7 +132,7 @@ namespace StardewModdingAPI.Framework ); this.ContentManagers.Add(contentManagerForAssetPropagation); this.VanillaContentManager = new LocalizedContentManager(serviceProvider, rootDirectory); - this.CoreAssets = new CoreAssetPropagator(this.MainContentManager, contentManagerForAssetPropagation, reflection, aggressiveMemoryOptimizations); + this.CoreAssets = new CoreAssetPropagator(this.MainContentManager, contentManagerForAssetPropagation, this.Monitor, reflection, aggressiveMemoryOptimizations); } /// Get a new content manager which handles reading files from the game content folder with support for interception. diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 83ed52ad..3146ceaf 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using Microsoft.Xna.Framework.Graphics; using Netcode; +using StardewModdingAPI.Framework; using StardewModdingAPI.Framework.ContentManagers; using StardewModdingAPI.Framework.Reflection; using StardewModdingAPI.Toolkit.Utilities; @@ -36,15 +37,18 @@ namespace StardewModdingAPI.Metadata /// An internal content manager used only for asset propagation. See remarks on . private readonly GameContentManagerForAssetPropagation DisposableContentManager; + /// Writes messages to the console. + private readonly IMonitor Monitor; + + /// Simplifies access to private game code. + private readonly Reflector Reflection; + /// Whether to enable more aggressive memory optimizations. private readonly bool AggressiveMemoryOptimizations; /// Normalizes an asset key to match the cache key and assert that it's valid. private readonly Func AssertAndNormalizeAssetName; - /// Simplifies access to private game code. - private readonly Reflector Reflection; - /// Optimized bucket categories for batch reloading assets. private enum AssetBucket { @@ -65,12 +69,14 @@ namespace StardewModdingAPI.Metadata /// Initialize the core asset data. /// The main content manager through which to reload assets. /// An internal content manager used only for asset propagation. + /// Writes messages to the console. /// Simplifies access to private code. /// Whether to enable more aggressive memory optimizations. - public CoreAssetPropagator(LocalizedContentManager mainContent, GameContentManagerForAssetPropagation disposableContent, Reflector reflection, bool aggressiveMemoryOptimizations) + public CoreAssetPropagator(LocalizedContentManager mainContent, GameContentManagerForAssetPropagation disposableContent, IMonitor monitor, Reflector reflection, bool aggressiveMemoryOptimizations) { this.MainContentManager = mainContent; this.DisposableContentManager = disposableContent; + this.Monitor = monitor; this.Reflection = reflection; this.AggressiveMemoryOptimizations = aggressiveMemoryOptimizations; @@ -116,7 +122,17 @@ namespace StardewModdingAPI.Metadata default: foreach (var entry in bucket) { - bool changed = this.PropagateOther(entry.Key, entry.Value, ignoreWorld, out bool curChangedMapWarps); + bool changed = false; + bool curChangedMapWarps = false; + try + { + changed = this.PropagateOther(entry.Key, entry.Value, ignoreWorld, out curChangedMapWarps); + } + catch (Exception ex) + { + this.Monitor.Log($"An error occurred while propagating asset changes. Error details:\n{ex.GetLogSummary()}", LogLevel.Error); + } + propagatedAssets[entry.Key] = changed; updatedNpcWarps = updatedNpcWarps || curChangedMapWarps; } -- cgit From c7db35818b93ea4735c2b69ce28cd0a24e603d14 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Apr 2021 12:09:07 -0400 Subject: fix Context.IsMainPlayer incorrectly true when split-screen player is joining --- src/SMAPI/Context.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Context.cs b/src/SMAPI/Context.cs index 5f70d0f7..a745592c 100644 --- a/src/SMAPI/Context.cs +++ b/src/SMAPI/Context.cs @@ -86,7 +86,7 @@ namespace StardewModdingAPI public static bool HasRemotePlayers => Context.IsMultiplayer && !Game1.hasLocalClientsOnly; /// Whether the current player is the main player. This is always true in single-player, and true when hosting in multiplayer. - public static bool IsMainPlayer => Game1.IsMasterGame && !(TitleMenu.subMenu is FarmhandMenu); + public static bool IsMainPlayer => Game1.IsMasterGame && Context.ScreenId == 0 && !(TitleMenu.subMenu is FarmhandMenu); /********* -- cgit From bca1e63c3e66011aef8cb9736e091ced05aa4992 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Apr 2021 12:11:06 -0400 Subject: fix error when mod edits bundle data while a split-screen player is joining --- src/SMAPI/Metadata/CoreAssetPropagator.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 3146ceaf..623c65d5 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -274,6 +274,7 @@ namespace StardewModdingAPI.Metadata return true; case "data\\bundles": // NetWorldState constructor + if (Context.IsMainPlayer && Game1.netWorldState != null) { var bundles = this.Reflection.GetField(Game1.netWorldState.Value, "bundles").GetValue(); var rewards = this.Reflection.GetField>(Game1.netWorldState.Value, "bundleRewards").GetValue(); -- cgit From f961a376ee5347d5ac2b830ce82b28f116889e72 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 15 Apr 2021 21:17:19 -0400 Subject: log Stardew64Installer patch version if applicable (#767) --- src/SMAPI/Framework/Logging/LogManager.cs | 37 +++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index 0cc2da9f..804acfb3 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; +using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using StardewModdingAPI.Framework.Commands; @@ -11,6 +12,7 @@ using StardewModdingAPI.Framework.ModLoading; using StardewModdingAPI.Internal.ConsoleWriting; using StardewModdingAPI.Toolkit.Framework.ModData; using StardewModdingAPI.Toolkit.Utilities; +using StardewValley; namespace StardewModdingAPI.Framework.Logging { @@ -283,16 +285,16 @@ namespace StardewModdingAPI.Framework.Logging /// The custom SMAPI settings. public void LogIntro(string modsPath, IDictionary customSettings) { - // get platform label - string platformLabel = EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform); - if ((Constants.GameFramework == GameFramework.Xna) != (Constants.Platform == Platform.Windows)) - platformLabel += $" with {Constants.GameFramework}"; -#if SMAPI_FOR_WINDOWS_64BIT_HACK - platformLabel += " 64-bit hack"; -#endif + // log platform & patches + { + this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform)}", LogLevel.Info); - // init logging - this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {platformLabel}", LogLevel.Info); + string[] patchLabels = this.GetPatchLabels().ToArray(); + if (patchLabels.Any()) + this.Monitor.Log($"Detected custom version: {string.Join(", ", patchLabels)}", LogLevel.Info); + } + + // log basic info this.Monitor.Log($"Mods go here: {modsPath}", LogLevel.Info); if (modsPath != Constants.DefaultModsPath) this.Monitor.Log("(Using custom --mods-path argument.)"); @@ -409,6 +411,23 @@ namespace StardewModdingAPI.Framework.Logging gameMonitor.Log(message, level); } + /// Get human-readable labels to log for detected SMAPI and Stardew Valley customizations. + private IEnumerable GetPatchLabels() + { + // custom game framework + if (EarlyConstants.IsWindows64BitHack) + yield return $"running 64-bit SMAPI with {Constants.GameFramework}"; + else if ((Constants.GameFramework == GameFramework.Xna) != (Constants.Platform == Platform.Windows)) + yield return $"running {Constants.GameFramework}"; + + // patched by Stardew64Installer + { + PropertyInfo patcherProperty = typeof(Game1).GetProperty("Stardew64InstallerVersion"); + if (patcherProperty != null) + yield return $"patched by Stardew64Installer {patcherProperty.GetValue(null)}"; + } + } + /// Write a summary of mod warnings to the console and log. /// The loaded mods. /// The mods which could not be loaded. -- cgit From 9174e17f5372905d3f494e1b36688f41dff367cc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 17 Apr 2021 22:10:51 -0400 Subject: mark field readonly --- src/SMAPI/Framework/ModLoading/ModMetadata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 0d89fd20..17e6d59a 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -20,7 +20,7 @@ namespace StardewModdingAPI.Framework.ModLoading private ModWarning ActualWarnings = ModWarning.None; /// The mod IDs which are listed as a requirement by this mod. The value for each pair indicates whether the dependency is required (i.e. not an optional dependency). - private Lazy> Dependencies; + private readonly Lazy> Dependencies; /********* -- cgit From 13a3c8fbddb9dd47d30e1b9684d3ceb048086e91 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 22 Apr 2021 18:13:45 -0400 Subject: add SMAPI version and bitness to console title earlier --- src/SMAPI/Constants.cs | 5 ++++- src/SMAPI/Program.cs | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 079c9251..b55104c0 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -59,6 +59,9 @@ namespace StardewModdingAPI /// The value which should appear in the SMAPI log, if any. internal static int? LogScreenId { get; set; } + + /// SMAPI's current raw semantic version. + internal static string RawApiVersion = "3.9.5"; } /// Contains SMAPI's constants and assumptions. @@ -71,7 +74,7 @@ namespace StardewModdingAPI ** Public ****/ /// SMAPI's current semantic version. - public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.9.5"); + public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion(EarlyConstants.RawApiVersion); /// The minimum supported version of Stardew Valley. public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.5.4"); diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 986d2780..e830f799 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -24,6 +24,8 @@ namespace StardewModdingAPI /// The command-line arguments. public static void Main(string[] args) { + Console.Title = $"SMAPI {EarlyConstants.RawApiVersion}{(EarlyConstants.IsWindows64BitHack ? " 64-bit" : "")} - {Console.Title}"; + try { AppDomain.CurrentDomain.AssemblyResolve += Program.CurrentDomain_AssemblyResolve; @@ -159,7 +161,7 @@ namespace StardewModdingAPI Console.ResetColor(); Console.WriteLine(); } - + Program.PressAnyKeyToExit(showMessage: true); } -- cgit From 665c6806d3797f8329ef8c6fcaa80d469fef5005 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 22 Apr 2021 21:52:09 -0400 Subject: add update alerts for Stardew64Installer (#767) --- src/SMAPI/Constants.cs | 15 +++++++++++++ src/SMAPI/Framework/Logging/LogManager.cs | 9 ++------ src/SMAPI/Framework/Models/SConfig.cs | 3 +++ src/SMAPI/Framework/SCore.cs | 35 +++++++++++++++++++++++++++++++ src/SMAPI/SMAPI.config.json | 5 +++++ 5 files changed, 60 insertions(+), 7 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index b55104c0..161e92b4 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -300,6 +300,21 @@ namespace StardewModdingAPI return new PlatformAssemblyMap(targetPlatform, removeAssemblyReferences.ToArray(), targetAssemblies.ToArray()); } + /// Get whether the game assembly was patched by Stardew64Installer. + /// The version of Stardew64Installer which was applied to the game assembly, if any. + internal static bool IsPatchedByStardew64Installer(out ISemanticVersion version) + { + PropertyInfo property = typeof(Game1).GetProperty("Stardew64InstallerVersion"); + if (property == null) + { + version = null; + return false; + } + + version = new SemanticVersion((string)property.GetValue(null)); + return true; + } + /********* ** Private methods diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index 804acfb3..a4df3c18 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; -using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using StardewModdingAPI.Framework.Commands; @@ -12,7 +11,6 @@ using StardewModdingAPI.Framework.ModLoading; using StardewModdingAPI.Internal.ConsoleWriting; using StardewModdingAPI.Toolkit.Framework.ModData; using StardewModdingAPI.Toolkit.Utilities; -using StardewValley; namespace StardewModdingAPI.Framework.Logging { @@ -421,11 +419,8 @@ namespace StardewModdingAPI.Framework.Logging yield return $"running {Constants.GameFramework}"; // patched by Stardew64Installer - { - PropertyInfo patcherProperty = typeof(Game1).GetProperty("Stardew64InstallerVersion"); - if (patcherProperty != null) - yield return $"patched by Stardew64Installer {patcherProperty.GetValue(null)}"; - } + if (Constants.IsPatchedByStardew64Installer(out ISemanticVersion patchedByVersion)) + yield return $"patched by Stardew64Installer {patchedByVersion}"; } /// Write a summary of mod warnings to the console and log. diff --git a/src/SMAPI/Framework/Models/SConfig.cs b/src/SMAPI/Framework/Models/SConfig.cs index 4a80e34c..a71bafd9 100644 --- a/src/SMAPI/Framework/Models/SConfig.cs +++ b/src/SMAPI/Framework/Models/SConfig.cs @@ -52,6 +52,9 @@ namespace StardewModdingAPI.Framework.Models /// SMAPI's GitHub project name, used to perform update checks. public string GitHubProjectName { get; set; } + /// Stardew64Installer's GitHub project name, used to perform update checks. + public string Stardew64InstallerGitHubProjectName { get; set; } + /// The base URL for SMAPI's web API, used to perform update checks. public string WebApiBaseUrl { get; set; } diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index e8c8a8e5..85a2bb8f 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -1302,6 +1302,41 @@ namespace StardewModdingAPI.Framework this.LogManager.WriteUpdateMarker(updateFound.ToString(), updateUrl); } + // check Stardew64Installer version + if (Constants.IsPatchedByStardew64Installer(out ISemanticVersion patchedByVersion)) + { + ISemanticVersion updateFound = null; + string updateUrl = null; + try + { + // fetch update check + ModEntryModel response = client.GetModInfo(new[] { new ModSearchEntryModel("Steviegt6.Stardew64Installer", patchedByVersion, new[] { $"GitHub:{this.Settings.Stardew64InstallerGitHubProjectName}" }) }, apiVersion: Constants.ApiVersion, gameVersion: Constants.GameVersion, platform: Constants.Platform).Single().Value; + updateFound = response.SuggestedUpdate?.Version; + updateUrl = response.SuggestedUpdate?.Url ?? Constants.HomePageUrl; + + // log message + if (updateFound != null) + this.Monitor.Log($"You can update Stardew64Installer to {updateFound}: {updateUrl}", LogLevel.Alert); + else + this.Monitor.Log(" Stardew64Installer okay."); + + // show errors + if (response.Errors.Any()) + { + this.Monitor.Log("Couldn't check for a new version of Stardew64Installer. This won't affect your game, but you may not be notified of new versions if this keeps happening.", LogLevel.Warn); + this.Monitor.Log($"Error: {string.Join("\n", response.Errors)}"); + } + } + catch (Exception ex) + { + this.Monitor.Log("Couldn't check for a new version of Stardew64Installer. This won't affect your game, but you won't be notified of new versions if this keeps happening.", LogLevel.Warn); + this.Monitor.Log(ex is WebException && ex.InnerException == null + ? $"Error: {ex.Message}" + : $"Error: {ex.GetLogSummary()}" + ); + } + } + // check mod versions if (mods.Any()) { diff --git a/src/SMAPI/SMAPI.config.json b/src/SMAPI/SMAPI.config.json index b8179207..7b5625d6 100644 --- a/src/SMAPI/SMAPI.config.json +++ b/src/SMAPI/SMAPI.config.json @@ -69,6 +69,11 @@ copy all the settings, or you may cause bugs due to overridden changes in future */ "GitHubProjectName": "Pathoschild/SMAPI", + /** + * Stardew64Installer's GitHub project name, used to perform update checks. + */ + "Stardew64InstallerGitHubProjectName": "Steviegt6/Stardew64Installer", + /** * The base URL for SMAPI's web API, used to perform update checks. * Note: the protocol will be changed to http:// on Linux/macOS due to OpenSSL issues with the -- cgit From fa72198d1d38a77df6b92fcf936862f644a04f10 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 23 Apr 2021 22:12:41 -0400 Subject: add [64-bit] tag to window titles (#767) --- src/SMAPI/Framework/SCore.cs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 85a2bb8f..5862b112 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -263,10 +263,7 @@ namespace StardewModdingAPI.Framework }); // set window titles - this.SetWindowTitles( - game: $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}", - smapi: $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}" - ); + this.UpdateWindowTitles(); } catch (Exception ex) { @@ -280,10 +277,7 @@ namespace StardewModdingAPI.Framework this.LogManager.LogSettingsHeader(this.Settings); // set window titles - this.SetWindowTitles( - game: $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}", - smapi: $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}" - ); + this.UpdateWindowTitles(); // start game this.Monitor.Log("Starting game...", LogLevel.Debug); @@ -387,11 +381,7 @@ namespace StardewModdingAPI.Framework } // update window titles - int modsLoaded = this.ModRegistry.GetAll().Count(); - this.SetWindowTitles( - game: $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion} with {modsLoaded} mods", - smapi: $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion} with {modsLoaded} mods" - ); + this.UpdateWindowTitles(); } /// Raised after the game finishes initializing. @@ -1238,13 +1228,23 @@ namespace StardewModdingAPI.Framework return !issuesFound; } - /// Set the window titles for the game and console windows. - /// The game window text. - /// The SMAPI window text. - private void SetWindowTitles(string game, string smapi) + /// Set the titles for the game and console windows. + private void UpdateWindowTitles() { - this.Game.Window.Title = game; - this.LogManager.SetConsoleTitle(smapi); + string smapiVersion = $"{Constants.ApiVersion}{(EarlyConstants.IsWindows64BitHack ? " [64-bit]" : "")}"; + + string consoleTitle = $"SMAPI {smapiVersion} - running Stardew Valley {Constants.GameVersion}"; + string gameTitle = $"Stardew Valley {Constants.GameVersion} - running SMAPI {smapiVersion}"; + + if (this.ModRegistry.AreAllModsLoaded) + { + int modsLoaded = this.ModRegistry.GetAll().Count(); + consoleTitle += $" with {modsLoaded} mods"; + gameTitle += $" with {modsLoaded} mods"; + } + + this.Game.Window.Title = gameTitle; + this.LogManager.SetConsoleTitle(consoleTitle); } /// Asynchronously check for a new version of SMAPI and any installed mods, and print alerts to the console if an update is available. -- cgit From 99f70f963459912ce66f5a586eb4fc36e561b69d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 1 May 2021 12:33:09 -0400 Subject: match tilesheets without extension to .png files automatically if possible --- .../Framework/ContentManagers/ModContentManager.cs | 17 +++++++++++++---- 1 fi