Remove loading of Covers from xml
This commit is contained in:
1 parent
41480797e2
commit
cbc3223114
1 file changed
+6
-39
+6
-39
@@ -177,62 +177,29 @@ namespace Vocaluxe.Base
|
|||||||
if (String.IsNullOrEmpty(coverTheme.Name))
|
if (String.IsNullOrEmpty(coverTheme.Name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var ignoreList = new List<string>();
|
|
||||||
|
|
||||||
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
|
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
|
||||||
List<string> files = CHelper.ListImageFiles(coverPath, true, true);
|
List<string> files = CHelper.ListImageFiles(coverPath, true, true);
|
||||||
|
|
||||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.File));
|
|
||||||
lock (_Covers)
|
lock (_Covers)
|
||||||
{
|
{
|
||||||
if (xmlReader != null)
|
|
||||||
{
|
|
||||||
_Covers.Clear();
|
|
||||||
List<string> cover = xmlReader.GetNames("//root/Cover/*");
|
|
||||||
foreach (string coverName in cover)
|
|
||||||
{
|
|
||||||
string name;
|
|
||||||
string filePath;
|
|
||||||
xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty);
|
|
||||||
xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out filePath, String.Empty);
|
|
||||||
string coverFilePath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder, filePath);
|
|
||||||
if (!File.Exists(coverFilePath))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
_AddCover(name, coverFilePath);
|
|
||||||
ignoreList.Add(Path.GetFileName(coverFilePath));
|
|
||||||
|
|
||||||
if (name == "NoCover")
|
|
||||||
NoCover = _Covers[name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
_AddCover(Path.GetFileNameWithoutExtension(file), file);
|
||||||
if (!ignoreList.Contains(Path.GetFileName(file)))
|
if (_CoverExists("No Cover"))
|
||||||
_AddCover(Path.GetFileNameWithoutExtension(file), file);
|
NoCover = _Covers["No Cover"];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ads a cover with the given name if it does not exist yet
|
/// Ads a cover with the given name if it does not exist yet
|
||||||
/// MUST HOLD _Covers lock at this point
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">Name of the cover</param>
|
/// <param name="name">Name of the cover</param>
|
||||||
/// <param name="file">Filename of image file</param>
|
/// <param name="file">Filename of image file</param>
|
||||||
private static void _AddCover(string name, string file)
|
private static void _AddCover(string name, string file)
|
||||||
{
|
{
|
||||||
CTexture texture = CDraw.AddTexture(file);
|
lock (_Covers)
|
||||||
|
|
||||||
if (!_CoverExists(name))
|
|
||||||
_Covers.Add(name, texture);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
CTexture tex = _Covers[name];
|
if (!_CoverExists(name))
|
||||||
CDraw.RemoveTexture(ref tex);
|
_Covers.Add(name, CDraw.AddTexture(file));
|
||||||
_Covers[name] = texture;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user