public static void LoadSongs() { CLog.StartBenchmark(1, "Load Songs"); _SongsLoaded = false; _Songs.Clear(); CLog.StartBenchmark(2, "List Songs"); List <string> files = new List <string>(); foreach (string p in CConfig.SongFolder) { string path = p; files.AddRange(Helper.ListFiles(path, "*.txt", true, true)); files.AddRange(Helper.ListFiles(path, "*.txd", true, true)); } CLog.StopBenchmark(2, "List Songs"); CLog.StartBenchmark(2, "Read TXTs"); foreach (string file in files) { CSong Song = new CSong(); if (Song.ReadTXTSong(file)) { Song.ID = _Songs.Count; _Songs.Add(Song); } } CLog.StopBenchmark(2, "Read TXTs"); CLog.StartBenchmark(2, "Sort Songs"); Sort(CConfig.SongSorting); CLog.StopBenchmark(2, "Sort Songs"); Category = -1; _SongsLoaded = true; if (CConfig.Renderer != ERenderer.TR_CONFIG_SOFTWARE && CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART) { CLog.StartBenchmark(2, "Load Cover"); for (int i = 0; i < _Songs.Count; i++) { CSong song = _Songs[i]; song.ReadNotes(); STexture texture = song.CoverTextureSmall; song.CoverTextureBig = texture; _CoverLoadIndex++; } _CoverLoaded = true; CDataBase.CommitCovers(); CLog.StopBenchmark(2, "Load Cover"); } CLog.StopBenchmark(1, "Load Songs "); }
public static void Init() { _BGMusicFileNames.AddRange(Helper.ListFiles(CSettings.sFolderBackgroundMusic, "*.mp3", true, true)); _BGMusicFileNames.AddRange(Helper.ListFiles(CSettings.sFolderBackgroundMusic, "*.wav", true, true)); _BGMusicFileNames.AddRange(Helper.ListFiles(CSettings.sFolderBackgroundMusic, "*.ogg", true, true)); _BGMusicFileNames.AddRange(Helper.ListFiles(CSettings.sFolderBackgroundMusic, "*.wma", true, true)); if (CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC) { AddBackgroundMusic(); } _Playing = false; }
public static void LoadProfiles() { _Profiles = new List <SProfile>(); List <string> files = new List <string>(); files.AddRange(Helper.ListFiles(CSettings.sFolderProfiles, "*.xml", true, true)); foreach (string file in files) { LoadProfile(file); } SortProfilesByName(); }
public static void Init() { List <string> templist = new List <string>(); foreach (string ending in CSettings.MusicFileTypes) { templist.AddRange(Helper.ListFiles(CSettings.sFolderBackgroundMusic, ending, true, true)); } foreach (string path in templist) { _BGMusicFileNames.Add(new PlaylistElement(path)); } if (CConfig.BackgroundMusicSource != EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC) { AddBackgroundMusic(); } if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) { _VideoEnabled = true; } _Playing = false; }
/// <summary> /// Loads all cover-themes to list. /// </summary> private static void _LoadCoverThemes() { _CoverThemes.Clear(); string folderPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover); IEnumerable <string> files = CHelper.ListFiles(folderPath, "*.xml"); var xml = new CXmlDeserializer(); foreach (string file in files) { SThemeCover theme; try { theme = xml.Deserialize <SThemeCover>(Path.Combine(folderPath, file)); } catch (CXmlException e) { CLog.Error("Error loading cover theme " + file + ": " + e); continue; } if (!String.IsNullOrEmpty(theme.Info.Folder) && !String.IsNullOrEmpty(theme.Info.Name)) { theme.FolderPath = Path.Combine(folderPath, theme.Info.Folder); _CoverThemes.Add(theme); } } }
public static bool LoadPartyLanguageFiles(int partyModeID, string path) { var files = new List <string>(); files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); return(files.All(file => _LoadPartyLanguageFile(partyModeID, file))); }
public static void LoadSongs() { CLog.StartBenchmark("Load Songs"); SongsLoaded = false; _Songs.Clear(); CLog.StartBenchmark("List Songs"); var files = new List <string>(); foreach (string p in CConfig.SongFolders) { if (Directory.Exists(p)) { string path = p; files.AddRange(CHelper.ListFiles(path, "*.txt", true, true)); files.AddRange(CHelper.ListFiles(path, "*.txd", true, true)); } } CLog.StopBenchmark("List Songs"); CLog.StartBenchmark("Read TXTs"); foreach (string file in files) { CSong song = CSong.LoadSong(file); if (song == null) { continue; } song.ID = _Songs.Count; if (song.LoadNotes()) { _Songs.Add(song); } } CLog.StopBenchmark("Read TXTs"); CLog.StartBenchmark("Sort Songs"); Sorter.SongSorting = CConfig.Config.Game.SongSorting; Sorter.IgnoreArticles = CConfig.Config.Game.IgnoreArticles; Categorizer.Tabs = CConfig.Config.Game.Tabs; Categorizer.ObjectChanged += _HandleCategoriesChanged; CLog.StopBenchmark("Sort Songs"); Category = -1; SongsLoaded = true; switch (CConfig.Config.Theme.CoverLoading) { case ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART: _LoadCovers(); break; case ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC: _LoadCoversAsync(); break; } CLog.StopBenchmark("Load Songs"); }
public static bool Init() { var files = new List <string>(); files.AddRange(CHelper.ListFiles(CSettings.FolderNameLanguages, "*.xml", true, true)); foreach (string file in files) { _LoadLanguageFile(file); } return(_CurrentLanguage >= 0 && _FallbackLanguage >= 0); }
private static void _ConvertUSDXPlaylists() { var files = new List <string>(); files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataFolder, CConfig.FolderPlaylists), "*.upl", true, true)); foreach (string file in files) { CPlaylistFile playlist = _ConvertUSDXPlaylist(file); playlist.Save(); _Playlists.Add(playlist); } }
/// <summary> /// Loads all cover-themes to list. /// </summary> private static void LoadCoverThemes() { _CoverThemes.Clear(); CHelper Helper = new CHelper(); string path = CSettings.sFolderCover; List <string> files = Helper.ListFiles(path, "*.xml", false); foreach (string file in files) { bool loaded = false; XPathDocument xPathDoc = null; XPathNavigator navigator = null; try { xPathDoc = new XPathDocument(Path.Combine(path, file)); navigator = xPathDoc.CreateNavigator(); loaded = true; } catch (Exception) { loaded = false; if (navigator != null) { navigator = null; } if (xPathDoc != null) { xPathDoc = null; } } if (loaded) { SCoverTheme coverTheme = new SCoverTheme(); CHelper.GetValueFromXML("//root/Info/Name", navigator, ref coverTheme.Name, String.Empty); CHelper.GetValueFromXML("//root/Info/Folder", navigator, ref coverTheme.Folder, String.Empty); if (coverTheme.Folder != String.Empty && coverTheme.Name != String.Empty) { coverTheme.File = file; _CoverThemes.Add(coverTheme); } } } }
public static void LoadPlaylists() { _Playlists = new List <CPlaylistFile>(); List <string> files = new List <string>(); files.AddRange(Helper.ListFiles(CSettings.sFolderPlaylists, "*.xml", true, true)); foreach (string file in files) { CPlaylistFile playlist = new CPlaylistFile(file); _Playlists.Add(playlist); } SortPlaylistsByName(); }
private static void _LoadPartyModes() { var files = new List <string>(); files.AddRange(CHelper.ListFiles(CSettings.FolderNamePartyModes, "*.xml", false, true)); foreach (string file in files) { SPartyMode pm; if (_LoadPartyMode(file, out pm)) { _PartyModes.Add(pm.PartyMode.ID, pm); } } }
private static void _LoadProfiles() { _LoadAvatars(); var knownFiles = new List <string>(); if (_Profiles.Count > 0) { var ids = new int[_Profiles.Keys.Count]; _Profiles.Keys.CopyTo(ids, 0); foreach (int id in ids) { if (_Profiles[id].LoadProfile()) { knownFiles.Add(Path.GetFileName(_Profiles[id].FilePath)); } else { _Profiles.Remove(id); } } } var files = new List <string>(); foreach (string path in CConfig.ProfileFolders) { files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); } foreach (string file in files) { if (knownFiles.Contains(Path.GetFileName(file))) { continue; } var profile = new CProfile(); if (profile.LoadProfile(file)) { profile.ID = _ProfileIDs.Dequeue(); _Profiles.Add(profile.ID, profile); } } _ProfilesChanged = true; }
public static void Init() { _Languages = new List <SLanguage>(); _settings.Indent = true; _settings.Encoding = System.Text.Encoding.UTF8; _settings.ConformanceLevel = ConformanceLevel.Document; List <string> files = new List <string>(); files.AddRange(Helper.ListFiles(CSettings.sFolderLanguages, "*.xml", true, true)); foreach (string file in files) { LoadLanguageFile(file); } }
public static void Load() { _Playlists = new List <CPlaylistFile>(); var files = new List <string>(); files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataFolder, CConfig.FolderPlaylists), "*.xml", true, true)); foreach (string file in files) { CPlaylistFile playlist = new CPlaylistFile(); if (playlist._Load(file)) { _Playlists.Add(playlist); } } }
/// <summary> /// Loads all cover which are defined in the cover config file. /// </summary> private static void LoadCover(string coverThemeName) { SCoverTheme coverTheme = new SCoverTheme(); coverTheme = CoverTheme(coverThemeName); if (coverTheme.Name != String.Empty) { bool loaded = false; XPathDocument xPathDoc = null; XPathNavigator navigator = null; try { xPathDoc = new XPathDocument(Path.Combine(CSettings.sFolderCover, coverTheme.File)); navigator = xPathDoc.CreateNavigator(); loaded = true; } catch (Exception) { loaded = false; if (navigator != null) { navigator = null; } if (xPathDoc != null) { xPathDoc = null; } } if (loaded) { lock (_MutexCover) { _Cover.Clear(); List <string> cover = CHelper.GetValuesFromXML("Cover", navigator); for (int i = 0; i < cover.Count; i++) { SCover sk = new SCover(); string name = String.Empty; string value = String.Empty; CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Name", navigator, ref name, String.Empty); CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Path", navigator, ref value, String.Empty); sk.Name = name; sk.Value = Path.Combine(coverTheme.Folder, value); if (File.Exists(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value)))) { sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value))); } else { sk.Texture = _NoCover; } _Cover.Add(sk); if (sk.Name == "NoCover") { _NoCover = sk.Texture; } } } } CHelper Helper = new CHelper(); List <string> files = new List <string>(); files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.png", true, true)); files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpg", true, true)); files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpeg", true, true)); files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.bmp", true, true)); foreach (string file in files) { string name = Path.GetFileNameWithoutExtension(file); if (!CoverExists(name)) { SCover sk = new SCover(); string value = String.Empty; sk.Name = name; sk.Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file)); sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, sk.Value)); _Cover.Add(sk); } } } }
private async static void _LoadProfiles() { _LoadAvatars(); var knownFiles = new List <string>(); if (_Profiles.Count > 0) { var ids = new Guid[_Profiles.Keys.Count]; _Profiles.Keys.CopyTo(ids, 0); foreach (Guid id in ids) { if (_Profiles[id].LoadProfile()) { knownFiles.Add(Path.GetFileName(_Profiles[id].FilePath)); } else { _Profiles.Remove(id); } } } if (CConfig.UseCloudServer) { string json = JsonConvert.SerializeObject(new { Key = CConfig.CloudServerKey }); var content = new StringContent(json, Encoding.UTF8, "application/json"); string responseString = ""; var response = await _Client.PostAsync(CConfig.CloudServerURL + "/api/getProfiles", content); responseString = await response.Content.ReadAsStringAsync(); CProfile[] CloudProfiles = JsonConvert.DeserializeObject <CProfile[]>(responseString); Console.Write(CloudProfiles); foreach (CProfile profile in CloudProfiles) { _Profiles.Add(profile.ID, profile); } } else { var files = new List <string>(); foreach (string path in CConfig.ProfileFolders) { files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); } foreach (string file in files) { if (knownFiles.Contains(Path.GetFileName(file))) { continue; } var profile = new CProfile(); if (profile.LoadProfile(file)) { _Profiles.Add(profile.ID, profile); } } } _ProfilesChanged = true; }
public static void ListSkins() { CHelper Helper = new CHelper(); int themeIndex = GetThemeIndex(); _Skins.Clear(); if (themeIndex < 0) { CLog.LogError("Error List Skins. Can't find Theme: " + CConfig.Theme); return; } Theme theme = _Themes[themeIndex]; string path = Path.Combine(theme.Path, theme.SkinFolder); List <string> files = Helper.ListFiles(path, "*.xml", false); foreach (string file in files) { bool loaded = false; XPathDocument xPathDoc = null; XPathNavigator navigator = null; try { xPathDoc = new XPathDocument(Path.Combine(path, file)); navigator = xPathDoc.CreateNavigator(); loaded = true; } catch (Exception e) { CLog.LogError("Error loading skin " + file + ": " + e.Message); loaded = false; if (navigator != null) { navigator = null; } if (xPathDoc != null) { xPathDoc = null; } } if (loaded) { Skin skin = new Skin(); int version = 0; CHelper.TryGetIntValueFromXML("//root/SkinSystemVersion", navigator, ref version); if (version == SkinSystemVersion) { CHelper.GetValueFromXML("//root/Info/Name", navigator, ref skin.Name, String.Empty); if (skin.Name != String.Empty) { CHelper.GetValueFromXML("//root/Info/Author", navigator, ref skin.Author, String.Empty); CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMajor", navigator, ref skin.SkinVersionMajor); CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMinor", navigator, ref skin.SkinVersionMinor); skin.Path = path; skin.FileName = file; skin.SkinList = new Dictionary <string, SkinElement>(); List <string> names = CHelper.GetValuesFromXML("Skins", navigator); foreach (string str in names) { SkinElement sk = new SkinElement(); sk.Name = str; sk.Value = String.Empty; skin.SkinList[str] = sk; } skin.VideoList = new List <SkinElement>(); names = CHelper.GetValuesFromXML("Videos", navigator); foreach (string str in names) { SkinElement sk = new SkinElement(); sk.Name = str; sk.Value = String.Empty; skin.VideoList.Add(sk); } _Skins.Add(skin); } } else { string msg = "Can't load Skin \"" + file + "\", "; if (version < SkinSystemVersion) { msg += "the file ist outdated! "; } else { msg += "the file is for newer program versions! "; } msg += "Current SkinSystemVersion is " + SkinSystemVersion.ToString(); CLog.LogError(msg); } } } }
private static bool _LoadPartyMode(string filePath, out SPartyMode pm) { CXmlDeserializer deser = new CXmlDeserializer(); try { pm = deser.Deserialize <SPartyMode>(filePath); if (pm.PartyModeSystemVersion != _PartyModeSystemVersion) { throw new Exception("Wrong PartyModeSystemVersion " + pm.PartyModeSystemVersion + " expected: " + _PartyModeSystemVersion); } if (pm.ScreenFiles.Count == 0) { throw new Exception("No ScreenFiles found"); } } catch (Exception e) { pm = new SPartyMode(); CLog.LogError("Error loading PartyMode file " + filePath + ": " + e.Message); return(false); } string pathToPm = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNamePartyModes, pm.Info.Folder); string pathToCode = Path.Combine(pathToPm, CSettings.FolderNamePartyModeCode); var filesToCompile = new List <string>(); filesToCompile.AddRange(CHelper.ListFiles(pathToCode, "*.cs", false, true)); Assembly output = _CompileFiles(filesToCompile.ToArray()); if (output == null) { return(false); } object instance = output.CreateInstance(typeof(IPartyMode).Namespace + "." + pm.Info.Folder + "." + pm.Info.PartyModeFile, false, BindingFlags.Public | BindingFlags.Instance, null, new object[] { _NextID++ }, null, null); if (instance == null) { CLog.LogError("Error creating Instance of PartyMode file: " + filePath); return(false); } try { pm.PartyMode = (IPartyMode)instance; } catch (Exception e) { CLog.LogError("Error casting PartyMode file: " + filePath + "; " + e.Message); return(false); } if (!CLanguage.LoadPartyLanguageFiles(pm.PartyMode.ID, Path.Combine(pathToPm, CSettings.FolderNamePartyModeLanguages))) { CLog.LogError("Error loading language files for PartyMode: " + filePath); return(false); } if (!CThemes.ReadThemesFromFolder(Path.Combine(pathToPm, CSettings.FolderNameThemes), pm.PartyMode.ID)) { return(false); } if (!CThemes.LoadPartymodeTheme(pm.PartyMode.ID)) { return(false); } foreach (string screenfile in pm.ScreenFiles) { CMenuParty screen = _GetPartyScreenInstance(output, screenfile, pm.Info.Folder); if (screen != null) { screen.AssignPartyMode(pm.PartyMode); pm.PartyMode.AddScreen(screen, screenfile); } else { return(false); } } pm.PartyMode.LoadTheme(); pm.Info.ExtInfo = pm.PartyMode; return(true); }
private static void ListThemes() { CHelper Helper = new CHelper(); _Themes.Clear(); string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderThemes); List <string> files = Helper.ListFiles(path, "*.xml", false); foreach (string file in files) { bool loaded = false; XPathDocument xPathDoc = null; XPathNavigator navigator = null; try { xPathDoc = new XPathDocument(Path.Combine(path, file)); navigator = xPathDoc.CreateNavigator(); loaded = true; } catch (Exception e) { CLog.LogError("Error loading theme " + file + ": " + e.Message); loaded = false; if (navigator != null) { navigator = null; } if (xPathDoc != null) { xPathDoc = null; } } if (loaded) { Theme theme = new Theme(); int version = 0; CHelper.TryGetIntValueFromXML("//root/ThemeSystemVersion", navigator, ref version); if (version == ThemeSystemVersion) { CHelper.GetValueFromXML("//root/Info/Name", navigator, ref theme.Name, String.Empty); if (theme.Name != String.Empty) { CHelper.GetValueFromXML("//root/Info/Author", navigator, ref theme.Author, String.Empty); CHelper.GetValueFromXML("//root/Info/SkinFolder", navigator, ref theme.SkinFolder, String.Empty); CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMajor", navigator, ref theme.ThemeVersionMajor); CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMinor", navigator, ref theme.ThemeVersionMinor); theme.Path = path; theme.FileName = file; _Themes.Add(theme); } } else { string msg = "Can't load Theme \"" + file + "\", "; if (version < ThemeSystemVersion) { msg += "the file ist outdated! "; } else { msg += "the file is for newer program versions! "; } msg += "Current ThemeSystemVersion is " + ThemeSystemVersion.ToString(); CLog.LogError(msg); } } } }