From 8b5bb563e61926ea16bfac4316fb3b597eba4a8b Mon Sep 17 00:00:00 2001 From: Jiiniasu Date: Thu, 12 Jul 2018 21:55:10 +0200 Subject: [PATCH 1/6] Horrible duet fix --- Vocaluxe/Screens/CScreenSing.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index e36dfbfd..b5eb65ed 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -994,7 +994,20 @@ namespace Vocaluxe.Screens _CloseSong(); CGame.NextRound(); - CGame.ResetPlayer(); + var voiceAssignments = new int[CGame.NumPlayers]; + if (CGame.GetSong() != null && CGame.GetSong().IsDuet) + { + //Save duet-assignment before resetting + for (int i = 0; i < voiceAssignments.Length; i++) + voiceAssignments[i] = CGame.Players[i].VoiceNr; + CGame.ResetPlayer(); + for (int i = 0; i < voiceAssignments.Length; i++) + CGame.Players[i].VoiceNr = voiceAssignments[i]; + } else + { + CGame.ResetPlayer(); + } + _LoadCurrentSong(); From b17b42a5d90511605775903ea0453cfce6811dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 17 Sep 2018 10:45:23 +0200 Subject: [PATCH 2/6] Fix #397 --- Vocaluxe.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/Vocaluxe.sln b/Vocaluxe.sln index 27cbd7c1..423e9884 100644 --- a/Vocaluxe.sln +++ b/Vocaluxe.sln @@ -152,6 +152,7 @@ Global {54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x64.ActiveCfg = Release|x64 {54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x64.Build.0 = Release|x64 {54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x86.ActiveCfg = Release|Win32 + {54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x86.Build.0 = Release|Win32 {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x64.ActiveCfg = Debug|x64 {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x64.Build.0 = Debug|x64 {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x86.ActiveCfg = Debug|x86 From ff6a0823adbe4499d002bf5fb510f1cf17d7f43c Mon Sep 17 00:00:00 2001 From: Jiiniasu Date: Sun, 30 Sep 2018 09:50:49 +0200 Subject: [PATCH 3/6] Fix wrong Z-index --- Output/Themes/Genius/Screens/ScreenScore.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Output/Themes/Genius/Screens/ScreenScore.xml b/Output/Themes/Genius/Screens/ScreenScore.xml index 6ebbf94a..8432d887 100644 --- a/Output/Themes/Genius/Screens/ScreenScore.xml +++ b/Output/Themes/Genius/Screens/ScreenScore.xml @@ -261,7 +261,7 @@ 60 50 - 0 + -1 27 0 @@ -275,7 +275,7 @@ 640 50 - 0 + -1 27 0 From 70be8f4d94acd0edca9cdd6802339a50204f75c8 Mon Sep 17 00:00:00 2001 From: Stefan Wurzinger Date: Mon, 22 Oct 2018 02:25:45 +0200 Subject: [PATCH 4/6] improve song enumeration performance --- Vocaluxe/Base/CSongs.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index d3670c80..555fe93e 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -339,18 +339,17 @@ namespace Vocaluxe.Base SongsLoaded = false; _Songs.Clear(); - var files = new List(); + var files = Enumerable.Empty(); using (CBenchmark.Time("List Songs")) { - foreach (string p in CConfig.SongFolders) + foreach (string path in CConfig.SongFolders) { - if (Directory.Exists(p)) + if (Directory.Exists(path)) { - string path = p; - files.AddRange(CHelper.ListFiles(path, "*.txt", true, true)); - files.AddRange(CHelper.ListFiles(path, "*.txd", true, true)); + files = files.Union(Directory.EnumerateFiles(path, "*.txt", SearchOption.AllDirectories)); + files = files.Union(Directory.EnumerateFiles(path, "*.txd", SearchOption.AllDirectories)); } } } From e70cb2a44a1a16035f61ed8cffff307f840c37e7 Mon Sep 17 00:00:00 2001 From: Stefan Wurzinger Date: Wed, 24 Oct 2018 00:19:22 +0200 Subject: [PATCH 5/6] fix log message formatter --- VocaluxeLib/Log/CLog.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VocaluxeLib/Log/CLog.cs b/VocaluxeLib/Log/CLog.cs index e2719273..2b78b8cb 100644 --- a/VocaluxeLib/Log/CLog.cs +++ b/VocaluxeLib/Log/CLog.cs @@ -196,10 +196,10 @@ namespace VocaluxeLib.Log int i = 0; return theRegex.Replace(template, delegate(Match match) { - if (propertyValues.Length >= i) + if (i >= propertyValues.Length) return match.Value; return propertyValues[i++].ToString(); - }); + }); } } From b5185d56b2741074f30ac331ef026d04e5ebf316 Mon Sep 17 00:00:00 2001 From: Stefan Wurzinger Date: Wed, 24 Oct 2018 01:07:22 +0200 Subject: [PATCH 6/6] ListFiles: enumerate files lazily --- Vocaluxe/Base/CBackgroundMusic.cs | 2 +- Vocaluxe/Base/CCover.cs | 4 ++-- Vocaluxe/Base/CSongs.cs | 4 ++-- Vocaluxe/Base/ThemeSystem/CTheme.cs | 2 +- Vocaluxe/Base/ThemeSystem/CThemes.cs | 2 +- VocaluxeLib/CHelper.cs | 32 +++++++++++----------------- VocaluxeLib/Songs/CSong.cs | 4 ++-- 7 files changed, 21 insertions(+), 29 deletions(-) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 19c47c19..5050b408 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -157,7 +157,7 @@ namespace Vocaluxe.Base if (_Initialized) return; - List soundFiles = CHelper.ListSoundFiles(CSettings.FolderNameBackgroundMusic, true, true); + IEnumerable soundFiles = CHelper.ListSoundFiles(CSettings.FolderNameBackgroundMusic, true, true); foreach (string path in soundFiles) _BGMusicFiles.Add(new CPlaylistElement(path)); diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index 6dea5e2f..3ac5a87b 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -174,7 +174,7 @@ namespace Vocaluxe.Base _CoverThemes.Clear(); string folderPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover); - List files = CHelper.ListFiles(folderPath, "*.xml"); + IEnumerable files = CHelper.ListFiles(folderPath, "*.xml"); var xml = new CXmlDeserializer(); foreach (string file in files) @@ -207,7 +207,7 @@ namespace Vocaluxe.Base Debug.Assert(!String.IsNullOrEmpty(coverTheme.Info.Name)); - List files = CHelper.ListImageFiles(coverTheme.FolderPath, true, true); + IEnumerable files = CHelper.ListImageFiles(coverTheme.FolderPath, true, true); lock (_Covers) { diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 555fe93e..3a442fea 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -348,8 +348,8 @@ namespace Vocaluxe.Base { if (Directory.Exists(path)) { - files = files.Union(Directory.EnumerateFiles(path, "*.txt", SearchOption.AllDirectories)); - files = files.Union(Directory.EnumerateFiles(path, "*.txd", SearchOption.AllDirectories)); + files = files.Union(CHelper.ListFiles(path, "*.txt", true, true)); + files = files.Union(CHelper.ListFiles(path, "*.txd", true, true)); } } } diff --git a/Vocaluxe/Base/ThemeSystem/CTheme.cs b/Vocaluxe/Base/ThemeSystem/CTheme.cs index 12ea5eaf..404517c0 100644 --- a/Vocaluxe/Base/ThemeSystem/CTheme.cs +++ b/Vocaluxe/Base/ThemeSystem/CTheme.cs @@ -86,7 +86,7 @@ namespace Vocaluxe.Base.ThemeSystem } string path = Path.Combine(_Folder, Name); - List files = CHelper.ListFiles(path, "*.xml"); + IEnumerable files = CHelper.ListFiles(path, "*.xml"); // Load skins, succeed if at least 1 skin was loaded bool ok = false; diff --git a/Vocaluxe/Base/ThemeSystem/CThemes.cs b/Vocaluxe/Base/ThemeSystem/CThemes.cs index 8ca65c47..1262c473 100644 --- a/Vocaluxe/Base/ThemeSystem/CThemes.cs +++ b/Vocaluxe/Base/ThemeSystem/CThemes.cs @@ -135,7 +135,7 @@ namespace Vocaluxe.Base.ThemeSystem public static bool ReadThemesFromFolder(string path, int partyModeID) { - List files = CHelper.ListFiles(path, "*.xml", false, true); + IEnumerable files = CHelper.ListFiles(path, "*.xml", false, true); List newThemes = new List(); foreach (string file in files) diff --git a/VocaluxeLib/CHelper.cs b/VocaluxeLib/CHelper.cs index 6c04fee7..20efe943 100644 --- a/VocaluxeLib/CHelper.cs +++ b/VocaluxeLib/CHelper.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Drawing; using System.Globalization; using System.IO; +using System.Linq; using VocaluxeLib.Log; namespace VocaluxeLib @@ -165,25 +166,20 @@ namespace VocaluxeLib /// Search directories recursively /// False for just file names, True for full path /// List of file names - public static List ListFiles(string path, string searchPattern, bool recursive = false, bool fullpath = false) + public static IEnumerable ListFiles(string path, string searchPattern, bool recursive = false, bool fullpath = false) { - var files = new List(); + IEnumerable files = Enumerable.Empty(); var dir = new DirectoryInfo(path); if (!dir.Exists) return files; + if (recursive && !fullpath) + throw new NotSupportedException("recursive file listing with relative path names is not supported"); + try { - // ReSharper disable LoopCanBeConvertedToQuery - foreach (FileInfo file in dir.GetFiles(searchPattern)) - // ReSharper restore LoopCanBeConvertedToQuery - files.Add(!fullpath ? file.Name : file.FullName); - - if (recursive) - { - foreach (DirectoryInfo di in dir.GetDirectories()) - files.AddRange(ListFiles(di.FullName, searchPattern, true, fullpath)); - } + files = Directory.EnumerateFiles(dir.FullName, searchPattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); + files = files.Select(fullpath ? (Func)Path.GetFullPath : Path.GetFileName); } catch (Exception) {} @@ -198,13 +194,9 @@ namespace VocaluxeLib /// Search directories recursively /// False for just file names, True for full path /// List of file names - public static List ListFiles(string path, IEnumerable searchPatterns, bool recursive = false, bool fullpath = false) + public static IEnumerable ListFiles(string path, IEnumerable searchPatterns, bool recursive = false, bool fullpath = false) { - var files = new List(); - foreach (string pattern in searchPatterns) - files.AddRange(ListFiles(path, pattern, recursive, fullpath)); - - return files; + return searchPatterns.SelectMany(pattern => ListFiles(path, pattern, recursive, fullpath)); } /// @@ -214,7 +206,7 @@ namespace VocaluxeLib /// Search directories recursively /// False for just file names, True for full path /// List of image file names - public static List ListImageFiles(string path, bool recursive = false, bool fullpath = false) + public static IEnumerable ListImageFiles(string path, bool recursive = false, bool fullpath = false) { return ListFiles(path, _ImageFileTypes, recursive, fullpath); } @@ -226,7 +218,7 @@ namespace VocaluxeLib /// Search directories recursively /// False for just file names, True for full path /// List of image file names - public static List ListSoundFiles(string path, bool recursive = false, bool fullpath = false) + public static IEnumerable ListSoundFiles(string path, bool recursive = false, bool fullpath = false) { return ListFiles(path, _SoundFileTypes, recursive, fullpath); } diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index fb9c033e..e6ddaf4d 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -325,7 +325,7 @@ namespace VocaluxeLib.Songs { if (CoverFileName == "") { - List files = CHelper.ListImageFiles(Folder); + IEnumerable files = CHelper.ListImageFiles(Folder); foreach (String file in files) { if (file.ContainsIgnoreCase("[CO]") && @@ -336,7 +336,7 @@ namespace VocaluxeLib.Songs if (BackgroundFileNames.Count == 0) { - List files = CHelper.ListImageFiles(Folder); + IEnumerable files = CHelper.ListImageFiles(Folder); foreach (String file in files) { if (file.ContainsIgnoreCase("[BG]") &&