From 5bcef15c5a4bd7eb6f5f3e72539dbee6a468f052 Mon Sep 17 00:00:00 2001
From: Sweet Panda <76555779+RealSweetPanda@users.noreply.github.com>
Date: Sat, 29 Apr 2023 20:59:58 +0300
Subject: [PATCH] fixed schedules starting at default locations (#10)
fixed npc start at default locations after reload
code cleanup
bump version to 3.2.0
fixed update keys
---
Framework/IGenericModConfigMenuApi.cs | 29 +-
Framework/ModConfig.cs | 8 +-
Framework/Model/BuffData.cs | 3 +-
Framework/Model/PlayerData.cs | 18 +-
Framework/Model/PositionData.cs | 3 +-
Framework/NPCExtensions.cs | 97 +++
Framework/NewSaveGameMenuV2.cs | 186 +++---
Framework/NewShippingMenuV2.cs | 882 +++++++++++++++-----------
Framework/SaveAnywhereAPI.cs | 58 +-
Framework/SaveManager.cs | 270 ++++----
README.md | 9 +-
SaveAnywhere.cs | 118 ++--
SaveAnywhere.csproj | 2 +-
manifest.json | 9 +-
14 files changed, 1012 insertions(+), 680 deletions(-)
create mode 100644 Framework/NPCExtensions.cs
diff --git a/Framework/IGenericModConfigMenuApi.cs b/Framework/IGenericModConfigMenuApi.cs
index 0369c19..6eba71a 100644
--- a/Framework/IGenericModConfigMenuApi.cs
+++ b/Framework/IGenericModConfigMenuApi.cs
@@ -1,9 +1,5 @@
using System;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
-using StardewModdingAPI.Utilities;
-using StardewValley;
namespace GenericModConfigMenu
{
@@ -21,7 +17,10 @@ public interface IGenericModConfigMenuApi
/// Reset the mod's config to its default values.
/// Save the mod's current config to the config.json file.
/// Whether the options can only be edited from the title screen.
- /// Each mod can only be registered once, unless it's deleted via before calling this again.
+ ///
+ /// Each mod can only be registered once, unless it's deleted via before calling this
+ /// again.
+ ///
void Register(IManifest mod, Action reset, Action save, bool titleScreenOnly = false);
@@ -31,7 +30,10 @@ public interface IGenericModConfigMenuApi
/// Add a section title at the current position in the form.
/// The mod's manifest.
/// The title text shown in the form.
- /// The tooltip text shown when the cursor hovers on the title, or null to disable the tooltip.
+ ///
+ /// The tooltip text shown when the cursor hovers on the title, or null to disable the
+ /// tooltip.
+ ///
void AddSectionTitle(IManifest mod, Func text, Func tooltip = null);
/// Add a paragraph of text at the current position in the form.
@@ -97,9 +99,16 @@ public interface IGenericModConfigMenuApi
/// Get the current value from the mod config.
/// Set a new value in the mod config.
/// The label text to show in the form.
- /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip.
- /// The unique field ID for use with , or null to auto-generate a randomized ID.
- void AddKeybind(IManifest mod, Func getValue, Action setValue, Func name, Func tooltip = null, string fieldId = null);
+ ///
+ /// The tooltip text shown when the cursor hovers on the field, or null to disable the
+ /// tooltip.
+ ///
+ ///
+ /// The unique field ID for use with , or null to auto-generate a
+ /// randomized ID.
+ ///
+ void AddKeybind(IManifest mod, Func getValue, Action setValue, Func name,
+ Func tooltip = null, string fieldId = null);
/// Add a key binding list at the current position in the form.
/// The mod's manifest.
@@ -174,4 +183,4 @@ public interface IGenericModConfigMenuApi
/// The mod's manifest.
//void Unregister(IManifest mod);
}
-}
+}
\ No newline at end of file
diff --git a/Framework/ModConfig.cs b/Framework/ModConfig.cs
index f78e970..d659575 100644
--- a/Framework/ModConfig.cs
+++ b/Framework/ModConfig.cs
@@ -1,7 +1,9 @@
using StardewModdingAPI;
-namespace SaveAnywhere.Framework {
- internal class ModConfig {
- public SButton SaveKey { get; set; } = (SButton) 75;
+namespace SaveAnywhere.Framework
+{
+ internal class ModConfig
+ {
+ public SButton SaveKey { get; set; } = (SButton)75;
}
}
\ No newline at end of file
diff --git a/Framework/Model/BuffData.cs b/Framework/Model/BuffData.cs
index e7d3387..301b6f3 100644
--- a/Framework/Model/BuffData.cs
+++ b/Framework/Model/BuffData.cs
@@ -1,4 +1,5 @@
-namespace SaveAnywhere.Framework.Model {
+namespace SaveAnywhere.Framework.Model
+{
public sealed record BuffData(
string DisplaySource,
string Source,
diff --git a/Framework/Model/PlayerData.cs b/Framework/Model/PlayerData.cs
index e19fc35..b35e528 100644
--- a/Framework/Model/PlayerData.cs
+++ b/Framework/Model/PlayerData.cs
@@ -1,12 +1,14 @@
-namespace SaveAnywhere.Framework.Model {
- public class PlayerData {
+namespace SaveAnywhere.Framework.Model
+{
+ public class PlayerData
+ {
public int Time { get; init; }
- public BuffData[] otherBuffs { get; init; }
-
- public BuffData drinkBuff { get; init; }
-
- public BuffData foodBuff { get; init; }
- public PositionData Position { get; init; }
+ public BuffData[] OtherBuffs { get; init; }
+
+ public BuffData DrinkBuff { get; init; }
+
+ public BuffData FoodBuff { get; init; }
+ public PositionData[] Position { get; init; }
public bool IsCharacterSwimming { get; init; }
}
diff --git a/Framework/Model/PositionData.cs b/Framework/Model/PositionData.cs
index 319e7dc..7b3cb78 100644
--- a/Framework/Model/PositionData.cs
+++ b/Framework/Model/PositionData.cs
@@ -1,4 +1,5 @@
-namespace SaveAnywhere.Framework.Model {
+namespace SaveAnywhere.Framework.Model
+{
public sealed record PositionData(
string Name,
string Map,
diff --git a/Framework/NPCExtensions.cs b/Framework/NPCExtensions.cs
new file mode 100644
index 0000000..cd9cf5a
--- /dev/null
+++ b/Framework/NPCExtensions.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Microsoft.Xna.Framework;
+using Netcode;
+using StardewValley;
+
+namespace SaveAnywhere.Framework
+{
+ public static class NpcExtensions
+ {
+
+ public static SchedulePathDescription pathfindToNextScheduleLocation(this NPC npc,
+ string startingLocation,
+ int startingX,
+ int startingY,
+ string endingLocation,
+ int endingX,
+ int endingY,
+ int finalFacingDirection,
+ string endBehavior,
+ string endMessage)
+ {
+ var pointStack = new Stack();
+ var startPoint = new Point(startingX, startingY);
+ var stringList = !startingLocation.Equals(endingLocation, StringComparison.Ordinal)
+ ? npc.getLocationRoute(startingLocation, endingLocation)
+ : null;
+ if (stringList != null)
+ {
+ for (var index = 0; index < stringList.Count; ++index)
+ {
+ var locationFromName = Game1.getLocationFromName(stringList[index]);
+ if (locationFromName.Name.Equals("Trailer") &&
+ Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade"))
+ locationFromName = Game1.getLocationFromName("Trailer_Big");
+ if (index < stringList.Count - 1)
+ {
+ var warpPointTo = locationFromName.getWarpPointTo(stringList[index + 1]);
+ if (warpPointTo.Equals(Point.Zero) || startPoint.Equals(Point.Zero))
+ throw new Exception("schedule pathing tried to find a warp point that doesn't exist.");
+ pointStack = addToStackForSchedule(pointStack,
+ PathFindController.findPathForNPCSchedules(startPoint, warpPointTo, locationFromName,
+ 30000));
+ startPoint = locationFromName.getWarpPointTarget(warpPointTo, npc);
+ }
+ else
+ {
+ pointStack = addToStackForSchedule(pointStack,
+ PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY),
+ locationFromName, 30000));
+ }
+ }
+ }
+ else if (startingLocation.Equals(endingLocation, StringComparison.Ordinal))
+ {
+ var locationFromName = Game1.getLocationFromName(startingLocation);
+ if (locationFromName.Name.Equals("Trailer") &&
+ Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade"))
+ locationFromName = Game1.getLocationFromName("Trailer_Big");
+ pointStack = PathFindController.findPathForNPCSchedules(startPoint, new Point(endingX, endingY),
+ locationFromName, 30000);
+ }
+
+ return new SchedulePathDescription(pointStack, finalFacingDirection, endBehavior, endMessage);
+ }
+
+ private static List getLocationRoute(this NPC npc, string startingLocation, string endingLocation)
+ {
+ var field = typeof(NPC)
+ .GetField("routesFromLocationToLocation",
+ BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Default | BindingFlags.Instance);
+ //get routesFromLocationToLocation field from fields and get its value
+ var routes = (List>)field.GetValue(null);
+ foreach (var source in routes)
+ if (source.First().Equals(startingLocation, StringComparison.Ordinal) &&
+ source.Last().Equals(endingLocation, StringComparison.Ordinal) &&
+ ((int)(NetFieldBase)npc.gender == 0 ||
+ !source.Contains("BathHouse_MensLocker", StringComparer.Ordinal)) &&
+ ((int)(NetFieldBase)npc.gender != 0 ||
+ !source.Contains("BathHouse_WomensLocker", StringComparer.Ordinal)))
+ return source;
+ return null;
+ }
+
+ private static Stack addToStackForSchedule(Stack original, Stack toAdd)
+ {
+ if (toAdd == null)
+ return original;
+ original = new Stack(original);
+ while (original.Count > 0)
+ toAdd.Push(original.Pop());
+ return toAdd;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Framework/NewSaveGameMenuV2.cs b/Framework/NewSaveGameMenuV2.cs
index ddbfdb7..668fb94 100644
--- a/Framework/NewSaveGameMenuV2.cs
+++ b/Framework/NewSaveGameMenuV2.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -10,38 +9,43 @@
using StardewValley.BellsAndWhistles;
using StardewValley.Menus;
-namespace SaveAnywhere.Framework {
- public class NewSaveGameMenuV2 : IClickableMenu {
+namespace SaveAnywhere.Framework
+{
+ public class NewSaveGameMenuV2 : IClickableMenu
+ {
+ private readonly StringBuilder _stringBuilder = new();
+ private readonly SparklingText _saveText;
private int _ellipsisCount;
private float _ellipsisDelay = 0.5f;
- protected bool _hasSentFarmhandData;
- private readonly StringBuilder _stringBuilder = new();
- private int completePause = -1;
- public bool hasDrawn;
- private IEnumerator loader;
- private int margin = 500;
- public Multiplayer multiplayer;
- public bool quit;
- private readonly SparklingText saveText;
- private Stopwatch stopwatch;
+ private bool _hasSentFarmhandData;
+ private int _completePause = -1;
+ private bool _hasDrawn;
+ private IEnumerator _loader;
+ private int _margin = 500;
+ public Multiplayer Multiplayer;
+ private bool _quit;
- public NewSaveGameMenuV2() {
- saveText = new SparklingText(Game1.dialogueFont,
+ public NewSaveGameMenuV2()
+ {
+ _saveText = new SparklingText(Game1.dialogueFont,
Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11378"), Color.LimeGreen,
Color.Black * 0.001F, false, 0.1, 1500, 32);
_hasSentFarmhandData = false;
- multiplayer = (Multiplayer) typeof(Game1)
- .GetField(nameof(multiplayer), BindingFlags.Static | BindingFlags.NonPublic).GetValue(Program.gamePtr);
+ Multiplayer = (Multiplayer)typeof(Game1)
+ .GetField(nameof(Multiplayer), BindingFlags.Static | BindingFlags.NonPublic).GetValue(Program.gamePtr);
}
public event EventHandler SaveComplete;
- public override void receiveRightClick(int x, int y, bool playSound = true) { }
+ public override void receiveRightClick(int x, int y, bool playSound = true)
+ {
+ }
- public void complete() {
+ private void complete()
+ {
Game1.playSound("money");
- completePause = 1500;
- loader = null;
+ _completePause = 1500;
+ _loader = null;
Game1.game1.IsSaving = false;
if (!Game1.IsMasterGame || Game1.newDaySync == null || Game1.newDaySync.hasSaved())
return;
@@ -49,122 +53,149 @@ public void complete() {
SaveComplete(this, EventArgs.Empty);
}
- public override bool readyToClose() {
+ public override bool readyToClose()
+ {
return false;
}
- public override void update(GameTime time) {
- if (quit) {
+ public override void update(GameTime time)
+ {
+ if (_quit)
+ {
if (!Game1.activeClickableMenu.Equals(this) || !Game1.PollForEndOfNewDaySync())
return;
Game1.exitActiveMenu();
}
- else {
+ else
+ {
base.update(time);
- if (Game1.client != null && Game1.client.timedOut) {
- quit = true;
+ if (Game1.client is { timedOut: true })
+ {
+ _quit = true;
if (!Game1.activeClickableMenu.Equals(this))
return;
Game1.exitActiveMenu();
}
- else {
- _ellipsisDelay -= (float) time.ElapsedGameTime.TotalSeconds;
- if (_ellipsisDelay <= 0.0) {
+ else
+ {
+ _ellipsisDelay -= (float)time.ElapsedGameTime.TotalSeconds;
+ if (_ellipsisDelay <= 0.0)
+ {
_ellipsisDelay += 0.75f;
++_ellipsisCount;
if (_ellipsisCount > 3)
_ellipsisCount = 1;
}
- if (loader != null) {
- loader.MoveNext();
- if (loader.Current >= 100) {
- margin -= time.ElapsedGameTime.Milliseconds;
- if (margin <= 0)
+ if (_loader != null)
+ {
+ _loader.MoveNext();
+ if (_loader.Current >= 100)
+ {
+ _margin -= time.ElapsedGameTime.Milliseconds;
+ if (_margin <= 0)
complete();
}
}
- else if (hasDrawn && completePause == -1) {
- if (Game1.IsMasterGame) {
- if (Game1.saveOnNewDay) {
+ else if (_hasDrawn && _completePause == -1)
+ {
+ if (Game1.IsMasterGame)
+ {
+ if (Game1.saveOnNewDay)
+ {
Game1.player.team.endOfNightStatus.UpdateState("ready");
- if (Game1.newDaySync != null) {
- if (Game1.newDaySync.readyForSave()) {
- multiplayer.saveFarmhands();
+ if (Game1.newDaySync != null)
+ {
+ if (Game1.newDaySync.readyForSave())
+ {
+ Multiplayer.saveFarmhands();
Game1.game1.IsSaving = true;
- loader = SaveGame.Save();
-
+ _loader = SaveGame.Save();
}
}
- else {
- multiplayer.saveFarmhands();
+ else
+ {
+ Multiplayer.saveFarmhands();
Game1.game1.IsSaving = true;
- loader = SaveGame.Save();
+ _loader = SaveGame.Save();
}
}
- else {
- margin = -1;
- if (Game1.newDaySync != null) {
- if (Game1.newDaySync.readyForSave()) {
+ else
+ {
+ _margin = -1;
+ if (Game1.newDaySync != null)
+ {
+ if (Game1.newDaySync.readyForSave())
+ {
Game1.game1.IsSaving = true;
complete();
}
}
- else {
+ else
+ {
complete();
}
}
}
- else {
- if (!_hasSentFarmhandData) {
+ else
+ {
+ if (!_hasSentFarmhandData)
+ {
_hasSentFarmhandData = true;
- multiplayer.sendFarmhand();
+ Multiplayer.sendFarmhand();
}
- multiplayer.UpdateLate();
- multiplayer.UpdateEarly();
+ Multiplayer.UpdateLate();
+ Multiplayer.UpdateEarly();
if (Game1.newDaySync != null)
Game1.newDaySync.readyForSave();
Game1.player.team.endOfNightStatus.UpdateState("ready");
- if (Game1.newDaySync != null) {
+ if (Game1.newDaySync != null)
+ {
if (Game1.newDaySync.hasSaved())
complete();
}
- else {
+ else
+ {
complete();
}
}
}
- if (completePause < 0)
+ if (_completePause < 0)
return;
- completePause -= time.ElapsedGameTime.Milliseconds;
- saveText.update(time);
- if (completePause >= 0)
+ _completePause -= time.ElapsedGameTime.Milliseconds;
+ _saveText.update(time);
+ if (_completePause >= 0)
return;
- quit = true;
- completePause = -9999;
+ _quit = true;
+ _completePause = -9999;
}
}
}
- public static void saveClientOptions() {
+ public static void saveClientOptions()
+ {
var startupPreferences = new StartupPreferences();
startupPreferences.loadPreferences(false, true);
startupPreferences.clientOptions = Game1.options;
startupPreferences.savePreferences(false);
}
- public override void draw(SpriteBatch b) {
+ public override void draw(SpriteBatch b)
+ {
base.draw(b);
var vector2 = Utility.makeSafe(new Vector2(64f, Game1.viewport.Height - 64), new Vector2(64f, 64f));
var flag = false;
- if (completePause >= 0) {
+ if (_completePause >= 0)
+ {
if (Game1.saveOnNewDay)
- saveText.draw(b, vector2);
+ _saveText.draw(b, vector2);
}
- else if (margin < 0 || Game1.IsClient) {
- if (Game1.IsMultiplayer) {
+ else if (_margin < 0 || Game1.IsClient)
+ {
+ if (Game1.IsMultiplayer)
+ {
_stringBuilder.Clear();
_stringBuilder.Append(Game1.content.LoadString("Strings\\UI:ReadyCheck",
Game1.newDaySync.numReadyForSave(), Game1.getOnlineFarmers().Count()));
@@ -174,14 +205,16 @@ public override void draw(SpriteBatch b) {
flag = true;
}
}
- else if (!Game1.IsMultiplayer) {
+ else if (!Game1.IsMultiplayer)
+ {
_stringBuilder.Clear();
_stringBuilder.Append(Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11381"));
for (var index = 0; index < _ellipsisCount; ++index)
_stringBuilder.Append(".");
b.DrawString(Game1.dialogueFont, _stringBuilder, vector2, Color.White);
}
- else {
+ else
+ {
_stringBuilder.Clear();
_stringBuilder.Append(Game1.content.LoadString("Strings\\UI:ReadyCheck",
Game1.newDaySync.numReadyForSave(), Game1.getOnlineFarmers().Count()));
@@ -191,17 +224,18 @@ public override void draw(SpriteBatch b) {
flag = true;
}
- if (completePause > 0)
+ if (_completePause > 0)
flag = false;
if (Game1.newDaySync != null && Game1.newDaySync.hasSaved())
flag = false;
if (Game1.IsMultiplayer & flag && Game1.options.showMPEndOfNightReadyStatus)
Game1.player.team.endOfNightStatus.Draw(b, vector2 + new Vector2(0.0f, -32f), 4f, 0.99f, 0,
- (PlayerStatusList.VerticalAlignment) 1);
- hasDrawn = true;
+ (PlayerStatusList.VerticalAlignment)1);
+ _hasDrawn = true;
}
- public void Dispose() {
+ public void Dispose()
+ {
Game1.game1.IsSaving = false;
}
}
diff --git a/Framework/NewShippingMenuV2.cs b/Framework/NewShippingMenuV2.cs
index 0f8f87d..a01c319 100644
--- a/Framework/NewShippingMenuV2.cs
+++ b/Framework/NewShippingMenuV2.cs
@@ -3,103 +3,109 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
-using StardewModdingAPI;
using StardewValley;
using StardewValley.BellsAndWhistles;
using StardewValley.Menus;
using Object = StardewValley.Object;
-namespace SaveAnywhere.Framework {
- public class NewShippingMenuV2 : IClickableMenu {
- public const int region_okbutton = 101;
- public const int region_forwardButton = 102;
- public const int region_backButton = 103;
- public const int farming_category = 0;
- public const int foraging_category = 1;
- public const int fishing_category = 2;
- public const int mining_category = 3;
- public const int other_category = 4;
- public const int total_category = 5;
- public const int timePerIntroCategory = 500;
- public const int outroFadeTime = 800;
- public const int smokeRate = 100;
- public const int categorylabelHeight = 25;
- protected bool _hasFinished;
- public List animations = new();
- public ClickableTextureComponent backButton;
- public List categories = new();
- private readonly List categoryDials = new();
- private readonly List> categoryItems = new();
- private readonly int categoryLabelsWidth;
- private readonly List categoryTotals = new();
- private int centerX;
- private int centerY;
- public int currentPage = -1;
- public int currentTab;
- private int dayPlaqueY;
- private int finalOutroTimer;
- public ClickableTextureComponent forwardButton;
- private int introTimer = 3500;
- private readonly int itemAndPlusButtonWidth;
- private readonly int itemSlotWidth;
- public int itemsPerCategoryPage = 9;
- private readonly Dictionary- itemValues = new();
- private int moonShake = -1;
- private bool newDayPlaque;
- public ClickableTextureComponent okButton;
- private bool outro;
- private int outroFadeTimer;
- private int outroPauseBeforeDateChange;
- private readonly int plusButtonWidth;
- private bool savedYet;
- private int smokeTimer;
- private int timesPokedMoon;
- private readonly int totalWidth;
- private float weatherX;
-
-
-
- public NewShippingMenuV2(IList
- items) : base(0, 0, Game1.viewport.Width, Game1.viewport.Height) {
+namespace SaveAnywhere.Framework
+{
+ public class NewShippingMenuV2 : IClickableMenu
+ {
+ public const int RegionOkbutton = 101;
+ public const int RegionForwardButton = 102;
+ public const int RegionBackButton = 103;
+ public const int FarmingCategory = 0;
+ public const int ForagingCategory = 1;
+ public const int FishingCategory = 2;
+ public const int MiningCategory = 3;
+ public const int OtherCategory = 4;
+ public const int TotalCategory = 5;
+ public const int TimePerIntroCategory = 500;
+ public const int OutroFadeTime = 800;
+ public const int SmokeRate = 100;
+ public const int CategorylabelHeight = 25;
+ private readonly List _categoryDials = new();
+ private readonly List
> _categoryItems = new();
+ private readonly int _categoryLabelsWidth;
+ private readonly List _categoryTotals = new();
+ private readonly int _itemAndPlusButtonWidth;
+ private readonly int _itemSlotWidth;
+ private readonly Dictionary- _itemValues = new();
+ private readonly int _plusButtonWidth;
+ private readonly int _totalWidth;
+ private bool _hasFinished;
+ private readonly List _animations = new();
+ private readonly ClickableTextureComponent _backButton;
+ private readonly List _categories = new();
+ private int _centerX;
+ private int _centerY;
+ private int _currentPage = -1;
+ private int _currentTab;
+ private int _dayPlaqueY;
+ private int _finalOutroTimer;
+ private readonly ClickableTextureComponent _forwardButton;
+ private int _introTimer = 3500;
+ private int _itemsPerCategoryPage = 9;
+ private int _moonShake = -1;
+ private readonly ClickableTextureComponent _okButton;
+ private bool _outro;
+ private int _outroFadeTimer;
+ private int _outroPauseBeforeDateChange;
+ private bool _savedYet;
+ private int _smokeTimer;
+ private int _timesPokedMoon;
+ private float _weatherX;
+
+
+ public NewShippingMenuV2(IList
- items) : base(0, 0, Game1.viewport.Width, Game1.viewport.Height)
+ {
Game1.player.team.endOfNightStatus.UpdateState("shipment");
parseItems(items);
if (!Game1.wasRainingYesterday)
Game1.changeMusicTrack(Game1.currentSeason.Equals("summer") ? "nightTime" : "none");
- categoryLabelsWidth = 512;
- plusButtonWidth = 40;
- itemSlotWidth = 96;
- itemAndPlusButtonWidth = plusButtonWidth + itemSlotWidth + 8;
- totalWidth = categoryLabelsWidth + itemAndPlusButtonWidth;
- centerX = Game1.viewport.Width / 2;
- centerY = Game1.viewport.Height / 2;
+ _categoryLabelsWidth = 512;
+ _plusButtonWidth = 40;
+ _itemSlotWidth = 96;
+ _itemAndPlusButtonWidth = _plusButtonWidth + _itemSlotWidth + 8;
+ _totalWidth = _categoryLabelsWidth + _itemAndPlusButtonWidth;
+ _centerX = Game1.viewport.Width / 2;
+ _centerY = Game1.viewport.Height / 2;
_hasFinished = false;
- outro = true;
+ _outro = true;
var num = -1;
- for (var index = 0; index < 6; ++index) {
- var categories = this.categories;
+ for (var index = 0; index < 6; ++index)
+ {
+ var categories = this._categories;
var textureComponent = new ClickableTextureComponent("",
- new Rectangle(centerX + totalWidth / 2 - plusButtonWidth, centerY - 300 + index * 27 * 4,
- plusButtonWidth, 44), "", getCategoryName(index), Game1.mouseCursors,
- new Rectangle(392, 361, 10, 11), 4f);
- textureComponent.visible = index < 5 && categoryItems[index].Count > 0;
- textureComponent.myID = index;
- textureComponent.downNeighborID = index < 4 ? index + 1 : 101;
- textureComponent.upNeighborID = index > 0 ? num : -1;
- textureComponent.upNeighborImmutable = true;
+ new Rectangle(_centerX + _totalWidth / 2 - _plusButtonWidth, _centerY - 300 + index * 27 * 4,
+ _plusButtonWidth, 44), "", getCategoryName(index), Game1.mouseCursors,
+ new Rectangle(392, 361, 10, 11), 4f)
+ {
+ visible = index < 5 && _categoryItems[index].Count > 0,
+ myID = index,
+ downNeighborID = index < 4 ? index + 1 : 101,
+ upNeighborID = index > 0 ? num : -1,
+ upNeighborImmutable = true
+ };
categories.Add(textureComponent);
- num = index >= 5 || categoryItems[index].Count <= 0 ? num : index;
+ num = index >= 5 || _categoryItems[index].Count <= 0 ? num : index;
}
- dayPlaqueY = this.categories[0].bounds.Y - 128;
- var rectangle = new Rectangle(centerX + totalWidth / 2 - itemAndPlusButtonWidth + 32, centerY + 300 - 64,
+ _dayPlaqueY = this._categories[0].bounds.Y - 128;
+ var rectangle = new Rectangle(_centerX + _totalWidth / 2 - _itemAndPlusButtonWidth + 32, _centerY + 300 - 64,
64, 64);
var textureComponent1 = new ClickableTextureComponent(
Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11382"), rectangle, null,
Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11382"), Game1.mouseCursors,
- new Rectangle(128, 256, 64, 64), 1f);
- textureComponent1.myID = 101;
- textureComponent1.upNeighborID = num;
- okButton = textureComponent1;
- if (Game1.options.gamepadControls) {
+ new Rectangle(128, 256, 64, 64), 1f)
+ {
+ myID = 101,
+ upNeighborID = num
+ };
+ _okButton = textureComponent1;
+ if (Game1.options.gamepadControls)
+ {
Mouse.SetPosition(rectangle.Center.X, rectangle.Center.Y);
Game1.InvalidateOldMouseMovement();
Game1.lastCursorMotionWasMouse = false;
@@ -107,20 +113,25 @@ public NewShippingMenuV2(IList
- items) : base(0, 0, Game1.viewport.Width, G
var textureComponent2 = new ClickableTextureComponent("",
new Rectangle(xPositionOnScreen + 32, yPositionOnScreen + height - 64, 48, 44), null, "",
- Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f);
- textureComponent2.myID = 103;
- textureComponent2.rightNeighborID = -7777;
- backButton = textureComponent2;
+ Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f)
+ {
+ myID = 103,
+ rightNeighborID = -7777
+ };
+ _backButton = textureComponent2;
var textureComponent3 = new ClickableTextureComponent("",
new Rectangle(xPositionOnScreen + width - 32 - 48, yPositionOnScreen + height - 64, 48, 44), null, "",
- Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f);
- textureComponent3.myID = 102;
- textureComponent3.leftNeighborID = 103;
- forwardButton = textureComponent3;
+ Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f)
+ {
+ myID = 102,
+ leftNeighborID = 103
+ };
+ _forwardButton = textureComponent3;
if (Game1.dayOfMonth == 25 && Game1.currentSeason.Equals("winter"))
- animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(640, 800, 32, 16),
+ _animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(640, 800, 32, 16),
80f, 2, 1000, new Vector2(Game1.viewport.Width, Game1.random.Next(0, 200)), false, false, 0.01f,
- 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, true) {
+ 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, true)
+ {
motion = new Vector2(-4f, 0.0f),
delayBeforeAnimationStart = 3000
});
@@ -134,78 +145,83 @@ public NewShippingMenuV2(IList
- items) : base(0, 0, Game1.viewport.Width, G
base.snapToDefaultClickableComponent();
}
- public void RepositionItems() {
- centerX = Game1.viewport.Width / 2;
- centerY = Game1.viewport.Height / 2;
+ private void RepositionItems()
+ {
+ _centerX = Game1.viewport.Width / 2;
+ _centerY = Game1.viewport.Height / 2;
for (var index = 0; index < 6; ++index)
- categories[index].bounds = new Rectangle(centerX + totalWidth / 2 - plusButtonWidth,
- centerY - 300 + index * 27 * 4, plusButtonWidth, 44);
- dayPlaqueY = categories[0].bounds.Y - 128;
- if (dayPlaqueY < 0)
- dayPlaqueY = -64;
- backButton.bounds.X = xPositionOnScreen + 32;
- backButton.bounds.Y = yPositionOnScreen + height - 64;
- forwardButton.bounds.X = xPositionOnScreen + width - 32 - 48;
- forwardButton.bounds.Y = yPositionOnScreen + height - 64;
- okButton.bounds = new Rectangle(centerX + totalWidth / 2 - itemAndPlusButtonWidth + 32, centerY + 300 - 64,
+ _categories[index].bounds = new Rectangle(_centerX + _totalWidth / 2 - _plusButtonWidth,
+ _centerY - 300 + index * 27 * 4, _plusButtonWidth, 44);
+ _dayPlaqueY = _categories[0].bounds.Y - 128;
+ if (_dayPlaqueY < 0)
+ _dayPlaqueY = -64;
+ _backButton.bounds.X = xPositionOnScreen + 32;
+ _backButton.bounds.Y = yPositionOnScreen + height - 64;
+ _forwardButton.bounds.X = xPositionOnScreen + width - 32 - 48;
+ _forwardButton.bounds.Y = yPositionOnScreen + height - 64;
+ _okButton.bounds = new Rectangle(_centerX + _totalWidth / 2 - _itemAndPlusButtonWidth + 32, _centerY + 300 - 64,
64, 64);
- itemsPerCategoryPage = (int) ((yPositionOnScreen + height - 64 - (yPositionOnScreen + 32)) / 68.0);
- if (currentPage < 0)
+ _itemsPerCategoryPage = (int)((yPositionOnScreen + height - 64 - (yPositionOnScreen + 32)) / 68.0);
+ if (_currentPage < 0)
return;
- currentTab = Utility.Clamp(currentTab, 0, (categoryItems[currentPage].Count - 1) / itemsPerCategoryPage);
+ _currentTab = Utility.Clamp(_currentTab, 0, (_categoryItems[_currentPage].Count - 1) / _itemsPerCategoryPage);
}
- protected override void customSnapBehavior(int direction, int oldRegion, int oldID) {
- if (oldID != 103 || direction != 1 || !showForwardButton())
+ protected override void customSnapBehavior(int direction, int oldRegion, int oldId)
+ {
+ if (oldId != 103 || direction != 1 || !showForwardButton())
return;
currentlySnappedComponent = getComponentWithID(102);
snapCursorToCurrentSnappedComponent();
}
- public override void snapToDefaultClickableComponent() {
- if (currentPage != -1)
- currentlySnappedComponent = getComponentWithID(103);
- else
- currentlySnappedComponent = getComponentWithID(101);
+ public override void snapToDefaultClickableComponent()
+ {
+ currentlySnappedComponent = getComponentWithID(_currentPage != -1 ? 103 : 101);
snapCursorToCurrentSnappedComponent();
}
- public void parseItems(IList
- items) {
+ private void parseItems(IList
- items)
+ {
Utility.consolidateStacks(items);
- for (var index = 0; index < 6; ++index) {
- categoryItems.Add(new List
- ());
- categoryTotals.Add(0);
- categoryDials.Add(new MoneyDial(7, index == 5));
+ for (var index = 0; index < 6; ++index)
+ {
+ _categoryItems.Add(new List
- ());
+ _categoryTotals.Add(0);
+ _categoryDials.Add(new MoneyDial(7, index == 5));
}
foreach (var key in items)
- if (key is Object) {
- var o = key as Object;
- var categoryIndexForObject = getCategoryIndexForObject(o);
- categoryItems[categoryIndexForObject].Add(o);
- var num = o.sellToStorePrice() * o.Stack;
- categoryTotals[categoryIndexForObject] += num;
- itemValues[key] = num;
- Game1.stats.itemsShipped += (uint) o.Stack;
- if (o.Category == -75 || o.Category == -79)
- Game1.stats.CropsShipped += (uint) o.Stack;
- if (o.countsForShippedCollection())
- Game1.player.shippedBasic(o.ParentSheetIndex, o.Stack);
+ if (key is Object obj)
+ {
+ var categoryIndexForObject = getCategoryIndexForObject(obj);
+ _categoryItems[categoryIndexForObject].Add(obj);
+ var num = obj.sellToStorePrice() * obj.Stack;
+ _categoryTotals[categoryIndexForObject] += num;
+ _itemValues[obj] = num;
+ Game1.stats.itemsShipped += (uint)obj.Stack;
+ if (obj.Category == -75 || obj.Category == -79)
+ Game1.stats.CropsShipped += (uint)obj.Stack;
+ if (obj.countsForShippedCollection())
+ Game1.player.shippedBasic(obj.ParentSheetIndex, obj.Stack);
}
- for (var index = 0; index < 5; ++index) {
- categoryTotals[5] += categoryTotals[index];
- categoryItems[5].AddRange(categoryItems[index]);
- categoryDials[index].currentValue = categoryTotals[index];
- categoryDials[index].previousTargetValue = categoryDials[index].currentValue;
+ for (var index = 0; index < 5; ++index)
+ {
+ _categoryTotals[5] += _categoryTotals[index];
+ _categoryItems[5].AddRange(_categoryItems[index]);
+ _categoryDials[index].currentValue = _categoryTotals[index];
+ _categoryDials[index].previousTargetValue = _categoryDials[index].currentValue;
}
- categoryDials[5].currentValue = categoryTotals[5];
- Game1.setRichPresence("earnings", categoryTotals[5]);
+ _categoryDials[5].currentValue = _categoryTotals[5];
+ Game1.setRichPresence("earnings", _categoryTotals[5]);
}
- public int getCategoryIndexForObject(Object o) {
- switch (o.ParentSheetIndex) {
+ private int getCategoryIndexForObject(Object o)
+ {
+ switch (o.ParentSheetIndex)
+ {
case 296:
case 396:
case 402:
@@ -215,7 +231,8 @@ public int getCategoryIndexForObject(Object o) {
case 418:
return 1;
default:
- switch (o.Category) {
+ switch (o.Category)
+ {
case -81:
case -27:
case -23:
@@ -241,8 +258,10 @@ public int getCategoryIndexForObject(Object o) {
}
}
- public string getCategoryName(int index) {
- switch (index) {
+ private string getCategoryName(int index)
+ {
+ switch (index)
+ {
case 0:
return Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11389");
case 1:
@@ -260,145 +279,173 @@ public string getCategoryName(int index) {
}
}
- public override void update(GameTime time) {
+ public override void update(GameTime time)
+ {
base.update(time);
- if (_hasFinished) {
+ if (_hasFinished)
+ {
shipItems();
exitThisMenu(false);
}
- else {
- double weatherX = this.weatherX;
+ else
+ {
+ double weatherX = this._weatherX;
var elapsedGameTime = time.ElapsedGameTime;
var num1 = elapsedGameTime.Milliseconds * 0.029999999329447746;
- this.weatherX = (float) (weatherX + num1);
- for (var index = animations.Count - 1; index >= 0; --index)
- if (animations[index].update(time))
- animations.RemoveAt(index);
- if (outro) {
- if (this.outroFadeTimer > 0) {
- var outroFadeTimer = this.outroFadeTimer;
+ this._weatherX = (float)(weatherX + num1);
+ for (var index = _animations.Count - 1; index >= 0; --index)
+ if (_animations[index].update(time))
+ _animations.RemoveAt(index);
+ if (_outro)
+ {
+ if (this._outroFadeTimer > 0)
+ {
+ var outroFadeTimer = this._outroFadeTimer;
elapsedGameTime = time.ElapsedGameTime;
var milliseconds = elapsedGameTime.Milliseconds;
- this.outroFadeTimer = outroFadeTimer - milliseconds;
+ this._outroFadeTimer = outroFadeTimer - milliseconds;
}
- else if (this.outroFadeTimer <= 0 && this.dayPlaqueY < centerY - 64) {
- if (animations.Count > 0)
- animations.Clear();
- var dayPlaqueY = this.dayPlaqueY;
+ else if (this._outroFadeTimer <= 0 && this._dayPlaqueY < _centerY - 64)
+ {
+ if (_animations.Count > 0)
+ _animations.Clear();
+ var dayPlaqueY = this._dayPlaqueY;
elapsedGameTime = time.ElapsedGameTime;
- var num2 = (int) Math.Ceiling(elapsedGameTime.Milliseconds * 0.349999994039536);
- this.dayPlaqueY = dayPlaqueY + num2;
- if (this.dayPlaqueY >= centerY - 64)
- outroPauseBeforeDateChange = 700;
+ var num2 = (int)Math.Ceiling(elapsedGameTime.Milliseconds * 0.349999994039536);
+ this._dayPlaqueY = dayPlaqueY + num2;
+ if (this._dayPlaqueY >= _centerY - 64)
+ _outroPauseBeforeDateChange = 700;
}
- else if (outroPauseBeforeDateChange > 0) {
- var beforeDateChange = outroPauseBeforeDateChange;
+ else if (_outroPauseBeforeDateChange > 0)
+ {
+ var beforeDateChange = _outroPauseBeforeDateChange;
elapsedGameTime = time.ElapsedGameTime;
var milliseconds = elapsedGameTime.Milliseconds;
- outroPauseBeforeDateChange = beforeDateChange - milliseconds;
- if (outroPauseBeforeDateChange <= 0) {
+ _outroPauseBeforeDateChange = beforeDateChange - milliseconds;
+ if (_outroPauseBeforeDateChange <= 0)
+ {
Game1.playSound("newRecipe");
- finalOutroTimer = 2000;
- animations.Clear();
- if (!savedYet)
- savedYet = true;
+ _finalOutroTimer = 2000;
+ _animations.Clear();
+ if (!_savedYet)
+ _savedYet = true;
}
}
- else if (this.finalOutroTimer > 0 && savedYet) {
- var finalOutroTimer = this.finalOutroTimer;
+ else if (this._finalOutroTimer > 0 && _savedYet)
+ {
+ var finalOutroTimer = this._finalOutroTimer;
elapsedGameTime = time.ElapsedGameTime;
var milliseconds = elapsedGameTime.Milliseconds;
- this.finalOutroTimer = finalOutroTimer - milliseconds;
- if (this.finalOutroTimer <= 0)
+ this._finalOutroTimer = finalOutroTimer - milliseconds;
+ if (this._finalOutroTimer <= 0)
_hasFinished = true;
}
}
- if (introTimer >= 0) {
- var introTimer1 = introTimer;
- var introTimer2 = introTimer;
+ if (_introTimer >= 0)
+ {
+ var introTimer1 = _introTimer;
+ var introTimer2 = _introTimer;
elapsedGameTime = time.ElapsedGameTime;
var num3 = elapsedGameTime.Milliseconds *
(Game1.oldMouseState.LeftButton == ButtonState.Pressed ? 3 : 1);
- introTimer = introTimer2 - num3;
- if (introTimer1 % 500 < introTimer % 500 && introTimer <= 3000) {
- var num4 = 4 - introTimer / 500;
- if (num4 < 6 && num4 > -1) {
- if (categoryItems[num4].Count > 0) {
+ _introTimer = introTimer2 - num3;
+ if (introTimer1 % 500 < _introTimer % 500 && _introTimer <= 3000)
+ {
+ var num4 = 4 - _introTimer / 500;
+ if (num4 is < 6 and > -1)
+ {
+ if (_categoryItems[num4].Count > 0)
+ {
Game1.playSound(getCategorySound(num4));
- categoryDials[num4].currentValue = 0;
- categoryDials[num4].previousTargetValue = 0;
+ _categoryDials[num4].currentValue = 0;
+ _categoryDials[num4].previousTargetValue = 0;
}
- else {
+ else
+ {
Game1.playSound("stoneStep");
}
}
}
- if (introTimer < 0) {
+ if (_introTimer < 0)
+ {
if (Game1.options.SnappyMenus)
base.snapToDefaultClickableComponent();
Game1.playSound("money");
- categoryDials[5].currentValue = 0;
- categoryDials[5].previousTargetValue = 0;
+ _categoryDials[5].currentValue = 0;
+ _categoryDials[5].previousTargetValue = 0;
}
}
- else if (Game1.dayOfMonth != 28 && !outro) {
- if (!Game1.wasRainingYesterday) {
+ else if (Game1.dayOfMonth != 28 && !_outro)
+ {
+ if (!Game1.wasRainingYesterday)
+ {
var vector2 = new Vector2(Game1.viewport.Width, Game1.random.Next(200));
var rectangle = new Rectangle(640, 752, 16, 16);
var num5 = Game1.random.Next(1, 4);
- if (Game1.random.NextDouble() < 0.001) {
+ if (Game1.random.NextDouble() < 0.001)
+ {
var flag = Game1.random.NextDouble() < 0.5;
if (Game1.random.NextDouble() < 0.5)
- animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors",
+ _animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors",
new Rectangle(640, 826, 16, 8), 40f, 4, 0,
- new Vector2(Game1.random.Next(centerX * 2), Game1.random.Next(centerY)), false,
- flag) {
+ new Vector2(Game1.random.Next(_centerX * 2), Game1.random.Next(_centerY)), false,
+ flag)
+ {
rotation = 3.141593f,
scale = 4f,
motion = new Vector2(flag ? -8f : 8f, 8f),
local = true
});
else
- animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors",
+ _animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors",
new Rectangle(258, 1680, 16, 16), 40f, 4, 0,
- new Vector2(Game1.random.Next(centerX * 2), Game1.random.Next(centerY)), false,
- flag) {
+ new Vector2(Game1.random.Next(_centerX * 2), Game1.random.Next(_centerY)), false,
+ flag)
+ {
scale = 4f,
motion = new Vector2(flag ? -8f : 8f, 8f),
local = true
});
}
- else if (Game1.random.NextDouble() < 0.0002) {
+ else if (Game1.random.NextDouble() < 0.0002)
+ {
vector2 = new Vector2(Game1.viewport.Width, Game1.random.Next(4, 256));
- animations.Add(new TemporaryAnimatedSprite("", new Rectangle(0, 0, 1, 1), 9999f, 1, 10000,
+ _animations.Add(new TemporaryAnimatedSprite("", new Rectangle(0, 0, 1, 1), 9999f, 1, 10000,
vector2, false, false, 0.01f, 0.0f,
- Color.White * (0.25f + (float) Game1.random.NextDouble()), 4f, 0.0f, 0.0f, 0.0f, true) {
+ Color.White * (0.25f + (float)Game1.random.NextDouble()), 4f, 0.0f, 0.0f, 0.0f, true)
+ {
motion = new Vector2(-0.25f, 0.0f)
});
}
- else if (Game1.random.NextDouble() < 5E-05) {
+ else if (Game1.random.NextDouble() < 5E-05)
+ {
vector2 = new Vector2(Game1.viewport.Width, Game1.viewport.Height - 192);
- for (var index = 0; index < num5; ++index) {
- animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", rectangle,
+ for (var index = 0; index < num5; ++index)
+ {
+ _animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", rectangle,
Game1.random.Next(60, 101), 4, 100,
vector2 + new Vector2((index + 1) * Game1.random.Next(15, 18), (index + 1) * -20),
- false, false, 0.01f, 0.0f, Color.Black, 4f, 0.0f, 0.0f, 0.0f, true) {
+ false, false, 0.01f, 0.0f, Color.Black, 4f, 0.0f, 0.0f, 0.0f, true)
+ {
motion = new Vector2(-1f, 0.0f)
});
- animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", rectangle,
+ _animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", rectangle,
Game1.random.Next(60, 101), 4, 100,
vector2 + new Vector2((index + 1) * Game1.random.Next(15, 18), (index + 1) * 20),
- false, false, 0.01f, 0.0f, Color.Black, 4f, 0.0f, 0.0f, 0.0f, true) {
+ false, false, 0.01f, 0.0f, Color.Black, 4f, 0.0f, 0.0f, 0.0f, true)
+ {
motion = new Vector2(-1f, 0.0f)
});
}
}
- else if (Game1.random.NextDouble() < 1E-05) {
+ else if (Game1.random.NextDouble() < 1E-05)
+ {
rectangle = new Rectangle(640, 784, 16, 16);
- animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", rectangle, 75f, 4, 1000,
- vector2, false, false, 0.01f, 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, true) {
+ _animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", rectangle, 75f, 4, 1000,
+ vector2, false, false, 0.01f, 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, true)
+ {
motion = new Vector2(-3f, 0.0f),
yPeriodic = true,
yPeriodicLoopTime = 1000f,
@@ -408,38 +455,42 @@ public override void update(GameTime time) {
}
}
- var smokeTimer = this.smokeTimer;
+ var smokeTimer = this._smokeTimer;
elapsedGameTime = time.ElapsedGameTime;
var milliseconds = elapsedGameTime.Milliseconds;
- this.smokeTimer = smokeTimer - milliseconds;
- if (this.smokeTimer <= 0) {
- this.smokeTimer = 50;
- animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors",
+ this._smokeTimer = smokeTimer - milliseconds;
+ if (this._smokeTimer <= 0)
+ {
+ this._smokeTimer = 50;
+ _animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors",
new Rectangle(684, 1075, 1, 1), 1000f, 1, 1000,
- new Vector2(188f, Game1.viewport.Height - 128 + 20), false, false) {
+ new Vector2(188f, Game1.viewport.Height - 128 + 20), false, false)
+ {
color = Game1.wasRainingYesterday ? Color.SlateGray : Color.White,
scale = 4f,
scaleChange = 0.0f,
alphaFade = 1f / 400f,
- motion = new Vector2(0.0f, (float) (-Game1.random.Next(25, 75) / 100.0 / 4.0)),
+ motion = new Vector2(0.0f, (float)(-Game1.random.Next(25, 75) / 100.0 / 4.0)),
acceleration = new Vector2(-1f / 1000f, 0.0f)
});
}
}
- if (this.moonShake <= 0)
+ if (this._moonShake <= 0)
return;
- var moonShake = this.moonShake;
+ var moonShake = this._moonShake;
elapsedGameTime = time.ElapsedGameTime;
var milliseconds1 = elapsedGameTime.Milliseconds;
- this.moonShake = moonShake - milliseconds1;
+ this._moonShake = moonShake - milliseconds1;
}
}
- public string getCategorySound(int which) {
- switch (which) {
+ private string getCategorySound(int which)
+ {
+ switch (which)
+ {
case 0:
- return !(categoryItems[0][0] as Object).isAnimalProduct() ? "harvest" : "cluck";
+ return !(_categoryItems[0][0] as Object).isAnimalProduct() ? "harvest" : "cluck";
case 1:
return "leafrustle";
case 2:
@@ -455,99 +506,120 @@ public string getCategorySound(int which) {
}
}
- public override void applyMovementKey(int direction) {
+ public override void applyMovementKey(int direction)
+ {
if (!CanReceiveInput())
return;
base.applyMovementKey(direction);
}
- public override void performHoverAction(int x, int y) {
+ public override void performHoverAction(int x, int y)
+ {
if (!CanReceiveInput())
return;
base.performHoverAction(x, y);
- if (currentPage == -1) {
- okButton.tryHover(x, y);
- foreach (var category in categories)
+ if (_currentPage == -1)
+ {
+ _okButton.tryHover(x, y);
+ foreach (var category in _categories)
category.sourceRect.X = !category.containsPoint(x, y) ? 392 : 402;
}
- else {
- backButton.tryHover(x, y, 0.5f);
- forwardButton.tryHover(x, y, 0.5f);
+ else
+ {
+ _backButton.tryHover(x, y, 0.5f);
+ _forwardButton.tryHover(x, y, 0.5f);
}
}
- public bool CanReceiveInput() {
- return introTimer <= 0 && !outro;
+ private bool CanReceiveInput()
+ {
+ return _introTimer <= 0 && !_outro;
}
- public override void receiveKeyPress(Keys key) {
+ public override void receiveKeyPress(Keys key)
+ {
if (!CanReceiveInput())
return;
- if (introTimer <= 0 && !Game1.options.gamepadControls && (key.Equals((Keys) 27) ||
+ if (_introTimer <= 0 && !Game1.options.gamepadControls && (key.Equals((Keys)27) ||
Game1.options.doesInputListContain(
- Game1.options.menuButton, key))) {
- base.receiveLeftClick(okButton.bounds.Center.X, okButton.bounds.Center.Y);
+ Game1.options.menuButton, key)))
+ {
+ base.receiveLeftClick(_okButton.bounds.Center.X, _okButton.bounds.Center.Y);
}
- else {
- if (introTimer > 0 || (Game1.options.gamepadControls &&
+ else
+ {
+ if (_introTimer > 0 || (Game1.options.gamepadControls &&
Game1.options.doesInputListContain(Game1.options.menuButton, key)))
return;
base.receiveKeyPress(key);
}
}
- public override void receiveGamePadButton(Buttons b) {
+ public override void receiveGamePadButton(Buttons b)
+ {
if (!CanReceiveInput())
return;
base.receiveGamePadButton(b);
- if (b == Buttons.B && currentPage != -1) {
- if (currentTab == 0) {
- if (Game1.options.SnappyMenus) {
- currentlySnappedComponent = getComponentWithID(currentPage);
+ if (b == Buttons.B && _currentPage != -1)
+ {
+ if (_currentTab == 0)
+ {
+ if (Game1.options.SnappyMenus)
+ {
+ currentlySnappedComponent = getComponentWithID(_currentPage);
snapCursorToCurrentSnappedComponent();
}
- currentPage = -1;
+ _currentPage = -1;
}
- else {
- --currentTab;
+ else
+ {
+ --_currentTab;
}
Game1.playSound("shwip");
}
- else {
- if ((b != Buttons.Start && b != Buttons.B) || currentPage != -1 || outro)
+ else
+ {
+ if ((b != Buttons.Start && b != Buttons.B) || _currentPage != -1 || _outro)
return;
- if (introTimer <= 0)
+ if (_introTimer <= 0)
okClicked();
else
- introTimer -= Game1.currentGameTime.ElapsedGameTime.Milliseconds * 2;
+ _introTimer -= Game1.currentGameTime.ElapsedGameTime.Milliseconds * 2;
}
}
- private void okClicked() {
- outro = true;
- outroFadeTimer = 800;
+ private void okClicked()
+ {
+ _outro = true;
+ _outroFadeTimer = 800;
Game1.playSound("bigDeSelect");
Game1.changeMusicTrack("none");
}
- public override void receiveLeftClick(int x, int y, bool playSound = true) {
+ public override void receiveLeftClick(int x, int y, bool playSound = true)
+ {
if (!CanReceiveInput())
return;
- if (outro && !savedYet) {
- savedYet = true;
+ if (_outro && !_savedYet)
+ {
+ _savedYet = true;
}
- else {
+ else
+ {
base.receiveLeftClick(x, y, playSound);
- if (currentPage == -1 && introTimer <= 0 && okButton.containsPoint(x, y))
+ if (_currentPage == -1 && _introTimer <= 0 && _okButton.containsPoint(x, y))
okClicked();
- if (currentPage == -1) {
- for (var index = 0; index < categories.Count; ++index)
- if (categories[index].visible && categories[index].containsPoint(x, y)) {
- currentPage = index;
+ if (_currentPage == -1)
+ {
+ for (var index = 0; index < _categories.Count; ++index)
+ if (_categories[index].visible && _categories[index].containsPoint(x, y))
+ {
+ _currentPage = index;
Game1.playSound("shwip");
- if (Game1.options.SnappyMenus) {
+ if (Game1.options.SnappyMenus)
+ {
currentlySnappedComponent = getComponentWithID(103);
snapCursorToCurrentSnappedComponent();
}
@@ -556,136 +628,150 @@ public override void receiveLeftClick(int x, int y, bool playSound = true) {
}
int num;
- if (Game1.dayOfMonth == 28 && timesPokedMoon <= 10) {
+ if (Game1.dayOfMonth == 28 && _timesPokedMoon <= 10)
+ {
var rectangle = new Rectangle(Game1.viewport.Width - 176, 4, 172, 172);
num = !rectangle.Contains(x, y) ? 1 : 0;
}
- else {
+ else
+ {
num = 1;
}
if (num != 0)
return;
- moonShake = 100;
- ++timesPokedMoon;
- if (timesPokedMoon > 10)
- Game1.playSound("shadowDie");
- else
- Game1.playSound("thudStep");
+ _moonShake = 100;
+ ++_timesPokedMoon;
+ Game1.playSound(_timesPokedMoon > 10 ? "shadowDie" : "thudStep");
}
- else if (backButton.containsPoint(x, y)) {
- if (currentTab == 0) {
- if (Game1.options.SnappyMenus) {
- currentlySnappedComponent = getComponentWithID(currentPage);
+ else if (_backButton.containsPoint(x, y))
+ {
+ if (_currentTab == 0)
+ {
+ if (Game1.options.SnappyMenus)
+ {
+ currentlySnappedComponent = getComponentWithID(_currentPage);
snapCursorToCurrentSnappedComponent();
}
- currentPage = -1;
+ _currentPage = -1;
}
- else {
- --currentTab;
+ else
+ {
+ --_currentTab;
}
Game1.playSound("shwip");
}
- else {
- if (!showForwardButton() || !forwardButton.containsPoint(x, y))
+ else
+ {
+ if (!showForwardButton() || !_forwardButton.containsPoint(x, y))
return;
- ++currentTab;
+ ++_currentTab;
Game1.playSound("shwip");
}
}
}
- public override void receiveRightClick(int x, int y, bool playSound = true) { }
+ public override void receiveRightClick(int x, int y, bool playSound = true)
+ {
+ }
- public bool showForwardButton() {
- return categoryItems[currentPage].Count > itemsPerCategoryPage * (currentTab + 1);
+ private bool showForwardButton()
+ {
+ return _categoryItems[_currentPage].Count > _itemsPerCategoryPage * (_currentTab + 1);
}
- public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) {
+ public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds)
+ {
initialize(0, 0, Game1.viewport.Width, Game1.viewport.Height);
RepositionItems();
}
public override void draw(SpriteBatch b)
{
- if (Game1.wasRainingYesterday) {
+ if (Game1.wasRainingYesterday)
+ {
b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height),
new Rectangle(639, 858, 1, 184),
Game1.currentSeason.Equals("winter")
? Color.LightSlateGray
- : Color.SlateGray * (float) (1.0 - introTimer / 3500.0));
+ : Color.SlateGray * (float)(1.0 - _introTimer / 3500.0));
b.Draw(Game1.mouseCursors, new Rectangle(2556, 0, Game1.viewport.Width, Game1.viewport.Height),
new Rectangle(639, 858, 1, 184),
Game1.currentSeason.Equals("winter")
? Color.LightSlateGray
- : Color.SlateGray * (float) (1.0 - introTimer / 3500.0));
+ : Color.SlateGray * (float)(1.0 - _introTimer / 3500.0));
for (var index = -244; index < Game1.viewport.Width + 244; index += 244)
- b.Draw(Game1.mouseCursors, new Vector2(index + (float) (weatherX / 2.0 % 244.0), 32f),
+ b.Draw(Game1.mouseCursors, new Vector2(index + (float)(_weatherX / 2.0 % 244.0), 32f),
new Rectangle(643, 1142, 61, 53),
- Color.DarkSlateGray * 1f * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ Color.DarkSlateGray * 1f * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
b.Draw(Game1.mouseCursors, new Vector2(0.0f, Game1.viewport.Height - 192),
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 48),
Game1.currentSeason.Equals("winter")
? Color.White * 0.25f
- : new Color(30, 62, 50) * (float) (0.5 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f,
- (SpriteEffects) 1, 1f);
+ : new Color(30, 62, 50) * (float)(0.5 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f,
+ (SpriteEffects)1, 1f);
b.Draw(Game1.mouseCursors, new Vector2(2556f, Game1.viewport.Height - 192),
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 48),
Game1.currentSeason.Equals("winter")
? Color.White * 0.25f
- : new Color(30, 62, 50) * (float) (0.5 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f,
- (SpriteEffects) 1, 1f);
+ : new Color(30, 62, 50) * (float)(0.5 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f,
+ (SpriteEffects)1, 1f);
b.Draw(Game1.mouseCursors, new Vector2(0.0f, Game1.viewport.Height - 128),
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 32),
Game1.currentSeason.Equals("winter")
? Color.White * 0.5f
- : new Color(30, 62, 50) * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ : new Color(30, 62, 50) * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
b.Draw(Game1.mouseCursors, new Vector2(2556f, Game1.viewport.Height - 128),
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 32),
Game1.currentSeason.Equals("winter")
? Color.White * 0.5f
- : new Color(30, 62, 50) * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ : new Color(30, 62, 50) * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
b.Draw(Game1.mouseCursors, new Vector2(160f, Game1.viewport.Height - 128 + 16 + 8),
- new Rectangle(653, 880, 10, 10), Color.White * (float) (1.0 - introTimer / 3500.0), 0.0f,
+ new Rectangle(653, 880, 10, 10), Color.White * (float)(1.0 - _introTimer / 3500.0), 0.0f,
Vector2.Zero, 4f, 0, 1f);
for (var index = -244; index < Game1.viewport.Width + 244; index += 244)
- b.Draw(Game1.mouseCursors, new Vector2(index + weatherX % 244f, -32f),
- new Rectangle(643, 1142, 61, 53), Color.SlateGray * 0.85f * (float) (1.0 - introTimer / 3500.0),
+ b.Draw(Game1.mouseCursors, new Vector2(index + _weatherX % 244f, -32f),
+ new Rectangle(643, 1142, 61, 53), Color.SlateGray * 0.85f * (float)(1.0 - _introTimer / 3500.0),
0.0f, Vector2.Zero, 4f, 0, 0.9f);
- foreach (var animation in animations)
+ foreach (var animation in _animations)
animation.draw(b, true);
for (var index = -244; index < Game1.viewport.Width + 244; index += 244)
- b.Draw(Game1.mouseCursors, new Vector2(index + (float) (weatherX * 1.5 % 244.0), sbyte.MinValue),
- new Rectangle(643, 1142, 61, 53), Color.LightSlateGray * (float) (1.0 - introTimer / 3500.0),
+ b.Draw(Game1.mouseCursors, new Vector2(index + (float)(_weatherX * 1.5 % 244.0), sbyte.MinValue),
+ new Rectangle(643, 1142, 61, 53), Color.LightSlateGray * (float)(1.0 - _introTimer / 3500.0),
0.0f, Vector2.Zero, 4f, 0, 0.9f);
}
- else {
+ else
+ {
b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height),
- new Rectangle(639, 858, 1, 184), Color.White * (float) (1.0 - introTimer / 3500.0));
+ new Rectangle(639, 858, 1, 184), Color.White * (float)(1.0 - _introTimer / 3500.0));
b.Draw(Game1.mouseCursors, new Rectangle(2556, 0, Game1.viewport.Width, Game1.viewport.Height),
- new Rectangle(639, 858, 1, 184), Color.White * (float) (1.0 - introTimer / 3500.0));
+ new Rectangle(639, 858, 1, 184), Color.White * (float)(1.0 - _introTimer / 3500.0));
b.Draw(Game1.mouseCursors, new Vector2(0.0f, 0.0f), new Rectangle(0, 1453, 639, 195),
- Color.White * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ Color.White * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
b.Draw(Game1.mouseCursors, new Vector2(2556f, 0.0f), new Rectangle(0, 1453, 639, 195),
- Color.White * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
- if (Game1.dayOfMonth == 28) {
+ Color.White * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ if (Game1.dayOfMonth == 28)
+ {
b.Draw(Game1.mouseCursors,
- new Vector2(Game1.viewport.Width - 176, 4f) + (moonShake > 0
+ new Vector2(Game1.viewport.Width - 176, 4f) + (_moonShake > 0
? new Vector2(Game1.random.Next(-1, 2), Game1.random.Next(-1, 2))
: Vector2.Zero), new Rectangle(642, 835, 43, 43),
- Color.White * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
- if (timesPokedMoon > 10) {
+ Color.White * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ if (_timesPokedMoon > 10)
+ {
var spriteBatch = b;
var mouseCursors = Game1.mouseCursors;
- var vector2 = new Vector2(Game1.viewport.Width - 136, 48f) + (moonShake > 0
+ var vector2 = new Vector2(Game1.viewport.Width - 136, 48f) + (_moonShake > 0
? new Vector2(Game1.random.Next(-1, 2), Game1.random.Next(-1, 2))
: Vector2.Zero);
int num;
- if (Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 4000.0 >= 200.0) {
+ if (Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 4000.0 >= 200.0)
+ {
var totalGameTime = Game1.currentGameTime.TotalGameTime;
- if (totalGameTime.TotalMilliseconds % 8000.0 > 7600.0) {
+ if (totalGameTime.TotalMilliseconds % 8000.0 > 7600.0)
+ {
totalGameTime = Game1.currentGameTime.TotalGameTime;
if (totalGameTime.TotalMilliseconds % 8000.0 < 7800.0)
goto label_21;
@@ -699,7 +785,7 @@ public override void draw(SpriteBatch b)
num = 21;
label_22:
var nullable = new Rectangle(685, 844 + num, 19, 21);
- var color = Color.White * (float) (1.0 - introTimer / 3500.0);
+ var color = Color.White * (float)(1.0 - _introTimer / 3500.0);
var zero = Vector2.Zero;
spriteBatch.Draw(mouseCursors, vector2, nullable, color, 0.0f, zero, 4f, 0, 1f);
}
@@ -709,208 +795,230 @@ public override void draw(SpriteBatch b)
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 48),
Game1.currentSeason.Equals("winter")
? Color.White * 0.25f
- : new Color(0, 20, 40) * (float) (0.649999976158142 - introTimer / 3500.0), 0.0f, Vector2.Zero,
- 4f, (SpriteEffects) 1, 1f);
+ : new Color(0, 20, 40) * (float)(0.649999976158142 - _introTimer / 3500.0), 0.0f, Vector2.Zero,
+ 4f, (SpriteEffects)1, 1f);
b.Draw(Game1.mouseCursors, new Vector2(2556f, Game1.viewport.Height - 192),
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 48),
Game1.currentSeason.Equals("winter")
? Color.White * 0.25f
- : new Color(0, 20, 40) * (float) (0.649999976158142 - introTimer / 3500.0), 0.0f, Vector2.Zero,
- 4f, (SpriteEffects) 1, 1f);
+ : new Color(0, 20, 40) * (float)(0.649999976158142 - _introTimer / 3500.0), 0.0f, Vector2.Zero,
+ 4f, (SpriteEffects)1, 1f);
b.Draw(Game1.mouseCursors, new Vector2(0.0f, Game1.viewport.Height - 128),
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 32),
Game1.currentSeason.Equals("winter")
? Color.White * 0.5f
- : new Color(0, 32, 20) * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ : new Color(0, 32, 20) * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
b.Draw(Game1.mouseCursors, new Vector2(2556f, Game1.viewport.Height - 128),
new Rectangle(0, Game1.currentSeason.Equals("winter") ? 1034 : 737, 639, 32),
Game1.currentSeason.Equals("winter")
? Color.White * 0.5f
- : new Color(0, 32, 20) * (float) (1.0 - introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
+ : new Color(0, 32, 20) * (float)(1.0 - _introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, 0, 1f);
b.Draw(Game1.mouseCursors, new Vector2(160f, Game1.viewport.Height - 128 + 16 + 8),
- new Rectangle(653, 880, 10, 10), Color.White * (float) (1.0 - introTimer / 3500.0), 0.0f,
+ new Rectangle(653, 880, 10, 10), Color.White * (float)(1.0 - _introTimer / 3500.0), 0.0f,
Vector2.Zero, 4f, 0, 1f);
}
- if (!outro && !Game1.wasRainingYesterday)
- foreach (var animation in animations)
+ if (!_outro && !Game1.wasRainingYesterday)
+ foreach (var animation in _animations)
animation.draw(b, true);
- if (currentPage == -1) {
- var num1 = categories[0].bounds.Y - 128;
+ if (_currentPage == -1)
+ {
+ var num1 = _categories[0].bounds.Y - 128;
if (num1 >= 0)
SpriteText.drawStringWithScrollCenteredAt(b, Utility.getDateString(), Game1.viewport.Width / 2,
num1);
var num2 = -20;
var index1 = 0;
- foreach (var category in categories) {
- if (introTimer < 2500 - index1 * 500) {
+ foreach (var category in _categories)
+ {
+ if (_introTimer < 2500 - index1 * 500)
+ {
var vector2 = category.getVector2() + new Vector2(12f, -8f);
- if (category.visible) {
+ if (category.visible)
+ {
category.draw(b);
b.Draw(Game1.mouseCursors, vector2 + new Vector2(-104f, num2 + 4),
new Rectangle(293, 360, 24, 24), Color.White, 0.0f, Vector2.Zero, 4f, 0, 0.88f);
- categoryItems[index1][0]
+ _categoryItems[index1][0]
.drawInMenu(b, vector2 + new Vector2(-88f, num2 + 16), 1f, 1f, 0.9f, 0);
}
drawTextureBox(b, Game1.mouseCursors, new Rectangle(384, 373, 18, 18),
- (int) (vector2.X + (double) -itemSlotWidth - categoryLabelsWidth - 12.0),
- (int) (vector2.Y + (double) num2), categoryLabelsWidth, 104, Color.White, 4f, false);
+ (int)(vector2.X + (double)-_itemSlotWidth - _categoryLabelsWidth - 12.0),
+ (int)(vector2.Y + (double)num2), _categoryLabelsWidth, 104, Color.White, 4f, false);
SpriteText.drawString(b, category.hoverText,
- (int) vector2.X - itemSlotWidth - categoryLabelsWidth + 8, (int) vector2.Y + 4);
+ (int)vector2.X - _itemSlotWidth - _categoryLabelsWidth + 8, (int)vector2.Y + 4);
for (var index2 = 0; index2 < 6; ++index2)
b.Draw(Game1.mouseCursors,
- vector2 + new Vector2(-itemSlotWidth - 192 - 24 + index2 * 6 * 4, 12f),
+ vector2 + new Vector2(-_itemSlotWidth - 192 - 24 + index2 * 6 * 4, 12f),
new Rectangle(355, 476, 7, 11), Color.White, 0.0f, Vector2.Zero, 4f, 0, 0.88f);
- categoryDials[index1].draw(b, vector2 + new Vector2(-itemSlotWidth - 192 - 48 + 4, 20f),
- categoryTotals[index1]);
- b.Draw(Game1.mouseCursors, vector2 + new Vector2(-itemSlotWidth - 64 - 4, 12f),
+ _categoryDials[index1].draw(b, vector2 + new Vector2(-_itemSlotWidth - 192 - 48 + 4, 20f),
+ _categoryTotals[index1]);
+ b.Draw(Game1.mouseCursors, vector2 + new Vector2(-_itemSlotWidth - 64 - 4, 12f),
new Rectangle(408, 476, 9, 11), Color.White, 0.0f, Vector2.Zero, 4f, 0, 0.88f);
}
++index1;
}
- if (introTimer <= 0)
- okButton.draw(b);
+ if (_introTimer <= 0)
+ _okButton.draw(b);
}
- else {
+ else
+ {
drawTextureBox(b, 0, 0, Game1.viewport.Width, Game1.viewport.Height, Color.White);
var vector2 = new Vector2(xPositionOnScreen + 32, yPositionOnScreen + 32);
- for (var index = currentTab * itemsPerCategoryPage;
- index < currentTab * itemsPerCategoryPage + itemsPerCategoryPage;
+ for (var index = _currentTab * _itemsPerCategoryPage;
+ index < _currentTab * _itemsPerCategoryPage + _itemsPerCategoryPage;
++index)
- if (categoryItems[currentPage].Count > index) {
- var key = categoryItems[currentPage][index];
- key.drawInMenu(b, vector2, 1f, 1f, 1f, (StackDrawType) 1);
+ if (_categoryItems[_currentPage].Count > index)
+ {
+ var key = _categoryItems[_currentPage][index];
+ key.drawInMenu(b, vector2, 1f, 1f, 1f, (StackDrawType)1);
int stack;
- if (LocalizedContentManager.CurrentLanguageLatin) {
+ if (LocalizedContentManager.CurrentLanguageLatin)
+ {
var spriteBatch1 = b;
var displayName1 = key.DisplayName;
string str1;
- if (key.Stack <= 1) {
+ if (key.Stack <= 1)
+ {
str1 = "";
}
- else {
+ else
+ {
stack = key.Stack;
str1 = " x" + stack;
}
var str2 = displayName1 + str1;
- var num3 = (int) vector2.X + 64 + 12;
- var num4 = (int) vector2.Y + 12;
+ var num3 = (int)vector2.X + 64 + 12;
+ var num4 = (int)vector2.Y + 12;
SpriteText.drawString(spriteBatch1, str2, num3, num4);
var str3 = ".";
var num5 = 0;
- while (true) {
+ while (true)
+ {
var num6 = num5;
var num7 = width - 96;
var displayName2 = key.DisplayName;
string str4;
- if (key.Stack <= 1) {
+ if (key.Stack <= 1)
+ {
str4 = "";
}
- else {
+ else
+ {
stack = key.Stack;
str4 = " x" + stack;
}
var str5 = Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020",
- itemValues[key]);
+ _itemValues[key]);
var widthOfString = SpriteText.getWidthOfString(displayName2 + str4 + str5);
var num8 = num7 - widthOfString;
- if (num6 < num8) {
+ if (num6 < num8)
+ {
str3 += " .";
num5 += SpriteText.getWidthOfString(" .");
}
- else {
+ else
+ {
break;
}
}
var spriteBatch2 = b;
var str6 = str3;
- var num9 = (int) vector2.X + 80;
+ var num9 = (int)vector2.X + 80;
var displayName3 = key.DisplayName;
string str7;
- if (key.Stack <= 1) {
+ if (key.Stack <= 1)
+ {
str7 = "";
}
- else {
+ else
+ {
stack = key.Stack;
str7 = " x" + stack;
}
var widthOfString1 = SpriteText.getWidthOfString(displayName3 + str7);
var num10 = num9 + widthOfString1;
- var num11 = (int) vector2.Y + 8;
+ var num11 = (int)vector2.Y + 8;
SpriteText.drawString(spriteBatch2, str6, num10, num11);
SpriteText.drawString(b,
Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020",
- itemValues[key]),
- (int) vector2.X + width - 64 - SpriteText.getWidthOfString(
+ _itemValues[key]),
+ (int)vector2.X + width - 64 - SpriteText.getWidthOfString(
Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020",
- itemValues[key])), (int) vector2.Y + 12);
+ _itemValues[key])), (int)vector2.Y + 12);
}
- else {
+ else
+ {
var displayName = key.DisplayName;
string str8;
- if (key.Stack <= 1) {
+ if (key.Stack <= 1)
+ {
str8 = ".";
}
- else {
+ else
+ {
stack = key.Stack;
str8 = " x" + stack;
}
var str9 = displayName + str8;
var str10 = Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020",
- itemValues[key]);
- var num = (int) vector2.X + width - 64 - SpriteText.getWidthOfString(
+ _itemValues[key]);
+ var num = (int)vector2.X + width - 64 - SpriteText.getWidthOfString(
Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020",
- itemValues[key]));
+ _itemValues[key]));
SpriteText.getWidthOfString(str9 + str10);
while (SpriteText.getWidthOfString(str9 + str10) < 1123)
str9 += " .";
if (SpriteText.getWidthOfString(str9 + str10) >= 1155)
str9 = str9.Remove(str9.Length - 1);
- SpriteText.drawString(b, str9, (int) vector2.X + 64 + 12, (int) vector2.Y + 12);
- SpriteText.drawString(b, str10, num, (int) vector2.Y + 12);
+ SpriteText.drawString(b, str9, (int)vector2.X + 64 + 12, (int)vector2.Y + 12);
+ SpriteText.drawString(b, str10, num, (int)vector2.Y + 12);
}
vector2.Y += 68f;
}
- backButton.draw(b);
+ _backButton.draw(b);
if (showForwardButton())
- forwardButton.draw(b);
+ _forwardButton.draw(b);
}
- if (outro) {
+ if (_outro)
+ {
b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height),
- new Rectangle(639, 858, 1, 184), Color.Black * (1F - outroFadeTimer / 800F));
+ new Rectangle(639, 858, 1, 184), Color.Black * (1F - _outroFadeTimer / 800F));
SpriteText.drawStringWithScrollCenteredAt(b,
- newDayPlaque ? Utility.getDateString() : Utility.getDateString(), Game1.viewport.Width / 2,
- dayPlaqueY);
- foreach (var animation in animations)
+ Utility.getDateString(), Game1.viewport.Width / 2,
+ _dayPlaqueY);
+ foreach (var animation in _animations)
animation.draw(b, true);
- if (finalOutroTimer > 0 || _hasFinished)
+ if (_finalOutroTimer > 0 || _hasFinished)
b.Draw(Game1.staminaRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height),
- new Rectangle(0, 0, 1, 1), Color.Black * (1F - finalOutroTimer * 0.0005F));
+ new Rectangle(0, 0, 1, 1), Color.Black * (1F - _finalOutroTimer * 0.0005F));
}
- if (Game1.options.SnappyMenus && (introTimer > 0 || outro))
+ if (Game1.options.SnappyMenus && (_introTimer > 0 || _outro))
return;
drawMouse(b);
}
- public void shipItems() {
+ private void shipItems()
+ {
var shippingBin = Game1.getFarm().getShippingBin(Game1.player);
- if (Game1.player.useSeparateWallets || (!Game1.player.useSeparateWallets && Game1.player.IsMainPlayer)) {
+ if (Game1.player.useSeparateWallets || (!Game1.player.useSeparateWallets && Game1.player.IsMainPlayer))
+ {
var num = 0;
foreach (var obj in shippingBin)
- if (obj is Object)
- num += (obj as Object).sellToStorePrice() * obj.Stack;
+ if (obj is Object obj1)
+ num += obj1.sellToStorePrice() * obj1.Stack;
Game1.player.Money += num;
Game1.getFarm().getShippingBin(Game1.player).Clear();
}
@@ -918,11 +1026,13 @@ public void shipItems() {
if (!Game1.player.useSeparateWallets || !Game1.player.IsMainPlayer)
return;
foreach (var allFarmhand in Game1.getAllFarmhands())
- if (!allFarmhand.isActive() && !allFarmhand.isUnclaimedFarmhand) {
+ if (!allFarmhand.isActive() && !allFarmhand.isUnclaimedFarmhand)
+ {
var num = 0;
foreach (var obj in Game1.getFarm().getShippingBin(allFarmhand))
- if (obj is Object)
- num += (obj as Object).sellToStorePrice(allFarmhand.UniqueMultiplayerID) * obj.Stack;
+ if (obj is Object obj1)
+
+ num += obj1.sellToStorePrice(allFarmhand.UniqueMultiplayerID) * obj1.Stack;
Game1.player.team.AddIndividualMoney(allFarmhand, num);
Game1.getFarm().getShippingBin(allFarmhand).Clear();
}
diff --git a/Framework/SaveAnywhereAPI.cs b/Framework/SaveAnywhereAPI.cs
index fbefb08..1b9f9ec 100644
--- a/Framework/SaveAnywhereAPI.cs
+++ b/Framework/SaveAnywhereAPI.cs
@@ -1,45 +1,55 @@
using System;
-namespace SaveAnywhere.Framework {
- public class SaveAnywhereAPI {
-
- public event EventHandler BeforeSave {
- add => SaveAnywhere.Instance.SaveManager.beforeSave += value;
- remove => SaveAnywhere.Instance.SaveManager.beforeSave -= value;
+namespace SaveAnywhere.Framework
+{
+ public class SaveAnywhereApi
+ {
+ public event EventHandler BeforeSave
+ {
+ add => SaveAnywhere.Instance.SaveManager.BeforeSave += value;
+ remove => SaveAnywhere.Instance.SaveManager.BeforeSave -= value;
}
- public event EventHandler AfterSave {
- add => SaveAnywhere.Instance.SaveManager.afterSave += value;
- remove => SaveAnywhere.Instance.SaveManager.afterSave -= value;
+ public event EventHandler AfterSave
+ {
+ add => SaveAnywhere.Instance.SaveManager.AfterSave += value;
+ remove => SaveAnywhere.Instance.SaveManager.AfterSave -= value;
}
- public event EventHandler AfterLoad {
- add => SaveAnywhere.Instance.SaveManager.afterLoad += value;
- remove => SaveAnywhere.Instance.SaveManager.afterLoad -= value;
+ public event EventHandler AfterLoad
+ {
+ add => SaveAnywhere.Instance.SaveManager.AfterLoad += value;
+ remove => SaveAnywhere.Instance.SaveManager.AfterLoad -= value;
}
- public void addBeforeSaveEvent(string ID, Action BeforeSave) {
- SaveAnywhere.Instance.SaveManager.beforeCustomSavingBegins.Add(ID, BeforeSave);
+ public void addBeforeSaveEvent(string id, Action beforeSave)
+ {
+ SaveAnywhere.Instance.SaveManager.BeforeCustomSavingBegins.Add(id, beforeSave);
}
- public void removeBeforeSaveEvent(string ID, Action BeforeSave) {
- SaveAnywhere.Instance.SaveManager.beforeCustomSavingBegins.Remove(ID);
+ public void removeBeforeSaveEvent(string id, Action beforeSave)
+ {
+ SaveAnywhere.Instance.SaveManager.BeforeCustomSavingBegins.Remove(id);
}
- public void addAfterSaveEvent(string ID, Action AfterSave) {
- SaveAnywhere.Instance.SaveManager.afterCustomSavingCompleted.Add(ID, AfterSave);
+ public void addAfterSaveEvent(string id, Action afterSave)
+ {
+ SaveAnywhere.Instance.SaveManager.AfterCustomSavingCompleted.Add(id, afterSave);
}
- public void removeAfterSaveEvent(string ID, Action AfterSave) {
- SaveAnywhere.Instance.SaveManager.afterCustomSavingCompleted.Remove(ID);
+ public void removeAfterSaveEvent(string id, Action afterSave)
+ {
+ SaveAnywhere.Instance.SaveManager.AfterCustomSavingCompleted.Remove(id);
}
- public void addAfterLoadEvent(string ID, Action AfterLoad) {
- SaveAnywhere.Instance.SaveManager.afterSaveLoaded.Add(ID, AfterLoad);
+ public void addAfterLoadEvent(string id, Action afterLoad)
+ {
+ SaveAnywhere.Instance.SaveManager.AfterSaveLoaded.Add(id, afterLoad);
}
- public void removeAfterLoadEvent(string ID, Action AfterLoad) {
- SaveAnywhere.Instance.SaveManager.afterSaveLoaded.Remove(ID);
+ public void removeAfterLoadEvent(string id, Action afterLoad)
+ {
+ SaveAnywhere.Instance.SaveManager.AfterSaveLoaded.Remove(id);
}
}
}
\ No newline at end of file
diff --git a/Framework/SaveManager.cs b/Framework/SaveManager.cs
index ade244f..acef375 100644
--- a/Framework/SaveManager.cs
+++ b/Framework/SaveManager.cs
@@ -2,129 +2,137 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using Force.DeepCloner;
using Microsoft.Xna.Framework;
using SaveAnywhere.Framework.Model;
using StardewModdingAPI;
using StardewValley;
-namespace SaveAnywhere.Framework {
- public class SaveManager {
- private readonly IModHelper Helper;
- private readonly Action OnLoaded;
- private readonly IReflectionHelper Reflection;
- public Dictionary afterCustomSavingCompleted;
- public Dictionary afterSaveLoaded;
- public Dictionary beforeCustomSavingBegins;
- private NewSaveGameMenuV2 currentSaveMenu;
- private bool WaitingToSave;
-
- public SaveManager(IModHelper helper, IReflectionHelper reflection, Action onLoaded) {
- Helper = helper;
- Reflection = reflection;
+namespace SaveAnywhere.Framework
+{
+ public class SaveManager
+ {
+ private readonly IModHelper _helper;
+ private readonly Action _onLoaded;
+ public readonly Dictionary AfterCustomSavingCompleted;
+ public readonly Dictionary AfterSaveLoaded;
+ public readonly Dictionary BeforeCustomSavingBegins;
+ private NewSaveGameMenuV2 _currentSaveMenu;
+ private bool _waitingToSave;
+
+ public SaveManager(IModHelper helper, Action onLoaded)
+ {
+ _helper = helper;
+ _onLoaded = onLoaded;
// OnLoaded = onLoaded;
- beforeCustomSavingBegins = new Dictionary();
- afterCustomSavingCompleted = new Dictionary();
- afterSaveLoaded = new Dictionary();
+ BeforeCustomSavingBegins = new Dictionary();
+ AfterCustomSavingCompleted = new Dictionary();
+ AfterSaveLoaded = new Dictionary();
}
private string RelativeDataPath => Path.Combine("data", Constants.SaveFolderName + ".json");
- public event EventHandler beforeSave;
+ public event EventHandler BeforeSave;
+
+ public event EventHandler AfterSave;
- public event EventHandler afterSave;
+ public event EventHandler AfterLoad;
- public event EventHandler afterLoad;
- private void empty(object o, EventArgs args) { }
- public void Update() {
- if (!WaitingToSave || Game1.activeClickableMenu != null)
+ public void Update()
+ {
+ if (!_waitingToSave || Game1.activeClickableMenu != null)
return;
- currentSaveMenu = new NewSaveGameMenuV2();
- currentSaveMenu.SaveComplete += CurrentSaveMenu_SaveComplete;
- Game1.activeClickableMenu = currentSaveMenu;
- WaitingToSave = false;
+ _currentSaveMenu = new NewSaveGameMenuV2();
+ _currentSaveMenu.SaveComplete += CurrentSaveMenu_SaveComplete;
+ Game1.activeClickableMenu = _currentSaveMenu;
+ _waitingToSave = false;
}
- private void CurrentSaveMenu_SaveComplete(object sender, EventArgs e) {
- currentSaveMenu.SaveComplete -= CurrentSaveMenu_SaveComplete;
- currentSaveMenu = null;
+ private void CurrentSaveMenu_SaveComplete(object sender, EventArgs e)
+ {
+ _currentSaveMenu.SaveComplete -= CurrentSaveMenu_SaveComplete;
+ _currentSaveMenu = null;
SaveAnywhere.RestoreMonsters();
- if (afterSave != null)
- afterSave(this, EventArgs.Empty);
- foreach (var keyValuePair in afterCustomSavingCompleted)
+ if (AfterSave != null)
+ AfterSave(this, EventArgs.Empty);
+ foreach (var keyValuePair in AfterCustomSavingCompleted)
keyValuePair.Value();
}
- public void ClearData() {
- if (File.Exists(Path.Combine(Helper.DirectoryPath, RelativeDataPath)))
- File.Delete(Path.Combine(Helper.DirectoryPath, RelativeDataPath));
+ public void ClearData()
+ {
+ if (File.Exists(Path.Combine(_helper.DirectoryPath, RelativeDataPath)))
+ File.Delete(Path.Combine(_helper.DirectoryPath, RelativeDataPath));
RemoveLegacyDataForThisPlayer();
}
- public bool saveDataExists() {
- return File.Exists(Path.Combine(Helper.DirectoryPath, RelativeDataPath));
+ public bool saveDataExists()
+ {
+ return File.Exists(Path.Combine(_helper.DirectoryPath, RelativeDataPath));
}
- public void BeginSaveData() {
- if (beforeSave != null)
- beforeSave(this, EventArgs.Empty);
- foreach (var customSavingBegin in beforeCustomSavingBegins)
+ public void BeginSaveData()
+ {
+ if (BeforeSave != null)
+ BeforeSave(this, EventArgs.Empty);
+ foreach (var customSavingBegin in BeforeCustomSavingBegins)
customSavingBegin.Value();
SaveAnywhere.Instance.cleanMonsters();
var farm = Game1.getFarm();
- if (farm.getShippingBin(Game1.player) != null) {
+ if (farm.getShippingBin(Game1.player) != null)
+ {
Game1.activeClickableMenu = new NewShippingMenuV2(farm.getShippingBin(Game1.player));
farm.lastItemShipped = null;
- WaitingToSave = true;
+ _waitingToSave = true;
}
- else {
- currentSaveMenu = new NewSaveGameMenuV2();
- currentSaveMenu.SaveComplete += CurrentSaveMenu_SaveComplete;
- Game1.activeClickableMenu = currentSaveMenu;
+ else
+ {
+ _currentSaveMenu = new NewSaveGameMenuV2();
+ _currentSaveMenu.SaveComplete += CurrentSaveMenu_SaveComplete;
+ Game1.activeClickableMenu = _currentSaveMenu;
}
+
var drink = Game1.buffsDisplay.drink;
BuffData drinkdata = null;
if (drink != null)
- {
drinkdata = new BuffData(
drink.displaySource,
drink.source,
drink.millisecondsDuration,
drink.buffAttributes
);
- }
var food = Game1.buffsDisplay.food;
BuffData fooddata = null;
if (food != null)
- {
fooddata = new BuffData(
food.displaySource,
food.source,
food.millisecondsDuration,
food.buffAttributes
);
- }
- Helper.Data.WriteJsonFile(RelativeDataPath, new PlayerData {
+ _helper.Data.WriteJsonFile(RelativeDataPath, new PlayerData
+ {
Time = Game1.timeOfDay,
- otherBuffs = GetotherBuffs().ToArray(),
- drinkBuff = drinkdata,
- foodBuff = fooddata,
- Position = GetPosition(),
+ OtherBuffs = GetotherBuffs().ToArray(),
+ DrinkBuff = drinkdata,
+ FoodBuff = fooddata,
+ Position = GetPosition().ToArray(),
IsCharacterSwimming = Game1.player.swimming.Value
});
RemoveLegacyDataForThisPlayer();
}
- public void LoadData() {
- var data = Helper.Data.ReadJsonFile(RelativeDataPath);
+ public void LoadData()
+ {
+ var data = _helper.Data.ReadJsonFile(RelativeDataPath);
if (data == null)
return;
- SetPositions(data.Position);
- if (data.otherBuffs != null)
- {
- foreach (var buff in data.otherBuffs)
+ SetPositions(data.Position, data.Time);
+ if (data.OtherBuffs != null)
+ foreach (var buff in data.OtherBuffs)
{
var atts = buff.Attributes;
Game1.buffsDisplay.addOtherBuff(new Buff(atts[0],
@@ -143,10 +151,10 @@ public void LoadData() {
buff.Source,
buff.DisplaySource));
}
- }
- var datadrink = data.drinkBuff;
- var datafood = data.foodBuff;
-
+
+ var datadrink = data.DrinkBuff;
+ var datafood = data.FoodBuff;
+
if (datadrink != null)
{
var atts = datadrink.Attributes;
@@ -166,6 +174,7 @@ public void LoadData() {
datadrink.Source,
datadrink.DisplaySource));
}
+
if (datafood != null)
{
var atts = datafood.Attributes;
@@ -183,39 +192,47 @@ public void LoadData() {
atts[11],
datafood.MillisecondsDuration * 10 / 7000,
datafood.Source,
- datafood.DisplaySource),datafood.MillisecondsDuration);
+ datafood.DisplaySource), datafood.MillisecondsDuration);
}
+
ResumeSwimming(data);
- var onLoaded = OnLoaded;
+ var onLoaded = _onLoaded;
if (onLoaded != null)
onLoaded();
- if (afterLoad != null)
- afterLoad(this, EventArgs.Empty);
- foreach (var keyValuePair in afterSaveLoaded)
+ if (AfterLoad != null)
+ AfterLoad(this, EventArgs.Empty);
+ foreach (var keyValuePair in AfterSaveLoaded)
keyValuePair.Value();
- SafelySetTime(data.Time);
}
- public void ResumeSwimming(PlayerData data) {
- try {
+ private void ResumeSwimming(PlayerData data)
+ {
+ try
+ {
if (!data.IsCharacterSwimming)
return;
Game1.player.changeIntoSwimsuit();
Game1.player.swimming.Value = true;
}
- catch { }
+ catch
+ {
+ // ignored
+ }
}
- private IEnumerable GetotherBuffs() {
- foreach (var buff in Game1.buffsDisplay.otherBuffs) {
+
+ private IEnumerable GetotherBuffs()
+ {
+ foreach (var buff in Game1.buffsDisplay.otherBuffs)
yield return new BuffData(
buff.displaySource,
- buff.source,
+ buff.source,
buff.millisecondsDuration,
buff.buffAttributes
);
- }
}
- private PositionData GetPosition() {
+
+ private IEnumerable GetPosition()
+ {
var player = Game1.player;
var name1 = player.Name;
var map1 = player.currentLocation.uniqueName.Value;
@@ -223,30 +240,74 @@ private PositionData GetPosition() {
map1 = player.currentLocation.Name;
var tile1 = player.getTileLocationPoint();
int facingDirection1 = player.facingDirection;
- return new PositionData(name1, map1, tile1.X, tile1.Y, facingDirection1);
+ yield return new PositionData(name1, map1, tile1.X, tile1.Y, facingDirection1);
+ foreach (var allCharacter in Utility.getAllCharacters())
+ if (allCharacter.isVillager())
+ yield return new PositionData(allCharacter.Name, allCharacter.currentLocation.Name,
+ allCharacter.getTileLocationPoint().X, allCharacter.getTileLocationPoint().Y,
+ allCharacter.facingDirection);
}
- private void SetPositions(PositionData position) {
+ private void SetPositions(PositionData[] position, int time)
+ {
+ Game1.player.faceDirection(position[0].FacingDirection);
+ foreach (var allCharacter in Utility.getAllCharacters())
+ {
+ allCharacter.dayUpdate(Game1.dayOfMonth);
+ if (allCharacter.isVillager())
+ {
+ var pos = position.FirstOrDefault(p => p.Name == allCharacter.Name);
+ if (pos != null)
+ {
+ Game1.xLocationAfterWarp = pos.X;
+ Game1.yLocationAfterWarp = pos.Y;
+ Game1.facingDirectionAfterWarp = pos.FacingDirection;
+ Game1.warpCharacter(allCharacter, pos.Map, new Point(pos.X, pos.Y));
+ allCharacter.faceDirection(pos.FacingDirection);
+ var newSchedule = allCharacter.getSchedule(Game1.dayOfMonth).DeepClone();
+ if (newSchedule != null)
+ {
+ var dest = allCharacter.getSchedule(Game1.dayOfMonth)
+ .LastOrDefault(data => data.Key < time);
- Game1.player.previousLocationName = Game1.player.currentLocation.Name;
- Game1.xLocationAfterWarp = position.X;
- Game1.yLocationAfterWarp = position.Y;
- Game1.facingDirectionAfterWarp = position.FacingDirection;
- Game1.fadeScreenToBlack();
- Game1.warpFarmer(position.Map, position.X, position.Y, false);
- Game1.player.faceDirection(position.FacingDirection);
-
+ if (dest.Key != 0)
+ {
+ var destMap = allCharacter.currentLocation.Name;
+ foreach (var point in dest.Value.route)
+ {
+ var warp = Game1.getLocationFromName(destMap).warps
+ .FirstOrDefault(data => data.X == point.X && data.Y == point.Y);
+ if (warp != null) destMap = warp.TargetName;
+ }
- foreach (var allCharacter in Utility.getAllCharacters()) {
- allCharacter.dayUpdate(Game1.dayOfMonth);
- }
- }
+ newSchedule.Remove(dest.Key);
+ newSchedule.Add(time,
+ allCharacter.pathfindToNextScheduleLocation(pos.Map, pos.X, pos.Y, destMap,
+ dest.Value.route.Last().X, dest.Value.route.Last().Y,
+ dest.Value.facingDirection,
+ dest.Value.endOfRouteBehavior, dest.Value.endOfRouteMessage));
+ allCharacter.Schedule = newSchedule;
+ }
+ }
+ }
+
+ Game1.player.previousLocationName = Game1.player.currentLocation.Name;
+ Game1.xLocationAfterWarp = position[0].X;
+ Game1.yLocationAfterWarp = position[0].Y;
+ Game1.facingDirectionAfterWarp = position[0].FacingDirection;
+ Game1.fadeScreenToBlack();
+ Game1.warpFarmer(position[0].Map, position[0].X, position[0].Y, false);
+ }
+ }
+ SafelySetTime(time);
+ }
- private void RemoveLegacyDataForThisPlayer() {
- var directoryInfo1 = new DirectoryInfo(Path.Combine(Helper.DirectoryPath, "Save_Data"));
+ private void RemoveLegacyDataForThisPlayer()
+ {
+ var directoryInfo1 = new DirectoryInfo(Path.Combine(_helper.DirectoryPath, "Save_Data"));
var directoryInfo2 = new DirectoryInfo(Path.Combine(directoryInfo1.FullName, Game1.player.Name));
if (directoryInfo2.Exists)
directoryInfo2.Delete(true);
@@ -254,24 +315,21 @@ private void RemoveLegacyDataForThisPlayer() {
return;
directoryInfo1.Delete(true);
}
-
+
private void SafelySetTime(int time)
{
// transition to new time
- int intervals = Utility.CalculateMinutesBetweenTimes(Game1.timeOfDay, time) / 10;
+ var intervals = Utility.CalculateMinutesBetweenTimes(Game1.timeOfDay, time) / 10;
if (intervals > 0)
- {
- for (int i = 0; i < intervals; i++)
+ for (var i = 0; i < intervals; i++)
Game1.performTenMinuteClockUpdate();
- }
else if (intervals < 0)
- {
- for (int i = 0; i > intervals; i--)
+ for (var i = 0; i > intervals; i--)
{
- Game1.timeOfDay = Utility.ModifyTime(Game1.timeOfDay, -20); // offset 20 mins so game updates to next interval
+ Game1.timeOfDay =
+ Utility.ModifyTime(Game1.timeOfDay, -20); // offset 20 mins so game updates to next interval
Game1.performTenMinuteClockUpdate();
}
- }
// reset ambient light
// White is the default non-raining color. If it's raining or dark out, UpdateGameClock
diff --git a/README.md b/README.md
index 3578ea2..668800f 100644
--- a/README.md
+++ b/README.md
@@ -16,13 +16,16 @@ Run the game using SMAPI.
### How To Use
-Press K to save anywhere. Edit the config.json file in a text editor to change the key (it will appear once you run the game), if you have GMCM use it instead.
+Press K to save anywhere. Edit the config.json file in a text editor to change the key (it will appear once you run the
+game), if you have GMCM use it instead.
#### Created by Omegasis, Aredjay, and RealSweetPanda
### Notes
-The mod should now work with map extension mods, modded characters, modded items, etc in the newest update. If it doesn't, report it and we can fix it.
+The mod should now work with map extension mods, modded characters, modded items, etc in the newest update. If it
+doesn't, report it and we can fix it.
-As much as we want to make the mod stable it can always This mod might crash and cause issues. just be aware and if it occurs just report it and we will fix it!
+As much as we want to make the mod stable it can always This mod might crash and cause issues. just be aware and if it
+occurs just report it and we will fix it!
diff --git a/SaveAnywhere.cs b/SaveAnywhere.cs
index 3c4e22e..1c18b58 100644
--- a/SaveAnywhere.cs
+++ b/SaveAnywhere.cs
@@ -8,25 +8,22 @@
using StardewValley.Characters;
using StardewValley.Monsters;
-namespace SaveAnywhere {
- public class SaveAnywhere : Mod {
+namespace SaveAnywhere
+{
+ public class SaveAnywhere : Mod
+ {
public static SaveAnywhere Instance;
- public static IModHelper ModHelper;
- public static IMonitor ModMonitor;
- private readonly IDictionary NpcSchedules = new Dictionary();
- private ModConfig Config;
- private bool customMenuOpen;
- private bool firstLoad;
- public bool IsCustomSaving;
- private Dictionary> monsters;
+ private ModConfig _config;
+ private Dictionary> _monsters;
public SaveManager SaveManager;
- private bool ShouldResetSchedules;
+
- public override void Entry(IModHelper helper) {
- Config = helper.ReadConfig();
- SaveManager = new SaveManager(Helper, Helper.Reflection, () => ShouldResetSchedules = true);
+ public override void Entry(IModHelper helper)
+ {
+ _config = helper.ReadConfig();
+ SaveManager = new SaveManager(Helper, null);
helper.Events.GameLoop.SaveLoaded += OnSaveLoaded;
helper.Events.GameLoop.UpdateTicked += OnUpdateTicked;
helper.Events.GameLoop.DayEnding += OnDayEnded;
@@ -34,48 +31,43 @@ public override void Entry(IModHelper helper) {
helper.Events.GameLoop.ReturnedToTitle += GameLoop_ReturnedToTitle;
helper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged;
Helper.Events.GameLoop.GameLaunched += BuildConfigMenu;
- ModHelper = helper;
- ModMonitor = Monitor;
- customMenuOpen = false;
Instance = this;
- firstLoad = false;
-
}
private void BuildConfigMenu(object sender, GameLaunchedEventArgs e)
{
// get Generic Mod Config Menu's API (if it's installed)
- var configMenu = this.Helper.ModRegistry.GetApi("spacechase0.GenericModConfigMenu");
+ var configMenu = Helper.ModRegistry.GetApi("spacechase0.GenericModConfigMenu");
if (configMenu is null) return;
// register mod
configMenu.Register(
- mod: this.ModManifest,
- reset: () => this.Config = new ModConfig(),
- save: () => this.Helper.WriteConfig(this.Config)
+ ModManifest,
+ () => _config = new ModConfig(),
+ () => Helper.WriteConfig(_config)
);
- configMenu.AddSectionTitle(this.ModManifest, () => "Key Bindings");
+ configMenu.AddSectionTitle(ModManifest, () => "Key Bindings");
configMenu.AddKeybind(
- mod: this.ModManifest,
+ ModManifest,
name: () => "Save Key",
- getValue: () => this.Config.SaveKey,
- setValue: value => this.Config.SaveKey = value
+ getValue: () => _config.SaveKey,
+ setValue: value => _config.SaveKey = value
);
}
- private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { }
+ private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e)
+ {
+ }
- private void GameLoop_ReturnedToTitle(object sender, ReturnedToTitleEventArgs e) {
- firstLoad = false;
+ private void GameLoop_ReturnedToTitle(object sender, ReturnedToTitleEventArgs e)
+ {
}
- private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) {
+ private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
+ {
// ShouldResetSchedules = true;
- if (SaveManager.saveDataExists())
- {
- SaveManager.LoadData();
- }
+ if (SaveManager.saveDataExists()) SaveManager.LoadData();
}
private void OnDayEnded(object sender, DayEndingEventArgs e)
@@ -83,57 +75,67 @@ private void OnDayEnded(object sender, DayEndingEventArgs e)
SaveManager.ClearData();
}
- private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) {
- if (Context.IsWorldReady) {
+ private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
+ {
+ if (Context.IsWorldReady)
+ {
if (!Game1.player.IsMainPlayer)
return;
SaveManager.Update();
}
}
- public void cleanMonsters() {
- monsters = new Dictionary>();
- foreach (var location in Game1.locations) {
- monsters.Add(location, new List());
+ public void cleanMonsters()
+ {
+ _monsters = new Dictionary>();
+ foreach (var location in Game1.locations)
+ {
+ _monsters.Add(location, new List());
foreach (var character in location.characters)
- if (character is Monster monster) {
+ if (character is Monster monster)
+ {
Monitor.Log(character.Name);
- monsters[location].Add(monster);
+ _monsters[location].Add(monster);
}
- foreach (var monster in monsters[location])
+ foreach (var monster in _monsters[location])
location.characters.Remove(monster);
}
}
- public static void RestoreMonsters() {
- foreach (var monster1 in Instance.monsters)
+ public static void RestoreMonsters()
+ {
+ foreach (var monster1 in Instance._monsters)
foreach (var monster2 in monster1.Value)
monster1.Key.addCharacter(monster2);
- Instance.monsters.Clear();
+ Instance._monsters.Clear();
}
- private void OnButtonPressed(object sender, ButtonPressedEventArgs e) {
- if (!Context.IsPlayerFree || e.Button != Config.SaveKey || Game1.eventUp || Game1.isFestival())
+ private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
+ {
+ if (!Context.IsPlayerFree || e.Button != _config.SaveKey || Game1.eventUp || Game1.isFestival())
return;
- if (Game1.client == null) {
- if (Game1.player.currentLocation.getCharacters().OfType().Any()) {
+ if (Game1.client == null)
+ {
+ if (Game1.player.currentLocation.getCharacters().OfType().Any())
+ {
Game1.addHUDMessage(new HUDMessage("The spirits don't want you to save here.", 3));
}
- else {
- IsCustomSaving = true;
+ else
+ {
SaveManager.BeginSaveData();
-
}
}
- else {
+ else
+ {
Game1.addHUDMessage(new HUDMessage("Only server hosts can save anywhere.", 3));
}
}
-
- public override object GetApi() {
- return new SaveAnywhereAPI();
+
+ public override object GetApi()
+ {
+ return new SaveAnywhereApi();
}
}
}
\ No newline at end of file
diff --git a/SaveAnywhere.csproj b/SaveAnywhere.csproj
index e35f0c4..6704000 100644
--- a/SaveAnywhere.csproj
+++ b/SaveAnywhere.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/manifest.json b/manifest.json
index aec3c38..1e5ef1a 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,10 +1,13 @@
{
- "Name": "Save Anywhere",
+ "Name": "Save Anywhere Redux",
"Author": "Open Source",
- "Version": "3.1.0",
+ "Version": "3.2.0",
"Description": "This mod allows you to save your game at any time, anywhere.",
"UniqueID": "Omegasis.SaveAnywhere",
"EntryDll": "SaveAnywhere.dll",
"MinimumApiVersion": "3.0.0",
- "UpdateKeys": [ "Nexus:8386", "GitHub:RealSweetPanda/SaveAnywhere" ]
+ "UpdateKeys": [
+ "Nexus:8386",
+ "GitHub:RealSweetPanda/SaveAnywhereRedux"
+ ]
}
\ No newline at end of file