drop support for XACT music packs per discussion
This commit is contained in:
parent
d0a81165e4
commit
4a427b7f5e
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"name": "Omegas's Music Data Example",
|
||||
"author": "Omegasis",
|
||||
"description": "Just a simple example of how metadata is formated for music packs. Feel free to copy and edit this one!",
|
||||
"versionInfo": "1.0.0 CoolExample",
|
||||
"pathToMusicPackIcon": "Icon.png",
|
||||
"Icon": null
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
Place the Wave Bank.xwb file and Sound Bank.xsb file you created in XACT in a similar directory in Content/Music/XACT/SoundPackName.
|
||||
Modify MusicPackInformation.json as desire!
|
||||
Run the mod!
|
|
@ -1,152 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
public class MusicHexProcessor
|
||||
{
|
||||
/*********
|
||||
** Public methods
|
||||
*********/
|
||||
/// <summary>Process the soundbank.swb file's hex info and extract the song names from it.</summary>
|
||||
public static List<string> ProcessSongNamesFromHex(XACTMusicPack musicPack, Action reset, string FileName)
|
||||
{
|
||||
List<string> cleanCueNames = new List<string>();
|
||||
byte[] array = File.ReadAllBytes(FileName);
|
||||
string rawName = FileName.Substring(0, FileName.Length - 4);
|
||||
|
||||
string hexDumpContents = HexDump(array);
|
||||
|
||||
string rawHexName = rawName + "HexDump.txt";
|
||||
File.WriteAllText(rawHexName, hexDumpContents);
|
||||
|
||||
string[] readText = File.ReadAllLines(rawHexName);
|
||||
string largeString = "";
|
||||
foreach (string line in readText)
|
||||
{
|
||||
try
|
||||
{
|
||||
string newString = "";
|
||||
for (int i = 62; i <= 77; i++)
|
||||
newString += line[i];
|
||||
largeString += newString;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
string[] splits = largeString.Split('ÿ');
|
||||
string fix = "";
|
||||
foreach (string s in splits)
|
||||
{
|
||||
if (s == "")
|
||||
continue;
|
||||
fix += s;
|
||||
}
|
||||
splits = fix.Split('.');
|
||||
|
||||
foreach (string split in splits)
|
||||
{
|
||||
if (split == "")
|
||||
continue;
|
||||
try
|
||||
{
|
||||
Game1.waveBank = musicPack.WaveBank;
|
||||
Game1.soundBank = musicPack.SoundBank;
|
||||
|
||||
if (Game1.soundBank.GetCue(split) != null)
|
||||
cleanCueNames.Add(split);
|
||||
|
||||
reset.Invoke();
|
||||
}
|
||||
catch
|
||||
{
|
||||
reset.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
return cleanCueNames;
|
||||
}
|
||||
|
||||
|
||||
/*********
|
||||
** Private methods
|
||||
*********/
|
||||
private static string HexDump(byte[] bytes, int bytesPerLine = 16)
|
||||
{
|
||||
if (bytes == null)
|
||||
return "<null>";
|
||||
|
||||
int bytesLength = bytes.Length;
|
||||
|
||||
char[] hexChars = "0123456789ABCDEF".ToCharArray();
|
||||
|
||||
int firstHexColumn =
|
||||
8 // 8 characters for the address
|
||||
+ 3; // 3 spaces
|
||||
|
||||
int firstCharColumn = firstHexColumn
|
||||
+ bytesPerLine * 3 // - 2 digit for the hexadecimal value and 1 space
|
||||
+ (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th
|
||||
+ 2; // 2 spaces
|
||||
|
||||
int lineLength = firstCharColumn
|
||||
+ bytesPerLine // - characters to show the ascii value
|
||||
+ Environment.NewLine.Length; // Carriage return and line feed (should normally be 2)
|
||||
|
||||
char[] line = (new string(' ', lineLength - 2) + Environment.NewLine).ToCharArray();
|
||||
int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine;
|
||||
StringBuilder result = new StringBuilder(expectedLines * lineLength);
|
||||
|
||||
for (int i = 0; i < bytesLength; i += bytesPerLine)
|
||||
{
|
||||
line[0] = hexChars[(i >> 28) & 0xF];
|
||||
line[1] = hexChars[(i >> 24) & 0xF];
|
||||
line[2] = hexChars[(i >> 20) & 0xF];
|
||||
line[3] = hexChars[(i >> 16) & 0xF];
|
||||
line[4] = hexChars[(i >> 12) & 0xF];
|
||||
line[5] = hexChars[(i >> 8) & 0xF];
|
||||
line[6] = hexChars[(i >> 4) & 0xF];
|
||||
line[7] = hexChars[(i >> 0) & 0xF];
|
||||
|
||||
int hexColumn = firstHexColumn;
|
||||
int charColumn = firstCharColumn;
|
||||
|
||||
for (int j = 0; j < bytesPerLine; j++)
|
||||
{
|
||||
if (j > 0 && (j & 7) == 0) hexColumn++;
|
||||
if (i + j >= bytesLength)
|
||||
{
|
||||
line[hexColumn] = ' ';
|
||||
line[hexColumn + 1] = ' ';
|
||||
line[charColumn] = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
byte b = bytes[i + j];
|
||||
line[hexColumn] = hexChars[(b >> 4) & 0xF];
|
||||
line[hexColumn + 1] = hexChars[b & 0xF];
|
||||
line[charColumn] = GetAsciiSymbol(b);
|
||||
}
|
||||
hexColumn += 3;
|
||||
charColumn++;
|
||||
}
|
||||
result.Append(line);
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
public static char GetAsciiSymbol(byte ch)
|
||||
{
|
||||
if (ch < 32) return '.'; // Non-printable ASCII
|
||||
if (ch < 127) return (char)ch; // Normal ASCII
|
||||
// Handle the hole in Latin-1
|
||||
if (ch == 127) return '.';
|
||||
if (ch < 0x90) return "€.‚ƒ„…†‡ˆ‰Š‹Œ.Ž."[ch & 0xF];
|
||||
if (ch < 0xA0) return ".‘’“”•–—˜™š›œ.žŸ"[ch & 0xF];
|
||||
if (ch == 0xAD) return '.'; // Soft hyphen: this symbol is zero-width even in monospace fonts
|
||||
return (char)ch; // Normal Latin-1
|
||||
}
|
||||
}
|
||||
}
|
|
@ -408,13 +408,6 @@ namespace StardewSymphonyRemastered.Framework
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Checks if the song exists at all in this music pack.</summary>
|
||||
public bool isSongInList(string songName)
|
||||
{
|
||||
Song song = this.getSongFromList(this.listOfSongsWithoutTriggers, songName);
|
||||
return song != null && this.listOfSongsWithoutTriggers.Contains(song);
|
||||
}
|
||||
|
||||
/// <summary>A pretty big function to add in all of the specific songs that play at certain locations_seasons_weather_dayOfWeek_times. </summary>
|
||||
public void initializeSeasonalMusic()
|
||||
{
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
/// <summary>TODO: Make this work and add in overrided functions.</summary>
|
||||
public class XACTMusicPack : MusicPack
|
||||
{
|
||||
public WaveBank WaveBank;
|
||||
public ISoundBank SoundBank;
|
||||
|
||||
public Cue currentCue;
|
||||
|
||||
public string WaveBankPath;
|
||||
public string SoundBankPath;
|
||||
|
||||
/// <summary>Construct an instance.</summary>
|
||||
public XACTMusicPack(string directoryToXwb, string pathToWaveBank, string pathToSoundBank)
|
||||
{
|
||||
this.directory = directoryToXwb;
|
||||
this.WaveBankPath = pathToWaveBank;
|
||||
this.SoundBankPath = pathToSoundBank;
|
||||
this.songInformation = new SongSpecifics();
|
||||
this.currentCue = null;
|
||||
this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToXwb);
|
||||
if (this.musicPackInformation == null)
|
||||
{
|
||||
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", "");
|
||||
}
|
||||
|
||||
this.WaveBank = new WaveBank(Game1.audioEngine, this.WaveBankPath);
|
||||
this.SoundBank = new SoundBankWrapper(new SoundBank(Game1.audioEngine, this.SoundBankPath));
|
||||
this.loadMusicFiles();
|
||||
}
|
||||
|
||||
/// <summary>Load all of the generic music file names into the music pack's information.</summary>
|
||||
private void loadMusicFiles()
|
||||
{
|
||||
var listOfSongStrings = MusicHexProcessor.ProcessSongNamesFromHex(this, StardewSymphony.Reset, this.SoundBankPath);
|
||||
|
||||
List<Song> listofSongs = new List<Song>();
|
||||
foreach (string songname in listOfSongStrings)
|
||||
{
|
||||
Song song = new Song(songname);
|
||||
listofSongs.Add(song);
|
||||
}
|
||||
|
||||
this.songInformation.listOfSongsWithoutTriggers = listofSongs;
|
||||
}
|
||||
|
||||
/// <summary>Get the cue from the list of songs.</summary>
|
||||
/// <param name="name">The name of the song to get.</param>
|
||||
private Cue getCue(string name)
|
||||
{
|
||||
if (!this.songInformation.isSongInList(name))
|
||||
{
|
||||
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
|
||||
{
|
||||
return this.SoundBank.GetCue(name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Play a song.</summary>
|
||||
/// <param name="name">The name of the song to play.</param>
|
||||
public override void playSong(string name)
|
||||
{
|
||||
this.currentCue = this.getCue(name);
|
||||
if (this.currentCue == null)
|
||||
return; //getCue will throw the error message.
|
||||
|
||||
Game1.waveBank = this.WaveBank;
|
||||
Game1.soundBank = this.SoundBank;
|
||||
this.currentCue.Play();
|
||||
StardewSymphony.Reset();
|
||||
}
|
||||
|
||||
/// <summary>Stops the currently playing song and nulls the current song.</summary>
|
||||
public override void stopSong()
|
||||
{
|
||||
Game1.currentSong?.Stop(AudioStopOptions.Immediate);
|
||||
if (this.currentCue != null)
|
||||
{
|
||||
Game1.waveBank = this.WaveBank;
|
||||
Game1.soundBank = this.SoundBank;
|
||||
this.currentCue.Stop(AudioStopOptions.Immediate);
|
||||
StardewSymphony.Reset();
|
||||
this.currentCue = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isPlaying()
|
||||
{
|
||||
if (this.currentCue == null) return false;
|
||||
return this.currentCue.IsPlaying;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,6 @@ namespace StardewSymphonyRemastered
|
|||
|
||||
private string MusicPath;
|
||||
public static string WavMusicDirectory;
|
||||
public static string XACTMusicDirectory;
|
||||
public static string TemplateMusicDirectory;
|
||||
|
||||
public bool musicPacksInitialized;
|
||||
|
@ -76,13 +75,11 @@ namespace StardewSymphonyRemastered
|
|||
|
||||
this.MusicPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Music");
|
||||
WavMusicDirectory = Path.Combine(this.MusicPath, "Wav");
|
||||
XACTMusicDirectory = Path.Combine(this.MusicPath, "XACT");
|
||||
TemplateMusicDirectory = Path.Combine(this.MusicPath, "Templates");
|
||||
|
||||
|
||||
textureManager = new TextureManager();
|
||||
this.createDirectories();
|
||||
this.createBlankXACTTemplate();
|
||||
this.createBlankWAVTemplate();
|
||||
|
||||
this.musicPacksInitialized = false;
|
||||
|
@ -219,7 +216,6 @@ namespace StardewSymphonyRemastered
|
|||
public void initializeMusicPacks()
|
||||
{
|
||||
//load in all packs here.
|
||||
this.loadXACTMusicPacks();
|
||||
this.loadWAVMusicPacks();
|
||||
}
|
||||
|
||||
|
@ -324,42 +320,17 @@ namespace StardewSymphonyRemastered
|
|||
textureManager.addTexture("BackButton", new Texture2DExtended(ModHelper, Manifest.UniqueID, backButton));
|
||||
|
||||
|
||||
if (!Directory.Exists(this.MusicPath))
|
||||
Directory.CreateDirectory(this.MusicPath);
|
||||
if (!Directory.Exists(WavMusicDirectory))
|
||||
Directory.CreateDirectory(WavMusicDirectory);
|
||||
if (!Directory.Exists(XACTMusicDirectory))
|
||||
Directory.CreateDirectory(XACTMusicDirectory);
|
||||
if (!Directory.Exists(TemplateMusicDirectory))
|
||||
Directory.CreateDirectory(TemplateMusicDirectory);
|
||||
}
|
||||
|
||||
/// <summary>Used to create a blank XACT music pack example.</summary>
|
||||
public void createBlankXACTTemplate()
|
||||
{
|
||||
string path = Path.Combine(TemplateMusicDirectory, "XACT");
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
if (!File.Exists(Path.Combine(path, "MusicPackInformation.json")))
|
||||
{
|
||||
MusicPackMetaData blankMetaData = new MusicPackMetaData("Omegas's Music Data Example", "Omegasis", "Just a simple example of how metadata is formated for music packs. Feel free to copy and edit this one!", "1.0.0 CoolExample", "Icon.png");
|
||||
blankMetaData.writeToJson(Path.Combine(path, "MusicPackInformation.json"));
|
||||
}
|
||||
if (!File.Exists(Path.Combine(path, "readme.txt")))
|
||||
{
|
||||
string info = "Place the Wave Bank.xwb file and Sound Bank.xsb file you created in XACT in a similar directory in Content/Music/XACT/SoundPackName.\nModify MusicPackInformation.json as desire!\nRun the mod!";
|
||||
File.WriteAllText(Path.Combine(path, "readme.txt"), info);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>USed to create a blank WAV music pack example.</summary>
|
||||
public void createBlankWAVTemplate()
|
||||
{
|
||||
string path = Path.Combine(TemplateMusicDirectory, "WAV");
|
||||
string pathSongs = Path.Combine(path, "Songs");
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
if (!Directory.Exists(pathSongs))
|
||||
Directory.CreateDirectory(pathSongs);
|
||||
if (!File.Exists(Path.Combine(path, "MusicPackInformation.json")))
|
||||
{
|
||||
|
@ -373,61 +344,6 @@ namespace StardewSymphonyRemastered
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Load in the XACT music packs.</summary>
|
||||
public void loadXACTMusicPacks()
|
||||
{
|
||||
string[] listOfDirectories = Directory.GetDirectories(XACTMusicDirectory);
|
||||
foreach (string folder in listOfDirectories)
|
||||
{
|
||||
//This chunk essentially allows people to name .xwb and .xsb files whatever they want.
|
||||
string[] xwb = Directory.GetFiles(folder, "*.xwb");
|
||||
string[] xsb = Directory.GetFiles(folder, "*.xsb");
|
||||
|
||||
//string[] debug = Directory.GetFiles(folder);
|
||||
if (xwb.Length == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
string waveBank = xwb[0];
|
||||
string soundBank = xsb[0];
|
||||
string metaData = Path.Combine(folder, "MusicPackInformation.json");
|
||||
|
||||
if (!File.Exists(metaData))
|
||||
{
|
||||
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);
|
||||
}
|
||||
XACTMusicPack musicPack = new XACTMusicPack(folder, waveBank, soundBank);
|
||||
|
||||
musicPack.songInformation.initializeMenuMusic();
|
||||
musicPack.readFromJson();
|
||||
|
||||
musicManager.addMusicPack(musicPack, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Load in WAV music packs.</summary>
|
||||
public void loadWAVMusicPacks()
|
||||
{
|
||||
|
@ -451,13 +367,6 @@ namespace StardewSymphonyRemastered
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Reset the music files for the game.</summary>
|
||||
public static void Reset()
|
||||
{
|
||||
Game1.waveBank = DefaultWaveBank;
|
||||
Game1.soundBank = DefaultSoundBank;
|
||||
}
|
||||
|
||||
public static void DebugLog(string s)
|
||||
{
|
||||
if (Config.EnableDebugLog)
|
||||
|
|
|
@ -86,12 +86,10 @@
|
|||
<Compile Include="Framework\Music\Song.cs" />
|
||||
<Compile Include="Framework\Music\SongListNode.cs" />
|
||||
<Compile Include="StardewSymphony.cs" />
|
||||
<Compile Include="Framework\Music\MusicHexProcessor.cs" />
|
||||
<Compile Include="Framework\Music\MusicManager.cs" />
|
||||
<Compile Include="Framework\Music\MusicPack.cs" />
|
||||
<Compile Include="Framework\Music\SongSpecifics.cs" />
|
||||
<Compile Include="Framework\Music\WavMusicPack.cs" />
|
||||
<Compile Include="Framework\Music\XACTMusicPack.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -209,9 +207,6 @@
|
|||
<Content Include="Content\Music\Templates\WAV\Songs\SongsGoHere.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Music\Templates\XACT\MusicPackInformation.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="manifest.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -224,9 +219,6 @@
|
|||
<Content Include="Content\Music\Templates\WAV\readme.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Music\Templates\XACT\readme.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Content\Music\Wav\" />
|
||||
|
|
Loading…
Reference in New Issue