mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:13:34 +08:00
Simplify implementation
This commit is contained in:
parent
a9cbabf711
commit
2f786ffc32
@ -77,13 +77,16 @@ namespace osu.Game.Rulesets.Catch.Edit
|
||||
public override bool HandleReverse()
|
||||
{
|
||||
var hitObjects = EditorBeatmap.SelectedHitObjects
|
||||
.OfType<CatchHitObject>()
|
||||
.OrderBy(obj => obj.StartTime)
|
||||
.ToList();
|
||||
.OfType<CatchHitObject>()
|
||||
.OrderBy(obj => obj.StartTime)
|
||||
.ToList();
|
||||
|
||||
double selectionStartTime = SelectedItems.Min(h => h.StartTime);
|
||||
double selectionEndTime = SelectedItems.Max(h => h.GetEndTime());
|
||||
|
||||
// the expectation is that even if the objects themselves are reversed temporally,
|
||||
// the position of new combos in the selection should remain the same.
|
||||
// preserve it for later before doing the reversal.
|
||||
var newComboOrder = hitObjects.Select(obj => obj.NewCombo).ToList();
|
||||
|
||||
foreach (var h in hitObjects)
|
||||
@ -99,15 +102,11 @@ namespace osu.Game.Rulesets.Catch.Edit
|
||||
}
|
||||
}
|
||||
|
||||
// re-order objects again after flipping their times
|
||||
hitObjects = [.. hitObjects.OrderBy(obj => obj.StartTime)];
|
||||
// re-order objects by start time again after reversing, and restore new combo flag positioning
|
||||
hitObjects = hitObjects.OrderBy(obj => obj.StartTime).ToList();
|
||||
|
||||
int i = 0;
|
||||
foreach (bool newCombo in newComboOrder)
|
||||
{
|
||||
hitObjects[i].NewCombo = newCombo;
|
||||
i++;
|
||||
}
|
||||
for (int i = 0; i < hitObjects.Count; ++i)
|
||||
hitObjects[i].NewCombo = newComboOrder[i];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -79,15 +79,18 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
public override bool HandleReverse()
|
||||
{
|
||||
var hitObjects = EditorBeatmap.SelectedHitObjects
|
||||
.OfType<OsuHitObject>()
|
||||
.OrderBy(obj => obj.StartTime)
|
||||
.ToList();
|
||||
.OfType<OsuHitObject>()
|
||||
.OrderBy(obj => obj.StartTime)
|
||||
.ToList();
|
||||
|
||||
double endTime = hitObjects.Max(h => h.GetEndTime());
|
||||
double startTime = hitObjects.Min(h => h.StartTime);
|
||||
|
||||
bool moreThanOneObject = hitObjects.Count > 1;
|
||||
|
||||
// the expectation is that even if the objects themselves are reversed temporally,
|
||||
// the position of new combos in the selection should remain the same.
|
||||
// preserve it for later before doing the reversal.
|
||||
var newComboOrder = hitObjects.Select(obj => obj.NewCombo).ToList();
|
||||
|
||||
foreach (var h in hitObjects)
|
||||
@ -102,15 +105,11 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
}
|
||||
}
|
||||
|
||||
// re-order objects again after flipping their times
|
||||
hitObjects = [.. hitObjects.OrderBy(obj => obj.StartTime)];
|
||||
// re-order objects by start time again after reversing, and restore new combo flag positioning
|
||||
hitObjects = hitObjects.OrderBy(obj => obj.StartTime).ToList();
|
||||
|
||||
int i = 0;
|
||||
foreach (bool newCombo in newComboOrder)
|
||||
{
|
||||
hitObjects[i].NewCombo = newCombo;
|
||||
i++;
|
||||
}
|
||||
for (int i = 0; i < hitObjects.Count; ++i)
|
||||
hitObjects[i].NewCombo = newComboOrder[i];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user