Fixed Stardew Symphony Remastered from numerous menu and music glitches.
This commit is contained in:
parent
704a15ad4d
commit
a6257c5d28
|
@ -1586,7 +1586,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
if (this.currentMusicPackAlbum == null || this.currentSelectedSong == null) return false;
|
if (this.currentMusicPackAlbum == null || this.currentSelectedSong == null) return false;
|
||||||
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
||||||
//Check for generic festival music.
|
//Check for generic festival music.
|
||||||
if (this.drawMode == DrawMode.FestivalSelection)
|
if (this.drawMode == DrawMode.SelectedFestival)
|
||||||
{
|
{
|
||||||
var festivalSonglist = info.Value.songInformation.festivalSongs;
|
var festivalSonglist = info.Value.songInformation.festivalSongs;
|
||||||
if (festivalSonglist == null) return false;
|
if (festivalSonglist == null) return false;
|
||||||
|
@ -1594,9 +1594,9 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
//Check for generic event music.
|
//Check for generic event music.
|
||||||
if (this.drawMode == DrawMode.EventSelection)
|
if (this.drawMode == DrawMode.SelectedEvent)
|
||||||
{
|
{
|
||||||
var eventSonglist = info.Value.songInformation.festivalSongs;
|
var eventSonglist = info.Value.songInformation.eventSongs;
|
||||||
if (eventSonglist == null) return false;
|
if (eventSonglist == null) return false;
|
||||||
if (!eventSonglist.Contains(info.Value.songInformation.getSongFromList(eventSonglist, this.currentSelectedSong.name))) return false;
|
if (!eventSonglist.Contains(info.Value.songInformation.getSongFromList(eventSonglist, this.currentSelectedSong.name))) return false;
|
||||||
else return true;
|
else return true;
|
||||||
|
@ -1894,6 +1894,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
this.currentMusicPackAlbum.draw(b);
|
this.currentMusicPackAlbum.draw(b);
|
||||||
this.currentSelectedSong.draw(b);
|
this.currentSelectedSong.draw(b);
|
||||||
this.currentlySelectedOption.draw(b);
|
this.currentlySelectedOption.draw(b);
|
||||||
|
/*
|
||||||
if (!doesPackContainMusic())
|
if (!doesPackContainMusic())
|
||||||
{
|
{
|
||||||
this.addButton.draw(b);
|
this.addButton.draw(b);
|
||||||
|
@ -1902,6 +1903,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
{
|
{
|
||||||
this.deleteButton.draw(b);
|
this.deleteButton.draw(b);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
this.playButton.draw(b);
|
this.playButton.draw(b);
|
||||||
this.stopButton.draw(b);
|
this.stopButton.draw(b);
|
||||||
|
|
||||||
|
@ -1952,6 +1954,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
this.currentMusicPackAlbum.draw(b);
|
this.currentMusicPackAlbum.draw(b);
|
||||||
this.currentSelectedSong.draw(b);
|
this.currentSelectedSong.draw(b);
|
||||||
this.currentlySelectedOption.draw(b);
|
this.currentlySelectedOption.draw(b);
|
||||||
|
/*
|
||||||
if (!doesPackContainMusic())
|
if (!doesPackContainMusic())
|
||||||
{
|
{
|
||||||
this.addButton.draw(b);
|
this.addButton.draw(b);
|
||||||
|
@ -1960,6 +1963,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
{
|
{
|
||||||
this.deleteButton.draw(b);
|
this.deleteButton.draw(b);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
this.playButton.draw(b);
|
this.playButton.draw(b);
|
||||||
this.stopButton.draw(b);
|
this.stopButton.draw(b);
|
||||||
|
|
||||||
|
@ -2010,6 +2014,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
this.currentMusicPackAlbum.draw(b);
|
this.currentMusicPackAlbum.draw(b);
|
||||||
this.currentSelectedSong.draw(b);
|
this.currentSelectedSong.draw(b);
|
||||||
this.currentlySelectedOption.draw(b);
|
this.currentlySelectedOption.draw(b);
|
||||||
|
/*
|
||||||
if (!doesPackContainMusic())
|
if (!doesPackContainMusic())
|
||||||
{
|
{
|
||||||
this.addButton.draw(b);
|
this.addButton.draw(b);
|
||||||
|
@ -2018,6 +2023,7 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
{
|
{
|
||||||
this.deleteButton.draw(b);
|
this.deleteButton.draw(b);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
this.playButton.draw(b);
|
this.playButton.draw(b);
|
||||||
this.stopButton.draw(b);
|
this.stopButton.draw(b);
|
||||||
|
|
||||||
|
@ -2161,13 +2167,16 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
{
|
{
|
||||||
if (this.drawMode == DrawMode.WeatherSelection || this.drawMode == DrawMode.TimeSelection || this.drawMode == DrawMode.LocationSelection || this.drawMode == DrawMode.DaySelection || this.drawMode == DrawMode.NothingElseToDisplay)
|
if (this.drawMode == DrawMode.WeatherSelection || this.drawMode == DrawMode.TimeSelection || this.drawMode == DrawMode.LocationSelection || this.drawMode == DrawMode.DaySelection || this.drawMode == DrawMode.NothingElseToDisplay)
|
||||||
{
|
{
|
||||||
if (!doesPackContainMusic())
|
if (this.selectedJustLocation==false)
|
||||||
{
|
{
|
||||||
this.addButton.draw(b);
|
if (!doesPackContainMusic())
|
||||||
}
|
{
|
||||||
else
|
this.addButton.draw(b);
|
||||||
{
|
}
|
||||||
this.deleteButton.draw(b);
|
else
|
||||||
|
{
|
||||||
|
this.deleteButton.draw(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.playButton.draw(b);
|
this.playButton.draw(b);
|
||||||
|
@ -2248,19 +2257,18 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
|
|
||||||
|
|
||||||
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
||||||
StardewSymphony.ModMonitor.Log(generateSongTriggerKeyFromSelection());
|
//StardewSymphony.ModMonitor.Log(generateSongTriggerKeyFromSelection());
|
||||||
//Add generic festival music.
|
//Add generic festival music.
|
||||||
if (this.drawMode == DrawMode.FestivalSelection)
|
if (this.drawMode == DrawMode.SelectedFestival)
|
||||||
{
|
{
|
||||||
|
info.Value.songInformation.addSongToFestivalList(this.currentSelectedSong.label);
|
||||||
info.Value.songInformation.addSongToFestivalList(this.currentlySelectedFestival.label);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add generic event music.
|
//Add generic event music.
|
||||||
if(this.drawMode== DrawMode.EventSelection)
|
if(this.drawMode== DrawMode.SelectedEvent)
|
||||||
{
|
{
|
||||||
info.Value.songInformation.addSongToEventList(this.currentlySelectedEvent.label);
|
info.Value.songInformation.addSongToEventList(this.currentSelectedSong.label);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2274,7 +2282,25 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void deleteSong()
|
public void deleteSong()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
var info = (KeyValuePair<string, MusicPack>)this.currentMusicPackAlbum.buttonFunctionality.leftClick.paramaters[0];
|
||||||
|
|
||||||
|
|
||||||
|
if (this.drawMode == DrawMode.SelectedFestival)
|
||||||
|
{
|
||||||
|
info.Value.songInformation.removeSongFromFestivalList(this.currentSelectedSong.label);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add generic event music.
|
||||||
|
if (this.drawMode == DrawMode.SelectedEvent)
|
||||||
|
{
|
||||||
|
info.Value.songInformation.removeSongFromEventList(this.currentSelectedSong.label);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
info.Value.songInformation.removeSongFromTriggerList(generateSongTriggerKeyFromSelection(), this.currentSelectedSong.label);
|
info.Value.songInformation.removeSongFromTriggerList(generateSongTriggerKeyFromSelection(), this.currentSelectedSong.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2318,13 +2344,13 @@ namespace StardewSymphonyRemastered.Framework.Menus
|
||||||
else if (this.currentlySelectedOption.name == "WinterButton") key += "winter";
|
else if (this.currentlySelectedOption.name == "WinterButton") key += "winter";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StardewSymphony.ModMonitor.Log("Error: You are not in a valid menu area to set the song information. Please make sure that a valid season is selected for the song options", StardewModdingAPI.LogLevel.Alert);
|
//StardewSymphony.ModMonitor.Log("Error: You are not in a valid menu area to set the song information. Please make sure that a valid season is selected for the song options", StardewModdingAPI.LogLevel.Alert);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StardewSymphony.ModMonitor.Log("Error: You are not in a valid menu area to set the song information. Please make sure that a valid season is selected for the song options", StardewModdingAPI.LogLevel.Alert);
|
//StardewSymphony.ModMonitor.Log("Error: You are not in a valid menu area to set the song information. Please make sure that a valid season is selected for the song options", StardewModdingAPI.LogLevel.Alert);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,26 +65,55 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updtes the timer every second to check if a song is playing or not.
|
||||||
|
/// </summary>
|
||||||
public void updateTimer()
|
public void updateTimer()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (this.currentMusicPack == null) return;
|
if (this.currentMusicPack == null) return;
|
||||||
if (this.currentMusicPack.isPlaying()) return;
|
if (this.currentMusicPack.isPlaying())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Random r = new Random(Game1.random.Next());
|
if (timer == null)
|
||||||
|
{
|
||||||
int val = r.Next(StardewSymphony.Config.MinimumDelayBetweenSongsInMilliseconds, StardewSymphony.Config.MaximumDelayBetweenSongsInMilliseconds + 1);
|
Random r = new Random(Game1.random.Next());
|
||||||
timer = new Timer(val);
|
int val = r.Next(StardewSymphony.Config.MinimumDelayBetweenSongsInMilliseconds, StardewSymphony.Config.MaximumDelayBetweenSongsInMilliseconds + 1);
|
||||||
timer.Elapsed += onTimerFinished;
|
//StardewSymphony.ModMonitor.Log("Music Pack is not playing! Generate a new timer! Delay: "+val.ToString());
|
||||||
timer.Enabled = true;
|
timer = new Timer(val);
|
||||||
|
timer.Elapsed += onTimerFinished;
|
||||||
|
timer.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timer.Enabled = true;
|
||||||
|
timer.Elapsed += onTimerFinished;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects a new song when the timer delay runs out.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
public void onTimerFinished(System.Object source, ElapsedEventArgs e)
|
public void onTimerFinished(System.Object source, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (this.currentMusicPack.isPlaying())
|
||||||
|
{
|
||||||
|
timer.Enabled = false;
|
||||||
|
timer = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//StardewSymphony.ModMonitor.Log("AHH THE TIMER FINISHED!");
|
||||||
timer.Enabled = false;
|
timer.Enabled = false;
|
||||||
|
timer.Elapsed -= onTimerFinished;
|
||||||
selectMusic(SongSpecifics.getCurrentConditionalString());
|
selectMusic(SongSpecifics.getCurrentConditionalString());
|
||||||
|
timer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -269,6 +298,11 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
/// <param name="songListKey"></param>
|
/// <param name="songListKey"></param>
|
||||||
public void selectMusic(string songListKey)
|
public void selectMusic(string songListKey)
|
||||||
{
|
{
|
||||||
|
//Nullify the timer when new music is selected.
|
||||||
|
if (this.timer != null)
|
||||||
|
{
|
||||||
|
this.timer = null;
|
||||||
|
}
|
||||||
|
|
||||||
var listOfValidMusicPacks = getListOfApplicableMusicPacks(songListKey);
|
var listOfValidMusicPacks = getListOfApplicableMusicPacks(songListKey);
|
||||||
|
|
||||||
|
|
|
@ -63,16 +63,19 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
{
|
{
|
||||||
string json = Path.Combine(path, "MusicPackInformation.json");
|
string json = Path.Combine(path, "MusicPackInformation.json");
|
||||||
var meta=StardewSymphony.ModHelper.ReadJsonFile<MusicPackMetaData>(json);
|
var meta=StardewSymphony.ModHelper.ReadJsonFile<MusicPackMetaData>(json);
|
||||||
|
|
||||||
|
string[] pathParse = path.Split(new String[] { StardewSymphony.ModHelper.DirectoryPath },StringSplitOptions.None);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper,StardewSymphony.Manifest, StardewSymphony.getRelativeDirectory(Path.Combine(path, meta.pathToMusicPackIcon + ".png")));
|
meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper,StardewSymphony.Manifest, Path.Combine(pathParse[1], meta.pathToMusicPackIcon + ".png"));
|
||||||
}
|
}
|
||||||
catch(Exception errr)
|
catch(Exception errr)
|
||||||
{
|
{
|
||||||
errr.ToString();
|
errr.ToString();
|
||||||
meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper,StardewSymphony.Manifest ,StardewSymphony.getRelativeDirectory(Path.Combine(path, meta.pathToMusicPackIcon)));
|
meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper,StardewSymphony.Manifest ,Path.Combine(pathParse[1], meta.pathToMusicPackIcon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch(Exception err)
|
||||||
|
|
|
@ -625,7 +625,6 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
public void addSongToFestivalList(string songName)
|
public void addSongToFestivalList(string songName)
|
||||||
{
|
{
|
||||||
|
|
||||||
var songKeyPair = this.festivalSongs;
|
|
||||||
|
|
||||||
var song = getSongFromList(listOfSongsWithoutTriggers, songName); //Get the song from the master song pool
|
var song = getSongFromList(listOfSongsWithoutTriggers, songName); //Get the song from the master song pool
|
||||||
if (song == null)
|
if (song == null)
|
||||||
|
@ -634,7 +633,7 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is " + songName);
|
StardewSymphony.ModMonitor.Log("For some reason you are trying to add a song that is null. The name of the song is " + songName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
songKeyPair.Add(song); //add the song from master pool to the trigger list
|
this.festivalSongs.Add(song); //add the song from master pool to the trigger list
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSongToEventList(string songName)
|
public void addSongToEventList(string songName)
|
||||||
|
@ -664,6 +663,28 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
songKeyPair.Value.Remove(song);
|
songKeyPair.Value.Remove(song);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a song from the event list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="songListKey"></param>
|
||||||
|
/// <param name="songName"></param>
|
||||||
|
public void removeSongFromEventList( string songName)
|
||||||
|
{
|
||||||
|
var song = getSongFromList(this.eventSongs, songName);
|
||||||
|
this.eventSongs.Remove(song);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a song from the festival list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="songListKey"></param>
|
||||||
|
/// <param name="songName"></param>
|
||||||
|
public void removeSongFromFestivalList( string songName)
|
||||||
|
{
|
||||||
|
var song = getSongFromList(this.festivalSongs, songName);
|
||||||
|
this.festivalSongs.Remove(song);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the Song instance that is referenced with the song's name.
|
/// Get the Song instance that is referenced with the song's name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -672,8 +693,10 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Song getSongFromList(List<Song> songList,string songName)
|
public Song getSongFromList(List<Song> songList,string songName)
|
||||||
{
|
{
|
||||||
|
//StardewSymphony.ModMonitor.Log("Get the song: " + songName);
|
||||||
foreach (var song in songList)
|
foreach (var song in songList)
|
||||||
{
|
{
|
||||||
|
//StardewSymphony.ModMonitor.Log("Looking at song: " + song.name);
|
||||||
if (song.name == songName)
|
if (song.name == songName)
|
||||||
{
|
{
|
||||||
return song;
|
return song;
|
||||||
|
|
|
@ -18,26 +18,12 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
public Song currentSong;
|
public Song currentSong;
|
||||||
public string songsDirectory;
|
public string songsDirectory;
|
||||||
|
|
||||||
/// <summary>
|
public SoundEffectInstance sound;
|
||||||
/// Used to actually play the song.
|
|
||||||
/// </summary>
|
|
||||||
DynamicSoundEffectInstance dynamicSound;
|
|
||||||
/// <summary>
|
|
||||||
/// Used to keep track of where in the song we are.
|
|
||||||
/// </summary>
|
|
||||||
int position;
|
|
||||||
/// <summary>
|
|
||||||
/// ???
|
|
||||||
/// </summary>
|
|
||||||
int count;
|
|
||||||
/// <summary>
|
|
||||||
/// Used to store the info for the song.
|
|
||||||
/// </summary>
|
|
||||||
byte[] byteArray;
|
|
||||||
|
|
||||||
|
|
||||||
bool loop;
|
bool loop;
|
||||||
|
|
||||||
|
|
||||||
|
public Dictionary<string,SoundEffectInstance> sounds;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -50,6 +36,7 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
this.songInformation = new SongSpecifics();
|
this.songInformation = new SongSpecifics();
|
||||||
this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToMusicPack);
|
this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToMusicPack);
|
||||||
this.loop = Loop;
|
this.loop = Loop;
|
||||||
|
this.sounds = new Dictionary<string, SoundEffectInstance>();
|
||||||
/*
|
/*
|
||||||
if (this.musicPackInformation == null)
|
if (this.musicPackInformation == null)
|
||||||
{
|
{
|
||||||
|
@ -80,83 +67,21 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load a wav file into the stream to be played.
|
/// Load a wav file into the stream to be played.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void LoadWavFromFileToStream(string p)
|
public void LoadWavFromFileToStream(string file)
|
||||||
{
|
{
|
||||||
// Create a new SpriteBatch, which can be used to draw textures.
|
// Create a new SpriteBatch, which can be used to draw textures.
|
||||||
|
|
||||||
string file =p;
|
|
||||||
System.IO.Stream waveFileStream = File.OpenRead(file); //TitleContainer.OpenStream(file);
|
System.IO.Stream waveFileStream = File.OpenRead(file); //TitleContainer.OpenStream(file);
|
||||||
|
this.effect = SoundEffect.FromStream(waveFileStream);
|
||||||
BinaryReader reader = new BinaryReader(waveFileStream);
|
this.sound=this.effect.CreateInstance();
|
||||||
|
this.currentSong = new Song(file);
|
||||||
int chunkID = reader.ReadInt32();
|
waveFileStream.Dispose();
|
||||||
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(10000));
|
|
||||||
if (count > byteArray.Length)
|
|
||||||
{
|
|
||||||
count = byteArray.Length;
|
|
||||||
}
|
|
||||||
dynamicSound.BufferNeeded += new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
|
|
||||||
this.currentSong = new Song(p);
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void DynamicSound_BufferNeeded(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//StardewSymphony.ModMonitor.Log(byteArray.Length.ToString());
|
|
||||||
//StardewSymphony.ModMonitor.Log(position.ToString());
|
|
||||||
//StardewSymphony.ModMonitor.Log(count.ToString());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dynamicSound.SubmitBuffer(byteArray, position, count);
|
|
||||||
}
|
|
||||||
catch(Exception err)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//dynamicSound.SubmitBuffer(byteArray);
|
|
||||||
//dynamicSound.SubmitBuffer(byteArray, position + count / 2, count / 2);
|
|
||||||
|
|
||||||
position += count;
|
|
||||||
if (position + count > byteArray.Length)
|
|
||||||
{
|
|
||||||
if (loop)
|
|
||||||
{
|
|
||||||
position = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of the currently playing song.
|
/// Returns the name of the currently playing song.
|
||||||
|
@ -177,10 +102,18 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
List<Song> listOfSongs = new List<Song>();
|
List<Song> listOfSongs = new List<Song>();
|
||||||
foreach(var wav in wavFiles)
|
foreach(var wav in wavFiles)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
System.IO.Stream waveFileStream = File.OpenRead(wav); //TitleContainer.OpenStream(file);
|
||||||
|
SoundEffect eff = SoundEffect.FromStream(waveFileStream);
|
||||||
|
SoundEffectInstance instance = eff.CreateInstance();
|
||||||
|
string name = Path.GetFileNameWithoutExtension(wav);
|
||||||
|
this.sounds.Add(name, instance);
|
||||||
|
|
||||||
|
waveFileStream.Dispose();
|
||||||
Song song = new Song(wav);
|
Song song = new Song(wav);
|
||||||
listOfSongs.Add(song);
|
this.songInformation.listOfSongsWithoutTriggers.Add(song);
|
||||||
|
//listOfSongs.Add(song);
|
||||||
}
|
}
|
||||||
this.songInformation.listOfSongsWithoutTriggers = listOfSongs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -188,7 +121,7 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void pauseSong()
|
public override void pauseSong()
|
||||||
{
|
{
|
||||||
if (dynamicSound != null) dynamicSound.Pause();
|
if (this.sound != null) sound.Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -198,8 +131,19 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
public override void playSong(string name)
|
public override void playSong(string name)
|
||||||
{
|
{
|
||||||
string pathToSong = getSongPathFromName(name);
|
string pathToSong = getSongPathFromName(name);
|
||||||
LoadWavFromFileToStream(pathToSong);
|
|
||||||
dynamicSound.Play();
|
bool exists=this.sounds.TryGetValue(name,out this.sound);
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
this.currentSong = new Song(name);
|
||||||
|
sound.Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StardewSymphony.ModMonitor.Log("An error occured where we can't find the song anymore. Weird. Please contact Omegasis with a SMAPI Log and describe when/how the event occured.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void playRandomSong()
|
public override void playRandomSong()
|
||||||
|
@ -215,8 +159,8 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void resumeSong()
|
public override void resumeSong()
|
||||||
{
|
{
|
||||||
if (dynamicSound == null) return;
|
if (sound == null) return;
|
||||||
dynamicSound.Resume();
|
sound.Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -226,15 +170,10 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
{
|
{
|
||||||
if (Game1.currentSong != null) Game1.currentSong.Stop(AudioStopOptions.Immediate);
|
if (Game1.currentSong != null) Game1.currentSong.Stop(AudioStopOptions.Immediate);
|
||||||
if (this.currentSong == null) return;
|
if (this.currentSong == null) return;
|
||||||
if (dynamicSound != null)
|
if (sound != null)
|
||||||
{
|
{
|
||||||
dynamicSound.Stop(true);
|
sound.Stop(true);
|
||||||
dynamicSound.BufferNeeded -= new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
|
|
||||||
dynamicSound = null;
|
|
||||||
this.currentSong = null;
|
this.currentSong = null;
|
||||||
position = 0;
|
|
||||||
count = 0;
|
|
||||||
byteArray = new byte[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +191,7 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
/// Get the son's name from the path.
|
/// Get the son's name from the path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>11111111111111
|
||||||
public string getSongNameFromPath(string path)
|
public string getSongNameFromPath(string path)
|
||||||
{
|
{
|
||||||
foreach(var song in this.songInformation.listOfSongsWithoutTriggers)
|
foreach(var song in this.songInformation.listOfSongsWithoutTriggers)
|
||||||
|
@ -278,8 +217,8 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
|
|
||||||
public override bool isPlaying()
|
public override bool isPlaying()
|
||||||
{
|
{
|
||||||
if (this.dynamicSound == null) return false;
|
if (this.sound == null) return false;
|
||||||
if (this.dynamicSound.State == SoundState.Playing) return true;
|
if (this.sound.State == SoundState.Playing) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,36 +508,6 @@ namespace StardewSymphonyRemastered
|
||||||
Game1.soundBank = DefaultSoundBank;
|
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)
|
|
||||||
{
|
|
||||||
err.ToString();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DebugLog(string s)
|
public static void DebugLog(string s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Name": "Stardew Symphony Remastered",
|
"Name": "Stardew Symphony Remastered",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "2.1.5",
|
"Version": "2.1.6",
|
||||||
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
||||||
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
||||||
"EntryDll": "StardewSymphonyRemastered.dll",
|
"EntryDll": "StardewSymphonyRemastered.dll",
|
||||||
|
|
|
@ -23,12 +23,7 @@ namespace StardustCore.NetCode.Graphics
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetString currentAnimationName;
|
|
||||||
public NetInt currentAnimationListIndex;
|
|
||||||
public NetTexture2DExtended objectTexture;
|
|
||||||
public NetAnimation defaultDrawFrame;
|
|
||||||
public NetBool enabled;
|
|
||||||
public NetString animationDataString;
|
|
||||||
|
|
||||||
protected override void ReadDelta(BinaryReader reader, NetVersion version)
|
protected override void ReadDelta(BinaryReader reader, NetVersion version)
|
||||||
{
|
{
|
||||||
|
@ -64,13 +59,13 @@ namespace StardustCore.NetCode.Graphics
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Value.currentAnimation = defaultDrawFrame.Value;
|
Value.currentAnimation = defaultAnimation.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WriteDelta(BinaryWriter writer)
|
protected override void WriteDelta(BinaryWriter writer)
|
||||||
{
|
{
|
||||||
NetString curentAnimationName = new NetString(Value.currentAnimationName);
|
NetString currentAnimationName = new NetString(Value.currentAnimationName);
|
||||||
currentAnimationName.Write(writer);
|
currentAnimationName.Write(writer);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue