Esempio n. 1
0
        private void SetGameTime(int time)
        {
            if (time == gameTime)
            {
                return; // prevent recursive calls
            }
            if (time > timeUpDown.Maximum)
            {
                return;
            }
            long totalMs = 0;

            gameTime         = time;
            timeUpDown.Value = gameTime;
            trackBar1.Value  = gameTime;
            PerfStopwatch.Start("Game Draw:".PadRight(25));
            skControl.Invalidate();
            totalMs += PerfStopwatch.Stop();

            // Update aim strain plot time range
            PerfStopwatch.Start("Aim strain plot update".PadRight(25));
            aimStrainPlot.plt.Clear();
            plotter.PlotPartialAimStrainGraph(
                aimStrainPlot.plt,
                gameTime - 2000, gameTime,
                aimStrainPeakTimes, aimStrainPeaks,
                denseAimStrainTimes, denseAimStrainValues,
                aimStrainTimes, aimStrainPerObjectValues);
            aimStrainPlot.plt.Axis(x1: gameTime - 2000, x2: gameTime, y1: 0, y2: aimStrainValues.Max() + 50);
            aimStrainPlot.Render();
            totalMs += PerfStopwatch.Stop();

            // Update aim strain meter
            PerfStopwatch.Start("Aim strain meter update".PadRight(25));
            aimStrainMeter.plt.Clear();
            plotter.UpdateAimStrainMeter(aimStrainMeter.plt, denseAimStrainTimes, denseAimStrainValues, aimStrainPeakTimes, aimStrainPeaks, gameTime);
            aimStrainMeter.Render();
            totalMs += PerfStopwatch.Stop();

            // Update sorted peaks graph
            PerfStopwatch.Start("Sorted peaks plot update".PadRight(25));
            if (plotter.ShouldRedrawSortedPeaksPlot(aimStrainPeakTimes, aimStrainPeaks, gameTime))
            {
                sortedPeaksPlot.plt.Clear();
                plotter.PlotSortedPeaks(sortedPeaksPlot.plt, aimStrainPeakTimes, aimStrainPeaks, gameTime);
                sortedPeaksPlot.Render();
            }
            totalMs += PerfStopwatch.Stop();
            Console.WriteLine($"total: {totalMs} ms ({1000 / totalMs} Hz)");
            Console.WriteLine("");
        }
Esempio n. 2
0
        private void LoadBeatmapFromFile(string beatmapPath)
        {
            // Load osu beatmap
            var convertBeatmap = ReadBeatmap(beatmapPath);

            beatmap = (OsuBeatmap) new OsuBeatmapConverter(convertBeatmap).Convert();
            var processor = new OsuBeatmapProcessor(beatmap);

            processor.PreProcess();
            processor.PostProcess();

            // Calculate difficulty
            var workingBeatmap = new PpWorkingBeatmap(convertBeatmap);

            calculator = new OsuDifficultyCalculator(new OsuRuleset(), workingBeatmap);
            var diffAttributes = calculator.Calculate(new Mod[] { });
            var aim            = (Aim)diffAttributes.Skills[0];

            aimStrainTimes           = aim.StrainTimes;
            aimStrainValues          = aim.StrainValues;
            aimStrainPeakTimes       = aim.strainPeakTimes;
            aimStrainPeaks           = aim.strainPeaks;
            aimStrainPerObjectValues = aim.StrainPerObjectValues;
            (denseAimStrainTimes, denseAimStrainValues) = plotter.CalculateDenseStrainValues(aim.StrainTimes, aim.StrainValues);

            // Plot aim strain
            PerfStopwatch.Start("Aim Strain Graph");
            aimStrainPlot.plt.Clear();
            plotter.InitAimStrainGraph(aimStrainPlot.plt);
            plotter.PlotFullAimStrainGraph(
                aimStrainPlot.plt,
                aimStrainPeakTimes, aimStrainPeaks,
                denseAimStrainTimes, denseAimStrainValues,
                aimStrainTimes, aimStrainPerObjectValues);
            aimStrainPlot.Render();
            PerfStopwatch.Stop();

            Text = $"bmviewer - {convertBeatmap}";

            // Update GUI controls
            // TODO: Use events to update values
            timeUpDown.Minimum = (int)beatmap.HitObjects.First().StartTime - 1000;
            trackBar1.Minimum  = (int)beatmap.HitObjects.First().StartTime - 1000;
            timeUpDown.Maximum = (int)beatmap.HitObjects.Last().StartTime + 10000;
            trackBar1.Maximum  = (int)beatmap.HitObjects.Last().StartTime + 10000;

            // Set initial game time
            SetGameTime((int)beatmap.HitObjects.First().StartTime - 1000);
            stopwatchStartTime = gameTime;
        }