Example #1
0
        public override void Draw()
        {
            TapWindow.Draw();

            List <Line> lineList = new List <Line>();
            Vector2     vCentre  = new Vector2(330, 360);

            //Determines the size of the metronome
            float hitObjectRadius = editor.hitObjectManager.HitObjectRadius;

            ControlPoint active = AudioEngine.ActiveControlPoint;
            float        mul    = active != null ? active.BpmMultiplier : 1;                      // Avoid nullref when no sections exist.

            float dist  = (float)(100 * BeatmapManager.Current.DifficultySliderMultiplier / mul); // Length of one beat
            float count = (int)(300 / dist);                                                      // Number of beats

            // Fix for very fast slider speeds: make the slider half a beat long.
            // This fix should hold for speeds up to 6.0x
            if (count == 0)
            {
                count = 0.5f;
            }

            float   totalLength = count * dist;
            Vector2 off         = new Vector2(totalLength * 0.5f, 0);

            lineList.Add(
                new Line(GameBase.WindowManager.ApplyRatio(vCentre - off), GameBase.WindowManager.ApplyRatio(vCentre + off)));
            GameBase.LineManager.Draw(lineList, hitObjectRadius * GameBase.WindowManager.RatioInverse, backgroundColour, 0,
                                      @"Standard", true);
            lineList.Clear();

            // fix tick spacing for slider (BPM) multiplier sections
            Vector2 pointDist = new Vector2((float)editor.hitObjectManager.SliderScoringPointDistance / mul, 0);

            Vector2 cp = vCentre - off;

            // Fix rounding error causing a missing tick.
            // In a perfect world, we could use tick RATE here, not distance.
            while (cp.X <= vCentre.X + off.X + 1.0f)
            {
                lineList.Add(new Line(GameBase.WindowManager.ApplyRatio(cp), GameBase.WindowManager.ApplyRatio(cp)));
                cp += pointDist;
            }

            cp = vCentre - off;

            GameBase.LineManager.Draw(lineList, hitObjectRadius * 0.2F * editor.hitObjectManager.SpriteRatio,
                                      Color.White, 0, @"Standard",
                                      true);
            lineList.Clear();


            double first = AudioEngine.BeatOffsetAt(AudioEngine.Time);

            // AllowMultiplier: FALSE, otherwise we compensate for slider multipliers TWICE and get the wrong value.
            double f = (AudioEngine.Time - first) / AudioEngine.BeatLengthAt(AudioEngine.Time, false);

            f *= dist;
            f  = f % (totalLength * 2);

            while (f < 0)
            {
                f += totalLength;
            }

            if (f >= totalLength)
            {
                f = (totalLength * 2) - f;
            }

            cp += new Vector2((float)f, 0);

            lineList.Add(new Line(GameBase.WindowManager.ApplyRatio(cp), GameBase.WindowManager.ApplyRatio(cp)));
            GameBase.LineManager.Draw(lineList, hitObjectRadius * GameBase.WindowManager.RatioInverse, metronomeColour, 0, @"Standard", true);
        }