From eed0f3a1de4e277ad9e0513963ac56385d1abfcb Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 11 Mar 2018 21:02:14 +0100 Subject: [PATCH 01/33] Added setting to not hide the first object in Hidden mod --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 50 +++++++++++++--- osu.Game/Configuration/OsuConfigManager.cs | 5 +- .../Sections/Gameplay/GeneralSettings.cs | 5 ++ osu.Game/Rulesets/Mods/IReadFromConfig.cs | 15 +++++ osu.Game/Rulesets/UI/RulesetContainer.cs | 58 ++++++++++++------- osu.Game/osu.Game.csproj | 1 + 6 files changed, 102 insertions(+), 32 deletions(-) create mode 100644 osu.Game/Rulesets/Mods/IReadFromConfig.cs diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 4aeb76121a..02730e644e 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -7,32 +7,51 @@ using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Objects.Types; +using osu.Game.Configuration; namespace osu.Game.Rulesets.Osu.Mods { - public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects + public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects, IReadFromConfig { public override string Description => @"Play with no approach circles and fading notes for a slight score advantage."; public override double ScoreMultiplier => 1.06; private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; + private bool IncreaseFirstObjectVisibility = true; + private IEnumerable drawables; - public void ApplyToDrawableHitObjects(IEnumerable drawables) + private void applyMod() { - foreach (var d in drawables.OfType()) + if (IncreaseFirstObjectVisibility) { - d.ApplyCustomUpdateState += ApplyHiddenState; + foreach (var d in drawables.OfType()) + { + //Don't hide the first object + if (d.ChildID == 1) continue; + d.ApplyCustomUpdateState += ApplyHiddenState; - d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; - foreach (var h in d.HitObject.NestedHitObjects.OfType()) - h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; + d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; + foreach (var h in d.HitObject.NestedHitObjects.OfType()) + h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; + + } + } + else + { + foreach (var d in drawables.OfType()) + { + d.ApplyCustomUpdateState += ApplyHiddenState; + + d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; + foreach (var h in d.HitObject.NestedHitObjects.OfType()) + h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; + } } } - protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state) { if (!(drawable is DrawableOsuHitObject d)) @@ -83,5 +102,18 @@ namespace osu.Game.Rulesets.Osu.Mods break; } } + + public void ApplyToConfig(OsuConfigManager config) + { + IncreaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); + //This starts the process of applying the mod effects. We start it here since this is the last void called. + applyMod(); + } + + public void ApplyToDrawableHitObjects(IEnumerable drawables) + { + this.drawables = drawables; + } + } } diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 3d927ef67c..37a7da5515 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -78,6 +78,8 @@ namespace osu.Game.Configuration Set(OsuSetting.SpeedChangeVisualisation, SpeedChangeVisualisationMethod.Sequential); + Set(OsuSetting.IncreaseFirstObjectVisibility, true); + // Update Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer); @@ -125,6 +127,7 @@ namespace osu.Game.Configuration Version, ShowConvertedBeatmaps, SpeedChangeVisualisation, - Skin + Skin, + IncreaseFirstObjectVisibility } } diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index b60b0d9531..1d2dc50105 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -38,6 +38,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuSetting.KeyOverlay) }, + new SettingsCheckbox + { + LabelText = "Increase the first object's visibility in \"Hidden\" mod", + Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) + }, }; } } diff --git a/osu.Game/Rulesets/Mods/IReadFromConfig.cs b/osu.Game/Rulesets/Mods/IReadFromConfig.cs new file mode 100644 index 0000000000..9452f5ee1e --- /dev/null +++ b/osu.Game/Rulesets/Mods/IReadFromConfig.cs @@ -0,0 +1,15 @@ +using osu.Framework.Allocation; +using osu.Game.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.Rulesets.Mods +{ + public interface IReadFromConfig + { + void ApplyToConfig(OsuConfigManager config); + } +} diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 780bc5c86b..86429cd36c 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -67,6 +67,7 @@ namespace osu.Game.Rulesets.UI /// public readonly CursorContainer Cursor; + protected readonly Ruleset Ruleset; private IRulesetConfigManager rulesetConfig; @@ -89,11 +90,9 @@ namespace osu.Game.Rulesets.UI Cursor = CreateCursor(); } - [BackgroundDependencyLoader(true)] + [BackgroundDependencyLoader] private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) { - this.onScreenDisplay = onScreenDisplay; - rulesetConfig = CreateConfig(Ruleset, settings); if (rulesetConfig != null) @@ -101,6 +100,7 @@ namespace osu.Game.Rulesets.UI dependencies.Cache(rulesetConfig); onScreenDisplay?.BeginTracking(this, rulesetConfig); } + } public abstract ScoreProcessor CreateScoreProcessor(); @@ -167,6 +167,7 @@ namespace osu.Game.Rulesets.UI public abstract class RulesetContainer : RulesetContainer where TObject : HitObject { + public event Action OnJudgement; public event Action OnJudgementRemoved; @@ -195,10 +196,34 @@ namespace osu.Game.Rulesets.UI /// public readonly bool IsForCurrentRuleset; + public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(this); protected override Container Content => content; private Container content; + private IEnumerable mods; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + + KeyBindingInputManager.Add(content = new Container + { + RelativeSizeAxes = Axes.Both, + }); + + AddInternal(KeyBindingInputManager); + KeyBindingInputManager.Add(Playfield); + + if (Cursor != null) + KeyBindingInputManager.Add(Cursor); + + loadObjects(); + + // Apply mods + applyMods(Mods, config); + + } /// /// Whether to assume the beatmap passed into this is for the current ruleset. @@ -247,34 +272,19 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager.RelativeSizeAxes = Axes.Both; // Add mods, should always be the last thing applied to give full control to mods - applyMods(Mods); + // Mods are now added in the load() method, this method is still executed after the constructor + // so they are still added in last + } - [BackgroundDependencyLoader] - private void load() - { - KeyBindingInputManager.Add(content = new Container - { - RelativeSizeAxes = Axes.Both, - }); - AddInternal(KeyBindingInputManager); - KeyBindingInputManager.Add(Playfield); - - if (Cursor != null) - KeyBindingInputManager.Add(Cursor); - - loadObjects(); - } /// /// Applies the active mods to this RulesetContainer. /// /// - private void applyMods(IEnumerable mods) + private void applyMods(IEnumerable mods, OsuConfigManager config) { - if (mods == null) - return; foreach (var mod in mods.OfType>()) foreach (var obj in Beatmap.HitObjects) @@ -282,6 +292,10 @@ namespace osu.Game.Rulesets.UI foreach (var mod in mods.OfType>()) mod.ApplyToRulesetContainer(this); + + foreach (var mod in mods.OfType()) + mod.ApplyToConfig(config); + } public override void SetReplay(Replay replay) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d10f0085cc..74a3b94388 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -372,6 +372,7 @@ + From ea6434a7a07d840e61ed768e0a091e560ec7632f Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 11 Mar 2018 21:19:34 +0100 Subject: [PATCH 02/33] Why this line got deleted :thinking: --- osu.Game/Rulesets/UI/RulesetContainer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 86429cd36c..03a3666cdd 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -93,6 +93,8 @@ namespace osu.Game.Rulesets.UI [BackgroundDependencyLoader] private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) { + this.onScreenDisplay = onScreenDisplay; + rulesetConfig = CreateConfig(Ruleset, settings); if (rulesetConfig != null) @@ -272,8 +274,9 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager.RelativeSizeAxes = Axes.Both; // Add mods, should always be the last thing applied to give full control to mods - // Mods are now added in the load() method, this method is still executed after the constructor - // so they are still added in last + // Mods are now added in the load() method because we need the OsuConfigManager + // for the IReadFromConfig implementations. Rhis method is still executed after the constructor, + // so the mods are still added in last } From 6a8bc067cd1a5ee9fbcfa67091244d7c32d2aa67 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 11 Mar 2018 21:30:48 +0100 Subject: [PATCH 03/33] Add license header --- osu.Game/Rulesets/Mods/IReadFromConfig.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Mods/IReadFromConfig.cs b/osu.Game/Rulesets/Mods/IReadFromConfig.cs index 9452f5ee1e..f891d42217 100644 --- a/osu.Game/Rulesets/Mods/IReadFromConfig.cs +++ b/osu.Game/Rulesets/Mods/IReadFromConfig.cs @@ -1,10 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + using osu.Game.Configuration; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Rulesets.Mods { From 9516bec13d048f04bc0113b5d607a80ed745bc9d Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 11 Mar 2018 21:45:15 +0100 Subject: [PATCH 04/33] Fix naming rule --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 02730e644e..4da3459b7f 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -21,12 +21,12 @@ namespace osu.Game.Rulesets.Osu.Mods private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; - private bool IncreaseFirstObjectVisibility = true; + private bool increaseFirstObjectVisibility = true; private IEnumerable drawables; private void applyMod() { - if (IncreaseFirstObjectVisibility) + if (increaseFirstObjectVisibility) { foreach (var d in drawables.OfType()) { @@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Osu.Mods public void ApplyToConfig(OsuConfigManager config) { - IncreaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); + increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); //This starts the process of applying the mod effects. We start it here since this is the last void called. applyMod(); } From 802a6870c4ad1d8788b4988042d8efe5c652514a Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 11 Mar 2018 22:09:16 +0100 Subject: [PATCH 05/33] Chesterton's fence --- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 03a3666cdd..5e0bad9b74 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.UI Cursor = CreateCursor(); } - [BackgroundDependencyLoader] + [BackgroundDependencyLoader(true)] private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) { this.onScreenDisplay = onScreenDisplay; From 6d9e78a3a3b94689e1892cc37dcc7d693eab92e9 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 11 Mar 2018 22:40:49 +0100 Subject: [PATCH 06/33] Review changes --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 18 ++---------------- .../Sections/Gameplay/GeneralSettings.cs | 2 +- osu.Game/Rulesets/Mods/IReadFromConfig.cs | 2 +- osu.Game/Rulesets/UI/RulesetContainer.cs | 14 ++++---------- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 4da3459b7f..7e5a629ca9 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -26,12 +26,10 @@ namespace osu.Game.Rulesets.Osu.Mods private void applyMod() { - if (increaseFirstObjectVisibility) - { foreach (var d in drawables.OfType()) { //Don't hide the first object - if (d.ChildID == 1) continue; + if (d.ChildID == 1 && increaseFirstObjectVisibility) continue; d.ApplyCustomUpdateState += ApplyHiddenState; d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; @@ -39,18 +37,6 @@ namespace osu.Game.Rulesets.Osu.Mods h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; } - } - else - { - foreach (var d in drawables.OfType()) - { - d.ApplyCustomUpdateState += ApplyHiddenState; - - d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; - foreach (var h in d.HitObject.NestedHitObjects.OfType()) - h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; - } - } } protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state) { @@ -103,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.Mods } } - public void ApplyToConfig(OsuConfigManager config) + public void ReadFromConfig(OsuConfigManager config) { increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); //This starts the process of applying the mod effects. We start it here since this is the last void called. diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 1d2dc50105..7501bd4150 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -40,7 +40,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay }, new SettingsCheckbox { - LabelText = "Increase the first object's visibility in \"Hidden\" mod", + LabelText = "Show approach circle on first \"Hidden\" object", Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) }, }; diff --git a/osu.Game/Rulesets/Mods/IReadFromConfig.cs b/osu.Game/Rulesets/Mods/IReadFromConfig.cs index f891d42217..708edcfdfb 100644 --- a/osu.Game/Rulesets/Mods/IReadFromConfig.cs +++ b/osu.Game/Rulesets/Mods/IReadFromConfig.cs @@ -7,6 +7,6 @@ namespace osu.Game.Rulesets.Mods { public interface IReadFromConfig { - void ApplyToConfig(OsuConfigManager config); + void ReadFromConfig(OsuConfigManager config); } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 5e0bad9b74..f8c56b2bd2 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -67,7 +67,6 @@ namespace osu.Game.Rulesets.UI /// public readonly CursorContainer Cursor; - protected readonly Ruleset Ruleset; private IRulesetConfigManager rulesetConfig; @@ -102,7 +101,6 @@ namespace osu.Game.Rulesets.UI dependencies.Cache(rulesetConfig); onScreenDisplay?.BeginTracking(this, rulesetConfig); } - } public abstract ScoreProcessor CreateScoreProcessor(); @@ -169,7 +167,6 @@ namespace osu.Game.Rulesets.UI public abstract class RulesetContainer : RulesetContainer where TObject : HitObject { - public event Action OnJudgement; public event Action OnJudgementRemoved; @@ -198,7 +195,6 @@ namespace osu.Game.Rulesets.UI /// public readonly bool IsForCurrentRuleset; - public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(this); protected override Container Content => content; @@ -208,7 +204,6 @@ namespace osu.Game.Rulesets.UI [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - KeyBindingInputManager.Add(content = new Container { RelativeSizeAxes = Axes.Both, @@ -224,7 +219,6 @@ namespace osu.Game.Rulesets.UI // Apply mods applyMods(Mods, config); - } /// @@ -275,9 +269,8 @@ namespace osu.Game.Rulesets.UI // Add mods, should always be the last thing applied to give full control to mods // Mods are now added in the load() method because we need the OsuConfigManager - // for the IReadFromConfig implementations. Rhis method is still executed after the constructor, + // for the IReadFromConfig implementations. This method is still executed after the constructor, // so the mods are still added in last - } @@ -288,6 +281,8 @@ namespace osu.Game.Rulesets.UI /// private void applyMods(IEnumerable mods, OsuConfigManager config) { + if (mods == null) + return; foreach (var mod in mods.OfType>()) foreach (var obj in Beatmap.HitObjects) @@ -297,8 +292,7 @@ namespace osu.Game.Rulesets.UI mod.ApplyToRulesetContainer(this); foreach (var mod in mods.OfType()) - mod.ApplyToConfig(config); - + mod.ReadFromConfig(config); } public override void SetReplay(Replay replay) From 8a86766324e83f7e3f7550f8aab93984b9d6350b Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 13 Mar 2018 23:21:47 +0100 Subject: [PATCH 07/33] Changes requests --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 47 +++++++++------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 7e5a629ca9..57f6389f78 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -11,6 +11,7 @@ using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Configuration; +using osu.Framework.Configuration; namespace osu.Game.Rulesets.Osu.Mods { @@ -18,26 +19,29 @@ namespace osu.Game.Rulesets.Osu.Mods { public override string Description => @"Play with no approach circles and fading notes for a slight score advantage."; public override double ScoreMultiplier => 1.06; - private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; - private bool increaseFirstObjectVisibility = true; - private IEnumerable drawables; + private Bindable increaseFirstObjectVisibility; - private void applyMod() + public void ReadFromConfig(OsuConfigManager config) { - foreach (var d in drawables.OfType()) - { - //Don't hide the first object - if (d.ChildID == 1 && increaseFirstObjectVisibility) continue; - d.ApplyCustomUpdateState += ApplyHiddenState; - - d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; - foreach (var h in d.HitObject.NestedHitObjects.OfType()) - h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; - - } + increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); } + + public void ApplyToDrawableHitObjects(IEnumerable drawables) + { + foreach (var d in drawables.OfType()) + { + //Don't hide the first object ("drawables" are in a reverse order -> Last() ) + if (d == drawables.Last() && increaseFirstObjectVisibility) continue; + d.ApplyCustomUpdateState += ApplyHiddenState; + + d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; + foreach (var h in d.HitObject.NestedHitObjects.OfType()) + h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; + } + } + protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state) { if (!(drawable is DrawableOsuHitObject d)) @@ -88,18 +92,5 @@ namespace osu.Game.Rulesets.Osu.Mods break; } } - - public void ReadFromConfig(OsuConfigManager config) - { - increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); - //This starts the process of applying the mod effects. We start it here since this is the last void called. - applyMod(); - } - - public void ApplyToDrawableHitObjects(IEnumerable drawables) - { - this.drawables = drawables; - } - } } From 92b47d87ba6cf003cce96c6fabe18bf67f02a8f6 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Wed, 14 Mar 2018 23:14:03 +0100 Subject: [PATCH 08/33] makes more sense but not fixed --- osu.Game/Rulesets/UI/RulesetContainer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index f8c56b2bd2..b945d887f7 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -202,8 +202,11 @@ namespace osu.Game.Rulesets.UI private IEnumerable mods; [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(OsuConfigManager osuConfig) { + // Apply mods + applyMods(Mods, osuConfig); + KeyBindingInputManager.Add(content = new Container { RelativeSizeAxes = Axes.Both, @@ -216,9 +219,6 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager.Add(Cursor); loadObjects(); - - // Apply mods - applyMods(Mods, config); } /// @@ -284,15 +284,15 @@ namespace osu.Game.Rulesets.UI if (mods == null) return; + foreach (var mod in mods.OfType()) + mod.ReadFromConfig(config); + foreach (var mod in mods.OfType>()) foreach (var obj in Beatmap.HitObjects) mod.ApplyToHitObject(obj); foreach (var mod in mods.OfType>()) mod.ApplyToRulesetContainer(this); - - foreach (var mod in mods.OfType()) - mod.ReadFromConfig(config); } public override void SetReplay(Replay replay) From fea8f868d7e8ce63f51d1e5b8aeabc34fc94565c Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sat, 17 Mar 2018 13:22:58 +0100 Subject: [PATCH 09/33] Fixing hidden test bug --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 57f6389f78..b6b17166b1 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Mods public override double ScoreMultiplier => 1.06; private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; - private Bindable increaseFirstObjectVisibility; + private Bindable increaseFirstObjectVisibility = new Bindable(false); public void ReadFromConfig(OsuConfigManager config) { From 9252203916f7a2f1bd353e79547f9211206c18b2 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 20 Mar 2018 18:23:41 +0100 Subject: [PATCH 10/33] build fix --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index b6b17166b1..8c4dac03a3 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Mods public override double ScoreMultiplier => 1.06; private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; - private Bindable increaseFirstObjectVisibility = new Bindable(false); + private Bindable increaseFirstObjectVisibility; public void ReadFromConfig(OsuConfigManager config) { @@ -30,10 +30,13 @@ namespace osu.Game.Rulesets.Osu.Mods public void ApplyToDrawableHitObjects(IEnumerable drawables) { + //In the Tests for hidden the ReadFromConfig() void isn't called -> the following bindable is null + //It's too much work to get the Dependency Injection on the Tests to get the config for just this mod, so I just make sure + //the bindable isn't null foreach (var d in drawables.OfType()) { //Don't hide the first object ("drawables" are in a reverse order -> Last() ) - if (d == drawables.Last() && increaseFirstObjectVisibility) continue; + if (d == drawables.Last() && (increaseFirstObjectVisibility == null || increaseFirstObjectVisibility)) continue; d.ApplyCustomUpdateState += ApplyHiddenState; d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; From 87b9ffced2ea92fa12506ae4c18dc7317806076b Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 20 Mar 2018 21:51:05 +0100 Subject: [PATCH 11/33] added description of the IReadFromConfig interface --- osu.Game/Rulesets/Mods/IReadFromConfig.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Rulesets/Mods/IReadFromConfig.cs b/osu.Game/Rulesets/Mods/IReadFromConfig.cs index 708edcfdfb..ec9fd00356 100644 --- a/osu.Game/Rulesets/Mods/IReadFromConfig.cs +++ b/osu.Game/Rulesets/Mods/IReadFromConfig.cs @@ -5,6 +5,9 @@ using osu.Game.Configuration; namespace osu.Game.Rulesets.Mods { + /// + /// An interface for mods that require reading access to the osu! configuration. + /// public interface IReadFromConfig { void ReadFromConfig(OsuConfigManager config); From 4068be1293d32d060cac90b15f6e360a11d34c8f Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 20 Mar 2018 21:54:44 +0100 Subject: [PATCH 12/33] cleared comment --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 8c4dac03a3..66eba5890a 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -30,12 +30,11 @@ namespace osu.Game.Rulesets.Osu.Mods public void ApplyToDrawableHitObjects(IEnumerable drawables) { - //In the Tests for hidden the ReadFromConfig() void isn't called -> the following bindable is null - //It's too much work to get the Dependency Injection on the Tests to get the config for just this mod, so I just make sure - //the bindable isn't null foreach (var d in drawables.OfType()) { //Don't hide the first object ("drawables" are in a reverse order -> Last() ) + //If increaseFirstObjectVisibility is null then we're exectuing one of the tests for the hidden mod. Since it's too much + //work for just this interface to work on this tests (DI of the config..), I just make sure to not throw a null exception if (d == drawables.Last() && (increaseFirstObjectVisibility == null || increaseFirstObjectVisibility)) continue; d.ApplyCustomUpdateState += ApplyHiddenState; From cdbe6bf22dcc1b64f609cb98ddc8926092a1630c Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 20 Mar 2018 21:55:35 +0100 Subject: [PATCH 13/33] cleared comment --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 66eba5890a..de2dc9f9b4 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Mods { foreach (var d in drawables.OfType()) { - //Don't hide the first object ("drawables" are in a reverse order -> Last() ) + //Don't hide the first object if the increaseFirstObjectVisibility is true ("drawables" are in a reverse order -> Last() ) //If increaseFirstObjectVisibility is null then we're exectuing one of the tests for the hidden mod. Since it's too much //work for just this interface to work on this tests (DI of the config..), I just make sure to not throw a null exception if (d == drawables.Last() && (increaseFirstObjectVisibility == null || increaseFirstObjectVisibility)) continue; From 8159e219fd310730331202c01b2edeb4e8325bab Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 20 Mar 2018 22:23:27 +0100 Subject: [PATCH 14/33] increaseFirstObjectVisibility now cannot be null --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index de2dc9f9b4..cd1d860f9f 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Mods public override double ScoreMultiplier => 1.06; private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; - private Bindable increaseFirstObjectVisibility; + private Bindable increaseFirstObjectVisibility = new Bindable(); public void ReadFromConfig(OsuConfigManager config) { @@ -33,8 +33,6 @@ namespace osu.Game.Rulesets.Osu.Mods foreach (var d in drawables.OfType()) { //Don't hide the first object if the increaseFirstObjectVisibility is true ("drawables" are in a reverse order -> Last() ) - //If increaseFirstObjectVisibility is null then we're exectuing one of the tests for the hidden mod. Since it's too much - //work for just this interface to work on this tests (DI of the config..), I just make sure to not throw a null exception if (d == drawables.Last() && (increaseFirstObjectVisibility == null || increaseFirstObjectVisibility)) continue; d.ApplyCustomUpdateState += ApplyHiddenState; From 505a7c14fca90ccff9340b252c93f274f5cc5964 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Wed, 21 Mar 2018 21:14:17 +0100 Subject: [PATCH 15/33] was persuaded I changed the if statement... --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index cd1d860f9f..a599c70870 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Mods foreach (var d in drawables.OfType()) { //Don't hide the first object if the increaseFirstObjectVisibility is true ("drawables" are in a reverse order -> Last() ) - if (d == drawables.Last() && (increaseFirstObjectVisibility == null || increaseFirstObjectVisibility)) continue; + if (d == drawables.Last() && increaseFirstObjectVisibility) continue; d.ApplyCustomUpdateState += ApplyHiddenState; d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; From 393c01ba90fbb45bb6d068bf1575cfbe512388dd Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 6 May 2018 12:38:25 +0200 Subject: [PATCH 16/33] Made the changes requested --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 24 ++----------- osu.Game/Rulesets/Mods/ModHidden.cs | 28 +++++++++++++++- osu.Game/Rulesets/UI/RulesetContainer.cs | 39 +++++++++++----------- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 0edea5ac66..7652d47a36 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -15,34 +15,14 @@ using osu.Framework.Configuration; namespace osu.Game.Rulesets.Osu.Mods { - public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects, IReadFromConfig + public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects { public override string Description => @"Play with no approach circles and fading circles/sliders."; public override double ScoreMultiplier => 1.06; private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; - private Bindable increaseFirstObjectVisibility = new Bindable(); - public void ReadFromConfig(OsuConfigManager config) - { - increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); - } - - public void ApplyToDrawableHitObjects(IEnumerable drawables) - { - foreach (var d in drawables.OfType()) - { - //Don't hide the first object if the increaseFirstObjectVisibility is true ("drawables" are in a reverse order -> Last() ) - if (d == drawables.Last() && increaseFirstObjectVisibility) continue; - d.ApplyCustomUpdateState += ApplyHiddenState; - - d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; - foreach (var h in d.HitObject.NestedHitObjects.OfType()) - h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; - } - } - - protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state) + protected override void ApplyHiddenState(DrawableHitObject drawable, ArmedState state) { if (!(drawable is DrawableOsuHitObject d)) return; diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index b489a665d9..e80533b6cc 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -1,16 +1,42 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Game.Configuration; using osu.Game.Graphics; +using osu.Game.Rulesets.Objects.Drawables; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Rulesets.Mods { - public abstract class ModHidden : Mod + public abstract class ModHidden : Mod, IReadFromConfig { public override string Name => "Hidden"; public override string ShortenedName => "HD"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden; public override ModType Type => ModType.DifficultyIncrease; public override bool Ranked => true; + + protected Bindable increaseFirstObjectVisibility = new Bindable(); + + public void ReadFromConfig(OsuConfigManager config) + { + increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); + } + + public void ApplyToDrawableHitObjects(IEnumerable drawables) + { + foreach (var d in drawables.OfType()) + { + if (d == drawables.Last() && increaseFirstObjectVisibility) + return; + + d.ApplyCustomUpdateState += ApplyHiddenState; + } + } + + protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state) { } } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index e22e87dcc9..ce563b7e06 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -66,6 +66,7 @@ namespace osu.Game.Rulesets.UI /// The cursor provided by this . May be null if no cursor is provided. /// public readonly CursorContainer Cursor; + protected readonly Ruleset Ruleset; @@ -88,12 +89,11 @@ namespace osu.Game.Rulesets.UI Cursor = CreateCursor(); } - + [BackgroundDependencyLoader(true)] private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) { this.onScreenDisplay = onScreenDisplay; - rulesetConfig = CreateConfig(Ruleset, settings); if (rulesetConfig != null) @@ -101,6 +101,7 @@ namespace osu.Game.Rulesets.UI dependencies.Cache(rulesetConfig); onScreenDisplay?.BeginTracking(this, rulesetConfig); } + } public abstract ScoreProcessor CreateScoreProcessor(); @@ -130,7 +131,6 @@ namespace osu.Game.Rulesets.UI HasReplayLoaded.Value = ReplayInputManager.ReplayInputHandler != null; } - /// /// Creates the cursor. May be null if the doesn't provide a custom cursor. /// @@ -167,6 +167,7 @@ namespace osu.Game.Rulesets.UI public abstract class RulesetContainer : RulesetContainer where TObject : HitObject { + public event Action OnJudgement; public event Action OnJudgementRemoved; @@ -194,7 +195,7 @@ namespace osu.Game.Rulesets.UI /// Whether the specified beatmap is assumed to be specific to the current ruleset. /// public readonly bool IsForCurrentRuleset; - + public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(this); protected override Container Content => content; @@ -202,11 +203,8 @@ namespace osu.Game.Rulesets.UI private IEnumerable mods; [BackgroundDependencyLoader] - private void load(OsuConfigManager osuConfig) + private void load(OsuConfigManager config) { - // Apply mods - applyMods(Mods, osuConfig); - KeyBindingInputManager.Add(content = new Container { RelativeSizeAxes = Axes.Both, @@ -218,7 +216,11 @@ namespace osu.Game.Rulesets.UI if (Cursor != null) KeyBindingInputManager.Add(Cursor); + // Apply mods + applyMods(Mods, config); + loadObjects(); + } /// @@ -235,7 +237,6 @@ namespace osu.Game.Rulesets.UI WorkingBeatmap = workingBeatmap; IsForCurrentRuleset = isForCurrentRuleset; - // ReSharper disable once PossibleNullReferenceException Mods = workingBeatmap.Mods.Value; RelativeSizeAxes = Axes.Both; @@ -269,31 +270,29 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager.RelativeSizeAxes = Axes.Both; // Add mods, should always be the last thing applied to give full control to mods - // Mods are now added in the load() method because we need the OsuConfigManager - // for the IReadFromConfig implementations. This method is still executed after the constructor, - // so the mods are still added in last + // Mods are now added in the load() method, this method is still executed after the constructor + // so they are still added in last } - - /// /// Applies the active mods to this RulesetContainer. /// /// private void applyMods(IEnumerable mods, OsuConfigManager config) { - if (mods == null) + if(mods == null) + { return; - - foreach (var mod in mods.OfType()) - mod.ReadFromConfig(config); - + } foreach (var mod in mods.OfType>()) foreach (var obj in Beatmap.HitObjects) mod.ApplyToHitObject(obj); foreach (var mod in mods.OfType>()) mod.ApplyToRulesetContainer(this); + + foreach (var mod in mods.OfType()) + mod.ReadFromConfig(config); } public override void SetReplay(Replay replay) @@ -301,7 +300,7 @@ namespace osu.Game.Rulesets.UI base.SetReplay(replay); if (ReplayInputManager?.ReplayInputHandler != null) - ReplayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace; + ReplayInputManager.ReplayInputHandler.ToScreenSpace = input => Playfield.ScaledContent.ToScreenSpace(input); } /// From 095f6e1530aee70c3f8e72063cfbfeea17c36dae Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 6 May 2018 12:49:15 +0200 Subject: [PATCH 17/33] Code sanity --- osu.Game/Rulesets/UI/RulesetContainer.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index ce563b7e06..ce65260edb 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -66,7 +66,6 @@ namespace osu.Game.Rulesets.UI /// The cursor provided by this . May be null if no cursor is provided. /// public readonly CursorContainer Cursor; - protected readonly Ruleset Ruleset; @@ -101,7 +100,6 @@ namespace osu.Game.Rulesets.UI dependencies.Cache(rulesetConfig); onScreenDisplay?.BeginTracking(this, rulesetConfig); } - } public abstract ScoreProcessor CreateScoreProcessor(); @@ -220,7 +218,6 @@ namespace osu.Game.Rulesets.UI applyMods(Mods, config); loadObjects(); - } /// From 008daf9a076da74b1f50eb7de9efb4a2f5baeb8f Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 6 May 2018 12:57:52 +0200 Subject: [PATCH 18/33] White space trimmed --- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index ce65260edb..3332ef6a77 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.UI Cursor = CreateCursor(); } - + [BackgroundDependencyLoader(true)] private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) { From af851022770611a685b9bcae74d5784eec304454 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 6 May 2018 13:04:20 +0200 Subject: [PATCH 19/33] Should be ok now --- osu.Game/Rulesets/UI/RulesetContainer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 3332ef6a77..59b26e91de 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -67,6 +67,7 @@ namespace osu.Game.Rulesets.UI /// public readonly CursorContainer Cursor; + protected readonly Ruleset Ruleset; private IRulesetConfigManager rulesetConfig; @@ -165,7 +166,7 @@ namespace osu.Game.Rulesets.UI public abstract class RulesetContainer : RulesetContainer where TObject : HitObject { - + public event Action OnJudgement; public event Action OnJudgementRemoved; @@ -193,7 +194,7 @@ namespace osu.Game.Rulesets.UI /// Whether the specified beatmap is assumed to be specific to the current ruleset. /// public readonly bool IsForCurrentRuleset; - + public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(this); protected override Container Content => content; @@ -218,6 +219,7 @@ namespace osu.Game.Rulesets.UI applyMods(Mods, config); loadObjects(); + } /// From d36d9643eb5ae76e2e9bb7ca3a645402468b84f0 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 6 May 2018 13:09:46 +0200 Subject: [PATCH 20/33] Missed one white space.. I guess my editor wasn't properly configured for this file --- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 59b26e91de..749fcb476c 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -289,7 +289,7 @@ namespace osu.Game.Rulesets.UI foreach (var mod in mods.OfType>()) mod.ApplyToRulesetContainer(this); - + foreach (var mod in mods.OfType()) mod.ReadFromConfig(config); } From c4e45e30ef2d64a544a5f38240badd03ea54aa44 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 6 May 2018 13:18:12 +0200 Subject: [PATCH 21/33] Solving conflict --- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 749fcb476c..3ff67dcef9 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -299,7 +299,7 @@ namespace osu.Game.Rulesets.UI base.SetReplay(replay); if (ReplayInputManager?.ReplayInputHandler != null) - ReplayInputManager.ReplayInputHandler.ToScreenSpace = input => Playfield.ScaledContent.ToScreenSpace(input); + ReplayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace; } /// From 16bcd6c3ed98595310fcd6265fd9072bd079b50d Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 8 May 2018 14:33:26 +0200 Subject: [PATCH 22/33] Appvtests (#1) * Resolving AppVeyor's errors --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 5 ----- osu.Game/Rulesets/Mods/ModHidden.cs | 9 ++++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index 7652d47a36..f7a9fda14f 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -2,16 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; -using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; -using osu.Game.Configuration; -using osu.Framework.Configuration; namespace osu.Game.Rulesets.Osu.Mods { diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index e80533b6cc..ab1911fe88 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Game.Configuration; using osu.Game.Graphics; @@ -19,18 +18,18 @@ namespace osu.Game.Rulesets.Mods public override ModType Type => ModType.DifficultyIncrease; public override bool Ranked => true; - protected Bindable increaseFirstObjectVisibility = new Bindable(); + protected Bindable IncreaseFirstObjectVisibility = new Bindable(); public void ReadFromConfig(OsuConfigManager config) { - increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); + IncreaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); } public void ApplyToDrawableHitObjects(IEnumerable drawables) { - foreach (var d in drawables.OfType()) + foreach (var d in drawables) { - if (d == drawables.Last() && increaseFirstObjectVisibility) + if (d == drawables.Last() && IncreaseFirstObjectVisibility) return; d.ApplyCustomUpdateState += ApplyHiddenState; From 2492e34d3fd8be6aaf3d3804b413901485de8b80 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Thu, 17 May 2018 19:44:09 +0200 Subject: [PATCH 23/33] resolving codefactor styling issues --- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 0587d34c2e..1cad3c827b 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -166,7 +166,6 @@ namespace osu.Game.Rulesets.UI public abstract class RulesetContainer : RulesetContainer where TObject : HitObject { - public event Action OnJudgement; public event Action OnJudgementRemoved; @@ -214,7 +213,6 @@ namespace osu.Game.Rulesets.UI applyMods(Mods, config); loadObjects(); - } /// From f53164843d0d17d17282e041a501cf2bb527a618 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 15:56:02 +0900 Subject: [PATCH 24/33] Reduce spacing changes --- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 1cad3c827b..c8582a740c 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -67,7 +67,6 @@ namespace osu.Game.Rulesets.UI /// public readonly CursorContainer Cursor; - protected readonly Ruleset Ruleset; private IRulesetConfigManager rulesetConfig; @@ -94,6 +93,7 @@ namespace osu.Game.Rulesets.UI private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) { this.onScreenDisplay = onScreenDisplay; + rulesetConfig = CreateConfig(Ruleset, settings); if (rulesetConfig != null) From 5ec349de78dad5c25ae274340b407a92734eb7e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 15:59:33 +0900 Subject: [PATCH 25/33] Reorder methods and remove useless comments --- osu.Game/Rulesets/UI/RulesetContainer.cs | 42 +++++++++++------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index c8582a740c..f06365e04a 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -195,26 +195,6 @@ namespace osu.Game.Rulesets.UI private Container content; private IEnumerable mods; - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - KeyBindingInputManager.Add(content = new Container - { - RelativeSizeAxes = Axes.Both, - }); - - AddInternal(KeyBindingInputManager); - KeyBindingInputManager.Add(Playfield); - - if (Cursor != null) - KeyBindingInputManager.Add(Cursor); - - // Apply mods - applyMods(Mods, config); - - loadObjects(); - } - /// /// Whether to assume the beatmap passed into this is for the current ruleset. /// Creates a hit renderer for a beatmap. @@ -236,10 +216,26 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager = CreateInputManager(); KeyBindingInputManager.RelativeSizeAxes = Axes.Both; + } - // Add mods, should always be the last thing applied to give full control to mods - // Mods are now added in the load() method, this method is still executed after the constructor - // so they are still added in last + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + KeyBindingInputManager.Add(content = new Container + { + RelativeSizeAxes = Axes.Both, + }); + + AddInternal(KeyBindingInputManager); + KeyBindingInputManager.Add(Playfield); + + if (Cursor != null) + KeyBindingInputManager.Add(Cursor); + + // Apply mods + applyMods(Mods, config); + + loadObjects(); } /// From 9e17eb234223e2b9869b159f675f3466336b54b2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 16:03:08 +0900 Subject: [PATCH 26/33] Reword settings text to be ruleset agnostic --- osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 492b108a21..9b3c199b5c 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -40,7 +40,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay }, new SettingsCheckbox { - LabelText = "Show approach circle on first \"Hidden\" object", + LabelText = "Increase visibility of first object with \"Hidden\" mod", Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) }, }; From 50e2871c89ff774048cc4b58cc91972e35397943 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 22 May 2018 21:29:41 +0200 Subject: [PATCH 27/33] why this line was ommited --- osu.Game/Rulesets/Mods/ModHidden.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index ab1911fe88..5e06c81dff 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -33,6 +33,7 @@ namespace osu.Game.Rulesets.Mods return; d.ApplyCustomUpdateState += ApplyHiddenState; + d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; } } From 08e423ac5b9c85b77d158a8b4e8fccc32f806785 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 22 May 2018 21:35:17 +0200 Subject: [PATCH 28/33] code sanity --- osu.Game/Rulesets/Mods/ModHidden.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index 5e06c81dff..da4f04049f 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Mods return; d.ApplyCustomUpdateState += ApplyHiddenState; - d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; + d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; } } From 7a31986812aaf0dd516bfee79fa9b6a808fae1ef Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 22 May 2018 22:39:55 +0200 Subject: [PATCH 29/33] resolving the lost code problem --- osu.Game/Rulesets/Mods/ModHidden.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index da4f04049f..ab1911fe88 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -33,7 +33,6 @@ namespace osu.Game.Rulesets.Mods return; d.ApplyCustomUpdateState += ApplyHiddenState; - d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; } } From 1dd5bdcf72adc661febf0e39e1acf022488a9a36 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 12:32:59 +0900 Subject: [PATCH 30/33] Move setting to new "mods" section --- .../Sections/Gameplay/GeneralSettings.cs | 5 ---- .../Sections/Gameplay/ModsSettings.cs | 26 +++++++++++++++++++ .../Settings/Sections/GameplaySection.cs | 3 ++- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 9b3c199b5c..647395cf69 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -38,11 +38,6 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuSetting.KeyOverlay) }, - new SettingsCheckbox - { - LabelText = "Increase visibility of first object with \"Hidden\" mod", - Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) - }, }; } } diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs new file mode 100644 index 0000000000..a9cefa81da --- /dev/null +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Configuration; + +namespace osu.Game.Overlays.Settings.Sections.Gameplay +{ + public class ModsSettings : SettingsSubsection + { + protected override string Header => "Mods"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + Children = new[] + { + new SettingsCheckbox + { + LabelText = "Increase visibility of first object with \"Hidden\" mod", + Bindable = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility) + }, + }; + } + } +} diff --git a/osu.Game/Overlays/Settings/Sections/GameplaySection.cs b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs index 3851a73901..8add0b01ec 100644 --- a/osu.Game/Overlays/Settings/Sections/GameplaySection.cs +++ b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs @@ -21,7 +21,8 @@ namespace osu.Game.Overlays.Settings.Sections { new GeneralSettings(), new SongSelectSettings(), - new ScrollingSettings() + new ScrollingSettings(), + new ModsSettings(), }; } From f253828d4930b572d93c8f983a3bf8061ce3e4f3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 13:51:51 +0900 Subject: [PATCH 31/33] Fix regressions --- osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index f7a9fda14f..4220b72b16 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -2,21 +2,38 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; +using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Osu.Objects; namespace osu.Game.Rulesets.Osu.Mods { - public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects + public class OsuModHidden : ModHidden { public override string Description => @"Play with no approach circles and fading circles/sliders."; public override double ScoreMultiplier => 1.06; private const double fade_in_duration_multiplier = 0.4; private const double fade_out_duration_multiplier = 0.3; + public override void ApplyToDrawableHitObjects(IEnumerable drawables) + { + void adjustFadeIn(OsuHitObject h) => h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; + + foreach (var d in drawables.OfType()) + { + adjustFadeIn(d.HitObject); + foreach (var h in d.HitObject.NestedHitObjects.OfType()) + adjustFadeIn(h); + } + + base.ApplyToDrawableHitObjects(drawables); + } + protected override void ApplyHiddenState(DrawableHitObject drawable, ArmedState state) { if (!(drawable is DrawableOsuHitObject d)) From a5679f7bf58a9475743b868651f3918c90d5a882 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 14:04:20 +0900 Subject: [PATCH 32/33] Improve readability of code --- osu.Game/Rulesets/Mods/ModHidden.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index ab1911fe88..45da628ce8 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -10,7 +10,7 @@ using System.Linq; namespace osu.Game.Rulesets.Mods { - public abstract class ModHidden : Mod, IReadFromConfig + public abstract class ModHidden : Mod, IReadFromConfig, IApplicableToDrawableHitObjects { public override string Name => "Hidden"; public override string ShortenedName => "HD"; @@ -25,15 +25,11 @@ namespace osu.Game.Rulesets.Mods IncreaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); } - public void ApplyToDrawableHitObjects(IEnumerable drawables) + public virtual void ApplyToDrawableHitObjects(IEnumerable drawables) { - foreach (var d in drawables) - { - if (d == drawables.Last() && IncreaseFirstObjectVisibility) - return; - + // todo: fix ordering of objects so we don't have to do this (#2740). + foreach (var d in drawables.Reverse().Skip(IncreaseFirstObjectVisibility ? 1 : 0)) d.ApplyCustomUpdateState += ApplyHiddenState; - } } protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state) { } From d3cd267036758cc75b6f9c7ab0fffca233ecd2e6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 14:20:51 +0900 Subject: [PATCH 33/33] Formatting fixes --- osu.Game/Rulesets/UI/RulesetContainer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index f06365e04a..384b71cccc 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -57,6 +57,7 @@ namespace osu.Game.Rulesets.UI public abstract IEnumerable Objects { get; } private readonly Lazy playfield; + /// /// The playfield. /// @@ -250,8 +251,8 @@ namespace osu.Game.Rulesets.UI foreach (var mod in mods.OfType>()) mod.ApplyToRulesetContainer(this); - foreach (var mod in mods.OfType()) - mod.ReadFromConfig(config); + foreach (var mod in mods.OfType()) + mod.ReadFromConfig(config); } public override void SetReplay(Replay replay)