Exemplo n.º 1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public override FetchedScoreStore FetchScores()
        {
            var map = MapManager.Selected.Value;

            var scores = ScoreDatabaseCache.FetchMapScores(map.Md5Checksum);

            return(new FetchedScoreStore(scores));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Performs any initial setup the game needs to run.
        /// </summary>
        private void PerformGameSetup()
        {
            ConfigManager.Initialize();

            DeleteTemporaryFiles();

            ScoreDatabaseCache.CreateTable();
            MapDatabaseCache.Load(false);
            QuaverSettingsDatabaseCache.Initialize();

            // Force garabge collection.
            GC.Collect();

            // Start watching for mapset changes in the folder.
            MapsetImporter.WatchForChanges();

            // Initially set the global volume.
            AudioTrack.GlobalVolume  = ConfigManager.VolumeGlobal.Value;
            AudioSample.GlobalVolume = ConfigManager.VolumeEffect.Value;

            ConfigManager.VolumeGlobal.ValueChanged += (sender, e) =>
            {
                AudioTrack.GlobalVolume  = e.Value;
                AudioSample.GlobalVolume = e.Value;
            };;

            ConfigManager.VolumeMusic.ValueChanged += (sender, e) => { if (AudioEngine.Track != null)
                                                                       {
                                                                           AudioEngine.Track.Volume = e.Value;
                                                                       }
            };
            ConfigManager.VolumeEffect.ValueChanged     += (sender, e) => AudioSample.GlobalVolume = e.Value;
            ConfigManager.Pitched.ValueChanged          += (sender, e) => AudioEngine.Track.ToggleRatePitching(e.Value);
            ConfigManager.FpsLimiterType.ValueChanged   += (sender, e) => InitializeFpsLimiting();
            ConfigManager.WindowFullScreen.ValueChanged += (sender, e) => Graphics.IsFullScreen = e.Value;

            // Handle discord rich presence.
            DiscordHelper.Initialize("376180410490552320");
            DiscordHelper.Presence = new DiscordRpc.RichPresence()
            {
                LargeImageKey  = "quaver",
                LargeImageText = ConfigManager.Username.Value,
                EndTimestamp   = 0
            };

            DiscordRpc.UpdatePresence(ref DiscordHelper.Presence);

            // Create bindable for selected map.
            if (MapManager.Mapsets.Count != 0)
            {
                MapManager.Selected = new Bindable <Map>(MapManager.Mapsets.First().Maps.First());
            }
        }
Exemplo n.º 3
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.º 4
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);
            }
        }