Merge branch 'develop' into FixSonarOrg

This commit is contained in:
lukeIam committed 2020-01-10 17:21:29 +01:00
commit 5c9c766b92
11 files changed
+43 -38

No files matched your search

+2 -2
View File
@@ -261,7 +261,7 @@
<Text Name="TextTitle"> <Text Name="TextTitle">
<X>60</X> <X>60</X>
<Y>50</Y> <Y>50</Y>
<Z>0</Z> <Z>-1</Z>
<H>27</H> <H>27</H>
<MaxW>0</MaxW> <MaxW>0</MaxW>
<Color Name="TextColor" /> <Color Name="TextColor" />
@@ -275,7 +275,7 @@
<Text Name="TextSong"> <Text Name="TextSong">
<X>640</X> <X>640</X>
<Y>50</Y> <Y>50</Y>
<Z>0</Z> <Z>-1</Z>
<H>27</H> <H>27</H>
<MaxW>0</MaxW> <MaxW>0</MaxW>
<Color Name="TextColor" /> <Color Name="TextColor" />
+1
View File
@@ -152,6 +152,7 @@ Global
{54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x64.ActiveCfg = Release|x64 {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|x64.Build.0 = Release|x64
{54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x86.ActiveCfg = Release|Win32 {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.ActiveCfg = Debug|x64
{8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x64.Build.0 = Debug|x64 {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x64.Build.0 = Debug|x64
{8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x86.ActiveCfg = Debug|x86 {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x86.ActiveCfg = Debug|x86
+1 -1
View File
@@ -157,7 +157,7 @@ namespace Vocaluxe.Base
if (_Initialized) if (_Initialized)
return; return;
List<string> soundFiles = CHelper.ListSoundFiles(CSettings.FolderNameBackgroundMusic, true, true); IEnumerable<string> soundFiles = CHelper.ListSoundFiles(CSettings.FolderNameBackgroundMusic, true, true);
foreach (string path in soundFiles) foreach (string path in soundFiles)
_BGMusicFiles.Add(new CPlaylistElement(path)); _BGMusicFiles.Add(new CPlaylistElement(path));
+2 -2
View File
@@ -174,7 +174,7 @@ namespace Vocaluxe.Base
_CoverThemes.Clear(); _CoverThemes.Clear();
string folderPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover); string folderPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover);
List<string> files = CHelper.ListFiles(folderPath, "*.xml"); IEnumerable<string> files = CHelper.ListFiles(folderPath, "*.xml");
var xml = new CXmlDeserializer(); var xml = new CXmlDeserializer();
foreach (string file in files) foreach (string file in files)
@@ -207,7 +207,7 @@ namespace Vocaluxe.Base
Debug.Assert(!String.IsNullOrEmpty(coverTheme.Info.Name)); Debug.Assert(!String.IsNullOrEmpty(coverTheme.Info.Name));
List<string> files = CHelper.ListImageFiles(coverTheme.FolderPath, true, true); IEnumerable<string> files = CHelper.ListImageFiles(coverTheme.FolderPath, true, true);
lock (_Covers) lock (_Covers)
{ {
+5 -6
View File
@@ -339,18 +339,17 @@ namespace Vocaluxe.Base
SongsLoaded = false; SongsLoaded = false;
_Songs.Clear(); _Songs.Clear();
var files = new List<string>(); var files = Enumerable.Empty<string>();
using (CBenchmark.Time("List Songs")) 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 = files.Union(CHelper.ListFiles(path, "*.txt", true, true));
files.AddRange(CHelper.ListFiles(path, "*.txt", true, true)); files = files.Union(CHelper.ListFiles(path, "*.txd", true, true));
files.AddRange(CHelper.ListFiles(path, "*.txd", true, true));
} }
} }
} }
+1 -1
View File
@@ -86,7 +86,7 @@ namespace Vocaluxe.Base.ThemeSystem
} }
string path = Path.Combine(_Folder, Name); string path = Path.Combine(_Folder, Name);
List<string> files = CHelper.ListFiles(path, "*.xml"); IEnumerable<string> files = CHelper.ListFiles(path, "*.xml");
// Load skins, succeed if at least 1 skin was loaded // Load skins, succeed if at least 1 skin was loaded
bool ok = false; bool ok = false;
+1 -1
View File
@@ -135,7 +135,7 @@ namespace Vocaluxe.Base.ThemeSystem
public static bool ReadThemesFromFolder(string path, int partyModeID) public static bool ReadThemesFromFolder(string path, int partyModeID)
{ {
List<string> files = CHelper.ListFiles(path, "*.xml", false, true); IEnumerable<string> files = CHelper.ListFiles(path, "*.xml", false, true);
List<CTheme> newThemes = new List<CTheme>(); List<CTheme> newThemes = new List<CTheme>();
foreach (string file in files) foreach (string file in files)
+14 -1
View File
@@ -994,7 +994,20 @@ namespace Vocaluxe.Screens
_CloseSong(); _CloseSong();
CGame.NextRound(); 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(); _LoadCurrentSong();
+12 -20
View File
@@ -20,6 +20,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq;
using VocaluxeLib.Log; using VocaluxeLib.Log;
namespace VocaluxeLib namespace VocaluxeLib
@@ -165,25 +166,20 @@ namespace VocaluxeLib
/// <param name="recursive">Search directories recursively</param> /// <param name="recursive">Search directories recursively</param>
/// <param name="fullpath">False for just file names, True for full path</param> /// <param name="fullpath">False for just file names, True for full path</param>
/// <returns>List of file names</returns> /// <returns>List of file names</returns>
public static List<string> ListFiles(string path, string searchPattern, bool recursive = false, bool fullpath = false) public static IEnumerable<string> ListFiles(string path, string searchPattern, bool recursive = false, bool fullpath = false)
{ {
var files = new List<string>(); IEnumerable<string> files = Enumerable.Empty<string>();
var dir = new DirectoryInfo(path); var dir = new DirectoryInfo(path);
if (!dir.Exists) if (!dir.Exists)
return files; return files;
if (recursive && !fullpath)
throw new NotSupportedException("recursive file listing with relative path names is not supported");
try try
{ {
// ReSharper disable LoopCanBeConvertedToQuery files = Directory.EnumerateFiles(dir.FullName, searchPattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
foreach (FileInfo file in dir.GetFiles(searchPattern)) files = files.Select(fullpath ? (Func<string, string>)Path.GetFullPath : Path.GetFileName);
// 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));
}
} }
catch (Exception) {} catch (Exception) {}
@@ -198,13 +194,9 @@ namespace VocaluxeLib
/// <param name="recursive">Search directories recursively</param> /// <param name="recursive">Search directories recursively</param>
/// <param name="fullpath">False for just file names, True for full path</param> /// <param name="fullpath">False for just file names, True for full path</param>
/// <returns>List of file names</returns> /// <returns>List of file names</returns>
public static List<string> ListFiles(string path, IEnumerable<string> searchPatterns, bool recursive = false, bool fullpath = false) public static IEnumerable<string> ListFiles(string path, IEnumerable<string> searchPatterns, bool recursive = false, bool fullpath = false)
{ {
var files = new List<string>(); return searchPatterns.SelectMany(pattern => ListFiles(path, pattern, recursive, fullpath));
foreach (string pattern in searchPatterns)
files.AddRange(ListFiles(path, pattern, recursive, fullpath));
return files;
} }
/// <summary> /// <summary>
@@ -214,7 +206,7 @@ namespace VocaluxeLib
/// <param name="recursive">Search directories recursively</param> /// <param name="recursive">Search directories recursively</param>
/// <param name="fullpath">False for just file names, True for full path</param> /// <param name="fullpath">False for just file names, True for full path</param>
/// <returns>List of image file names</returns> /// <returns>List of image file names</returns>
public static List<string> ListImageFiles(string path, bool recursive = false, bool fullpath = false) public static IEnumerable<string> ListImageFiles(string path, bool recursive = false, bool fullpath = false)
{ {
return ListFiles(path, _ImageFileTypes, recursive, fullpath); return ListFiles(path, _ImageFileTypes, recursive, fullpath);
} }
@@ -226,7 +218,7 @@ namespace VocaluxeLib
/// <param name="recursive">Search directories recursively</param> /// <param name="recursive">Search directories recursively</param>
/// <param name="fullpath">False for just file names, True for full path</param> /// <param name="fullpath">False for just file names, True for full path</param>
/// <returns>List of image file names</returns> /// <returns>List of image file names</returns>
public static List<string> ListSoundFiles(string path, bool recursive = false, bool fullpath = false) public static IEnumerable<string> ListSoundFiles(string path, bool recursive = false, bool fullpath = false)
{ {
return ListFiles(path, _SoundFileTypes, recursive, fullpath); return ListFiles(path, _SoundFileTypes, recursive, fullpath);
} }
+2 -2
View File
@@ -196,10 +196,10 @@ namespace VocaluxeLib.Log
int i = 0; int i = 0;
return theRegex.Replace(template, delegate(Match match) return theRegex.Replace(template, delegate(Match match)
{ {
if (propertyValues.Length >= i) if (i >= propertyValues.Length)
return match.Value; return match.Value;
return propertyValues[i++].ToString(); return propertyValues[i++].ToString();
}); });
} }
} }
+2 -2
View File
@@ -325,7 +325,7 @@ namespace VocaluxeLib.Songs
{ {
if (CoverFileName == "") if (CoverFileName == "")
{ {
List<string> files = CHelper.ListImageFiles(Folder); IEnumerable<string> files = CHelper.ListImageFiles(Folder);
foreach (String file in files) foreach (String file in files)
{ {
if (file.ContainsIgnoreCase("[CO]") && if (file.ContainsIgnoreCase("[CO]") &&
@@ -336,7 +336,7 @@ namespace VocaluxeLib.Songs
if (BackgroundFileNames.Count == 0) if (BackgroundFileNames.Count == 0)
{ {
List<string> files = CHelper.ListImageFiles(Folder); IEnumerable<string> files = CHelper.ListImageFiles(Folder);
foreach (String file in files) foreach (String file in files)
{ {
if (file.ContainsIgnoreCase("[BG]") && if (file.ContainsIgnoreCase("[BG]") &&