Merge pull request #59 from janavarro95/SMAPI3.0
Finally commited work for fixes to Happy Birthday and Save Anywhere.
This commit is contained in:
commit
e6843e7094
|
@ -2034,6 +2034,7 @@ namespace Omegasis.HappyBirthday
|
|||
public static string GetTranslatedString(string key)
|
||||
{
|
||||
StardewValley.LocalizedContentManager.LanguageCode code = HappyBirthday.Config.translationInfo.TranslationCodes[HappyBirthday.Config.translationInfo.CurrentTranslation];
|
||||
if (string.IsNullOrEmpty(key)) return "";
|
||||
string value = HappyBirthday.Instance.messages.translatedStrings[code][key];
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
|
|
@ -115,69 +115,57 @@ namespace Omegasis.HappyBirthday
|
|||
{
|
||||
if (e.NewLocation == Game1.getLocationFromName("CommunityCenter"))
|
||||
{
|
||||
EventHelper eve=this.eventManager.getEvent("CommunityCenterBirthday");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("CommunityCenterBirthday");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("Trailer"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Penny");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Penny");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("Trailer_Big"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Penny_BigHome");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Penny_BigHome");
|
||||
}
|
||||
|
||||
if (e.NewLocation == Game1.getLocationFromName("ScienceHouse"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Maru");
|
||||
eve.startEventAtLocationifPossible();
|
||||
EventHelper eve2 = this.eventManager.getEvent("BirthdayDating:Sebastian");
|
||||
eve2.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Maru");
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Sebastian");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("LeahHouse"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Leah");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Leah");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("SeedShop"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Abigail");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Abigail");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("HaleyHouse"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Emily");
|
||||
eve.startEventAtLocationifPossible();
|
||||
EventHelper eve2 = this.eventManager.getEvent("BirthdayDating:Haley");
|
||||
eve2.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Emily");
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Haley");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("HarveyRoom"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Harvey");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Harvey");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("ElliottHouse"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Elliott");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Elliott");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("SamHouse"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Sam");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Sam");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("JoshHouse"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Alex");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Alex");
|
||||
}
|
||||
if (e.NewLocation == Game1.getLocationFromName("AnimalShop"))
|
||||
{
|
||||
EventHelper eve = this.eventManager.getEvent("BirthdayDating:Shane");
|
||||
eve.startEventAtLocationifPossible();
|
||||
this.eventManager.startEventAtLocationIfPossible("BirthdayDating:Shane");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
|
||||
|
@ -601,58 +589,6 @@ namespace Omegasis.HappyBirthday
|
|||
this.eventManager.addEvent(birthdayDating_Sam);
|
||||
this.eventManager.addEvent(birthdayDating_Alex);
|
||||
this.eventManager.addEvent(birthdayDating_Shane);
|
||||
if (Game1.player.eventsSeen.Contains(communityCenterJunimoBirthday.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(communityCenterJunimoBirthday.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Penny.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Penny.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Maru.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Maru.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Sebastian.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Sebastian.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Leah.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Leah.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Abigail.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Abigail.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Emily.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Emily.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Haley.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Haley.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Harvey.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Harvey.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Elliott.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Elliott.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Sam.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Sam.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Alex.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Alex.getEventID()); //Repeat the event.
|
||||
}
|
||||
if (Game1.player.eventsSeen.Contains(birthdayDating_Shane.getEventID()))
|
||||
{
|
||||
Game1.player.eventsSeen.Remove(birthdayDating_Shane.getEventID()); //Repeat the event.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||
|
@ -683,6 +619,13 @@ namespace Omegasis.HappyBirthday
|
|||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.eventManager != null)
|
||||
{
|
||||
this.eventManager.update();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.HasChosenBirthday && Game1.activeClickableMenu == null && Game1.player.Name.ToLower() != "unnamed farmhand")
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"Name": "Happy Birthday",
|
||||
"Author": "Alpha_Omegasis",
|
||||
"Version": "1.10.4",
|
||||
"Version": "1.10.5",
|
||||
"Description": "Adds the farmer's birthday to the game.",
|
||||
"UniqueID": "Omegasis.HappyBirthday",
|
||||
"EntryDll": "HappyBirthday.dll",
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
}
|
||||
else
|
||||
{
|
||||
NewSaveGameMenu.saveClientOptions();
|
||||
NewSaveGameMenuV2.saveClientOptions();
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
}
|
||||
}
|
||||
|
||||
private static void saveClientOptions()
|
||||
public static void saveClientOptions()
|
||||
{
|
||||
StartupPreferences startupPreferences = new StartupPreferences();
|
||||
int num1 = 0;
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewValley;
|
||||
using StardewValley.BellsAndWhistles;
|
||||
using StardewValley.Menus;
|
||||
|
||||
namespace Omegasis.SaveAnywhere.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a modified version of the stardew valley save game menu made by ConcernedApe with modifications made by myself.. All rights go to him.
|
||||
/// </summary>
|
||||
public class NewSaveGameMenuV2:IClickableMenu
|
||||
{
|
||||
public event EventHandler SaveComplete;
|
||||
|
||||
private int completePause = -1;
|
||||
private int margin = 500;
|
||||
private StringBuilder _stringBuilder = new StringBuilder();
|
||||
private float _ellipsisDelay = 0.5f;
|
||||
private Stopwatch stopwatch;
|
||||
private IEnumerator<int> loader;
|
||||
public bool quit;
|
||||
public bool hasDrawn;
|
||||
private SparklingText saveText;
|
||||
private int _ellipsisCount;
|
||||
protected bool _hasSentFarmhandData;
|
||||
|
||||
public Multiplayer multiplayer;
|
||||
|
||||
public NewSaveGameMenuV2()
|
||||
{
|
||||
this.saveText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11378"), Color.LimeGreen, Color.Black * (1f / 1000f), false, 0.1, 1500, 32, 500, 1f);
|
||||
this._hasSentFarmhandData = false;
|
||||
|
||||
Type type = typeof(Game1);
|
||||
FieldInfo info = type.GetField("multiplayer", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
this.multiplayer = (Multiplayer)info.GetValue(StardewValley.Program.gamePtr);
|
||||
|
||||
//this.multiplayer = SaveAnywhere.ModHelper.Reflection.GetField<Multiplayer>(, "multiplayer", true).GetValue();
|
||||
}
|
||||
|
||||
public override void receiveRightClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
}
|
||||
|
||||
public void complete()
|
||||
{
|
||||
Game1.playSound("money");
|
||||
this.completePause = 1500;
|
||||
this.loader = (IEnumerator<int>)null;
|
||||
Game1.game1.IsSaving = false;
|
||||
if (!Game1.IsMasterGame || Game1.newDaySync == null || Game1.newDaySync.hasSaved())
|
||||
return;
|
||||
Game1.newDaySync.flagSaved();
|
||||
|
||||
SaveComplete.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public override bool readyToClose()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void update(GameTime time)
|
||||
{
|
||||
if (this.quit)
|
||||
{
|
||||
if (!Game1.activeClickableMenu.Equals((object)this) || !Game1.PollForEndOfNewDaySync())
|
||||
return;
|
||||
Game1.exitActiveMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.update(time);
|
||||
if (Game1.client != null && Game1.client.timedOut)
|
||||
{
|
||||
this.quit = true;
|
||||
if (!Game1.activeClickableMenu.Equals((object)this))
|
||||
return;
|
||||
Game1.exitActiveMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
double ellipsisDelay = (double)this._ellipsisDelay;
|
||||
TimeSpan elapsedGameTime = time.ElapsedGameTime;
|
||||
double totalSeconds = elapsedGameTime.TotalSeconds;
|
||||
this._ellipsisDelay = (float)(ellipsisDelay - totalSeconds);
|
||||
if ((double)this._ellipsisDelay <= 0.0)
|
||||
{
|
||||
this._ellipsisDelay += 0.75f;
|
||||
++this._ellipsisCount;
|
||||
if (this._ellipsisCount > 3)
|
||||
this._ellipsisCount = 1;
|
||||
}
|
||||
if (this.loader != null)
|
||||
{
|
||||
this.loader.MoveNext();
|
||||
if (this.loader.Current >= 100)
|
||||
{
|
||||
int margin = this.margin;
|
||||
elapsedGameTime = time.ElapsedGameTime;
|
||||
int milliseconds = elapsedGameTime.Milliseconds;
|
||||
this.margin = margin - milliseconds;
|
||||
if (this.margin <= 0)
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
else if (this.hasDrawn && this.completePause == -1)
|
||||
{
|
||||
if (Game1.IsMasterGame)
|
||||
{
|
||||
if (Game1.saveOnNewDay)
|
||||
{
|
||||
Game1.player.team.endOfNightStatus.UpdateState("ready");
|
||||
if (Game1.newDaySync != null)
|
||||
{
|
||||
if (Game1.newDaySync.readyForSave())
|
||||
{
|
||||
this.multiplayer.saveFarmhands();
|
||||
Game1.game1.IsSaving = true;
|
||||
this.loader = SaveGame.Save();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.multiplayer.saveFarmhands();
|
||||
Game1.game1.IsSaving = true;
|
||||
this.loader = SaveGame.Save();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.margin = -1;
|
||||
if (Game1.newDaySync != null)
|
||||
{
|
||||
if (Game1.newDaySync.readyForSave())
|
||||
{
|
||||
Game1.game1.IsSaving = true;
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this._hasSentFarmhandData)
|
||||
{
|
||||
this._hasSentFarmhandData = true;
|
||||
this.multiplayer.sendFarmhand();
|
||||
}
|
||||
this.multiplayer.UpdateLate(false);
|
||||
Program.sdk.Update();
|
||||
this.multiplayer.UpdateEarly();
|
||||
if (Game1.newDaySync != null)
|
||||
{
|
||||
Game1.newDaySync.readyForSave();
|
||||
}
|
||||
Game1.player.team.endOfNightStatus.UpdateState("ready");
|
||||
if (Game1.newDaySync != null)
|
||||
{
|
||||
if (Game1.newDaySync.hasSaved())
|
||||
{
|
||||
//SaveGameMenu.saveClientOptions();
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.completePause < 0)
|
||||
return;
|
||||
int completePause = this.completePause;
|
||||
elapsedGameTime = time.ElapsedGameTime;
|
||||
int milliseconds1 = elapsedGameTime.Milliseconds;
|
||||
this.completePause = completePause - milliseconds1;
|
||||
this.saveText.update(time);
|
||||
if (this.completePause >= 0)
|
||||
return;
|
||||
this.quit = true;
|
||||
this.completePause = -9999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveClientOptions()
|
||||
{
|
||||
StartupPreferences startupPreferences = new StartupPreferences();
|
||||
startupPreferences.loadPreferences(false, true);
|
||||
startupPreferences.clientOptions = Game1.options;
|
||||
startupPreferences.savePreferences(false);
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
base.draw(b);
|
||||
Vector2 vector2 = Utility.makeSafe(new Vector2(64f, (float)(Game1.viewport.Height - 64)), new Vector2(64f, 64f));
|
||||
bool flag = false;
|
||||
if (this.completePause >= 0)
|
||||
{
|
||||
if (Game1.saveOnNewDay)
|
||||
this.saveText.draw(b, vector2);
|
||||
}
|
||||
else if (this.margin < 0 || Game1.IsClient)
|
||||
{
|
||||
if (Game1.IsMultiplayer)
|
||||
{
|
||||
this._stringBuilder.Clear();
|
||||
this._stringBuilder.Append(Game1.content.LoadString("Strings\\UI:ReadyCheck", (object)Game1.newDaySync.numReadyForSave(), (object)Game1.getOnlineFarmers().Count<Farmer>()));
|
||||
for (int index = 0; index < this._ellipsisCount; ++index)
|
||||
this._stringBuilder.Append(".");
|
||||
b.DrawString(Game1.dialogueFont, this._stringBuilder, vector2, Color.White);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
else if (!Game1.IsMultiplayer)
|
||||
{
|
||||
this._stringBuilder.Clear();
|
||||
this._stringBuilder.Append(Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11381"));
|
||||
for (int index = 0; index < this._ellipsisCount; ++index)
|
||||
this._stringBuilder.Append(".");
|
||||
b.DrawString(Game1.dialogueFont, this._stringBuilder, vector2, Color.White);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._stringBuilder.Clear();
|
||||
this._stringBuilder.Append(Game1.content.LoadString("Strings\\UI:ReadyCheck", (object)Game1.newDaySync.numReadyForSave(), (object)Game1.getOnlineFarmers().Count<Farmer>()));
|
||||
for (int index = 0; index < this._ellipsisCount; ++index)
|
||||
this._stringBuilder.Append(".");
|
||||
b.DrawString(Game1.dialogueFont, this._stringBuilder, vector2, Color.White);
|
||||
flag = true;
|
||||
}
|
||||
if (this.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, PlayerStatusList.HorizontalAlignment.Left, PlayerStatusList.VerticalAlignment.Bottom);
|
||||
this.hasDrawn = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Game1.game1.IsSaving = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,40 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
: base(items)
|
||||
{
|
||||
this.SavedYet = reflection.GetField<bool>(this, "savedYet");
|
||||
|
||||
|
||||
NetCollection<Item> shippingBin = Game1.getFarm().getShippingBin(Game1.player);
|
||||
if (Game1.player.useSeparateWallets || !Game1.player.useSeparateWallets && Game1.player.IsMainPlayer)
|
||||
{
|
||||
int num = 0;
|
||||
foreach (Item obj in shippingBin)
|
||||
{
|
||||
if (obj is Object)
|
||||
num += (obj as Object).sellToStorePrice(-1L) * obj.Stack;
|
||||
}
|
||||
Game1.player.Money += num;
|
||||
Game1.getFarm().getShippingBin(Game1.player).Clear();
|
||||
}
|
||||
|
||||
if (Game1.player.useSeparateWallets && Game1.player.IsMainPlayer)
|
||||
{
|
||||
foreach (Farmer allFarmhand in Game1.getAllFarmhands())
|
||||
{
|
||||
if (!allFarmhand.isActive() && !allFarmhand.isUnclaimedFarmhand)
|
||||
{
|
||||
int num = 0;
|
||||
foreach (Item obj in Game1.getFarm().getShippingBin(allFarmhand))
|
||||
{
|
||||
if (obj is Object)
|
||||
num += (obj as Object).sellToStorePrice(allFarmhand.UniqueMultiplayerID) * obj.Stack;
|
||||
}
|
||||
Game1.player.team.AddIndividualMoney(allFarmhand, num);
|
||||
Game1.getFarm().getShippingBin(allFarmhand).Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Overrides some base functionality of the shipping menu to enable proper closing.</summary>
|
||||
|
|
|
@ -0,0 +1,832 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Netcode;
|
||||
using StardewValley;
|
||||
using StardewValley.BellsAndWhistles;
|
||||
using StardewValley.Menus;
|
||||
|
||||
namespace Omegasis.SaveAnywhere.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// The stardew valley shipping menu that has been stripped of date changing features and the default saving menu.
|
||||
///
|
||||
/// Credits for the original code go to ConcernedApe with the edits made by me Omegasis.
|
||||
/// </summary>
|
||||
public class NewShippingMenuV2 : IClickableMenu
|
||||
{
|
||||
public int itemsPerCategoryPage = 9;
|
||||
public int currentPage = -1;
|
||||
public List<ClickableTextureComponent> categories = new List<ClickableTextureComponent>();
|
||||
private List<int> categoryTotals = new List<int>();
|
||||
private List<MoneyDial> categoryDials = new List<MoneyDial>();
|
||||
private Dictionary<Item, int> itemValues = new Dictionary<Item, int>();
|
||||
private List<List<Item>> categoryItems = new List<List<Item>>();
|
||||
private int introTimer = 3500;
|
||||
private int moonShake = -1;
|
||||
public List<TemporaryAnimatedSprite> animations = new List<TemporaryAnimatedSprite>();
|
||||
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;
|
||||
public int currentTab;
|
||||
public ClickableTextureComponent okButton;
|
||||
public ClickableTextureComponent forwardButton;
|
||||
public ClickableTextureComponent backButton;
|
||||
private int categoryLabelsWidth;
|
||||
private int plusButtonWidth;
|
||||
private int itemSlotWidth;
|
||||
private int itemAndPlusButtonWidth;
|
||||
private int totalWidth;
|
||||
private int centerX;
|
||||
private int centerY;
|
||||
private int outroFadeTimer;
|
||||
private int outroPauseBeforeDateChange;
|
||||
private int finalOutroTimer;
|
||||
private int smokeTimer;
|
||||
private int dayPlaqueY;
|
||||
private int timesPokedMoon;
|
||||
private float weatherX;
|
||||
private bool outro;
|
||||
private bool newDayPlaque;
|
||||
private bool savedYet;
|
||||
protected bool _hasFinished;
|
||||
|
||||
|
||||
|
||||
public NewShippingMenuV2(IList<Item> items)
|
||||
: base(0, 0, Game1.viewport.Width, Game1.viewport.Height, false)
|
||||
{
|
||||
Game1.player.team.endOfNightStatus.UpdateState("shipment");
|
||||
this.parseItems(items);
|
||||
if (!Game1.wasRainingYesterday)
|
||||
Game1.changeMusicTrack(Game1.currentSeason.Equals("summer") ? "nightTime" : "none", false, Game1.MusicContext.Default);
|
||||
this.categoryLabelsWidth = 512;
|
||||
this.plusButtonWidth = 40;
|
||||
this.itemSlotWidth = 96;
|
||||
this.itemAndPlusButtonWidth = this.plusButtonWidth + this.itemSlotWidth + 8;
|
||||
this.totalWidth = this.categoryLabelsWidth + this.itemAndPlusButtonWidth;
|
||||
this.centerX = Game1.viewport.Width / 2;
|
||||
this.centerY = Game1.viewport.Height / 2;
|
||||
this._hasFinished = false;
|
||||
int num = -1;
|
||||
for (int index = 0; index < 6; ++index)
|
||||
{
|
||||
List<ClickableTextureComponent> categories = this.categories;
|
||||
ClickableTextureComponent textureComponent = new ClickableTextureComponent("", new Rectangle(this.centerX + this.totalWidth / 2 - this.plusButtonWidth, this.centerY - 300 + index * 27 * 4, this.plusButtonWidth, 44), "", this.getCategoryName(index), Game1.mouseCursors, new Rectangle(392, 361, 10, 11), 4f, false);
|
||||
textureComponent.visible = index < 5 && this.categoryItems[index].Count > 0;
|
||||
textureComponent.myID = index;
|
||||
textureComponent.downNeighborID = index < 4 ? index + 1 : 101;
|
||||
textureComponent.upNeighborID = index > 0 ? num : -1;
|
||||
textureComponent.upNeighborImmutable = true;
|
||||
categories.Add(textureComponent);
|
||||
num = index >= 5 || this.categoryItems[index].Count <= 0 ? num : index;
|
||||
}
|
||||
this.dayPlaqueY = this.categories[0].bounds.Y - 128;
|
||||
Rectangle bounds = new Rectangle(this.centerX + this.totalWidth / 2 - this.itemAndPlusButtonWidth + 32, this.centerY + 300 - 64, 64, 64);
|
||||
ClickableTextureComponent textureComponent1 = new ClickableTextureComponent(Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11382"), bounds, (string)null, Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11382"), Game1.mouseCursors, new Rectangle(128, 256, 64, 64), 1f, false);
|
||||
textureComponent1.myID = 101;
|
||||
textureComponent1.upNeighborID = num;
|
||||
this.okButton = textureComponent1;
|
||||
if (Game1.options.gamepadControls)
|
||||
{
|
||||
Mouse.SetPosition(bounds.Center.X, bounds.Center.Y);
|
||||
Game1.InvalidateOldMouseMovement();
|
||||
Game1.lastCursorMotionWasMouse = false;
|
||||
}
|
||||
ClickableTextureComponent textureComponent2 = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + 32, this.yPositionOnScreen + this.height - 64, 48, 44), (string)null, "", Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f, false);
|
||||
textureComponent2.myID = 103;
|
||||
textureComponent2.rightNeighborID = -7777;
|
||||
this.backButton = textureComponent2;
|
||||
ClickableTextureComponent textureComponent3 = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width - 32 - 48, this.yPositionOnScreen + this.height - 64, 48, 44), (string)null, "", Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f, false);
|
||||
textureComponent3.myID = 102;
|
||||
textureComponent3.leftNeighborID = 103;
|
||||
this.forwardButton = textureComponent3;
|
||||
if (Game1.dayOfMonth == 25 && Game1.currentSeason.Equals("winter"))
|
||||
this.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(640, 800, 32, 16), 80f, 2, 1000, new Vector2((float)Game1.viewport.Width, (float)Game1.random.Next(0, 200)), false, false, 0.01f, 0.0f, Color.White, 4f, 0.0f, 0.0f, 0.0f, true)
|
||||
{
|
||||
motion = new Vector2(-4f, 0.0f),
|
||||
delayBeforeAnimationStart = 3000
|
||||
});
|
||||
Game1.stats.checkForShippingAchievements();
|
||||
if (!Game1.player.achievements.Contains(34) && Utility.hasFarmerShippedAllItems())
|
||||
Game1.getAchievement(34, true);
|
||||
this.RepositionItems();
|
||||
this.populateClickableComponentList();
|
||||
if (!Game1.options.SnappyMenus)
|
||||
return;
|
||||
this.snapToDefaultClickableComponent();
|
||||
}
|
||||
|
||||
public void RepositionItems()
|
||||
{
|
||||
this.centerX = Game1.viewport.Width / 2;
|
||||
this.centerY = Game1.viewport.Height / 2;
|
||||
for (int index = 0; index < 6; ++index)
|
||||
this.categories[index].bounds = new Rectangle(this.centerX + this.totalWidth / 2 - this.plusButtonWidth, this.centerY - 300 + index * 27 * 4, this.plusButtonWidth, 44);
|
||||
this.dayPlaqueY = this.categories[0].bounds.Y - 128;
|
||||
if (this.dayPlaqueY < 0)
|
||||
this.dayPlaqueY = -64;
|
||||
this.backButton.bounds.X = this.xPositionOnScreen + 32;
|
||||
this.backButton.bounds.Y = this.yPositionOnScreen + this.height - 64;
|
||||
this.forwardButton.bounds.X = this.xPositionOnScreen + this.width - 32 - 48;
|
||||
this.forwardButton.bounds.Y = this.yPositionOnScreen + this.height - 64;
|
||||
this.okButton.bounds = new Rectangle(this.centerX + this.totalWidth / 2 - this.itemAndPlusButtonWidth + 32, this.centerY + 300 - 64, 64, 64);
|
||||
this.itemsPerCategoryPage = (int)((double)(this.yPositionOnScreen + this.height - 64 - (this.yPositionOnScreen + 32)) / 68.0);
|
||||
if (this.currentPage < 0)
|
||||
return;
|
||||
this.currentTab = Utility.Clamp(this.currentTab, 0, (this.categoryItems[this.currentPage].Count - 1) / this.itemsPerCategoryPage);
|
||||
}
|
||||
|
||||
protected override void customSnapBehavior(int direction, int oldRegion, int oldID)
|
||||
{
|
||||
if (oldID != 103 || direction != 1 || !this.showForwardButton())
|
||||
return;
|
||||
this.currentlySnappedComponent = this.getComponentWithID(102);
|
||||
this.snapCursorToCurrentSnappedComponent();
|
||||
}
|
||||
|
||||
public override void snapToDefaultClickableComponent()
|
||||
{
|
||||
if (this.currentPage != -1)
|
||||
this.currentlySnappedComponent = this.getComponentWithID(103);
|
||||
else
|
||||
this.currentlySnappedComponent = this.getComponentWithID(101);
|
||||
this.snapCursorToCurrentSnappedComponent();
|
||||
}
|
||||
|
||||
public void parseItems(IList<Item> items)
|
||||
{
|
||||
Utility.consolidateStacks(items);
|
||||
for (int index = 0; index < 6; ++index)
|
||||
{
|
||||
this.categoryItems.Add(new List<Item>());
|
||||
this.categoryTotals.Add(0);
|
||||
this.categoryDials.Add(new MoneyDial(7, index == 5));
|
||||
}
|
||||
foreach (Item index in (IEnumerable<Item>)items)
|
||||
{
|
||||
if (index is StardewValley.Object)
|
||||
{
|
||||
StardewValley.Object o = index as StardewValley.Object;
|
||||
int categoryIndexForObject = this.getCategoryIndexForObject(o);
|
||||
this.categoryItems[categoryIndexForObject].Add((Item)o);
|
||||
int num = o.sellToStorePrice(-1L) * o.Stack;
|
||||
this.categoryTotals[categoryIndexForObject] += num;
|
||||
this.itemValues[index] = 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);
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < 5; ++index)
|
||||
{
|
||||
this.categoryTotals[5] += this.categoryTotals[index];
|
||||
this.categoryItems[5].AddRange((IEnumerable<Item>)this.categoryItems[index]);
|
||||
this.categoryDials[index].currentValue = this.categoryTotals[index];
|
||||
this.categoryDials[index].previousTargetValue = this.categoryDials[index].currentValue;
|
||||
}
|
||||
this.categoryDials[5].currentValue = this.categoryTotals[5];
|
||||
Game1.setRichPresence("earnings", (object)this.categoryTotals[5]);
|
||||
}
|
||||
|
||||
public int getCategoryIndexForObject(StardewValley.Object o)
|
||||
{
|
||||
switch ((o.ParentSheetIndex))
|
||||
{
|
||||
case 296:
|
||||
case 396:
|
||||
case 402:
|
||||
case 406:
|
||||
case 410:
|
||||
case 414:
|
||||
case 418:
|
||||
return 1;
|
||||
default:
|
||||
switch (o.Category)
|
||||
{
|
||||
case -81:
|
||||
case -27:
|
||||
case -23:
|
||||
return 1;
|
||||
case -80:
|
||||
case -79:
|
||||
case -75:
|
||||
case -26:
|
||||
case -14:
|
||||
case -6:
|
||||
case -5:
|
||||
return 0;
|
||||
case -20:
|
||||
case -4:
|
||||
return 2;
|
||||
case -15:
|
||||
case -12:
|
||||
case -2:
|
||||
return 3;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string getCategoryName(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
return Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11389");
|
||||
case 1:
|
||||
return Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11390");
|
||||
case 2:
|
||||
return Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11391");
|
||||
case 3:
|
||||
return Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11392");
|
||||
case 4:
|
||||
return Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11393");
|
||||
case 5:
|
||||
return Game1.content.LoadString("Strings\\StringsFromCSFiles:ShippingMenu.cs.11394");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public override void update(GameTime time)
|
||||
{
|
||||
base.update(time);
|
||||
if (this._hasFinished)
|
||||
{
|
||||
//if (!Game1.PollForEndOfNewDaySync())
|
||||
//return;
|
||||
this.shipItems();
|
||||
|
||||
this.exitThisMenu(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
if (this.saveGameMenu != null)
|
||||
{
|
||||
this.saveGameMenu.update(time);
|
||||
if (this.saveGameMenu.quit)
|
||||
{
|
||||
this.saveGameMenu = (SaveGameMenu)null;
|
||||
this.savedYet = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
this.weatherX += (float)time.ElapsedGameTime.Milliseconds * 0.03f;
|
||||
for (int index = this.animations.Count - 1; index >= 0; --index)
|
||||
{
|
||||
if (this.animations[index].update(time))
|
||||
this.animations.RemoveAt(index);
|
||||
}
|
||||
if (this.outro)
|
||||
{
|
||||
//this._hasFinished = true;
|
||||
//return;
|
||||
|
||||
if (this.outroFadeTimer > 0)
|
||||
this.outroFadeTimer -= time.ElapsedGameTime.Milliseconds;
|
||||
else if (this.outroFadeTimer <= 0 && this.dayPlaqueY < this.centerY - 64)
|
||||
{
|
||||
if (this.animations.Count > 0)
|
||||
this.animations.Clear();
|
||||
this.dayPlaqueY += (int)Math.Ceiling((double)time.ElapsedGameTime.Milliseconds * 0.349999994039536);
|
||||
if (this.dayPlaqueY >= this.centerY - 64)
|
||||
this.outroPauseBeforeDateChange = 700;
|
||||
}
|
||||
else if (this.outroPauseBeforeDateChange > 0)
|
||||
{
|
||||
this.outroPauseBeforeDateChange -= time.ElapsedGameTime.Milliseconds;
|
||||
if (this.outroPauseBeforeDateChange <= 0)
|
||||
{
|
||||
//this.newDayPlaque = true;
|
||||
Game1.playSound("newRecipe");
|
||||
|
||||
/*
|
||||
if (!Game1.currentSeason.Equals("winter"))
|
||||
DelayedAction.playSoundAfterDelay(Game1.isRaining ? "rainsound" : "rooster", 1500, (GameLocation)null, -1);
|
||||
*/
|
||||
this.finalOutroTimer = 2000;
|
||||
this.animations.Clear();
|
||||
if (!this.savedYet)
|
||||
{
|
||||
this.savedYet = true;
|
||||
/*
|
||||
if (this.saveGameMenu != null)
|
||||
return;
|
||||
this.saveGameMenu = new SaveGameMenu();
|
||||
return;
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.finalOutroTimer > 0 && this.savedYet)
|
||||
{
|
||||
this.finalOutroTimer -= time.ElapsedGameTime.Milliseconds;
|
||||
if (this.finalOutroTimer <= 0)
|
||||
this._hasFinished = true;
|
||||
}
|
||||
}
|
||||
if (this.introTimer >= 0)
|
||||
{
|
||||
int introTimer = this.introTimer;
|
||||
this.introTimer -= time.ElapsedGameTime.Milliseconds * (Game1.oldMouseState.LeftButton == ButtonState.Pressed ? 3 : 1);
|
||||
if (introTimer % 500 < this.introTimer % 500 && this.introTimer <= 3000)
|
||||
{
|
||||
int which = 4 - this.introTimer / 500;
|
||||
if (which < 6 && which > -1)
|
||||
{
|
||||
if (this.categoryItems[which].Count > 0)
|
||||
{
|
||||
Game1.playSound(this.getCategorySound(which));
|
||||
this.categoryDials[which].currentValue = 0;
|
||||
this.categoryDials[which].previousTargetValue = 0;
|
||||
}
|
||||
else
|
||||
Game1.playSound("stoneStep");
|
||||
}
|
||||
}
|
||||
if (this.introTimer < 0)
|
||||
{
|
||||
if (Game1.options.SnappyMenus)
|
||||
this.snapToDefaultClickableComponent();
|
||||
Game1.playSound("money");
|
||||
this.categoryDials[5].currentValue = 0;
|
||||
this.categoryDials[5].previousTargetValue = 0;
|
||||
}
|
||||
}
|
||||
else if (Game1.dayOfMonth != 28 && !this.outro)
|
||||
{
|
||||
if (!Game1.wasRainingYesterday)
|
||||
{
|
||||
Vector2 position = new Vector2((float)Game1.viewport.Width, (float)Game1.random.Next(200));
|
||||
Rectangle sourceRect = new Rectangle(640, 752, 16, 16);
|
||||
int num = Game1.random.Next(1, 4);
|
||||
if (Game1.random.NextDouble() < 0.001)
|
||||
{
|
||||
bool flipped = Game1.random.NextDouble() < 0.5;
|
||||
if (Game1.random.NextDouble() < 0.5)
|
||||
this.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(640, 826, 16, 8), 40f, 4, 0, new Vector2((float)Game1.random.Next(this.centerX * 2), (float)Game1.random.Next(this.centerY)), false, flipped)
|
||||
{
|
||||
rotation = 3.141593f,
|
||||
scale = 4f,
|
||||
motion = new Vector2(flipped ? -8f : 8f, 8f),
|
||||
local = true
|
||||
});
|
||||
else
|
||||
this.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(258, 1680, 16, 16), 40f, 4, 0, new Vector2((float)Game1.random.Next(this.centerX * 2), (float)Game1.random.Next(this.centerY)), false, flipped)
|
||||
{
|
||||
scale = 4f,
|
||||
motion = new Vector2(flipped ? -8f : 8f, 8f),
|
||||
local = true
|
||||
});
|
||||
}
|
||||
else if (Game1.random.NextDouble() < 0.0002)
|
||||
{
|
||||
position = new Vector2((float)Game1.viewport.Width, (float)Game1.random.Next(4, 256));
|
||||
this.animations.Add(new TemporaryAnimatedSprite("", new Rectangle(0, 0, 1, 1), 9999f, 1, 10000, position, false, false, 0.01f, 0.0f, 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)
|
||||
{
|
||||
position = new Vector2((float)Game1.viewport.Width, (float)(Game1.viewport.Height - 192));
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
this.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", sourceRect, (float)Game1.random.Next(60, 101), 4, 100, position + new Vector2((float)((index + 1) * Game1.random.Next(15, 18)), (float)((index + 1) * -20)), false, false, 0.01f, 0.0f, Color.Black, 4f, 0.0f, 0.0f, 0.0f, true)
|
||||
{
|
||||
motion = new Vector2(-1f, 0.0f)
|
||||
});
|
||||
this.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", sourceRect, (float)Game1.random.Next(60, 101), 4, 100, position + new Vector2((float)((index + 1) * Game1.random.Next(15, 18)), (float)((index + 1) * 20)), 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)
|
||||
{
|
||||
sourceRect = new Rectangle(640, 784, 16, 16);
|
||||
this.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", sourceRect, 75f, 4, 1000, position, 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,
|
||||
yPeriodicRange = 8f,
|
||||
shakeIntensity = 0.5f
|
||||
});
|
||||
}
|
||||
}
|
||||
this.smokeTimer -= time.ElapsedGameTime.Milliseconds;
|
||||
if (this.smokeTimer <= 0)
|
||||
{
|
||||
this.smokeTimer = 50;
|
||||
this.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(684, 1075, 1, 1), 1000f, 1, 1000, new Vector2(188f, (float)(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)((double)-Game1.random.Next(25, 75) / 100.0 / 4.0)),
|
||||
acceleration = new Vector2(-1f / 1000f, 0.0f)
|
||||
});
|
||||
}
|
||||
}
|
||||
if (this.moonShake <= 0)
|
||||
return;
|
||||
this.moonShake -= time.ElapsedGameTime.Milliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
public string getCategorySound(int which)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
case 0:
|
||||
return !(this.categoryItems[0][0] as StardewValley.Object).isAnimalProduct() ? "harvest" : "cluck";
|
||||
case 1:
|
||||
return "leafrustle";
|
||||
case 2:
|
||||
return "button1";
|
||||
case 3:
|
||||
return "hammer";
|
||||
case 4:
|
||||
return "coin";
|
||||
case 5:
|
||||
return "money";
|
||||
default:
|
||||
return "stoneStep";
|
||||
}
|
||||
}
|
||||
|
||||
public override void applyMovementKey(int direction)
|
||||
{
|
||||
if (!this.CanReceiveInput())
|
||||
return;
|
||||
base.applyMovementKey(direction);
|
||||
}
|
||||
|
||||
public override void performHoverAction(int x, int y)
|
||||
{
|
||||
if (!this.CanReceiveInput())
|
||||
return;
|
||||
base.performHoverAction(x, y);
|
||||
if (this.currentPage == -1)
|
||||
{
|
||||
this.okButton.tryHover(x, y, 0.1f);
|
||||
foreach (ClickableTextureComponent category in this.categories)
|
||||
category.sourceRect.X = !category.containsPoint(x, y) ? 392 : 402;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.backButton.tryHover(x, y, 0.5f);
|
||||
this.forwardButton.tryHover(x, y, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanReceiveInput()
|
||||
{
|
||||
return this.introTimer <= 0 && !this.outro;
|
||||
}
|
||||
|
||||
public override void receiveKeyPress(Keys key)
|
||||
{
|
||||
if (!this.CanReceiveInput())
|
||||
return;
|
||||
if (this.introTimer <= 0 && !Game1.options.gamepadControls && (key.Equals((object)Keys.Escape) || Game1.options.doesInputListContain(Game1.options.menuButton, key)))
|
||||
{
|
||||
this.receiveLeftClick(this.okButton.bounds.Center.X, this.okButton.bounds.Center.Y, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.introTimer > 0 || Game1.options.gamepadControls && Game1.options.doesInputListContain(Game1.options.menuButton, key))
|
||||
return;
|
||||
base.receiveKeyPress(key);
|
||||
}
|
||||
}
|
||||
|
||||
public override void receiveGamePadButton(Buttons b)
|
||||
{
|
||||
if (!this.CanReceiveInput())
|
||||
return;
|
||||
base.receiveGamePadButton(b);
|
||||
if (b == Buttons.B && this.currentPage != -1)
|
||||
{
|
||||
if (this.currentTab == 0)
|
||||
{
|
||||
if (Game1.options.SnappyMenus)
|
||||
{
|
||||
this.currentlySnappedComponent = this.getComponentWithID(this.currentPage);
|
||||
this.snapCursorToCurrentSnappedComponent();
|
||||
}
|
||||
this.currentPage = -1;
|
||||
}
|
||||
else
|
||||
--this.currentTab;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b != Buttons.Start && b != Buttons.B || (this.currentPage != -1 || this.outro))
|
||||
return;
|
||||
if (this.introTimer <= 0)
|
||||
this.okClicked();
|
||||
else
|
||||
this.introTimer -= Game1.currentGameTime.ElapsedGameTime.Milliseconds * 2;
|
||||
}
|
||||
}
|
||||
|
||||
private void okClicked()
|
||||
{
|
||||
this.outro = true;
|
||||
this.outroFadeTimer = 800;
|
||||
Game1.playSound("bigDeSelect");
|
||||
Game1.changeMusicTrack("none", false, Game1.MusicContext.Default);
|
||||
}
|
||||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
if (!this.CanReceiveInput())
|
||||
return;
|
||||
if (this.outro && !this.savedYet)
|
||||
{
|
||||
this.savedYet = true;
|
||||
//SaveGameMenu saveGameMenu = this.saveGameMenu;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.receiveLeftClick(x, y, playSound);
|
||||
if (this.currentPage == -1 && this.introTimer <= 0 && this.okButton.containsPoint(x, y))
|
||||
this.okClicked();
|
||||
if (this.currentPage == -1)
|
||||
{
|
||||
for (int index = 0; index < this.categories.Count; ++index)
|
||||
{
|
||||
if (this.categories[index].visible && this.categories[index].containsPoint(x, y))
|
||||
{
|
||||
this.currentPage = index;
|
||||
Game1.playSound("shwip");
|
||||
if (Game1.options.SnappyMenus)
|
||||
{
|
||||
this.currentlySnappedComponent = this.getComponentWithID(103);
|
||||
this.snapCursorToCurrentSnappedComponent();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Game1.dayOfMonth != 28 || this.timesPokedMoon > 10 || !new Rectangle(Game1.viewport.Width - 176, 4, 172, 172).Contains(x, y))
|
||||
return;
|
||||
this.moonShake = 100;
|
||||
++this.timesPokedMoon;
|
||||
if (this.timesPokedMoon > 10)
|
||||
Game1.playSound("shadowDie");
|
||||
else
|
||||
Game1.playSound("thudStep");
|
||||
}
|
||||
else if (this.backButton.containsPoint(x, y))
|
||||
{
|
||||
if (this.currentTab == 0)
|
||||
{
|
||||
if (Game1.options.SnappyMenus)
|
||||
{
|
||||
this.currentlySnappedComponent = this.getComponentWithID(this.currentPage);
|
||||
this.snapCursorToCurrentSnappedComponent();
|
||||
}
|
||||
this.currentPage = -1;
|
||||
}
|
||||
else
|
||||
--this.currentTab;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.showForwardButton() || !this.forwardButton.containsPoint(x, y))
|
||||
return;
|
||||
++this.currentTab;
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void receiveRightClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
}
|
||||
|
||||
public bool showForwardButton()
|
||||
{
|
||||
return this.categoryItems[this.currentPage].Count > this.itemsPerCategoryPage * (this.currentTab + 1);
|
||||
}
|
||||
|
||||
public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds)
|
||||
{
|
||||
this.initialize(0, 0, Game1.viewport.Width, Game1.viewport.Height, false);
|
||||
this.RepositionItems();
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
if (Game1.wasRainingYesterday)
|
||||
{
|
||||
b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Game1.currentSeason.Equals("winter") ? Color.LightSlateGray : Color.SlateGray * (float)(1.0 - (double)this.introTimer / 3500.0));
|
||||
b.Draw(Game1.mouseCursors, new Rectangle(2556, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Game1.currentSeason.Equals("winter") ? Color.LightSlateGray : Color.SlateGray * (float)(1.0 - (double)this.introTimer / 3500.0));
|
||||
for (int index = -244; index < Game1.viewport.Width + 244; index += 244)
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)index + (float)((double)this.weatherX / 2.0 % 244.0), 32f), new Rectangle?(new Rectangle(643, 1142, 61, 53)), Color.DarkSlateGray * 1f * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - 192)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.FlipHorizontally, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(2556f, (float)(Game1.viewport.Height - 192)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.FlipHorizontally, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - 128)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(2556f, (float)(Game1.viewport.Height - 128)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(160f, (float)(Game1.viewport.Height - 128 + 16 + 8)), new Rectangle?(new Rectangle(653, 880, 10, 10)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
for (int index = -244; index < Game1.viewport.Width + 244; index += 244)
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)index + this.weatherX % 244f, -32f), new Rectangle?(new Rectangle(643, 1142, 61, 53)), Color.SlateGray * 0.85f * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.9f);
|
||||
foreach (TemporaryAnimatedSprite animation in this.animations)
|
||||
animation.draw(b, true, 0, 0, 1f);
|
||||
for (int index = -244; index < Game1.viewport.Width + 244; index += 244)
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)index + (float)((double)this.weatherX * 1.5 % 244.0), (float)sbyte.MinValue), new Rectangle?(new Rectangle(643, 1142, 61, 53)), Color.LightSlateGray * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.9f);
|
||||
}
|
||||
else
|
||||
{
|
||||
b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0));
|
||||
b.Draw(Game1.mouseCursors, new Rectangle(2556, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0));
|
||||
b.Draw(Game1.mouseCursors, new Vector2(0.0f, 0.0f), new Rectangle?(new Rectangle(0, 1453, 639, 195)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(2556f, 0.0f), new Rectangle?(new Rectangle(0, 1453, 639, 195)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
if (Game1.dayOfMonth == 28)
|
||||
{
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(Game1.viewport.Width - 176), 4f) + (this.moonShake > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Rectangle?(new Rectangle(642, 835, 43, 43)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
if (this.timesPokedMoon > 10)
|
||||
{
|
||||
SpriteBatch spriteBatch = b;
|
||||
Texture2D mouseCursors = Game1.mouseCursors;
|
||||
Vector2 position = new Vector2((float)(Game1.viewport.Width - 136), 48f) + (this.moonShake > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero);
|
||||
int num;
|
||||
if (Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 4000.0 >= 200.0)
|
||||
{
|
||||
TimeSpan totalGameTime = Game1.currentGameTime.TotalGameTime;
|
||||
if (totalGameTime.TotalMilliseconds % 8000.0 > 7600.0)
|
||||
{
|
||||
totalGameTime = Game1.currentGameTime.TotalGameTime;
|
||||
if (totalGameTime.TotalMilliseconds % 8000.0 < 7800.0)
|
||||
goto label_21;
|
||||
}
|
||||
num = 0;
|
||||
goto label_22;
|
||||
}
|
||||
label_21:
|
||||
num = 21;
|
||||
label_22:
|
||||
Rectangle? sourceRectangle = new Rectangle?(new Rectangle(685, 844 + num, 19, 21));
|
||||
Color color = Color.White * (float)(1.0 - (double)this.introTimer / 3500.0);
|
||||
Vector2 zero = Vector2.Zero;
|
||||
spriteBatch.Draw(mouseCursors, position, sourceRectangle, color, 0.0f, zero, 4f, SpriteEffects.None, 1f);
|
||||
}
|
||||
}
|
||||
b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - 192)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.FlipHorizontally, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(2556f, (float)(Game1.viewport.Height - 192)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.FlipHorizontally, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(0.0f, (float)(Game1.viewport.Height - 128)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(2556f, (float)(Game1.viewport.Height - 128)), new Rectangle?(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 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2(160f, (float)(Game1.viewport.Height - 128 + 16 + 8)), new Rectangle?(new Rectangle(653, 880, 10, 10)), Color.White * (float)(1.0 - (double)this.introTimer / 3500.0), 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1f);
|
||||
}
|
||||
if (!this.outro && !Game1.wasRainingYesterday)
|
||||
{
|
||||
foreach (TemporaryAnimatedSprite animation in this.animations)
|
||||
animation.draw(b, true, 0, 0, 1f);
|
||||
}
|
||||
if (this.currentPage == -1)
|
||||
{
|
||||
int y = this.categories[0].bounds.Y - 128;
|
||||
if (y >= 0)
|
||||
SpriteText.drawStringWithScrollCenteredAt(b, Utility.getDateString(), Game1.viewport.Width / 2, y, "", 1f, -1, 0, 0.88f, false);
|
||||
int num = -20;
|
||||
int index1 = 0;
|
||||
foreach (ClickableTextureComponent category in this.categories)
|
||||
{
|
||||
if (this.introTimer < 2500 - index1 * 500)
|
||||
{
|
||||
Vector2 vector2 = category.getVector2() + new Vector2(12f, -8f);
|
||||
if (category.visible)
|
||||
{
|
||||
category.draw(b);
|
||||
b.Draw(Game1.mouseCursors, vector2 + new Vector2(-104f, (float)(num + 4)), new Rectangle?(new Rectangle(293, 360, 24, 24)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
|
||||
this.categoryItems[index1][0].drawInMenu(b, vector2 + new Vector2(-88f, (float)(num + 16)), 1f, 1f, 0.9f, StackDrawType.Hide);
|
||||
}
|
||||
IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(384, 373, 18, 18), (int)((double)vector2.X + (double)-this.itemSlotWidth - (double)this.categoryLabelsWidth - 12.0), (int)((double)vector2.Y + (double)num), this.categoryLabelsWidth, 104, Color.White, 4f, false);
|
||||
SpriteText.drawString(b, category.hoverText, (int)vector2.X - this.itemSlotWidth - this.categoryLabelsWidth + 8, (int)vector2.Y + 4, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1, SpriteText.ScrollTextAlignment.Left);
|
||||
for (int index2 = 0; index2 < 6; ++index2)
|
||||
b.Draw(Game1.mouseCursors, vector2 + new Vector2((float)(-this.itemSlotWidth - 192 - 24 + index2 * 6 * 4), 12f), new Rectangle?(new Rectangle(355, 476, 7, 11)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
|
||||
this.categoryDials[index1].draw(b, vector2 + new Vector2((float)(-this.itemSlotWidth - 192 - 48 + 4), 20f), this.categoryTotals[index1]);
|
||||
b.Draw(Game1.mouseCursors, vector2 + new Vector2((float)(-this.itemSlotWidth - 64 - 4), 12f), new Rectangle?(new Rectangle(408, 476, 9, 11)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
|
||||
}
|
||||
++index1;
|
||||
}
|
||||
if (this.introTimer <= 0)
|
||||
this.okButton.draw(b);
|
||||
}
|
||||
else
|
||||
{
|
||||
IClickableMenu.drawTextureBox(b, 0, 0, Game1.viewport.Width, Game1.viewport.Height, Color.White);
|
||||
Vector2 location = new Vector2((float)(this.xPositionOnScreen + 32), (float)(this.yPositionOnScreen + 32));
|
||||
for (int index1 = this.currentTab * this.itemsPerCategoryPage; index1 < this.currentTab * this.itemsPerCategoryPage + this.itemsPerCategoryPage; ++index1)
|
||||
{
|
||||
if (this.categoryItems[this.currentPage].Count > index1)
|
||||
{
|
||||
Item index2 = this.categoryItems[this.currentPage][index1];
|
||||
index2.drawInMenu(b, location, 1f, 1f, 1f, StackDrawType.Draw);
|
||||
if (LocalizedContentManager.CurrentLanguageLatin)
|
||||
{
|
||||
SpriteText.drawString(b, index2.DisplayName + (index2.Stack > 1 ? " x" + (object)index2.Stack : ""), (int)location.X + 64 + 12, (int)location.Y + 12, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1, SpriteText.ScrollTextAlignment.Left);
|
||||
string s = ".";
|
||||
for (int index3 = 0; index3 < this.width - 96 - SpriteText.getWidthOfString(index2.DisplayName + (index2.Stack > 1 ? " x" + (object)index2.Stack : "") + Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.itemValues[index2]), 999999); index3 += SpriteText.getWidthOfString(" .", 999999))
|
||||
s += " .";
|
||||
SpriteText.drawString(b, s, (int)location.X + 80 + SpriteText.getWidthOfString(index2.DisplayName + (index2.Stack > 1 ? " x" + (object)index2.Stack : ""), 999999), (int)location.Y + 8, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1, SpriteText.ScrollTextAlignment.Left);
|
||||
SpriteText.drawString(b, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.itemValues[index2]), (int)location.X + this.width - 64 - SpriteText.getWidthOfString(Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.itemValues[index2]), 999999), (int)location.Y + 12, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1, SpriteText.ScrollTextAlignment.Left);
|
||||
}
|
||||
else
|
||||
{
|
||||
string s1 = index2.DisplayName + (index2.Stack > 1 ? " x" + (object)index2.Stack : ".");
|
||||
string s2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.itemValues[index2]);
|
||||
int x = (int)location.X + this.width - 64 - SpriteText.getWidthOfString(Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.itemValues[index2]), 999999);
|
||||
SpriteText.getWidthOfString(s1 + s2, 999999);
|
||||
while (SpriteText.getWidthOfString(s1 + s2, 999999) < 1123)
|
||||
s1 += " .";
|
||||
if (SpriteText.getWidthOfString(s1 + s2, 999999) >= 1155)
|
||||
s1 = s1.Remove(s1.Length - 1);
|
||||
SpriteText.drawString(b, s1, (int)location.X + 64 + 12, (int)location.Y + 12, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1, SpriteText.ScrollTextAlignment.Left);
|
||||
SpriteText.drawString(b, s2, x, (int)location.Y + 12, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1, SpriteText.ScrollTextAlignment.Left);
|
||||
}
|
||||
location.Y += 68f;
|
||||
}
|
||||
}
|
||||
this.backButton.draw(b);
|
||||
if (this.showForwardButton())
|
||||
this.forwardButton.draw(b);
|
||||
}
|
||||
if (this.outro)
|
||||
{
|
||||
b.Draw(Game1.mouseCursors, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(639, 858, 1, 184)), Color.Black * (float)(1.0 - (double)this.outroFadeTimer / 800.0));
|
||||
SpriteText.drawStringWithScrollCenteredAt(b, this.newDayPlaque ? Utility.getDateString(0) : Utility.getDateString(), Game1.viewport.Width / 2, this.dayPlaqueY, "", 1f, -1, 0, 0.88f, false);
|
||||
foreach (TemporaryAnimatedSprite animation in this.animations)
|
||||
animation.draw(b, true, 0, 0, 1f);
|
||||
if (this.finalOutroTimer > 0 || this._hasFinished)
|
||||
b.Draw(Game1.staminaRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black * (float)(1.0 - (double)this.finalOutroTimer / 2000.0));
|
||||
}
|
||||
if (Game1.options.SnappyMenus && (this.introTimer > 0 || this.outro))
|
||||
return;
|
||||
this.drawMouse(b);
|
||||
}
|
||||
|
||||
|
||||
public void shipItems()
|
||||
{
|
||||
NetCollection<Item> shippingBin = Game1.getFarm().getShippingBin(Game1.player);
|
||||
if (Game1.player.useSeparateWallets || !Game1.player.useSeparateWallets && Game1.player.IsMainPlayer)
|
||||
{
|
||||
int num = 0;
|
||||
foreach (Item obj in shippingBin)
|
||||
{
|
||||
if (obj is StardewValley.Object)
|
||||
num += (obj as StardewValley.Object).sellToStorePrice(-1L) * obj.Stack;
|
||||
}
|
||||
Game1.player.Money += num;
|
||||
Game1.getFarm().getShippingBin(Game1.player).Clear();
|
||||
}
|
||||
|
||||
if (Game1.player.useSeparateWallets && Game1.player.IsMainPlayer)
|
||||
{
|
||||
foreach (Farmer allFarmhand in Game1.getAllFarmhands())
|
||||
{
|
||||
if (!allFarmhand.isActive() && !allFarmhand.isUnclaimedFarmhand)
|
||||
{
|
||||
int num = 0;
|
||||
foreach (Item obj in Game1.getFarm().getShippingBin(allFarmhand))
|
||||
{
|
||||
if (obj is StardewValley.Object)
|
||||
num += (obj as StardewValley.Object).sellToStorePrice(allFarmhand.UniqueMultiplayerID) * obj.Stack;
|
||||
}
|
||||
Game1.player.team.AddIndividualMoney(allFarmhand, num);
|
||||
Game1.getFarm().getShippingBin(allFarmhand).Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -6,24 +6,119 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Omegasis.SaveAnywhere.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for the Save Anywhere API
|
||||
/// Other mods can use this interface to get the
|
||||
/// API from the SMAPI helper
|
||||
/// </summary>
|
||||
public class SaveAnywhereAPI
|
||||
{
|
||||
|
||||
/*********
|
||||
** Events
|
||||
*********/
|
||||
/// <summary>
|
||||
/// Event that fires before game save
|
||||
/// </summary>
|
||||
public event EventHandler BeforeSave
|
||||
{
|
||||
add
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.beforeSave += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.beforeSave -= value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Event that fires after game save
|
||||
/// </summary>
|
||||
public event EventHandler AfterSave
|
||||
{
|
||||
add
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterSave += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterSave -= value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Event that fires after game load
|
||||
/// </summary>
|
||||
public event EventHandler AfterLoad
|
||||
{
|
||||
add
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterLoad += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterLoad -= value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public SaveAnywhereAPI()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add in an event that can trigger before saving begins.
|
||||
/// </summary>
|
||||
/// <param name="ID"></param>
|
||||
/// <param name="BeforeSave"></param>
|
||||
public void addBeforeSaveEvent(string ID, Action BeforeSave)
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.beforeCustomSavingBegins.Add(ID, BeforeSave);
|
||||
}
|
||||
public void addAfterSaveEvent(string ID, Action BeforeSave)
|
||||
/// <summary>
|
||||
/// Remove an event that can trigger before saving begins.
|
||||
/// </summary>
|
||||
/// <param name="ID"></param>
|
||||
/// <param name="BeforeSave"></param>
|
||||
public void removeBeforeSaveEvent(string ID, Action BeforeSave)
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterCustomSavingCompleted.Add(ID, BeforeSave);
|
||||
SaveAnywhere.Instance.SaveManager.beforeCustomSavingBegins.Remove(ID);
|
||||
}
|
||||
public void addAfterLoadEvent(string ID, Action BeforeSave)
|
||||
/// <summary>
|
||||
/// Add an event that tiggers after saving has finished.
|
||||
/// </summary>
|
||||
/// <param name="ID"></param>
|
||||
/// <param name="AfterSave"></param>
|
||||
public void addAfterSaveEvent(string ID, Action AfterSave)
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterSaveLoaded.Add(ID, BeforeSave);
|
||||
SaveAnywhere.Instance.SaveManager.afterCustomSavingCompleted.Add(ID, AfterSave);
|
||||
}
|
||||
/// <summary>
|
||||
///Remove an event that triggers after saving has occured.
|
||||
/// </summary>
|
||||
/// <param name="ID"></param>
|
||||
/// <param name="AfterSave"></param>
|
||||
public void removeAfterSaveEvent(string ID, Action AfterSave)
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterCustomSavingCompleted.Remove(ID);
|
||||
}
|
||||
/// <summary>
|
||||
/// Add in an event that triggers afer loading has occured.
|
||||
/// </summary>
|
||||
/// <param name="ID"></param>
|
||||
/// <param name="AfterLoad"></param>
|
||||
public void addAfterLoadEvent(string ID, Action AfterLoad)
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterSaveLoaded.Add(ID, AfterLoad);
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove an event that occurs after loading has occured.
|
||||
/// </summary>
|
||||
/// <param name="ID"></param>
|
||||
/// <param name="AfterLoad"></param>
|
||||
public void removeAfterLoadEvent(string ID, Action AfterLoad)
|
||||
{
|
||||
SaveAnywhere.Instance.SaveManager.afterSaveLoaded.Remove(ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,12 +33,17 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
private bool WaitingToSave;
|
||||
|
||||
/// <summary> Currently displayed save menu (null if no menu is displayed) </summary>
|
||||
private NewSaveGameMenu currentSaveMenu;
|
||||
private NewSaveGameMenuV2 currentSaveMenu;
|
||||
|
||||
|
||||
public Dictionary<string, Action> beforeCustomSavingBegins;
|
||||
public event EventHandler beforeSave;
|
||||
|
||||
public Dictionary<string, Action> afterCustomSavingCompleted;
|
||||
public event EventHandler afterSave;
|
||||
|
||||
public Dictionary<string, Action> afterSaveLoaded;
|
||||
public event EventHandler afterLoad;
|
||||
|
||||
/*********
|
||||
** Public methods
|
||||
|
@ -67,7 +72,7 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
// perform passive save
|
||||
if (this.WaitingToSave && Game1.activeClickableMenu == null)
|
||||
{
|
||||
this.currentSaveMenu = new NewSaveGameMenu();
|
||||
this.currentSaveMenu = new NewSaveGameMenuV2();
|
||||
this.currentSaveMenu.SaveComplete += this.CurrentSaveMenu_SaveComplete;
|
||||
Game1.activeClickableMenu = this.currentSaveMenu;
|
||||
this.WaitingToSave = false;
|
||||
|
@ -82,7 +87,11 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
this.currentSaveMenu.SaveComplete -= this.CurrentSaveMenu_SaveComplete;
|
||||
this.currentSaveMenu = null;
|
||||
SaveAnywhere.RestoreMonsters();
|
||||
//AfterSave.Invoke(this, EventArgs.Empty);
|
||||
if (this.afterSave != null)
|
||||
{
|
||||
this.afterSave.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
foreach (var v in this.afterCustomSavingCompleted)
|
||||
{
|
||||
v.Value.Invoke();
|
||||
|
@ -111,25 +120,31 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
/// <summary>Initiate a game save.</summary>
|
||||
public void BeginSaveData()
|
||||
{
|
||||
|
||||
if (this.beforeSave != null)
|
||||
{
|
||||
this.beforeSave.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
foreach(var v in this.beforeCustomSavingBegins)
|
||||
{
|
||||
v.Value.Invoke();
|
||||
}
|
||||
|
||||
SaveAnywhere.Instance.cleanMonsters();
|
||||
|
||||
// save game data
|
||||
Farm farm = Game1.getFarm();
|
||||
if (farm.getShippingBin(Game1.player)!=null)
|
||||
{
|
||||
|
||||
Game1.activeClickableMenu = new NewShippingMenu(farm.getShippingBin(Game1.player), this.Reflection);
|
||||
farm.getShippingBin(Game1.player).Clear();
|
||||
//Game1.activeClickableMenu = new NewShippingMenu(farm.getShippingBin(Game1.player), this.Reflection);
|
||||
Game1.activeClickableMenu = new NewShippingMenuV2(farm.getShippingBin(Game1.player));
|
||||
//farm.getShippingBin(Game1.player).Clear();
|
||||
farm.lastItemShipped = null;
|
||||
this.WaitingToSave = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentSaveMenu = new NewSaveGameMenu();
|
||||
this.currentSaveMenu = new NewSaveGameMenuV2();
|
||||
this.currentSaveMenu.SaveComplete += this.CurrentSaveMenu_SaveComplete;
|
||||
Game1.activeClickableMenu = this.currentSaveMenu;
|
||||
}
|
||||
|
@ -161,6 +176,10 @@ namespace Omegasis.SaveAnywhere.Framework
|
|||
this.ResumeSwimming(data);
|
||||
this.SetPositions(data.Characters);
|
||||
this.OnLoaded?.Invoke();
|
||||
if (this.afterLoad != null)
|
||||
{
|
||||
this.afterLoad.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
foreach (var v in this.afterSaveLoaded)
|
||||
{
|
||||
v.Value.Invoke();
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace Omegasis.SaveAnywhere
|
|||
}
|
||||
if (Game1.activeClickableMenu != null)
|
||||
{
|
||||
if (Game1.activeClickableMenu.GetType() == typeof(NewSaveGameMenu))
|
||||
if (Game1.activeClickableMenu.GetType() == typeof(NewSaveGameMenuV2))
|
||||
{
|
||||
this.customMenuOpen = true;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ namespace Omegasis.SaveAnywhere
|
|||
}
|
||||
|
||||
/// <summary>Saves all monsters from the game world.</summary>
|
||||
private void cleanMonsters()
|
||||
public void cleanMonsters()
|
||||
{
|
||||
this.monsters = new Dictionary<GameLocation, List<Monster>>();
|
||||
|
||||
|
@ -230,7 +230,7 @@ namespace Omegasis.SaveAnywhere
|
|||
if (Game1.isFestival()) return;
|
||||
if (Game1.client == null)
|
||||
{
|
||||
this.cleanMonsters();
|
||||
|
||||
// validate: community center Junimos can't be saved
|
||||
|
||||
if (Game1.player.currentLocation.getCharacters().OfType<Junimo>().Any())
|
||||
|
|
|
@ -84,6 +84,8 @@
|
|||
<Compile Include="Framework\Models\PositionData.cs" />
|
||||
<Compile Include="Framework\NewSaveGameMenu.cs" />
|
||||
<Compile Include="Framework\Models\PlayerData.cs" />
|
||||
<Compile Include="Framework\NewSaveGameMenuV2.cs" />
|
||||
<Compile Include="Framework\NewShippingMenuV2.cs" />
|
||||
<Compile Include="Framework\NPCExtensions.cs" />
|
||||
<Compile Include="Framework\SaveAnywhereAPI.cs" />
|
||||
<Compile Include="Framework\SaveManager.cs" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"Name": "Save Anywhere",
|
||||
"Author": "Alpha_Omegasis",
|
||||
"Version": "2.12.0",
|
||||
"Version": "2.12.3",
|
||||
"Description": "Lets you save almost anywhere.",
|
||||
"UniqueID": "Omegasis.SaveAnywhere",
|
||||
"EntryDll": "SaveAnywhere.dll",
|
||||
|
|
|
@ -230,13 +230,15 @@ namespace StardustCore.Events
|
|||
/// <summary>
|
||||
/// Checks to see if all of the event preconditions have been met and starts the event if so.
|
||||
/// </summary>
|
||||
public virtual void startEventAtLocationifPossible()
|
||||
public virtual bool startEventAtLocationifPossible()
|
||||
{
|
||||
if (this.canEventOccur())
|
||||
{
|
||||
//Game1.player.currentLocation.currentEvent = this.getEvent();
|
||||
Game1.player.currentLocation.startEvent(this.getEvent());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,11 +22,14 @@ namespace StardustCore.Events
|
|||
|
||||
public Dictionary<string, ConcurrentEventInformation> concurrentEventActions;
|
||||
|
||||
public Dictionary<Farmer, HashSet<EventHelper>> seenEvents;
|
||||
|
||||
public EventManager()
|
||||
{
|
||||
this.events = new Dictionary<string, EventHelper>();
|
||||
this.customEventLogic = new Dictionary<string, Action<EventManager,string>>();
|
||||
this.concurrentEventActions = new Dictionary<string, ConcurrentEventInformation>();
|
||||
this.seenEvents = new Dictionary<Farmer, HashSet<EventHelper>>();
|
||||
|
||||
this.customEventLogic.Add("Omegasis.EventFramework.AddObjectToPlayersInventory", ExtraEventActions.addObjectToPlayerInventory);
|
||||
this.customEventLogic.Add("Omegasis.EventFramework.ViewportLerp", ExtraEventActions.ViewportLerp);
|
||||
|
@ -67,7 +70,7 @@ namespace StardustCore.Events
|
|||
/// </summary>
|
||||
public virtual void update()
|
||||
{
|
||||
if (Game1.CurrentEvent == null)
|
||||
if (Game1.eventUp == false)
|
||||
{
|
||||
if (this.concurrentEventActions.Count > 0)
|
||||
{
|
||||
|
@ -128,11 +131,51 @@ namespace StardustCore.Events
|
|||
/// <param name="EventName"></param>
|
||||
public virtual void startEventAtLocationIfPossible(string EventName)
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log("Try to start event!");
|
||||
|
||||
if (this.events.ContainsKey(EventName))
|
||||
{
|
||||
if (Game1.eventUp == true) return;
|
||||
if (this.seenEvents.ContainsKey(Game1.player)){
|
||||
if (this.seenEvents[Game1.player].Contains(this.events[EventName]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Game1.eventUp == true)
|
||||
{
|
||||
if (this.events[EventName].getEventID() == Game1.CurrentEvent.id)
|
||||
{
|
||||
this.concurrentEventActions.Clear(); //Clean all old parallel actions before starting a new event.
|
||||
bool started2=this.events[EventName].startEventAtLocationifPossible();
|
||||
if (started2)
|
||||
{
|
||||
if (this.seenEvents.ContainsKey(Game1.player))
|
||||
{
|
||||
this.seenEvents[Game1.player].Add(this.events[EventName]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.seenEvents.Add(Game1.player, new HashSet<EventHelper>() { this.events[EventName] });
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.concurrentEventActions.Clear(); //Clean all old parallel actions before starting a new event.
|
||||
this.events[EventName].startEventAtLocationifPossible();
|
||||
bool started=this.events[EventName].startEventAtLocationifPossible();
|
||||
if (started)
|
||||
{
|
||||
if(this.seenEvents.ContainsKey(Game1.player)){
|
||||
this.seenEvents[Game1.player].Add(this.events[EventName]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.seenEvents.Add(Game1.player,new HashSet<EventHelper>() { this.events[EventName] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +188,11 @@ namespace StardustCore.Events
|
|||
|
||||
this.events.TryGetValue(EventName, out EventHelper e);
|
||||
if (e == null) return;
|
||||
Game1.player.eventsSeen.Remove(e.getEventID());
|
||||
if (this.seenEvents.ContainsKey(Game1.player))
|
||||
{
|
||||
this.seenEvents[Game1.player].Remove(e);
|
||||
}
|
||||
//Game1.player.eventsSeen.Remove(e.getEventID());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"Name": "StardustCore",
|
||||
"Author": "Alpha_Omegasis",
|
||||
"Version": "2.4.0",
|
||||
"Version": "2.4.2",
|
||||
"Description": "A core mod that allows for other mods of mine to be run.",
|
||||
"UniqueID": "Omegasis.StardustCore",
|
||||
"EntryDll": "StardustCore.dll",
|
||||
|
|
Loading…
Reference in New Issue