Big update to Symphony Remastered. Added in support for festivals, events, and menus. Also added in support for adding in support for mods that use Symphony.

This commit is contained in:
2018-04-27 11:49:52 -07:00
parent e42e91e30d
commit 7e5d4349ca
5 changed files with 557 additions and 110 deletions

View File

@ -166,6 +166,7 @@ namespace Omegasis.StardewSymphony
if (!Context.IsWorldReady)
return;
this.SelectMusic();
}

View File

@ -16,9 +16,20 @@ using StardustCore.UIUtilities.SpriteFonts.Components;
namespace StardewSymphonyRemastered.Framework.Menus
{
/* TODO: Make the different menus for the conditional keys
* Normal (locations, season, weather,date, time)
* Festival
* Event
*
*/
/// <summary>
/// Interface for the menu for selection music.
/// </summary>
public class MusicManagerMenu : IClickableMenuExtended
{
/// <summary>
/// The different displays for this menu.
/// </summary>
public enum DrawMode
{
AlbumSelection,
@ -26,15 +37,15 @@ namespace StardewSymphonyRemastered.Framework.Menus
SongSelectionMode,
}
public List<Button> musicAlbumButtons;
public List<Button> musicAlbumButtons;
public Button currentMusicPackAlbum;
public Button currentSelectedSong;
public DrawMode drawMode;
public int currentAlbumIndex;
public int currentSongPageIndex;
public List<Button> fancyButtons;
public int framesSinceLastUpdate;
public List<Button> fancyButtons; //List that holds all of the buttons for the fancy album menu.
public int framesSinceLastUpdate; //Used to control how fast we can cycle through the menu.
public bool searchBoxSelected;
@ -278,7 +289,12 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
}
/// <summary>
/// Functionality that occurs when right clicking a menu component.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="playSound"></param>
public override void receiveRightClick(int x, int y, bool playSound = true)
{
if (this.drawMode == DrawMode.AlbumSelection)
@ -303,6 +319,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
}
/// <summary>
/// Actions that occur when hovering over an icon.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
public override void performHoverAction(int x, int y)
{
if (this.drawMode == DrawMode.AlbumSelection)
@ -374,6 +395,12 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
}
/// <summary>
/// Functionality that occurs when left clicking a menu component.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="playSound"></param>
public override void receiveLeftClick(int x, int y, bool playSound = true)
{
if (this.drawMode == DrawMode.AlbumSelection)

View File

@ -190,6 +190,49 @@ namespace StardewSymphonyRemastered.Framework
return listOfValidDictionaries;
}
public Dictionary<MusicPack, List<Song>> getListOfApplicableMusicPacksForFestivals()
{
Dictionary<MusicPack, List<Song>> listOfValidDictionaries = new Dictionary<MusicPack, List<Song>>();
foreach (var v in this.musicPacks)
{
try
{
var songList = v.Value.songInformation.getFestivalMusic();
if (songList.Count > 0)
{
listOfValidDictionaries.Add(v.Value, songList);
}
}
catch (Exception err)
{
}
}
return listOfValidDictionaries;
}
public Dictionary<MusicPack, List<Song>> getListOfApplicableMusicPacksForEvents()
{
Dictionary<MusicPack, List<Song>> listOfValidDictionaries = new Dictionary<MusicPack, List<Song>>();
foreach (var v in this.musicPacks)
{
try
{
var songList = v.Value.songInformation.getEventMusic();
if (songList.Count > 0)
{
listOfValidDictionaries.Add(v.Value, songList);
}
}
catch (Exception err)
{
}
}
return listOfValidDictionaries;
}
/// <summary>
/// Selects the actual song to be played right now based off of the selector key. The selector key should be called when the player's location changes.
/// </summary>
@ -223,7 +266,7 @@ namespace StardewSymphonyRemastered.Framework
if (listOfValidMusicPacks.Count == 0)
{
//No valid songs to play at this time.
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + subKey + ". Are you sure you did this properly?");
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + subKey + ". 1 Are you sure you did this properly?");
//return;
}
}
@ -244,15 +287,22 @@ namespace StardewSymphonyRemastered.Framework
}
if (string.IsNullOrEmpty(subKey))
{
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + songListKey + ". Are you sure you did this properly?");
return;
bool f = checkGenericMusic(songListKey);
if (f == false)
{
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + songListKey + ".2 Are you sure you did this properly?");
StardewSymphony.menuChangedMusic = false;
return;
}
}
StardewSymphony.ModMonitor.Log(subKey, StardewModdingAPI.LogLevel.Alert);
listOfValidMusicPacks = getListOfApplicableMusicPacks(subKey);
if (listOfValidMusicPacks.Count == 0)
{
//No valid songs to play at this time.
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + subKey + ". Are you sure you did this properly?");
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + subKey + ".3 Are you sure you did this properly?");
//return;
}
//Try to get more specific.
@ -277,19 +327,28 @@ namespace StardewSymphonyRemastered.Framework
if (listOfValidMusicPacks.Count == 0)
{
//No valid songs to play at this time.
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + subKey + ". Are you sure you did this properly?");
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + subKey + ".4 Are you sure you did this properly?");
//return;
}
}
}
//If the list of valid packs are 0, check if I'm currently at an event or festival and try to play a generalized song from there.
if (listOfValidMusicPacks.Count == 0)
{
//No valid songs to play at this time.
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + songListKey + ". Are you sure you did this properly?");
return;
bool f= checkGenericMusic(songListKey);
if (f == false)
{
//No valid songs to play at this time.
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + songListKey + ".7 Are you sure you did this properly?");
StardewSymphony.menuChangedMusic = false;
return;
}
}
//If there is a valid key for the place/time/event/festival I am at, play it!
int randInt = packSelector.Next(0, listOfValidMusicPacks.Count-1);
@ -306,6 +365,72 @@ namespace StardewSymphonyRemastered.Framework
}
public bool checkGenericMusic(string songListKey)
{
if (Game1.CurrentEvent != null)
{
if (Game1.CurrentEvent.isFestival)
{
//Try to play a generalized festival song.
var listOfFestivalPacks = this.getListOfApplicableMusicPacksForFestivals();
if (listOfFestivalPacks.Count > 0)
{
int randFestivalPack = packSelector.Next(0, listOfFestivalPacks.Count - 1);
var festivalMusicPackPair = listOfFestivalPacks.ElementAt(randFestivalPack);
//used to swap the music packs and stop the last playing song.
this.swapMusicPacks(festivalMusicPackPair.Key.musicPackInformation.name);
int randFestivalPack2 = songSelector.Next(0, festivalMusicPackPair.Value.Count);
var festivalSongName = festivalMusicPackPair.Value.ElementAt(randFestivalPack2);
this.currentMusicPack.playSong(festivalSongName.name);
StardewSymphony.menuChangedMusic = false;
return true;
}
else
{
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + songListKey + ".5 Are you sure you did this properly?");
StardewSymphony.ModMonitor.Log("Also failed playing a festival event song.");
StardewSymphony.menuChangedMusic = false;
return false;
}
}
else
{
//Try to play a generalized event song.
var listOfEventPacks = this.getListOfApplicableMusicPacksForEvents();
if (listOfEventPacks.Count > 0)
{
int randEventPack = packSelector.Next(0, listOfEventPacks.Count - 1);
var eventMusicPackPair = listOfEventPacks.ElementAt(randEventPack);
//used to swap the music packs and stop the last playing song.
this.swapMusicPacks(eventMusicPackPair.Key.musicPackInformation.name);
int randEventPack2 = songSelector.Next(0, eventMusicPackPair.Value.Count);
var eventSongName = eventMusicPackPair.Value.ElementAt(randEventPack2);
this.currentMusicPack.playSong(eventSongName.name);
StardewSymphony.menuChangedMusic = false;
return true;
}
else
{
StardewSymphony.ModMonitor.Log("Error: There are no songs to play across any music pack for the song key: " + songListKey + ".6 Are you sure you did this properly?");
StardewSymphony.ModMonitor.Log("Also failed playing a generalized event song.");
StardewSymphony.menuChangedMusic = false;
return false;
}
}
}
return false;
}
/// <summary>
/// Adds a valid xwb music pack to the list of music packs available.
/// </summary>
@ -346,7 +471,9 @@ namespace StardewSymphonyRemastered.Framework
this.musicPacks.Add(musicPack.musicPackInformation.name,musicPack);
}
/// <summary>
/// Initializes all of the potential key triggers for playing songs.
/// </summary>
public void initializeSeasonalMusic()
{
foreach(var pack in this.musicPacks)
@ -355,6 +482,43 @@ namespace StardewSymphonyRemastered.Framework
}
}
/// <summary>
/// Initializes all of the potential key triggers for playing songs.
/// </summary>
public void initializeMenuMusic()
{
foreach (var pack in this.musicPacks)
{
pack.Value.songInformation.initializeMenuMusic();
}
}
/// <summary>
/// Initializes all of the potential key triggers for playing songs.
/// </summary>
public void initializeFestivalMusic()
{
foreach (var pack in this.musicPacks)
{
pack.Value.songInformation.initializeFestivalMusic();
}
}
/// <summary>
/// Initializes all of the potential key triggers for playing songs.
/// </summary>
public void initializeEventMusic()
{
foreach (var pack in this.musicPacks)
{
pack.Value.songInformation.initializeEventMusic();
}
}
/// <summary>
/// Play a random song from a given music pack.
/// </summary>
/// <param name="musicPackName"></param>
public void playRandomSongFromPack(string musicPackName)
{
this.musicPacks.TryGetValue(musicPackName, out MusicPack musicPack);

View File

@ -9,28 +9,31 @@ namespace StardewSymphonyRemastered.Framework
{
/// <summary>
/// Stores information about what songs play when.
///
/// TODO: Festivals and events
/// </summary>
public class SongSpecifics
{
public Dictionary<string, List<Song>> listOfSongsWithTriggers; //triggerName, <songs>
public Dictionary<string, List<Song>> listOfSongsWithTriggers; //triggerName, <songs>. Seasonal music
public Dictionary<string, List<Song>> eventSongs;
public Dictionary<string, List<Song>> festivalSongs;
public List<Song> listOfSongsWithoutTriggers;
public List<Song> listOfSongsWithoutTriggers;
public List<Song> festivalSongs;
public List<Song> eventSongs;
public static List<string> locations = new List<string>();
public static List<string> festivals = new List<string>();
public static List<string> events = new List<string>();
/// <summary>
/// Keeps track of the menus that support custom music with this mod.
/// </summary>
public static List<string> menus = new List<string>();
string[] seasons;
string[] weather;
string[] daysOfWeek;
string[] timesOfDay;
List<string> menus;
public static char seperator = '_';
/// <summary>
@ -52,7 +55,6 @@ namespace StardewSymphonyRemastered.Framework
"rainy",
"debris",
"lightning",
"festival",
"snow",
"wedding"
};
@ -71,17 +73,13 @@ namespace StardewSymphonyRemastered.Framework
"day",
"night"
};
menus = new List<string>();
menus.Add(typeof(StardewValley.Menus.TitleMenu).ToString().Replace('.', seperator));
listOfSongsWithTriggers = new Dictionary<string, List<Song>>();
eventSongs = new Dictionary<string, List<Song>>();
festivalSongs = new Dictionary<string, List<Song>>();
this.listOfSongsWithoutTriggers = new List<Song>();
this.addMenuMusic();
this.eventSongs = new List<Song>();
this.festivalSongs = new List<Song>();
}
@ -100,23 +98,41 @@ namespace StardewSymphonyRemastered.Framework
{
string key = "";
bool foundMenuString = false;
if (Game1.eventUp == true)
//Event id's are the number found before the : for the event in Content/events/<location>.yaml file where location is the name of the stardew valley location.
if (Game1.eventUp == true && Game1.CurrentEvent.isFestival==false)
{
//Get the event id an hijack it with some different music
//String key="Event_EventName";
var reflected = StardewSymphony.ModHelper.Reflection.GetField<int>(Game1.CurrentEvent, "id", true);
int id = reflected.GetValue();
key= id.ToString(); //get the event id. Really really messy.
return key;
}
else if (Game1.isFestival())
{
//hijack the name of the festival and load some different songs
// string s="Festival_FestivalName";
//hijack the date of the festival and load some different songs
// string s="Festival name"
key = Game1.CurrentEvent.FestivalName;
return key;
}
else if (Game1.activeClickableMenu!=null)
{
if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.TitleMenu))
String name = Game1.activeClickableMenu.GetType().ToString().Replace('.', seperator);
//Iterate through all of the potential menu options and check if it is valid.
foreach (var menuNamespaceName in menus)
{
key = Game1.activeClickableMenu.GetType().ToString().Replace('.',seperator);
foundMenuString = true;
if (name == menuNamespaceName)
{
key =name;
foundMenuString = true;
StardewSymphony.menuChangedMusic = true;
return key;
}
}
return ""; //No menu found so don't event try to change the music.
}
else
@ -137,26 +153,52 @@ namespace StardewSymphonyRemastered.Framework
/// <summary>
/// Initialize the location lists with the names of all of the major locations in the game.
/// </summary>
public static void addLocations()
public static void initializeLocationsList()
{
//Give stardew symphony access to have unique music at any game location.
foreach (var v in Game1.locations)
{
locations.Add(v.name);
StardewSymphony.ModMonitor.Log("Adding in song triggers for location: " + v.name);
}
//Try to get stardew symphony to recognize builds on the farm and try to give those buildings unique soundtracks as well.
try
{
var farm = (Farm)Game1.getLocationFromName("Farm");
foreach(var building in farm.buildings)
{
locations.Add(building.nameOfIndoors);
StardewSymphony.ModMonitor.Log("Adding in song triggers for location: " + building.nameOfIndoors);
}
}
catch(Exception err)
{
StardewSymphony.ModMonitor.Log(err.ToString());
}
}
/// <summary>
/// TODO: Find a way to get all of the festivals in the game for this list. Perhapse have a way to check the season and day of the month and equivilate it to something.
/// Initialize list of festivals for the game.
/// Initializes a list of the festivals included in vanilla stardew valley to be allowed to have custom music options.
/// Initialized by festival name
/// </summary>
public static void addFestivals()
public static void initializeFestivalsList()
{
//Do some logic for festivals here.
addFestival("Egg Festival"); //Egg festival
addFestival("Flower Dance"); //Flower dance
addFestival("Luau"); //luau
addFestival("Dance Of The Moonlight Jellies"); //moonlight jellies
addFestival("Stardew Valley Fair"); //fall fair
addFestival("Spirit's Eve"); //spirits eve
addFestival("Festival of Ice"); //festival of ice
addFestival("Feast of the Winter Star"); //festival of winter star
}
/// <summary>
/// Add a specific new festival to the list
/// Add a specific new festival to the list. Must be in the format seasonDay.
/// Ex) spring13
/// Ex) fall27
/// </summary>
public static void addFestival(string name)
{
@ -167,17 +209,19 @@ namespace StardewSymphonyRemastered.Framework
/// TODO: Get a list of all of the vanilla events in the game. But how to determine what event is playing is the question.
/// </summary>
/// <param name="name"></param>
public static void addEvents()
public static void initializeEventsList()
{
//Do some logic here
//addEvent(12345.ToString());
}
/// <summary>
/// TODO: Custom way to add in event to hijack music.
/// </summary>
/// <param name="name"></param>
public static void addEvent(string name)
public static void addEvent(string id)
{
events.Add(id);
//Do some logic here
}
@ -244,14 +288,15 @@ namespace StardewSymphonyRemastered.Framework
/// <returns></returns>
public static string getWeatherString()
{
if (Game1.weatherIcon == Game1.weather_sunny) return "sunny";
if (Game1.weatherIcon == Game1.weather_rain) return "rainy";
if (Game1.weatherIcon == Game1.weather_debris) return "lightning";
if (Game1.weatherIcon == Game1.weather_lightning) return "debris"; //????
if (Game1.weatherIcon == Game1.weather_festival) return "festival";
if (Game1.weatherIcon == Game1.weather_snow) return "snow";
if (Game1.weatherIcon == Game1.weather_wedding) return "wedding";
return "";
if (Game1.isRaining && Game1.isLightning==false) return "rainy";
if (Game1.isLightning) return "lightning";
if (Game1.isDebrisWeather) return "debris"; //????
if (Game1.isSnowing) return "snow";
if (Game1.weddingToday) return "wedding";
return "sunny"; //If none of the other weathers, make it sunny.
}
/// <summary>
@ -270,7 +315,14 @@ namespace StardewSymphonyRemastered.Framework
/// <returns></returns>
public static string getLocationString()
{
return Game1.currentLocation.name;
try
{
return Game1.currentLocation.name;
}
catch(Exception err)
{
return "";
}
}
public static string getCurrentMenuString()
@ -284,24 +336,136 @@ namespace StardewSymphonyRemastered.Framework
// Non-Static Methods //
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
#region
/// <summary>
/// Adds the song's reference to a music pack.
/// </summary>
/// <param name="songName"></param>
/// <param name="songName">The FULL namespace of the menu. Example is StardewValley.Menus.TitleMenu</param>
public void addSongToMusicPack(Song song)
{
this.listOfSongsWithoutTriggers.Add(song);
}
public void addMenuMusic()
/// <summary>
/// Initialize a basic list of menus supported.
/// </summary>
public static void initializeMenuList()
{
addMenu(typeof(StardewValley.Menus.TitleMenu)); //Of course!
addMenu(typeof(StardewValley.Menus.AboutMenu)); //Sure, though I doubt many people look at this menu.
addMenu(typeof(StardewValley.Menus.Billboard)); //The billboard in town.
addMenu(typeof(StardewValley.Menus.BlueprintsMenu)); // the crafting menu.
//addMenu(typeof(StardewValley.Menus.BobberBar)); //Fishing.
addMenu(typeof(StardewValley.Menus.Bundle)); //Definitely could be fun. Custom bundle menu music.
addMenu(typeof(StardewValley.Menus.CarpenterMenu)); //Building a thing with robbin
addMenu(typeof(StardewValley.Menus.CataloguePage)); //???
addMenu(typeof(StardewValley.Menus.CharacterCustomization)); //Yea!
addMenu(typeof(StardewValley.Menus.CollectionsPage));
addMenu(typeof(StardewValley.Menus.CooperativeMenu));
addMenu(typeof(StardewValley.Menus.CraftingPage));
addMenu(typeof(StardewValley.Menus.Fish)); //Music when fishing
addMenu(typeof(StardewValley.Menus.GameMenu)); //Err default inventory page?
addMenu(typeof(StardewValley.Menus.GeodeMenu)); //Flint
addMenu(typeof(StardewValley.Menus.LoadGameMenu)); //Loading the game.
addMenu(typeof(StardewValley.Menus.LevelUpMenu)); //Leveling up
addMenu(typeof(StardewValley.Menus.LetterViewerMenu)); //Viewing your mail
addMenu(typeof(StardewValley.Menus.MapPage)); //Looking at the map
addMenu(typeof(StardewValley.Menus.MuseumMenu)); //Arranging things in the museum
addMenu(typeof(StardewValley.Menus.NamingMenu)); //Naming an animal
addMenu(typeof(StardewValley.Menus.PurchaseAnimalsMenu)); //Buying an animal.
addMenu(typeof(StardewValley.Menus.SaveGameMenu)); //Saving the game / end of night
addMenu(typeof(StardewValley.Menus.ShippingMenu)); //Shipping screen.
addMenu(typeof(StardewValley.Menus.ShopMenu)); //Buying things
}
/// <summary>
/// Add a menu to stardew symphony so that it may have unique music.
/// </summary>
/// <param name="name"></param>
public static void addMenu(string name)
{
try
{
name = name.Replace('.', seperator); //Sanitize the name passed in to use my parsing conventions.
menus.Add(name);
}
catch(Exception err)
{
}
}
/// <summary>
/// Add amenu to stardew symphony so that it may have unique music.
/// </summary>
/// <param name="menuType">The type of menu to add in. Typically this is typeof(MyMenuClass)</param>
public static void addMenu(Type menuType)
{
try
{
string name = menuType.ToString().Replace('.', seperator); //Sanitize the name passed in to use my parsing conventions.
menus.Add(name); //Add the sanitized menu name to the list of menus that have custom music.
}
catch(Exception err)
{
}
}
/// <summary>
/// Initialize the music packs with music from all passed in menus.
/// </summary>
public void initializeMenuMusic()
{
foreach(var v in menus)
{
this.listOfSongsWithTriggers.Add(v, new List<Song>());
try
{
this.listOfSongsWithTriggers.Add(v, new List<Song>());
}
catch(Exception err)
{
}
}
}
public void initializeFestivalMusic()
{
foreach (var v in festivals)
{
try
{
this.listOfSongsWithTriggers.Add(v, new List<Song>());
}
catch (Exception err)
{
}
}
}
public void initializeEventMusic()
{
foreach (var v in events)
{
try
{
this.listOfSongsWithTriggers.Add(v, new List<Song>());
}
catch (Exception err)
{
}
}
}
/// <summary>
/// Checks if the song exists at all in this music pack.
/// </summary>
@ -366,48 +530,55 @@ namespace StardewSymphonyRemastered.Framework
public KeyValuePair<string,List<Song>>getSongList(string key)
{
string keyPhrase = "";
string keyPhraseInfo = "";
try
{
keyPhrase= key.Split(seperator).ElementAt(0);
keyPhraseInfo= key.Split(seperator).ElementAt(1);
}
catch(Exception err)
{
keyPhrase = key;
}
if (keyPhrase == "event")
{
foreach (KeyValuePair<string, List<Song>> pair in eventSongs)
{
if (pair.Key == key) return pair;
}
//return new KeyValuePair<string, List<Song>>(key, eventSongs[key]);
}
else if (keyPhrase == "festival")
{
foreach (KeyValuePair<string, List<Song>> pair in festivalSongs)
{
if (pair.Key == key) return pair;
}
//return new KeyValuePair<string, List<string>>(key, festivalSongs[key]);
}
else
{
//This is just the plain song name with no extra info.
foreach(KeyValuePair<string,List<Song>> pair in listOfSongsWithTriggers)
{
//StardewSymphony.ModMonitor.Log(pair.Key);
if (pair.Key == key) return pair;
}
//return new KeyValuePair<string, List<string>>(key, listOfSongsWithTriggers[key]);
//This is just the plain song name with no extra info.
foreach (KeyValuePair<string, List<Song>> pair in listOfSongsWithTriggers)
{
//StardewSymphony.ModMonitor.Log(pair.Key);
if (pair.Key == key) return pair;
}
//This is just the plain song name with no extra info.
foreach (KeyValuePair<string, List<Song>> pair in listOfSongsWithTriggers)
{
//StardewSymphony.ModMonitor.Log(pair.Key);
if (pair.Key == key) return pair;
}
//return new KeyValuePair<string, List<string>>(key, listOfSongsWithTriggers[key]);
return new KeyValuePair<string, List<Song>>("",null);
}
public List<Song> getFestivalMusic()
{
return this.festivalSongs;
}
public List<Song> getEventMusic()
{
return this.eventSongs;
}
/// <summary>
/// Add a song name to a specific list of songs to play that will play under certain conditions.
/// </summary>

View File

@ -19,10 +19,21 @@ namespace StardewSymphonyRemastered
/// TODO:
/// -Make way to swap between album menu draw modes
/// -make a currently playing menu off to the side to tell you what song is playing from what album.
/// Make songs work for festivals and events.
/// Finish making triggers menus
/// 3.Make interface.
/// 5.Release
/// 6.Make videos documenting how to make this mod work.
/// 7.Make way to generate new music packs.
///
///
/// Add mod config to have silent rain option.
/// Add in song delay function.
/// Add in shuffle song button that just selects music but probably plays a different song. same as musicManager.selectmusic(getConditionalString);
///
///
/// Notes:
/// All mods must add events/locations/festivals/menu information to this mod during the Entry function of their mod because once the game does it's first update tick, that's when all of the packs are initialized with all of their music.
/// </summary>
public class StardewSymphony : Mod
{
@ -43,6 +54,14 @@ namespace StardewSymphonyRemastered
public bool musicPacksInitialized;
public static bool festivalStart;
public static bool eventStart;
public static bool menuChangedMusic;
public static TextureManager textureManager;
/// <summary>
/// Entry point for the mod.
@ -60,6 +79,13 @@ namespace StardewSymphonyRemastered
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave;
StardewModdingAPI.Events.MenuEvents.MenuChanged += MenuEvents_MenuChanged;
StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed;
StardewModdingAPI.Events.GameEvents.FirstUpdateTick += GameEvents_FirstUpdateTick;
musicManager = new MusicManager();
MusicPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Music");
@ -74,8 +100,71 @@ namespace StardewSymphonyRemastered
this.createBlankWAVTemplate();
musicPacksInitialized = false;
menuChangedMusic = false;
//Initialize all of the lists upon creation during entry.
SongSpecifics.initializeMenuList();
SongSpecifics.initializeEventsList();
SongSpecifics.initializeFestivalsList();
initializeMusicPacks();
}
/// <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>
/// <param name="sender"></param>
/// <param name="e"></param>
private void GameEvents_FirstUpdateTick(object sender, EventArgs e)
{
if (musicPacksInitialized == false)
{
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.initializeEventMusic();//Initialize event music that has been added to SongSpecifics.menus from all other mods during their Entry function.
//Note that locations should also be added to SongSpecifics.locations during the mod's respective Entry function.
musicPacksInitialized = true;
//musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
}
/// <summary>
/// Events to occur after the game has loaded in.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
//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.
musicManager.initializeSeasonalMusic(); //Initialize the seasonal music using all locations gathered in the location list.
}
/// <summary>
/// Choose new music when a menu is closed.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
{
if (menuChangedMusic == true)
{
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
}
/// <summary>
/// Choose new music when a menu is opened.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuEvents_MenuChanged(object sender, StardewModdingAPI.Events.EventArgsClickableMenuChanged e)
{
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
private void SaveEvents_BeforeSave(object sender, EventArgs e)
@ -88,6 +177,11 @@ namespace StardewSymphonyRemastered
*/
}
/// <summary>
/// Fires when a key is pressed to open the music selection menu.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
{
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K)
@ -104,15 +198,29 @@ namespace StardewSymphonyRemastered
/// <param name="e"></param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
{
if (Game1.currentSong != null) Game1.currentSong.Stop(AudioStopOptions.Immediate);
if (musicPacksInitialized == false)
// ModMonitor.Log("HELLO WORLD");
if (Game1.currentSong != null)
{
initializeMusicPacks();
musicPacksInitialized = true;
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
//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
}
}
/// <summary>
/// Raised when the player changes locations. This should determine the next song to play.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e)
{
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
/// <summary>
/// Load in the music packs to the music manager.
/// </summary>
@ -267,30 +375,6 @@ namespace StardewSymphonyRemastered
}
}
/// <summary>
/// Raised when the player changes locations. This should determine the next song to play.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e)
{
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
/// <summary>
/// Events to occur after the game has loaded in.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
StardewSymphonyRemastered.Framework.SongSpecifics.addLocations();
StardewSymphonyRemastered.Framework.SongSpecifics.addFestivals();
StardewSymphonyRemastered.Framework.SongSpecifics.addEvents();
musicManager.initializeSeasonalMusic();
}
/// <summary>
/// Reset the music files for the game.