From ac959e998e8ca094646e97dae71c00b418bcc8b3 Mon Sep 17 00:00:00 2001 From: Daiter Date: Wed, 6 Mar 2024 12:19:45 +0300 Subject: [PATCH 1/2] complete version --- .../Mods/ManiaModInvert.cs | 85 ++++++++----------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs index 6cb2cf74a2..6768c99aab 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs @@ -4,10 +4,12 @@ using System; using System.Collections.Generic; using System.Linq; +using osu.Framework.Bindables; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Game.Audio; using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mods; @@ -29,6 +31,9 @@ namespace osu.Game.Rulesets.Mania.Mods 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) { var maniaBeatmap = (ManiaBeatmap)beatmap; @@ -38,64 +43,46 @@ namespace osu.Game.Rulesets.Mania.Mods foreach (var column in maniaBeatmap.HitObjects.GroupBy(h => h.Column)) { var newColumnObjects = new List(); - if (true) + + List<(double startTime, IList samples, string type)> locations; + + if (FullInvert.Value) { - - var locations = column.Select(n => (startTime: n.StartTime, samples: n.Samples)) - .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 + locations = column.OfType().Select(n => (startTime: n.StartTime, samples: n.Samples, type: "note")) + .Concat(column.OfType().SelectMany(h => new[] { - Column = column.Key, - StartTime = locations[i].startTime, - Duration = duration, - NodeSamples = new List> { locations[i].samples, Array.Empty() } - }); - } - + (startTime: h.StartTime, samples: h.GetNodeSamples(0), type: "release"), + (startTime: h.EndTime, samples: h.GetNodeSamples(1), type: "note") + })) + .OrderBy(h => h.startTime).ToList(); } else { - //var locations = column.OfType().Select(n => (startTime: n.StartTime, samples: n.Samples)) - // .Concat(column.OfType().SelectMany(h => new[] - // { - // (startTime: h.StartTime, samples: h.GetNodeSamples(0)), - // (startTime: h.EndTime, samples: h.GetNodeSamples(1)) - // })) - // .OrderBy(h => h.startTime).ToList(); + locations = column.Select(n => (startTime: n.StartTime, samples: n.Samples, type: "note")) + .OrderBy(h => h.startTime).ToList(); + } + for (int i = 0; i < locations.Count - 1; i++) + { + if (locations[i].type == "release") + continue; - //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; - // // 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; - // // 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); + if (locations[i + 1].type != "release") + // 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 = locations[i].startTime, - // Duration = duration, - // NodeSamples = new List> { locations[i].samples, Array.Empty() } - // }); - //} + newColumnObjects.Add(new HoldNote + { + Column = column.Key, + StartTime = locations[i].startTime, + Duration = duration, + NodeSamples = new List> { locations[i].samples, Array.Empty() } + }); } newObjects.AddRange(newColumnObjects); } From a7123bf869f799b6083f2b27acec30cd079d1abe Mon Sep 17 00:00:00 2001 From: Daiter Date: Wed, 6 Mar 2024 13:07:30 +0300 Subject: [PATCH 2/2] fm --- osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs index 6768c99aab..ecb11ba377 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs @@ -47,7 +47,6 @@ namespace osu.Game.Rulesets.Mania.Mods List<(double startTime, IList samples, string type)> locations; if (FullInvert.Value) - { locations = column.OfType().Select(n => (startTime: n.StartTime, samples: n.Samples, type: "note")) .Concat(column.OfType().SelectMany(h => new[] { @@ -55,12 +54,10 @@ namespace osu.Game.Rulesets.Mania.Mods (startTime: h.EndTime, samples: h.GetNodeSamples(1), type: "note") })) .OrderBy(h => h.startTime).ToList(); - } else - { locations = column.Select(n => (startTime: n.StartTime, samples: n.Samples, type: "note")) .OrderBy(h => h.startTime).ToList(); - } + for (int i = 0; i < locations.Count - 1; i++) { if (locations[i].type == "release") @@ -84,6 +81,7 @@ namespace osu.Game.Rulesets.Mania.Mods NodeSamples = new List> { locations[i].samples, Array.Empty() } }); } + newObjects.AddRange(newColumnObjects); }