From 756cabd5d01a433413032bd5e500eec6c1aad4ba Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 29 Jun 2018 12:45:48 +0900 Subject: [PATCH 1/6] Add a preprocess method to BeatmapProcessor --- .../Beatmaps/CatchBeatmapProcessor.cs | 79 ++++++++++--------- .../Beatmaps/OsuBeatmapProcessor.cs | 4 +- osu.Game/Beatmaps/BeatmapProcessor.cs | 32 +++++--- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +- 4 files changed, 73 insertions(+), 49 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index 8473f5a36c..02395331dc 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -15,19 +15,26 @@ namespace osu.Game.Rulesets.Catch.Beatmaps { public class CatchBeatmapProcessor : BeatmapProcessor { + public const int RNG_SEED = 1337; + public CatchBeatmapProcessor(IBeatmap beatmap) : base(beatmap) { } - public override void PostProcess() + public override void PreProcess() { - applyPositionOffsets(); + base.PreProcess(); initialiseHyperDash((List)Beatmap.HitObjects); + } + public override void PostProcess() + { base.PostProcess(); + applyPositionOffsets(); + int index = 0; foreach (var obj in Beatmap.HitObjects.OfType()) { @@ -37,41 +44,6 @@ namespace osu.Game.Rulesets.Catch.Beatmaps } } - public const int RNG_SEED = 1337; - - private void applyPositionOffsets() - { - var rng = new FastRandom(RNG_SEED); - // todo: HardRock displacement should be applied here - - foreach (var obj in Beatmap.HitObjects) - { - switch (obj) - { - case BananaShower bananaShower: - foreach (var nested in bananaShower.NestedHitObjects) - { - ((BananaShower.Banana)nested).X = (float)rng.NextDouble(); - rng.Next(); // osu!stable retrieved a random banana type - rng.Next(); // osu!stable retrieved a random banana rotation - rng.Next(); // osu!stable retrieved a random banana colour - } - break; - case JuiceStream juiceStream: - foreach (var nested in juiceStream.NestedHitObjects) - { - var hitObject = (CatchHitObject)nested; - if (hitObject is TinyDroplet) - hitObject.X += rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH; - else if (hitObject is Droplet) - rng.Next(); // osu!stable retrieved a random droplet rotation - hitObject.X = MathHelper.Clamp(hitObject.X, 0, 1); - } - break; - } - } - } - private void initialiseHyperDash(List objects) { // todo: add difficulty adjust. @@ -115,5 +87,38 @@ namespace osu.Game.Rulesets.Catch.Beatmaps lastDirection = thisDirection; } } + + private void applyPositionOffsets() + { + var rng = new FastRandom(RNG_SEED); + // todo: HardRock displacement should be applied here + + foreach (var obj in Beatmap.HitObjects) + { + switch (obj) + { + case BananaShower bananaShower: + foreach (var nested in bananaShower.NestedHitObjects) + { + ((BananaShower.Banana)nested).X = (float)rng.NextDouble(); + rng.Next(); // osu!stable retrieved a random banana type + rng.Next(); // osu!stable retrieved a random banana rotation + rng.Next(); // osu!stable retrieved a random banana colour + } + break; + case JuiceStream juiceStream: + foreach (var nested in juiceStream.NestedHitObjects) + { + var hitObject = (CatchHitObject)nested; + if (hitObject is TinyDroplet) + hitObject.X += rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH; + else if (hitObject is Droplet) + rng.Next(); // osu!stable retrieved a random droplet rotation + hitObject.X = MathHelper.Clamp(hitObject.X, 0, 1); + } + break; + } + } + } } } diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs index c7c9f4a01a..6cea5df078 100644 --- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs @@ -15,10 +15,10 @@ namespace osu.Game.Rulesets.Osu.Beatmaps { } - public override void PostProcess() + public override void PreProcess() { + base.PreProcess(); applyStacking((Beatmap)Beatmap); - base.PostProcess(); } private void applyStacking(Beatmap beatmap) diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index bf1cd7d4ee..1fc22197fe 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -11,11 +11,27 @@ namespace osu.Game.Beatmaps IBeatmap Beatmap { get; } /// - /// Post-processes to add mode-specific components that aren't added during conversion. + /// Processes the converted prior to being invoked. /// - /// An example of such a usage is for combo colours. + /// Nested s generated during will not be present by this point, + /// and no mods will have been applied to the s. /// /// + /// + /// This can only be used to add alterations to s generated directly through the conversion process. + /// + void PreProcess(); + + /// + /// Processes the converted after has been invoked. + /// + /// Nested s generated during will be present by this point, + /// and mods will have been applied to all s. + /// + /// + /// + /// This should be used to add alterations to s while they are in their most playable state. + /// void PostProcess(); } @@ -32,13 +48,7 @@ namespace osu.Game.Beatmaps Beatmap = beatmap; } - /// - /// Post-processes a Beatmap to add mode-specific components that aren't added during conversion. - /// - /// An example of such a usage is for combo colours. - /// - /// - public virtual void PostProcess() + public virtual void PreProcess() { IHasComboInformation lastObj = null; @@ -62,5 +72,9 @@ namespace osu.Game.Beatmaps lastObj = obj; } } + + public virtual void PostProcess() + { + } } } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 1a65611a3d..1dc90b3d6c 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -116,6 +116,11 @@ namespace osu.Game.Beatmaps mod.ApplyToDifficulty(converted.BeatmapInfo.BaseDifficulty); } + IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted); + + // Pre-process + processor?.PreProcess(); + // Compute default values for hitobjects, including creating nested hitobjects in-case they're needed foreach (var obj in converted.HitObjects) obj.ApplyDefaults(converted.ControlPointInfo, converted.BeatmapInfo.BaseDifficulty); @@ -125,7 +130,7 @@ namespace osu.Game.Beatmaps mod.ApplyToHitObject(obj); // Post-process - rulesetInstance.CreateBeatmapProcessor(converted)?.PostProcess(); + processor?.PostProcess(); return converted; } From 99068debc41b68636402b866feab04700a01ef82 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 29 Jun 2018 13:07:00 +0900 Subject: [PATCH 2/6] Split out into separate interface + add xmldocs --- osu.Game/Beatmaps/BeatmapProcessor.cs | 32 +-------------------- osu.Game/Beatmaps/IBeatmapConverter.cs | 3 ++ osu.Game/Beatmaps/IBeatmapProcessor.cs | 40 ++++++++++++++++++++++++++ osu.Game/Rulesets/Ruleset.cs | 10 +++++++ 4 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 osu.Game/Beatmaps/IBeatmapProcessor.cs diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index 1fc22197fe..0173125e8b 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -6,39 +6,9 @@ using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Beatmaps { - public interface IBeatmapProcessor - { - IBeatmap Beatmap { get; } - - /// - /// Processes the converted prior to being invoked. - /// - /// Nested s generated during will not be present by this point, - /// and no mods will have been applied to the s. - /// - /// - /// - /// This can only be used to add alterations to s generated directly through the conversion process. - /// - void PreProcess(); - - /// - /// Processes the converted after has been invoked. - /// - /// Nested s generated during will be present by this point, - /// and mods will have been applied to all s. - /// - /// - /// - /// This should be used to add alterations to s while they are in their most playable state. - /// - void PostProcess(); - } - /// - /// Processes a post-converted Beatmap. + /// Provides functionality to alter a after it has been converted. /// - /// The type of HitObject contained in the Beatmap. public class BeatmapProcessor : IBeatmapProcessor { public IBeatmap Beatmap { get; } diff --git a/osu.Game/Beatmaps/IBeatmapConverter.cs b/osu.Game/Beatmaps/IBeatmapConverter.cs index 00566093b8..cbf9d184ac 100644 --- a/osu.Game/Beatmaps/IBeatmapConverter.cs +++ b/osu.Game/Beatmaps/IBeatmapConverter.cs @@ -7,6 +7,9 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Beatmaps { + /// + /// Provides functionality to convert a for a . + /// public interface IBeatmapConverter { /// diff --git a/osu.Game/Beatmaps/IBeatmapProcessor.cs b/osu.Game/Beatmaps/IBeatmapProcessor.cs new file mode 100644 index 0000000000..282662373a --- /dev/null +++ b/osu.Game/Beatmaps/IBeatmapProcessor.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps +{ + /// + /// Provides functionality to alter a after it has been converted. + /// + public interface IBeatmapProcessor + { + /// + /// The to process. This should already be converted to the applicable . + /// + IBeatmap Beatmap { get; } + + /// + /// Processes the converted prior to being invoked. + /// + /// Nested s generated during will not be present by this point, + /// and no mods will have been applied to the s. + /// + /// + /// + /// This can only be used to add alterations to s generated directly through the conversion process. + /// + void PreProcess(); + + /// + /// Processes the converted after has been invoked. + /// + /// Nested s generated during will be present by this point, + /// and mods will have been applied to all s. + /// + /// + /// + /// This should be used to add alterations to s while they are in their most playable state. + /// + void PostProcess(); + } +} diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index f818523a3d..82d9945ef7 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -57,8 +57,18 @@ namespace osu.Game.Rulesets /// public abstract RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap); + /// + /// Creates a to convert a to one that is applicable for this . + /// + /// The to be converted. + /// The . public abstract IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap); + /// + /// Optionally creates a to alter a after it has been converted. + /// + /// The to be processed. + /// The . public virtual IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => null; public abstract DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap); From 4fb276bab7ebfdabec52023027d30eeb1ebd3f98 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 29 Jun 2018 13:52:13 +0900 Subject: [PATCH 3/6] Move hyperdash init to PostProcess --- .../Beatmaps/CatchBeatmapProcessor.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index 02395331dc..aa05e5a4d6 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -22,19 +22,14 @@ namespace osu.Game.Rulesets.Catch.Beatmaps { } - public override void PreProcess() - { - base.PreProcess(); - - initialiseHyperDash((List)Beatmap.HitObjects); - } - public override void PostProcess() { base.PostProcess(); applyPositionOffsets(); + initialiseHyperDash((List)Beatmap.HitObjects); + int index = 0; foreach (var obj in Beatmap.HitObjects.OfType()) { From 98fb2e03c0bcf3ebc47e65855d82ab6ada6bf04e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 1 Jul 2018 18:03:15 +0900 Subject: [PATCH 4/6] Fix rulesets not loading in debug builds after running a release build --- osu.Game/Rulesets/RulesetStore.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs index a7a9fea5f2..513173ef2f 100644 --- a/osu.Game/Rulesets/RulesetStore.cs +++ b/osu.Game/Rulesets/RulesetStore.cs @@ -84,7 +84,13 @@ namespace osu.Game.Rulesets { try { - var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo), (RulesetInfo)null)).RulesetInfo; + var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo, asm => + { + // for the time being, let's ignore the version being loaded. + // this allows for debug builds to successfully load rulesets (even though debug rulesets have a 0.0.0 version). + asm.Version = null; + return Assembly.Load(asm); + }, null), (RulesetInfo)null)).RulesetInfo; r.Name = instanceInfo.Name; r.ShortName = instanceInfo.ShortName; From f007e71c87369e7e07e65fe5c1fdb2dae23d6ba2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 2 Jul 2018 12:31:41 +0900 Subject: [PATCH 5/6] Retrieve the mania key action through DI --- .../TestCaseColumn.cs | 6 ++-- .../TestCaseNotes.cs | 12 +++++-- .../TestCaseStage.cs | 4 +-- .../Objects/Drawables/DrawableHoldNote.cs | 22 ++++++------ .../Drawables/DrawableManiaHitObject.cs | 35 ++++++++++++------- .../Objects/Drawables/DrawableNote.cs | 6 ++-- osu.Game.Rulesets.Mania/UI/Column.cs | 25 ++++++------- .../UI/Components/ColumnBackground.cs | 10 +++--- .../UI/Components/ColumnKeyArea.cs | 11 +++--- .../UI/ManiaRulesetContainer.cs | 20 +++++------ osu.Game.Rulesets.Mania/UI/ManiaStage.cs | 2 +- 11 files changed, 83 insertions(+), 70 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/TestCaseColumn.cs b/osu.Game.Rulesets.Mania.Tests/TestCaseColumn.cs index 72f0b046b6..de2bfaed9c 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestCaseColumn.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestCaseColumn.cs @@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Mania.Tests var obj = new Note { Column = i, StartTime = Time.Current + 2000 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); - columns[i].Add(new DrawableNote(obj, columns[i].Action)); + columns[i].Add(new DrawableNote(obj)); } } @@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Mania.Tests var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); - columns[i].Add(new DrawableHoldNote(obj, columns[i].Action)); + columns[i].Add(new DrawableHoldNote(obj)); } } @@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Mania.Tests Origin = Anchor.Centre, Height = 0.85f, AccentColour = Color4.OrangeRed, - Action = action, + Action = { Value = action }, VisibleTimeRange = { Value = 2000 } }; diff --git a/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs b/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs index 4fdfac93b7..0f70ceece2 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestCaseNotes.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -63,7 +64,7 @@ namespace osu.Game.Rulesets.Mania.Tests AutoSizeAxes = Axes.Both, Child = new NoteContainer(direction, $"note, scrolling {direction.ToString().ToLower()}") { - Child = new DrawableNote(note, ManiaAction.Key1) { AccentColour = Color4.OrangeRed } + Child = new DrawableNote(note) { AccentColour = Color4.OrangeRed } } }; } @@ -78,7 +79,7 @@ namespace osu.Game.Rulesets.Mania.Tests AutoSizeAxes = Axes.Both, Child = new NoteContainer(direction, $"hold note, scrolling {direction.ToString().ToLower()}") { - Child = new DrawableHoldNote(note, ManiaAction.Key1) + Child = new DrawableHoldNote(note) { RelativeSizeAxes = Axes.Both, AccentColour = Color4.OrangeRed, @@ -136,6 +137,13 @@ namespace osu.Game.Rulesets.Mania.Tests }; } + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) + { + var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); + dependencies.CacheAs>(new Bindable()); + return dependencies; + } + protected override void Update() { base.Update(); diff --git a/osu.Game.Rulesets.Mania.Tests/TestCaseStage.cs b/osu.Game.Rulesets.Mania.Tests/TestCaseStage.cs index 9aff853ffd..8046c46fc1 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestCaseStage.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestCaseStage.cs @@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.Mania.Tests var obj = new Note { Column = i, StartTime = Time.Current + 2000 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); - stage.Add(new DrawableNote(obj, stage.Columns[i].Action)); + stage.Add(new DrawableNote(obj)); } } } @@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Mania.Tests var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); - stage.Add(new DrawableHoldNote(obj, stage.Columns[i].Action)); + stage.Add(new DrawableHoldNote(obj)); } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index ce0276f759..597450f223 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -38,8 +38,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container tickContainer; - public DrawableHoldNote(HoldNote hitObject, ManiaAction action) - : base(hitObject, action) + public DrawableHoldNote(HoldNote hitObject) + : base(hitObject) { RelativeSizeAxes = Axes.X; @@ -57,12 +57,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables HoldStartTime = () => holdStartTime }) }, - head = new DrawableHeadNote(this, action) + head = new DrawableHeadNote(this) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre }, - tail = new DrawableTailNote(this, action) + tail = new DrawableTailNote(this) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre @@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (Time.Current < HitObject.StartTime || Time.Current > HitObject.EndTime) return false; - if (action != Action) + if (action != Action.Value) return false; // The user has pressed during the body of the hold note, after the head note and its hit windows have passed @@ -135,7 +135,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (!holdStartTime.HasValue) return false; - if (action != Action) + if (action != Action.Value) return false; holdStartTime = null; @@ -154,8 +154,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { private readonly DrawableHoldNote holdNote; - public DrawableHeadNote(DrawableHoldNote holdNote, ManiaAction action) - : base(holdNote.HitObject.Head, action) + public DrawableHeadNote(DrawableHoldNote holdNote) + : base(holdNote.HitObject.Head) { this.holdNote = holdNote; } @@ -191,8 +191,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly DrawableHoldNote holdNote; - public DrawableTailNote(DrawableHoldNote holdNote, ManiaAction action) - : base(holdNote.HitObject.Tail, action) + public DrawableTailNote(DrawableHoldNote holdNote) + : base(holdNote.HitObject.Tail) { this.holdNote = holdNote; } @@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (!holdNote.holdStartTime.HasValue) return false; - if (action != Action) + if (action != Action.Value) return false; UpdateJudgement(true); diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 1271fae0c1..cb6196a890 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -10,30 +11,26 @@ using osu.Game.Rulesets.UI.Scrolling; namespace osu.Game.Rulesets.Mania.Objects.Drawables { - public abstract class DrawableManiaHitObject : DrawableHitObject - where TObject : ManiaHitObject + public abstract class DrawableManiaHitObject : DrawableHitObject { /// - /// The key that will trigger input for this hit object. + /// The which causes this to be hit. /// - protected ManiaAction Action { get; } - - public new TObject HitObject; + protected readonly IBindable Action = new Bindable(); protected readonly IBindable Direction = new Bindable(); - protected DrawableManiaHitObject(TObject hitObject, ManiaAction? action = null) + protected DrawableManiaHitObject(ManiaHitObject hitObject) : base(hitObject) { - HitObject = hitObject; - - if (action != null) - Action = action.Value; } - [BackgroundDependencyLoader] - private void load(IScrollingInfo scrollingInfo) + [BackgroundDependencyLoader(true)] + private void load([CanBeNull] IBindable action, [NotNull] IScrollingInfo scrollingInfo) { + if (action != null) + Action.BindTo(action); + Direction.BindTo(scrollingInfo.Direction); Direction.BindValueChanged(OnDirectionChanged, true); } @@ -42,6 +39,18 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { Anchor = Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; } + } + + public abstract class DrawableManiaHitObject : DrawableManiaHitObject + where TObject : ManiaHitObject + { + public new readonly TObject HitObject; + + protected DrawableManiaHitObject(TObject hitObject) + : base(hitObject) + { + HitObject = hitObject; + } protected override void UpdateState(ArmedState state) { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index fb4aa74ad1..18084c4c08 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -20,8 +20,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { private readonly NotePiece headPiece; - public DrawableNote(Note hitObject, ManiaAction action) - : base(hitObject, action) + public DrawableNote(Note hitObject) + : base(hitObject) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public virtual bool OnPressed(ManiaAction action) { - if (action != Action) + if (action != Action.Value) return false; return UpdateJudgement(true); diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index e731ce9195..a19a6fb5d4 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -7,6 +7,8 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Rulesets.Objects.Drawables; using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.UI.Components; @@ -19,21 +21,7 @@ namespace osu.Game.Rulesets.Mania.UI private const float column_width = 45; private const float special_column_width = 70; - private ManiaAction action; - - public ManiaAction Action - { - get => action; - set - { - if (action == value) - return; - action = value; - - background.Action = value; - keyArea.Action = value; - } - } + public readonly Bindable Action = new Bindable(); private readonly ColumnBackground background; private readonly ColumnKeyArea keyArea; @@ -130,6 +118,13 @@ namespace osu.Game.Rulesets.Mania.UI } } + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) + { + var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); + dependencies.CacheAs>(Action); + return dependencies; + } + /// /// Adds a DrawableHitObject to this Playfield. /// diff --git a/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs b/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs index 9b744bd254..19cc8fffef 100644 --- a/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs +++ b/osu.Game.Rulesets.Mania/UI/Components/ColumnBackground.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components { public class ColumnBackground : CompositeDrawable, IKeyBindingHandler, IHasAccentColour { - public ManiaAction Action; + private readonly IBindable action = new Bindable(); private Box background; private Box backgroundOverlay; @@ -25,8 +25,10 @@ namespace osu.Game.Rulesets.Mania.UI.Components private readonly IBindable direction = new Bindable(); [BackgroundDependencyLoader] - private void load(IScrollingInfo scrollingInfo) + private void load(IBindable action, IScrollingInfo scrollingInfo) { + this.action.BindTo(action); + InternalChildren = new[] { background = new Box @@ -91,14 +93,14 @@ namespace osu.Game.Rulesets.Mania.UI.Components public bool OnPressed(ManiaAction action) { - if (action == Action) + if (action == this.action.Value) backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint); return false; } public bool OnReleased(ManiaAction action) { - if (action == Action) + if (action == this.action.Value) backgroundOverlay.FadeTo(0, 250, Easing.OutQuint); return false; } diff --git a/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs b/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs index 4ce1614310..e30a033831 100644 --- a/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs +++ b/osu.Game.Rulesets.Mania/UI/Components/ColumnKeyArea.cs @@ -21,15 +21,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components private const float key_icon_size = 10; private const float key_icon_corner_radius = 3; - public ManiaAction Action; - + private readonly IBindable action = new Bindable(); private readonly IBindable direction = new Bindable(); private Container keyIcon; [BackgroundDependencyLoader] - private void load(IScrollingInfo scrollingInfo) + private void load(IBindable action, IScrollingInfo scrollingInfo) { + this.action.BindTo(action); + Drawable gradient; InternalChildren = new[] @@ -107,14 +108,14 @@ namespace osu.Game.Rulesets.Mania.UI.Components public bool OnPressed(ManiaAction action) { - if (action == Action) + if (action == this.action.Value) keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint); return false; } public bool OnReleased(ManiaAction action) { - if (action == Action) + if (action == this.action.Value) keyIcon.ScaleTo(1f, 125, Easing.OutQuint); return false; } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index fa6fba0cd8..e6ebf43c67 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -101,17 +101,15 @@ namespace osu.Game.Rulesets.Mania.UI protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) { - ManiaAction action = Playfield.Columns.ElementAt(h.Column).Action; - - var holdNote = h as HoldNote; - if (holdNote != null) - return new DrawableHoldNote(holdNote, action); - - var note = h as Note; - if (note != null) - return new DrawableNote(note, action); - - return null; + switch (h) + { + case HoldNote holdNote: + return new DrawableHoldNote(holdNote); + case Note note: + return new DrawableNote(note); + default: + return null; + } } protected override Vector2 PlayfieldArea => new Vector2(1, 0.8f); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs index 7b68582944..4c7deb4567 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs @@ -127,7 +127,7 @@ namespace osu.Game.Rulesets.Mania.UI var column = new Column(direction) { IsSpecial = isSpecial, - Action = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++ + Action = { Value = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++ } }; AddColumn(column); From b7893bc9947780cd5517fc09ea5ab90d98f66607 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Jul 2018 13:05:09 +0900 Subject: [PATCH 6/6] Remove unnecessary comments --- osu.Game/Beatmaps/WorkingBeatmap.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 1dc90b3d6c..74da978d9c 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -118,7 +118,6 @@ namespace osu.Game.Beatmaps IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted); - // Pre-process processor?.PreProcess(); // Compute default values for hitobjects, including creating nested hitobjects in-case they're needed @@ -129,7 +128,6 @@ namespace osu.Game.Beatmaps foreach (var obj in converted.HitObjects) mod.ApplyToHitObject(obj); - // Post-process processor?.PostProcess(); return converted;