Beispiel #1
0
 private static void _CloseProgram()
 {
     // Unloading in reverse order
     try
     {
         CController.Close();
         CVocaluxeServer.Close();
         CGraphics.Close();
         CThemes.Close();
         CCover.Close();
         CFonts.Close();
         CBackgroundMusic.Close();
         CWebcam.Close();
         CDataBase.Close();
         CVideo.Close();
         CRecord.Close();
         CSound.Close();
         CDraw.Close();
     }
     catch (Exception e)
     {
         CLog.LogError("Error during shutdown!", false, false, e);
     }
     GC.Collect(); // Do a GC run here before we close logs to have finalizers run
     try
     {
         CLog.Close(); // Do this last, so we get all log entries!
     }
     catch (Exception) {}
     Environment.Exit(Environment.ExitCode);
 }
Beispiel #2
0
        internal CUpdateQuery(CDataBase p_data_base, CObjectMap p_map, String p_table_name, SQL.CAssignmentList p_assignments, SQL.CWhereCondition p_update_condition)
            : base(p_data_base)
        {
            if (p_map == null)
            {
                throw new ArgumentNullException("You must specify an object map to use.");
            }
            if (p_table_name == null)
            {
                throw new ArgumentNullException("You must specify a table name to use.");
            }
            if (String.IsNullOrWhiteSpace(p_table_name))
            {
                throw new ArgumentException("The specified table name may not consist only of whitespace.");
            }
            if (p_assignments == null)
            {
                throw new ArgumentNullException("You must specify assignments to use for the query.");
            }

            m_p_table_name       = p_table_name;
            m_p_assignments      = p_assignments;
            m_p_update_condition = p_update_condition;
            _m_p_map             = p_map;
        }
Beispiel #3
0
        /// <summary>
        /// Constructs a new select query with the given properties.
        /// </summary>
        /// <param name="p_data_base">The database the query is supposed to run against.</param>
        /// <param name="p_map">The object map the query is created for.</param>
        /// <param name="p_column_names">The columns that should be extracted by the query.</param>
        /// <param name="p_table_name">The name of the table this query should extract data from.</param>
        /// <param name="p_where_condition">The conditions that rows must satisfy to be matched in this query, or null if there should be no conditions.</param>
        internal CSelectQuery(CDataBase p_data_base, CObjectMap p_map, String p_table_name, String[] p_column_names, SQL.CWhereCondition p_where_condition)
            : base(p_data_base)
        {
            if (p_map == null)
            {
                throw new ArgumentNullException("You must specify a map to use.");
            }
            if (p_table_name == null)
            {
                throw new ArgumentNullException("You must specify a table name to use.");
            }
            if (String.IsNullOrWhiteSpace(p_table_name))
            {
                throw new ArgumentException("The specified table name may not consist only of whitespace.");
            }
            if (p_column_names == null)
            {
                throw new ArgumentNullException("You must provide column names to use.");
            }

            m_p_columns         = new ReadOnlyCollection <String>((IList <String>)p_column_names.Clone());
            m_p_table_name      = p_table_name;
            m_p_where_condition = p_where_condition;

            _m_p_map = p_map;
        }
Beispiel #4
0
        private void _LoadScores()
        {
            _Pos = 0;
            int rounds = CGame.NumRounds;

            _Scores = new List <SDBScoreEntry> [rounds];
            for (int round = 0; round < rounds; round++)
            {
                int             songID   = CGame.GetSong(round).ID;
                EGameMode       gameMode = CGame.GetGameMode(round);
                EHighscoreStyle style    = CBase.Config.GetHighscoreStyle();
                _Scores[round] = CDataBase.LoadScore(songID, gameMode, style);
            }
        }
Beispiel #5
0
        private void LoadScores()
        {
            CPoints points = CGame.GetPoints();

            if (points == null)
            {
                return;
            }

            _Pos = 0;
            for (int round = 0; round < points.NumRounds; round++)
            {
                SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0];
                CDataBase.LoadScore(ref _Scores[round], player);
            }
        }
Beispiel #6
0
 static void CloseProgram()
 {
     // Unloading
     try
     {
         CSound.RecordCloseAll();
         CSound.CloseAllStreams();
         CVideo.VdCloseAll();
         CDraw.Unload();
         CLog.CloseAll();
         CDataBase.CloseConnections();
     }
     catch (Exception)
     {
     }
 }
Beispiel #7
0
        private void LoadScores()
        {
            CPoints points = CGame.GetPoints();

            if (points == null)
            {
                return;
            }

            _Pos = 0;
            for (int round = 0; round < points.NumRounds; round++)
            {
                SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0];
                CDataBase.LoadScore(ref _Scores, player);

                if (round == _Round)
                {
                    _IsDuet = false;

                    CSong song = CSongs.GetSong(player.SongID);
                    Texts[htTexts(TextSongName)].Text = song.Artist + " - " + song.Title;

                    switch (CGame.GameMode)
                    {
                    case EGameMode.Normal:
                        Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL";
                        break;

                    case EGameMode.Medley:
                        Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_MEDLEY";
                        break;

                    case EGameMode.Duet:
                        Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_DUET";
                        _IsDuet = true;
                        break;

                    default:
                        Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL";
                        break;
                    }
                }
            }
        }
Beispiel #8
0
        private void _SavePlayedSongs()
        {
            for (int round = 0; round < _Points.NumRounds; round++)
            {
                SPlayer[] players = _Points.GetPlayer(round, CGame.NumPlayers);

                for (int p = 0; p < players.Length; p++)
                {
                    if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished)
                    {
                        CSong song = CSongs.GetSong(players[p].SongID);
                        CDataBase.IncreaseSongCounter(song.DataBaseSongID);
                        song.NumPlayed++;
                        song.NumPlayedSession++;
                        break;
                    }
                }
            }
        }
Beispiel #9
0
        public ProvinceDropDownList(IContainer container)
        {
            container.Add(this);

            InitializeComponent();

            db = new CDataBase();
            ds = new DataSet();

            ds = db.GetProvinceFromSDF_V2(-1);

            this.DataSource = ds.Tables[0];

            this.ValueMember = "codice_provincia";

            this.DisplayMember = "provincia";

            Initialize(null, null);
        }
Beispiel #10
0
        public ComuniDropDownList(IContainer container)
        {
            container.Add(this);

            InitializeComponent();

            db = new CDataBase();
            ds = new DataSet();

            ds = db.GetComuniFromSDF_V2(-1, -1);


            this.DataSource = ds.Tables[0];

            this.ValueMember = "id_progressivo";

            this.DisplayMember = "denominazione_in_italiano";

            Initialize(null, null);
        }
        public RegioniDropDownList(IContainer container)
        {
            container.Add(this);

            InitializeComponent();


            db = new CDataBase();
            ds = new DataSet();

            ds = db.GetRegionsFromSDF_V2();

            this.DataSource = ds.Tables[0];

            this.ValueMember = "codice_regione";

            this.DisplayMember = "denominazione_regione";

            Initialize(null, null);
        }
Beispiel #12
0
        internal CInsertQuery(CDataBase p_data_base, Boolean update_on_duplicate_key, CObjectMap p_object_map, String[] p_column_names, params Object[][] p_values)
            : base(p_data_base)
        {
            if (p_object_map == null)
            {
                throw new ArgumentNullException("You must specify an object map to use.");
            }
            if (p_column_names == null)
            {
                throw new ArgumentNullException("You must specify columns names to use.");
            }
            if (p_values == null)
            {
                throw new ArgumentNullException("You must specify values to use.");
            }
            for (Int32 i = 0; i < p_values.Length; ++i)
            {
                if (p_values[i].Length != p_column_names.Length)
                {
                    throw new ArgumentException("One set of values did not have exactly the same length as the column names provided.");
                }
            }

            m_p_keys = new ReadOnlyCollection <String>(p_object_map.m_p_unique_keys.Select(x => x.m_p_column_name).ToArray());
            m_on_duplicate_key_update = update_on_duplicate_key;
            m_p_table_name            = p_object_map.m_p_object_table;
            m_p_column_names          = new ReadOnlyCollection <String>((IList <String>)p_column_names.Clone());
            m_p_values = new ReadOnlyCollection <ReadOnlyCollection <Object> >((from p_value in p_values select new ReadOnlyCollection <Object>(p_value)).ToArray());

            _m_p_map = p_object_map;

            _m_has_key = false;
            for (Int32 i = 0; i < m_p_keys.Count; ++i)
            {
                if (m_p_column_names.Contains(m_p_keys[i]))
                {
                    _m_has_key = true;
                    break;
                }
            }
        }
Beispiel #13
0
        public CMain()
        {
            oDataBase = new CDataBase();

            fMain = new frmMain();

            oRequestResult = new CRequest_Result(ref fMain);

            fMain.mnuMainFile_Create.Click += mnuMainFile_Create_Click;

            fMain.mnuMainFile_Open.Click += mnuMainFile_Open_Click;



            fMain.tspTemplateRequest_Add.Click += tspTemplateRequest_Add_Click;

            fMain.tspTemplateRequest_Del.Click += tspTemplateRequest_Del_Click;

            fMain.tspTemplateRequest_Edit.Click += tspTemplateRequest_Edit_Click;

            fMain.lsvHeader_Result.MouseDoubleClick += tspTemplateRequest_Edit_Click;
        }
Beispiel #14
0
        private void AddScoresToDB()
        {
            CPoints points = CGame.GetPoints();

            if (points == null)
            {
                return;
            }

            for (int round = 0; round < points.NumRounds; round++)
            {
                SPlayer[] player = points.GetPlayer(round, CGame.NumPlayer);

                for (int p = 0; p < player.Length; p++)
                {
                    if (player[p].Points > CSettings.MinScoreForDB && player[p].SongFinished && !CProfiles.IsGuestProfile(player[p].ProfileID))
                    {
                        _NewEntryIDs.Add(CDataBase.AddScore(player[p]));
                    }
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// Constructs a new delete query to delete columns matching the given condition from the given table.
        /// </summary>
        /// <param name="p_data_base">The database the query should be run against.</param>
        /// <param name="p_map">The object map this query is being created for.</param>
        /// <param name="p_table_name">The name of the table to delete rows from.</param>
        /// <param name="p_where_condition">The condition a row must satisfy to be deleted.</param>
        /// <param name="limit">The total number of rows to delete, or 0 if every matched row should be deleted.</param>
        internal CDeleteQuery(CDataBase p_data_base, CObjectMap p_map, String p_table_name, SQL.CWhereCondition p_where_condition, UInt64 limit)
            : base(p_data_base)
        {
            if (p_map == null)
            {
                throw new ArgumentNullException("The map may not be null.");
            }
            if (p_table_name == null)
            {
                throw new ArgumentNullException("You must specify a table name to use.");
            }
            if (String.IsNullOrWhiteSpace(p_table_name))
            {
                throw new ArgumentException("The specified table name may not consist only of whitespace.");
            }

            m_p_table_name      = p_table_name;
            m_p_where_condition = p_where_condition;

            m_limit = limit;

            _m_p_map = p_map;
        }
Beispiel #16
0
        private void _LoadScores()
        {
            _Pos = 0;
            int rounds = CGame.NumRounds;

            if (rounds == 0)
            {
                _FromScreenSong = true;
                _Round          = (int)EGameMode.TR_GAMEMODE_NORMAL;
                _Scores         = new List <SDBScoreEntry> [4];
                int             songID = CScreenSong.getSelectedSongID();
                EHighscoreStyle style  = CBase.Config.GetHighscoreStyle();
                bool            foundHighscoreEntries = false;

                for (int gameModeNum = 0; gameModeNum < 4; gameModeNum++)
                {
                    _Scores[gameModeNum] = CDataBase.LoadScore(songID, (EGameMode)gameModeNum, style);
                    if (!foundHighscoreEntries && _Scores[gameModeNum].Count > 0)
                    {
                        _Round = gameModeNum;
                        foundHighscoreEntries = true;
                    }
                }
            }
            else
            {
                _FromScreenSong = false;
                _Scores         = new List <SDBScoreEntry> [rounds];
                for (int round = 0; round < rounds; round++)
                {
                    int             songID   = CGame.GetSong(round).ID;
                    EGameMode       gameMode = CGame.GetGameMode(round);
                    EHighscoreStyle style    = CBase.Config.GetHighscoreStyle();
                    _Scores[round] = CDataBase.LoadScore(songID, gameMode, style);
                }
            }
        }
Beispiel #17
0
 /// <summary>
 /// Constructs a new abstract database query and sets the connection String to the one specified in the database.
 /// </summary>
 /// <param name="p_data_base">The database the connection String should be taken from.</param>
 internal CDataBaseQuery(CDataBase p_data_base)
 {
     m_p_data_base = p_data_base;
 }
Beispiel #18
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver);

            // Close program if there is another instance running
            if (!EnsureSingleInstance())
            {
                //TODO: put it into language file
                MessageBox.Show("Another Instance of Vocaluxe is already runnning!");
                return;
            }

            Application.DoEvents();

            try
            {
                // Init Log
                CLog.Init();

                CSettings.CreateFolders();
                Application.DoEvents();

                // Init Language
                CLog.StartBenchmark(0, "Init Language");
                CLanguage.Init();
                CLog.StopBenchmark(0, "Init Language");

                Application.DoEvents();

                // load config
                CLog.StartBenchmark(0, "Init Config");
                CConfig.LoadCommandLineParams(args);
                CConfig.UseCommandLineParamsBefore();
                CConfig.Init();
                CConfig.UseCommandLineParamsAfter();
                CLog.StopBenchmark(0, "Init Config");

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

                // Init Draw
                CLog.StartBenchmark(0, "Init Draw");
                CDraw.InitDraw();
                CLog.StopBenchmark(0, "Init Draw");

                Application.DoEvents();

                // Init Database
                CLog.StartBenchmark(0, "Init Database");
                CDataBase.Init();
                CLog.StopBenchmark(0, "Init Database");

                Application.DoEvents();

                // Init Playback
                CLog.StartBenchmark(0, "Init Playback");
                CSound.PlaybackInit();
                CLog.StopBenchmark(0, "Init Playback");

                Application.DoEvents();

                // Init Record
                CLog.StartBenchmark(0, "Init Record");
                CSound.RecordInit();
                CLog.StopBenchmark(0, "Init Record");

                Application.DoEvents();

                //Init Webcam
                CLog.StartBenchmark(0, "Init Webcam");
                CWebcam.Init();
                CLog.StopBenchmark(0, "Init Webcam");

                Application.DoEvents();

                // Init Background Music
                CLog.StartBenchmark(0, "Init Background Music");
                CBackgroundMusic.Init();
                CLog.StopBenchmark(0, "Init Background Music");

                Application.DoEvents();

                // Init Profiles
                CLog.StartBenchmark(0, "Init Profiles");
                CProfiles.Init();
                CLog.StopBenchmark(0, "Init Profiles");

                Application.DoEvents();

                // Init Font
                CLog.StartBenchmark(0, "Init Font");
                CFonts.Init();
                CLog.StopBenchmark(0, "Init Font");

                Application.DoEvents();

                // Init VideoDecoder
                CLog.StartBenchmark(0, "Init Videodecoder");
                CVideo.Init();
                CLog.StopBenchmark(0, "Init Videodecoder");

                Application.DoEvents();

                // Load Cover
                CLog.StartBenchmark(0, "Init Cover");
                CCover.Init();
                CLog.StopBenchmark(0, "Init Cover");

                Application.DoEvents();

                // Theme System
                CLog.StartBenchmark(0, "Init Theme");
                CTheme.InitTheme();
                CLog.StopBenchmark(0, "Init Theme");

                Application.DoEvents();

                // Init Screens
                CLog.StartBenchmark(0, "Init Screens");
                CGraphics.InitGraphics();
                CLog.StopBenchmark(0, "Init Screens");

                Application.DoEvents();

                // Init Input
                CLog.StartBenchmark(0, "Init Input");
                CInput.Init();
                CLog.StopBenchmark(0, "Init Input");

                // Init Game;
                CLog.StartBenchmark(0, "Init Game");
                CGame.Init();
                CLog.StopBenchmark(0, "Init Game");
            }
            catch (Exception e)
            {
                MessageBox.Show("Error on start up: " + e.Message + e.StackTrace);
                CLog.LogError("Error on start up: " + e.Message + e.StackTrace);
                CloseProgram();
                Environment.Exit(Environment.ExitCode);
            }
            Application.DoEvents();

            // Start Main Loop
            _SplashScreen.Close();

            try
            {
                CDraw.MainLoop();
            }
            catch (Exception e)
            {
                MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace);
                CLog.LogError("Unhandled error: " + e.Message + e.StackTrace);
            }

            CloseProgram();
        }
Beispiel #19
0
        public override void LoadTheme(string xmlPath)
        {
            bool ressourceOK = true;

            //Vocaluxe-Logo
            ressourceOK &= CDataBase.GetCreditsRessource("Logo_voc.png", ref _TexLogo);

            //Little stars for logo
            ressourceOK &= CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref _TexPerfectNoteStar);

            ressourceOK &= CDataBase.GetCreditsRessource("redDot.png", ref _TexRedDot);
            ressourceOK &= CDataBase.GetCreditsRessource("blueDot.png", ref _TexBlueDot);

            ressourceOK &= CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel);
            ressourceOK &= CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice);
            ressourceOK &= CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep);
            ressourceOK &= CDataBase.GetCreditsRessource("flamefire.png", ref _TexNameFlamefire);
            ressourceOK &= CDataBase.GetCreditsRessource("lukeIam.png", ref _TexNameLukeIam);
            ressourceOK &= CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning);
            ressourceOK &= CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand);
            ressourceOK &= CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03);

            if (!ressourceOK)
            {
                CLog.Fatal("Could not load all ressources!");
            }

            //Prepare Text
            int lastY = 280;

            foreach (string[] paragraph in _Paragraphs)
            {
                string line = "";
                for (int e = 0; e < paragraph.Length; e++)
                {
                    if (paragraph[e] == null)
                    {
                        continue;
                    }
                    string newLine = " " + paragraph[e];
                    CText  text    = GetNewText(75, lastY, -2, 25, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
                    text.Visible = false;
                    if (CFonts.GetTextBounds(text).Width < (CSettings.RenderW - 220))
                    {
                        line += newLine;

                        //Check if all words are used
                        if ((e + 1) == paragraph.Length)
                        {
                            text.Text = line;
                            _ParagraphTexts.Add(text);
                            line   = "";
                            lastY += 40;
                        }
                    }
                    else
                    {
                        _ParagraphTexts.Add(text);
                        line   = newLine;
                        lastY += 27;
                    }
                    _AddText(text);
                }
            }

            CBackground bg = new CBackground(_BGTheme, -1);

            bg.LoadSkin();
            _AddBackground(bg);

            //Vocaluxe-Logo
            _Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1),
                                 new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, -270, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2));
            _AddStatic(_Logo);

            //Little stars for logo
            var numstars = (int)(_Logo.Rect.W * 0.25f / 2f);
            var partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1);

            _StarsRed  = _GetStarParticles(numstars, true, partRect, true);
            _StarsBlue = _GetStarParticles(numstars, false, partRect, true);
            _AddParticleEffect(_StarsRed);
            _AddParticleEffect(_StarsBlue);

            //Credit names
            _CreditNames = new List <CCreditName>();

            _AddNewCreditName(_TexNameBrunzel, 502, 29, true);
            _AddNewCreditName(_TexNameDarkice, 360, 55, true);
            _AddNewCreditName(_TexNameFlokuep, 214, 14, true);
            _AddNewCreditName(_TexNameFlamefire, 496, 46, true);
            _AddNewCreditName(_TexNameLukeIam, 411, 26, true);
            _AddNewCreditName(_TexNameBohning, 383, 54, false);
            _AddNewCreditName(_TexNameMesand, 525, 13, false);
            _AddNewCreditName(_TexNameBabene03, 33, 26, false);

            _AddTranslations();
        }
Beispiel #20
0
        public override void LoadTheme()
        {
            //Vocaluxe-Logo
            CDataBase.GetCreditsRessource("Logo_voc.png", ref _TexLogo);

            //Little stars for logo
            CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref _TexPerfectNoteStar);

            //brunzel
            CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel);

            //Darkice
            CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice);

            //flokuep
            CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep);

            //bohning
            CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning);

            //mesand
            CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand);

            //babene03
            CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03);

            //pantero
            CDataBase.GetCreditsRessource("pantero.png", ref _TexNamePantero);

            //Pinky007
            CDataBase.GetCreditsRessource("Pinky007.png", ref _TexNamePinky007);

            //Prepare Text
            int lastY = 280;

            for (int i = 0; i < paragraphs.Count; i++)
            {
                string line = "";
                for (int e = 0; e < paragraphs[i].Length; e++)
                {
                    if (paragraphs[i][e] != null)
                    {
                        string newline = line + " " + paragraphs[i][e];
                        CText  text    = new CText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
                        if (CDraw.GetTextBounds(text).Width < (CSettings.iRenderW - 220))
                        {
                            line = line + " " + paragraphs[i][e];

                            //Check if all words are used
                            if ((e + 1) == paragraphs[i].Length)
                            {
                                text.Text = line;
                                paragraphTexts.Add(text);
                                line   = "";
                                lastY += 40;
                            }
                        }
                        else
                        {
                            paragraphTexts.Add(text);
                            line   = " " + paragraphs[i][e];
                            lastY += 27;
                        }
                    }
                }
            }
        }
Beispiel #21
0
        private static void _Run(string[] args)
        {
            Application.DoEvents();

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

                // Init Log
                CLog.Init();

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

                CLog.StartBenchmark("Init Program");
                CMain.Init();
                Application.DoEvents();

                // Init Language
                CLog.StartBenchmark("Init Language");
                if (!CLanguage.Init())
                {
                    throw new CLoadingException("Language");
                }
                CLog.StopBenchmark("Init Language");

                Application.DoEvents();

                // load config
                CLog.StartBenchmark("Init Config");
                CConfig.LoadCommandLineParams(args);
                CConfig.UseCommandLineParamsBefore();
                CConfig.Init();
                CConfig.UseCommandLineParamsAfter();
                CLog.StopBenchmark("Init Config");

                // Create folders
                CSettings.CreateFolders();

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

                // Init Draw
                CLog.StartBenchmark("Init Draw");
                if (!CDraw.Init())
                {
                    throw new CLoadingException("drawing");
                }
                CLog.StopBenchmark("Init Draw");

                Application.DoEvents();

                // Init Playback
                CLog.StartBenchmark("Init Playback");
                if (!CSound.Init())
                {
                    throw new CLoadingException("playback");
                }
                CLog.StopBenchmark("Init Playback");

                Application.DoEvents();

                // Init Record
                CLog.StartBenchmark("Init Record");
                if (!CRecord.Init())
                {
                    throw new CLoadingException("record");
                }
                CLog.StopBenchmark("Init Record");

                Application.DoEvents();

                // Init VideoDecoder
                CLog.StartBenchmark("Init Videodecoder");
                if (!CVideo.Init())
                {
                    throw new CLoadingException("video");
                }
                CLog.StopBenchmark("Init Videodecoder");

                Application.DoEvents();

                // Init Database
                CLog.StartBenchmark("Init Database");
                if (!CDataBase.Init())
                {
                    throw new CLoadingException("database");
                }
                CLog.StopBenchmark("Init Database");

                Application.DoEvents();

                //Init Webcam
                CLog.StartBenchmark("Init Webcam");
                if (!CWebcam.Init())
                {
                    throw new CLoadingException("webcam");
                }
                CLog.StopBenchmark("Init Webcam");

                Application.DoEvents();

                // Init Background Music
                CLog.StartBenchmark("Init Background Music");
                CBackgroundMusic.Init();
                CLog.StopBenchmark("Init Background Music");

                Application.DoEvents();

                // Init Profiles
                CLog.StartBenchmark("Init Profiles");
                CProfiles.Init();
                CLog.StopBenchmark("Init Profiles");

                Application.DoEvents();

                // Init Fonts
                CLog.StartBenchmark("Init Fonts");
                if (!CFonts.Init())
                {
                    throw new CLoadingException("fonts");
                }
                CLog.StopBenchmark("Init Fonts");

                Application.DoEvents();

                // Theme System
                CLog.StartBenchmark("Init Theme");
                if (!CThemes.Init())
                {
                    throw new CLoadingException("theme");
                }
                CLog.StopBenchmark("Init Theme");

                CLog.StartBenchmark("Load Theme");
                CThemes.Load();
                CLog.StopBenchmark("Load Theme");

                Application.DoEvents();

                // Load Cover
                CLog.StartBenchmark("Init Cover");
                if (!CCover.Init())
                {
                    throw new CLoadingException("covertheme");
                }
                CLog.StopBenchmark("Init Cover");

                Application.DoEvents();

                // Init Screens
                CLog.StartBenchmark("Init Screens");
                CGraphics.Init();
                CLog.StopBenchmark("Init Screens");

                Application.DoEvents();

                // Init Server
                CLog.StartBenchmark("Init Server");
                CVocaluxeServer.Init();
                CLog.StopBenchmark("Init Server");

                Application.DoEvents();

                // Init Input
                CLog.StartBenchmark("Init Input");
                CController.Init();
                CController.Connect();
                CLog.StopBenchmark("Init Input");

                Application.DoEvents();

                // Init Game;
                CLog.StartBenchmark("Init Game");
                CGame.Init();
                CProfiles.Update();
                CConfig.UsePlayers();
                CLog.StopBenchmark("Init Game");

                Application.DoEvents();

                // Init Party Modes;
                CLog.StartBenchmark("Init Party Modes");
                if (!CParty.Init())
                {
                    throw new CLoadingException("Party Modes");
                }
                CLog.StopBenchmark("Init 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();
                CLog.StopBenchmark("Init Program");
            }
            catch (Exception e)
            {
                MessageBox.Show("Error on start up: " + e.Message);
                CLog.LogError("Error on start up: " + e);
                if (_SplashScreen != null)
                {
                    _SplashScreen.Close();
                }
                _CloseProgram();
                return;
            }
            Application.DoEvents();

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

            CDraw.MainLoop();
        }
Beispiel #22
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();
        }