From b248c4b2bdbb247a66b8b1ce6846375c5b3ebf6b Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 7 Jan 2020 09:27:46 +0100 Subject: [PATCH 01/14] Reload Song From Disk - develop Reload Song From Disk using F5 or CTRL+R while in pause menu --- Vocaluxe/Screens/CScreenSing.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index b5eb65ed..ad5a5c59 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -287,6 +287,25 @@ namespace Vocaluxe.Screens if (CConfig.Config.Debug.SaveModifiedSongs == EOffOn.TR_CONFIG_ON) song.Save(); break; + + case Keys.R: + if (keyEvent.Mod == EModifier.Ctrl) + { + if (_Pause) + { + _SetPause(false); + _RestartRound(); + } + } + break; + + case Keys.F5: + if (_Pause) + { + _SetPause(false); + _RestartRound(); + } + break; } } @@ -1054,6 +1073,7 @@ namespace Vocaluxe.Screens } CSong song = CGame.GetSong(); + song.ReloadSong(); if (song == null) { @@ -1828,4 +1848,4 @@ namespace Vocaluxe.Screens } } } -} \ No newline at end of file +} From 791d2293d3652e3f8c88498035ef468c5e8576ec Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 7 Jan 2020 09:29:49 +0100 Subject: [PATCH 02/14] Added ReloadSong() to reload a song from disk --- VocaluxeLib/Songs/CSong.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index e6ddaf4d..8a63b605 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -288,6 +288,14 @@ namespace VocaluxeLib.Songs return loader.ReadNotes(); } + public bool ReloadSong() + { + var loader = new CSongLoader(this); + bool retValue = loader.ReadHeader(); + retValue = loader.ReadNotes(true); + return retValue; + } + public bool Save() { return Save(Path.Combine(Folder, FileName)); @@ -518,4 +526,4 @@ namespace VocaluxeLib.Songs ShortEnd.Source = EDataSource.Calculated; } } -} \ No newline at end of file +} From a4df215654791c1b3f086438e8cfd05772152ff2 Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 7 Jan 2020 09:31:40 +0100 Subject: [PATCH 03/14] Some fixes to allow reload a song from disk --- VocaluxeLib/Songs/CSongLoader.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs index 99702bc8..965176e0 100644 --- a/VocaluxeLib/Songs/CSongLoader.cs +++ b/VocaluxeLib/Songs/CSongLoader.cs @@ -88,6 +88,9 @@ namespace VocaluxeLib.Songs _Song._CalculateMedley = true; _Song.Preview.Source = EDataSource.None; _Song.ShortEnd.Source = EDataSource.None; + _Song.Start = 0; + _Song.VideoGap = 0; + _Song.Preview.StartTime = 0; var headerFlags = new EHeaderFlags(); StreamReader sr = null; @@ -761,4 +764,4 @@ namespace VocaluxeLib.Songs } } } -} \ No newline at end of file +} From a36ee3e389e83ea4d37a3424fca35f6c621cfbbc Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 18 Jan 2020 23:05:47 +0100 Subject: [PATCH 04/14] Added key to skip 30 seconds and don't reload notes from pause menu --- Vocaluxe/Screens/CScreenSing.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 0134dadd..8320805a 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -289,6 +289,7 @@ namespace Vocaluxe.Screens song.Save(); break; + // Restart Round and reload song file header case Keys.R: if (keyEvent.Mod == EModifier.Ctrl) { @@ -300,6 +301,7 @@ namespace Vocaluxe.Screens } break; + // Restart Round and reload song file header case Keys.F5: if (_Pause) { @@ -307,6 +309,23 @@ namespace Vocaluxe.Screens _RestartRound(); } break; + + // Skip 30 seconds + case Keys.Right: + if (keyEvent.Mod == EModifier.Ctrl) + { + if (!_Pause) + { + 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; } } @@ -982,7 +1001,7 @@ namespace Vocaluxe.Screens _CloseSong(); CGame.ResetPlayer(); - _LoadCurrentSong(); + _LoadCurrentSong(true); _StartSong(); } @@ -1062,7 +1081,7 @@ namespace Vocaluxe.Screens /// /// Prepare streams and screen for current song. /// - private void _LoadCurrentSong() + private void _LoadCurrentSong(bool restartRound = false) { if (CGame.IsFinished()) { @@ -1071,7 +1090,7 @@ namespace Vocaluxe.Screens } CSong song = CGame.GetSong(); - song.ReloadSong(); + song.ReloadSong(!restartRound); if (song == null) { From 872bcf776fa8a9555c224972dd10c46d6ba3ec0d Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 18 Jan 2020 23:07:17 +0100 Subject: [PATCH 05/14] Modified ReloadSong() to allow no notes reloading --- VocaluxeLib/Songs/CSong.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index 4d8e41f7..e507fd94 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -288,11 +288,11 @@ namespace VocaluxeLib.Songs return loader.ReadNotes(); } - public bool ReloadSong() + public bool ReloadSong(bool reloadNotes) { var loader = new CSongLoader(this); bool retValue = loader.ReadHeader(); - retValue = loader.ReadNotes(true); + retValue = loader.ReadNotes(reloadNotes); return retValue; } From 630a6242ae081036d7d2dc10cbae37226ba90df7 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 18 Jan 2020 23:12:00 +0100 Subject: [PATCH 06/14] Added key to skip 30 seconds and don't reload notes from pause menu --- Vocaluxe/Screens/CScreenSing.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 8320805a..c8e0d8ab 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -1001,7 +1001,7 @@ namespace Vocaluxe.Screens _CloseSong(); CGame.ResetPlayer(); - _LoadCurrentSong(true); + _LoadCurrentSong(false); _StartSong(); } @@ -1081,7 +1081,7 @@ namespace Vocaluxe.Screens /// /// Prepare streams and screen for current song. /// - private void _LoadCurrentSong(bool restartRound = false) + private void _LoadCurrentSong(bool reloadNotes = true) { if (CGame.IsFinished()) { @@ -1090,7 +1090,7 @@ namespace Vocaluxe.Screens } CSong song = CGame.GetSong(); - song.ReloadSong(!restartRound); + song.ReloadSong(reloadNotes); if (song == null) { From 3fcb22269afc8bd8a5706fb400be76f5d57122d2 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 18 Jan 2020 23:28:57 +0100 Subject: [PATCH 07/14] Small changes to make sure song variable will be used after null checking --- Vocaluxe/Screens/CScreenSing.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index c8e0d8ab..dab2ce04 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -1090,7 +1090,6 @@ namespace Vocaluxe.Screens } CSong song = CGame.GetSong(); - song.ReloadSong(reloadNotes); if (song == null) { @@ -1098,6 +1097,7 @@ namespace Vocaluxe.Screens return; } + song.ReloadSong(reloadNotes); string songname = song.Artist + " - " + song.Title; int rounds = CGame.GetNumSongs(); if (rounds > 1) From 64c0b392a90168137cbd2d8ae0e695063d6f4d79 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 19 Jan 2020 09:29:54 +0100 Subject: [PATCH 08/14] Removing two "Code Smells" --- Vocaluxe/Screens/CScreenSing.cs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index dab2ce04..843d7532 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -291,13 +291,10 @@ namespace Vocaluxe.Screens // Restart Round and reload song file header case Keys.R: - if (keyEvent.Mod == EModifier.Ctrl) + if (keyEvent.Mod == EModifier.Ctrl && _Pause) { - if (_Pause) - { - _SetPause(false); - _RestartRound(); - } + _SetPause(false); + _RestartRound(); } break; @@ -312,18 +309,15 @@ namespace Vocaluxe.Screens // Skip 30 seconds case Keys.Right: - if (keyEvent.Mod == EModifier.Ctrl) + if (keyEvent.Mod == EModifier.Ctrl && !_Pause) { - if (!_Pause) - { - if (_TimerSongText.IsRunning) - _TimerSongText.Stop(); + if (_TimerSongText.IsRunning) + _TimerSongText.Stop(); - float newTime = _CurrentTime + 30f; - if (CSound.GetLength(_CurrentStream) < (_CurrentTime + 30f)) - newTime = CSound.GetLength(_CurrentStream) - 1f; - CSound.SetPosition(_CurrentStream, newTime); - } + float newTime = _CurrentTime + 30f; + if (CSound.GetLength(_CurrentStream) < (_CurrentTime + 30f)) + newTime = CSound.GetLength(_CurrentStream) - 1f; + CSound.SetPosition(_CurrentStream, newTime); } break; } From 50426bdf3fb7b6c1fc059960553e0c45e8ddd2a1 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 19 Jan 2020 09:38:46 +0100 Subject: [PATCH 09/14] Disable CTRL+Arrow Right in party modes --- Vocaluxe/Screens/CScreenSing.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 843d7532..11009b7d 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -309,7 +309,8 @@ namespace Vocaluxe.Screens // Skip 30 seconds case Keys.Right: - if (keyEvent.Mod == EModifier.Ctrl && !_Pause) + SScreenSongOptions Sso = CParty.GetSongSelectionOptions(); + if (keyEvent.Mod == EModifier.Ctrl && !_Pause && !Sso.Selection.PartyMode) { if (_TimerSongText.IsRunning) _TimerSongText.Stop(); From 59808d1f9fdaf7f5d44dd598eefbfbb9da4e3a73 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 19 Jan 2020 09:51:31 +0100 Subject: [PATCH 10/14] Disable reloading song while party mode is active --- Vocaluxe/Screens/CScreenSing.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 11009b7d..be339a17 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -30,6 +30,7 @@ using VocaluxeLib.Draw; using VocaluxeLib.Log; using VocaluxeLib.Menu; using VocaluxeLib.Menu.SingNotes; +using VocaluxeLib.PartyModes; using VocaluxeLib.Songs; namespace Vocaluxe.Screens @@ -133,6 +134,7 @@ namespace Vocaluxe.Screens private bool _Webcam; private CBackground _SlideShow; + private SScreenSongOptions _Sso; public override EMusicType CurrentMusicType { @@ -309,8 +311,7 @@ namespace Vocaluxe.Screens // Skip 30 seconds case Keys.Right: - SScreenSongOptions Sso = CParty.GetSongSelectionOptions(); - if (keyEvent.Mod == EModifier.Ctrl && !_Pause && !Sso.Selection.PartyMode) + if (keyEvent.Mod == EModifier.Ctrl && !_Pause && !_Sso.Selection.PartyMode) { if (_TimerSongText.IsRunning) _TimerSongText.Stop(); @@ -390,6 +391,7 @@ namespace Vocaluxe.Screens _SetPause(false); _TimeRects.Clear(); + _Sso = CParty.GetSongSelectionOptions(); _SingNotes[_SingBars].Init(0); _AssignPlayerElements(); @@ -1092,7 +1094,9 @@ namespace Vocaluxe.Screens return; } - song.ReloadSong(reloadNotes); + if (!_Sso.Selection.PartyMode) + song.ReloadSong(reloadNotes); + string songname = song.Artist + " - " + song.Title; int rounds = CGame.GetNumSongs(); if (rounds > 1) From 183d4b12bf80989705e36128dd8e7091b0325908 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 19 Jan 2020 12:21:31 +0100 Subject: [PATCH 11/14] Change: Reload song from disk only at game mode normal This should fix issues while song reloading at short and medley game modes. In my opinion testing song txt file changes are in almost all cases only useful at normal game mode, so this change could be the final workaround. For checking different medley values in the txt file (MEDLEYSTARTBEAT / MEDLEYENDBEAT) you still have to restart the game. --- Vocaluxe/Screens/CScreenSing.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index be339a17..278e7965 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -1094,7 +1094,7 @@ namespace Vocaluxe.Screens return; } - if (!_Sso.Selection.PartyMode) + if (!_Sso.Selection.PartyMode && CGame.GameMode == EGameMode.TR_GAMEMODE_NORMAL) song.ReloadSong(reloadNotes); string songname = song.Artist + " - " + song.Title; From 57fac61c93a092bccc4d3114c6f65c1aea6cf30d Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 19 Jan 2020 16:23:31 +0100 Subject: [PATCH 12/14] Fix missing background image after reloading from disk --- VocaluxeLib/Songs/CSongLoader.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs index 965176e0..ca642b4c 100644 --- a/VocaluxeLib/Songs/CSongLoader.cs +++ b/VocaluxeLib/Songs/CSongLoader.cs @@ -82,6 +82,7 @@ namespace VocaluxeLib.Songs _Song.Languages.Clear(); _Song.Genres.Clear(); _Song.UnknownTags.Clear(); + _Song.BackgroundFileNames.Clear(); _Song._Comment = ""; _Song.ManualEncoding = false; _Song.Medley.Source = EDataSource.None; From a022f5c927b3d0718bde67db40ff42a2c046cf6b Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 19 Jan 2020 16:29:59 +0100 Subject: [PATCH 13/14] Fixed code smell --- VocaluxeLib/Songs/CSong.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index e507fd94..bc101698 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -292,6 +292,9 @@ namespace VocaluxeLib.Songs { var loader = new CSongLoader(this); bool retValue = loader.ReadHeader(); + if (!retValue) + return false; + retValue = loader.ReadNotes(reloadNotes); return retValue; } From 4e744c1c23c1d84b087db75b9edb55c6601e860e Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 26 Jan 2020 15:25:59 +0100 Subject: [PATCH 14/14] Allow song reloading from disk also for duet game mode --- Vocaluxe/Screens/CScreenSing.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 8c01fc55..2d3f3a75 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -1094,7 +1094,7 @@ namespace Vocaluxe.Screens return; } - if (!_Sso.Selection.PartyMode && CGame.GameMode == EGameMode.TR_GAMEMODE_NORMAL) + 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;