private static void _Sort(ESongSorting sorting, EOffOn Tabs, string SearchString) { if (_Songs.Count == 0) { return; } _Categories.Clear(); string category = String.Empty; _Tabs = Tabs; List <SongPointer> _SortList = new List <SongPointer>(); List <CSong> _SongList = new List <CSong>(); foreach (CSong song in _Songs) { if (SearchString == String.Empty) { _SongList.Add(song); } else { if (song.Title.ToUpper().Contains(SearchString.ToUpper()) || song.Artist.ToUpper().Contains(SearchString.ToUpper())) { _SongList.Add(song); } } } switch (sorting) { case ESongSorting.TR_CONFIG_EDITION: foreach (CSong song in _SongList) { if (song.Edition.Count == 0) { _SortList.Add(new SongPointer(song.ID, String.Empty)); } else { for (int i = 0; i < song.Edition.Count; i++) { _SortList.Add(new SongPointer(song.ID, song.Edition[i])); } } } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { if (_SongsSortList[i].SortString.Length > 0) { if (_SongsSortList[i].SortString != category) { category = _SongsSortList[i].SortString; _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } else { if (CLanguage.Translate("TR_SCREENSONG_NOEDITION") != category) { category = CLanguage.Translate("TR_SCREENSONG_NOEDITION"); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } } break; case ESongSorting.TR_CONFIG_GENRE: foreach (CSong song in _SongList) { if (song.Genre.Count == 0) { _SortList.Add(new SongPointer(song.ID, String.Empty)); } else { for (int i = 0; i < song.Genre.Count; i++) { _SortList.Add(new SongPointer(song.ID, song.Genre[i])); } } } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { if (_SongsSortList[i].SortString.Length > 0) { if (_SongsSortList[i].SortString != category) { category = _SongsSortList[i].SortString; _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } else { if (CLanguage.Translate("TR_SCREENSONG_NOGENRE") != category) { category = CLanguage.Translate("TR_SCREENSONG_NOGENRE"); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } } break; case ESongSorting.TR_CONFIG_NONE: foreach (CSong song in _SongList) { _SortList.Add(new SongPointer(song.ID, String.Empty)); } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { _SongsSortList[i].CatIndex = 0; } category = CLanguage.Translate("TR_SCREENSONG_ALLSONGS"); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); break; case ESongSorting.TR_CONFIG_FOLDER: foreach (CSong song in _SongList) { _SortList.Add(new SongPointer(song.ID, song.FolderName)); } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { if (_SongsSortList[i].SortString != category) { category = _SongsSortList[i].SortString; _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } break; case ESongSorting.TR_CONFIG_ARTIST: foreach (CSong song in _SongList) { _SortList.Add(new SongPointer(song.ID, song.Artist)); } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { if (_SongsSortList[i].SortString != category) { category = _SongsSortList[i].SortString; _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } break; case ESongSorting.TR_CONFIG_ARTIST_LETTER: foreach (CSong song in _SongList) { _SortList.Add(new SongPointer(song.ID, song.Artist)); } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); int NotLetterCat = -1; for (int i = 0; i < _SongsSortList.Length; i++) { Char firstLetter = Char.ToUpper(_SongsSortList[i].SortString[0]); if (!Char.IsLetter(firstLetter)) { firstLetter = '#'; } if (firstLetter.ToString() != category) { if (firstLetter != '#' || NotLetterCat == -1) { category = firstLetter.ToString(); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); _SongsSortList[i].CatIndex = _Categories.Count - 1; if (firstLetter == '#') { NotLetterCat = _SongsSortList[i].CatIndex; } } else { _SongsSortList[i].CatIndex = NotLetterCat; } } else { _SongsSortList[i].CatIndex = _Categories.Count - 1; } } break; case ESongSorting.TR_CONFIG_TITLE_LETTER: foreach (CSong song in _SongList) { _SortList.Add(new SongPointer(song.ID, song.Title)); } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper())); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); NotLetterCat = -1; for (int i = 0; i < _SongsSortList.Length; i++) { Char firstLetter = Char.ToUpper(_SongsSortList[i].SortString[0]); if (!Char.IsLetter(firstLetter)) { firstLetter = '#'; } if (firstLetter.ToString() != category) { if (firstLetter != '#' || NotLetterCat == -1) { category = firstLetter.ToString(); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); _SongsSortList[i].CatIndex = _Categories.Count - 1; if (firstLetter == '#') { NotLetterCat = _SongsSortList[i].CatIndex; } } else { _SongsSortList[i].CatIndex = NotLetterCat; } } else { _SongsSortList[i].CatIndex = _Categories.Count - 1; } } break; case ESongSorting.TR_CONFIG_DECADE: foreach (CSong song in _SongList) { _SortList.Add(new SongPointer(song.ID, song.Year)); } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.CompareTo(s2.SortString); if (res == 0) { res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { if (_SongsSortList[i].SortString.Length > 0 && !_SongsSortList[i].SortString.Equals("0000")) { String decade = _SongsSortList[i].SortString.Substring(0, 3) + "0 - " + _SongsSortList[i].SortString.Substring(0, 3) + "9"; if (decade != category) { category = decade; _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } else { if (CLanguage.Translate("TR_SCREENSONG_NOYEAR") != category) { category = CLanguage.Translate("TR_SCREENSONG_NOYEAR"); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } } break; case ESongSorting.TR_CONFIG_YEAR: foreach (CSong song in _SongList) { _SortList.Add(new SongPointer(song.ID, song.Year)); } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.CompareTo(s2.SortString); if (res == 0) { res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { if (_SongsSortList[i].SortString.Length > 0 && !_SongsSortList[i].SortString.Equals("0000")) { if (_SongsSortList[i].SortString != category) { category = _SongsSortList[i].SortString; _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } else { if (CLanguage.Translate("TR_SCREENSONG_NOYEAR") != category) { category = CLanguage.Translate("TR_SCREENSONG_NOYEAR"); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } } break; case ESongSorting.TR_CONFIG_LANGUAGE: foreach (CSong song in _SongList) { if (song.Language.Count == 0) { _SortList.Add(new SongPointer(song.ID, String.Empty)); } else { for (int i = 0; i < song.Language.Count; i++) { _SortList.Add(new SongPointer(song.ID, song.Language[i])); } } } _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { int res = s1.SortString.CompareTo(s2.SortString); if (res == 0) { res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper()); if (res == 0) { return(_Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper())); } return(res); } return(res); }); _SongsSortList = _SortList.ToArray(); _Categories.Clear(); for (int i = 0; i < _SongsSortList.Length; i++) { if (_SongsSortList[i].SortString.Length > 0) { if (_SongsSortList[i].SortString != category) { category = _SongsSortList[i].SortString; _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } else { if (CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE") != category) { category = CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE"); _Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1))); } _SongsSortList[i].CatIndex = _Categories.Count - 1; } } break; default: break; } if (_Tabs == EOffOn.TR_CONFIG_OFF) { _Categories.Clear(); _Categories.Add(new CCategory("", new STexture(-1), new STexture(-1))); for (int i = 0; i < _SongsSortList.Length; i++) { _SongsSortList[i].CatIndex = 0; } } foreach (CCategory cat in _Categories) { STexture cover = CCover.Cover(cat.Name); cat.CoverTextureSmall = cover; } }
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); }
public bool TranslationExists(string keyWord) { return(CLanguage.TranslationExists(keyWord)); }
public string Translate(string keyWord, int partyModeID) { return(CLanguage.Translate(keyWord, partyModeID)); }
public string Translate(string keyWord) { return(CLanguage.Translate(keyWord)); }
public static RectangleF GetTextBounds(CText text, float height) { Height = height; return(new RectangleF(text.X, text.Y, GetTextWidth(CLanguage.Translate(text.Text)), GetTextHeight(CLanguage.Translate(text.Text)))); }
public static bool LoadConfig() { #region Inits bool loaded = false; XPathDocument xPathDoc = null; XPathNavigator navigator = null; try { xPathDoc = new XPathDocument(CSettings.sFileConfig); navigator = xPathDoc.CreateNavigator(); loaded = true; } catch (Exception) { CLog.LogError("Error opening Config.xml (FileName: " + CSettings.sFileConfig); loaded = false; if (navigator != null) { navigator = null; } if (xPathDoc != null) { xPathDoc = null; } } #endregion Inits if (loaded) { string value = string.Empty; #region Debug CHelper.TryGetEnumValueFromXML <EDebugLevel>("//root/Debug/DebugLevel", navigator, ref DebugLevel); #endregion Debug #region Graphics CHelper.TryGetEnumValueFromXML <ERenderer>("//root/Graphics/Renderer", navigator, ref Renderer); CHelper.TryGetEnumValueFromXML <ETextureQuality>("//root/Graphics/TextureQuality", navigator, ref TextureQuality); CHelper.TryGetIntValueFromXML("//root/Graphics/CoverSize", navigator, ref CoverSize); if (CoverSize > 1024) { CoverSize = 1024; } if (CoverSize < 32) { CoverSize = 32; } CHelper.TryGetIntValueFromXML("//root/Graphics/ScreenW", navigator, ref ScreenW); CHelper.TryGetIntValueFromXML("//root/Graphics/ScreenH", navigator, ref ScreenH); CHelper.TryGetEnumValueFromXML <EAntiAliasingModes>("//root/Graphics/AAMode", navigator, ref AAMode); CHelper.TryGetEnumValueFromXML <EColorDeep>("//root/Graphics/Colors", navigator, ref Colors); CHelper.TryGetFloatValueFromXML("//root/Graphics/MaxFPS", navigator, ref MaxFPS); CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Graphics/VSync", navigator, ref VSync); CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Graphics/FullScreen", navigator, ref FullScreen); CHelper.TryGetFloatValueFromXML("//root/Graphics/FadeTime", navigator, ref FadeTime); #endregion Graphics #region Theme CHelper.GetValueFromXML("//root/Theme/Name", navigator, ref Theme, Theme); CHelper.GetValueFromXML("//root/Theme/Skin", navigator, ref Skin, Skin); CHelper.GetValueFromXML("//root/Theme/Cover", navigator, ref CoverTheme, CoverTheme); CHelper.TryGetEnumValueFromXML("//root/Theme/DrawNoteLines", navigator, ref DrawNoteLines); CHelper.TryGetEnumValueFromXML("//root/Theme/DrawToneHelper", navigator, ref DrawToneHelper); CHelper.TryGetEnumValueFromXML("//root/Theme/TimerLook", navigator, ref TimerLook); CHelper.TryGetEnumValueFromXML("//root/Theme/CoverLoading", navigator, ref CoverLoading); #endregion Theme #region Sound CHelper.TryGetEnumValueFromXML <EPlaybackLib>("//root/Sound/PlayBackLib", navigator, ref PlayBackLib); CHelper.TryGetEnumValueFromXML <ERecordLib>("//root/Sound/RecordLib", navigator, ref RecordLib); CHelper.TryGetEnumValueFromXML <EBufferSize>("//root/Sound/AudioBufferSize", navigator, ref AudioBufferSize); CHelper.TryGetIntValueFromXML("//root/Sound/AudioLatency", navigator, ref AudioLatency); if (AudioLatency < -500) { AudioLatency = -500; } if (AudioLatency > 500) { AudioLatency = 500; } CHelper.TryGetEnumValueFromXML("//root/Sound/BackgroundMusic", navigator, ref BackgroundMusic); CHelper.TryGetIntValueFromXML("//root/Sound/BackgroundMusicVolume", navigator, ref BackgroundMusicVolume); CHelper.TryGetEnumValueFromXML("//root/Sound/BackgroundMusicSource", navigator, ref BackgroundMusicSource); #endregion Sound #region Game // Songfolder value = string.Empty; int i = 1; while (CHelper.GetValueFromXML("//root/Game/SongFolder" + i.ToString(), navigator, ref value, value)) { if (i == 1) { SongFolder.Clear(); } SongFolder.Add(value); value = string.Empty; i++; } CHelper.TryGetEnumValueFromXML <ESongMenu>("//root/Game/SongMenu", navigator, ref SongMenu); CHelper.TryGetEnumValueFromXML <ESongSorting>("//root/Game/SongSorting", navigator, ref SongSorting); CHelper.TryGetFloatValueFromXML("//root/Game/ScoreAnimationTime", navigator, ref ScoreAnimationTime); CHelper.TryGetEnumValueFromXML <ETimerMode>("//root/Game/TimerMode", navigator, ref TimerMode); CHelper.TryGetIntValueFromXML("//root/Game/NumPlayer", navigator, ref NumPlayer); CHelper.TryGetEnumValueFromXML("//root/Game/Tabs", navigator, ref Tabs); CHelper.GetValueFromXML("//root/Game/Language", navigator, ref Language, Language); CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Game/LyricsOnTop", navigator, ref LyricsOnTop); if ((ScoreAnimationTime > 0 && ScoreAnimationTime < 1) || ScoreAnimationTime < 0) { ScoreAnimationTime = 1; } if (NumPlayer < 1 || NumPlayer > CSettings.MaxNumPlayer) { NumPlayer = 2; } List <string> _Languages = new List <string>(); _Languages = CLanguage.GetLanguages(); bool _LangExists = false; for (i = 0; i < _Languages.Count; i++) { if (_Languages[i] == Language) { _LangExists = true; } } //TODO: What should we do, if English not exists? if (_LangExists == false) { Language = "English"; } CLanguage.SetLanguage(Language); #endregion Game #region Video CHelper.TryGetEnumValueFromXML <EVideoDecoder>("//root/Video/VideoDecoder", navigator, ref VideoDecoder); CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Video/VideoBackgrounds", navigator, ref VideoBackgrounds); CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Video/VideoPreview", navigator, ref VideoPreview); CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Video/VideosInSongs", navigator, ref VideosInSongs); #endregion Video #region Record MicConfig = new SMicConfig[CSettings.MaxNumPlayer]; value = string.Empty; for (int p = 1; p <= CSettings.MaxNumPlayer; p++) { MicConfig[p - 1] = new SMicConfig(0); CHelper.GetValueFromXML("//root/Record/MicConfig" + p.ToString() + "/DeviceName", navigator, ref MicConfig[p - 1].DeviceName, String.Empty); CHelper.GetValueFromXML("//root/Record/MicConfig" + p.ToString() + "/DeviceDriver", navigator, ref MicConfig[p - 1].DeviceDriver, String.Empty); CHelper.GetValueFromXML("//root/Record/MicConfig" + p.ToString() + "/InputName", navigator, ref MicConfig[p - 1].InputName, String.Empty); CHelper.TryGetIntValueFromXML("//root/Record/MicConfig" + p.ToString() + "/Channel", navigator, ref MicConfig[p - 1].Channel); } CHelper.TryGetIntValueFromXML("//root/Record/MicDelay", navigator, ref MicDelay); MicDelay = (int)(20 * Math.Round(MicDelay / 20.0)); if (MicDelay < 0) { MicDelay = 0; } if (MicDelay > 500) { MicDelay = 500; } #endregion Record return(true); } else { return(false); } }