Started work on StardewSymphonyRemastered. New features, more options, and a UI are in the works.
This commit is contained in:
parent
efe185e76d
commit
1cd732cf4e
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Omegasis.StardewSymphony.Framework.SongsProcessor
|
||||
{
|
||||
public class MusicPack
|
||||
{
|
||||
public MusicPackMetaData musicPackInformation;
|
||||
public List<Song> listOfAllSongs;
|
||||
|
||||
|
||||
public MusicPack(string Name,string pathToFiles)
|
||||
{
|
||||
string extentionInformation = Path.GetExtension(pathToFiles);
|
||||
|
||||
|
||||
if (extentionInformation==".xwb") {
|
||||
this.musicPackInformation = new MusicPackMetaData(Name,pathToFiles);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.musicPackInformation = new MusicPackMetaData(Name);
|
||||
this.getAllWavFileFromDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
public void getAllWavFileFromDirectory()
|
||||
{
|
||||
string[] files = System.IO.Directory.GetFiles(musicPackInformation.fileLocation, "*.wav");
|
||||
|
||||
foreach(var s in files)
|
||||
{
|
||||
Song song = new Song(Path.GetFileName(musicPackInformation.fileLocation), s, false);
|
||||
this.listOfAllSongs.Add(song);
|
||||
}
|
||||
}
|
||||
|
||||
public void playSong(string name)
|
||||
{
|
||||
Song song = returnSong(name);
|
||||
if (song != null)
|
||||
{
|
||||
song.play();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopSong(string name)
|
||||
{
|
||||
Song song = returnSong(name);
|
||||
if (song != null)
|
||||
{
|
||||
song.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void resumeSong(string name)
|
||||
{
|
||||
Song song = returnSong(name);
|
||||
if (song != null)
|
||||
{
|
||||
song.resume();
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseSong(string name)
|
||||
{
|
||||
Song song = returnSong(name);
|
||||
if (song != null)
|
||||
{
|
||||
song.pause();
|
||||
}
|
||||
}
|
||||
|
||||
public void changeVolume(string name,float amount)
|
||||
{
|
||||
Song song = returnSong(name);
|
||||
if (song != null)
|
||||
{
|
||||
song.changeVolume(amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get's the song from the list.
|
||||
/// </summary>
|
||||
/// <param name="Name"></param>
|
||||
/// <returns></returns>
|
||||
public Song returnSong(string Name)
|
||||
{
|
||||
return listOfAllSongs.Find(item => item.name == Name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Omegasis.StardewSymphony.Framework.SongsProcessor
|
||||
{
|
||||
public class MusicPackMetaData
|
||||
{
|
||||
public string name;
|
||||
public string fileLocation;
|
||||
public bool xwbWavePack;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for non-xwb music packs
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public MusicPackMetaData(string name)
|
||||
{
|
||||
|
||||
this.name = name;
|
||||
this.xwbWavePack = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for xnb music packs
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="fileLocation"></param>
|
||||
public MusicPackMetaData(string name,string fileLocation)
|
||||
{
|
||||
this.name = name;
|
||||
this.fileLocation = fileLocation;
|
||||
this.xwbWavePack = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,221 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Omegasis.StardewSymphony.Framework.SongsProcessor
|
||||
{
|
||||
public class Song
|
||||
{
|
||||
public string name;
|
||||
public string fileLocation;
|
||||
public bool existsInMusicXNBFile;
|
||||
|
||||
|
||||
public DynamicSoundEffectInstance dynamicSound;
|
||||
public int position;
|
||||
public int count;
|
||||
public byte[] byteArray;
|
||||
|
||||
public EventHandler<EventArgs> bufferHandler;
|
||||
|
||||
public SongsProcessor.SongState songState;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="Name">Name of the song.</param>
|
||||
/// <param name="FileLocation">Path to the song.</param>
|
||||
/// <param name="ExistsInXNBWavePack">Checks if this song comes from a .xwb file or a .wav file.</param>
|
||||
public Song(string Name, string FileLocation, bool ExistsInXNBWavePack)
|
||||
{
|
||||
this.name = Name;
|
||||
this.fileLocation = FileLocation;
|
||||
this.existsInMusicXNBFile = ExistsInXNBWavePack;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the song from the path so that we can stream it.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DynamicSoundEffectInstance loadSongIntoStream()
|
||||
{
|
||||
|
||||
System.IO.Stream waveFileStream = TitleContainer.OpenStream(this.fileLocation);
|
||||
|
||||
BinaryReader reader = new BinaryReader(waveFileStream);
|
||||
|
||||
int chunkID = reader.ReadInt32();
|
||||
int fileSize = reader.ReadInt32();
|
||||
int riffType = reader.ReadInt32();
|
||||
int fmtID = reader.ReadInt32();
|
||||
int fmtSize = reader.ReadInt32();
|
||||
int fmtCode = reader.ReadInt16();
|
||||
int channels = reader.ReadInt16();
|
||||
int sampleRate = reader.ReadInt32();
|
||||
int fmtAvgBPS = reader.ReadInt32();
|
||||
int fmtBlockAlign = reader.ReadInt16();
|
||||
int bitDepth = reader.ReadInt16();
|
||||
|
||||
if (fmtSize == 18)
|
||||
{
|
||||
// Read any extra values
|
||||
int fmtExtraSize = reader.ReadInt16();
|
||||
reader.ReadBytes(fmtExtraSize);
|
||||
}
|
||||
|
||||
int dataID = reader.ReadInt32();
|
||||
int dataSize = reader.ReadInt32();
|
||||
|
||||
byteArray = reader.ReadBytes(dataSize);
|
||||
|
||||
dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels);
|
||||
count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(100));
|
||||
bufferHandler= new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
|
||||
dynamicSound.BufferNeeded += bufferHandler;
|
||||
|
||||
return this.dynamicSound;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Null the song out so that we can remove it from memory and switch to another song???
|
||||
/// </summary>
|
||||
public void unloadSongFromStream()
|
||||
{
|
||||
dynamicSound.Stop();
|
||||
dynamicSound.BufferNeeded -= bufferHandler;
|
||||
dynamicSound = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Taken from an example. I'm sure this is necessary to keep streaming the audio.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void DynamicSound_BufferNeeded(object sender, EventArgs e)
|
||||
{
|
||||
dynamicSound.SubmitBuffer(byteArray, position, count / 2);
|
||||
dynamicSound.SubmitBuffer(byteArray, position + count / 2, count / 2);
|
||||
|
||||
position += count;
|
||||
if (position + count > byteArray.Length)
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop the currently playing song.
|
||||
/// </summary>
|
||||
public void stop()
|
||||
{
|
||||
if (this.dynamicSound != null)
|
||||
{
|
||||
if(this.songState==SongState.Playing || this.songState == SongState.Paused)
|
||||
{
|
||||
this.dynamicSound.Stop();
|
||||
this.songState = SongState.Stopped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays the current song.
|
||||
/// </summary>
|
||||
public void play()
|
||||
{
|
||||
if (this.dynamicSound != null)
|
||||
{
|
||||
if (getSongState() == SongState.Stopped || getSongState() == SongState.Paused)
|
||||
{
|
||||
this.dynamicSound.Play();
|
||||
this.songState = SongState.Playing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resume the current song from being paused.
|
||||
/// </summary>
|
||||
public void resume()
|
||||
{
|
||||
if (this.dynamicSound != null)
|
||||
{
|
||||
if (getSongState() == SongState.Stopped || getSongState() == SongState.Paused)
|
||||
{
|
||||
this.dynamicSound.Resume();
|
||||
this.songState = SongState.Playing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pauses the current song.
|
||||
/// </summary>
|
||||
public void pause()
|
||||
{
|
||||
if (getSongState() == SongState.Playing || getSongState() == SongState.Stopped)
|
||||
{
|
||||
this.dynamicSound.Pause();
|
||||
this.songState = SongState.Paused;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the volume of the song playing.
|
||||
/// </summary>
|
||||
/// <param name="newVolumeAmount"></param>
|
||||
public void changeVolume(float newVolumeAmount)
|
||||
{
|
||||
if (this.dynamicSound != null)
|
||||
{
|
||||
this.dynamicSound.Volume = newVolumeAmount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the state of the song so that users know if the song is playing, stopped, or paused.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SongState getSongState()
|
||||
{
|
||||
return this.songState;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the song is playing or not.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool isPlaying()
|
||||
{
|
||||
if (getSongState() == SongState.Playing) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks is the song is paused or not.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool isPaused()
|
||||
{
|
||||
if (getSongState() == SongState.Paused) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the song is stopped or not.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool isStopped()
|
||||
{
|
||||
if (getSongState() == SongState.Stopped) return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Omegasis.StardewSymphony.Framework.SongsProcessor
|
||||
{
|
||||
public enum SongState
|
||||
{
|
||||
/// <summary>The song is currently playing.</summary>
|
||||
Playing,
|
||||
|
||||
/// <summary>The song is currently paused.</summary>
|
||||
Paused,
|
||||
|
||||
/// <summary>The song is currently stopped.</summary>
|
||||
Stopped
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -154,7 +154,7 @@ namespace Omegasis.StardewSymphony
|
|||
}
|
||||
|
||||
// init sound
|
||||
this.HexProcessor.ProcessHex();
|
||||
this.HexProcessor.ProcessHex(); //Get all of the songs from the music packs.
|
||||
this.SelectMusic();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,11 @@
|
|||
<Link>Properties\GlobalAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Framework\ModConfig.cs" />
|
||||
<Compile Include="Framework\SongsProcessor\MusicPack.cs" />
|
||||
<Compile Include="Framework\SongsProcessor\MusicPackMetaData.cs" />
|
||||
<Compile Include="Framework\SongsProcessor\Song.cs" />
|
||||
<Compile Include="Framework\SongsProcessor\SongState.cs" />
|
||||
<Compile Include="Framework\SongsProcessor\WaveFile.cs" />
|
||||
<Compile Include="StardewSymphony.cs" />
|
||||
<Compile Include="Framework\MusicHexProcessor.cs" />
|
||||
<Compile Include="Framework\MusicManager.cs" />
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Express 14 for Windows Desktop
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewSymphonyRemastered", "StardewSymphonyRemastered\StardewSymphonyRemastered.csproj", "{19F64B03-6A9B-49E1-854A-C05D5A014646}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{19F64B03-6A9B-49E1-854A-C05D5A014646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{19F64B03-6A9B-49E1-854A-C05D5A014646}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19F64B03-6A9B-49E1-854A-C05D5A014646}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{19F64B03-6A9B-49E1-854A-C05D5A014646}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewSymphonyRemastered
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// BIG WIP. Don't use this at all because it does nothing right now.
|
||||
/// TODO:
|
||||
/// 1.Make Xwb packs work
|
||||
/// 2.Make stream files work
|
||||
/// 2.5. Make Music Manager
|
||||
/// 3.Make interface.
|
||||
/// 4.Make sure stuff doesn't blow up.
|
||||
/// 5.Release
|
||||
/// 6.Make videos documenting how to make this mod work.
|
||||
/// 7.Make way to generate new music packs.
|
||||
/// </summary>
|
||||
public class Class1 : Mod
|
||||
{
|
||||
public static WaveBank DefaultWaveBank;
|
||||
public static SoundBank DefaultSoundBank;
|
||||
|
||||
|
||||
public override void Entry(IModHelper helper)
|
||||
{
|
||||
DefaultSoundBank = Game1.soundBank;
|
||||
DefaultWaveBank = Game1.waveBank;
|
||||
|
||||
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </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();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reset the music files for the game.
|
||||
/// </summary>
|
||||
public static void Reset()
|
||||
{
|
||||
Game1.waveBank = DefaultWaveBank;
|
||||
Game1.soundBank = DefaultSoundBank;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,188 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using StardewValley;
|
||||
using StardewSymphonyRemastered.Framework;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
public class MusicHexProcessor
|
||||
{
|
||||
/*********
|
||||
** Properties
|
||||
*********/
|
||||
/// <summary>All of the music/soundbanks and their locations.</summary>
|
||||
private readonly XwbMusicPack MasterList;
|
||||
|
||||
/// <summary>The registered soundbanks.</summary>
|
||||
private readonly List<string> SoundBanks = new List<string>();
|
||||
|
||||
/// <summary>The callback to reset the game audio.</summary>
|
||||
private readonly Action Reset;
|
||||
|
||||
|
||||
/*********
|
||||
** Public methods
|
||||
*********/
|
||||
/// <summary>Construct an instance.</summary>
|
||||
/// <param name="masterList">All of the music/soundbanks and their locations.</param>
|
||||
/// <param name="reset">The callback to reset the game audio.</param>
|
||||
public MusicHexProcessor(XwbMusicPack masterList, Action reset)
|
||||
{
|
||||
this.MasterList = masterList;
|
||||
this.Reset = reset;
|
||||
}
|
||||
|
||||
/// <summary>Add a file path to the list of soundbanks.</summary>
|
||||
/// <param name="path">The soundbank file path.</param>
|
||||
public void AddSoundBank(string path)
|
||||
{
|
||||
this.SoundBanks.Add(path);
|
||||
}
|
||||
|
||||
public static List<string> ProcessSongNamesFromHex(XwbMusicPack musicPack, Action reset, string FileName)
|
||||
{
|
||||
int counter = 0;
|
||||
List<string> cleanCueNames = new List<string>();
|
||||
byte[] array = File.ReadAllBytes(FileName);
|
||||
string rawName = FileName.Substring(0, FileName.Length - 4);
|
||||
string cueName = rawName + "CueList.txt";
|
||||
|
||||
if (File.Exists(cueName))
|
||||
{
|
||||
string[] arr = File.ReadAllLines(cueName);
|
||||
List<string> names = new List<string>();
|
||||
foreach(var v in arr)
|
||||
{
|
||||
names.Add(v);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
string hexDumpContents = HexDump(array);
|
||||
|
||||
string rawHexName = rawName + "HexDump.txt";
|
||||
File.WriteAllText(rawHexName, hexDumpContents);
|
||||
|
||||
string[] readText = File.ReadAllLines(rawHexName);
|
||||
string largeString = "";
|
||||
foreach (var 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 (var 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 { }
|
||||
}
|
||||
|
||||
return cleanCueNames;
|
||||
}
|
||||
|
||||
/*********
|
||||
** Private methods
|
||||
*********/
|
||||
public 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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO: Make this manage all of the music.
|
||||
/// </summary>
|
||||
public class MusicManager
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// A base class that xnb and wav packs will derive commonalities from.
|
||||
/// </summary>
|
||||
public class MusicPack
|
||||
{
|
||||
public string name;
|
||||
public string directory;
|
||||
public List<string> listOfSongs;
|
||||
|
||||
|
||||
public virtual void playSong(string name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void pauseSong(string name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void stopSong(string name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void returnSong(string name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void loadMusicFiles()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
using StardewValley;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores information about what songs play when.
|
||||
/// </summary>
|
||||
public class SongSpecifics
|
||||
{
|
||||
Dictionary<string, List<string>> listOfSongsWithTriggers; //triggerName, <songs>
|
||||
|
||||
Dictionary<string, List<string>> eventSongs;
|
||||
|
||||
Dictionary<string, List<string>> festivalSongs;
|
||||
|
||||
public static List<string> locations = new List<string>();
|
||||
public static List<string> festivals = new List<string>();
|
||||
public static List<string> events = new List<string>();
|
||||
|
||||
string[] seasons;
|
||||
string[] weather;
|
||||
string[] daysOfWeek;
|
||||
string[] timesOfDay;
|
||||
char seperator = '_';
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public SongSpecifics()
|
||||
{
|
||||
seasons = new string[]
|
||||
{
|
||||
"spring",
|
||||
"summer",
|
||||
"fall",
|
||||
"winter"
|
||||
};
|
||||
|
||||
weather = new string[]
|
||||
{
|
||||
"sunny",
|
||||
"rainy",
|
||||
"debris",
|
||||
"lightning",
|
||||
"festival",
|
||||
"snow",
|
||||
"wedding"
|
||||
};
|
||||
daysOfWeek = new string[]
|
||||
{
|
||||
"sunday",
|
||||
"monday",
|
||||
"tuesday",
|
||||
"wednesday",
|
||||
"thursday",
|
||||
"friday",
|
||||
"saturday"
|
||||
};
|
||||
timesOfDay = new string[]
|
||||
{
|
||||
"day",
|
||||
"night"
|
||||
};
|
||||
|
||||
listOfSongsWithTriggers = new Dictionary<string, List<string>>();
|
||||
eventSongs = new Dictionary<string, List<string>>();
|
||||
festivalSongs = new Dictionary<string, List<string>>();
|
||||
|
||||
this.addSongLists();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the location lists with the names of all of the major locations in the game.
|
||||
/// </summary>
|
||||
public static void addLocations()
|
||||
{
|
||||
foreach(var v in Game1.locations)
|
||||
{
|
||||
locations.Add(v.name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public static void addFestivals()
|
||||
{
|
||||
//Do some logic for festivals here.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a specific new festival to the list
|
||||
/// </summary>
|
||||
public static void addFestival(string name)
|
||||
{
|
||||
festivals.Add(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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()
|
||||
{
|
||||
//Do some logic here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TODO: Custom way to add in event to hijack music.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public static void addEvent(string name)
|
||||
{
|
||||
//Do some logic here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a location to the loctaion list.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public static void addLocation(string name)
|
||||
{
|
||||
locations.Add(name);
|
||||
}
|
||||
|
||||
/// <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 addSongLists()
|
||||
{
|
||||
foreach (var loc in Game1.locations)
|
||||
{
|
||||
foreach (var season in seasons)
|
||||
{
|
||||
listOfSongsWithTriggers.Add(loc.name + seperator + season, new List<string>());
|
||||
foreach(var Weather in weather)
|
||||
{
|
||||
listOfSongsWithTriggers.Add(loc.name + seperator + season + seperator + Weather, new List<string>());
|
||||
foreach(var day in daysOfWeek)
|
||||
{
|
||||
listOfSongsWithTriggers.Add(loc.name + seperator + season + seperator + Weather + seperator + day, new List<string>());
|
||||
foreach(var time in timesOfDay)
|
||||
{
|
||||
listOfSongsWithTriggers.Add(loc.name + seperator + season + seperator + Weather + seperator + day + seperator + time, new List<string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Add in some default seasonal music because maybe a location doesn't have some music?
|
||||
foreach (var season in seasons)
|
||||
{
|
||||
listOfSongsWithTriggers.Add(season, new List<string>());
|
||||
foreach (var Weather in weather)
|
||||
{
|
||||
listOfSongsWithTriggers.Add( season + seperator + Weather, new List<string>());
|
||||
foreach (var day in daysOfWeek)
|
||||
{
|
||||
listOfSongsWithTriggers.Add(season + seperator + Weather + seperator + day, new List<string>());
|
||||
foreach (var time in timesOfDay)
|
||||
{
|
||||
listOfSongsWithTriggers.Add(season + seperator + Weather + seperator + day + seperator + time, new List<string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TODO: Add functionality for events and festivals
|
||||
/// Sum up some conditionals to parse the correct string key to access the songs list.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string getCurrentConditionalString()
|
||||
{
|
||||
string key = "";
|
||||
if (Game1.eventUp == true)
|
||||
{
|
||||
//Get the event id an hijack it with some different music
|
||||
}
|
||||
else if (Game1.isFestival())
|
||||
{
|
||||
//hijack the name of the festival and load some different songs
|
||||
}
|
||||
/*
|
||||
else if (Game1.eventUp == false && Game1.isFestival() == false && Game1.currentSpeaker != null)
|
||||
{
|
||||
//get the speaker's name and play their theme song?
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
key = getLocationString()+seperator+ getSeasonNameString() + seperator + getWeatherString() + seperator + getDayOfWeekString() + seperator + getTimeOfDayString();
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the day of the week from what game day it is.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string getDayOfWeekString()
|
||||
{
|
||||
int day = Game1.dayOfMonth;
|
||||
int dayOfWeek = day % 7;
|
||||
if (dayOfWeek == 0)
|
||||
{
|
||||
return "sunday";
|
||||
}
|
||||
if (dayOfWeek == 1)
|
||||
{
|
||||
return "monday";
|
||||
}
|
||||
if (dayOfWeek == 2)
|
||||
{
|
||||
return "tuesday";
|
||||
}
|
||||
if (dayOfWeek == 3)
|
||||
{
|
||||
return "wednesday";
|
||||
}
|
||||
if (dayOfWeek == 4)
|
||||
{
|
||||
return "thursday";
|
||||
}
|
||||
if (dayOfWeek == 5)
|
||||
{
|
||||
return "friday";
|
||||
}
|
||||
if (dayOfWeek == 6)
|
||||
{
|
||||
return "saturday";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the current season
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string getSeasonNameString()
|
||||
{
|
||||
return Game1.currentSeason.ToLower();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the name for the current weather outside.
|
||||
/// </summary>
|
||||
/// <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 "debris";
|
||||
if (Game1.weatherIcon == Game1.weather_lightning) return "lightning";
|
||||
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 "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the name for the time of day that it currently is.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string getTimeOfDayString()
|
||||
{
|
||||
if (Game1.timeOfDay< Game1.getModeratelyDarkTime()) return "day";
|
||||
else return "night";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the location of where I am at.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string getLocationString()
|
||||
{
|
||||
return Game1.currentLocation.name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO: Make this class
|
||||
/// </summary>
|
||||
class WavMusicPack : MusicPack
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardewSymphonyRemastered.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO: Make this work and add in overrided functions.
|
||||
/// </summary>
|
||||
public class XwbMusicPack: MusicPack
|
||||
{
|
||||
public Microsoft.Xna.Framework.Audio.WaveBank WaveBank;
|
||||
public Microsoft.Xna.Framework.Audio.SoundBank SoundBank;
|
||||
|
||||
public StardewSymphonyRemastered.Framework.SongSpecifics songInformation;
|
||||
|
||||
public string XWBPath;
|
||||
|
||||
public XwbMusicPack(string name, string directoryToXwb,string pathToXWB)
|
||||
{
|
||||
this.name = name;
|
||||
this.directory = directoryToXwb;
|
||||
this.XWBPath = pathToXWB;
|
||||
this.songInformation = new SongSpecifics();
|
||||
}
|
||||
|
||||
public override void loadMusicFiles()
|
||||
{
|
||||
this.listOfSongs=StardewSymphonyRemastered.Framework.MusicHexProcessor.ProcessSongNamesFromHex(this,Class1.Reset,this.XWBPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("StardewSymphonyRemastered")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("StardewSymphonyRemastered")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("19f64b03-6a9b-49e1-854a-c05d5a014646")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{19F64B03-6A9B-49E1-854A-C05D5A014646}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>StardewSymphonyRemastered</RootNamespace>
|
||||
<AssemblyName>StardewSymphonyRemastered</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Framework\MusicHexProcessor.cs" />
|
||||
<Compile Include="Framework\MusicManager.cs" />
|
||||
<Compile Include="Framework\MusicPack.cs" />
|
||||
<Compile Include="Framework\SongSpecifics.cs" />
|
||||
<Compile Include="Framework\WavMusicPack.cs" />
|
||||
<Compile Include="Framework\XwbMusicPack.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.0.2" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue