Merge pull request #458 from Stefan1200-de/ReloadSongFromDisk_develop-patch

Reload song from disk / key shortcut for skipping 30 seconds while singing
This commit is contained in:
Stefan authored and GitHub committed 2020-01-26 17:47:54 +01:00
commit 63da979409
3 files changed
+56 -3

No files matched your search

+40 -2
View File
@@ -30,6 +30,7 @@ using VocaluxeLib.Draw;
using VocaluxeLib.Log; using VocaluxeLib.Log;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SingNotes; using VocaluxeLib.Menu.SingNotes;
using VocaluxeLib.PartyModes;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
namespace Vocaluxe.Screens namespace Vocaluxe.Screens
@@ -133,6 +134,7 @@ namespace Vocaluxe.Screens
private bool _Webcam; private bool _Webcam;
private CBackground _SlideShow; private CBackground _SlideShow;
private SScreenSongOptions _Sso;
public override EMusicType CurrentMusicType public override EMusicType CurrentMusicType
{ {
@@ -288,6 +290,38 @@ namespace Vocaluxe.Screens
if (CConfig.Config.Debug.SaveModifiedSongs == EOffOn.TR_CONFIG_ON) if (CConfig.Config.Debug.SaveModifiedSongs == EOffOn.TR_CONFIG_ON)
song.Save(); song.Save();
break; break;
// Restart Round and reload song file header
case Keys.R:
if (keyEvent.Mod == EModifier.Ctrl && _Pause)
{
_SetPause(false);
_RestartRound();
}
break;
// Restart Round and reload song file header
case Keys.F5:
if (_Pause)
{
_SetPause(false);
_RestartRound();
}
break;
// Skip 30 seconds
case Keys.Right:
if (keyEvent.Mod == EModifier.Ctrl && !_Pause && !_Sso.Selection.PartyMode)
{
if (_TimerSongText.IsRunning)
_TimerSongText.Stop();
float newTime = _CurrentTime + 30f;
if (CSound.GetLength(_CurrentStream) < (_CurrentTime + 30f))
newTime = CSound.GetLength(_CurrentStream) - 1f;
CSound.SetPosition(_CurrentStream, newTime);
}
break;
} }
} }
@@ -357,6 +391,7 @@ namespace Vocaluxe.Screens
_SetPause(false); _SetPause(false);
_TimeRects.Clear(); _TimeRects.Clear();
_Sso = CParty.GetSongSelectionOptions();
_SingNotes[_SingBars].Init(0); _SingNotes[_SingBars].Init(0);
_AssignPlayerElements(); _AssignPlayerElements();
@@ -963,7 +998,7 @@ namespace Vocaluxe.Screens
_CloseSong(); _CloseSong();
CGame.ResetPlayer(); CGame.ResetPlayer();
_LoadCurrentSong(); _LoadCurrentSong(false);
_StartSong(); _StartSong();
} }
@@ -1043,7 +1078,7 @@ namespace Vocaluxe.Screens
/// <summary> /// <summary>
/// Prepare streams and screen for current song. /// Prepare streams and screen for current song.
/// </summary> /// </summary>
private void _LoadCurrentSong() private void _LoadCurrentSong(bool reloadNotes = true)
{ {
if (CGame.IsFinished()) if (CGame.IsFinished())
{ {
@@ -1059,6 +1094,9 @@ namespace Vocaluxe.Screens
return; return;
} }
if (!_Sso.Selection.PartyMode && (CGame.GameMode == EGameMode.TR_GAMEMODE_NORMAL || CGame.GameMode == EGameMode.TR_GAMEMODE_DUET))
song.ReloadSong(reloadNotes);
string songname = song.Artist + " - " + song.Title; string songname = song.Artist + " - " + song.Title;
int rounds = CGame.GetNumSongs(); int rounds = CGame.GetNumSongs();
if (rounds > 1) if (rounds > 1)
+11
View File
@@ -288,6 +288,17 @@ namespace VocaluxeLib.Songs
return loader.ReadNotes(); return loader.ReadNotes();
} }
public bool ReloadSong(bool reloadNotes)
{
var loader = new CSongLoader(this);
bool retValue = loader.ReadHeader();
if (!retValue)
return false;
retValue = loader.ReadNotes(reloadNotes);
return retValue;
}
public bool Save() public bool Save()
{ {
return Save(Path.Combine(Folder, FileName)); return Save(Path.Combine(Folder, FileName));
+5 -1
View File
@@ -82,12 +82,16 @@ namespace VocaluxeLib.Songs
_Song.Languages.Clear(); _Song.Languages.Clear();
_Song.Genres.Clear(); _Song.Genres.Clear();
_Song.UnknownTags.Clear(); _Song.UnknownTags.Clear();
_Song.BackgroundFileNames.Clear();
_Song._Comment = ""; _Song._Comment = "";
_Song.ManualEncoding = false; _Song.ManualEncoding = false;
_Song.Medley.Source = EDataSource.None; _Song.Medley.Source = EDataSource.None;
_Song._CalculateMedley = true; _Song._CalculateMedley = true;
_Song.Preview.Source = EDataSource.None; _Song.Preview.Source = EDataSource.None;
_Song.ShortEnd.Source = EDataSource.None; _Song.ShortEnd.Source = EDataSource.None;
_Song.Start = 0;
_Song.VideoGap = 0;
_Song.Preview.StartTime = 0;
var headerFlags = new EHeaderFlags(); var headerFlags = new EHeaderFlags();
StreamReader sr = null; StreamReader sr = null;
@@ -761,4 +765,4 @@ namespace VocaluxeLib.Songs
} }
} }
} }
} }