Ejemplo n.º 1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            HandleLoadingWheelAnimations();

            if (Screen.WorkingMap.HitObjects.Count != LastObjectCount)
            {
                ObjectCount.Text = $"Object Count: {Screen.WorkingMap.HitObjects.Count:n0}";
                RecalculateDifficulty();
            }

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (AudioEngine.Track.Rate != PreviousPlaybackRate)
            {
                PlaybackRate.Text = $"Playback Speed: {AudioEngine.Track.Rate:0.00}x";
            }

            var timingPoint = Screen.WorkingMap.GetTimingPointAt(AudioEngine.Track.Time);

            if (timingPoint == null)
            {
                Bpm.Text = "BPM: No Timing Point!";
            }
            else if (timingPoint != LastTimingPoint)
            {
                Bpm.Text = $"BPM: {timingPoint?.Bpm:0.00}";
            }

            LastTimingPoint      = timingPoint;
            LastObjectCount      = Screen.WorkingMap.HitObjects.Count;
            PreviousPlaybackRate = AudioEngine.Track.Rate;

            base.Update(gameTime);
        }
        /// <summary>
        /// </summary>
        /// <param name="tp"></param>
        /// <param name="isSelected"></param>
        private void OnTpButtonClicked(TimingPointInfo tp, bool isSelected)
        {
            var t = TimeSpan.FromMilliseconds(tp.StartTime);

            if (!ImGui.Button($"{t.Minutes:00}:{t.Seconds:00}:{t.Milliseconds:000}", new Vector2()))
            {
                return;
            }

            // User is holding control down, so add this SV to the selected ones
            if (KeyboardManager.CurrentState.IsKeyDown(Keys.LeftControl) ||
                KeyboardManager.CurrentState.IsKeyDown(Keys.LeftControl))
            {
                if (isSelected)
                {
                    if (SelectedTimingPoints.Count != 1)
                    {
                        SelectedTimingPoints.Remove(tp);
                    }

                    if (SelectedTimingPoints.Count == 1)
                    {
                        SetInputTextToFirstSelected();
                    }
                }
                else
                {
                    SelectedTimingPoints.Add(tp);

                    if (SelectedTimingPoints.Count == 1)
                    {
                        SetInputTextToFirstSelected();
                    }
                    else
                    {
                        TextTime = "";
                        TextBpm  = "";
                    }
                }
            }
            // Clicking the currently selected button seeks the user to that point in time
            else
            {
                if (isSelected && !AudioEngine.Track.IsDisposed)
                {
                    AudioEngine.Track.Seek(tp.StartTime);

                    var game   = GameBase.Game as QuaverGame;
                    var screen = game?.CurrentScreen as EditorScreen;
                    screen?.SetHitSoundObjectIndex();
                }

                SelectedTimingPoints.Clear();
                SelectedTimingPoints.Add(tp);

                TextTime = tp.StartTime.ToString(CultureInfo.InvariantCulture);
                TextBpm  = $"{tp.Bpm:0.00}";
            }
        }
 /// <summary>
 /// </summary>
 /// <param name="tp"></param>
 /// <param name="newTime"></param>
 /// <param name="newBpm"></param>
 public EditorTimingPointChangeInfo(TimingPointInfo tp, float newTime, float newBpm)
 {
     Info         = tp;
     OriginalTime = Info.StartTime;
     OriginalBpm  = Info.Bpm;
     NewTime      = newTime;
     NewBpm       = newBpm;
 }
Ejemplo n.º 4
0
        public TimingPoint(TimingPointInfo timingPoint, int volume, bool dontUseOffset)
        {
            var offset = dontUseOffset ? 0 : Osu.OsuBeatmap.QUAVER_TO_OSU_OFFSET;

            Time        = (int)Math.Round(timingPoint.StartTime) + offset;
            Uninherited = 1;
            // osu! can't handle 0 BPM, so it's replaced with a very low BPM value instead (0.000006 BPM).
            BeatLength = timingPoint.Bpm <= 0 ? -10e10 : timingPoint.MillisecondsPerBeat;
            Volume     = volume;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// </summary>
 /// <param name="tp"></param>
 /// <returns></returns>
 private Sprite CreateTimingPointLine(TimingPointInfo tp) => new Sprite
 {
     Parent    = this,
     Alignment = Alignment.TopCenter,
     Size      = new ScalableVector2(Width - 4, 2),
     Tint      = Color.Crimson,
     Y         = Height - Height * (float)(tp.StartTime / (AudioEngine.Track.Length)),
     Image     = Pixel,
     Alpha     = 0.85f
 };
Ejemplo n.º 6
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="container"></param>
        /// <param name="tp"></param>
        /// <param name="time"></param>
        /// <param name="index"></param>
        /// <param name="measureCount"></param>
        public TimelineTickLine(EditorScrollContainerKeys container, TimingPointInfo tp, float time, int index, int measureCount)
        {
            Container   = container;
            TimingPoint = tp;
            Index       = index;
            Time        = time;

            if (!IsMeasureLine)
            {
                return;
            }

            Y = -2;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// </summary>
        /// <param name="tp"></param>
        public void RemoveTimingPointLine(TimingPointInfo tp)
        {
            if (tp == null)
            {
                return;
            }

            if (TimingPointLines.ContainsKey(tp))
            {
                TimingPointLines[tp].Destroy();
                TimingPointLines.Remove(tp);
            }

            Container.ForceRecache();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// </summary>
        /// <param name="tp"></param>
        public void MoveTimingPointLine(TimingPointInfo tp)
        {
            if (tp == null || !TimingPointLines.ContainsKey(tp))
            {
                return;
            }

            TimingPointLines[tp].Y = Height - Height * (float)(tp.StartTime / AudioEngine.Track.Length);

            if (TimingPointLines[tp].Y < 0)
            {
                TimingPointLines[tp].Y = 0;
            }

            Container.ForceRecache();
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Returns color of note beatsnap
        /// </summary>
        /// <param name="info"></param>
        /// <param name="timingPoint"></param>
        /// <returns></returns>
        public static int GetBeatSnap(HitObjectInfo info, TimingPointInfo timingPoint)
        {
            // Add 2ms offset buffer space to offset and get beat length
            var pos        = info.StartTime - timingPoint.StartTime + 2;
            var beatlength = 60000 / timingPoint.Bpm;

            // subtract pos until it's less than beat length. multiple loops for efficiency
            while (pos >= beatlength * (1 << 16))
            {
                pos -= beatlength * (1 << 16);
            }
            while (pos >= beatlength * (1 << 12))
            {
                pos -= beatlength * (1 << 12);
            }
            while (pos >= beatlength * (1 << 8))
            {
                pos -= beatlength * (1 << 8);
            }
            while (pos >= beatlength * (1 << 4))
            {
                pos -= beatlength * (1 << 4);
            }
            while (pos >= beatlength)
            {
                pos -= beatlength;
            }

            // Calculate Note's snap index
            var index = (int)(Math.Floor(48 * pos / beatlength));

            // Return Color of snap index
            for (var i = 0; i < 8; i++)
            {
                if (index % BeatSnaps[i] == 0)
                {
                    return(i);
                }
            }

            // If it's not snapped to 1/16 or less, return 1/48 snap color
            return(8);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// </summary>
        private void CreateTextBpm()
        {
            var timingPoint = Screen.WorkingMap.GetTimingPointAt(AudioEngine.Track.Time);

            Bpm = new SpriteTextBitmap(FontsBitmap.AllerRegular,
                                       $"BPM: 0")
            {
                Parent   = this,
                X        = TextBeatSnap.X,
                Y        = TextDifficultyRating.Y + TextDifficultyRating.Height + 14,
                FontSize = 16,
            };

            if (timingPoint != null)
            {
                Bpm.Text = $"BPM: {timingPoint.Bpm:0.00}";
            }

            LastTimingPoint = timingPoint;
        }
Ejemplo n.º 11
0
        /// <summary>
        ///    Finds the length of a timing point.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public double GetTimingPointLength(TimingPointInfo point)
        {
            // Find the index of the current timing point.
            var index = TimingPoints.IndexOf(point);

            // ??
            if (index == -1)
            {
                throw new ArgumentException();
            }

            // There is another timing point ahead of this one
            // so we'll need to get the length of the two points.
            if (index + 1 < TimingPoints.Count)
            {
                return(TimingPoints[index + 1].StartTime - TimingPoints[index].StartTime);
            }

            // Only one timing point, so we can assume that it goes to the end of the map.
            return(Length - point.StartTime);
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     Returns color of note beatsnap
        /// </summary>
        /// <param name="info"></param>
        /// <param name="timingPoint"></param>
        /// <returns></returns>
        public static int GetBeatSnap(HitObjectInfo info, TimingPointInfo timingPoint)
        {
            // Add 2ms offset buffer space to offset and get beat length
            var pos        = info.StartTime - timingPoint.StartTime + 0;
            var beatlength = 60000 / timingPoint.Bpm;

            // Calculate Note's snap index
            var index = Math.Round(48 * pos / beatlength, MidpointRounding.AwayFromZero);

            // Return Color of snap index
            for (var i = 0; i < 8; i++)
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (index % BeatSnaps[i] == 0)
                {
                    return(i);
                }
            }

            // If it's not snapped to 1/16 or less, return 1/48 snap color
            return(8);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// </summary>
        private void SelectClosestPoint()
        {
            if (WorkingMap.TimingPoints.Count == 0)
            {
                return;
            }

            // Find the closest timing point so it can be selected upon opening.
            TimingPointInfo closestTimingPoint = null;
            var             minDiff            = double.MaxValue;

            WorkingMap.TimingPoints.ForEach(x =>
            {
                var diff = Math.Abs(AudioEngine.Track.Time - x.StartTime);

                if (!(diff < minDiff))
                {
                    return;
                }

                minDiff            = diff;
                closestTimingPoint = x;
            });

            if (closestTimingPoint == null)
            {
                return;
            }

            SelectedTimingPoints.Clear();
            SelectedTimingPoints.Add(closestTimingPoint);
            NeedsToScroll = true;

            TextTime = closestTimingPoint.StartTime.ToString(CultureInfo.InvariantCulture);
            TextBpm  = $"{closestTimingPoint.Bpm:0.00}";
        }
 /// <summary>
 /// </summary>
 /// <param name="workingMap"></param>
 /// <param name="tp"></param>
 public EditorActionAddTimingPoint(Qua workingMap, TimingPointInfo tp)
 {
     WorkingMap  = workingMap;
     TimingPoint = tp;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// </summary>
        private void HandleAddRemoveButtons()
        {
            if (ImGui.Button("Add"))
            {
                var tp = new TimingPointInfo()
                {
                    StartTime = (int)AudioEngine.Track.Time,
                    Bpm       = 0
                };

                var game   = GameBase.Game as QuaverGame;
                var screen = game?.CurrentScreen as EditorScreen;
                screen?.Ruleset.ActionManager.Perform(new EditorActionAddTimingPoint(WorkingMap, tp));

                SelectedTimingPoints.Clear();
                SelectedTimingPoints.Add(tp);
                NeedsToScroll = true;

                TextTime = tp.StartTime.ToString(CultureInfo.InvariantCulture);
                TextBpm  = $"{tp.Bpm:0.00}";
            }

            ImGui.SameLine();

            if (ImGui.Button("Remove"))
            {
                if (SelectedTimingPoints.Count == 0)
                {
                    return;
                }

                var game   = GameBase.Game as QuaverGame;
                var screen = game?.CurrentScreen as EditorScreen;

                var lastTp = SelectedTimingPoints.Last();

                screen?.Ruleset.ActionManager.Perform(new EditorActionRemoveTimingPoints(WorkingMap, new List <TimingPointInfo>(SelectedTimingPoints)));

                SelectedTimingPoints.Clear();

                if (WorkingMap.TimingPoints.Count != 0)
                {
                    var sv = WorkingMap.TimingPoints.FindLast(x => x.StartTime <= lastTp.StartTime);

                    if (sv != null)
                    {
                        TextTime = sv.StartTime.ToString(CultureInfo.InvariantCulture);
                        TextBpm  = $"{sv.Bpm:0.00}";
                        SelectedTimingPoints.Add(sv);
                    }
                    else
                    {
                        TextTime = "";
                        TextBpm  = $"";
                    }
                }
                else
                {
                    TextTime = "";
                    TextBpm  = $"";
                }

                NeedsToScroll = true;
            }
        }
Ejemplo n.º 16
0
        public static TimingPoint QuaTPToManiaTP(TimingPointInfo quaTP)
        {
            TimingPoint maniaTP = new TimingPoint((int)quaTP.StartTime, quaTP.MillisecondsPerBeat);

            return(maniaTP);
        }
 public AutoModIssueTimingPointAfterAudioEnd(TimingPointInfo timingPoint) : base(AutoModIssueLevel.Warning)
 {
     TimingPoint = timingPoint;
     Text        = $"The timing point at: {TimingPoint.StartTime} is placed after the audio ends.";
 }
Ejemplo n.º 18
0
 /// <summary>
 /// </summary>
 /// <param name="tp"></param>
 public void AddTimingPointLine(TimingPointInfo tp)
 {
     TimingPointLines[tp] = CreateTimingPointLine(tp);
     Container.ForceRecache();
 }