示例#1
0
        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");
        }
示例#2
0
文件: CSongs.cs 项目: zhaozw/Vocaluxe
        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 ");
        }
示例#3
0
        public static void Init()
        {
            // Add Screens, must be the same order as in EScreens!
            CLog.StartBenchmark("Build Screen List");

            _Screens.Add(new CScreenTest());
            _Screens.Add(new CScreenLoad());
            _Screens.Add(new CScreenMain());
            _Screens.Add(new CScreenSong());
            _Screens.Add(new CScreenOptions());
            _Screens.Add(new CScreenSing());
            _Screens.Add(new CScreenProfiles());
            _Screens.Add(new CScreenScore());
            _Screens.Add(new CScreenHighscore());
            _Screens.Add(new CScreenOptionsGame());
            _Screens.Add(new CScreenOptionsSound());
            _Screens.Add(new CScreenOptionsRecord());
            _Screens.Add(new CScreenOptionsVideo());
            _Screens.Add(new CScreenOptionsVideoAdjustments());
            _Screens.Add(new CScreenOptionsLyrics());
            _Screens.Add(new CScreenOptionsTheme());
            _Screens.Add(new CScreenNames());
            _Screens.Add(new CScreenCredits());
            _Screens.Add(new CScreenParty());

            Debug.Assert(_Screens.Count == (int)EScreen.CountEntry, "Screen list and screens enum do not match");

            _PopupScreens.Add(new CPopupScreenPlayerControl());
            _PopupScreens.Add(new CPopupScreenVolumeControl());
            _PopupScreens.Add(new CPopupScreenServerQR());

            CLog.StopBenchmark("Build Screen List");

            CurrentScreen       = _Screens[(int)EScreen.Load];
            NextScreen          = null;
            _CurrentPopupScreen = EPopupScreens.NoPopup;
            _VolumePopupTimer   = new Stopwatch();

            GlobalAlpha = 1f;
            ZOffset     = 0f;

            CLog.StartBenchmark("Load Theme");
            LoadTheme();
            CLog.StopBenchmark("Load Theme");
        }
示例#4
0
        public static void LoadTheme()
        {
            _Cursor.LoadSkin();

            for (int i = 0; i < _Screens.Count; i++)
            {
                CLog.StartBenchmark("Load Theme " + Enum.GetNames(typeof(EScreen))[i]);
                _Screens[i].Init();
                _Screens[i].LoadTheme(CThemes.GetThemeScreensPath(_Screens[i].PartyModeID));
                CLog.StopBenchmark("Load Theme " + Enum.GetNames(typeof(EScreen))[i]);
            }

            foreach (IMenu popup in _PopupScreens)
            {
                popup.Init();
                popup.LoadTheme(CThemes.GetThemeScreensPath(popup.PartyModeID));
            }
        }
示例#5
0
        private static void _LoadCovers()
        {
            CLog.StartBenchmark("Load Covers");
            int            songCount = _Songs.Count;
            AutoResetEvent ev        = new AutoResetEvent(songCount == 0);

            NumSongsWithCoverLoaded = 0;
            foreach (CSong song in _Songs)
            {
                CSong tmp = song;
                Task.Factory.StartNew(() =>
                {
                    tmp.LoadSmallCover();
                    if (Interlocked.Increment(ref _NumSongsWithCoverLoaded) >= songCount)
                    {
                        ev.Set();
                    }
                });
            }
            ev.WaitOne();
            _CoverLoaded = true;
            CDataBase.CommitCovers();
            CLog.StopBenchmark("Load Covers");
        }
示例#6
0
        /// <summary>
        /// Loads theme fonts from skin file
        /// </summary>
        public static void LoadThemeFonts(string ThemeName, string FontFolder, XPathNavigator navigator)
        {
            string value = string.Empty;
            int    i     = 1;

            while (CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Folder", navigator, ref value, value))
            {
                SFont sf = new SFont();
                sf.Folder = value;

                sf.IsThemeFont = true;
                sf.ThemeName   = ThemeName;

                bool ok = true;

                ok           &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileNormal", navigator, ref value, value);
                sf.FileNormal = value;
                value         = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                CFont f = new CFont(value);
                sf.Normal = f;

                string name = String.Empty;
                ok     &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Name", navigator, ref name, value);
                sf.Name = name;

                ok           &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileItalic", navigator, ref value, value);
                sf.FileItalic = value;
                value         = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f             = new CFont(value);
                sf.Italic     = f;

                ok         &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBold", navigator, ref value, value);
                sf.FileBold = value;
                value       = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f           = new CFont(value);
                sf.Bold     = f;

                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value);
                sf.FileBoldItalic = value;
                value             = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f             = new CFont(value);
                sf.BoldItalic = f;

                sf.Outline = 0f;
                ok        &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline);

                sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A);

                if (ok)
                {
                    _Fonts.Add(sf);
                }
                else
                {
                    CLog.LogError("Error loading theme fonts for theme \"" + ThemeName + "\": Error in Font" + i.ToString());
                }
                i++;
            }

            CLog.StartBenchmark(1, "BuildGlyphs");
            BuildGlyphs();
            CLog.StopBenchmark(1, "BuildGlyphs");
        }