mirror of
https://github.com/osukey/osukey.git
synced 2025-05-31 02:17:34 +09:00
Merge pull request #18531 from peppy/track-groups-better
Improve group tracking logic to avoid switching which point type unnecessarily
This commit is contained in:
commit
dd93fc283b
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -146,6 +147,8 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
trackActivePoint();
|
trackActivePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Type trackedType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Given the user has selected a control point group, we want to track any group which is
|
/// Given the user has selected a control point group, we want to track any group which is
|
||||||
/// active at the current point in time which matches the type the user has selected.
|
/// active at the current point in time which matches the type the user has selected.
|
||||||
@ -156,16 +159,27 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
private void trackActivePoint()
|
private void trackActivePoint()
|
||||||
{
|
{
|
||||||
// For simplicity only match on the first type of the active control point.
|
// For simplicity only match on the first type of the active control point.
|
||||||
var selectedPointType = selectedGroup.Value?.ControlPoints.FirstOrDefault()?.GetType();
|
if (selectedGroup.Value == null)
|
||||||
|
trackedType = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If the selected group only has one control point, update the tracking type.
|
||||||
|
if (selectedGroup.Value.ControlPoints.Count == 1)
|
||||||
|
trackedType = selectedGroup.Value?.ControlPoints.Single().GetType();
|
||||||
|
// If the selected group has more than one control point, choose the first as the tracking type
|
||||||
|
// if we don't already have a singular tracked type.
|
||||||
|
else if (trackedType == null)
|
||||||
|
trackedType = selectedGroup.Value?.ControlPoints.FirstOrDefault()?.GetType();
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedPointType != null)
|
if (trackedType != null)
|
||||||
{
|
{
|
||||||
// We don't have an efficient way of looking up groups currently, only individual point types.
|
// We don't have an efficient way of looking up groups currently, only individual point types.
|
||||||
// To improve the efficiency of this in the future, we should reconsider the overall structure of ControlPointInfo.
|
// To improve the efficiency of this in the future, we should reconsider the overall structure of ControlPointInfo.
|
||||||
|
|
||||||
// Find the next group which has the same type as the selected one.
|
// Find the next group which has the same type as the selected one.
|
||||||
var found = Beatmap.ControlPointInfo.Groups
|
var found = Beatmap.ControlPointInfo.Groups
|
||||||
.Where(g => g.ControlPoints.Any(cp => cp.GetType() == selectedPointType))
|
.Where(g => g.ControlPoints.Any(cp => cp.GetType() == trackedType))
|
||||||
.LastOrDefault(g => g.Time <= clock.CurrentTimeAccurate);
|
.LastOrDefault(g => g.Time <= clock.CurrentTimeAccurate);
|
||||||
|
|
||||||
if (found != null)
|
if (found != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user