Symphony now takes priority over StardewValley music. Can be changed simply by adding in a StardewValley Music Pack. Also Music Album Icons!

This commit is contained in:
2018-03-21 13:02:50 -07:00
parent fd53797c5f
commit dad514a6d6
5 changed files with 49 additions and 9 deletions

View File

@ -42,7 +42,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
}
else
{
this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 100 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List<object>
this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List<object>
{
(object)v
}

View File

@ -2,6 +2,7 @@
using StardustCore.UIUtilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -59,16 +60,24 @@ namespace StardewSymphonyRemastered.Framework
/// <returns></returns>
public static MusicPackMetaData readFromJson(string path)
{
var meta=StardewSymphony.ModHelper.ReadJsonFile<MusicPackMetaData>(path);
string json = Path.Combine(path, "MusicPackInformation.json");
var meta=StardewSymphony.ModHelper.ReadJsonFile<MusicPackMetaData>(json);
try
{
meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper, meta.pathToMusicPackIcon + ".png");
try
{
meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper, StardewSymphony.getRelativeDirectory(Path.Combine(path, meta.pathToMusicPackIcon + ".png")));
}
catch(Exception errr)
{
meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper, StardewSymphony.getRelativeDirectory(Path.Combine(path, meta.pathToMusicPackIcon)));
}
}
catch(Exception err)
{
//StardewSymphony.ModMonitor.Log(err.ToString());
}
return StardewSymphony.ModHelper.ReadJsonFile<MusicPackMetaData>(path);
return meta;
}
/// <summary>

View File

@ -45,13 +45,14 @@ namespace StardewSymphonyRemastered.Framework
this.setModDirectoryFromFullDirectory();
this.songsDirectory = Path.Combine(this.directory, "Songs");
this.songInformation = new SongSpecifics();
this.musicPackInformation = MusicPackMetaData.readFromJson(Path.Combine(directoryToMusicPack, "MusicPackInformation.json"));
this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToMusicPack);
if (this.musicPackInformation == null)
{
StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToMusicPack + ". Blank information will be put in place.", StardewModdingAPI.LogLevel.Warn);
this.musicPackInformation = new MusicPackMetaData("???", "???", "", "0.0.0","");
//StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToMusicPack + ". Blank information will be put in place.", StardewModdingAPI.LogLevel.Warn);
//this.musicPackInformation = new MusicPackMetaData("???", "???", "", "0.0.0","");
}
StardewSymphony.ModMonitor.Log(this.musicPackInformation.name.ToString());
this.loadMusicFiles();
}

View File

@ -37,7 +37,7 @@ namespace StardewSymphonyRemastered.Framework
this.setModDirectoryFromFullDirectory();
this.songInformation = new SongSpecifics();
this.currentCue = null;
this.musicPackInformation = MusicPackMetaData.readFromJson(Path.Combine(directoryToXwb, "MusicPackInformation.json"));
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);

View File

@ -105,6 +105,7 @@ 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)
{
initializeMusicPacks();
@ -299,6 +300,35 @@ namespace StardewSymphonyRemastered
Game1.soundBank = DefaultSoundBank;
}
/// <summary>
/// Used to splice the mod directory to get relative paths.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
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];
}
catch (Exception err)
{
return spliter[0];
}
}
/// <summary>
/// Used to finish cleaning up absolute asset paths into a shortened relative path.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static string getRelativeDirectory(string path)
{
string s = getShortenedDirectory(path);
return s.Remove(0, 1);
}
}
}