mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 10:53:21 +08:00
complete version
This commit is contained in:
parent
19425ee180
commit
ac959e998e
@ -4,10 +4,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -29,6 +31,9 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
|
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ManiaModHoldOff) };
|
public override Type[] IncompatibleMods => new[] { typeof(ManiaModHoldOff) };
|
||||||
|
|
||||||
|
[SettingSource("Invert Long Notes", "Invert long notes into nothing.")]
|
||||||
|
public BindableBool FullInvert { get; } = new BindableBool();
|
||||||
|
|
||||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
var maniaBeatmap = (ManiaBeatmap)beatmap;
|
var maniaBeatmap = (ManiaBeatmap)beatmap;
|
||||||
@ -38,64 +43,46 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
foreach (var column in maniaBeatmap.HitObjects.GroupBy(h => h.Column))
|
foreach (var column in maniaBeatmap.HitObjects.GroupBy(h => h.Column))
|
||||||
{
|
{
|
||||||
var newColumnObjects = new List<ManiaHitObject>();
|
var newColumnObjects = new List<ManiaHitObject>();
|
||||||
if (true)
|
|
||||||
|
List<(double startTime, IList<HitSampleInfo> samples, string type)> locations;
|
||||||
|
|
||||||
|
if (FullInvert.Value)
|
||||||
{
|
{
|
||||||
|
locations = column.OfType<Note>().Select(n => (startTime: n.StartTime, samples: n.Samples, type: "note"))
|
||||||
var locations = column.Select(n => (startTime: n.StartTime, samples: n.Samples))
|
.Concat(column.OfType<HoldNote>().SelectMany(h => new[]
|
||||||
.OrderBy(h => h.startTime).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < locations.Count - 1; i++)
|
|
||||||
{
|
|
||||||
// Full duration of the hold note.
|
|
||||||
double duration = locations[i + 1].startTime - locations[i].startTime;
|
|
||||||
|
|
||||||
// Beat length at the end of the hold note.
|
|
||||||
double beatLength = beatmap.ControlPointInfo.TimingPointAt(locations[i + 1].startTime).BeatLength;
|
|
||||||
|
|
||||||
// Decrease the duration by at most a 1/4 beat to ensure there's no instantaneous notes.
|
|
||||||
duration = Math.Max(duration / 2, duration - beatLength / 4);
|
|
||||||
|
|
||||||
newColumnObjects.Add(new HoldNote
|
|
||||||
{
|
{
|
||||||
Column = column.Key,
|
(startTime: h.StartTime, samples: h.GetNodeSamples(0), type: "release"),
|
||||||
StartTime = locations[i].startTime,
|
(startTime: h.EndTime, samples: h.GetNodeSamples(1), type: "note")
|
||||||
Duration = duration,
|
}))
|
||||||
NodeSamples = new List<IList<HitSampleInfo>> { locations[i].samples, Array.Empty<HitSampleInfo>() }
|
.OrderBy(h => h.startTime).ToList();
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//var locations = column.OfType<Note>().Select(n => (startTime: n.StartTime, samples: n.Samples))
|
locations = column.Select(n => (startTime: n.StartTime, samples: n.Samples, type: "note"))
|
||||||
// .Concat(column.OfType<HoldNote>().SelectMany(h => new[]
|
.OrderBy(h => h.startTime).ToList();
|
||||||
// {
|
}
|
||||||
// (startTime: h.StartTime, samples: h.GetNodeSamples(0)),
|
for (int i = 0; i < locations.Count - 1; i++)
|
||||||
// (startTime: h.EndTime, samples: h.GetNodeSamples(1))
|
{
|
||||||
// }))
|
if (locations[i].type == "release")
|
||||||
// .OrderBy(h => h.startTime).ToList();
|
continue;
|
||||||
|
|
||||||
//for (int i = 0; i < locations.Count - 1; i++)
|
// Beat length at the end of the hold note.
|
||||||
//{
|
double beatLength = beatmap.ControlPointInfo.TimingPointAt(locations[i + 1].startTime).BeatLength;
|
||||||
// // Full duration of the hold note.
|
|
||||||
// double duration = locations[i + 1].startTime - locations[i].startTime;
|
|
||||||
|
|
||||||
// // Beat length at the end of the hold note.
|
// Full duration of the hold note.
|
||||||
// double beatLength = beatmap.ControlPointInfo.TimingPointAt(locations[i + 1].startTime).BeatLength;
|
double duration = locations[i + 1].startTime - locations[i].startTime;
|
||||||
|
|
||||||
// // Decrease the duration by at most a 1/4 beat to ensure there's no instantaneous notes.
|
if (locations[i + 1].type != "release")
|
||||||
// duration = Math.Max(duration / 2, duration - beatLength / 4);
|
// Decrease the duration by at most a 1/4 beat to ensure there's no instantaneous notes.
|
||||||
|
duration = Math.Max(duration / 2, duration - beatLength / 4);
|
||||||
|
|
||||||
// newColumnObjects.Add(new HoldNote
|
newColumnObjects.Add(new HoldNote
|
||||||
// {
|
{
|
||||||
// Column = column.Key,
|
Column = column.Key,
|
||||||
// StartTime = locations[i].startTime,
|
StartTime = locations[i].startTime,
|
||||||
// Duration = duration,
|
Duration = duration,
|
||||||
// NodeSamples = new List<IList<HitSampleInfo>> { locations[i].samples, Array.Empty<HitSampleInfo>() }
|
NodeSamples = new List<IList<HitSampleInfo>> { locations[i].samples, Array.Empty<HitSampleInfo>() }
|
||||||
// });
|
});
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
newObjects.AddRange(newColumnObjects);
|
newObjects.AddRange(newColumnObjects);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user