Merge branch 'Development' of https://github.com/janavarro95/Stardew_Valley_Mods into Development
This commit is contained in:
commit
e3bb6582f5
|
@ -12,7 +12,7 @@ namespace Omegasis.SaveBackup
|
||||||
public class SaveBackup : Mod
|
public class SaveBackup : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The folder path containing the game's app data.</summary>
|
/// <summary>The folder path containing the game's app data.</summary>
|
||||||
private static readonly string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
|
private static readonly string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
|
||||||
|
@ -41,17 +41,17 @@ namespace Omegasis.SaveBackup
|
||||||
|
|
||||||
this.BackupSaves(SaveBackup.PrePlayBackupsPath);
|
this.BackupSaves(SaveBackup.PrePlayBackupsPath);
|
||||||
|
|
||||||
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked before the save is updated.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
private void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
this.BackupSaves(SaveBackup.NightlyBackupsPath);
|
this.BackupSaves(SaveBackup.NightlyBackupsPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Backs up your save files when loading SMAPI and every in game night when saving.",
|
"Description": "Backs up your save files when loading SMAPI and every in game night when saving.",
|
||||||
"UniqueID": "Omegasis.AdvancedSaveBackup",
|
"UniqueID": "Omegasis.AdvancedSaveBackup",
|
||||||
"EntryDll": "AdvancedSaveBackup.dll",
|
"EntryDll": "AdvancedSaveBackup.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:435" ]
|
"UpdateKeys": [ "Nexus:435" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using Omegasis.AutoSpeed.Framework;
|
using Omegasis.AutoSpeed.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
using StardewModdingAPI.Events;
|
using StardewModdingAPI.Events;
|
||||||
|
@ -10,7 +9,7 @@ namespace Omegasis.AutoSpeed
|
||||||
public class AutoSpeed : Mod
|
public class AutoSpeed : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -23,7 +22,7 @@ namespace Omegasis.AutoSpeed
|
||||||
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +30,10 @@ namespace Omegasis.AutoSpeed
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
if (Context.IsPlayerFree)
|
if (Context.IsPlayerFree)
|
||||||
Game1.player.addedSpeed = this.Config.Speed;
|
Game1.player.addedSpeed = this.Config.Speed;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Got to go fast!",
|
"Description": "Got to go fast!",
|
||||||
"UniqueID": "Omegasis.AutoSpeed",
|
"UniqueID": "Omegasis.AutoSpeed",
|
||||||
"EntryDll": "AutoSpeed.dll",
|
"EntryDll": "AutoSpeed.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:443" ]
|
"UpdateKeys": [ "Nexus:443" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Omegasis.BillboardAnywhere
|
||||||
public class BillboardAnywhere : Mod
|
public class BillboardAnywhere : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -25,20 +25,20 @@ namespace Omegasis.BillboardAnywhere
|
||||||
{
|
{
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
public void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
// load menu if key pressed
|
// load menu if key pressed
|
||||||
if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding)
|
if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding)
|
||||||
Game1.activeClickableMenu = new Billboard();
|
Game1.activeClickableMenu = new Billboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace Omegasis.BillboardAnywhere.Framework
|
namespace Omegasis.BillboardAnywhere.Framework
|
||||||
{
|
{
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
internal class ModConfig
|
internal class ModConfig
|
||||||
{
|
{
|
||||||
/// <summary>The key which shows the billboard menu.</summary>
|
/// <summary>The key which shows the billboard menu.</summary>
|
||||||
public string KeyBinding { get; set; } = "B";
|
public SButton KeyBinding { get; set; } = SButton.B;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Lets you view the billboard from anywhere.",
|
"Description": "Lets you view the billboard from anywhere.",
|
||||||
"UniqueID": "Omegasis.BillboardAnywhere",
|
"UniqueID": "Omegasis.BillboardAnywhere",
|
||||||
"EntryDll": "BillboardAnywhere.dll",
|
"EntryDll": "BillboardAnywhere.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:492" ]
|
"UpdateKeys": [ "Nexus:492" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Omegasis.BuildEndurance.Framework;
|
using Omegasis.BuildEndurance.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
|
@ -11,10 +10,10 @@ namespace Omegasis.BuildEndurance
|
||||||
public class BuildEndurance : Mod
|
public class BuildEndurance : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The relative path for the current player's data file.</summary>
|
/// <summary>The relative path for the current player's data file.</summary>
|
||||||
private string DataFilePath => Path.Combine("data", $"{Constants.SaveFolderName}.json");
|
private string RelativeDataPath => Path.Combine("data", $"{Constants.SaveFolderName}.json");
|
||||||
|
|
||||||
/// <summary>The mod settings.</summary>
|
/// <summary>The mod settings.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -47,10 +46,9 @@ namespace Omegasis.BuildEndurance
|
||||||
{
|
{
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
GameEvents.OneSecondTick += this.GameEvents_OneSecondTick;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
|
||||||
|
|
||||||
this.ModHelper = this.Helper;
|
this.ModHelper = this.Helper;
|
||||||
this.ModMonitor = this.Monitor;
|
this.ModMonitor = this.Monitor;
|
||||||
|
@ -60,24 +58,18 @@ namespace Omegasis.BuildEndurance
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked once per second during a game update.</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_OneSecondTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
|
||||||
// nerf how quickly tool xp is gained (I hope)
|
|
||||||
if (this.HasRecentToolExp)
|
|
||||||
this.HasRecentToolExp = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
|
|
||||||
/// <param name="sender">The event sender.</param>
|
|
||||||
/// <param name="e">The event data.</param>
|
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
if (!Context.IsWorldReady)
|
if (!Context.IsWorldReady)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// nerf how quickly tool xp is gained (I hope)
|
||||||
|
if (e.IsOneSecond && this.HasRecentToolExp)
|
||||||
|
this.HasRecentToolExp = false;
|
||||||
|
|
||||||
// give XP when player finishes eating
|
// give XP when player finishes eating
|
||||||
if (Game1.player.isEating)
|
if (Game1.player.isEating)
|
||||||
this.WasEating = true;
|
this.WasEating = true;
|
||||||
|
@ -112,10 +104,10 @@ namespace Omegasis.BuildEndurance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked after the player loads a save.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
// reset state
|
// reset state
|
||||||
this.WasExhausted = false;
|
this.WasExhausted = false;
|
||||||
|
@ -124,7 +116,7 @@ namespace Omegasis.BuildEndurance
|
||||||
this.WasEating = false;
|
this.WasEating = false;
|
||||||
|
|
||||||
// load player data
|
// load player data
|
||||||
this.PlayerData = this.Helper.ReadJsonFile<PlayerData>(this.DataFilePath) ?? new PlayerData();
|
this.PlayerData = this.Helper.Data.ReadJsonFile<PlayerData>(this.RelativeDataPath) ?? new PlayerData();
|
||||||
if (this.PlayerData.OriginalMaxStamina == 0)
|
if (this.PlayerData.OriginalMaxStamina == 0)
|
||||||
this.PlayerData.OriginalMaxStamina = Game1.player.MaxStamina;
|
this.PlayerData.OriginalMaxStamina = Game1.player.MaxStamina;
|
||||||
|
|
||||||
|
@ -150,10 +142,10 @@ namespace Omegasis.BuildEndurance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked just before the game is saved.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
private void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
// reset data
|
// reset data
|
||||||
this.WasExhausted = false;
|
this.WasExhausted = false;
|
||||||
|
@ -179,7 +171,7 @@ namespace Omegasis.BuildEndurance
|
||||||
this.PlayerData.NightlyStamina = Game1.player.MaxStamina;
|
this.PlayerData.NightlyStamina = Game1.player.MaxStamina;
|
||||||
|
|
||||||
// save data
|
// save data
|
||||||
this.Helper.WriteJsonFile(this.DataFilePath, this.PlayerData);
|
this.Helper.Data.WriteJsonFile(this.RelativeDataPath, this.PlayerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Try and emulate the old Game1.shouldFarmerPassout logic.</summary>
|
/// <summary>Try and emulate the old Game1.shouldFarmerPassout logic.</summary>
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Increase your health as you play.",
|
"Description": "Increase your health as you play.",
|
||||||
"UniqueID": "Omegasis.BuildEndurance",
|
"UniqueID": "Omegasis.BuildEndurance",
|
||||||
"EntryDll": "BuildEndurance.dll",
|
"EntryDll": "BuildEndurance.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:445" ]
|
"UpdateKeys": [ "Nexus:445" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Omegasis.BuildHealth.Framework;
|
using Omegasis.BuildHealth.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
|
@ -11,10 +10,10 @@ namespace Omegasis.BuildHealth
|
||||||
public class BuildHealth : Mod
|
public class BuildHealth : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The relative path for the current player's data file.</summary>
|
/// <summary>The relative path for the current player's data file.</summary>
|
||||||
private string DataFilePath => Path.Combine("data", $"{Constants.SaveFolderName}.json");
|
private string RelativeDataPath => Path.Combine("data", $"{Constants.SaveFolderName}.json");
|
||||||
|
|
||||||
/// <summary>The mod settings and player data.</summary>
|
/// <summary>The mod settings and player data.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -42,10 +41,9 @@ namespace Omegasis.BuildHealth
|
||||||
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
GameEvents.OneSecondTick += this.GameEvents_OneSecondTick;
|
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
|
||||||
TimeEvents.AfterDayStarted += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoaded;
|
|
||||||
|
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
}
|
}
|
||||||
|
@ -54,24 +52,18 @@ namespace Omegasis.BuildHealth
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked once per second during a game update.</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_OneSecondTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
|
||||||
// nerf how quickly tool xp is gained (I hope)
|
|
||||||
if (this.HasRecentToolExp)
|
|
||||||
this.HasRecentToolExp = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
|
|
||||||
/// <param name="sender">The event sender.</param>
|
|
||||||
/// <param name="e">The event data.</param>
|
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
if (!Context.IsWorldReady)
|
if (!Context.IsWorldReady)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// nerf how quickly tool xp is gained (I hope)
|
||||||
|
if (e.IsOneSecond && this.HasRecentToolExp)
|
||||||
|
this.HasRecentToolExp = false;
|
||||||
|
|
||||||
// give XP when player finishes eating
|
// give XP when player finishes eating
|
||||||
if (Game1.player.isEating)
|
if (Game1.player.isEating)
|
||||||
this.WasEating = true;
|
this.WasEating = true;
|
||||||
|
@ -106,10 +98,10 @@ namespace Omegasis.BuildHealth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked after the player loads a save.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterLoaded(object sender, EventArgs e)
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
// reset state
|
// reset state
|
||||||
this.HasRecentToolExp = false;
|
this.HasRecentToolExp = false;
|
||||||
|
@ -118,7 +110,7 @@ namespace Omegasis.BuildHealth
|
||||||
this.WasCollapsed = false;
|
this.WasCollapsed = false;
|
||||||
|
|
||||||
// load player data
|
// load player data
|
||||||
this.PlayerData = this.Helper.ReadJsonFile<PlayerData>(this.DataFilePath) ?? new PlayerData();
|
this.PlayerData = this.Helper.Data.ReadJsonFile<PlayerData>(this.RelativeDataPath) ?? new PlayerData();
|
||||||
if (this.PlayerData.OriginalMaxHealth == 0)
|
if (this.PlayerData.OriginalMaxHealth == 0)
|
||||||
this.PlayerData.OriginalMaxHealth = Game1.player.maxHealth;
|
this.PlayerData.OriginalMaxHealth = Game1.player.maxHealth;
|
||||||
|
|
||||||
|
@ -140,10 +132,10 @@ namespace Omegasis.BuildHealth
|
||||||
Game1.player.maxHealth = this.PlayerData.BaseHealthBonus + this.PlayerData.CurrentLevelHealthBonus + this.PlayerData.OriginalMaxHealth;
|
Game1.player.maxHealth = this.PlayerData.BaseHealthBonus + this.PlayerData.CurrentLevelHealthBonus + this.PlayerData.OriginalMaxHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked just before the game saves.</summary>
|
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
private void OnDayStarted(object sender, DayStartedEventArgs e)
|
||||||
{
|
{
|
||||||
// reset data
|
// reset data
|
||||||
this.LastHealth = Game1.player.maxHealth;
|
this.LastHealth = Game1.player.maxHealth;
|
||||||
|
@ -169,7 +161,7 @@ namespace Omegasis.BuildHealth
|
||||||
}
|
}
|
||||||
|
|
||||||
// save data
|
// save data
|
||||||
this.Helper.WriteJsonFile(this.DataFilePath, this.PlayerData);
|
this.Helper.Data.WriteJsonFile(this.RelativeDataPath, this.PlayerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool shouldFarmerPassout()
|
public bool shouldFarmerPassout()
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Increase your health as you play.",
|
"Description": "Increase your health as you play.",
|
||||||
"UniqueID": "Omegasis.BuildHealth",
|
"UniqueID": "Omegasis.BuildHealth",
|
||||||
"EntryDll": "BuildHealth.dll",
|
"EntryDll": "BuildHealth.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:446" ]
|
"UpdateKeys": [ "Nexus:446" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Omegasis.BuyBackCollectables
|
||||||
public class BuyBackCollectables : Mod
|
public class BuyBackCollectables : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -24,19 +24,19 @@ namespace Omegasis.BuyBackCollectables
|
||||||
{
|
{
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
public void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding)
|
if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding)
|
||||||
Game1.activeClickableMenu = new BuyBackMenu(this.Config.CostMultiplier);
|
Game1.activeClickableMenu = new BuyBackMenu(this.Config.CostMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Omegasis.BuyBackCollectables.Framework
|
||||||
internal class BuyBackMenu : IClickableMenu
|
internal class BuyBackMenu : IClickableMenu
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The organics tab ID.</summary>
|
/// <summary>The organics tab ID.</summary>
|
||||||
private const int OrganicsTab = 0;
|
private const int OrganicsTab = 0;
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace Omegasis.BuyBackCollectables.Framework
|
namespace Omegasis.BuyBackCollectables.Framework
|
||||||
{
|
{
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
internal class ModConfig
|
internal class ModConfig
|
||||||
{
|
{
|
||||||
/// <summary>The key which shows the menu.</summary>
|
/// <summary>The key which shows the menu.</summary>
|
||||||
public string KeyBinding { get; set; } = "B";
|
public SButton KeyBinding { get; set; } = SButton.B;
|
||||||
|
|
||||||
/// <summary>The multiplier applied to the cost of buying back a collectable.</summary>
|
/// <summary>The multiplier applied to the cost of buying back a collectable.</summary>
|
||||||
public double CostMultiplier { get; set; } = 3.0;
|
public double CostMultiplier { get; set; } = 3.0;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Lets you buy back any obtained collectable.",
|
"Description": "Lets you buy back any obtained collectable.",
|
||||||
"UniqueID": "Omegasis.BuyBackCollectables",
|
"UniqueID": "Omegasis.BuyBackCollectables",
|
||||||
"EntryDll": "BuyBackCollectables.dll",
|
"EntryDll": "BuyBackCollectables.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:507" ]
|
"UpdateKeys": [ "Nexus:507" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using CustomNPCFramework.Framework.Enums;
|
using CustomNPCFramework.Framework.Enums;
|
||||||
using CustomNPCFramework.Framework.Graphics;
|
using CustomNPCFramework.Framework.Graphics;
|
||||||
using CustomNPCFramework.Framework.ModularNpcs.ColorCollections;
|
using CustomNPCFramework.Framework.ModularNpcs.ColorCollections;
|
||||||
|
@ -8,6 +9,7 @@ using CustomNPCFramework.Framework.NPCS;
|
||||||
using CustomNPCFramework.Framework.Utilities;
|
using CustomNPCFramework.Framework.Utilities;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
|
using StardewModdingAPI.Events;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
|
||||||
namespace CustomNPCFramework
|
namespace CustomNPCFramework
|
||||||
|
@ -63,13 +65,10 @@ namespace CustomNPCFramework
|
||||||
ModMonitor = this.Monitor;
|
ModMonitor = this.Monitor;
|
||||||
Manifest = this.ModManifest;
|
Manifest = this.ModManifest;
|
||||||
|
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_LoadChar;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saved += this.OnSaved;
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterSave += this.SaveEvents_AfterSave;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
|
|
||||||
StardewModdingAPI.Events.PlayerEvents.Warped += this.LocationEvents_CurrentLocationChanged;
|
|
||||||
StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
|
||||||
npcTracker = new NpcTracker();
|
npcTracker = new NpcTracker();
|
||||||
assetPool = new AssetPool();
|
assetPool = new AssetPool();
|
||||||
var assetManager = new AssetManager();
|
var assetManager = new AssetManager();
|
||||||
|
@ -82,31 +81,34 @@ namespace CustomNPCFramework
|
||||||
/// <summary>Initialize the asset pool with some test variables.</summary>
|
/// <summary>Initialize the asset pool with some test variables.</summary>
|
||||||
public void initializeAssetPool()
|
public void initializeAssetPool()
|
||||||
{
|
{
|
||||||
string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS");
|
string relativePath = Path.Combine("Content", "Graphics", "NPCS");
|
||||||
assetPool.getAssetManager("testNPC").addPathCreateDirectory(new KeyValuePair<string, string>("characters", path));
|
assetPool.getAssetManager("testNPC").addPathCreateDirectory(new KeyValuePair<string, string>("characters", relativePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>A function that is called when the game finishes saving.</summary>
|
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterSave(object sender, EventArgs e)
|
private void OnSaved(object sender, SavedEventArgs e)
|
||||||
{
|
{
|
||||||
npcTracker.afterSave();
|
npcTracker.afterSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>A function that is called when the game is about to load. Used to clean up all the npcs from the game world to prevent it from crashing.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
private void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
|
// clean up all the npcs from the game world to prevent it from crashing
|
||||||
npcTracker.cleanUpBeforeSave();
|
npcTracker.cleanUpBeforeSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Called upon 60 times a second. For testing purposes only. Will remove in future release.</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
|
// TODO For testing purposes only. Will remove in future release.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (Game1.player.currentLocation == null) return;
|
if (Game1.player.currentLocation == null) return;
|
||||||
if (Game1.activeClickableMenu != null) return;
|
if (Game1.activeClickableMenu != null) return;
|
||||||
|
@ -123,16 +125,13 @@ namespace CustomNPCFramework
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Called when the player's location changes.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsPlayerWarped e) { }
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
|
|
||||||
/// <summary>Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE</summary>
|
|
||||||
/// <param name="sender">The event sender.</param>
|
|
||||||
/// <param name="e">The event arguments.</param>
|
|
||||||
private void SaveEvents_LoadChar(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
|
// TODO Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE
|
||||||
|
|
||||||
ExtendedNpc myNpc3 = assetPool.generateNPC(Genders.female, 0, 1, new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null));
|
ExtendedNpc myNpc3 = assetPool.generateNPC(Genders.female, 0, 1, new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null));
|
||||||
MerchantNpc merch = new MerchantNpc(new List<Item>()
|
MerchantNpc merch = new MerchantNpc(new List<Item>()
|
||||||
{
|
{
|
||||||
|
@ -145,52 +144,40 @@ namespace CustomNPCFramework
|
||||||
public void initializeExamples()
|
public void initializeExamples()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
string dirPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Templates");
|
string relativeDirPath = Path.Combine("Content", "Templates");
|
||||||
var aManager = assetPool.getAssetManager("testNPC");
|
var aManager = assetPool.getAssetManager("testNPC");
|
||||||
aManager.addPathCreateDirectory(new KeyValuePair<string, string>("templates", dirPath));
|
aManager.addPathCreateDirectory(new KeyValuePair<string, string>("templates", relativeDirPath));
|
||||||
string filePath = Path.Combine(dirPath, "Example.json");
|
|
||||||
if (!File.Exists(filePath))
|
|
||||||
{
|
|
||||||
string getRelativePath = getShortenedDirectory(filePath);
|
|
||||||
ModMonitor.Log("THIS IS THE PATH::: " + getRelativePath);
|
|
||||||
AssetInfo info = new AssetInfo("MyExample", new NamePairings("StandingExampleL", "StandingExampleR", "StandingExampleU", "StandingExampleD"), new NamePairings("MovingExampleL", "MovingExampleR", "MovingExampleU", "MovingExampleD"), new NamePairings("SwimmingExampleL", "SwimmingExampleR", "SwimmingExampleU", "SwimmingExampleD"), new NamePairings("SittingExampleL", "SittingExampleR", "SittingExampleU", "SittingExampleD"), new Vector2(16, 16), false);
|
|
||||||
info.writeToJson(filePath);
|
|
||||||
|
|
||||||
}
|
// write example
|
||||||
string filePath2 = Path.Combine(dirPath, "AdvancedExample.json");
|
|
||||||
if (!File.Exists(filePath2))
|
|
||||||
{
|
{
|
||||||
|
string relativeFilePath = Path.Combine(relativeDirPath, "Example.json");
|
||||||
|
if (!File.Exists(Path.Combine(this.Helper.DirectoryPath, relativeFilePath)))
|
||||||
|
{
|
||||||
|
ModMonitor.Log("THIS IS THE PATH::: " + relativeFilePath);
|
||||||
|
AssetInfo info = new AssetInfo("MyExample", new NamePairings("StandingExampleL", "StandingExampleR", "StandingExampleU", "StandingExampleD"), new NamePairings("MovingExampleL", "MovingExampleR", "MovingExampleU", "MovingExampleD"), new NamePairings("SwimmingExampleL", "SwimmingExampleR", "SwimmingExampleU", "SwimmingExampleD"), new NamePairings("SittingExampleL", "SittingExampleR", "SittingExampleU", "SittingExampleD"), new Vector2(16, 16), false);
|
||||||
|
info.writeToJson(relativeFilePath);
|
||||||
|
|
||||||
ExtendedAssetInfo info2 = new ExtendedAssetInfo("AdvancedExample", new NamePairings("AdvancedStandingExampleL", "AdvancedStandingExampleR", "AdvancedStandingExampleU", "AdvancedStandingExampleD"), new NamePairings("AdvancedMovingExampleL", "AdvancedMovingExampleR", "AdvancedMovingExampleU", "AdvancedMovingExampleD"), new NamePairings("AdvancedSwimmingExampleL", "AdvancedSwimmingExampleR", "AdvancedSwimmingExampleU", "AdvancedSwimmingExampleD"), new NamePairings("AdvancedSittingExampleL", "AdvancedSittingExampleR", "AdvancedSittingExampleU", "AdvancedSittingExampleD"), new Vector2(16, 16), false, Genders.female, new List<Seasons>()
|
}
|
||||||
{
|
|
||||||
Seasons.spring,
|
|
||||||
Seasons.summer
|
|
||||||
}, PartType.hair
|
|
||||||
);
|
|
||||||
info2.writeToJson(filePath2);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Used to splice the mod directory to get relative paths.</summary>
|
// write advanced example
|
||||||
public static string getShortenedDirectory(string path)
|
|
||||||
{
|
|
||||||
string lol = (string)path.Clone();
|
|
||||||
string[] spliter = lol.Split(new string[] { ModHelper.DirectoryPath }, StringSplitOptions.None);
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
return spliter[1];
|
string relativeFilePath = Path.Combine(relativeDirPath, "AdvancedExample.json");
|
||||||
}
|
if (!File.Exists(Path.Combine(this.Helper.DirectoryPath, relativeFilePath)))
|
||||||
catch
|
{
|
||||||
{
|
ExtendedAssetInfo info2 = new ExtendedAssetInfo("AdvancedExample", new NamePairings("AdvancedStandingExampleL", "AdvancedStandingExampleR", "AdvancedStandingExampleU", "AdvancedStandingExampleD"), new NamePairings("AdvancedMovingExampleL", "AdvancedMovingExampleR", "AdvancedMovingExampleU", "AdvancedMovingExampleD"), new NamePairings("AdvancedSwimmingExampleL", "AdvancedSwimmingExampleR", "AdvancedSwimmingExampleU", "AdvancedSwimmingExampleD"), new NamePairings("AdvancedSittingExampleL", "AdvancedSittingExampleR", "AdvancedSittingExampleU", "AdvancedSittingExampleD"), new Vector2(16, 16), false, Genders.female, new List<Seasons>() { Seasons.spring, Seasons.summer }, PartType.hair);
|
||||||
return spliter[0];
|
info2.writeToJson(relativeFilePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Used to finish cleaning up absolute asset paths into a shortened relative path.</summary>
|
/// <summary>Used to finish cleaning up absolute asset paths into a shortened relative path.</summary>
|
||||||
public static string getRelativeDirectory(string path)
|
public static string getRelativeDirectory(string path)
|
||||||
{
|
{
|
||||||
string s = getShortenedDirectory(path);
|
return path
|
||||||
return s.Remove(0, 1);
|
.Split(new[] { ModHelper.DirectoryPath }, 2, StringSplitOptions.None)
|
||||||
|
.Last()
|
||||||
|
.TrimStart(Path.DirectorySeparatorChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,17 +49,17 @@ namespace CustomNPCFramework.Framework.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Save the json to a certain location.</summary>
|
/// <summary>Save the json to a certain location.</summary>
|
||||||
/// <param name="path">The absolute path to save.</param>
|
/// <param name="relativeFilePath">The relative path to save.</param>
|
||||||
public void writeToJson(string path)
|
public void writeToJson(string relativeFilePath)
|
||||||
{
|
{
|
||||||
Class1.ModHelper.WriteJsonFile<AssetInfo>(path, this);
|
Class1.ModHelper.Data.WriteJsonFile(relativeFilePath, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Read the json from a certain location.</summary>
|
/// <summary>Read the json from a certain location.</summary>
|
||||||
/// <param name="path">The absolute path to save.</param>
|
/// <param name="relativePath">The relative path to save.</param>
|
||||||
public static AssetInfo readFromJson(string path)
|
public static AssetInfo readFromJson(string relativePath)
|
||||||
{
|
{
|
||||||
return Class1.ModHelper.ReadJsonFile<AssetInfo>(path);
|
return Class1.ModHelper.Data.ReadJsonFile<AssetInfo>(relativePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using CustomNPCFramework.Framework.Enums;
|
using CustomNPCFramework.Framework.Enums;
|
||||||
|
@ -9,65 +8,48 @@ namespace CustomNPCFramework.Framework.Graphics
|
||||||
public class AssetManager
|
public class AssetManager
|
||||||
{
|
{
|
||||||
/// <summary>A list of all of the assets held by this asset manager.</summary>
|
/// <summary>A list of all of the assets held by this asset manager.</summary>
|
||||||
public List<AssetSheet> assets;
|
public List<AssetSheet> assets { get; } = new List<AssetSheet>();
|
||||||
|
|
||||||
/// <summary>A list of all of the directories managed by this asset manager.</summary>
|
/// <summary>A list of directories managed by this asset manager, relative to the mod folder.</summary>
|
||||||
public Dictionary<string, string> paths;
|
public Dictionary<string, string> relativePaths { get; } = new Dictionary<string, string>();
|
||||||
|
|
||||||
/// <summary>Construct an instance.</summary>
|
|
||||||
public AssetManager()
|
|
||||||
{
|
|
||||||
this.assets = new List<AssetSheet>();
|
|
||||||
this.paths = new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Construct an instance.</summary>
|
|
||||||
/// <param name="assetsPathsToLoadFrom">A list of all directories to be managed by the asset manager. Name, path is the key pair value.</param>
|
|
||||||
public AssetManager(Dictionary<string, string> assetsPathsToLoadFrom)
|
|
||||||
{
|
|
||||||
this.assets = new List<AssetSheet>();
|
|
||||||
this.paths = assetsPathsToLoadFrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Default loading function from hardcoded paths.</summary>
|
/// <summary>Default loading function from hardcoded paths.</summary>
|
||||||
public void loadAssets()
|
public void loadAssets()
|
||||||
{
|
{
|
||||||
foreach (var path in this.paths)
|
foreach (var relativePath in this.relativePaths)
|
||||||
this.ProcessDirectory(path.Value);
|
this.ProcessDirectory(relativePath.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Process all .json files in the given directory. If there are more nested directories, keep digging to find more .json files. Also allows us to specify a broader directory like Content/Grahphics/ModularNPC/Hair to have multiple hair styles.</summary>
|
/// <summary>Process all .json files in the given directory. If there are more nested directories, keep digging to find more .json files. Also allows us to specify a broader directory like Content/Grahphics/ModularNPC/Hair to have multiple hair styles.</summary>
|
||||||
/// <param name="targetDirectory">The absolute directory path to process.</param>
|
/// <param name="relativeDirPath">The relative directory path to process.</param>
|
||||||
/// <remarks>Taken from Microsoft c# documented webpages.</remarks>
|
/// <remarks>Taken from Microsoft c# documented webpages.</remarks>
|
||||||
private void ProcessDirectory(string targetDirectory)
|
private void ProcessDirectory(string relativeDirPath)
|
||||||
{
|
{
|
||||||
// Process the list of files found in the directory.
|
DirectoryInfo root = new DirectoryInfo(Path.Combine(Class1.ModHelper.DirectoryPath, relativeDirPath));
|
||||||
string[] files = Directory.GetFiles(targetDirectory, "*.json");
|
foreach (FileInfo file in root.GetFiles("*.json"))
|
||||||
foreach (string file in files)
|
this.ProcessFile(Path.Combine(relativeDirPath, file.Name), relativeDirPath);
|
||||||
this.ProcessFile(file, targetDirectory);
|
|
||||||
|
|
||||||
// Recurse into subdirectories of this directory.
|
// Recurse into subdirectories of this directory.
|
||||||
string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
|
foreach (DirectoryInfo subdir in root.GetDirectories())
|
||||||
foreach (string subdirectory in subdirectoryEntries)
|
this.ProcessDirectory(Path.Combine(relativeDirPath, subdir.Name));
|
||||||
this.ProcessDirectory(subdirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Actually load in the asset information.</summary>
|
/// <summary>Actually load in the asset information.</summary>
|
||||||
/// <param name="file">The absolute file path to process.</param>
|
/// <param name="relativeFilePath">The relative path to the file to process.</param>
|
||||||
/// <param name="path">The absolute directory path containing the file.</param>
|
/// <param name="relativeDirPath">The relative path containing the file.</param>
|
||||||
private void ProcessFile(string file, string path)
|
private void ProcessFile(string relativeFilePath, string relativeDirPath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ExtendedAssetInfo info = ExtendedAssetInfo.readFromJson(file);
|
ExtendedAssetInfo info = ExtendedAssetInfo.readFromJson(relativeFilePath);
|
||||||
AssetSheet sheet = new AssetSheet(info, path);
|
AssetSheet sheet = new AssetSheet(info, relativeDirPath);
|
||||||
this.addAsset(sheet);
|
this.addAsset(sheet);
|
||||||
Class1.ModMonitor.Log("Loaded in new modular asset: " + info.assetName + " asset type: " + info.type);
|
Class1.ModMonitor.Log("Loaded in new modular asset: " + info.assetName + " asset type: " + info.type);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
AssetInfo info = AssetInfo.readFromJson(file);
|
AssetInfo info = AssetInfo.readFromJson(relativeFilePath);
|
||||||
AssetSheet sheet = new AssetSheet(info, path);
|
AssetSheet sheet = new AssetSheet(info, relativeDirPath);
|
||||||
this.addAsset(sheet);
|
this.addAsset(sheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,16 +84,16 @@ namespace CustomNPCFramework.Framework.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Add a path to the dictionary.</summary>
|
/// <summary>Add a path to the dictionary.</summary>
|
||||||
/// <param name="path">The absolute path to add.</param>
|
/// <param name="path">The relative path to add.</param>
|
||||||
private void addPath(KeyValuePair<string, string> path)
|
private void addPath(KeyValuePair<string, string> path)
|
||||||
{
|
{
|
||||||
this.paths.Add(path.Key, path.Value);
|
this.relativePaths.Add(path.Key, path.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Create appropriate directories for the path.</summary>
|
/// <summary>Create appropriate directories for the path.</summary>
|
||||||
private void createDirectoriesFromPaths()
|
private void createDirectoriesFromPaths()
|
||||||
{
|
{
|
||||||
foreach (var v in this.paths)
|
foreach (var v in this.relativePaths)
|
||||||
Directory.CreateDirectory(Path.Combine(Class1.ModHelper.DirectoryPath, v.Value));
|
Directory.CreateDirectory(Path.Combine(Class1.ModHelper.DirectoryPath, v.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ namespace CustomNPCFramework.Framework.Graphics
|
||||||
return new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection, drawColors);
|
return new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection, drawColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Get the string for the standard character sprite to be used from this asset sheet.</summary>
|
/// <summary>Get the relative path for the standard character sprite to be used from this asset sheet.</summary>
|
||||||
/// <param name="imageGraphics">The standard asset sheet to be used.</param>
|
/// <param name="imageGraphics">The standard asset sheet to be used.</param>
|
||||||
public virtual string getDefaultSpriteImage(AssetSheet imageGraphics)
|
public virtual string getDefaultSpriteImage(AssetSheet imageGraphics)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,21 +25,13 @@ namespace CustomNPCFramework.Framework.Graphics
|
||||||
|
|
||||||
/// <summary>Construct an instance.</summary>
|
/// <summary>Construct an instance.</summary>
|
||||||
/// <param name="info">The asset info file to be read in or created. Holds path information.</param>
|
/// <param name="info">The asset info file to be read in or created. Holds path information.</param>
|
||||||
/// <param name="path">The path to the assetinfo file.</param>
|
/// <param name="relativeDirPath">The relative path to the assetinfo file.</param>
|
||||||
/// <param name="direction">The direction to set the animation.</param>
|
/// <param name="direction">The direction to set the animation.</param>
|
||||||
public AssetSheet(AssetInfo info, string path, Direction direction = Direction.down)
|
public AssetSheet(AssetInfo info, string relativeDirPath, Direction direction = Direction.down)
|
||||||
{
|
{
|
||||||
this.assetInfo = info;
|
this.assetInfo = info;
|
||||||
this.textures = new TextureGroup(info, path, direction);
|
this.textures = new TextureGroup(info, relativeDirPath, direction);
|
||||||
try
|
this.path = relativeDirPath;
|
||||||
{
|
|
||||||
this.path = Class1.getShortenedDirectory(path);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,17 +56,12 @@ namespace CustomNPCFramework.Framework.Graphics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DirectionalTexture(IModHelper helper, NamePairings info, string path, Direction direction = Direction.down)
|
public DirectionalTexture(IModHelper helper, NamePairings info, string relativePath, Direction direction = Direction.down)
|
||||||
{
|
{
|
||||||
string leftString = Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1);
|
this.leftTexture = new Texture2DExtended(helper, Path.Combine(relativePath, $"{info.leftString}.png"));
|
||||||
string rightString = Class1.getShortenedDirectory(Path.Combine(path, info.rightString + ".png")).Remove(0, 1);
|
this.rightTexture = new Texture2DExtended(helper, Path.Combine(relativePath, $"{info.rightString}.png"));
|
||||||
string upString = Class1.getShortenedDirectory(Path.Combine(path, info.upString + ".png")).Remove(0, 1);
|
this.upTexture = new Texture2DExtended(helper, Path.Combine(relativePath, $"{info.upString}.png"));
|
||||||
string downString = Class1.getShortenedDirectory(Path.Combine(path, info.downString + ".png")).Remove(0, 1);
|
this.downTexture = new Texture2DExtended(helper, Path.Combine(relativePath, $"{info.downString}.png"));
|
||||||
|
|
||||||
this.leftTexture = new Texture2DExtended(helper, leftString);
|
|
||||||
this.rightTexture = new Texture2DExtended(helper, rightString);
|
|
||||||
this.upTexture = new Texture2DExtended(helper, upString);
|
|
||||||
this.downTexture = new Texture2DExtended(helper, downString);
|
|
||||||
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,17 +39,17 @@ namespace CustomNPCFramework.Framework.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Save the json to a certain location.</summary>
|
/// <summary>Save the json to a certain location.</summary>
|
||||||
/// <param name="path">The absolute path to write.</param>
|
/// <param name="relativePath">The relative path to write.</param>
|
||||||
public new void writeToJson(string path)
|
public new void writeToJson(string relativePath)
|
||||||
{
|
{
|
||||||
Class1.ModHelper.WriteJsonFile<ExtendedAssetInfo>(path, this);
|
Class1.ModHelper.Data.WriteJsonFile<ExtendedAssetInfo>(relativePath, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Read the json from a certain location.</summary>
|
/// <summary>Read the json from a certain location.</summary>
|
||||||
/// <param name="path">The absolute path to read.</param>
|
/// <param name="relativePath">The relative path to read.</param>
|
||||||
public new static ExtendedAssetInfo readFromJson(string path)
|
public new static ExtendedAssetInfo readFromJson(string relativePath)
|
||||||
{
|
{
|
||||||
return Class1.ModHelper.ReadJsonFile<ExtendedAssetInfo>(path);
|
return Class1.ModHelper.Data.ReadJsonFile<ExtendedAssetInfo>(relativePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,10 @@ namespace CustomNPCFramework.Framework.ModularNpcs
|
||||||
public string relativePath;
|
public string relativePath;
|
||||||
|
|
||||||
/// <summary>Construct an instance.</summary>
|
/// <summary>Construct an instance.</summary>
|
||||||
/// <param name="path">The full path to the file.</param>
|
/// <param name="relativePath">The relative path to the file.</param>
|
||||||
public Sprite(string path)
|
public Sprite(string relativePath)
|
||||||
{
|
{
|
||||||
try
|
this.relativePath = relativePath;
|
||||||
{
|
|
||||||
this.relativePath = Class1.getShortenedDirectory(path);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
this.relativePath = path;
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.sprite = new AnimatedSprite();
|
this.sprite = new AnimatedSprite();
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
{
|
{
|
||||||
"Name": "CustomNPCFramework",
|
"Name": "Custom NPC Framework",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "0.1.0",
|
"Version": "0.1.0",
|
||||||
"Description": "A system to add custom npcs to Stardew.",
|
"Description": "A system to add custom NPCs to Stardew.",
|
||||||
"UniqueID": "Omegasis.CustomNPCFramework",
|
"UniqueID": "Omegasis.CustomNPCFramework",
|
||||||
"EntryDll": "CustomNPCFramework.dll",
|
"EntryDll": "CustomNPCFramework.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": []
|
"UpdateKeys": [],
|
||||||
|
"Dependencies": [
|
||||||
|
{ "UniqueID": "Omegasis.StardustCore" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Omegasis.DailyQuestAnywhere
|
||||||
public class DailyQuestAnywhere : Mod
|
public class DailyQuestAnywhere : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -32,43 +32,43 @@ namespace Omegasis.DailyQuestAnywhere
|
||||||
{
|
{
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
SaveEvents.AfterSave += this.SaveEvents_AfterSave;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding)
|
if (Context.IsPlayerFree && e.Button == this.Config.KeyBinding)
|
||||||
|
{
|
||||||
if (!Game1.player.hasDailyQuest())
|
if (!Game1.player.hasDailyQuest())
|
||||||
{
|
{
|
||||||
if (this.dailyQuest == null)
|
if (this.dailyQuest == null)
|
||||||
{
|
|
||||||
this.dailyQuest = this.generateDailyQuest();
|
this.dailyQuest = this.generateDailyQuest();
|
||||||
}
|
|
||||||
Game1.questOfTheDay = this.dailyQuest;
|
Game1.questOfTheDay = this.dailyQuest;
|
||||||
Game1.activeClickableMenu = new Billboard(true);
|
Game1.activeClickableMenu = new Billboard(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Makes my daily quest referene null so we can't just keep getting a new reference.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterSave(object sender, System.EventArgs e)
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
this.dailyQuest = null; //Nullify my quest reference.
|
// makes daily quest null so we can't just keep getting a new reference
|
||||||
|
this.dailyQuest = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Generate a daily quest for sure.</summary>
|
/// <summary>Generate a daily quest for sure.</summary>
|
||||||
public Quest generateDailyQuest()
|
public Quest generateDailyQuest()
|
||||||
{
|
{
|
||||||
|
|
||||||
Random chanceRandom = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed);
|
Random chanceRandom = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed);
|
||||||
int chance = chanceRandom.Next(0, 101);
|
int chance = chanceRandom.Next(0, 101);
|
||||||
float actualChance = chance / 100;
|
float actualChance = chance / 100;
|
||||||
|
@ -85,15 +85,15 @@ namespace Omegasis.DailyQuestAnywhere
|
||||||
case 1:
|
case 1:
|
||||||
return new FishingQuest();
|
return new FishingQuest();
|
||||||
case 2:
|
case 2:
|
||||||
return new StardewValley.Quests.CraftingQuest();
|
return new CraftingQuest();
|
||||||
case 3:
|
case 3:
|
||||||
return new StardewValley.Quests.ItemDeliveryQuest();
|
return new ItemDeliveryQuest();
|
||||||
case 4:
|
case 4:
|
||||||
return new StardewValley.Quests.ItemHarvestQuest();
|
return new ItemHarvestQuest();
|
||||||
case 5:
|
case 5:
|
||||||
return new StardewValley.Quests.ResourceCollectionQuest();
|
return new ResourceCollectionQuest();
|
||||||
case 6:
|
case 6:
|
||||||
return new StardewValley.Quests.SlayMonsterQuest();
|
return new SlayMonsterQuest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null; //This should never happen.
|
return null; //This should never happen.
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace Omegasis.DailyQuestAnywhere.Framework
|
namespace Omegasis.DailyQuestAnywhere.Framework
|
||||||
{
|
{
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
internal class ModConfig
|
internal class ModConfig
|
||||||
{
|
{
|
||||||
/// <summary>The key which shows the menu.</summary>
|
/// <summary>The key which shows the menu.</summary>
|
||||||
public string KeyBinding { get; set; } = "H";
|
public SButton KeyBinding { get; set; } = SButton.H;
|
||||||
|
|
||||||
/// <summary>The chance for a daily quest to actually happen.</summary>
|
/// <summary>The chance for a daily quest to actually happen.</summary>
|
||||||
public float chanceForDailyQuest { get; set; } = .75f;
|
public float chanceForDailyQuest { get; set; } = .75f;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Open the daily quest board from anywhere in the game.",
|
"Description": "Open the daily quest board from anywhere in the game.",
|
||||||
"UniqueID": "Omegasis.DailyQuestAnywhere",
|
"UniqueID": "Omegasis.DailyQuestAnywhere",
|
||||||
"EntryDll": "DailyQuestAnywhere.dll",
|
"EntryDll": "DailyQuestAnywhere.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:513" ]
|
"UpdateKeys": [ "Nexus:513" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
using StardewModdingAPI.Events;
|
using StardewModdingAPI.Events;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
@ -15,17 +14,17 @@ namespace Omegasis.Fall28SnowDay
|
||||||
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked just before the game saves.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
public void SaveEvents_BeforeSave(object sender, EventArgs e)
|
public void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
if (Game1.IsFall && Game1.dayOfMonth == 27)
|
if (Game1.IsFall && Game1.dayOfMonth == 27)
|
||||||
Game1.weatherForTomorrow = Game1.weather_snow;
|
Game1.weatherForTomorrow = Game1.weather_snow;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Makes it snow on Fall 28, which makes a good explanation for all the snow on the next day.",
|
"Description": "Makes it snow on Fall 28, which makes a good explanation for all the snow on the next day.",
|
||||||
"UniqueID": "Omegasis.Fall28SnowDay",
|
"UniqueID": "Omegasis.Fall28SnowDay",
|
||||||
"EntryDll": "Fall28SnowDay.dll",
|
"EntryDll": "Fall28SnowDay.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:486" ]
|
"UpdateKeys": [ "Nexus:486" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using EventSystem.Framework.FunctionEvents;
|
||||||
using FarmersMarketStall.Framework.MapEvents;
|
using FarmersMarketStall.Framework.MapEvents;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
|
using StardewModdingAPI.Events;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
|
||||||
namespace FarmersMarketStall
|
namespace FarmersMarketStall
|
||||||
|
@ -29,17 +30,23 @@ namespace FarmersMarketStall
|
||||||
ModHelper = this.Helper;
|
ModHelper = this.Helper;
|
||||||
ModMonitor = this.Monitor;
|
ModMonitor = this.Monitor;
|
||||||
|
|
||||||
StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
marketStall = new Framework.MarketStall();
|
marketStall = new Framework.MarketStall();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
|
/// <param name="sender">The event sender.</param>
|
||||||
|
/// <param name="e">The event arguments.</param>
|
||||||
|
private void OnSaveLoaded(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new ShopInteractionEvent("FarmersMarketStall", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new MouseButtonEvents(null, true), new MouseEntryLeaveEvent(null, null)));
|
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new ShopInteractionEvent("FarmersMarketStall", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new MouseButtonEvents(null, true), new MouseEntryLeaveEvent(null, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
|
/// <param name="sender">The event sender.</param>
|
||||||
|
/// <param name="e">The event arguments.</param>
|
||||||
|
private void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
if (marketStall.stock.Count > 0)
|
if (marketStall.stock.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"Name": "FarmersMarketStall",
|
"Name": "Farmers Market Stall",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "0.1.0",
|
"Version": "0.1.0",
|
||||||
"Description": "A system to add a farmers market stall to Sundrop.",
|
"Description": "A system to add a farmers market stall to Sundrop.",
|
||||||
"UniqueID": "SunDrop.SunDropMapEvents.FarmersMarketStall",
|
"UniqueID": "SunDrop.SunDropMapEvents.FarmersMarketStall",
|
||||||
"EntryDll": "FarmersMarketStall.dll",
|
"EntryDll": "FarmersMarketStall.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [],
|
"UpdateKeys": [],
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
{ "UniqueID": "Omegasis.EventSystem" }
|
{ "UniqueID": "Omegasis.EventSystem" }
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Omegasis.HappyBirthday.Framework
|
||||||
internal class BirthdayMenu : IClickableMenu
|
internal class BirthdayMenu : IClickableMenu
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The labels to draw.</summary>
|
/// <summary>The labels to draw.</summary>
|
||||||
private readonly List<ClickableComponent> Labels = new List<ClickableComponent>();
|
private readonly List<ClickableComponent> Labels = new List<ClickableComponent>();
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace Omegasis.HappyBirthday.Framework
|
namespace Omegasis.HappyBirthday.Framework
|
||||||
{
|
{
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
public class ModConfig
|
public class ModConfig
|
||||||
{
|
{
|
||||||
/// <summary>The key which shows the menu.</summary>
|
/// <summary>The key which shows the menu.</summary>
|
||||||
public string KeyBinding { get; set; } = "O";
|
public SButton KeyBinding { get; set; } = SButton.O;
|
||||||
|
|
||||||
/// <summary>The minimum amount of friendship needed to get a birthday gift.</summary>
|
/// <summary>The minimum amount of friendship needed to get a birthday gift.</summary>
|
||||||
public int minNeutralFriendshipGiftLevel = 3;
|
public int minNeutralFriendshipGiftLevel = 3;
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Omegasis.HappyBirthday.Framework
|
||||||
internal class ObjectUtility
|
internal class ObjectUtility
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The cached object data.</summary>
|
/// <summary>The cached object data.</summary>
|
||||||
private static readonly Object[] ObjectList = ObjectUtility.GetAllObjects().ToArray();
|
private static readonly Object[] ObjectList = ObjectUtility.GetAllObjects().ToArray();
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Omegasis.HappyBirthday
|
||||||
public class HappyBirthday : Mod, IAssetEditor
|
public class HappyBirthday : Mod, IAssetEditor
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The relative path for the current player's data file.</summary>
|
/// <summary>The relative path for the current player's data file.</summary>
|
||||||
private string DataFilePath;
|
private string DataFilePath;
|
||||||
|
@ -76,16 +76,15 @@ namespace Omegasis.HappyBirthday
|
||||||
//helper.Content.AssetLoaders.Add(new PossibleGifts());
|
//helper.Content.AssetLoaders.Add(new PossibleGifts());
|
||||||
Config = helper.ReadConfig<ModConfig>();
|
Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted;
|
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
MenuEvents.MenuChanged += this.MenuEvents_MenuChanged;
|
helper.Events.Display.MenuChanged += this.OnMenuChanged;
|
||||||
MenuEvents.MenuClosed += this.MenuEvents_MenuClosed;
|
|
||||||
|
|
||||||
GraphicsEvents.OnPostRenderGuiEvent += this.GraphicsEvents_OnPostRenderGuiEvent;
|
helper.Events.Display.RenderedActiveMenu += this.OnRenderedActiveMenu;
|
||||||
StardewModdingAPI.Events.GraphicsEvents.OnPostRenderHudEvent += this.GraphicsEvents_OnPostRenderHudEvent;
|
helper.Events.Display.RenderedHud += this.OnRenderedHud;
|
||||||
//MultiplayerSupport.initializeMultiplayerSupport();
|
//MultiplayerSupport.initializeMultiplayerSupport();
|
||||||
ModHelper = this.Helper;
|
ModHelper = this.Helper;
|
||||||
ModMonitor = this.Monitor;
|
ModMonitor = this.Monitor;
|
||||||
|
@ -113,13 +112,9 @@ namespace Omegasis.HappyBirthday
|
||||||
/// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
|
/// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
|
||||||
public void Edit<T>(IAssetData asset)
|
public void Edit<T>(IAssetData asset)
|
||||||
{
|
{
|
||||||
asset
|
IDictionary<string, string> data = asset.AsDictionary<string, string>().Data;
|
||||||
.AsDictionary<string, string>()
|
data["birthdayMom"] = "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%";
|
||||||
.Set("birthdayMom", "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%");
|
data["birthdayDad"] = "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%";
|
||||||
|
|
||||||
asset
|
|
||||||
.AsDictionary<string, string>()
|
|
||||||
.Set("birthdayDad", "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,33 +156,25 @@ namespace Omegasis.HappyBirthday
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Used to check when a menu is closed.</summary>
|
/// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e)
|
private void OnRenderedHud(object sender, RenderedHudEventArgs e)
|
||||||
{
|
{
|
||||||
this.isDailyQuestBoard = false;
|
if (Game1.activeClickableMenu == null || this.PlayerData?.BirthdaySeason?.ToLower() != Game1.currentSeason.ToLower())
|
||||||
}
|
return;
|
||||||
|
|
||||||
/// <summary>Used to properly display hovertext for all events happening on a calendar day.</summary>
|
if (Game1.activeClickableMenu is Billboard billboard)
|
||||||
/// <param name="sender">The event sender.</param>
|
|
||||||
/// <param name="e">The event arguments.</param>
|
|
||||||
private void GraphicsEvents_OnPostRenderHudEvent(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (Game1.activeClickableMenu == null) return;
|
|
||||||
if (this.PlayerData?.BirthdaySeason == null) return;
|
|
||||||
if (this.PlayerData.BirthdaySeason.ToLower() != Game1.currentSeason.ToLower()) return;
|
|
||||||
if (Game1.activeClickableMenu is Billboard)
|
|
||||||
{
|
{
|
||||||
if (this.isDailyQuestBoard) return;
|
if (this.isDailyQuestBoard || billboard.calendarDays == null)
|
||||||
if ((Game1.activeClickableMenu as Billboard).calendarDays == null) return;
|
return;
|
||||||
|
|
||||||
//Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 1f, 4f, 2, Game1.player);
|
//Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 1f, 4f, 2, Game1.player);
|
||||||
|
|
||||||
string hoverText = "";
|
string hoverText = "";
|
||||||
List<string> texts = new List<string>();
|
List<string> texts = new List<string>();
|
||||||
|
|
||||||
foreach (var clicky in ((Billboard)Game1.activeClickableMenu).calendarDays)
|
foreach (var clicky in billboard.calendarDays)
|
||||||
{
|
{
|
||||||
if (clicky.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
if (clicky.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
|
||||||
{
|
{
|
||||||
|
@ -213,10 +200,10 @@ namespace Omegasis.HappyBirthday
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Used to show the farmer's portrait on the billboard menu.</summary>
|
/// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GraphicsEvents_OnPostRenderGuiEvent(object sender, EventArgs e)
|
private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e)
|
||||||
{
|
{
|
||||||
if (Game1.activeClickableMenu == null || this.isDailyQuestBoard)
|
if (Game1.activeClickableMenu == null || this.isDailyQuestBoard)
|
||||||
return;
|
return;
|
||||||
|
@ -246,72 +233,77 @@ namespace Omegasis.HappyBirthday
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Functionality to display the player's birthday on the billboard.</summary>
|
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e)
|
private void OnMenuChanged(object sender, MenuChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (Game1.activeClickableMenu == null)
|
switch (e.NewMenu)
|
||||||
{
|
{
|
||||||
this.isDailyQuestBoard = false;
|
case null:
|
||||||
return;
|
this.isDailyQuestBoard = false;
|
||||||
}
|
return;
|
||||||
if (Game1.activeClickableMenu is Billboard)
|
|
||||||
{
|
|
||||||
this.isDailyQuestBoard = ModHelper.Reflection.GetField<bool>((Game1.activeClickableMenu as Billboard), "dailyQuestBoard", true).GetValue();
|
|
||||||
if (this.isDailyQuestBoard) return;
|
|
||||||
|
|
||||||
Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
|
case Billboard billboard:
|
||||||
Color[] col = new Color[1];
|
|
||||||
col[0] = new Color(0, 0, 0, 1);
|
|
||||||
text.SetData<Color>(col);
|
|
||||||
//players birthday position rect=new ....
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(this.PlayerData.BirthdaySeason))
|
|
||||||
{
|
|
||||||
if (this.PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower())
|
|
||||||
{
|
{
|
||||||
int index = this.PlayerData.BirthdayDay;
|
this.isDailyQuestBoard = ModHelper.Reflection.GetField<bool>((Game1.activeClickableMenu as Billboard), "dailyQuestBoard", true).GetValue();
|
||||||
Rectangle birthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
|
if (this.isDailyQuestBoard)
|
||||||
(Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", Game1.player.name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var pair in this.othersBirthdays)
|
Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
|
||||||
{
|
Color[] col = new Color[1];
|
||||||
if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue;
|
col[0] = new Color(0, 0, 0, 1);
|
||||||
int index = pair.Value.BirthdayDay;
|
text.SetData<Color>(col);
|
||||||
Rectangle otherBirthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
|
//players birthday position rect=new ....
|
||||||
(Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", Game1.getFarmer(pair.Key).name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
|
|
||||||
}
|
if (!string.IsNullOrEmpty(this.PlayerData.BirthdaySeason))
|
||||||
|
{
|
||||||
|
if (this.PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower())
|
||||||
|
{
|
||||||
|
int index = this.PlayerData.BirthdayDay;
|
||||||
|
Rectangle birthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
|
||||||
|
billboard.calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", $"{Game1.player.Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var pair in this.othersBirthdays)
|
||||||
|
{
|
||||||
|
if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue;
|
||||||
|
int index = pair.Value.BirthdayDay;
|
||||||
|
Rectangle otherBirthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
|
||||||
|
billboard.calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", $"{Game1.getFarmer(pair.Key).Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked after a new day starts.</summary>
|
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void TimeEvents_AfterDayStarted(object sender, EventArgs e)
|
private void OnDayStarted(object sender, DayStartedEventArgs e)
|
||||||
{
|
{
|
||||||
this.CheckedForBirthday = false;
|
this.CheckedForBirthday = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
// show birthday selection menu
|
// show birthday selection menu
|
||||||
if (Game1.activeClickableMenu != null) return;
|
if (Game1.activeClickableMenu != null) return;
|
||||||
if (Context.IsPlayerFree && !this.HasChosenBirthday && e.KeyPressed.ToString() == Config.KeyBinding)
|
if (Context.IsPlayerFree && !this.HasChosenBirthday && e.Button == Config.KeyBinding)
|
||||||
Game1.activeClickableMenu = new BirthdayMenu(this.PlayerData.BirthdaySeason, this.PlayerData.BirthdayDay, this.SetBirthday);
|
Game1.activeClickableMenu = new BirthdayMenu(this.PlayerData.BirthdaySeason, this.PlayerData.BirthdayDay, this.SetBirthday);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked after the player loads a save.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
this.DataFilePath = Path.Combine("data", Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID + ".json");
|
this.DataFilePath = Path.Combine("data", $"{Game1.player.Name}_{Game1.player.UniqueMultiplayerID}.json");
|
||||||
|
|
||||||
// reset state
|
// reset state
|
||||||
this.VillagerQueue = new List<string>();
|
this.VillagerQueue = new List<string>();
|
||||||
|
@ -332,19 +324,19 @@ namespace Omegasis.HappyBirthday
|
||||||
//this.Dialogue = new Dictionary<string, Dialogue>();
|
//this.Dialogue = new Dictionary<string, Dialogue>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked just before the game updates the saves.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
private void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
if (this.HasChosenBirthday)
|
if (this.HasChosenBirthday)
|
||||||
this.Helper.Data.WriteJsonFile(this.DataFilePath, this.PlayerData);
|
this.Helper.Data.WriteJsonFile(this.DataFilePath, this.PlayerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!Context.IsWorldReady || Game1.eventUp || Game1.isFestival())
|
if (!Context.IsWorldReady || Game1.eventUp || Game1.isFestival())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Adds the farmer's birthday to the game.",
|
"Description": "Adds the farmer's birthday to the game.",
|
||||||
"UniqueID": "Omegasis.HappyBirthday",
|
"UniqueID": "Omegasis.HappyBirthday",
|
||||||
"EntryDll": "HappyBirthday.dll",
|
"EntryDll": "HappyBirthday.dll",
|
||||||
"MinimumApiVersion": "2.9",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:520" ]
|
"UpdateKeys": [ "Nexus:520" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
|
||||||
using EventSystem.Framework;
|
using EventSystem.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
|
using StardewModdingAPI.Events;
|
||||||
|
|
||||||
namespace EventSystem
|
namespace EventSystem
|
||||||
{
|
{
|
||||||
|
@ -18,16 +18,22 @@ namespace EventSystem
|
||||||
{
|
{
|
||||||
ModHelper = this.Helper;
|
ModHelper = this.Helper;
|
||||||
ModMonitor = this.Monitor;
|
ModMonitor = this.Monitor;
|
||||||
StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
|
/// <param name="sender">The event sender.</param>
|
||||||
|
/// <param name="e">The event arguments.</param>
|
||||||
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
eventManager = new EventManager();
|
eventManager = new EventManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
|
/// <param name="sender">The event sender.</param>
|
||||||
|
/// <param name="e">The event arguments.</param>
|
||||||
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
eventManager?.update();
|
eventManager?.update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"Name": "EventSystem",
|
"Name": "Event System",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "0.1.0",
|
"Version": "0.1.0",
|
||||||
"Description": "A system to manage different events that can happen on the map.",
|
"Description": "A system to manage different events that can happen on the map.",
|
||||||
"UniqueID": "Omegasis.EventSystem",
|
"UniqueID": "Omegasis.EventSystem",
|
||||||
"EntryDll": "EventSystem.dll",
|
"EntryDll": "EventSystem.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": []
|
"UpdateKeys": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Omegasis.MoreRain
|
||||||
public class MoreRain : Mod
|
public class MoreRain : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The weathers that can be safely overridden.</summary>
|
/// <summary>The weathers that can be safely overridden.</summary>
|
||||||
private readonly HashSet<int> NormalWeathers = new HashSet<int> { Game1.weather_sunny, Game1.weather_rain, Game1.weather_lightning, Game1.weather_debris, Game1.weather_snow };
|
private readonly HashSet<int> NormalWeathers = new HashSet<int> { Game1.weather_sunny, Game1.weather_rain, Game1.weather_lightning, Game1.weather_debris, Game1.weather_snow };
|
||||||
|
@ -29,26 +29,26 @@ namespace Omegasis.MoreRain
|
||||||
{
|
{
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked after the player loads a save.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
this.HandleNewDay();
|
this.HandleNewDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked before the game is saved.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
private void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
this.HandleNewDay();
|
this.HandleNewDay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Change how much it rains in the game.",
|
"Description": "Change how much it rains in the game.",
|
||||||
"UniqueID": "Omegasis.MoreRain",
|
"UniqueID": "Omegasis.MoreRain",
|
||||||
"EntryDll": "MoreRain.dll",
|
"EntryDll": "MoreRain.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:441" ]
|
"UpdateKeys": [ "Nexus:441" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace Omegasis.MuseumRearranger.Framework
|
namespace Omegasis.MuseumRearranger.Framework
|
||||||
{
|
{
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
internal class ModConfig
|
internal class ModConfig
|
||||||
{
|
{
|
||||||
/// <summary>The key which shows the museum rearranging menu.</summary>
|
/// <summary>The key which shows the museum rearranging menu.</summary>
|
||||||
public string ShowMenuKey { get; set; } = "R";
|
public SButton ShowMenuKey { get; set; } = SButton.R;
|
||||||
|
|
||||||
/// <summary>The key which toggles the inventory box when the menu is open.</summary>
|
/// <summary>The key which toggles the inventory box when the menu is open.</summary>
|
||||||
public string ToggleInventoryKey { get; set; } = "T";
|
public SButton ToggleInventoryKey { get; set; } = SButton.T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Omegasis.MuseumRearranger.Framework
|
||||||
internal class NewMuseumMenu : MuseumMenu
|
internal class NewMuseumMenu : MuseumMenu
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>Whether to show the inventory screen.</summary>
|
/// <summary>Whether to show the inventory screen.</summary>
|
||||||
private bool ShowInventory = true;
|
private bool ShowInventory = true;
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Omegasis.MuseumRearranger
|
||||||
public class MuseumRearranger : Mod
|
public class MuseumRearranger : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -28,23 +28,23 @@ namespace Omegasis.MuseumRearranger
|
||||||
{
|
{
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!Context.IsWorldReady)
|
if (!Context.IsWorldReady)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// open menu
|
// open menu
|
||||||
if (e.KeyPressed.ToString() == this.Config.ShowMenuKey)
|
if (e.Button == this.Config.ShowMenuKey)
|
||||||
{
|
{
|
||||||
if (Game1.activeClickableMenu != null)
|
if (Game1.activeClickableMenu != null)
|
||||||
return;
|
return;
|
||||||
|
@ -55,7 +55,7 @@ namespace Omegasis.MuseumRearranger
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggle inventory box
|
// toggle inventory box
|
||||||
if (e.KeyPressed.ToString() == this.Config.ToggleInventoryKey)
|
if (e.Button == this.Config.ToggleInventoryKey)
|
||||||
this.OpenMenu?.ToggleInventory();
|
this.OpenMenu?.ToggleInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Lets you rearrange the museum without needing to donate something.",
|
"Description": "Lets you rearrange the museum without needing to donate something.",
|
||||||
"UniqueID": "Omegasis.MuseumRearranger",
|
"UniqueID": "Omegasis.MuseumRearranger",
|
||||||
"EntryDll": "MuseumRearranger.dll",
|
"EntryDll": "MuseumRearranger.dll",
|
||||||
"MinimumApiVersion": "2.3",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:428" ]
|
"UpdateKeys": [ "Nexus:428" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,18 @@ namespace Omegasis.NightOwl.Framework
|
||||||
{
|
{
|
||||||
class NightFishing : IAssetEditor
|
class NightFishing : IAssetEditor
|
||||||
{
|
{
|
||||||
|
/// <summary>Get whether this instance can edit the given asset.</summary>
|
||||||
|
/// <param name="asset">Basic metadata about the asset being loaded.</param>
|
||||||
public bool CanEdit<T>(IAssetInfo asset)
|
public bool CanEdit<T>(IAssetInfo asset)
|
||||||
{
|
{
|
||||||
return asset.AssetNameEquals(@"Data\Fish");
|
return asset.AssetNameEquals(@"Data\Fish");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Edit a matched asset.</summary>
|
||||||
|
/// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it.</param>
|
||||||
public void Edit<T>(IAssetData asset)
|
public void Edit<T>(IAssetData asset)
|
||||||
{
|
{
|
||||||
Dictionary<int, string> nightFish = new Dictionary<int, string> // (T)(object) is a trick to cast anything to T if we know it's compatible
|
Dictionary<int, string> nightFish = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[128] = "Pufferfish/80/floater/1/36/1200 1600/summer/sunny/690 .4 685 .1/4/.3/.5/0",
|
[128] = "Pufferfish/80/floater/1/36/1200 1600/summer/sunny/690 .4 685 .1/4/.3/.5/0",
|
||||||
[129] = "Anchovy/30/dart/1/16/600 3000/spring fall/both/682 .2/1/.25/.3/0",
|
[129] = "Anchovy/30/dart/1/16/600 3000/spring fall/both/682 .2/1/.25/.3/0",
|
||||||
|
@ -78,10 +82,10 @@ namespace Omegasis.NightOwl.Framework
|
||||||
[799] = "Spook Fish/60/dart/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0",
|
[799] = "Spook Fish/60/dart/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0",
|
||||||
[800] = "Blobfish/75/floater/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0",
|
[800] = "Blobfish/75/floater/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IDictionary<int, string> data = asset.AsDictionary<int, string>().Data;
|
||||||
foreach (KeyValuePair<int, string> pair in nightFish)
|
foreach (KeyValuePair<int, string> pair in nightFish)
|
||||||
{
|
data[pair.Key] = pair.Value;
|
||||||
asset.AsDictionary<int, string>().Set(pair.Key, pair.Value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Netcode;
|
using Netcode;
|
||||||
|
@ -22,7 +21,7 @@ namespace Omegasis.NightOwl
|
||||||
public class NightOwl : Mod
|
public class NightOwl : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -91,12 +90,11 @@ namespace Omegasis.NightOwl
|
||||||
if (this.Config.UseInternalNightFishAssetEditor)
|
if (this.Config.UseInternalNightFishAssetEditor)
|
||||||
this.Helper.Content.AssetEditors.Add(new NightFishing());
|
this.Helper.Content.AssetEditors.Add(new NightFishing());
|
||||||
|
|
||||||
TimeEvents.TimeOfDayChanged += this.TimeEvents_TimeOfDayChanged;
|
helper.Events.GameLoop.TimeChanged += this.OnTimeChanged;
|
||||||
TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted;
|
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
GameEvents.FourthUpdateTick += this.GameEvents_FourthUpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
|
||||||
this.shouldWarpHorse = false;
|
this.shouldWarpHorse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,43 +102,40 @@ namespace Omegasis.NightOwl
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>Updates the earthquake event.</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
this.eve?.tickUpdate(Game1.currentGameTime);
|
this.eve?.tickUpdate(Game1.currentGameTime);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>The method invoked every fourth game update (roughly 15 times per second).</summary>
|
if (e.IsMultipleOf(4)) // ≈15 times per second
|
||||||
/// <param name="sender">The event sender.</param>
|
|
||||||
/// <param name="e">The event data.</param>
|
|
||||||
public void GameEvents_FourthUpdateTick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
// reset position after collapse
|
try
|
||||||
if (Context.IsWorldReady && this.JustStartedNewDay && this.Config.KeepPositionAfterCollapse)
|
|
||||||
{
|
{
|
||||||
if (this.PreCollapseMap != null)
|
// reset position after collapse
|
||||||
Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false);
|
if (Context.IsWorldReady && this.JustStartedNewDay && this.Config.KeepPositionAfterCollapse)
|
||||||
|
{
|
||||||
|
if (this.PreCollapseMap != null)
|
||||||
|
Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false);
|
||||||
|
|
||||||
this.PreCollapseMap = null;
|
this.PreCollapseMap = null;
|
||||||
this.JustStartedNewDay = false;
|
this.JustStartedNewDay = false;
|
||||||
this.JustCollapsed = false;
|
this.JustCollapsed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.Monitor.Log(ex.ToString(), LogLevel.Error);
|
||||||
|
this.WriteErrorLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
this.Monitor.Log(ex.ToString(), LogLevel.Error);
|
|
||||||
this.WriteErrorLog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked before the game saves.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
public void SaveEvents_BeforeSave(object sender, EventArgs e)
|
public void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
{
|
||||||
int collapseFee = 0;
|
int collapseFee = 0;
|
||||||
string[] passOutFees = Game1.player.mailbox
|
string[] passOutFees = Game1.player.mailbox
|
||||||
|
@ -156,20 +151,20 @@ namespace Omegasis.NightOwl
|
||||||
Game1.player.money += collapseFee;
|
Game1.player.money += collapseFee;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked after the player loads a save.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
public void SaveEvents_AfterLoad(object sender, EventArgs e)
|
public void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
this.IsUpLate = false;
|
this.IsUpLate = false;
|
||||||
this.JustStartedNewDay = false;
|
this.JustStartedNewDay = false;
|
||||||
this.JustCollapsed = false;
|
this.JustCollapsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked when a new day starts.</summary>
|
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
public void TimeEvents_AfterDayStarted(object sender, EventArgs e)
|
public void OnDayStarted(object sender, DayStartedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -252,10 +247,10 @@ namespace Omegasis.NightOwl
|
||||||
this.Helper.Reflection.GetField<Rectangle>(mountain, "railroadBlockRect").SetValue(Rectangle.Empty);
|
this.Helper.Reflection.GetField<Rectangle>(mountain, "railroadBlockRect").SetValue(Rectangle.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked when <see cref="Game1.timeOfDay"/> changes.</summary>
|
/// <summary>Raised after the in-game clock time changes.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
|
private void OnTimeChanged(object sender, TimeChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!Context.IsWorldReady)
|
if (!Context.IsWorldReady)
|
||||||
return;
|
return;
|
||||||
|
@ -353,8 +348,7 @@ namespace Omegasis.NightOwl
|
||||||
this.PreCollapseStamina,
|
this.PreCollapseStamina,
|
||||||
this.PreCollapseHealth
|
this.PreCollapseHealth
|
||||||
};
|
};
|
||||||
string path = Path.Combine(this.Helper.DirectoryPath, "Error_Logs", "Mod_State.json");
|
this.Helper.Data.WriteJsonFile("Error_Logs/Mod_State.json", state);
|
||||||
this.Helper.WriteJsonFile(path, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Try and emulate the old Game1.shouldFarmerPassout logic.</summary>
|
/// <summary>Try and emulate the old Game1.shouldFarmerPassout logic.</summary>
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Lets you stay up all night.",
|
"Description": "Lets you stay up all night.",
|
||||||
"UniqueID": "Omegasis.NightOwl",
|
"UniqueID": "Omegasis.NightOwl",
|
||||||
"EntryDll": "NightOwl.dll",
|
"EntryDll": "NightOwl.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:433" ]
|
"UpdateKeys": [ "Nexus:433" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
using StardewModdingAPI.Events;
|
using StardewModdingAPI.Events;
|
||||||
|
@ -17,17 +16,17 @@ namespace Omegasis.NoMorePets
|
||||||
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked after the player loads a save.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
public void SaveEvents_AfterLoad(object sender, EventArgs e)
|
public void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (Pet pet in Game1.player.currentLocation.getCharacters().OfType<Pet>().ToArray())
|
foreach (Pet pet in Game1.player.currentLocation.getCharacters().OfType<Pet>().ToArray())
|
||||||
pet.currentLocation.characters.Remove(pet);
|
pet.currentLocation.characters.Remove(pet);
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Removes all pets from the game.",
|
"Description": "Removes all pets from the game.",
|
||||||
"UniqueID": "Omegasis.NoMorePets",
|
"UniqueID": "Omegasis.NoMorePets",
|
||||||
"EntryDll": "NoMorePets.dll",
|
"EntryDll": "NoMorePets.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:506" ]
|
"UpdateKeys": [ "Nexus:506" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "A mod that attempts to add in a variety of new things to Stardew.",
|
"Description": "A mod that attempts to add in a variety of new things to Stardew.",
|
||||||
"UniqueID": "Omegasis.Revitalize",
|
"UniqueID": "Omegasis.Revitalize",
|
||||||
"EntryDll": "Revitalize.dll",
|
"EntryDll": "Revitalize.dll",
|
||||||
"MinimumApiVersion": "2.3",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": []
|
"UpdateKeys": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace Omegasis.SaveAnywhere.Framework
|
namespace Omegasis.SaveAnywhere.Framework
|
||||||
{
|
{
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
internal class ModConfig
|
internal class ModConfig
|
||||||
{
|
{
|
||||||
/// <summary>The key which initiates a save.</summary>
|
/// <summary>The key which initiates a save.</summary>
|
||||||
public string SaveKey { get; set; } = "K";
|
public SButton SaveKey { get; set; } = SButton.K;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Omegasis.SaveAnywhere.Framework
|
||||||
internal class NewShippingMenu : ShippingMenu
|
internal class NewShippingMenu : ShippingMenu
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The private field on the shipping menu which indicates the game has already been saved, which prevents it from saving.</summary>
|
/// <summary>The private field on the shipping menu which indicates the game has already been saved, which prevents it from saving.</summary>
|
||||||
private readonly IReflectedField<bool> SavedYet;
|
private readonly IReflectedField<bool> SavedYet;
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Omegasis.SaveAnywhere.Framework
|
||||||
public class SaveManager
|
public class SaveManager
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>Simplifies access to game code.</summary>
|
/// <summary>Simplifies access to game code.</summary>
|
||||||
private readonly IReflectionHelper Reflection;
|
private readonly IReflectionHelper Reflection;
|
||||||
|
@ -26,8 +26,8 @@ namespace Omegasis.SaveAnywhere.Framework
|
||||||
/// <summary>SMAPI's APIs for this mod.</summary>
|
/// <summary>SMAPI's APIs for this mod.</summary>
|
||||||
private readonly IModHelper Helper;
|
private readonly IModHelper Helper;
|
||||||
|
|
||||||
/// <summary>The full path to the player data file.</summary>
|
/// <summary>The relative path to the player data file.</summary>
|
||||||
private string SavePath => Path.Combine(this.Helper.DirectoryPath, "data", $"{Constants.SaveFolderName}.json");
|
private string RelativeDataPath => Path.Combine("data", $"{Constants.SaveFolderName}.json");
|
||||||
|
|
||||||
/// <summary>Whether we should save at the next opportunity.</summary>
|
/// <summary>Whether we should save at the next opportunity.</summary>
|
||||||
private bool WaitingToSave;
|
private bool WaitingToSave;
|
||||||
|
@ -80,7 +80,7 @@ namespace Omegasis.SaveAnywhere.Framework
|
||||||
/// <summary>Clear saved data.</summary>
|
/// <summary>Clear saved data.</summary>
|
||||||
public void ClearData()
|
public void ClearData()
|
||||||
{
|
{
|
||||||
File.Delete(this.SavePath);
|
File.Delete(Path.Combine(this.Helper.DirectoryPath, this.RelativeDataPath));
|
||||||
this.RemoveLegacyDataForThisPlayer();
|
this.RemoveLegacyDataForThisPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,20 +105,16 @@ namespace Omegasis.SaveAnywhere.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get data
|
// save data to disk
|
||||||
PlayerData data = new PlayerData
|
PlayerData data = new PlayerData
|
||||||
{
|
{
|
||||||
Time = Game1.timeOfDay,
|
Time = Game1.timeOfDay,
|
||||||
Characters = this.GetPositions().ToArray(),
|
Characters = this.GetPositions().ToArray(),
|
||||||
IsCharacterSwimming = Game1.player.swimming.Value
|
IsCharacterSwimming = Game1.player.swimming.Value
|
||||||
};
|
};
|
||||||
|
this.Helper.Data.WriteJsonFile(this.RelativeDataPath, data);
|
||||||
|
|
||||||
// save to disk
|
// clear any legacy data (no longer needed as backup)
|
||||||
// ReSharper disable once PossibleNullReferenceException -- not applicable
|
|
||||||
Directory.CreateDirectory(new FileInfo(this.SavePath).Directory.FullName);
|
|
||||||
this.Helper.WriteJsonFile(this.SavePath, data);
|
|
||||||
|
|
||||||
// clear any legacy data (no longer needed as backup)1
|
|
||||||
this.RemoveLegacyDataForThisPlayer();
|
this.RemoveLegacyDataForThisPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +122,7 @@ namespace Omegasis.SaveAnywhere.Framework
|
||||||
public void LoadData()
|
public void LoadData()
|
||||||
{
|
{
|
||||||
// get data
|
// get data
|
||||||
PlayerData data = this.Helper.ReadJsonFile<PlayerData>(this.SavePath);
|
PlayerData data = this.Helper.Data.ReadJsonFile<PlayerData>(this.RelativeDataPath);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Omegasis.SaveAnywhere
|
||||||
public class SaveAnywhere : Mod
|
public class SaveAnywhere : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
@ -53,11 +53,11 @@ namespace Omegasis.SaveAnywhere
|
||||||
|
|
||||||
this.SaveManager = new SaveManager(this.Helper, this.Helper.Reflection, onLoaded: () => this.ShouldResetSchedules = true);
|
this.SaveManager = new SaveManager(this.Helper, this.Helper.Reflection, onLoaded: () => this.ShouldResetSchedules = true);
|
||||||
|
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
SaveEvents.AfterSave += this.SaveEvents_AfterSave;
|
helper.Events.GameLoop.Saved += this.OnSaved;
|
||||||
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
|
||||||
TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
|
|
||||||
ModHelper = helper;
|
ModHelper = helper;
|
||||||
ModMonitor = this.Monitor;
|
ModMonitor = this.Monitor;
|
||||||
|
@ -68,10 +68,10 @@ namespace Omegasis.SaveAnywhere
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked after the player loads a save.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
// reset state
|
// reset state
|
||||||
this.IsCustomSaving = false;
|
this.IsCustomSaving = false;
|
||||||
|
@ -81,10 +81,10 @@ namespace Omegasis.SaveAnywhere
|
||||||
this.SaveManager.LoadData();
|
this.SaveManager.LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked after the player finishes saving.</summary>
|
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterSave(object sender, EventArgs e)
|
private void OnSaved(object sender, SavedEventArgs e)
|
||||||
{
|
{
|
||||||
// clear custom data after a normal save (to avoid restoring old state)
|
// clear custom data after a normal save (to avoid restoring old state)
|
||||||
if (!this.IsCustomSaving)
|
if (!this.IsCustomSaving)
|
||||||
|
@ -95,10 +95,10 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
// let save manager run background logic
|
// let save manager run background logic
|
||||||
if (Context.IsWorldReady)
|
if (Context.IsWorldReady)
|
||||||
|
@ -156,10 +156,10 @@ namespace Omegasis.SaveAnywhere
|
||||||
Game1.player.currentLocation.characters.Add(monster);
|
Game1.player.currentLocation.characters.Add(monster);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked after a new day starts.</summary>
|
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void TimeEvents_AfterDayStarted(object sender, EventArgs e)
|
private void OnDayStarted(object sender, DayStartedEventArgs e)
|
||||||
{
|
{
|
||||||
// reload NPC schedules
|
// reload NPC schedules
|
||||||
this.ShouldResetSchedules = true;
|
this.ShouldResetSchedules = true;
|
||||||
|
@ -173,16 +173,16 @@ namespace Omegasis.SaveAnywhere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!Context.IsPlayerFree)
|
if (!Context.IsPlayerFree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// initiate save (if valid context)
|
// initiate save (if valid context)
|
||||||
if (e.KeyPressed.ToString() == this.Config.SaveKey)
|
if (e.Button == this.Config.SaveKey)
|
||||||
{
|
{
|
||||||
if (Game1.client == null)
|
if (Game1.client == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"Description": "Lets you save almost anywhere.",
|
"Description": "Lets you save almost anywhere.",
|
||||||
"UniqueID": "Omegasis.SaveAnywhere",
|
"UniqueID": "Omegasis.SaveAnywhere",
|
||||||
"EntryDll": "SaveAnywhere.dll",
|
"EntryDll": "SaveAnywhere.dll",
|
||||||
"MinimumApiVersion": "2.4",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,9 @@ namespace SimpleSoundManager.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Constructor for wav files.</summary>
|
/// <summary>Constructor for wav files.</summary>
|
||||||
public void loadWavFile(IModHelper helper, string soundName, string pathToWav)
|
public void loadWavFile(IModHelper helper, string soundName, string relativePath)
|
||||||
{
|
{
|
||||||
WavSound wav = new WavSound(helper, soundName, pathToWav);
|
WavSound wav = new WavSound(helper, soundName, relativePath);
|
||||||
SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + soundName);
|
SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + soundName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,9 +37,9 @@ namespace SimpleSoundManager
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>A constructor that takes a mod helper and a relative path to a wav file.</summary>
|
/// <summary>A constructor that takes a mod helper and a relative path to a wav file.</summary>
|
||||||
public WavSound(IModHelper modHelper, string name, string pathInModDirectory, bool loop = false)
|
public WavSound(IModHelper modHelper, string name, string relativePath, bool loop = false)
|
||||||
{
|
{
|
||||||
string path = Path.Combine(modHelper.DirectoryPath, pathInModDirectory);
|
string path = Path.Combine(modHelper.DirectoryPath, relativePath);
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.soundName = name;
|
this.soundName = name;
|
||||||
this.loop = loop;
|
this.loop = loop;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "A simple framework to play sounds from wave banks and wav files.",
|
"Description": "A simple framework to play sounds from wave banks and wav files.",
|
||||||
"UniqueID": "Omegasis.SimpleSoundManager",
|
"UniqueID": "Omegasis.SimpleSoundManager",
|
||||||
"EntryDll": "SimpleSoundManager.dll",
|
"EntryDll": "SimpleSoundManager.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:1410" ]
|
"UpdateKeys": [ "Nexus:1410" ]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace StardewSymphonyRemastered
|
namespace StardewSymphonyRemastered
|
||||||
{
|
{
|
||||||
/// <summary>A class that handles all of the config files for this mod.</summary>
|
/// <summary>A class that handles all of the config files for this mod.</summary>
|
||||||
|
@ -13,7 +15,7 @@ namespace StardewSymphonyRemastered
|
||||||
public int MaximumDelayBetweenSongsInMilliseconds { get; set; } = 60000;
|
public int MaximumDelayBetweenSongsInMilliseconds { get; set; } = 60000;
|
||||||
|
|
||||||
/// <summary>The key binding to open the menu music.</summary>
|
/// <summary>The key binding to open the menu music.</summary>
|
||||||
public string KeyBinding { get; set; } = "L";
|
public SButton KeyBinding { get; set; } = SButton.L;
|
||||||
|
|
||||||
/// <summary>Whether to write a JSON file for every possible option for a music pack. Use at your own risk!</summary>
|
/// <summary>Whether to write a JSON file for every possible option for a music pack. Use at your own risk!</summary>
|
||||||
public bool WriteAllConfigMusicOptions { get; set; } = false;
|
public bool WriteAllConfigMusicOptions { get; set; } = false;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using Microsoft.Xna.Framework.Audio;
|
using Microsoft.Xna.Framework.Audio;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
|
@ -47,19 +45,16 @@ namespace StardewSymphonyRemastered
|
||||||
ModHelper = helper;
|
ModHelper = helper;
|
||||||
ModMonitor = this.Monitor;
|
ModMonitor = this.Monitor;
|
||||||
Config = helper.ReadConfig<Config>();
|
Config = helper.ReadConfig<Config>();
|
||||||
SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
// EventArgsLocationsChanged += LocationEvents_CurrentLocationChanged;
|
|
||||||
|
|
||||||
PlayerEvents.Warped += this.PlayerEvents_Warped;
|
helper.Events.Player.Warped += this.OnPlayerWarped;
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
SaveEvents.BeforeSave += this.SaveEvents_BeforeSave;
|
helper.Events.GameLoop.Saving += this.OnSaving;
|
||||||
|
|
||||||
MenuEvents.MenuChanged += this.MenuEvents_MenuChanged;
|
helper.Events.Display.MenuChanged += this.OnMenuChanged;
|
||||||
MenuEvents.MenuClosed += this.MenuEvents_MenuClosed;
|
|
||||||
|
|
||||||
GameEvents.FirstUpdateTick += this.GameEvents_FirstUpdateTick;
|
helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
|
||||||
GameEvents.OneSecondTick += this.GameEvents_OneSecondTick;
|
|
||||||
|
|
||||||
|
|
||||||
musicManager = new MusicManager();
|
musicManager = new MusicManager();
|
||||||
|
@ -76,34 +71,31 @@ namespace StardewSymphonyRemastered
|
||||||
this.LoadMusicPacks();
|
this.LoadMusicPacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameEvents_OneSecondTick(object sender, EventArgs e)
|
/// <summary>Raised after a player warps to a new location.</summary>
|
||||||
{
|
|
||||||
musicManager?.UpdateTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Raised when the player changes locations. This should determine the next song to play.</summary>
|
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void PlayerEvents_Warped(object sender, EventArgsPlayerWarped e)
|
private void OnPlayerWarped(object sender, WarpedEventArgs e)
|
||||||
{
|
{
|
||||||
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
|
if (e.IsLocalPlayer)
|
||||||
|
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Ran once all of teh entry methods are ran. This will ensure that all custom music from other mods has been properly loaded in.</summary>
|
/// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_FirstUpdateTick(object sender, EventArgs e)
|
private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
|
||||||
{
|
{
|
||||||
|
// Ran once all of the entry methods are ran. This will ensure that all custom music from other mods has been properly loaded in.
|
||||||
|
|
||||||
musicManager.initializeMenuMusic(); //Initialize menu music that has been added to SongSpecifics.menus from all other mods during their Entry function.
|
musicManager.initializeMenuMusic(); //Initialize menu music that has been added to SongSpecifics.menus from all other mods during their Entry function.
|
||||||
musicManager.initializeFestivalMusic(); //Initialize festival music that has been added to SongSpecifics.menus from all other mods during their Entry function.
|
musicManager.initializeFestivalMusic(); //Initialize festival music that has been added to SongSpecifics.menus from all other mods during their Entry function.
|
||||||
musicManager.initializeEventMusic(); //Initialize event music that has been added to SongSpecifics.menus from all other mods during their Entry function.
|
musicManager.initializeEventMusic(); //Initialize event music that has been added to SongSpecifics.menus from all other mods during their Entry function.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Events to occur after the game has loaded in.</summary>
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
//Locaion initialization MUST occur after load. Anything else can occur before.
|
//Locaion initialization MUST occur after load. Anything else can occur before.
|
||||||
SongSpecifics.initializeLocationsList(); //Gets all Game locations once the player has loaded the game, and all buildings on the player's farm and adds them to a location list.
|
SongSpecifics.initializeLocationsList(); //Gets all Game locations once the player has loaded the game, and all buildings on the player's farm and adds them to a location list.
|
||||||
|
@ -123,67 +115,74 @@ namespace StardewSymphonyRemastered
|
||||||
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
|
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary>
|
||||||
/// <summary>Choose new music when a menu is closed.</summary>
|
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e)
|
private void OnMenuChanged(object sender, MenuChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (menuChangedMusic)
|
// menu closed
|
||||||
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
|
if (e.NewMenu == null)
|
||||||
|
{
|
||||||
|
if (menuChangedMusic)
|
||||||
|
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// menu changed
|
||||||
|
else
|
||||||
|
musicManager.SelectMenuMusic(SongSpecifics.getCurrentConditionalString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Choose new music when a menu is opened.</summary>
|
/// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e)
|
private void OnSaving(object sender, SavingEventArgs e)
|
||||||
{
|
|
||||||
//var ok = musicManager.currentMusicPack.getNameOfCurrentSong();
|
|
||||||
musicManager.SelectMenuMusic(SongSpecifics.getCurrentConditionalString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveEvents_BeforeSave(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
// THIS IS WAY TO LONG to run. Better make it save individual lists when I am editing songs.
|
// THIS IS WAY TO LONG to run. Better make it save individual lists when I am editing songs.
|
||||||
foreach (var musicPack in musicManager.MusicPacks)
|
foreach (var musicPack in musicManager.MusicPacks)
|
||||||
musicPack.Value.SaveSettings();
|
musicPack.Value.SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Fires when a key is pressed to open the music selection menu.</summary>
|
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyPressed.ToString() == Config.KeyBinding && Game1.activeClickableMenu == null)
|
if (e.Button == Config.KeyBinding && Game1.activeClickableMenu == null)
|
||||||
Game1.activeClickableMenu = new Framework.Menus.MusicManagerMenu(Game1.viewport.Width, Game1.viewport.Height);
|
Game1.activeClickableMenu = new Framework.Menus.MusicManagerMenu(Game1.viewport.Width, Game1.viewport.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Raised every frame. Mainly used just to initiate the music packs. Probably not needed.</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event arguments.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
if (musicManager == null) return;
|
// update delay timer
|
||||||
|
if (e.IsOneSecond)
|
||||||
|
musicManager?.UpdateTimer();
|
||||||
|
|
||||||
if (Config.DisableStardewMusic)
|
// initiate music packs
|
||||||
|
if (musicManager != null)
|
||||||
{
|
{
|
||||||
if (Game1.currentSong != null)
|
if (Config.DisableStardewMusic)
|
||||||
{
|
{
|
||||||
Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs
|
if (Game1.currentSong != null)
|
||||||
Game1.currentSong.Stop(AudioStopOptions.AsAuthored);
|
{
|
||||||
Game1.nextMusicTrack = ""; //same as above line
|
Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs
|
||||||
|
Game1.currentSong.Stop(AudioStopOptions.AsAuthored);
|
||||||
|
Game1.nextMusicTrack = ""; //same as above line
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
if (musicManager.CurrentMusicPack == null) return;
|
|
||||||
if (Game1.currentSong != null && musicManager.CurrentMusicPack.IsPlaying())
|
|
||||||
{
|
{
|
||||||
//ModMonitor.Log("STOP THE MUSIC!!!");
|
if (musicManager.CurrentMusicPack == null) return;
|
||||||
Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs
|
if (Game1.currentSong != null && musicManager.CurrentMusicPack.IsPlaying())
|
||||||
Game1.currentSong.Stop(AudioStopOptions.AsAuthored);
|
{
|
||||||
//Game1.nextMusicTrack = ""; //same as above line
|
//ModMonitor.Log("STOP THE MUSIC!!!");
|
||||||
|
Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs
|
||||||
|
Game1.currentSong.Stop(AudioStopOptions.AsAuthored);
|
||||||
|
//Game1.nextMusicTrack = ""; //same as above line
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
||||||
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
||||||
"EntryDll": "StardewSymphonyRemastered.dll",
|
"EntryDll": "StardewSymphonyRemastered.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:425" ],
|
"UpdateKeys": [ "Nexus:425" ],
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
{ "UniqueID": "Omegasis.StardustCore" }
|
{ "UniqueID": "Omegasis.StardustCore" }
|
||||||
|
|
|
@ -26,17 +26,5 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
|
||||||
this.TopPadding = top;
|
this.TopPadding = top;
|
||||||
this.BottomPadding = bottom;
|
this.BottomPadding = bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Save this to a .json file.</summary>
|
|
||||||
public void WriteToJson(string path)
|
|
||||||
{
|
|
||||||
StardustCore.ModCore.ModHelper.WriteJsonFile(path, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Read the data from the .json file.</summary>
|
|
||||||
public static CharacterSpacing ReadFromJson(string path)
|
|
||||||
{
|
|
||||||
return StardustCore.ModCore.ModHelper.ReadJsonFile<CharacterSpacing>(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "A core mod that allows for other mods of mine to be run.",
|
"Description": "A core mod that allows for other mods of mine to be run.",
|
||||||
"UniqueID": "Omegasis.StardustCore",
|
"UniqueID": "Omegasis.StardustCore",
|
||||||
"EntryDll": "StardustCore.dll",
|
"EntryDll": "StardustCore.dll",
|
||||||
"MinimumApiVersion": "2.3",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": []
|
"UpdateKeys": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
|
||||||
using EventSystem.Framework.Events;
|
using EventSystem.Framework.Events;
|
||||||
using EventSystem.Framework.FunctionEvents;
|
using EventSystem.Framework.FunctionEvents;
|
||||||
using EventSystem.Framework.Information;
|
using EventSystem.Framework.Information;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
|
using StardewModdingAPI.Events;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
namespace SundropMapEvents
|
namespace SundropMapEvents
|
||||||
{
|
{
|
||||||
|
@ -18,10 +18,13 @@ namespace SundropMapEvents
|
||||||
{
|
{
|
||||||
ModHelper = this.Helper;
|
ModHelper = this.Helper;
|
||||||
ModMonitor = this.Monitor;
|
ModMonitor = this.Monitor;
|
||||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad;
|
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
|
||||||
|
/// <param name="sender">The event sender.</param>
|
||||||
|
/// <param name="e">The event arguments.</param>
|
||||||
|
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
|
||||||
{
|
{
|
||||||
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false)));
|
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false)));
|
||||||
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new MouseButtonEvents(null, null), new MouseEntryLeaveEvent(null, null), "Hello there!"));
|
EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new MouseButtonEvents(null, null), new MouseEntryLeaveEvent(null, null), "Hello there!"));
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"Name": "SunDropMapEvents",
|
"Name": "SunDrop Map Events",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "0.1.0",
|
"Version": "0.1.0",
|
||||||
"Description": "A system to add events to the SunDropMod",
|
"Description": "A system to add events to the SunDropMod",
|
||||||
"UniqueID": "SunDrop.MapEvents",
|
"UniqueID": "SunDrop.MapEvents",
|
||||||
"EntryDll": "SunDropMapEvents.dll",
|
"EntryDll": "SunDropMapEvents.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [],
|
"UpdateKeys": [],
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
{ "UniqueID": "Omegasis.EventSystem" }
|
{ "UniqueID": "Omegasis.EventSystem" }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using Omegasis.TimeFreeze.Framework;
|
using Omegasis.TimeFreeze.Framework;
|
||||||
using StardewModdingAPI;
|
using StardewModdingAPI;
|
||||||
using StardewModdingAPI.Events;
|
using StardewModdingAPI.Events;
|
||||||
|
@ -11,13 +10,11 @@ namespace Omegasis.TimeFreeze
|
||||||
public class TimeFreeze : Mod
|
public class TimeFreeze : Mod
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Properties
|
** Fields
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The mod configuration.</summary>
|
/// <summary>The mod configuration.</summary>
|
||||||
private ModConfig Config;
|
private ModConfig Config;
|
||||||
|
|
||||||
public int oldInterval;
|
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Public methods
|
** Public methods
|
||||||
|
@ -28,18 +25,17 @@ namespace Omegasis.TimeFreeze
|
||||||
{
|
{
|
||||||
this.Config = helper.ReadConfig<ModConfig>();
|
this.Config = helper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
|
||||||
//oldInterval = 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Private methods
|
** Private methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
|
/// <summary>Raised after the game state is updated (≈60 times per second).</summary>
|
||||||
/// <param name="sender">The event sender.</param>
|
/// <param name="sender">The event sender.</param>
|
||||||
/// <param name="e">The event data.</param>
|
/// <param name="e">The event arguments.</param>
|
||||||
private void GameEvents_UpdateTick(object sender, EventArgs e)
|
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!Context.IsWorldReady)
|
if (!Context.IsWorldReady)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
"Description": "Emulates old Harvest Moon-style games where time is frozen inside.",
|
"Description": "Emulates old Harvest Moon-style games where time is frozen inside.",
|
||||||
"UniqueID": "Omegasis.TimeFreeze",
|
"UniqueID": "Omegasis.TimeFreeze",
|
||||||
"EntryDll": "TimeFreeze.dll",
|
"EntryDll": "TimeFreeze.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [ "Nexus:973" ]
|
"UpdateKeys": [ "Nexus:973" ]
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -11,22 +11,19 @@ namespace Vocalization.Framework
|
||||||
|
|
||||||
public static Dictionary<string, SortedDictionary<string, VoiceAudioOptions>> DictionaryReferences = new Dictionary<string, SortedDictionary<string, VoiceAudioOptions>>();
|
public static Dictionary<string, SortedDictionary<string, VoiceAudioOptions>> DictionaryReferences = new Dictionary<string, SortedDictionary<string, VoiceAudioOptions>>();
|
||||||
|
|
||||||
public static string generateKey(string translationPath, string SpeakerName, string fileName, string dialogueKey)
|
public static string generateKey(LanguageName language, string SpeakerName, string fileName, string dialogueKey)
|
||||||
{
|
{
|
||||||
return Vocalization.config.translationInfo.getTranslationNameFromPath(translationPath) + Seperator + SpeakerName + Seperator + fileName + Seperator + dialogueKey;
|
return Vocalization.config.translationInfo.getTranslationName(language) + Seperator + SpeakerName + Seperator + fileName + Seperator + dialogueKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SortedDictionary<string, VoiceAudioOptions> getWavFileReferences(string translation)
|
public static SortedDictionary<string, VoiceAudioOptions> getWavFileReferences(LanguageName language)
|
||||||
{
|
{
|
||||||
return DictionaryReferences[Vocalization.config.translationInfo.getTranslationNameFromPath(translation)];
|
return DictionaryReferences[Vocalization.config.translationInfo.getTranslationName(language)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initialize()
|
public static void initialize()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues")))
|
Directory.CreateDirectory(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues"));
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues"));
|
|
||||||
}
|
|
||||||
loadAudioCues();
|
loadAudioCues();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,20 +42,18 @@ namespace Vocalization.Framework
|
||||||
|
|
||||||
public static void loadAudioCues()
|
public static void loadAudioCues()
|
||||||
{
|
{
|
||||||
foreach (string v in Vocalization.config.translationInfo.translations)
|
foreach (LanguageName language in Vocalization.config.translationInfo.LanguageNames)
|
||||||
{
|
{
|
||||||
var loaded = Vocalization.ModHelper.ReadJsonFile<SortedDictionary<string, VoiceAudioOptions>>(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues", "AudioCues" + Seperator + v + ".json"));
|
var loaded = Vocalization.ModHelper.Data.ReadJsonFile<SortedDictionary<string, VoiceAudioOptions>>($"AudioCues/AudioCues{Seperator}{language}.json")
|
||||||
if (loaded == null) loaded = new SortedDictionary<string, VoiceAudioOptions>();
|
?? new SortedDictionary<string, VoiceAudioOptions>();
|
||||||
DictionaryReferences.Add(v, loaded);
|
DictionaryReferences.Add(Vocalization.config.translationInfo.getTranslationName(language), loaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAudioCues()
|
public static void saveAudioCues()
|
||||||
{
|
{
|
||||||
foreach (var v in DictionaryReferences)
|
foreach (var v in DictionaryReferences)
|
||||||
{
|
Vocalization.ModHelper.Data.WriteJsonFile($"AudioCues/AudioCues{Seperator}{v.Key}.json", v.Value);
|
||||||
Vocalization.ModHelper.WriteJsonFile<SortedDictionary<string, VoiceAudioOptions>>(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues", "AudioCues" + Seperator + v.Key + ".json"), v.Value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,13 +172,16 @@ namespace Vocalization.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Change all of the files to the ones that are appropriate for that translation version.</summary>
|
/// <summary>Change all of the files to the ones that are appropriate for that translation version.</summary>
|
||||||
public void initializeForTranslation(string translation)
|
/// <param name="language">The translation language name.</param>
|
||||||
|
public void initializeForTranslation(LanguageName language)
|
||||||
{
|
{
|
||||||
|
string extension = Vocalization.config.translationInfo.getFileExtentionForTranslation(language);
|
||||||
|
|
||||||
for (int i = 0; i < this.dataFileNames.Count; i++)
|
for (int i = 0; i < this.dataFileNames.Count; i++)
|
||||||
{
|
{
|
||||||
Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i));
|
||||||
string s = this.dataFileNames.ElementAt(i);
|
string s = this.dataFileNames.ElementAt(i);
|
||||||
s = this.dataFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation));
|
s = this.dataFileNames.ElementAt(i).Replace(".xnb", extension);
|
||||||
this.dataFileNames[i] = s;
|
this.dataFileNames[i] = s;
|
||||||
Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i));
|
||||||
}
|
}
|
||||||
|
@ -187,7 +190,7 @@ namespace Vocalization.Framework
|
||||||
{
|
{
|
||||||
Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i));
|
||||||
string s = this.dialogueFileNames.ElementAt(i);
|
string s = this.dialogueFileNames.ElementAt(i);
|
||||||
s = this.dialogueFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation));
|
s = this.dialogueFileNames.ElementAt(i).Replace(".xnb", extension);
|
||||||
this.dialogueFileNames[i] = s;
|
this.dialogueFileNames[i] = s;
|
||||||
Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i));
|
||||||
}
|
}
|
||||||
|
@ -196,7 +199,7 @@ namespace Vocalization.Framework
|
||||||
{
|
{
|
||||||
Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i));
|
||||||
string s = this.stringsFileNames.ElementAt(i);
|
string s = this.stringsFileNames.ElementAt(i);
|
||||||
s = this.stringsFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation));
|
s = this.stringsFileNames.ElementAt(i).Replace(".xnb", extension);
|
||||||
this.stringsFileNames[i] = s;
|
this.stringsFileNames[i] = s;
|
||||||
Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i));
|
||||||
}
|
}
|
||||||
|
@ -205,7 +208,7 @@ namespace Vocalization.Framework
|
||||||
{
|
{
|
||||||
Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i));
|
||||||
string s = this.festivalFileNames.ElementAt(i);
|
string s = this.festivalFileNames.ElementAt(i);
|
||||||
s = this.festivalFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation));
|
s = this.festivalFileNames.ElementAt(i).Replace(".xnb", extension);
|
||||||
this.festivalFileNames[i] = s;
|
this.festivalFileNames[i] = s;
|
||||||
Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i));
|
||||||
}
|
}
|
||||||
|
@ -214,7 +217,7 @@ namespace Vocalization.Framework
|
||||||
{
|
{
|
||||||
Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i));
|
||||||
string s = this.eventFileNames.ElementAt(i);
|
string s = this.eventFileNames.ElementAt(i);
|
||||||
s = this.eventFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation));
|
s = this.eventFileNames.ElementAt(i).Replace(".xnb", extension);
|
||||||
this.eventFileNames[i] = s;
|
this.eventFileNames[i] = s;
|
||||||
Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i));
|
Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace Vocalization.Framework
|
||||||
|
{
|
||||||
|
/// <summary>The supported language names.</summary>
|
||||||
|
public enum LanguageName
|
||||||
|
{
|
||||||
|
English,
|
||||||
|
Spanish,
|
||||||
|
Chinese,
|
||||||
|
Japanese,
|
||||||
|
Russian,
|
||||||
|
German,
|
||||||
|
Portuguese
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -39,13 +40,13 @@ namespace Vocalization.Framework.Menus
|
||||||
Rectangle sourceRect = new Rectangle(0, 0, 4, 16);
|
Rectangle sourceRect = new Rectangle(0, 0, 4, 16);
|
||||||
this.sliderButton = new SliderButton("Slider", "Volume", new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 4, 16), buttonTexture, bar, sourceRect, 2f, new SliderInformation(SliderStyle.Horizontal, (int)(Vocalization.config.voiceVolume * 100), 1), new StardustCore.Animations.Animation(sourceRect), Color.White, Color.Black, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, null, true);
|
this.sliderButton = new SliderButton("Slider", "Volume", new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 4, 16), buttonTexture, bar, sourceRect, 2f, new SliderInformation(SliderStyle.Horizontal, (int)(Vocalization.config.voiceVolume * 100), 1), new StardustCore.Animations.Animation(sourceRect), Color.White, Color.Black, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, null, true);
|
||||||
|
|
||||||
Button english = new Button("EnglishButton", "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f);
|
Button english = new Button(LanguageName.English.ToString(), "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f);
|
||||||
Button spanish = new Button("SpanishButton", "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f);
|
Button spanish = new Button(LanguageName.Spanish.ToString(), "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f);
|
||||||
Button portuguese = new Button("PortugueseButton", "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f);
|
Button portuguese = new Button(LanguageName.Portuguese.ToString(), "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f);
|
||||||
Button russian = new Button("RussianButton", "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f);
|
Button russian = new Button(LanguageName.Russian.ToString(), "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f);
|
||||||
Button chinese = new Button("ChineseButton", "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f);
|
Button chinese = new Button(LanguageName.Chinese.ToString(), "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f);
|
||||||
Button japanese = new Button("JapaneseButton", "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f);
|
Button japanese = new Button(LanguageName.Japanese.ToString(), "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f);
|
||||||
Button german = new Button("GermanButton", "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f);
|
Button german = new Button(LanguageName.German.ToString(), "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f);
|
||||||
List<Button> buttons = new List<Button>
|
List<Button> buttons = new List<Button>
|
||||||
{
|
{
|
||||||
english,
|
english,
|
||||||
|
@ -61,7 +62,7 @@ namespace Vocalization.Framework.Menus
|
||||||
|
|
||||||
for (int i = 0; i < this.languages.buttons.Count; i++)
|
for (int i = 0; i < this.languages.buttons.Count; i++)
|
||||||
{
|
{
|
||||||
if (Vocalization.config.translationInfo.currentTranslation == this.languages.buttons.ElementAt(i).label)
|
if (Vocalization.config.translationInfo.CurrentTranslation == (LanguageName)Enum.Parse(typeof(LanguageName), this.languages.buttons.ElementAt(i).name))
|
||||||
this.languages.buttonIndex = i;
|
this.languages.buttonIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,9 +100,9 @@ namespace Vocalization.Framework.Menus
|
||||||
Vocalization.ModHelper.WriteConfig<ModConfig>(Vocalization.config);
|
Vocalization.ModHelper.WriteConfig<ModConfig>(Vocalization.config);
|
||||||
Vocalization.soundManager.volume = (float)Vocalization.config.voiceVolume;
|
Vocalization.soundManager.volume = (float)Vocalization.config.voiceVolume;
|
||||||
|
|
||||||
if (Vocalization.config.translationInfo.currentTranslation != this.getTranslationInfo())
|
if (Vocalization.config.translationInfo.CurrentTranslation != this.getTranslationInfo())
|
||||||
{
|
{
|
||||||
Vocalization.config.translationInfo.currentTranslation = this.getTranslationInfo();
|
Vocalization.config.translationInfo.CurrentTranslation = this.getTranslationInfo();
|
||||||
Vocalization.soundManager.sounds.Clear();
|
Vocalization.soundManager.sounds.Clear();
|
||||||
Vocalization.DialogueCues.Clear();
|
Vocalization.DialogueCues.Clear();
|
||||||
Vocalization.loadAllVoiceFiles();
|
Vocalization.loadAllVoiceFiles();
|
||||||
|
@ -112,10 +113,11 @@ namespace Vocalization.Framework.Menus
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string getTranslationInfo()
|
public LanguageName getTranslationInfo()
|
||||||
{
|
{
|
||||||
//Return the name of the button which will have the translation stuff here!
|
//Return the name of the button which will have the translation stuff here!
|
||||||
return this.languages.getCurrentButtonLabel();
|
string currentName = this.languages.getCurrentButtonName();
|
||||||
|
return (LanguageName)Enum.Parse(typeof(LanguageName), currentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string getAudioMode()
|
public string getAudioMode()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.Linq;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
|
||||||
namespace Vocalization.Framework
|
namespace Vocalization.Framework
|
||||||
|
@ -8,63 +8,56 @@ namespace Vocalization.Framework
|
||||||
/// <summary>A class which deals with handling different translations for Vocalization should other voice teams ever wish to voice act for that language.</summary>
|
/// <summary>A class which deals with handling different translations for Vocalization should other voice teams ever wish to voice act for that language.</summary>
|
||||||
public class TranslationInfo
|
public class TranslationInfo
|
||||||
{
|
{
|
||||||
/// <summary>The list of all supported translations by this mod.</summary>
|
/*********
|
||||||
public List<string> translations;
|
** Accessors
|
||||||
|
*********/
|
||||||
|
/// <summary>The language names supported by this mod.</summary>
|
||||||
|
public LanguageName[] LanguageNames { get; } = (from LanguageName language in Enum.GetValues(typeof(LanguageName)) select language).ToArray();
|
||||||
|
|
||||||
/// <summary>The current translation mode for the mod, so that it knows what files to load at the beginning of the game.</summary>
|
/// <summary>The current translation mode for the mod, so that it knows what files to load at the beginning of the game.</summary>
|
||||||
public string currentTranslation;
|
public LanguageName CurrentTranslation { get; set; } = LanguageName.English;
|
||||||
|
|
||||||
/// <summary>Holds the info for what translation has what file extension.</summary>
|
/// <summary>Holds the info for what translation has what file extension.</summary>
|
||||||
public Dictionary<string, string> translationFileInfo;
|
public Dictionary<LanguageName, string> TranslationFileExtensions { get; } = new Dictionary<LanguageName, string>();
|
||||||
|
|
||||||
|
public Dictionary<LanguageName, LocalizedContentManager.LanguageCode> TranslationCodes { get; } = new Dictionary<LanguageName, LocalizedContentManager.LanguageCode>();
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<string, LocalizedContentManager.LanguageCode> translationCodes;
|
/*********
|
||||||
/// <summary>Default constructor.</summary>
|
** Public methods
|
||||||
|
*********/
|
||||||
|
/// <summary>Construct an instance.</summary>
|
||||||
public TranslationInfo()
|
public TranslationInfo()
|
||||||
{
|
{
|
||||||
this.translations = new List<string>();
|
this.TranslationFileExtensions.Add(LanguageName.English, ".xnb");
|
||||||
|
this.TranslationFileExtensions.Add(LanguageName.Spanish, ".es-ES.xnb");
|
||||||
|
this.TranslationFileExtensions.Add(LanguageName.Chinese, ".zh-CN.xnb");
|
||||||
|
this.TranslationFileExtensions.Add(LanguageName.Japanese, ".ja-JP.xnb");
|
||||||
|
this.TranslationFileExtensions.Add(LanguageName.Russian, ".ru-RU.xnb");
|
||||||
|
this.TranslationFileExtensions.Add(LanguageName.German, ".de-DE.xnb");
|
||||||
|
this.TranslationFileExtensions.Add(LanguageName.Portuguese, ".pt-BR.xnb");
|
||||||
|
|
||||||
this.translationFileInfo = new Dictionary<string, string>();
|
this.TranslationCodes.Add(LanguageName.English, LocalizedContentManager.LanguageCode.en);
|
||||||
this.translationCodes = new Dictionary<string, LocalizedContentManager.LanguageCode>();
|
this.TranslationCodes.Add(LanguageName.Spanish, LocalizedContentManager.LanguageCode.es);
|
||||||
this.translations.Add("English");
|
this.TranslationCodes.Add(LanguageName.Chinese, LocalizedContentManager.LanguageCode.zh);
|
||||||
this.translations.Add("Spanish");
|
this.TranslationCodes.Add(LanguageName.Japanese, LocalizedContentManager.LanguageCode.ja);
|
||||||
this.translations.Add("Chinese");
|
this.TranslationCodes.Add(LanguageName.Russian, LocalizedContentManager.LanguageCode.ru);
|
||||||
this.translations.Add("Japanese");
|
this.TranslationCodes.Add(LanguageName.German, LocalizedContentManager.LanguageCode.de);
|
||||||
this.translations.Add("Russian");
|
this.TranslationCodes.Add(LanguageName.Portuguese, LocalizedContentManager.LanguageCode.pt);
|
||||||
this.translations.Add("German");
|
|
||||||
this.translations.Add("Brazillian Portuguese");
|
|
||||||
|
|
||||||
this.currentTranslation = "English";
|
|
||||||
|
|
||||||
this.translationFileInfo.Add("English", ".xnb");
|
|
||||||
this.translationFileInfo.Add("Spanish", ".es-ES.xnb");
|
|
||||||
this.translationFileInfo.Add("Chinese", ".zh-CN.xnb");
|
|
||||||
this.translationFileInfo.Add("Japanese", ".ja-JP.xnb");
|
|
||||||
this.translationFileInfo.Add("Russian", ".ru-RU.xnb");
|
|
||||||
this.translationFileInfo.Add("German", ".de-DE.xnb");
|
|
||||||
this.translationFileInfo.Add("Brazillian Portuguese", ".pt-BR.xnb");
|
|
||||||
|
|
||||||
this.translationCodes.Add("English", LocalizedContentManager.LanguageCode.en);
|
|
||||||
this.translationCodes.Add("Spanish", LocalizedContentManager.LanguageCode.es);
|
|
||||||
this.translationCodes.Add("Chinese", LocalizedContentManager.LanguageCode.zh);
|
|
||||||
this.translationCodes.Add("Japanese", LocalizedContentManager.LanguageCode.ja);
|
|
||||||
this.translationCodes.Add("Russian", LocalizedContentManager.LanguageCode.ru);
|
|
||||||
this.translationCodes.Add("German", LocalizedContentManager.LanguageCode.de);
|
|
||||||
this.translationCodes.Add("Brazillian Portuguese", LocalizedContentManager.LanguageCode.pt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string getTranslationNameFromPath(string fullPath)
|
/// <summary>Get the language name from a string.</summary>
|
||||||
|
/// <param name="language">The language name.</param>
|
||||||
|
public string getTranslationName(LanguageName language)
|
||||||
{
|
{
|
||||||
return Path.GetFileName(fullPath);
|
return language.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeLocalizedContentManagerFromTranslation(string translation)
|
public void changeLocalizedContentManagerFromTranslation(LanguageName language)
|
||||||
{
|
{
|
||||||
string tra = this.getTranslationNameFromPath(translation);
|
LocalizedContentManager.CurrentLanguageCode = !this.TranslationCodes.TryGetValue(language, out LocalizedContentManager.LanguageCode code)
|
||||||
LocalizedContentManager.CurrentLanguageCode = !this.translationCodes.TryGetValue(tra, out LocalizedContentManager.LanguageCode code)
|
|
||||||
? LocalizedContentManager.LanguageCode.en
|
? LocalizedContentManager.LanguageCode.en
|
||||||
: code;
|
: code;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetLocalizationCode()
|
public void resetLocalizationCode()
|
||||||
|
@ -73,44 +66,39 @@ namespace Vocalization.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the proper file extension for the current translation.</summary>
|
/// <summary>Gets the proper file extension for the current translation.</summary>
|
||||||
public string getFileExtentionForTranslation(string path)
|
/// <param name="language">The translation language name.</param>
|
||||||
|
public string getFileExtentionForTranslation(LanguageName language)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
bool f = translationFileInfo.TryGetValue(translation, out string value);
|
|
||||||
if (!f) return ".xnb";
|
|
||||||
else return value;
|
|
||||||
*/
|
|
||||||
string translation = Path.GetFileName(path);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return this.translationFileInfo[translation];
|
return this.TranslationFileExtensions[language];
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
|
|
||||||
Vocalization.ModMonitor.Log(err.ToString());
|
Vocalization.ModMonitor.Log(err.ToString());
|
||||||
Vocalization.ModMonitor.Log("Attempted to get translation: " + translation);
|
Vocalization.ModMonitor.Log($"Attempted to get translation: {language}");
|
||||||
return ".xnb";
|
return ".xnb";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the proper XNB for Buildings (aka Blueprints) from the data folder.</summary>
|
/// <summary>Gets the proper XNB for Buildings (aka Blueprints) from the data folder.</summary>
|
||||||
public string getBuildingXNBForTranslation(string translation)
|
public string getBuildingXNBForTranslation(LanguageName language)
|
||||||
{
|
{
|
||||||
string buildings = "Blueprints";
|
string buildings = "Blueprints";
|
||||||
return buildings + this.getFileExtentionForTranslation(translation);
|
return buildings + this.getFileExtentionForTranslation(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the proper XNB file for the name passed in. Combines the file name with it's proper translation extension.</summary>
|
/// <summary>Gets the proper XNB file for the name passed in. Combines the file name with it's proper translation extension.</summary>
|
||||||
public string getXNBForTranslation(string xnbFileName, string translation)
|
public string getXNBForTranslation(string xnbFileName, LanguageName language)
|
||||||
{
|
{
|
||||||
return xnbFileName + this.getFileExtentionForTranslation(translation);
|
return xnbFileName + this.getFileExtentionForTranslation(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Loads an XNB file from StardewValley/Content</summary>
|
/// <summary>Loads an XNB file from StardewValley/Content</summary>
|
||||||
public string LoadXNBFile(string xnbFileName, string key, string translation)
|
public string LoadXNBFile(string xnbFileName, string key, LanguageName language)
|
||||||
{
|
{
|
||||||
string xnb = xnbFileName + this.getFileExtentionForTranslation(translation);
|
string xnb = xnbFileName + this.getFileExtentionForTranslation(language);
|
||||||
Dictionary<string, string> loadedDict = Game1.content.Load<Dictionary<string, string>>(xnb);
|
Dictionary<string, string> loadedDict = Game1.content.Load<Dictionary<string, string>>(xnb);
|
||||||
|
|
||||||
if (!loadedDict.TryGetValue(key, out string loaded))
|
if (!loadedDict.TryGetValue(key, out string loaded))
|
||||||
|
@ -121,9 +109,9 @@ namespace Vocalization.Framework
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string LoadString(string path, string translation, object sub1, object sub2, object sub3)
|
public virtual string LoadString(string path, LanguageName language, object sub1, object sub2, object sub3)
|
||||||
{
|
{
|
||||||
string format = this.LoadString(path, translation);
|
string format = this.LoadString(path, language);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return string.Format(format, sub1, sub2, sub3);
|
return string.Format(format, sub1, sub2, sub3);
|
||||||
|
@ -133,9 +121,9 @@ namespace Vocalization.Framework
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string LoadString(string path, string translation, object sub1, object sub2)
|
public virtual string LoadString(string path, LanguageName language, object sub1, object sub2)
|
||||||
{
|
{
|
||||||
string format = this.LoadString(path, translation);
|
string format = this.LoadString(path, language);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return string.Format(format, sub1, sub2);
|
return string.Format(format, sub1, sub2);
|
||||||
|
@ -145,9 +133,9 @@ namespace Vocalization.Framework
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string LoadString(string path, string translation, object sub1)
|
public virtual string LoadString(string path, LanguageName language, object sub1)
|
||||||
{
|
{
|
||||||
string format = this.LoadString(path, translation);
|
string format = this.LoadString(path, language);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return string.Format(format, sub1);
|
return string.Format(format, sub1);
|
||||||
|
@ -157,16 +145,16 @@ namespace Vocalization.Framework
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string LoadString(string path, string translation)
|
public virtual string LoadString(string path, LanguageName language)
|
||||||
{
|
{
|
||||||
this.parseStringPath(path, out string assetName, out string key);
|
this.parseStringPath(path, out string assetName, out string key);
|
||||||
|
|
||||||
return this.LoadXNBFile(assetName, key, translation);
|
return this.LoadXNBFile(assetName, key, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string LoadString(string path, string translation, params object[] substitutions)
|
public virtual string LoadString(string path, LanguageName language, params object[] substitutions)
|
||||||
{
|
{
|
||||||
string format = this.LoadString(path, translation);
|
string format = this.LoadString(path, language);
|
||||||
if (substitutions.Length != 0)
|
if (substitutions.Length != 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -10,67 +10,67 @@ namespace Vocalization.Framework
|
||||||
{
|
{
|
||||||
public class Vocabulary
|
public class Vocabulary
|
||||||
{
|
{
|
||||||
public static string[] getRandomNegativeItemSlanderNouns(string translation)
|
public static string[] getRandomNegativeItemSlanderNouns(LanguageName language)
|
||||||
{
|
{
|
||||||
string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeItemNoun"), translation).Split('#');
|
string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeItemNoun"), language).Split('#');
|
||||||
return strArray;
|
return strArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] getRandomDeliciousAdjectives(string translation, NPC n = null)
|
public static string[] getRandomDeliciousAdjectives(LanguageName language, NPC n = null)
|
||||||
{
|
{
|
||||||
string[] strArray;
|
string[] strArray;
|
||||||
if (n != null && n.Age == 2)
|
if (n != null && n.Age == 2)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective_Child"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective_Child"), language).Split('#');
|
||||||
else
|
else
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective"), language).Split('#');
|
||||||
return strArray;
|
return strArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] getRandomNegativeFoodAdjectives(string translation, NPC n = null)
|
public static string[] getRandomNegativeFoodAdjectives(LanguageName language, NPC n = null)
|
||||||
{
|
{
|
||||||
string[] strArray;
|
string[] strArray;
|
||||||
if (n != null && n.Age == 2)
|
if (n != null && n.Age == 2)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective_Child"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective_Child"), language).Split('#');
|
||||||
else if (n != null && n.Manners == 1)
|
else if (n != null && n.Manners == 1)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective_Polite"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective_Polite"), language).Split('#');
|
||||||
else
|
else
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective"), language).Split('#');
|
||||||
return strArray;
|
return strArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] getRandomSlightlyPositiveAdjectivesForEdibleNoun(string translation, NPC n = null)
|
public static string[] getRandomSlightlyPositiveAdjectivesForEdibleNoun(LanguageName language, NPC n = null)
|
||||||
{
|
{
|
||||||
string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomSlightlyPositiveFoodAdjective"), translation).Split('#');
|
string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomSlightlyPositiveFoodAdjective"), language).Split('#');
|
||||||
return strArray;
|
return strArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] getRandomNegativeAdjectivesForEventOrPerson(string translation, NPC n = null)
|
public static string[] getRandomNegativeAdjectivesForEventOrPerson(LanguageName language, NPC n = null)
|
||||||
{
|
{
|
||||||
Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2);
|
Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2);
|
||||||
string[] strArray;
|
string[] strArray;
|
||||||
if (n != null && n.Age != 0)
|
if (n != null && n.Age != 0)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_Child"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_Child"), language).Split('#');
|
||||||
else if (n != null && n.Gender == 0)
|
else if (n != null && n.Gender == 0)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_AdultMale"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_AdultMale"), language).Split('#');
|
||||||
else if (n != null && n.Gender == 1)
|
else if (n != null && n.Gender == 1)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_AdultFemale"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_AdultFemale"), language).Split('#');
|
||||||
else
|
else
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_PlaceOrEvent"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_PlaceOrEvent"), language).Split('#');
|
||||||
return strArray;
|
return strArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string[] getRandomPositiveAdjectivesForEventOrPerson(string translation, NPC n = null)
|
public static string[] getRandomPositiveAdjectivesForEventOrPerson(LanguageName language, NPC n = null)
|
||||||
{
|
{
|
||||||
//Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2);
|
//Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2);
|
||||||
string[] strArray;
|
string[] strArray;
|
||||||
if (n != null && n.Age != 0)
|
if (n != null && n.Age != 0)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_Child"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_Child"), language).Split('#');
|
||||||
else if (n != null && n.Gender == 0)
|
else if (n != null && n.Gender == 0)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultMale"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultMale"), language).Split('#');
|
||||||
else if (n != null && n.Gender == 1)
|
else if (n != null && n.Gender == 1)
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultFemale"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultFemale"), language).Split('#');
|
||||||
else
|
else
|
||||||
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_PlaceOrEvent"), translation).Split('#');
|
strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_PlaceOrEvent"), language).Split('#');
|
||||||
return strArray;
|
return strArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ namespace Vocalization.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets a list of all of the possible cooking recipes in Stardew Valley.</summary>
|
/// <summary>Gets a list of all of the possible cooking recipes in Stardew Valley.</summary>
|
||||||
public static List<string> getAllCookingRecipes(string translation)
|
public static List<string> getAllCookingRecipes(LanguageName language)
|
||||||
{
|
{
|
||||||
List<string> recipes = new List<string>();
|
List<string> recipes = new List<string>();
|
||||||
Dictionary<string, string> cookingDict = Game1.content.Load<Dictionary<string, string>>(Path.Combine("Data", "TV", Vocalization.config.translationInfo.getXNBForTranslation("CookingChannel", translation)));
|
Dictionary<string, string> cookingDict = Game1.content.Load<Dictionary<string, string>>(Path.Combine("Data", "TV", Vocalization.config.translationInfo.getXNBForTranslation("CookingChannel", language)));
|
||||||
|
|
||||||
if (Vocalization.config.translationInfo.getTranslationNameFromPath(translation) == "English")
|
if (language == LanguageName.English)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, string> pair in cookingDict)
|
foreach (KeyValuePair<string, string> pair in cookingDict)
|
||||||
{
|
{
|
||||||
|
@ -105,10 +105,10 @@ namespace Vocalization.Framework
|
||||||
return recipes;
|
return recipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> getCarpenterStock(string translation)
|
public static List<string> getCarpenterStock(LanguageName language)
|
||||||
{
|
{
|
||||||
List<string> stock = new List<string>();
|
List<string> stock = new List<string>();
|
||||||
Vocalization.config.translationInfo.changeLocalizedContentManagerFromTranslation(translation);
|
Vocalization.config.translationInfo.changeLocalizedContentManagerFromTranslation(language);
|
||||||
|
|
||||||
for (int i = 0; i <= 1854; i++)
|
for (int i = 0; i <= 1854; i++)
|
||||||
{
|
{
|
||||||
|
@ -123,10 +123,10 @@ namespace Vocalization.Framework
|
||||||
return stock;
|
return stock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> getMerchantStock(string translation)
|
public static List<string> getMerchantStock(LanguageName language)
|
||||||
{
|
{
|
||||||
List<string> stock = new List<string>();
|
List<string> stock = new List<string>();
|
||||||
Dictionary<int, string> objDict = Game1.content.Load<Dictionary<int, string>>(Path.Combine("Data", Vocalization.config.translationInfo.getXNBForTranslation("ObjectInformation", translation)));
|
Dictionary<int, string> objDict = Game1.content.Load<Dictionary<int, string>>(Path.Combine("Data", Vocalization.config.translationInfo.getXNBForTranslation("ObjectInformation", language)));
|
||||||
//Vocalization.ModMonitor.Log("LOAD THE OBJECT INFO: ", LogLevel.Alert);
|
//Vocalization.ModMonitor.Log("LOAD THE OBJECT INFO: ", LogLevel.Alert);
|
||||||
foreach (KeyValuePair<int, string> pair in objDict)
|
foreach (KeyValuePair<int, string> pair in objDict)
|
||||||
{
|
{
|
||||||
|
@ -136,14 +136,14 @@ namespace Vocalization.Framework
|
||||||
stock.Add(obj.DisplayName);
|
stock.Add(obj.DisplayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (string item in getCarpenterStock(translation))
|
foreach (string item in getCarpenterStock(language))
|
||||||
stock.Add(item);
|
stock.Add(item);
|
||||||
return stock;
|
return stock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string getProperArticleForWord(string displayName, string translation)
|
public static string getProperArticleForWord(string displayName, LanguageName language)
|
||||||
{
|
{
|
||||||
Vocalization.config.translationInfo.changeLocalizedContentManagerFromTranslation(translation);
|
Vocalization.config.translationInfo.changeLocalizedContentManagerFromTranslation(language);
|
||||||
string s = Lexicon.getProperArticleForWord(displayName);
|
string s = Lexicon.getProperArticleForWord(displayName);
|
||||||
Vocalization.config.translationInfo.resetLocalizationCode();
|
Vocalization.config.translationInfo.resetLocalizationCode();
|
||||||
return s;
|
return s;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -48,6 +48,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Framework\AudioCues.cs" />
|
<Compile Include="Framework\AudioCues.cs" />
|
||||||
<Compile Include="Framework\CharacterVoiceCue.cs" />
|
<Compile Include="Framework\CharacterVoiceCue.cs" />
|
||||||
|
<Compile Include="Framework\LanguageName.cs" />
|
||||||
<Compile Include="Framework\Menus\VocalizationMenu.cs" />
|
<Compile Include="Framework\Menus\VocalizationMenu.cs" />
|
||||||
<Compile Include="Framework\ReplacementStrings.cs" />
|
<Compile Include="Framework\ReplacementStrings.cs" />
|
||||||
<Compile Include="Framework\TranslationInfo.cs" />
|
<Compile Include="Framework\TranslationInfo.cs" />
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"Description": "A mod that brings voice acting to Stardew Valley.",
|
"Description": "A mod that brings voice acting to Stardew Valley.",
|
||||||
"UniqueID": "Omegasis.Vocalization",
|
"UniqueID": "Omegasis.Vocalization",
|
||||||
"EntryDll": "Vocalization.dll",
|
"EntryDll": "Vocalization.dll",
|
||||||
"MinimumApiVersion": "2.0",
|
"MinimumApiVersion": "2.10.1",
|
||||||
"UpdateKeys": [],
|
"UpdateKeys": [],
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
{ "UniqueID": "Omegasis.SimpleSoundManager" },
|
{ "UniqueID": "Omegasis.SimpleSoundManager" },
|
||||||
|
|
Loading…
Reference in New Issue