示例#1
0
        private static void _LoadCovers()
        {
            using (CBenchmark.Time("Loaded 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();
            }
        }
示例#2
0
        public void BenchmarkBeginTest()
        {
            const string testMessage        = "BenchmarkBegin Test";
            string       testFileName       = Path.GetRandomFileName();
            string       testFileSongName   = Path.GetRandomFileName();
            string       testFileMarkerName = Path.GetRandomFileName();
            const string versionTag         = "Test Version (1.2.4)";

            // Init Log
            CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
                      (crash, cont, tag, log, error) => { Assert.Fail("Benchmarks should not show the reporter."); },
                      ELogLevel.Verbose);

            using (var token = CBenchmark.Begin(testMessage))
            {
                System.Threading.Thread.Sleep(1);
                token.End();
            }

            // Close logfile
            CLog.Close();

            // Check log
            Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileName)), "Mainlog file is missing.");
            Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileSongName)), "Songlog file is missing.");

            string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
            string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));

            StringAssert.Contains($"[Information] Started \"{ testMessage }\"", mainLogContent, "Start entry wrong");
            StringAssert.Contains($"[Information] Finished \"{ testMessage }\" successfully in ", mainLogContent, "Finish entry wrong");
            StringAssert.AreEqualIgnoringCase("", songLogContent, "Benchmark should not create song log entries");
        }
示例#3
0
        public static void Init()
        {
            // Add Screens, must be the same order as in EScreens!
            using (CBenchmark.Time("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());
            _PopupScreens.Add(new CPopupScreenNewPlayer());

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

            GlobalAlpha = 1f;
            ZOffset     = 0f;

            using (CBenchmark.Time("Load Theme"))
            {
                LoadTheme();
            }
        }
示例#4
0
        public override void OnClose()
        {
            base.OnClose();

            foreach (CVideoPlayer videoPlayer in _Intros)
            {
                videoPlayer.Close();
            }

            // Stop the song full load timer
            _TimerLoadSongsFull.Dispose();

            //Init Playlists
            using (CBenchmark.Time("Init Playlists"))
            {
                CPlaylists.Init();
            }
        }
示例#5
0
        public static void LoadTheme()
        {
            _Cursor.LoadSkin();

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

            foreach (IMenu popup in _PopupScreens)
            {
                popup.Init();
                popup.LoadTheme(CThemes.GetThemeScreensPath(popup.PartyModeID));
            }
        }
示例#6
0
        /// <summary>
        ///     Loads theme fonts
        /// </summary>
        public static bool LoadThemeFonts(IEnumerable <SFontFamily> fontFamilies, string fontFolder, string themeName, int partyModeId)
        {
            if (fontFamilies == null)
            {
                return(true);
            }
            foreach (SFontFamily fontFamily in fontFamilies)
            {
                if (!_LoadFont(fontFamily, fontFolder, themeName, partyModeId))
                {
                    CLog.Error("Error loading fonts for Theme " + themeName + "(" + partyModeId + ")");
                    return(false);
                }
            }

            using (CBenchmark.Time("Build Glyphs"))
            {
                _BuildGlyphs();
            }

            return(true);
        }
示例#7
0
        public override void OnShowFinish()
        {
            base.OnShowFinish();

            if (CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
            {
                foreach (CVideoPlayer videoPlayer in _Intros)
                {
                    videoPlayer.PreLoad();
                }
            }

            _TimerLoadSongsFull = CBenchmark.Time("Loaded Songs Full");

            _SongLoaderThread = new Thread(CSongs.LoadSongs)
            {
                Name = "SongLoader", IsBackground = true
            };
            _SongLoaderThread.Start();
            CBackgroundMusic.OwnSongsAvailable = false;

            CBackgroundMusic.Play();
        }
示例#8
0
        private static void _Run(string[] args)
        {
            Application.DoEvents();

            try
            {
                // Create data folder
                Directory.CreateDirectory(CSettings.DataFolder);

                // Init Log
                CLog.Init(CSettings.FolderNameLogs,
                          CSettings.FileNameMainLog,
                          CSettings.FileNameSongLog,
                          CSettings.FileNameCrashMarker,
                          CSettings.GetFullVersionText(),
                          CReporter.ShowReporterFunc,
                          ELogLevel.Information);

                if (!CProgrammHelper.CheckRequirements())
                {
                    return;
                }
                CProgrammHelper.Init();

                using (CBenchmark.Time("Init Program"))
                {
                    CMain.Init();
                    Application.DoEvents();

                    // Init Language
                    using (CBenchmark.Time("Init Language"))
                    {
                        if (!CLanguage.Init())
                        {
                            throw new CLoadingException("Language");
                        }
                    }

                    Application.DoEvents();

                    // load config
                    using (CBenchmark.Time("Init Config"))
                    {
                        CConfig.LoadCommandLineParams(args);
                        CConfig.UseCommandLineParamsBefore();
                        CConfig.Init();
                        CConfig.UseCommandLineParamsAfter();
                    }

                    // Create folders
                    CSettings.CreateFolders();

                    _SplashScreen = new CSplashScreen();
                    Application.DoEvents();

                    // Init Draw
                    using (CBenchmark.Time("Init Draw"))
                    {
                        if (!CDraw.Init())
                        {
                            throw new CLoadingException("drawing");
                        }
                    }

                    Application.DoEvents();

                    // Init Playback
                    using (CBenchmark.Time("Init Playback"))
                    {
                        if (!CSound.Init())
                        {
                            throw new CLoadingException("playback");
                        }
                    }

                    Application.DoEvents();

                    // Init Record
                    using (CBenchmark.Time("Init Record"))
                    {
                        if (!CRecord.Init())
                        {
                            throw new CLoadingException("record");
                        }
                    }

                    Application.DoEvents();

                    // Init VideoDecoder
                    using (CBenchmark.Time("Init Videodecoder"))
                    {
                        if (!CVideo.Init())
                        {
                            throw new CLoadingException("video");
                        }
                    }

                    Application.DoEvents();

                    // Init Database
                    using (CBenchmark.Time("Init Database"))
                    {
                        if (!CDataBase.Init())
                        {
                            throw new CLoadingException("database");
                        }
                    }

                    Application.DoEvents();

                    //Init Webcam
                    using (CBenchmark.Time("Init Webcam"))
                    {
                        if (!CWebcam.Init())
                        {
                            throw new CLoadingException("webcam");
                        }
                    }

                    Application.DoEvents();

                    // Init Background Music
                    using (CBenchmark.Time("Init Background Music"))
                    {
                        CBackgroundMusic.Init();
                    }

                    Application.DoEvents();

                    // Init Profiles
                    using (CBenchmark.Time("Init Profiles"))
                    {
                        CProfiles.Init();
                    }

                    Application.DoEvents();

                    // Init Fonts
                    using (CBenchmark.Time("Init Fonts"))
                    {
                        if (!CFonts.Init())
                        {
                            throw new CLoadingException("fonts");
                        }
                    }

                    Application.DoEvents();

                    // Theme System
                    using (CBenchmark.Time("Init Theme"))
                    {
                        if (!CThemes.Init())
                        {
                            throw new CLoadingException("theme");
                        }
                    }

                    using (CBenchmark.Time("Load Theme"))
                    {
                        CThemes.Load();
                    }

                    Application.DoEvents();

                    // Load Cover
                    using (CBenchmark.Time("Init Cover"))
                    {
                        if (!CCover.Init())
                        {
                            throw new CLoadingException("covertheme");
                        }
                    }

                    Application.DoEvents();

                    // Init Screens
                    using (CBenchmark.Time("Init Screens"))
                    {
                        CGraphics.Init();
                    }

                    Application.DoEvents();

                    // Init Server
                    using (CBenchmark.Time("Init Server"))
                    {
                        CVocaluxeServer.Init();
                    }

                    Application.DoEvents();

                    // Init Input
                    using (CBenchmark.Time("Init Input"))
                    {
                        CController.Init();
                        CController.Connect();
                    }

                    Application.DoEvents();

                    // Init Game
                    using (CBenchmark.Time("Init Game"))
                    {
                        CGame.Init();
                        CProfiles.Update();
                        CConfig.UsePlayers();
                    }

                    Application.DoEvents();

                    // Init Party Modes
                    using (CBenchmark.Time("Init Party Modes"))
                    {
                        if (!CParty.Init())
                        {
                            throw new CLoadingException("Party Modes");
                        }
                    }

                    Application.DoEvents();
                    //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage
                    //Rely on GC doing its job afterwards and call Dispose methods where appropriate
                    GC.Collect();
                }
            }
            catch (Exception e)
            {
                CLog.Error(e, "Error on start up: {ExceptionMessage}", CLog.Params(e.Message), show: true);
                if (_SplashScreen != null)
                {
                    _SplashScreen.Close();
                }
                _CloseProgram();
                return;
            }
            Application.DoEvents();

            // Start Main Loop
            if (_SplashScreen != null)
            {
                _SplashScreen.Close();
            }

            CDraw.MainLoop();
        }
示例#9
0
        public static void LoadSongs()
        {
            using (CBenchmark.Time("Load Songs"))
            {
                SongsLoaded = false;
                _Songs.Clear();

                var files = Enumerable.Empty <string>();

                using (CBenchmark.Time("List Songs"))
                {
                    foreach (string path in CConfig.SongFolders)
                    {
                        if (Directory.Exists(path))
                        {
                            files = files.Union(CHelper.ListFiles(path, "*.txt", true, true));
                            files = files.Union(CHelper.ListFiles(path, "*.txd", true, true));
                        }
                    }
                }

                using (CBenchmark.Time("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);
                        }
                    }
                }

                using (CBenchmark.Time("Sorted Songs"))
                {
                    Sorter.SongSorting         = CConfig.Config.Game.SongSorting;
                    Sorter.IgnoreArticles      = CConfig.Config.Game.IgnoreArticles;
                    Categorizer.Tabs           = CConfig.Config.Game.Tabs;
                    Categorizer.ObjectChanged += _HandleCategoriesChanged;
                }

                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;
                }
            }
        }