Exemplo n.º 1
0
        /// <summary>
        ///     Saves a local score to the database.
        /// </summary>
        private void SaveLocalScore()
        {
            var scoreId = 0;

            try
            {
                var localScore = Score.FromScoreProcessor(Gameplay.Ruleset.ScoreProcessor, Gameplay.MapHash, ConfigManager.Username.Value, ScrollSpeed,
                                                          Gameplay.PauseCount, Gameplay.Map.RandomizeModifierSeed);

                localScore.RatingProcessorVersion = RatingProcessorKeys.Version;
                localScore.RankedAccuracy         = Gameplay.Ruleset.StandardizedReplayPlayer.ScoreProcessor.Accuracy;

                var windows = JudgementWindowsDatabaseCache.Selected.Value;

                localScore.JudgementWindowPreset = windows.Name;
                localScore.JudgementWindowMarv   = windows.Marvelous;
                localScore.JudgementWindowPerf   = windows.Perfect;
                localScore.JudgementWindowGreat  = windows.Great;
                localScore.JudgementWindowGood   = windows.Good;
                localScore.JudgementWindowOkay   = windows.Okay;
                localScore.JudgementWindowMiss   = windows.Miss;

                if (ScoreProcessor.Failed)
                {
                    localScore.PerformanceRating = 0;
                }
                else
                {
                    localScore.PerformanceRating = new RatingProcessorKeys(Map.DifficultyFromMods(Gameplay.Ruleset.ScoreProcessor.Mods)).CalculateRating(Gameplay.Ruleset.StandardizedReplayPlayer.ScoreProcessor.Accuracy);
                }

                scoreId = ScoreDatabaseCache.InsertScoreIntoDatabase(localScore);
            }
            catch (Exception e)
            {
                NotificationManager.Show(NotificationLevel.Error, "There was an error saving your score. Check Runtime.log for more details.");
                Logger.Error(e, LogType.Runtime);
            }

            try
            {
                Replay.Write($"{ConfigManager.DataDirectory}/r/{scoreId}.qr");
            }
            catch (Exception e)
            {
                NotificationManager.Show(NotificationLevel.Error, "There was an error when saving your replay. Check Runtime.log for more details.");
                Logger.Error(e, LogType.Runtime);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Saves a local score to the database.
        /// </summary>
        private void SaveLocalScore()
        {
            var scoreId = 0;

            try
            {
                var localScore = Score.FromScoreProcessor(ScoreProcessor, Gameplay.MapHash, ConfigManager.Username.Value, ScrollSpeed,
                                                          Gameplay.PauseCount);

                localScore.RatingProcessorVersion = RatingProcessorKeys.Version;

                if (ScoreProcessor.Failed)
                {
                    localScore.PerformanceRating = 0;
                }
                else
                {
                    localScore.PerformanceRating = new RatingProcessorKeys(Map.DifficultyFromMods(ScoreProcessor.Mods)).CalculateRating(ScoreProcessor.Accuracy);
                }

                scoreId = ScoreDatabaseCache.InsertScoreIntoDatabase(localScore);
            }
            catch (Exception e)
            {
                NotificationManager.Show(NotificationLevel.Error, "There was an error saving your score. Check Runtime.log for more details.");
                Logger.Error(e, LogType.Runtime);
            }

            try
            {
                Replay.Write($"{ConfigManager.DataDirectory}/r/{scoreId}.qr");
            }
            catch (Exception e)
            {
                NotificationManager.Show(NotificationLevel.Error, "There was an error when saving your replay. Check Runtime.log for more details.");
                Logger.Error(e, LogType.Runtime);
            }
        }