Mod config, log surpressing, menu/location music working, just need to polish the menu and I'll be done!

This commit is contained in:
2018-06-01 12:09:50 -07:00
parent 02d3ab39e5
commit 70885979ed
14 changed files with 241 additions and 139 deletions

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardewSymphonyRemastered
{
public class Config
{
public bool EnableDebugLog { get; set; }=false;
public int MinimumDelayBetweenSongsInMilliseconds { get; set; }=5000;
public int MaximumDelayBetweenSongsInMilliseconds { get; set; }=60000;
public string KeyBinding { get; set; }="L";
}
}

View File

@ -14,12 +14,6 @@ using StardustCore.UIUtilities.SpriteFonts.Components;
namespace StardewSymphonyRemastered.Framework.Menus
{
/*
* make buttons make sounds when clicked
* Make sound player mod?
*
*/
/// <summary>
/// Interface for the menu for selection music.
/// </summary>
@ -537,7 +531,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
Texture2DExtended springTexture = StardewSymphony.textureManager.getTexture("SpringIcon");
if (springTexture == null)
{
StardewSymphony.ModMonitor.Log("TEXTURE NULL!");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("SPRING TEXTURE NULL!");
return;
}
float scale = 1.00f / ((float)springTexture.texture.Width / 64f);
@ -550,7 +545,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
Texture2DExtended summerTexture = StardewSymphony.textureManager.getTexture("SummerIcon");
if (summerTexture == null)
{
StardewSymphony.ModMonitor.Log("TEXTURE NULL!");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("SUMMER TEXTURE NULL!");
return;
}
float scale = 1.00f / ((float)summerTexture.texture.Width / 64f);
@ -563,7 +559,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
Texture2DExtended fallTexture = StardewSymphony.textureManager.getTexture("FallIcon");
if (fallTexture == null)
{
StardewSymphony.ModMonitor.Log("TEXTURE NULL!");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("FALL TEXTURE NULL!");
return;
}
float scale = 1.00f / ((float)fallTexture.texture.Width / 64f);
@ -576,7 +573,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
Texture2DExtended winterTexture = StardewSymphony.textureManager.getTexture("WinterIcon");
if (winterTexture == null)
{
StardewSymphony.ModMonitor.Log("TEXTURE NULL!");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("WINTER TEXTURE NULL!");
return;
}
float scale = 1.00f / ((float)winterTexture.texture.Width / 64f);
@ -595,7 +593,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
this.fancyButtons.Add(new Button("FestivalIcon", new Rectangle((int)festivalPlacement.X, (int)festivalPlacement.Y, 64, 64), festivalTexture, "Festival Music", festivalSrcRect, festivalScale, new Animation(festivalSrcRect), Color.White, Color.White, new ButtonFunctionality(null, null, null)));
if (festivalTexture == null)
{
StardewSymphony.ModMonitor.Log("TEXTURE NULL!");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("FESTIVAL TEXTURE NULL!");
return;
}
@ -607,7 +606,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
if (eventTexture == null)
{
StardewSymphony.ModMonitor.Log("TEXTURE NULL!");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("EVENT TEXTURE NULL!");
return;
}
@ -619,7 +619,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
if (menuTexture == null)
{
StardewSymphony.ModMonitor.Log("TEXTURE NULL!");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("MENU TEXTURE NULL!");
return;
}
}
@ -898,35 +899,27 @@ namespace StardewSymphonyRemastered.Framework.Menus
{
if (v == null)
{
// StardewSymphony.ModMonitor.Log("v is null at count: " + count);
continue;
}
if (v.buttonFunctionality == null)
{
// StardewSymphony.ModMonitor.Log("button functionality is null at count: " + count);
continue;
}
if (v.buttonFunctionality.hover == null)
{
// StardewSymphony.ModMonitor.Log("hover is null at count: " + count);
continue;
}
if (v.buttonFunctionality.hover.paramaters == null)
{
// StardewSymphony.ModMonitor.Log("Params are null at count: " + count);
continue;
}
if (v.buttonFunctionality.hover.paramaters.Count==0)
{
//StardewSymphony.ModMonitor.Log("Params are 0 at count: " + count);
continue;
}
var pair = (KeyValuePair<string, MusicPack>)v.buttonFunctionality.hover.paramaters[0];
v.hoverText = (string)pair.Key;
//if (v.buttonFunctionality.hover != null) v.buttonFunctionality.hover.run();
//StardewSymphony.ModMonitor.Log(pair.Key);
v.onHover();
//StardewSymphony.ModMonitor.Log(pair.Key);
}
else
{
@ -953,30 +946,35 @@ namespace StardewSymphonyRemastered.Framework.Menus
if(this.currentSelectedSong!=null && this.currentMusicPackAlbum!=null && this.playButton.containsPoint(x, y))
{
Game1.playSound("coin");
playSong();
return;
}
if (this.currentSelectedSong != null && this.currentMusicPackAlbum != null && this.stopButton.containsPoint(x, y))
{
Game1.playSound("coin");
stopSong();
return;
}
if (this.currentSelectedSong != null && this.currentMusicPackAlbum != null && this.addButton.containsPoint(x, y))
{
Game1.playSound("coin");
addSong();
return;
}
if (this.currentSelectedSong != null && this.currentMusicPackAlbum != null && this.deleteButton.containsPoint(x, y))
{
Game1.playSound("coin");
deleteSong();
return;
}
if (this.backButton.containsPoint(x, y))
{
Game1.playSound("coin");
goBack();
return;
}
@ -988,6 +986,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
{
if (v.containsPoint(x, y))
{
Game1.playSound("coin");
this.selectAlbum(v);
v.onLeftClick();
}
@ -1003,10 +1002,9 @@ namespace StardewSymphonyRemastered.Framework.Menus
{
if (v.containsPoint(x, y) && v.buttonFunctionality.leftClick != null)
{
Game1.playSound("coin");
v.onLeftClick();
this.currentAlbumIndex += count - 3;
//if (this.currentAlbumIndex >= this.musicAlbumButtons.Count) this.currentAlbumIndex -= (this.musicAlbumButtons.Count);
//StardewSymphony.ModMonitor.Log(this.currentAlbumIndex.ToString());
while (currentAlbumIndex < 0)
{
this.currentAlbumIndex = (this.musicAlbumButtons.Count - (this.currentAlbumIndex * -1));
@ -1018,9 +1016,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
count++;
}
}
//this.updateFancyButtons();
this.selectAlbum(ok);
//return;
}
if (this.drawMode == DrawMode.SongSelectionMode)
@ -1058,6 +1054,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
{
if (v.containsPoint(x, y))
{
Game1.playSound("coin");
selectSong(v);
songSelected = true;
}
@ -1105,7 +1102,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
}
}
if (buttonSelected == true) this.updateFancyButtons();
if (buttonSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
}
@ -1126,7 +1127,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
}
}
if (buttonSelected == true) this.updateFancyButtons();
if (buttonSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
}
@ -1147,7 +1152,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
}
}
if (buttonSelected == true) this.updateFancyButtons();
if (buttonSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
}
@ -1195,6 +1204,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
if (songSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
@ -1244,6 +1254,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
if (songSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
@ -1292,6 +1303,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
if (songSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
@ -1340,6 +1352,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
if (songSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
@ -1361,7 +1374,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
buttonSelected = true;
}
}
if (buttonSelected == true) this.updateFancyButtons();
if (buttonSelected == true)
{
Game1.playSound("coin");
this.updateFancyButtons();
}
return;
}
@ -1916,12 +1933,6 @@ namespace StardewSymphonyRemastered.Framework.Menus
this.drawMouse(b);
}
//Button Functionality
#region
private void hello(List<object> param)
{
StardewSymphony.ModMonitor.Log("Hello");
}
public void PlayRandomSongFromSelectedMusicPack(List<object> param)
{
@ -1940,9 +1951,8 @@ namespace StardewSymphonyRemastered.Framework.Menus
{
if (b.label == "Null") return;
this.currentMusicPackAlbum = b.clone(new Vector2(this.width*.1f+64,this.height*.05f+128));
StardewSymphony.ModMonitor.Log("Album Selected!"+b.name);
this.texturedStrings.Clear();
this.texturedStrings.Add(SpriteFonts.vanillaFont.ParseString("Name:" + (string)b.name, new Microsoft.Xna.Framework.Vector2(this.width*.1f, this.height*.05f + 256), b.textColor));
this.texturedStrings.Add(SpriteFonts.vanillaFont.ParseString("Name:" + (string)b.name, new Microsoft.Xna.Framework.Vector2(this.width*.1f, this.height*.05f + 256), b.textColor,false));
this.drawMode = DrawMode.SongSelectionMode;
}
@ -1962,9 +1972,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
/// </summary>
public void playSong()
{
StardewSymphony.ModMonitor.Log("Song Selected!" + this.currentSelectedSong.name);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Song Selected!" + this.currentSelectedSong.name);
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
StardewSymphony.ModMonitor.Log("Select Pack:" + info.Key);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Select Pack:" + info.Key);
StardewSymphony.musicManager.swapMusicPacks(info.Key);
StardewSymphony.musicManager.playSongFromCurrentPack(this.currentSelectedSong.name);
}
@ -1974,9 +1986,11 @@ namespace StardewSymphonyRemastered.Framework.Menus
/// </summary>
public void stopSong()
{
StardewSymphony.ModMonitor.Log("Song Selected!" + this.currentSelectedSong.name);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Song Selected!" + this.currentSelectedSong.name);
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
StardewSymphony.ModMonitor.Log("Select Pack:" + info.Key);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Select Pack:" + info.Key);
StardewSymphony.musicManager.swapMusicPacks(info.Key);
StardewSymphony.musicManager.stopSongFromCurrentMusicPack();
}
@ -2027,12 +2041,15 @@ namespace StardewSymphonyRemastered.Framework.Menus
string seperator = "_";
//Seasonal selection region
#region
if (this.currentlySelectedOption.name == "SeasonIcon")
if (this.currentlySelectedOption !=null)
{
if (Game1.currentSeason == "spring") key += "spring";
if (Game1.currentSeason == "summer") key += "summer";
if (Game1.currentSeason == "fall") key += "fall";
if (Game1.currentSeason == "winter") key += "winter";
if (this.currentlySelectedOption.name == "SeasonIcon")
{
if (Game1.currentSeason == "spring") key += "spring";
if (Game1.currentSeason == "summer") key += "summer";
if (Game1.currentSeason == "fall") key += "fall";
if (Game1.currentSeason == "winter") key += "winter";
}
}
if (this.currentlySelectedWeather != null)
{
@ -2065,6 +2082,13 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
#endregion
if (this.currentlySelectedMenu != null)
{
return this.currentlySelectedMenu.label;
}
if (this.currentlySelectedFestival != null) return this.currentlySelectedFestival.label;
if (this.currentlySelectedEvent != null) return this.currentlySelectedEvent.label;
return key;
}
@ -2163,6 +2187,5 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
#endregion
}
}

View File

@ -57,7 +57,8 @@ namespace StardewSymphonyRemastered.Framework
}
else
{
StardewSymphony.ModMonitor.Log("ERROR: Music Pack " + nameOfNewMusicPack + " isn't valid for some reason.", StardewModdingAPI.LogLevel.Alert);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("ERROR: Music Pack " + nameOfNewMusicPack + " isn't valid for some reason.", StardewModdingAPI.LogLevel.Alert);
}
}
@ -153,7 +154,8 @@ namespace StardewSymphonyRemastered.Framework
{
if (isMusicPackValid(name) == false)
{
StardewSymphony.ModMonitor.Log("Error, the music pack: " + name + " is not found. Please make sure it is loaded in and try again.");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Error, the music pack: " + name + " is not found. Please make sure it is loaded in and try again.");
return null;
}
else
@ -266,12 +268,14 @@ namespace StardewSymphonyRemastered.Framework
}
}
if (subKey == "") break;
StardewSymphony.ModMonitor.Log(subKey,StardewModdingAPI.LogLevel.Alert);
if (StardewSymphony.Config.EnableDebugLog)
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 + ". 1 Are you sure you did this properly?");
if (StardewSymphony.Config.EnableDebugLog)
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;
}
}
@ -297,7 +301,8 @@ namespace StardewSymphonyRemastered.Framework
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?");
if (StardewSymphony.Config.EnableDebugLog)
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;
}
@ -307,7 +312,8 @@ 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 + ".3 Are you sure you did this properly?");
if (StardewSymphony.Config.EnableDebugLog)
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.
@ -332,7 +338,8 @@ 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 + ".4 Are you sure you did this properly?");
if (StardewSymphony.Config.EnableDebugLog)
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;
}
}
@ -347,7 +354,8 @@ namespace StardewSymphonyRemastered.Framework
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?");
if (StardewSymphony.Config.EnableDebugLog)
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;
}
@ -361,7 +369,8 @@ namespace StardewSymphonyRemastered.Framework
//If I am trying to play a generic song and a non-generic song is playing, then play my generic song since I don't want to play the specific music anymore.
if (sizeList.Length < 3 && (this.currentMusicPack.isPlaying() && this.lastSongWasLocationSpecific==false))
{
StardewSymphony.ModMonitor.Log("Non specific music change detected. Not going to change the music this time");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Non specific music change detected. Not going to change the music this time");
return;
}
}
@ -415,8 +424,10 @@ namespace StardewSymphonyRemastered.Framework
}
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.");
if (StardewSymphony.Config.EnableDebugLog)
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?");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Also failed playing a festival event song.");
StardewSymphony.menuChangedMusic = false;
return false;
}
@ -444,8 +455,10 @@ namespace StardewSymphonyRemastered.Framework
}
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.");
if (StardewSymphony.Config.EnableDebugLog)
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?");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Also failed playing a generalized event song.");
StardewSymphony.menuChangedMusic = false;
return false;
}
@ -464,32 +477,28 @@ namespace StardewSymphonyRemastered.Framework
{
if (displayLogInformation == true)
{
StardewSymphony.ModMonitor.Log("Adding a new music pack!");
if (StardewSymphony.Config.EnableDebugLog)
{
StardewSymphony.ModMonitor.Log("Adding a new music pack!");
StardewSymphony.ModMonitor.Log(" Location:" + musicPack.shortenedDirectory);
StardewSymphony.ModMonitor.Log(" Name:" + musicPack.musicPackInformation.name);
StardewSymphony.ModMonitor.Log(" Author:" + musicPack.musicPackInformation.author);
StardewSymphony.ModMonitor.Log(" Description:" + musicPack.musicPackInformation.description);
StardewSymphony.ModMonitor.Log(" Version Info:" + musicPack.musicPackInformation.versionInfo);
StardewSymphony.ModMonitor.Log(" Song List:");
StardewSymphony.ModMonitor.Log(" Location:" + musicPack.shortenedDirectory);
StardewSymphony.ModMonitor.Log(" Name:" + musicPack.musicPackInformation.name);
StardewSymphony.ModMonitor.Log(" Author:" + musicPack.musicPackInformation.author);
StardewSymphony.ModMonitor.Log(" Description:" + musicPack.musicPackInformation.description);
StardewSymphony.ModMonitor.Log(" Version Info:" + musicPack.musicPackInformation.versionInfo);
StardewSymphony.ModMonitor.Log(" Song List:");
}
if (displaySongs == true)
{
foreach(var song in musicPack.songInformation.listOfSongsWithoutTriggers)
{
StardewSymphony.ModMonitor.Log(" " + song.name);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log(" " + song.name);
}
}
}
/*
if(musicPack.GetType()==typeof(WavMusicPack)){
foreach (var song in musicPack.songInformation.listOfSongsWithoutTriggers)
{
(musicPack as WavMusicPack).LoadWavFromFileToStream(song.pathToSong);
}
}
*/
this.musicPacks.Add(musicPack.musicPackInformation.name,musicPack);
}

View File

@ -75,7 +75,8 @@ namespace StardewSymphonyRemastered.Framework
/// </summary>
public virtual void writeToJson()
{
StardewSymphony.ModMonitor.Log("Loading in music for this pack:"+this.musicPackInformation.name+". Please wait.");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Saving music for this pack:"+this.musicPackInformation.name+". Please wait.");
string data = Path.Combine(this.directory, "data");
if (!Directory.Exists(data))
{
@ -84,6 +85,8 @@ namespace StardewSymphonyRemastered.Framework
foreach (var list in this.songInformation.listOfSongsWithTriggers)
{
if (list.Value.Count == 0) continue;
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Saving music: " + list.Key + ". Please wait.");
SongListNode node = new SongListNode(list.Key, list.Value);
node.WriteToJson(Path.Combine(data, node.trigger+".json"));
}
@ -94,7 +97,8 @@ namespace StardewSymphonyRemastered.Framework
/// </summary>
public virtual void readFromJson()
{
StardewSymphony.ModMonitor.Log("Saving music for this pack:" + this.musicPackInformation.name + ". Please wait as this will take quite soem time.");
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Loading music for this pack:" + this.musicPackInformation.name + ". Please wait as this will take quite some time.");
string data = Path.Combine(this.directory, "data");
if (!Directory.Exists(data))
{
@ -107,7 +111,14 @@ namespace StardewSymphonyRemastered.Framework
var pair = this.songInformation.getSongList(node.trigger+".json");
foreach (var v in node.songList)
{
this.songInformation.addSongToTriggerList(node.trigger, v.name);
try
{
this.songInformation.addSongToTriggerList(node.trigger, v.name);
}
catch(Exception err)
{
}
}
}

View File

@ -42,7 +42,8 @@ namespace StardewSymphonyRemastered.Framework
catch(Exception err)
{
this.Icon = null;
StardewSymphony.ModMonitor.Log(err.ToString());
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log(err.ToString());
}
}
/// <summary>
@ -77,7 +78,8 @@ namespace StardewSymphonyRemastered.Framework
catch(Exception err)
{
err.ToString();
//StardewSymphony.ModMonitor.Log(err.ToString());
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log(err.ToString());
}
return meta;
}

View File

@ -15,7 +15,7 @@ namespace StardewSymphonyRemastered.Framework
/// <summary>
/// The path to the song. In the case of XACT songs this points to the .xwb file. For WAV files this points directly to the WAV file itself.
/// </summary>
public string pathToSong;
private string pathToSong;
/// <summary>
/// The name of the song itself.
@ -25,7 +25,7 @@ namespace StardewSymphonyRemastered.Framework
/// <summary>
/// The relative path to the song.
/// </summary>
public string relativePath;
private string relativePath;
/// <summary>
/// Blank Constructor;
@ -116,5 +116,14 @@ namespace StardewSymphonyRemastered.Framework
StardewSymphony.ModHelper.WriteJsonFile<Song>(path, this);
}
public string getRelativePath()
{
return this.relativePath;
}
public string getPathToSong()
{
return this.pathToSong;
}
}
}

View File

@ -158,7 +158,8 @@ namespace StardewSymphonyRemastered.Framework
foreach (var v in Game1.locations)
{
locations.Add(v.Name);
StardewSymphony.ModMonitor.Log("Adding in song triggers for location: " + v.Name);
if (StardewSymphony.Config.EnableDebugLog)
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.
@ -168,12 +169,14 @@ namespace StardewSymphonyRemastered.Framework
foreach(var building in farm.buildings)
{
locations.Add(building.nameOfIndoors);
StardewSymphony.ModMonitor.Log("Adding in song triggers for location: " + building.nameOfIndoors);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Adding in song triggers for location: " + building.nameOfIndoors);
}
}
catch(Exception err)
{
StardewSymphony.ModMonitor.Log(err.ToString());
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log(err.ToString());
}
}
@ -428,7 +431,7 @@ namespace StardewSymphonyRemastered.Framework
}
catch(Exception err)
{
err.ToString();
//err.ToString();
}
}
}
@ -569,7 +572,8 @@ namespace StardewSymphonyRemastered.Framework
var song = getSongFromList(listOfSongsWithoutTriggers, songName); //Get the song from the master song pool
if (song == null)
{
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is "+ songName);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is "+ songName);
return;
}
songKeyPair.Value.Add(song); //add the song from master pool to the trigger list
@ -583,7 +587,8 @@ namespace StardewSymphonyRemastered.Framework
var song = getSongFromList(listOfSongsWithoutTriggers, songName); //Get the song from the master song pool
if (song == null)
{
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is " + songName);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is " + songName);
return;
}
songKeyPair.Add(song); //add the song from master pool to the trigger list
@ -597,7 +602,8 @@ namespace StardewSymphonyRemastered.Framework
var song = getSongFromList(listOfSongsWithoutTriggers, songName); //Get the song from the master song pool
if (song == null)
{
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is " + songName);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is " + songName);
return;
}
songKeyPair.Add(song); //add the song from master pool to the trigger list

View File

@ -244,7 +244,7 @@ namespace StardewSymphonyRemastered.Framework
{
foreach(var song in this.songInformation.listOfSongsWithoutTriggers)
{
if (song.pathToSong == path) return song.name;
if (song.getPathToSong()== path) return song.name;
}
return "";
}
@ -258,7 +258,7 @@ namespace StardewSymphonyRemastered.Framework
{
foreach (var song in this.songInformation.listOfSongsWithoutTriggers)
{
if (song.name == name) return song.pathToSong;
if (song.name == name) return song.getPathToSong();
}
return "";
}

View File

@ -40,7 +40,8 @@ namespace StardewSymphonyRemastered.Framework
this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToXwb);
if (this.musicPackInformation == null)
{
StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToXwb + ". Blank information will be put in place.",StardewModdingAPI.LogLevel.Warn);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToXwb + ". Blank information will be put in place.",StardewModdingAPI.LogLevel.Warn);
this.musicPackInformation = new MusicPackMetaData("???","???","","0.0.0","");
}
@ -84,7 +85,8 @@ namespace StardewSymphonyRemastered.Framework
private Cue getCue(string name) {
if (this.songInformation.isSongInList(name) == false)
{
StardewSymphony.ModMonitor.Log("Error! The song " + name + " could not be found in music pack " + this.musicPackInformation.name+". Please ensure that this song is part of this music pack located at: "+ this.WaveBankPath+ " or contact the music pack author: "+this.musicPackInformation.author,StardewModdingAPI.LogLevel.Error);
if (StardewSymphony.Config.EnableDebugLog)
StardewSymphony.ModMonitor.Log("Error! The song " + name + " could not be found in music pack " + this.musicPackInformation.name+". Please ensure that this song is part of this music pack located at: "+ this.WaveBankPath+ " or contact the music pack author: "+this.musicPackInformation.author,StardewModdingAPI.LogLevel.Error);
return null;
}
else

View File

@ -56,6 +56,8 @@ namespace StardewSymphonyRemastered
public static bool menuChangedMusic;
public static Config Config;
public static TextureManager textureManager;
@ -65,6 +67,7 @@ namespace StardewSymphonyRemastered
/// <param name="helper"></param>
public override void Entry(IModHelper helper)
{
Config = helper.ReadConfig<Config>();
DefaultSoundBank = Game1.soundBank;
DefaultWaveBank = Game1.waveBank;
ModHelper = helper;
@ -153,6 +156,12 @@ namespace StardewSymphonyRemastered
musicManager.initializeFestivalMusic();
musicManager.initializeEventMusic();
foreach (var musicPack in musicManager.musicPacks)
{
musicPack.Value.readFromJson();
}
musicManager.selectMusic(SongSpecifics.getCurrentConditionalString());
}
@ -181,12 +190,12 @@ namespace StardewSymphonyRemastered
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)
{
musicPack.Value.writeToJson();
}
*/
}
/// <summary>
@ -196,7 +205,7 @@ namespace StardewSymphonyRemastered
/// <param name="e"></param>
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
{
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K)
if (e.KeyPressed.ToString() == Config.KeyBinding)
{
Game1.activeClickableMenu = new Framework.Menus.MusicManagerMenu(Game1.viewport.Width,Game1.viewport.Height);
}
@ -210,7 +219,6 @@ namespace StardewSymphonyRemastered
/// <param name="e"></param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
{
// ModMonitor.Log("HELLO WORLD");
if (Game1.currentSong != null)
{
//ModMonitor.Log("STOP THE MUSIC!!!");
@ -221,10 +229,6 @@ namespace StardewSymphonyRemastered
}
/// <summary>
/// Load in the music packs to the music manager.
/// </summary>
@ -261,7 +265,6 @@ namespace StardewSymphonyRemastered
string dayIcon = Path.Combine(path, "TimeIcon_Day.png");
string nightIcon = Path.Combine(path, "TimeIcon_Night.png");
//Fun Icons
string eventIcon = Path.Combine(path, "EventIcon.png");
string festivalIcon = Path.Combine(path, "FestivalIcon.png");
@ -277,15 +280,12 @@ namespace StardewSymphonyRemastered
string stormIcon = Path.Combine(path, "WeatherIcon_Stormy.png");
string weddingIcon = Path.Combine(path, "WeatherIcon_WeddingHeart.png");
//Season Icons
string springIcon = Path.Combine(path, "SeasonIcon_Spring.png");
string summerIcon = Path.Combine(path, "SeasonIcon_Summer.png");
string fallIcon = Path.Combine(path, "SeasonIcon_Fall.png");
string winterIcon = Path.Combine(path, "SeasonIcon_Winter.png");
//Day Icons
string mondayIcon = Path.Combine(path, "DayIcons_Monday.png");
string tuesdayIcon = Path.Combine(path, "DayIcons_Tuesday.png");
@ -296,15 +296,10 @@ namespace StardewSymphonyRemastered
string sundayIcon = Path.Combine(path, "DayIcons_Sunday.png");
string houseIcon = Path.Combine(path, "HouseIcon.png");
string playButton = Path.Combine(path, "PlayButton.png");
string stopButton = Path.Combine(path, "StopButton.png");
string backButton = Path.Combine(path, "BackButton.png");
textureManager.addTexture("MusicNote",new Texture2DExtended(ModHelper,StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicNote)));
textureManager.addTexture("MusicDisk", new Texture2DExtended(ModHelper, StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicCD)));
textureManager.addTexture("MusicCD", new Texture2DExtended(ModHelper, StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicCD)));
@ -405,7 +400,7 @@ namespace StardewSymphonyRemastered
/// <summary>
/// Load in the XACT music packs.
/// </summary>
public static void loadXACTMusicPacks()
public void loadXACTMusicPacks()
{
string[] listOfDirectories= Directory.GetDirectories(XACTMusicDirectory);
foreach(string folder in listOfDirectories)
@ -417,23 +412,27 @@ namespace StardewSymphonyRemastered
string[] debug = Directory.GetFiles(folder);
if (xwb.Length == 0)
{
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There is no wave bank music file: .xwb located in this directory. AKA there is no valid music here.", LogLevel.Error);
if(Config.EnableDebugLog)
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There is no wave bank music file: .xwb located in this directory. AKA there is no valid music here.", LogLevel.Error);
return;
}
if (xwb.Length >= 2)
{
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There are too many wave bank music files or .xwbs located in this directory. Please ensure that there is only one music pack in this folder. You can make another music pack but putting a wave bank file in a different folder.", LogLevel.Error);
if (Config.EnableDebugLog)
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There are too many wave bank music files or .xwbs located in this directory. Please ensure that there is only one music pack in this folder. You can make another music pack but putting a wave bank file in a different folder.", LogLevel.Error);
return;
}
if (xsb.Length == 0)
{
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There is no sound bank music file: .xsb located in this directory. AKA there is no valid music here.", LogLevel.Error);
if (Config.EnableDebugLog)
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There is no sound bank music file: .xsb located in this directory. AKA there is no valid music here.", LogLevel.Error);
return;
}
if (xsb.Length >= 2)
{
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There are too many sound bank music files or .xsbs located in this directory. Please ensure that there is only one sound reference file in this folder. You can make another music pack but putting a sound file in a different folder.", LogLevel.Error);
if (Config.EnableDebugLog)
ModMonitor.Log("Error loading in attempting to load music pack from: " + folder + ". There are too many sound bank music files or .xsbs located in this directory. Please ensure that there is only one sound reference file in this folder. You can make another music pack but putting a sound file in a different folder.", LogLevel.Error);
return;
}
@ -443,12 +442,17 @@ namespace StardewSymphonyRemastered
if (!File.Exists(metaData))
{
ModMonitor.Log("WARNING! Loading in a music pack from: " + folder + ". There is no MusicPackInformation.json associated with this music pack meaning that while songs can be played from this pack, no information about it will be displayed.", LogLevel.Error);
if (Config.EnableDebugLog)
ModMonitor.Log("WARNING! Loading in a music pack from: " + folder + ". There is no MusicPackInformation.json associated with this music pack meaning that while songs can be played from this pack, no information about it will be displayed.", LogLevel.Error);
}
StardewSymphonyRemastered.Framework.XACTMusicPack musicPack = new XACTMusicPack(folder, waveBank,soundBank);
musicPack.songInformation.initializeMenuMusic();
musicPack.readFromJson();
musicManager.addMusicPack(musicPack,true,true);
musicPack.readFromJson();
}
}
@ -456,7 +460,7 @@ namespace StardewSymphonyRemastered
/// <summary>
/// Load in WAV music packs.
/// </summary>
public static void loadWAVMusicPacks()
public void loadWAVMusicPacks()
{
string[] listOfDirectories = Directory.GetDirectories(WavMusicDirectory);
foreach (string folder in listOfDirectories)
@ -465,13 +469,17 @@ namespace StardewSymphonyRemastered
if (!File.Exists(metaData))
{
ModMonitor.Log("WARNING! Loading in a music pack from: " + folder + ". There is no MusicPackInformation.json associated with this music pack meaning that while songs can be played from this pack, no information about it will be displayed.", LogLevel.Error);
if (Config.EnableDebugLog)
ModMonitor.Log("WARNING! Loading in a music pack from: " + folder + ". There is no MusicPackInformation.json associated with this music pack meaning that while songs can be played from this pack, no information about it will be displayed.", LogLevel.Error);
}
StardewSymphonyRemastered.Framework.WavMusicPack musicPack = new WavMusicPack(folder);
musicManager.addMusicPack(musicPack,true,true);
musicPack.songInformation.initializeMenuMusic();
musicPack.readFromJson();
musicManager.addMusicPack(musicPack,true,true);
}
}

View File

@ -68,7 +68,8 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="StardustCore">
<Reference Include="StardustCore, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\StardustCore\bin\Release\StardustCore.dll</HintPath>
</Reference>
<Reference Include="System" />
@ -81,6 +82,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Framework\Menus\MusicManagerMenu.cs" />
<Compile Include="Framework\Music\MusicPackMetaData.cs" />
<Compile Include="Framework\Music\Song.cs" />

View File

@ -8,7 +8,12 @@ namespace StardewSymphonyRemastered
{
public static class StaticExtentions
{
/// <summary>
/// Checks if a given object is null.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/// <returns></returns>
public static bool isNull<T>(this T obj)
{
if (obj == null) return true;

View File

@ -14,18 +14,18 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
public Vector2 position;
public string label;
public TexturedString(string Label,Vector2 Position,List<TexturedCharacter> Characters)
public TexturedString(string Label, Vector2 Position, List<TexturedCharacter> Characters, bool useRightPadding = true)
{
this.label = Label;
this.characters = Characters;
this.position = Position;
setCharacterPositions();
setCharacterPositions(useRightPadding);
}
/// <summary>
/// Sets the character positions relative to the string's position on screen.
/// </summary>
public void setCharacterPositions()
public void setCharacterPositions(bool useRightPadding=true)
{
int index = 0;
TexturedCharacter lastSeenChar=new TexturedCharacter();
@ -37,7 +37,14 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
}
else
{
c.position = new Vector2(this.position.X + c.spacing.LeftPadding + lastSeenChar.spacing.RightPadding+lastSeenChar.texture.Width*index, this.position.Y);
if (useRightPadding)
{
c.position = new Vector2(this.position.X + c.spacing.LeftPadding + lastSeenChar.spacing.RightPadding + lastSeenChar.texture.Width * index, this.position.Y);
}
else
{
c.position = new Vector2(this.position.X + c.spacing.LeftPadding + lastSeenChar.texture.Width * index, this.position.Y);
}
}
//StardustCore.ModCore.ModMonitor.Log(c.character.ToString());
//StardustCore.ModCore.ModMonitor.Log(c.position.ToString());
@ -50,23 +57,23 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
/// Adds a textured character to a textured string.
/// </summary>
/// <param name="ch"></param>
public void addCharacterToEnd(TexturedCharacter ch)
public void addCharacterToEnd(TexturedCharacter ch, bool useRightPadding = true)
{
this.characters.Add(ch);
this.setCharacterPositions();
this.setCharacterPositions(useRightPadding);
}
/// <summary>
/// Adds a list of textured characters to a textured string.
/// </summary>
/// <param name="chList"></param>
public void addCharactersToEnd(List<TexturedCharacter> chList)
public void addCharactersToEnd(List<TexturedCharacter> chList, bool useRightPadding=true)
{
foreach(var ch in chList)
{
this.characters.Add(ch);
}
this.setCharacterPositions();
this.setCharacterPositions(useRightPadding);
}
/// <summary>
@ -76,11 +83,11 @@ namespace StardustCore.UIUtilities.SpriteFonts.Components
/// <param name="second"></param>
/// <param name="NewPosition"></param>
/// <returns></returns>
public TexturedString addStrings(TexturedString first,TexturedString second,Vector2 NewPosition)
public TexturedString addStrings(TexturedString first, TexturedString second, Vector2 NewPosition, bool useRightPadding = true)
{
var newString = first + second;
newString.position = NewPosition;
newString.setCharacterPositions();
newString.setCharacterPositions(useRightPadding);
return newString;
}

View File

@ -62,7 +62,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
/// <param name="Position"></param>
/// <param name="stringColor"></param>
/// <returns></returns>
public TexturedString ParseString(string str, Vector2 Position, Color stringColor)
public TexturedString ParseString(string str, Vector2 Position, Color stringColor, bool useRightPadding = true)
{
List<TexturedCharacter> characters = new List<TexturedCharacter>();
foreach (var chr in str)
@ -71,7 +71,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
c.drawColor = stringColor;
characters.Add(c);
}
var tStr = new TexturedString(str,Position, characters);
var tStr = new TexturedString(str,Position, characters,useRightPadding);
return tStr;
}
@ -83,7 +83,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
/// <param name="Position">The position to draw the textured string.</param>
/// <param name="stringColor">The color of the textured string.</param>
/// <returns></returns>
public TexturedString ParseString(string label,string str, Vector2 Position, Color stringColor)
public TexturedString ParseString(string label,string str, Vector2 Position, Color stringColor, bool useRightPadding = true)
{
List<TexturedCharacter> characters = new List<TexturedCharacter>();
foreach (var chr in str)
@ -92,7 +92,7 @@ namespace StardustCore.UIUtilities.SpriteFonts.Fonts
c.drawColor = stringColor;
characters.Add(c);
}
var tStr = new TexturedString(label, Position, characters);
var tStr = new TexturedString(label, Position, characters,false);
return tStr;
}