From 9c1617c9ee51a0f6b93242fe8fc789336957460c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 11 Apr 2018 21:15:16 -0400 Subject: drop support for Stardew Valley 1.2 (#453) --- src/SMAPI.ModBuildConfig/build/smapi.targets | 2 +- .../Framework/Commands/Player/AddCommand.cs | 4 - .../Framework/Commands/Player/SetColorCommand.cs | 8 - .../Framework/Commands/Player/SetNameCommand.cs | 4 - .../Commands/World/DownMineLevelCommand.cs | 4 - .../Commands/World/SetMineLevelCommand.cs | 4 - .../Framework/ItemRepository.cs | 56 +- src/SMAPI/Constants.cs | 28 +- src/SMAPI/Events/EventArgsInput.cs | 6 - src/SMAPI/Events/EventArgsInventoryChanged.cs | 12 +- .../Events/EventArgsLocationObjectsChanged.cs | 18 +- src/SMAPI/Framework/ContentCore.cs | 83 +-- src/SMAPI/Framework/ContentManagerShim.cs | 8 - src/SMAPI/Framework/GameVersion.cs | 8 +- src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs | 116 ---- src/SMAPI/Framework/Reflection/ReflectedField.cs | 3 - src/SMAPI/Framework/Reflection/ReflectedMethod.cs | 3 - .../Framework/Reflection/ReflectedProperty.cs | 3 - src/SMAPI/Framework/SGame.cs | 711 +-------------------- src/SMAPI/IPrivateField.cs | 30 - src/SMAPI/IPrivateMethod.cs | 31 - src/SMAPI/IPrivateProperty.cs | 30 - src/SMAPI/IReflectionHelper.cs | 69 -- src/SMAPI/Metadata/CoreAssetPropagator.cs | 47 +- src/SMAPI/Metadata/InstructionMetadata.cs | 63 -- src/SMAPI/StardewModdingAPI.csproj | 3 - 26 files changed, 23 insertions(+), 1331 deletions(-) delete mode 100644 src/SMAPI/IPrivateField.cs delete mode 100644 src/SMAPI/IPrivateMethod.cs delete mode 100644 src/SMAPI/IPrivateProperty.cs (limited to 'src') diff --git a/src/SMAPI.ModBuildConfig/build/smapi.targets b/src/SMAPI.ModBuildConfig/build/smapi.targets index a177840c..78afa7da 100644 --- a/src/SMAPI.ModBuildConfig/build/smapi.targets +++ b/src/SMAPI.ModBuildConfig/build/smapi.targets @@ -76,7 +76,7 @@ false true - + $(GamePath)\Netcode.dll False true diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs index a6f42b98..ff11da1e 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs @@ -54,11 +54,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player // apply quality if (match.Item is Object obj) -#if STARDEW_VALLEY_1_3 obj.Quality = quality; -#else - obj.quality = quality; -#endif else if (match.Item is Tool tool) tool.UpgradeLevel = quality; diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs index aa4fd105..f0815ef6 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetColorCommand.cs @@ -36,11 +36,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player switch (target) { case "hair": -#if STARDEW_VALLEY_1_3 Game1.player.hairstyleColor.Value = color; -#else - Game1.player.hairstyleColor = color; -#endif monitor.Log("OK, your hair color is updated.", LogLevel.Info); break; @@ -50,11 +46,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player break; case "pants": -#if STARDEW_VALLEY_1_3 Game1.player.pantsColor.Value = color; -#else - Game1.player.pantsColor = color; -#endif monitor.Log("OK, your pants color is updated.", LogLevel.Info); break; } diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs index 71e17f71..e8cb0584 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/SetNameCommand.cs @@ -39,11 +39,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player case "farm": if (!string.IsNullOrWhiteSpace(name)) { -#if STARDEW_VALLEY_1_3 Game1.player.farmName.Value = args[1]; -#else - Game1.player.farmName = args[1]; -#endif monitor.Log($"OK, your farm's name is now {Game1.player.farmName}.", LogLevel.Info); } else diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs index c83c3b07..2cec0fd3 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/DownMineLevelCommand.cs @@ -21,11 +21,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World { int level = (Game1.currentLocation as MineShaft)?.mineLevel ?? 0; monitor.Log($"OK, warping you to mine level {level + 1}.", LogLevel.Info); -#if STARDEW_VALLEY_1_3 Game1.enterMine(level + 1); -#else - Game1.enterMine(false, level + 1, ""); -#endif } } } diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs index 5947af1a..b4f6d5b3 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/World/SetMineLevelCommand.cs @@ -26,11 +26,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World // handle level = Math.Max(1, level); monitor.Log($"OK, warping you to mine level {level}.", LogLevel.Info); -#if STARDEW_VALLEY_1_3 Game1.enterMine(level); -#else - Game1.enterMine(true, level, ""); -#endif } } } diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index 9c0981c4..833fddde 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -96,28 +96,16 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework if (item.category == SObject.FruitsCategory) { // wine -#if STARDEW_VALLEY_1_3 - SObject wine = - new SObject(348, 1) + SObject wine = new SObject(348, 1) { Name = $"{item.Name} Wine", Price = item.price * 3 }; wine.preserve.Value = SObject.PreserveType.Wine; wine.preservedParentSheetIndex.Value = item.parentSheetIndex; -#else - SObject wine = new SObject(348, 1) - { - name = $"{item.Name} Wine", - price = item.price * 3, - preserve = SObject.PreserveType.Wine, - preservedParentSheetIndex = item.parentSheetIndex - }; -#endif yield return new SearchableItem(ItemType.Object, this.CustomIDOffset + id, wine); // jelly -#if STARDEW_VALLEY_1_3 SObject jelly = new SObject(344, 1) { Name = $"{item.Name} Jelly", @@ -125,15 +113,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework }; jelly.preserve.Value = SObject.PreserveType.Jelly; jelly.preservedParentSheetIndex.Value = item.parentSheetIndex; -#else - SObject jelly = new SObject(344, 1) - { - name = $"{item.Name} Jelly", - price = 50 + item.Price * 2, - preserve = SObject.PreserveType.Jelly, - preservedParentSheetIndex = item.parentSheetIndex - }; -#endif yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 2 + id, jelly); } @@ -141,7 +120,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework else if (item.category == SObject.VegetableCategory) { // juice -#if STARDEW_VALLEY_1_3 SObject juice = new SObject(350, 1) { Name = $"{item.Name} Juice", @@ -149,19 +127,9 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework }; juice.preserve.Value = SObject.PreserveType.Juice; juice.preservedParentSheetIndex.Value = item.parentSheetIndex; -#else - SObject juice = new SObject(350, 1) - { - name = $"{item.Name} Juice", - price = (int)(item.price * 2.25d), - preserve = SObject.PreserveType.Juice, - preservedParentSheetIndex = item.parentSheetIndex - }; -#endif yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 3 + id, juice); // pickled -#if STARDEW_VALLEY_1_3 SObject pickled = new SObject(342, 1) { Name = $"Pickled {item.Name}", @@ -169,15 +137,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework }; pickled.preserve.Value = SObject.PreserveType.Pickle; pickled.preservedParentSheetIndex.Value = item.parentSheetIndex; -#else - SObject pickled = new SObject(342, 1) - { - name = $"Pickled {item.Name}", - price = 50 + item.Price * 2, - preserve = SObject.PreserveType.Pickle, - preservedParentSheetIndex = item.parentSheetIndex - }; -#endif yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 4 + id, pickled); } @@ -211,7 +170,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework // yield honey if (type != null) { -#if STARDEW_VALLEY_1_3 SObject honey = new SObject(Vector2.Zero, 340, item.Name + " Honey", false, true, false, false) { Name = "Wild Honey" @@ -223,18 +181,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework honey.Name = $"{item.Name} Honey"; honey.Price += item.Price * 2; } -#else - SObject honey = new SObject(Vector2.Zero, 340, item.Name + " Honey", false, true, false, false) - { - name = "Wild Honey", - honeyType = type - }; - if (type != SObject.HoneyType.Wild) - { - honey.name = $"{item.Name} Honey"; - honey.price += item.price * 2; - } -#endif yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 5 + id, honey); } } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 1e35c030..e547dfa6 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -37,28 +37,13 @@ namespace StardewModdingAPI ** Public ****/ /// SMAPI's current semantic version. - public static ISemanticVersion ApiVersion { get; } = -#if STARDEW_VALLEY_1_3 - new SemanticVersion($"2.6-alpha.{DateTime.UtcNow:yyyyMMddHHmm}"); -#else - new SemanticVersion("2.5.5"); -#endif + public static ISemanticVersion ApiVersion { get; } = new SemanticVersion($"2.6-alpha.{DateTime.UtcNow:yyyyMMddHHmm}"); /// The minimum supported version of Stardew Valley. - public static ISemanticVersion MinimumGameVersion { get; } = -#if STARDEW_VALLEY_1_3 - new GameVersion("1.3.0.4"); -#else - new SemanticVersion("1.2.30"); -#endif + public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.3.0.27"); /// The maximum supported version of Stardew Valley. - public static ISemanticVersion MaximumGameVersion { get; } = -#if STARDEW_VALLEY_1_3 - null; -#else - new SemanticVersion("1.2.33"); -#endif + public static ISemanticVersion MaximumGameVersion { get; } = null; /// The path to the game folder. public static string ExecutionPath { get; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); @@ -184,12 +169,7 @@ namespace StardewModdingAPI /// Get the name of a save directory for the current player. private static string GetSaveFolderName() { - string prefix = -#if STARDEW_VALLEY_1_3 - new string(Game1.player.Name.Where(char.IsLetterOrDigit).ToArray()); -#else - new string(Game1.player.name.Where(char.IsLetterOrDigit).ToArray()); -#endif + string prefix = new string(Game1.player.Name.Where(char.IsLetterOrDigit).ToArray()); return $"{prefix}_{Game1.uniqueIDForThisGame}"; } diff --git a/src/SMAPI/Events/EventArgsInput.cs b/src/SMAPI/Events/EventArgsInput.cs index 75b9b8cd..b2bd978b 100644 --- a/src/SMAPI/Events/EventArgsInput.cs +++ b/src/SMAPI/Events/EventArgsInput.cs @@ -18,12 +18,6 @@ namespace StardewModdingAPI.Events /// The current cursor position. public ICursorPosition Cursor { get; } -#if !STARDEW_VALLEY_1_3 - /// Whether the input is considered a 'click' by the game for enabling action. - [Obsolete("Use " + nameof(EventArgsInput.IsActionButton) + " or " + nameof(EventArgsInput.IsUseToolButton) + " instead")] // deprecated in SMAPI 2.1 - public bool IsClick => this.IsActionButton; -#endif - /// Whether the input should trigger actions on the affected tile. public bool IsActionButton { get; } diff --git a/src/SMAPI/Events/EventArgsInventoryChanged.cs b/src/SMAPI/Events/EventArgsInventoryChanged.cs index b85ae9db..1fdca834 100644 --- a/src/SMAPI/Events/EventArgsInventoryChanged.cs +++ b/src/SMAPI/Events/EventArgsInventoryChanged.cs @@ -12,11 +12,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The player's inventory. -#if STARDEW_VALLEY_1_3 public IList Inventory { get; } -#else - public List Inventory { get; } -#endif /// The added items. public List Added { get; } @@ -34,13 +30,7 @@ namespace StardewModdingAPI.Events /// Construct an instance. /// The player's inventory. /// The inventory changes. - public EventArgsInventoryChanged( -#if STARDEW_VALLEY_1_3 - IList inventory, -#else - List inventory, -#endif - List changedItems) + public EventArgsInventoryChanged(IList inventory, List changedItems) { this.Inventory = inventory; this.Added = changedItems.Where(n => n.ChangeType == ChangeType.Added).ToList(); diff --git a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs index 180e9d78..de6bd365 100644 --- a/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs +++ b/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs @@ -1,11 +1,7 @@ using System; -using Microsoft.Xna.Framework; -#if STARDEW_VALLEY_1_3 using System.Collections.Generic; +using Microsoft.Xna.Framework; using Netcode; -#else -using StardewValley; -#endif using Object = StardewValley.Object; namespace StardewModdingAPI.Events @@ -17,11 +13,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The current list of objects in the current location. -#if STARDEW_VALLEY_1_3 public IDictionary> NewObjects { get; } -#else - public SerializableDictionary NewObjects { get; } -#endif /********* @@ -29,13 +21,7 @@ namespace StardewModdingAPI.Events *********/ /// Construct an instance. /// The current list of objects in the current location. - public EventArgsLocationObjectsChanged( -#if STARDEW_VALLEY_1_3 - IDictionary> newObjects -#else - SerializableDictionary newObjects -#endif - ) + public EventArgsLocationObjectsChanged(IDictionary> newObjects) { this.NewObjects = newObjects; } diff --git a/src/SMAPI/Framework/ContentCore.cs b/src/SMAPI/Framework/ContentCore.cs index 43357553..9da18481 100644 --- a/src/SMAPI/Framework/ContentCore.cs +++ b/src/SMAPI/Framework/ContentCore.cs @@ -44,10 +44,8 @@ namespace StardewModdingAPI.Framework /// The underlying asset cache. private readonly ContentCache Cache; -#if STARDEW_VALLEY_1_3 /// A lookup which indicates whether the asset is localisable (i.e. the filename contains the locale), if previously loaded. private readonly IDictionary IsLocalisableLookup; -#endif /// The locale codes used in asset keys indexed by enum value. private readonly IDictionary Locales; @@ -111,9 +109,7 @@ namespace StardewModdingAPI.Framework this.CoreAssets = new CoreAssetPropagator(this.NormaliseAssetName, reflection); this.Locales = this.GetKeyLocales(reflection); this.LanguageCodes = this.Locales.ToDictionary(p => p.Value, p => p.Key, StringComparer.InvariantCultureIgnoreCase); -#if STARDEW_VALLEY_1_3 this.IsLocalisableLookup = reflection.GetField>(this.Content, "_localizedAsset").GetValue(); -#endif } /// Get a new content manager which defers loading to the content core. @@ -209,11 +205,7 @@ namespace StardewModdingAPI.Framework /// The language code for which to load content. /// The is empty or contains invalid characters. /// The content asset couldn't be loaded (e.g. because it doesn't exist). - public T Load(string assetName, ContentManager instance -#if STARDEW_VALLEY_1_3 - , LocalizedContentManager.LanguageCode language -#endif - ) + public T Load(string assetName, ContentManager instance, LocalizedContentManager.LanguageCode language) { // normalise asset key this.AssertValidAssetKeyFormat(assetName); @@ -221,11 +213,7 @@ namespace StardewModdingAPI.Framework // load game content if (!assetName.StartsWith(this.ModContentPrefix)) -#if STARDEW_VALLEY_1_3 return this.LoadImpl(assetName, instance, language); -#else - return this.LoadImpl(assetName, instance); -#endif // load mod content SContentLoadException GetContentError(string reasonPhrase) => new SContentLoadException($"Failed loading content asset '{assetName}': {reasonPhrase}"); @@ -235,11 +223,7 @@ namespace StardewModdingAPI.Framework { // try cache if (this.IsLoaded(assetName)) -#if STARDEW_VALLEY_1_3 return this.LoadImpl(assetName, instance, language); -#else - return this.LoadImpl(assetName, instance); -#endif // get file FileInfo file = this.GetModFile(assetName); @@ -251,11 +235,7 @@ namespace StardewModdingAPI.Framework { // XNB file case ".xnb": -#if STARDEW_VALLEY_1_3 return this.LoadImpl(assetName, instance, language); -#else - return this.LoadImpl(assetName, instance); -#endif // unpacked map case ".tbin": @@ -436,10 +416,6 @@ namespace StardewModdingAPI.Framework /// Simplifies access to private game code. private IDictionary GetKeyLocales(Reflector reflection) { -#if !STARDEW_VALLEY_1_3 - IReflectedField codeField = reflection.GetField(typeof(LocalizedContentManager), "_currentLangCode"); - LocalizedContentManager.LanguageCode previousCode = codeField.GetValue(); -#endif string previousOverride = this.Content.LanguageCodeOverride; try @@ -448,21 +424,11 @@ namespace StardewModdingAPI.Framework this.Content.LanguageCodeOverride = null; // create locale => code map - IReflectedMethod languageCodeString = reflection -#if STARDEW_VALLEY_1_3 - .GetMethod(this.Content, "languageCodeString"); -#else - .GetMethod(this.Content, "languageCode"); -#endif + IReflectedMethod languageCodeString = reflection.GetMethod(this.Content, "languageCodeString"); IDictionary map = new Dictionary(); foreach (LocalizedContentManager.LanguageCode code in Enum.GetValues(typeof(LocalizedContentManager.LanguageCode))) { -#if STARDEW_VALLEY_1_3 map[code] = languageCodeString.Invoke(code); -#else - codeField.SetValue(code); - map[code] = languageCodeString.Invoke(); -#endif } return map; @@ -471,10 +437,6 @@ namespace StardewModdingAPI.Framework { // restore previous settings this.Content.LanguageCodeOverride = previousOverride; -#if !STARDEW_VALLEY_1_3 - codeField.SetValue(previousCode); -#endif - } } @@ -520,18 +482,12 @@ namespace StardewModdingAPI.Framework /// The normalised asset name. private bool IsNormalisedKeyLoaded(string normalisedAssetName) { -#if STARDEW_VALLEY_1_3 if (!this.IsLocalisableLookup.TryGetValue(normalisedAssetName, out bool localisable)) return false; return localisable ? this.Cache.ContainsKey($"{normalisedAssetName}.{this.Locales[this.Content.GetCurrentLanguage()]}") : this.Cache.ContainsKey(normalisedAssetName); -#else - return - this.Cache.ContainsKey(normalisedAssetName) - || this.Cache.ContainsKey($"{normalisedAssetName}.{this.Locales[this.Content.GetCurrentLanguage()]}"); // translated asset -#endif } /// Track that a content manager loaded an asset. @@ -552,11 +508,7 @@ namespace StardewModdingAPI.Framework /// The asset path relative to the loader root directory, not including the .xnb extension. /// The content manager instance for which to load the asset. /// The language code for which to load content. - private T LoadImpl(string assetName, ContentManager instance -#if STARDEW_VALLEY_1_3 - , LocalizedContentManager.LanguageCode language -#endif - ) + private T LoadImpl(string assetName, ContentManager instance, LocalizedContentManager.LanguageCode language) { return this.WithWriteLock(() => { @@ -564,13 +516,7 @@ namespace StardewModdingAPI.Framework if (this.IsNormalisedKeyLoaded(assetName)) { this.TrackAssetLoader(assetName, instance); - return this.Content - -#if STARDEW_VALLEY_1_3 - .Load(assetName, language); -#else - .Load(assetName); -#endif + return this.Content.Load(assetName, language); } // load asset @@ -579,30 +525,17 @@ namespace StardewModdingAPI.Framework { this.Monitor.Log($"Broke loop while loading asset '{assetName}'.", LogLevel.Warn); this.Monitor.Log($"Bypassing mod loaders for this asset. Stack trace:\n{Environment.StackTrace}", LogLevel.Trace); - data = this.Content -#if STARDEW_VALLEY_1_3 - .Load(assetName, language); -#else - .Load(assetName); -#endif + data = this.Content.Load(assetName, language); } else { data = this.AssetsBeingLoaded.Track(assetName, () => { - string locale = -#if STARDEW_VALLEY_1_3 - this.GetLocale(language); -#else - this.GetLocale(); -#endif + string locale = this.GetLocale(language); IAssetInfo info = new AssetInfo(locale, assetName, typeof(T), this.NormaliseAssetName); - IAssetData asset = this.ApplyLoader(info) -#if STARDEW_VALLEY_1_3 + IAssetData asset = + this.ApplyLoader(info) ?? new AssetDataForObject(info, this.Content.Load(assetName, language), this.NormaliseAssetName); -#else - ?? new AssetDataForObject(info, this.Content.Load(assetName), this.NormaliseAssetName); -#endif asset = this.ApplyEditors(info, asset); return (T)asset.Data; }); diff --git a/src/SMAPI/Framework/ContentManagerShim.cs b/src/SMAPI/Framework/ContentManagerShim.cs index 8f88fc2d..2791eb78 100644 --- a/src/SMAPI/Framework/ContentManagerShim.cs +++ b/src/SMAPI/Framework/ContentManagerShim.cs @@ -43,14 +43,9 @@ namespace StardewModdingAPI.Framework /// The asset path relative to the loader root directory, not including the .xnb extension. public override T Load(string assetName) { -#if STARDEW_VALLEY_1_3 return this.Load(assetName, LocalizedContentManager.CurrentLanguageCode); -#else - return this.ContentCore.Load(assetName, this); -#endif } -#if STARDEW_VALLEY_1_3 /// Load an asset that has been processed by the content pipeline. /// The type of asset to load. /// The asset path relative to the loader root directory, not including the .xnb extension. @@ -67,7 +62,6 @@ namespace StardewModdingAPI.Framework { return this.Load(assetName, LanguageCode.en); } -#endif /// Inject an asset into the cache. /// The type of asset to inject. @@ -78,13 +72,11 @@ namespace StardewModdingAPI.Framework this.ContentCore.Inject(assetName, value, this); } -#if STARDEW_VALLEY_1_3 /// Create a new content manager for temporary use. public override LocalizedContentManager CreateTemporary() { return this.ContentCore.CreateContentManager("(temporary)"); } -#endif /********* diff --git a/src/SMAPI/Framework/GameVersion.cs b/src/SMAPI/Framework/GameVersion.cs index e5022212..85b2eef6 100644 --- a/src/SMAPI/Framework/GameVersion.cs +++ b/src/SMAPI/Framework/GameVersion.cs @@ -49,10 +49,8 @@ namespace StardewModdingAPI.Framework /// The game version string. private static string GetSemanticVersionString(string gameVersion) { -#if STARDEW_VALLEY_1_3 - if(gameVersion.StartsWith("1.3.0.")) + if (gameVersion.StartsWith("1.3.0.")) return new SemanticVersion(1, 3, 0, "alpha." + gameVersion.Substring("1.3.0.".Length)).ToString(); -#endif return GameVersion.VersionMap.TryGetValue(gameVersion, out string semanticVersion) ? semanticVersion @@ -63,10 +61,8 @@ namespace StardewModdingAPI.Framework /// The semantic version string. private static string GetGameVersionString(string semanticVersion) { - #if STARDEW_VALLEY_1_3 - if(semanticVersion.StartsWith("1.3-alpha.")) + if (semanticVersion.StartsWith("1.3-alpha.")) return "1.3.0." + semanticVersion.Substring("1.3-alpha.".Length); - #endif foreach (var mapping in GameVersion.VersionMap) { diff --git a/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs b/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs index e5bf47f6..648d6742 100644 --- a/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs @@ -107,122 +107,6 @@ namespace StardewModdingAPI.Framework.ModHelpers ); } -#if !STARDEW_VALLEY_1_3 - /**** - ** Obsolete - ****/ - /// Get a private instance field. - /// The field type. - /// The object which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - /// Returns the field wrapper, or null if the field doesn't exist and is false. - [Obsolete] - public IPrivateField GetPrivateField(object obj, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - return (IPrivateField)this.GetField(obj, name, required); - } - - /// Get a private static field. - /// The field type. - /// The type which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - [Obsolete] - public IPrivateField GetPrivateField(Type type, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - return (IPrivateField)this.GetField(type, name, required); - } - - /// Get a private instance property. - /// The property type. - /// The object which has the property. - /// The property name. - /// Whether to throw an exception if the private property is not found. - [Obsolete] - public IPrivateProperty GetPrivateProperty(object obj, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - return (IPrivateProperty)this.GetProperty(obj, name, required); - } - - /// Get a private static property. - /// The property type. - /// The type which has the property. - /// The property name. - /// Whether to throw an exception if the private property is not found. - [Obsolete] - public IPrivateProperty GetPrivateProperty(Type type, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - return (IPrivateProperty)this.GetProperty(type, name, required); - } - - /// Get the value of a private instance field. - /// The field type. - /// The object which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - /// Returns the field value, or the default value for if the field wasn't found and is false. - /// - /// This is a shortcut for followed by . - /// When is false, this will return the default value if reflection fails. If you need to check whether the field exists, use instead. - /// - [Obsolete] - public TValue GetPrivateValue(object obj, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - IPrivateField field = (IPrivateField)this.GetField(obj, name, required); - return field != null - ? field.GetValue() - : default(TValue); - } - - /// Get the value of a private static field. - /// The field type. - /// The type which has the field. - /// The field name. - /// Whether to throw an exception if the private field is not found. - /// Returns the field value, or the default value for if the field wasn't found and is false. - /// - /// This is a shortcut for followed by . - /// When is false, this will return the default value if reflection fails. If you need to check whether the field exists, use instead. - /// - [Obsolete] - public TValue GetPrivateValue(Type type, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - IPrivateField field = (IPrivateField)this.GetField(type, name, required); - return field != null - ? field.GetValue() - : default(TValue); - } - - /// Get a private instance method. - /// The object which has the method. - /// The field name. - /// Whether to throw an exception if the private field is not found. - [Obsolete] - public IPrivateMethod GetPrivateMethod(object obj, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - return (IPrivateMethod)this.GetMethod(obj, name, required); - } - - /// Get a private static method. - /// The type which has the method. - /// The field name. - /// Whether to throw an exception if the private field is not found. - [Obsolete] - public IPrivateMethod GetPrivateMethod(Type type, string name, bool required = true) - { - this.DeprecationManager.Warn($"{nameof(IReflectionHelper)}.GetPrivate*", "2.3", DeprecationLevel.Notice); - return (IPrivateMethod)this.GetMethod(type, name, required); - } -#endif - /********* ** Private methods diff --git a/src/SMAPI/Framework/Reflection/ReflectedField.cs b/src/SMAPI/Framework/Reflection/ReflectedField.cs index fb420dc5..09638b1d 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedField.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedField.cs @@ -6,9 +6,6 @@ namespace StardewModdingAPI.Framework.Reflection /// A field obtained through reflection. /// The field value type. internal class ReflectedField : IReflectedField -#if !STARDEW_VALLEY_1_3 - , IPrivateField -#endif { /********* ** Properties diff --git a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs index 803bc316..7d9072a0 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs @@ -5,9 +5,6 @@ namespace StardewModdingAPI.Framework.Reflection { /// A method obtained through reflection. internal class ReflectedMethod : IReflectedMethod -#if !STARDEW_VALLEY_1_3 - , IPrivateMethod -#endif { /********* ** Properties diff --git a/src/SMAPI/Framework/Reflection/ReflectedProperty.cs b/src/SMAPI/Framework/Reflection/ReflectedProperty.cs index 4f9d4e19..d59b71ac 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedProperty.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedProperty.cs @@ -6,9 +6,6 @@ namespace StardewModdingAPI.Framework.Reflection /// A property obtained through reflection. /// The property value type. internal class ReflectedProperty : IReflectedProperty -#if !STARDEW_VALLEY_1_3 - , IPrivateProperty -#endif { /********* ** Properties diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index c6e9aa92..b486f8cd 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -1,18 +1,14 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Threading; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; -#if STARDEW_VALLEY_1_3 using Netcode; -#endif using StardewModdingAPI.Events; using StardewModdingAPI.Framework.Events; using StardewModdingAPI.Framework.Input; @@ -24,11 +20,7 @@ using StardewValley.Locations; using StardewValley.Menus; using StardewValley.Tools; using xTile.Dimensions; -#if !STARDEW_VALLEY_1_3 -using xTile.Layers; -#else using SFarmer = StardewValley.Farmer; -#endif namespace StardewModdingAPI.Framework { @@ -136,11 +128,6 @@ namespace StardewModdingAPI.Framework /// Whether this is the very first update tick since the game started. private bool FirstUpdate; -#if !STARDEW_VALLEY_1_3 - /// The current game instance. - private static SGame Instance; -#endif - /// A callback to invoke after the game finishes initialising. private readonly Action OnGameInitialised; @@ -150,29 +137,9 @@ namespace StardewModdingAPI.Framework /// Simplifies access to private game code. private static Reflector Reflection; -#if !STARDEW_VALLEY_1_3 // ReSharper disable ArrangeStaticMemberQualifier, ArrangeThisQualifier, InconsistentNaming - /// Used to access private fields and methods. - private static List _fpsList => SGame.Reflection.GetField>(typeof(Game1), nameof(_fpsList)).GetValue(); - private static Stopwatch _fpsStopwatch => SGame.Reflection.GetField(typeof(Game1), nameof(SGame._fpsStopwatch)).GetValue(); - private static float _fps - { - set => SGame.Reflection.GetField(typeof(Game1), nameof(_fps)).SetValue(value); - } - private static Task _newDayTask => SGame.Reflection.GetField(typeof(Game1), nameof(_newDayTask)).GetValue(); - private Color bgColor => SGame.Reflection.GetField(this, nameof(this.bgColor)).GetValue(); - public RenderTarget2D screenWrapper => SGame.Reflection.GetProperty(this, "screen").GetValue(); // deliberately renamed to avoid an infinite loop - public BlendState lightingBlend => SGame.Reflection.GetField(this, nameof(this.lightingBlend)).GetValue(); - private readonly Action drawFarmBuildings = () => SGame.Reflection.GetMethod(SGame.Instance, nameof(drawFarmBuildings)).Invoke(); - private readonly Action drawHUD = () => SGame.Reflection.GetMethod(SGame.Instance, nameof(drawHUD)).Invoke(); - private readonly Action drawDialogueBox = () => SGame.Reflection.GetMethod(SGame.Instance, nameof(drawDialogueBox)).Invoke(); - private readonly Action renderScreenBuffer = () => SGame.Reflection.GetMethod(SGame.Instance, nameof(renderScreenBuffer)).Invoke(); - // ReSharper restore ArrangeStaticMemberQualifier, ArrangeThisQualifier, InconsistentNaming -#endif - -#if STARDEW_VALLEY_1_3 private static StringBuilder _debugStringBuilder => SGame.Reflection.GetField(typeof(Game1), nameof(_debugStringBuilder)).GetValue(); -#endif + // ReSharper restore ArrangeStaticMemberQualifier, ArrangeThisQualifier, InconsistentNaming /********* @@ -199,9 +166,6 @@ namespace StardewModdingAPI.Framework this.Monitor = monitor; this.Events = eventManager; this.FirstUpdate = true; -#if !STARDEW_VALLEY_1_3 - SGame.Instance = this; -#endif SGame.Reflection = reflection; this.OnGameInitialised = onGameInitialised; if (this.ContentCore == null) // shouldn't happen since CreateContentManager is called first, but let's init here just in case @@ -209,13 +173,6 @@ namespace StardewModdingAPI.Framework // set XNA option required by Stardew Valley Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef; - -#if !STARDEW_VALLEY_1_3 - // replace already-created content managers - this.Monitor?.Log("Overriding content manager...", LogLevel.Trace); - this.Content = this.ContentCore.CreateContentManager("SGame.Content"); - reflection.GetField(typeof(Game1), "_temporaryContent").SetValue(this.ContentCore.CreateContentManager("Game1._temporaryContent")); // regenerate value with new content manager -#endif } /**** @@ -262,11 +219,7 @@ namespace StardewModdingAPI.Framework // a small chance that the task will finish after we defer but before the game checks, // which means technically events should be raised, but the effects of missing one // update tick are neglible and not worth the complications of bypassing Game1.Update. -#if STARDEW_VALLEY_1_3 if (Game1._newDayTask != null) -#else - if (SGame._newDayTask != null) -#endif { base.Update(gameTime); this.Events.Specialised_UnvalidatedUpdateTick.Raise(); @@ -553,13 +506,7 @@ namespace StardewModdingAPI.Framework // raise current location's object list changed if (this.GetHash(Game1.currentLocation.objects) != this.PreviousLocationObjects) - this.Events.Location_LocationObjectsChanged.Raise(new EventArgsLocationObjectsChanged( -#if STARDEW_VALLEY_1_3 - Game1.currentLocation.objects.FieldDict -#else - Game1.currentLocation.objects -#endif - )); + this.Events.Location_LocationObjectsChanged.Raise(new EventArgsLocationObjectsChanged(Game1.currentLocation.objects.FieldDict)); // raise time changed if (Game1.timeOfDay != this.PreviousTime) @@ -686,7 +633,6 @@ namespace StardewModdingAPI.Framework [SuppressMessage("ReSharper", "RedundantCast", Justification = "copied from game code as-is")] [SuppressMessage("ReSharper", "RedundantExplicitNullableCreation", Justification = "copied from game code as-is")] [SuppressMessage("ReSharper", "RedundantTypeArgumentsOfMethod", Justification = "copied from game code as-is")] -#if STARDEW_VALLEY_1_3 private void DrawImpl(GameTime gameTime) { if (Game1.debugMode) @@ -1318,659 +1264,6 @@ namespace StardewModdingAPI.Framework } } } -#else - private void DrawImpl(GameTime gameTime) - { - if (Game1.debugMode) - { - if (SGame._fpsStopwatch.IsRunning) - { - float totalSeconds = (float)SGame._fpsStopwatch.Elapsed.TotalSeconds; - SGame._fpsList.Add(totalSeconds); - while (SGame._fpsList.Count >= 120) - SGame._fpsList.RemoveAt(0); - float num = 0.0f; - foreach (float fps in SGame._fpsList) - num += fps; - SGame._fps = (float)(1.0 / ((double)num / (double)SGame._fpsList.Count)); - } - SGame._fpsStopwatch.Restart(); - } - else - { - if (SGame._fpsStopwatch.IsRunning) - SGame._fpsStopwatch.Reset(); - SGame._fps = 0.0f; - SGame._fpsList.Clear(); - } - if (SGame._newDayTask != null) - { - this.GraphicsDevice.Clear(this.bgColor); - //base.Draw(gameTime); - } - else - { - if ((double)Game1.options.zoomLevel != 1.0) - this.GraphicsDevice.SetRenderTarget(this.screenWrapper); - if (this.IsSaving) - { - this.GraphicsDevice.Clear(this.bgColor); - IClickableMenu activeClickableMenu = Game1.activeClickableMenu; - if (activeClickableMenu != null) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - try - { - this.Events.Graphics_OnPreRenderGuiEvent.Raise(); - activeClickableMenu.draw(Game1.spriteBatch); - this.Events.Graphics_OnPostRenderGuiEvent.Raise(); - } - catch (Exception ex) - { - this.Monitor.Log($"The {activeClickableMenu.GetType().FullName} menu crashed while drawing itself during save. SMAPI will force it to exit to avoid crashing the game.\n{ex.GetLogSummary()}", LogLevel.Error); - activeClickableMenu.exitThisMenu(); - } - this.RaisePostRender(); - Game1.spriteBatch.End(); - } - //base.Draw(gameTime); - this.renderScreenBuffer(); - } - else - { - this.GraphicsDevice.Clear(this.bgColor); - if (Game1.activeClickableMenu != null && Game1.options.showMenuBackground && Game1.activeClickableMenu.showWithoutTransparencyIfOptionIsSet()) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - try - { - Game1.activeClickableMenu.drawBackground(Game1.spriteBatch); - this.Events.Graphics_OnPreRenderGuiEvent.Raise(); - Game1.activeClickableMenu.draw(Game1.spriteBatch); - this.Events.Graphics_OnPostRenderGuiEvent.Raise(); - } - catch (Exception ex) - { - this.Monitor.Log($"The {Game1.activeClickableMenu.GetType().FullName} menu crashed while drawing itself. SMAPI will force it to exit to avoid crashing the game.\n{ex.GetLogSummary()}", LogLevel.Error); - Game1.activeClickableMenu.exitThisMenu(); - } - this.RaisePostRender(); - Game1.spriteBatch.End(); - if ((double)Game1.options.zoomLevel != 1.0) - { - this.GraphicsDevice.SetRenderTarget((RenderTarget2D)null); - this.GraphicsDevice.Clear(this.bgColor); - Game1.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone); - Game1.spriteBatch.Draw((Texture2D)this.screenWrapper, Vector2.Zero, new Microsoft.Xna.Framework.Rectangle?(this.screenWrapper.Bounds), Color.White, 0.0f, Vector2.Zero, Game1.options.zoomLevel, SpriteEffects.None, 1f); - Game1.spriteBatch.End(); - } - if (Game1.overlayMenu != null) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - Game1.overlayMenu.draw(Game1.spriteBatch); - Game1.spriteBatch.End(); - } - } - else if ((int)Game1.gameMode == 11) - { - Game1.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - Game1.spriteBatch.DrawString(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3685"), new Vector2(16f, 16f), Color.HotPink); - Game1.spriteBatch.DrawString(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3686"), new Vector2(16f, 32f), new Color(0, (int)byte.MaxValue, 0)); - Game1.spriteBatch.DrawString(Game1.dialogueFont, Game1.parseText(Game1.errorMessage, Game1.dialogueFont, Game1.graphics.GraphicsDevice.Viewport.Width), new Vector2(16f, 48f), Color.White); - this.RaisePostRender(); - Game1.spriteBatch.End(); - } - else if (Game1.currentMinigame != null) - { - Game1.currentMinigame.draw(Game1.spriteBatch); - if (Game1.globalFade && !Game1.menuUp && (!Game1.nameSelectUp || Game1.messagePause)) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - Game1.spriteBatch.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * ((int)Game1.gameMode == 0 ? 1f - Game1.fadeToBlackAlpha : Game1.fadeToBlackAlpha)); - Game1.spriteBatch.End(); - } - this.RaisePostRender(needsNewBatch: true); - if ((double)Game1.options.zoomLevel != 1.0) - { - this.GraphicsDevice.SetRenderTarget((RenderTarget2D)null); - this.GraphicsDevice.Clear(this.bgColor); - Game1.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone); - Game1.spriteBatch.Draw((Texture2D)this.screenWrapper, Vector2.Zero, new Microsoft.Xna.Framework.Rectangle?(this.screenWrapper.Bounds), Color.White, 0.0f, Vector2.Zero, Game1.options.zoomLevel, SpriteEffects.None, 1f); - Game1.spriteBatch.End(); - } - if (Game1.overlayMenu != null) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - Game1.overlayMenu.draw(Game1.spriteBatch); - Game1.spriteBatch.End(); - } - } - else if (Game1.showingEndOfNightStuff) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - if (Game1.activeClickableMenu != null) - { - try - { - this.Events.Graphics_OnPreRenderGuiEvent.Raise(); - Game1.activeClickableMenu.draw(Game1.spriteBatch); - this.Events.Graphics_OnPostRenderGuiEvent.Raise(); - } - catch (Exception ex) - { - this.Monitor.Log($"The {Game1.activeClickableMenu.GetType().FullName} menu crashed while drawing itself during end-of-night-stuff. SMAPI will force it to exit to avoid crashing the game.\n{ex.GetLogSummary()}", LogLevel.Error); - Game1.activeClickableMenu.exitThisMenu(); - } - } - this.RaisePostRender(); - Game1.spriteBatch.End(); - if ((double)Game1.options.zoomLevel != 1.0) - { - this.GraphicsDevice.SetRenderTarget((RenderTarget2D)null); - this.GraphicsDevice.Clear(this.bgColor); - Game1.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone); - Game1.spriteBatch.Draw((Texture2D)this.screenWrapper, Vector2.Zero, new Microsoft.Xna.Framework.Rectangle?(this.screenWrapper.Bounds), Color.White, 0.0f, Vector2.Zero, Game1.options.zoomLevel, SpriteEffects.None, 1f); - Game1.spriteBatch.End(); - } - if (Game1.overlayMenu != null) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - Game1.overlayMenu.draw(Game1.spriteBatch); - Game1.spriteBatch.End(); - } - } - else if ((int)Game1.gameMode == 6) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - string str1 = ""; - for (int index = 0; (double)index < gameTime.TotalGameTime.TotalMilliseconds % 999.0 / 333.0; ++index) - str1 += "."; - string str2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3688"); - string str3 = str1; - string s = str2 + str3; - string str4 = "..."; - string str5 = str2 + str4; - int widthOfString = SpriteText.getWidthOfString(str5); - int height = 64; - int x = 64; - int y = Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - height; - SpriteText.drawString(Game1.spriteBatch, s, x, y, 999999, widthOfString, height, 1f, 0.88f, false, 0, str5, -1); - this.RaisePostRender(); - Game1.spriteBatch.End(); - if ((double)Game1.options.zoomLevel != 1.0) - { - this.GraphicsDevice.SetRenderTarget((RenderTarget2D)null); - this.GraphicsDevice.Clear(this.bgColor); - Game1.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone); - Game1.spriteBatch.Draw((Texture2D)this.screenWrapper, Vector2.Zero, new Microsoft.Xna.Framework.Rectangle?(this.screenWrapper.Bounds), Color.White, 0.0f, Vector2.Zero, Game1.options.zoomLevel, SpriteEffects.None, 1f); - Game1.spriteBatch.End(); - } - if (Game1.overlayMenu != null) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - Game1.overlayMenu.draw(Game1.spriteBatch); - Game1.spriteBatch.End(); - } - } - else - { - Microsoft.Xna.Framework.Rectangle rectangle; - if ((int)Game1.gameMode == 0) - { - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - } - else - { - if (Game1.drawLighting) - { - this.GraphicsDevice.SetRenderTarget(Game1.lightmap); - this.GraphicsDevice.Clear(Color.White * 0.0f); - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - Game1.spriteBatch.Draw(Game1.staminaRect, Game1.lightmap.Bounds, Game1.currentLocation.name.Equals("UndergroundMine") ? Game1.mine.getLightingColor(gameTime) : (Game1.ambientLight.Equals(Color.White) || Game1.isRaining && Game1.currentLocation.isOutdoors ? Game1.outdoorLight : Game1.ambientLight)); - for (int index = 0; index < Game1.currentLightSources.Count; ++index) - { - if (Utility.isOnScreen(Game1.currentLightSources.ElementAt(index).position, (int)((double)Game1.currentLightSources.ElementAt(index).radius * (double)Game1.tileSize * 4.0))) - Game1.spriteBatch.Draw(Game1.currentLightSources.ElementAt(index).lightTexture, Game1.GlobalToLocal(Game1.viewport, Game1.currentLightSources.ElementAt(index).position) / (float)(Game1.options.lightingQuality / 2), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLightSources.ElementAt(index).lightTexture.Bounds), Game1.currentLightSources.ElementAt(index).color, 0.0f, new Vector2((float)Game1.currentLightSources.ElementAt(index).lightTexture.Bounds.Center.X, (float)Game1.currentLightSources.ElementAt(index).lightTexture.Bounds.Center.Y), Game1.currentLightSources.ElementAt(index).radius / (float)(Game1.options.lightingQuality / 2), SpriteEffects.None, 0.9f); - } - Game1.spriteBatch.End(); - this.GraphicsDevice.SetRenderTarget((double)Game1.options.zoomLevel == 1.0 ? (RenderTarget2D)null : this.screenWrapper); - } - if (Game1.bloomDay && Game1.bloom != null) - Game1.bloom.BeginDraw(); - this.GraphicsDevice.Clear(this.bgColor); - Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); - this.Events.Graphics_OnPreRenderEvent.Raise(); - if (Game1.background != null) - Game1.background.draw(Game1.spriteBatch); - Game1.mapDisplayDevice.BeginScene(Game1.spriteBatch); - Game1.currentLocation.Map.GetLayer("Back").Draw(Game1.mapDisplayDevice, Game1.viewport, Location.Origin, false, Game1.pixelZoom); - Game1.currentLocation.drawWater(Game1.spriteBatch); - if (Game1.CurrentEvent == null) - { - foreach (NPC character in Game1.currentLocation.characters) - { - if (!character.swimming