From eed0f3a1de4e277ad9e0513963ac56385d1abfcb Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 11 Mar 2018 21:02:14 +0100 Subject: [PATCH 001/253] 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 002/253] 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 003/253] 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 004/253] 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 005/253] 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 006/253] 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 007/253] 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 008/253] 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 009/253] 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 010/253] 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 011/253] 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 012/253] 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 013/253] 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 014/253] 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 015/253] 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 78a7564acd527ad54ee71cbaf003022b5b7c9630 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 24 Mar 2018 16:00:18 -0700 Subject: [PATCH 016/253] Score multiplier edits --- .../Mods/ManiaModDualStages.cs | 2 +- .../Mods/ManiaModRandom.cs | 2 +- osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs | 2 +- osu.Game.Tests/Visual/TestCaseMods.cs | 11 ++++--- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 31 ++++++++++++++++--- osu.Game/Rulesets/Mods/ModAutoplay.cs | 2 +- osu.Game/Rulesets/Mods/ModRelax.cs | 2 +- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs index a1f9e0290e..949a2c950c 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModDualStages.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Mods public override string Name => "Dual Stages"; public override string ShortenedName => "DS"; public override string Description => @"Double the stages, double the fun!"; - public override double ScoreMultiplier => 0; + public override double ScoreMultiplier => 1; public void ApplyToBeatmapConverter(BeatmapConverter beatmapConverter) { diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs index df0f9a5437..dd528cb163 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Mods public override string ShortenedName => "RD"; public override FontAwesome Icon => FontAwesome.fa_osu_dice; public override string Description => @"Shuffle around the keys!"; - public override double ScoreMultiplier => 0; + public override double ScoreMultiplier => 1; public void ApplyToRulesetContainer(RulesetContainer rulesetContainer) { diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs index 0c842143e4..c78274e453 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Osu.Mods public override string ShortenedName => "AP"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_autopilot; public override string Description => @"Automatic cursor movement - just follow the rhythm."; - public override double ScoreMultiplier => 0; + public override double ScoreMultiplier => 1; public override bool Ranked => false; public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) }; } diff --git a/osu.Game.Tests/Visual/TestCaseMods.cs b/osu.Game.Tests/Visual/TestCaseMods.cs index 039d8bfdb6..4f841d3ee2 100644 --- a/osu.Game.Tests/Visual/TestCaseMods.cs +++ b/osu.Game.Tests/Visual/TestCaseMods.cs @@ -105,7 +105,7 @@ namespace osu.Game.Tests.Visual private void testManiaMods(ManiaRuleset ruleset) { - testMultiplierTextUnranked(ruleset.GetModsFor(ModType.Special).First(m => m is ManiaModRandom)); + testRankedTextUnranked(ruleset.GetModsFor(ModType.Special).First(m => m is ManiaModRandom)); } private void testSingleMod(Mod mod) @@ -182,13 +182,13 @@ namespace osu.Game.Tests.Visual checkLabelColor(Color4.White); } - private void testMultiplierTextUnranked(Mod mod) + private void testRankedTextUnranked(Mod mod) { - AddAssert("check for ranked", () => !modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix)); + AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.EndsWith(unranked_suffix)); selectNext(mod); - AddAssert("check for unranked", () => modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix)); + AddAssert("check for unranked", () => modSelect.RankedLabel.Text.EndsWith(unranked_suffix)); selectPrevious(mod); - AddAssert("check for ranked", () => !modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix)); + AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.EndsWith(unranked_suffix)); } private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1)); @@ -224,6 +224,7 @@ namespace osu.Game.Tests.Visual } public new OsuSpriteText MultiplierLabel => base.MultiplierLabel; + public new OsuSpriteText RankedLabel => base.RankedLabel; public new TriangleButton DeselectAllButton => base.DeselectAllButton; public new Color4 LowMultiplierColour => base.LowMultiplierColour; diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index d8c95da94f..21c1082191 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -27,10 +27,11 @@ namespace osu.Game.Overlays.Mods { private const float content_width = 0.8f; - protected Color4 LowMultiplierColour, HighMultiplierColour; + protected Color4 LowMultiplierColour, HighMultiplierColour, RankedColour; protected readonly TriangleButton DeselectAllButton; protected readonly OsuSpriteText MultiplierLabel; + protected readonly OsuSpriteText RankedLabel; private readonly FillFlowContainer footerContainer; protected override bool BlockPassThroughKeyboard => false; @@ -55,8 +56,9 @@ namespace osu.Game.Overlays.Mods { SelectedMods.ValueChanged += selectedModsChanged; - LowMultiplierColour = colours.Red; + LowMultiplierColour = colours.Yellow; HighMultiplierColour = colours.Green; + RankedColour = colours.Red; if (osu != null) Ruleset.BindTo(osu.Ruleset); @@ -98,15 +100,24 @@ namespace osu.Game.Overlays.Mods } MultiplierLabel.Text = $"{multiplier:N2}x"; - if (!ranked) - MultiplierLabel.Text += " (Unranked)"; - if (multiplier > 1.0) MultiplierLabel.FadeColour(HighMultiplierColour, 200); else if (multiplier < 1.0) MultiplierLabel.FadeColour(LowMultiplierColour, 200); else MultiplierLabel.FadeColour(Color4.White, 200); + + RankedLabel.Text = null; + if (!ranked) + { + RankedLabel.Text += " (Unranked)"; + RankedLabel.FadeColour(RankedColour, 200); + } + else + { + RankedLabel.Text = null; + RankedLabel.FadeColour(Color4.White, 200); + } } protected override void PopOut() @@ -362,6 +373,16 @@ namespace osu.Game.Overlays.Mods } }, MultiplierLabel = new OsuSpriteText + { + Font = @"Exo2.0-Bold", + TextSize = 30, + Shadow = true, + Margin = new MarginPadding + { + Top = 5 + } + }, + RankedLabel = new OsuSpriteText { Font = @"Exo2.0-Bold", TextSize = 30, diff --git a/osu.Game/Rulesets/Mods/ModAutoplay.cs b/osu.Game/Rulesets/Mods/ModAutoplay.cs index 9f45cada7e..8ab12cd30f 100644 --- a/osu.Game/Rulesets/Mods/ModAutoplay.cs +++ b/osu.Game/Rulesets/Mods/ModAutoplay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Mods public override string ShortenedName => "AT"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_auto; public override string Description => "Watch a perfect automated play through the song."; - public override double ScoreMultiplier => 0; + public override double ScoreMultiplier => 1; public bool AllowFail => false; public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) }; } diff --git a/osu.Game/Rulesets/Mods/ModRelax.cs b/osu.Game/Rulesets/Mods/ModRelax.cs index e8328c3ac7..071f5d5a66 100644 --- a/osu.Game/Rulesets/Mods/ModRelax.cs +++ b/osu.Game/Rulesets/Mods/ModRelax.cs @@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mods public override string Name => "Relax"; public override string ShortenedName => "RX"; public override FontAwesome Icon => FontAwesome.fa_osu_mod_relax; - public override double ScoreMultiplier => 0; + public override double ScoreMultiplier => 1; public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModNoFail), typeof(ModSuddenDeath) }; } } From 90d763fda51b8a5255179ee41ec466ebb9e1cc4b Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 25 Mar 2018 10:00:30 -0700 Subject: [PATCH 017/253] Apply review changes and suggestions --- osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs | 1 - osu.Game.Tests/Visual/TestCaseMods.cs | 12 ++++----- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 27 ++++++++++++------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs index c78274e453..b5e9540eae 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs @@ -14,7 +14,6 @@ namespace osu.Game.Rulesets.Osu.Mods public override FontAwesome Icon => FontAwesome.fa_osu_mod_autopilot; public override string Description => @"Automatic cursor movement - just follow the rhythm."; public override double ScoreMultiplier => 1; - public override bool Ranked => false; public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) }; } } diff --git a/osu.Game.Tests/Visual/TestCaseMods.cs b/osu.Game.Tests/Visual/TestCaseMods.cs index 4f841d3ee2..b194462a96 100644 --- a/osu.Game.Tests/Visual/TestCaseMods.cs +++ b/osu.Game.Tests/Visual/TestCaseMods.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual [Description("mod select and icon display")] public class TestCaseMods : OsuTestCase { - private const string unranked_suffix = " (Unranked)"; + private const string unranked_suffix = "(Unranked)"; private RulesetStore rulesets; private ModDisplay modDisplay; @@ -105,7 +105,7 @@ namespace osu.Game.Tests.Visual private void testManiaMods(ManiaRuleset ruleset) { - testRankedTextUnranked(ruleset.GetModsFor(ModType.Special).First(m => m is ManiaModRandom)); + testRankedText(ruleset.GetModsFor(ModType.Special).First(m => m is ManiaModRandom)); } private void testSingleMod(Mod mod) @@ -182,13 +182,13 @@ namespace osu.Game.Tests.Visual checkLabelColor(Color4.White); } - private void testRankedTextUnranked(Mod mod) + private void testRankedText(Mod mod) { - AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.EndsWith(unranked_suffix)); + AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.Equals(unranked_suffix)); selectNext(mod); - AddAssert("check for unranked", () => modSelect.RankedLabel.Text.EndsWith(unranked_suffix)); + AddAssert("check for unranked", () => modSelect.RankedLabel.Text.Equals(unranked_suffix)); selectPrevious(mod); - AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.EndsWith(unranked_suffix)); + AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.Equals(unranked_suffix)); } private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1)); diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 21c1082191..604e683917 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -30,6 +30,7 @@ namespace osu.Game.Overlays.Mods protected Color4 LowMultiplierColour, HighMultiplierColour, RankedColour; protected readonly TriangleButton DeselectAllButton; + protected readonly OsuSpriteText ScoreLabel; protected readonly OsuSpriteText MultiplierLabel; protected readonly OsuSpriteText RankedLabel; private readonly FillFlowContainer footerContainer; @@ -56,9 +57,9 @@ namespace osu.Game.Overlays.Mods { SelectedMods.ValueChanged += selectedModsChanged; - LowMultiplierColour = colours.Yellow; + LowMultiplierColour = colours.Red; HighMultiplierColour = colours.Green; - RankedColour = colours.Red; + RankedColour = colours.Blue; if (osu != null) Ruleset.BindTo(osu.Ruleset); @@ -99,6 +100,14 @@ namespace osu.Game.Overlays.Mods ranked &= mod.Ranked; } + ScoreLabel.Text = "Score Multiplier:"; + if (multiplier > 1.0) + ScoreLabel.FadeColour(HighMultiplierColour, 200); + else if (multiplier < 1.0) + ScoreLabel.FadeColour(LowMultiplierColour, 200); + else + ScoreLabel.FadeColour(Color4.White, 200); + MultiplierLabel.Text = $"{multiplier:N2}x"; if (multiplier > 1.0) MultiplierLabel.FadeColour(HighMultiplierColour, 200); @@ -110,14 +119,11 @@ namespace osu.Game.Overlays.Mods RankedLabel.Text = null; if (!ranked) { - RankedLabel.Text += " (Unranked)"; + RankedLabel.Text = "(Unranked)"; RankedLabel.FadeColour(RankedColour, 200); } else - { - RankedLabel.Text = null; RankedLabel.FadeColour(Color4.White, 200); - } } protected override void PopOut() @@ -362,14 +368,14 @@ namespace osu.Game.Overlays.Mods Right = 20 } }, - new OsuSpriteText + ScoreLabel = new OsuSpriteText { - Text = @"Score Multiplier: ", TextSize = 30, Shadow = true, Margin = new MarginPadding { - Top = 5 + Top = 5, + Right = 10 } }, MultiplierLabel = new OsuSpriteText @@ -389,7 +395,8 @@ namespace osu.Game.Overlays.Mods Shadow = true, Margin = new MarginPadding { - Top = 5 + Top = 5, + Left = 10 } } } From ac9527147f1f81cd9fd65911cca8eb833516a78a Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Tue, 27 Mar 2018 03:05:05 -0700 Subject: [PATCH 018/253] Fix transitioning of unranked label --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 604e683917..37a789190a 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -116,14 +116,13 @@ namespace osu.Game.Overlays.Mods else MultiplierLabel.FadeColour(Color4.White, 200); - RankedLabel.Text = null; + RankedLabel.Text = "(Unranked)"; + RankedLabel.FadeColour(RankedColour, 200); + RankedLabel.FadeOut(200); if (!ranked) { - RankedLabel.Text = "(Unranked)"; - RankedLabel.FadeColour(RankedColour, 200); + RankedLabel.FadeIn(200); } - else - RankedLabel.FadeColour(Color4.White, 200); } protected override void PopOut() From 5457f17e792af7bbcebfc758a40fa73eba427270 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 28 Mar 2018 19:53:15 -0700 Subject: [PATCH 019/253] Clean up code from reviews --- osu.Game.Tests/Visual/TestCaseMods.cs | 9 ++++--- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 29 +++++++--------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMods.cs b/osu.Game.Tests/Visual/TestCaseMods.cs index b194462a96..73bfe9b7bb 100644 --- a/osu.Game.Tests/Visual/TestCaseMods.cs +++ b/osu.Game.Tests/Visual/TestCaseMods.cs @@ -184,11 +184,14 @@ namespace osu.Game.Tests.Visual private void testRankedText(Mod mod) { - AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.Equals(unranked_suffix)); + AddWaitStep(1, "wait for fade"); + AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha.Equals(0)); selectNext(mod); - AddAssert("check for unranked", () => modSelect.RankedLabel.Text.Equals(unranked_suffix)); + AddWaitStep(1, "wait for fade"); + AddAssert("check for unranked", () => !modSelect.RankedLabel.Alpha.Equals(0)); selectPrevious(mod); - AddAssert("check for ranked", () => !modSelect.RankedLabel.Text.Equals(unranked_suffix)); + AddWaitStep(1, "wait for fade"); + AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha.Equals(0)); } private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1)); diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 37a789190a..f307d4c92f 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -27,12 +27,10 @@ namespace osu.Game.Overlays.Mods { private const float content_width = 0.8f; - protected Color4 LowMultiplierColour, HighMultiplierColour, RankedColour; + protected Color4 LowMultiplierColour, HighMultiplierColour; protected readonly TriangleButton DeselectAllButton; - protected readonly OsuSpriteText ScoreLabel; - protected readonly OsuSpriteText MultiplierLabel; - protected readonly OsuSpriteText RankedLabel; + protected readonly OsuSpriteText MultiplierLabel, RankedLabel; private readonly FillFlowContainer footerContainer; protected override bool BlockPassThroughKeyboard => false; @@ -59,7 +57,6 @@ namespace osu.Game.Overlays.Mods LowMultiplierColour = colours.Red; HighMultiplierColour = colours.Green; - RankedColour = colours.Blue; if (osu != null) Ruleset.BindTo(osu.Ruleset); @@ -100,14 +97,6 @@ namespace osu.Game.Overlays.Mods ranked &= mod.Ranked; } - ScoreLabel.Text = "Score Multiplier:"; - if (multiplier > 1.0) - ScoreLabel.FadeColour(HighMultiplierColour, 200); - else if (multiplier < 1.0) - ScoreLabel.FadeColour(LowMultiplierColour, 200); - else - ScoreLabel.FadeColour(Color4.White, 200); - MultiplierLabel.Text = $"{multiplier:N2}x"; if (multiplier > 1.0) MultiplierLabel.FadeColour(HighMultiplierColour, 200); @@ -116,13 +105,10 @@ namespace osu.Game.Overlays.Mods else MultiplierLabel.FadeColour(Color4.White, 200); - RankedLabel.Text = "(Unranked)"; - RankedLabel.FadeColour(RankedColour, 200); - RankedLabel.FadeOut(200); - if (!ranked) - { + if (ranked) + RankedLabel.FadeOut(200); + else RankedLabel.FadeIn(200); - } } protected override void PopOut() @@ -367,8 +353,9 @@ namespace osu.Game.Overlays.Mods Right = 20 } }, - ScoreLabel = new OsuSpriteText + new OsuSpriteText { + Text = @"Score Multiplier:", TextSize = 30, Shadow = true, Margin = new MarginPadding @@ -390,7 +377,9 @@ namespace osu.Game.Overlays.Mods RankedLabel = new OsuSpriteText { Font = @"Exo2.0-Bold", + Text = @"(Unranked)", TextSize = 30, + Colour = OsuColour.FromHex(@"66ccff"), Shadow = true, Margin = new MarginPadding { From 1bebda61f8d6bd048f26d60ae5cbd6b2d508eafd Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 31 Mar 2018 10:51:44 -0700 Subject: [PATCH 020/253] Use "==" instead of "equals" --- osu.Game.Tests/Visual/TestCaseMods.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMods.cs b/osu.Game.Tests/Visual/TestCaseMods.cs index 73bfe9b7bb..201804fa74 100644 --- a/osu.Game.Tests/Visual/TestCaseMods.cs +++ b/osu.Game.Tests/Visual/TestCaseMods.cs @@ -185,13 +185,13 @@ namespace osu.Game.Tests.Visual private void testRankedText(Mod mod) { AddWaitStep(1, "wait for fade"); - AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha.Equals(0)); + AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha == 0); selectNext(mod); AddWaitStep(1, "wait for fade"); - AddAssert("check for unranked", () => !modSelect.RankedLabel.Alpha.Equals(0)); + AddAssert("check for unranked", () => !(modSelect.RankedLabel.Alpha == 0)); selectPrevious(mod); AddWaitStep(1, "wait for fade"); - AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha.Equals(0)); + AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha == 0); } private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1)); From ee7db92e6bb5aba9a792b6b84ee3a22ac9e8682c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Tue, 3 Apr 2018 21:01:02 -0700 Subject: [PATCH 021/253] Simplify negative equality expression --- osu.Game.Tests/Visual/TestCaseMods.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseMods.cs b/osu.Game.Tests/Visual/TestCaseMods.cs index 201804fa74..8ee3c6e911 100644 --- a/osu.Game.Tests/Visual/TestCaseMods.cs +++ b/osu.Game.Tests/Visual/TestCaseMods.cs @@ -188,7 +188,7 @@ namespace osu.Game.Tests.Visual AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha == 0); selectNext(mod); AddWaitStep(1, "wait for fade"); - AddAssert("check for unranked", () => !(modSelect.RankedLabel.Alpha == 0)); + AddAssert("check for unranked", () => modSelect.RankedLabel.Alpha != 0); selectPrevious(mod); AddWaitStep(1, "wait for fade"); AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha == 0); From 393c01ba90fbb45bb6d068bf1575cfbe512388dd Mon Sep 17 00:00:00 2001 From: Vidalee Date: Sun, 6 May 2018 12:38:25 +0200 Subject: [PATCH 022/253] 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 023/253] 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 024/253] 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 025/253] 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 026/253] 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 027/253] 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 028/253] 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 dd9b9a18ac4571ffda22f5b883452d16dbabcc66 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 8 May 2018 16:21:54 +0300 Subject: [PATCH 029/253] Prevent user from scrolling outside the timeline in the editor --- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Edit/EditorClock.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index adb749b492..0e0f3fa9f1 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -47,7 +47,7 @@ namespace osu.Game.Screens.Edit { // TODO: should probably be done at a RulesetContainer level to share logic with Player. var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock(); - clock = new EditorClock(Beatmap.Value.Beatmap.ControlPointInfo, beatDivisor) { IsCoupled = false }; + clock = new EditorClock(Beatmap, beatDivisor) { IsCoupled = false }; clock.ChangeSource(sourceClock); dependencies.CacheAs(clock); diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 67025f0620..02bf581716 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -3,8 +3,10 @@ using System; using System.Linq; +using osu.Framework.Configuration; using osu.Framework.MathUtils; using osu.Framework.Timing; +using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Screens.Edit.Screens.Compose; @@ -15,10 +17,20 @@ namespace osu.Game.Screens.Edit /// public class EditorClock : DecoupleableInterpolatingFramedClock { + public Bindable Beatmap = new Bindable(); + public ControlPointInfo ControlPointInfo; private readonly BindableBeatDivisor beatDivisor; + public EditorClock(Bindable beatmap, BindableBeatDivisor beatDivisor) + { + this.beatDivisor = beatDivisor; + + Beatmap.BindTo(beatmap); + + ControlPointInfo = Beatmap.Value.Beatmap.ControlPointInfo; + } public EditorClock(ControlPointInfo controlPointInfo, BindableBeatDivisor beatDivisor) { this.beatDivisor = beatDivisor; @@ -111,6 +123,7 @@ namespace osu.Game.Screens.Edit if (seekTime > nextTimingPoint?.Time) seekTime = nextTimingPoint.Time; + seekTime = Math.Min(Math.Max(0, seekTime), Beatmap.Value.Track.Length); // Ensure the sought point is within the song's length Seek(seekTime); } } From e44062b77a54e792fdcb84fd1c9379cec473aafc Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Tue, 8 May 2018 16:37:06 +0300 Subject: [PATCH 030/253] Fix tests and implementation --- osu.Game/Screens/Edit/EditorClock.cs | 15 +++++++++------ osu.Game/Tests/Visual/EditorClockTestCase.cs | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 02bf581716..88d8477233 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -17,7 +17,9 @@ namespace osu.Game.Screens.Edit /// public class EditorClock : DecoupleableInterpolatingFramedClock { - public Bindable Beatmap = new Bindable(); + //public Bindable Beatmap = new Bindable(); + + public double TrackLength; public ControlPointInfo ControlPointInfo; @@ -27,15 +29,15 @@ namespace osu.Game.Screens.Edit { this.beatDivisor = beatDivisor; - Beatmap.BindTo(beatmap); - - ControlPointInfo = Beatmap.Value.Beatmap.ControlPointInfo; + ControlPointInfo = beatmap.Value.Beatmap.ControlPointInfo; + TrackLength = beatmap.Value.Track.Length; } - public EditorClock(ControlPointInfo controlPointInfo, BindableBeatDivisor beatDivisor) + public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor) { this.beatDivisor = beatDivisor; ControlPointInfo = controlPointInfo; + TrackLength = trackLength; } /// @@ -123,7 +125,8 @@ namespace osu.Game.Screens.Edit if (seekTime > nextTimingPoint?.Time) seekTime = nextTimingPoint.Time; - seekTime = Math.Min(Math.Max(0, seekTime), Beatmap.Value.Track.Length); // Ensure the sought point is within the song's length + // Ensure the sought point is within the boundaries + seekTime = Math.Min(Math.Max(0, seekTime), TrackLength); Seek(seekTime); } } diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index 43b20f7021..85d3684530 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual protected EditorClockTestCase() { - Clock = new EditorClock(new ControlPointInfo(), BeatDivisor) { IsCoupled = false }; + Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false }; } [BackgroundDependencyLoader] From 6676c55fe05f0f413b95740381f35738e13adfcd Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Wed, 9 May 2018 17:22:37 +0300 Subject: [PATCH 031/253] Introduce InputSettings --- .../Play/PlayerSettings/InputSettings.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 osu.Game/Screens/Play/PlayerSettings/InputSettings.cs diff --git a/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs b/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs new file mode 100644 index 0000000000..f9dda01c8c --- /dev/null +++ b/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs @@ -0,0 +1,39 @@ +// 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.Graphics; +using osu.Game.Configuration; + +namespace osu.Game.Screens.Play.PlayerSettings +{ + public class InputSettings : PlayerSettingsGroup + { + protected override string Title => "Input settings"; + + private readonly PlayerCheckbox mouseWheelCheckbox; + private readonly PlayerCheckbox mouseButtonsCheckbox; + + public InputSettings() + { + Children = new Drawable[] + { + mouseWheelCheckbox = new PlayerCheckbox + { + LabelText = "Disable mouse wheel during gameplay" + }, + mouseButtonsCheckbox = new PlayerCheckbox + { + LabelText = "Disable mouse buttons during gameplay" + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + mouseWheelCheckbox.Bindable = config.GetBindable(OsuSetting.MouseDisableWheel); + mouseButtonsCheckbox.Bindable = config.GetBindable(OsuSetting.MouseDisableButtons); + } + } +} From ccf82cacb029784988189ab9cbf462b1f91609df Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Wed, 9 May 2018 17:31:52 +0300 Subject: [PATCH 032/253] Show InputSettings on the PlayerLoader screen --- osu.Game/Screens/Play/PlayerLoader.cs | 18 +++++++++++++----- .../Play/PlayerSettings/InputSettings.cs | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 56fbd7b6e7..13293b6f93 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -7,15 +7,15 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; +using osu.Framework.Localisation; using osu.Framework.Screens; +using osu.Framework.Threading; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using OpenTK; -using osu.Framework.Localisation; -using osu.Framework.Threading; using osu.Game.Screens.Menu; using osu.Game.Screens.Play.PlayerSettings; +using OpenTK; namespace osu.Game.Screens.Play { @@ -51,11 +51,19 @@ namespace osu.Game.Screens.Play Origin = Anchor.Centre, }); - Add(new VisualSettings + Add(new FillFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - Margin = new MarginPadding(25) + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 20), + Margin = new MarginPadding { Top = 100, Right = 10 }, + Children = new PlayerSettingsGroup[] + { + new VisualSettings(), + new InputSettings() + } }); loadTask = LoadComponentAsync(player); diff --git a/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs b/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs index f9dda01c8c..25b6ebc2c3 100644 --- a/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs @@ -20,11 +20,11 @@ namespace osu.Game.Screens.Play.PlayerSettings { mouseWheelCheckbox = new PlayerCheckbox { - LabelText = "Disable mouse wheel during gameplay" + LabelText = "Disable mouse wheel" }, mouseButtonsCheckbox = new PlayerCheckbox { - LabelText = "Disable mouse buttons during gameplay" + LabelText = "Disable mouse buttons" } }; } From 93029fd5482d4fec1f493bfb83f41417283dcd67 Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Thu, 10 May 2018 20:38:55 +0300 Subject: [PATCH 033/253] Remove mouseWheelCheckbox from InputSettings player overlay --- osu.Game/Screens/Play/PlayerSettings/InputSettings.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs b/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs index 25b6ebc2c3..755ba468cc 100644 --- a/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/InputSettings.cs @@ -11,17 +11,12 @@ namespace osu.Game.Screens.Play.PlayerSettings { protected override string Title => "Input settings"; - private readonly PlayerCheckbox mouseWheelCheckbox; private readonly PlayerCheckbox mouseButtonsCheckbox; public InputSettings() { Children = new Drawable[] { - mouseWheelCheckbox = new PlayerCheckbox - { - LabelText = "Disable mouse wheel" - }, mouseButtonsCheckbox = new PlayerCheckbox { LabelText = "Disable mouse buttons" @@ -30,10 +25,6 @@ namespace osu.Game.Screens.Play.PlayerSettings } [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - mouseWheelCheckbox.Bindable = config.GetBindable(OsuSetting.MouseDisableWheel); - mouseButtonsCheckbox.Bindable = config.GetBindable(OsuSetting.MouseDisableButtons); - } + private void load(OsuConfigManager config) => mouseButtonsCheckbox.Bindable = config.GetBindable(OsuSetting.MouseDisableButtons); } } From 2a90686da622cbf9d6619bb787e3cc370de07906 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Sat, 12 May 2018 15:09:53 +0300 Subject: [PATCH 034/253] Simplify expression --- osu-framework | 2 +- osu.Game/Screens/Edit/EditorClock.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index 0773d895d9..e793a08417 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 0773d895d9aa0729995cd4a23efc28238e35ceed +Subproject commit e793a084177f53920645c4f6f70cfef91e7fd19e diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 88d8477233..6cae4d9187 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -9,6 +9,7 @@ using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Screens.Edit.Screens.Compose; +using OpenTK; namespace osu.Game.Screens.Edit { @@ -126,7 +127,7 @@ namespace osu.Game.Screens.Edit seekTime = nextTimingPoint.Time; // Ensure the sought point is within the boundaries - seekTime = Math.Min(Math.Max(0, seekTime), TrackLength); + seekTime = MathHelper.Clamp(seekTime, 0, TrackLength); Seek(seekTime); } } From 2492e34d3fd8be6aaf3d3804b413901485de8b80 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Thu, 17 May 2018 19:44:09 +0200 Subject: [PATCH 035/253] 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 6f94c110a56e975c74417548efbc9841e67c6315 Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Thu, 17 May 2018 23:09:13 +0300 Subject: [PATCH 036/253] Fix submodule conflict --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index e793a08417..fac688633b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e793a084177f53920645c4f6f70cfef91e7fd19e +Subproject commit fac688633b8fcf34ae5d0514c26b03e217161eb4 From 1f37dca7b7ea0ce8a19ae1ea7b426b1e7a4547c8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 19 May 2018 14:47:06 +0900 Subject: [PATCH 037/253] Fix HR / EZ being applied twice to AR --- .../Difficulty/OsuPerformanceCalculator.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index eeb776fa6e..ae74f12339 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -61,17 +61,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty if (mods.Any(m => !m.Ranked)) return 0; - // Todo: In the future we should apply changes to PreEmpt/AR at an OsuHitObject/BaseDifficulty level, but this is done - // locally for now as doing so would modify animations and other things unexpectedly - // DO NOT MODIFY THIS - double ar = Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate; - if (mods.Any(m => m is OsuModHardRock)) - ar = Math.Min(10, ar * 1.4); - if (mods.Any(m => m is OsuModEasy)) - ar = Math.Max(0, ar / 2); - - double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / TimeRate; double hitWindowGreat = (Beatmap.HitObjects.First().HitWindows.Great / 2 - 0.5) / TimeRate; + double preEmpt = BeatmapDifficulty.DifficultyRange(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / TimeRate; realApproachRate = preEmpt > 1200 ? (1800 - preEmpt) / 120 : (1200 - preEmpt) / 150 + 5; realOverallDifficulty = (80 - 0.5 - hitWindowGreat) / 6; From f53164843d0d17d17282e041a501cf2bb527a618 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 May 2018 15:56:02 +0900 Subject: [PATCH 038/253] 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 039/253] 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 040/253] 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 a54bda6ce1f15c98643014534e1be914834fa2ae Mon Sep 17 00:00:00 2001 From: AlFasGD Date: Mon, 21 May 2018 13:23:39 +0300 Subject: [PATCH 041/253] Apply requested changes --- osu-framework | 2 +- osu.Game/Screens/Edit/EditorClock.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu-framework b/osu-framework index fac688633b..80e78fd45b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit fac688633b8fcf34ae5d0514c26b03e217161eb4 +Subproject commit 80e78fd45bb79ca4bc46ecc05deb6058f3879faa diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs index 6cae4d9187..72fb91e7df 100644 --- a/osu.Game/Screens/Edit/EditorClock.cs +++ b/osu.Game/Screens/Edit/EditorClock.cs @@ -18,9 +18,7 @@ namespace osu.Game.Screens.Edit /// public class EditorClock : DecoupleableInterpolatingFramedClock { - //public Bindable Beatmap = new Bindable(); - - public double TrackLength; + public readonly double TrackLength; public ControlPointInfo ControlPointInfo; @@ -33,6 +31,7 @@ namespace osu.Game.Screens.Edit ControlPointInfo = beatmap.Value.Beatmap.ControlPointInfo; TrackLength = beatmap.Value.Track.Length; } + public EditorClock(ControlPointInfo controlPointInfo, double trackLength, BindableBeatDivisor beatDivisor) { this.beatDivisor = beatDivisor; From 30956b64aa394fa51bc2b23084519b23fd9b2417 Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Mon, 21 May 2018 18:57:01 +0300 Subject: [PATCH 042/253] Do not change Margin for player settings groups on the PlayerLoader screen --- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 13293b6f93..06c1503fd1 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -58,7 +58,7 @@ namespace osu.Game.Screens.Play AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 20), - Margin = new MarginPadding { Top = 100, Right = 10 }, + Margin = new MarginPadding(25), Children = new PlayerSettingsGroup[] { new VisualSettings(), From 1210368e29bdf8ebfb159894067cb9679add1fae Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 21 May 2018 23:00:02 -0300 Subject: [PATCH 043/253] Add MultiplayerScreen base class. --- osu.Game/Screens/Multi/Header.cs | 3 +- .../Multi/Screens/MultiplayerScreen.cs | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index db8898495f..f6b7bbfcef 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.SearchableList; +using osu.Game.Screens.Multi.Screens; using OpenTK; using OpenTK.Graphics; @@ -85,7 +86,7 @@ namespace osu.Game.Screens.Multi }, }; - breadcrumbs.Current.ValueChanged += s => screenTitle.Text = s.ToString(); + breadcrumbs.Current.ValueChanged += s => screenTitle.Text = s is MultiplayerScreen m ? m.Title : s.ToString(); breadcrumbs.Current.TriggerChange(); } diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs new file mode 100644 index 0000000000..5a17a32d8c --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -0,0 +1,57 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Screens; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Screens.Multi.Screens +{ + public abstract class MultiplayerScreen : OsuScreen + { + private const Easing in_easing = Easing.OutQuint; + private const Easing out_easing = Easing.InSine; + + protected virtual Container TransitionContent => Content; + + public abstract string Title { get; } + public abstract string Name { get; } + + public override string ToString() => Name; + + protected override void OnEntering(Screen last) + { + base.OnEntering(last); + + TransitionContent.MoveToX(200); + + TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing); + TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); + } + + protected override bool OnExiting(Screen next) + { + Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, out_easing); + TransitionContent.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, out_easing); + + return base.OnExiting(next); + } + + protected override void OnResuming(Screen last) + { + base.OnResuming(last); + + Content.FadeIn(WaveContainer.APPEAR_DURATION, in_easing); + TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); + } + + protected override void OnSuspending(Screen next) + { + base.OnSuspending(next); + + Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, out_easing); + TransitionContent.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, out_easing); + } + } +} From cae09492c30749096e2b6c54351234527f47be27 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 00:07:04 -0300 Subject: [PATCH 044/253] Basic Lounge functionality. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 158 ++++++++++++++++++ osu.Game.Tests/Visual/TestCaseMultiHeader.cs | 6 +- .../Screens/Multi/Components/DrawableRoom.cs | 33 +++- osu.Game/Screens/Multi/Multiplayer.cs | 8 +- osu.Game/Screens/Multi/Screens/Lobby.cs | 16 -- osu.Game/Screens/Multi/Screens/Lounge.cs | 115 +++++++++++++ osu.Game/Screens/Multi/Screens/Match.cs | 5 + 7 files changed, 312 insertions(+), 29 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseLounge.cs delete mode 100644 osu.Game/Screens/Multi/Screens/Lobby.cs create mode 100644 osu.Game/Screens/Multi/Screens/Lounge.cs diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs new file mode 100644 index 0000000000..b621899949 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -0,0 +1,158 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Screens; +using osu.Game.Users; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseLounge : OsuTestCase + { + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + Lounge lounge = new Lounge(); + + Room[] rooms = + { + new Room + { + Name = { Value = @"Just Another Room" }, + Host = { Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } } }, + Status = { Value = new RoomStatusPlaying() }, + Type = { Value = new GameTypeTagTeam() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 5.65, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"Sidetracked Day (Short Ver.)", + Artist = @"VINXIS", + AuthorString = @"Hobbes2", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/767600/covers/cover.jpg?1526243446", + }, + }, + }, + } + }, + MaxParticipants = { Value = 10 }, + Participants = + { + Value = new[] + { + new User { Username = @"flyte", Id = 3103765, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 142 } } }, + new User { Username = @"Cookiezi", Id = 124493, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 546 } } }, + new User { Username = @"Angelsim", Id = 1777162, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 287 } } }, + new User { Username = @"Rafis", Id = 2558286, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 468 } } }, + new User { Username = @"hvick225", Id = 50265, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 325 } } }, + new User { Username = @"peppy", Id = 2, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 625 } } }, + } + } + }, + new Room + { + Name = { Value = @"Not Just Any Room" }, + Host = { Value = new User { Username = @"Monstrata", Id = 2706438, Country = new Country { FlagName = @"CA" } } }, + Status = { Value = new RoomStatusOpen() }, + Type = { Value = new GameTypeTeamVersus() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 2.73, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"lit(var)", + Artist = @"kensuke ushio", + AuthorString = @"Monstrata", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/623972/covers/cover.jpg?1521167183", + }, + }, + }, + } + }, + Participants = + { + Value = new[] + { + new User { Username = @"Jeby", Id = 3136279, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 3497 } } }, + new User { Username = @"DualAkira", Id = 5220933, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 643 } } }, + new User { Username = @"Datenshi Yohane", Id = 7171857, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 10555 } } }, + } + } + }, + new Room + { + Name = { Value = @"room THE FINAL" }, + Host = { Value = new User { Username = @"Delis", Id = 1603923, Country = new Country { FlagName = @"JP" } } }, + Status = { Value = new RoomStatusPlaying() }, + Type = { Value = new GameTypeTagTeam() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 4.48, + Ruleset = rulesets.GetRuleset(3), + Metadata = new BeatmapMetadata + { + Title = @"663098", + Artist = @"OISHII", + AuthorString = @"Mentholzzz", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/663098/covers/cover.jpg?1521898837", + }, + }, + }, + } + }, + MaxParticipants = { Value = 30 }, + Participants = + { + Value = new[] + { + new User { Username = @"KizuA", Id = 6510442, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 5372 } } }, + new User { Username = @"Colored", Id = 827563, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 810 } } }, + new User { Username = @"Beryl", Id = 3817591, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 10096 } } }, + } + } + }, + }; + + AddStep(@"show", () => Add(lounge)); + AddStep(@"set rooms", () => lounge.Rooms = rooms); + AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); + AddStep(@"set rooms", () => lounge.Rooms = rooms); + AddStep(@"exit", lounge.Exit); + } + } +} diff --git a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs index af51a6221f..4406676aca 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs @@ -13,14 +13,14 @@ namespace osu.Game.Tests.Visual { public TestCaseMultiHeader() { - Lobby lobby; + Lounge lounge; Children = new Drawable[] { - lobby = new Lobby + lounge = new Lounge { Padding = new MarginPadding { Top = Header.HEIGHT }, }, - new Header(lobby), + new Header(lounge), }; } } diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 88a253d719..e5ba1a87cf 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; @@ -25,8 +26,8 @@ namespace osu.Game.Screens.Multi.Components { public class DrawableRoom : OsuClickableContainer, IStateful { + public const float SELECTION_BORDER_WIDTH = 4; private const float corner_radius = 5; - private const float selection_border_width = 4; private const float transition_duration = 100; private const float content_padding = 10; private const float height = 100; @@ -62,6 +63,17 @@ namespace osu.Game.Screens.Multi.Components } } + private Action action; + public new Action Action + { + get { return action; } + set + { + action = value; + Enabled.Value = action != null; + } + } + public event Action StateChanged; public DrawableRoom(Room room) @@ -69,8 +81,8 @@ namespace osu.Game.Screens.Multi.Components Room = room; RelativeSizeAxes = Axes.X; - Height = height + selection_border_width * 2; - CornerRadius = corner_radius + selection_border_width / 2; + Height = height + SELECTION_BORDER_WIDTH * 2; + CornerRadius = corner_radius + SELECTION_BORDER_WIDTH / 2; Masking = true; // create selectionBox here so State can be set before being loaded @@ -79,8 +91,6 @@ namespace osu.Game.Screens.Multi.Components RelativeSizeAxes = Axes.Both, Alpha = 0f, }; - - Action += () => State = SelectionState.Selected; } [BackgroundDependencyLoader] @@ -98,7 +108,7 @@ namespace osu.Game.Screens.Multi.Components new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding(selection_border_width), + Padding = new MarginPadding(SELECTION_BORDER_WIDTH), Child = new Container { RelativeSizeAxes = Axes.Both, @@ -272,5 +282,16 @@ namespace osu.Game.Screens.Multi.Components beatmapBind.BindTo(Room.Beatmap); participantsBind.BindTo(Room.Participants); } + + protected override bool OnClick(InputState state) + { + if (Enabled.Value) + { + Action?.Invoke(this); + State = SelectionState.Selected; + } + + return true; + } } } diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index b3d393209c..347a12dd56 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi RelativeSizeAxes = Axes.Both, }; - Lobby lobby; + Lounge lounge; Children = new Drawable[] { new Container @@ -52,12 +52,12 @@ namespace osu.Game.Screens.Multi { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = Header.HEIGHT }, - Child = lobby = new Lobby(), + Child = lounge = new Lounge(), }, - new Header(lobby), + new Header(lounge), }; - lobby.Exited += s => Exit(); + lounge.Exited += s => Exit(); } protected override void OnEntering(Screen last) diff --git a/osu.Game/Screens/Multi/Screens/Lobby.cs b/osu.Game/Screens/Multi/Screens/Lobby.cs deleted file mode 100644 index dcda40e0d7..0000000000 --- a/osu.Game/Screens/Multi/Screens/Lobby.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; - -namespace osu.Game.Screens.Multi.Screens -{ - public class Lobby : ScreenWhiteBox - { - protected override IEnumerable PossibleChildren => new[] { - typeof(MatchCreate), - typeof(Match) - }; - } -} diff --git a/osu.Game/Screens/Multi/Screens/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge.cs new file mode 100644 index 0000000000..b2ce94dd64 --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Lounge.cs @@ -0,0 +1,115 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using System.Collections.Generic; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.Multiplayer; +using osu.Game.Overlays.SearchableList; +using osu.Game.Screens.Multi.Components; +using OpenTK; + +namespace osu.Game.Screens.Multi.Screens +{ + public class Lounge : MultiplayerScreen + { + private readonly Container content; + private readonly FillFlowContainer roomsFlow; + private readonly RoomInspector roomInspector; + + protected override Container TransitionContent => content; + + public override string Title => "lounge"; + public override string Name => "Lounge"; + + private IEnumerable rooms; + public IEnumerable Rooms + { + get { return rooms; } + set + { + if (Equals(value, rooms)) return; + rooms = value; + + var enumerable = rooms.ToList(); + + roomsFlow.Children = enumerable.Select(r => new DrawableRoom(r) + { + Action = didSelect, + }).ToList(); + + if (!enumerable.Contains(roomInspector.Room)) + roomInspector.Room = null; + } + } + + public Lounge() + { + Children = new Drawable[] + { + content = new Container + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + Width = 0.55f, + Padding = new MarginPadding + { + Vertical = 35 - DrawableRoom.SELECTION_BORDER_WIDTH, + Right = 20 - DrawableRoom.SELECTION_BORDER_WIDTH + }, + Child = roomsFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + LayoutEasing = Easing.OutQuint, + LayoutDuration = 200, + Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2), + }, + }, + roomInspector = new RoomInspector + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Both, + Width = 0.45f, + }, + }, + }, + }; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + content.Padding = new MarginPadding + { + Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH, + Right = SearchableListOverlay.WIDTH_PADDING, + }; + } + + private void didSelect(DrawableRoom room) + { + roomsFlow.Children.ForEach(c => + { + if (c != room) + c.State = SelectionState.NotSelected; + }); + + roomInspector.Room = room.Room; + + // open the room if its selected and is clicked again + if (room.State == SelectionState.Selected) + Push(new Match(room.Room)); + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/Match.cs b/osu.Game/Screens/Multi/Screens/Match.cs index 4ba7fe9f6a..f6178d5691 100644 --- a/osu.Game/Screens/Multi/Screens/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Screens; +using osu.Game.Online.Multiplayer; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play; using osu.Game.Screens.Select; @@ -21,6 +22,10 @@ namespace osu.Game.Screens.Multi.Screens protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); + public Match(Room room) + { + } + protected override void OnEntering(Screen last) { base.OnEntering(last); From f7a4a4eeef45c7afc392729949b70ecd12231b40 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 00:24:39 -0300 Subject: [PATCH 045/253] Add Lounge FilterControl. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 2 +- osu.Game.Tests/Visual/TestCaseMultiHeader.cs | 2 +- osu.Game/Online/Multiplayer/Room.cs | 1 + .../Online/Multiplayer/RoomAvailability.cs | 18 +++++++++ osu.Game/Screens/Multi/Multiplayer.cs | 2 +- .../Multi/Screens/Lounge/FilterControl.cs | 27 +++++++++++++ .../Multi/Screens/{ => Lounge}/Lounge.cs | 40 ++++++++++++++++++- 7 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 osu.Game/Online/Multiplayer/RoomAvailability.cs create mode 100644 osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs rename osu.Game/Screens/Multi/Screens/{ => Lounge}/Lounge.cs (78%) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index b621899949..9dbc4012d5 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -6,7 +6,7 @@ using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; -using osu.Game.Screens.Multi.Screens; +using osu.Game.Screens.Multi.Screens.Lounge; using osu.Game.Users; namespace osu.Game.Tests.Visual diff --git a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs index 4406676aca..d27a447077 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Game.Screens.Multi; -using osu.Game.Screens.Multi.Screens; +using osu.Game.Screens.Multi.Screens.Lounge; namespace osu.Game.Tests.Visual { diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index f1c23e9e84..ae3fb5ec6e 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -12,6 +12,7 @@ namespace osu.Game.Online.Multiplayer public Bindable Name = new Bindable(); public Bindable Host = new Bindable(); public Bindable Status = new Bindable(); + public Bindable Availability = new Bindable(); public Bindable Type = new Bindable(); public Bindable Beatmap = new Bindable(); public Bindable MaxParticipants = new Bindable(); diff --git a/osu.Game/Online/Multiplayer/RoomAvailability.cs b/osu.Game/Online/Multiplayer/RoomAvailability.cs new file mode 100644 index 0000000000..6c154207ff --- /dev/null +++ b/osu.Game/Online/Multiplayer/RoomAvailability.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.ComponentModel; + +namespace osu.Game.Online.Multiplayer +{ + public enum RoomAvailability + { + Public, + + [Description(@"Friends Only")] + FriendsOnly, + + [Description(@"Invite Only")] + InviteOnly, + } +} diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 347a12dd56..ddaeb26806 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -8,7 +8,7 @@ using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; -using osu.Game.Screens.Multi.Screens; +using osu.Game.Screens.Multi.Screens.Lounge; namespace osu.Game.Screens.Multi { diff --git a/osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs b/osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs new file mode 100644 index 0000000000..421c89479a --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Graphics; +using osu.Game.Online.Multiplayer; +using osu.Game.Overlays.SearchableList; +using OpenTK.Graphics; + +namespace osu.Game.Screens.Multi.Screens.Lounge +{ + public class FilterControl : SearchableListFilterControl + { + protected override Color4 BackgroundColour => OsuColour.FromHex(@"362e42"); + protected override LoungeTab DefaultTab => LoungeTab.Public; + + public FilterControl() + { + DisplayStyleControl.Hide(); + } + } + + public enum LoungeTab + { + Public = RoomAvailability.Public, + Private = RoomAvailability.FriendsOnly, + } +} diff --git a/osu.Game/Screens/Multi/Screens/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs similarity index 78% rename from osu.Game/Screens/Multi/Screens/Lounge.cs rename to osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index b2ce94dd64..39aa1d73e7 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -1,21 +1,24 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using System.Collections.Generic; +using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input; +using osu.Framework.Screens; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; using osu.Game.Screens.Multi.Components; using OpenTK; -namespace osu.Game.Screens.Multi.Screens +namespace osu.Game.Screens.Multi.Screens.Lounge { public class Lounge : MultiplayerScreen { + private readonly FilterControl filter; private readonly Container content; private readonly FillFlowContainer roomsFlow; private readonly RoomInspector roomInspector; @@ -50,6 +53,7 @@ namespace osu.Game.Screens.Multi.Screens { Children = new Drawable[] { + filter = new FilterControl(), content = new Container { RelativeSizeAxes = Axes.Both, @@ -84,6 +88,8 @@ namespace osu.Game.Screens.Multi.Screens }, }, }; + + filter.Search.Exit += Exit; } protected override void UpdateAfterChildren() @@ -92,11 +98,41 @@ namespace osu.Game.Screens.Multi.Screens content.Padding = new MarginPadding { + Top = filter.DrawHeight, Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH, Right = SearchableListOverlay.WIDTH_PADDING, }; } + protected override void OnFocus(InputState state) + { + GetContainingInputManager().ChangeFocus(filter.Search); + } + + protected override void OnEntering(Screen last) + { + base.OnEntering(last); + filter.Search.HoldFocus = true; + } + + protected override bool OnExiting(Screen next) + { + filter.Search.HoldFocus = false; + return base.OnExiting(next); + } + + protected override void OnResuming(Screen last) + { + base.OnResuming(last); + filter.Search.HoldFocus = true; + } + + protected override void OnSuspending(Screen next) + { + base.OnSuspending(next); + filter.Search.HoldFocus = false; + } + private void didSelect(DrawableRoom room) { roomsFlow.Children.ForEach(c => From 6aac4269e6c4e458a41ee5ebf64d0adca01d07ac Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 00:33:41 -0300 Subject: [PATCH 046/253] Add filtering. --- .../Screens/Multi/Components/DrawableRoom.cs | 18 ++++++- .../Screens/Multi/Screens/Lounge/Lounge.cs | 52 ++++++++++++++++--- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index e5ba1a87cf..94f5f95062 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -24,7 +25,7 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Multi.Components { - public class DrawableRoom : OsuClickableContainer, IStateful + public class DrawableRoom : OsuClickableContainer, IStateful, IFilterable { public const float SELECTION_BORDER_WIDTH = 4; private const float corner_radius = 5; @@ -63,6 +64,21 @@ namespace osu.Game.Screens.Multi.Components } } + public IEnumerable FilterTerms => new[] { Room.Name.Value }; + + private bool matchingFilter; + public bool MatchingFilter + { + get { return matchingFilter; } + set + { + if (value == matchingFilter) return; + matchingFilter = value; + + this.FadeTo(MatchingFilter ? 1 : 0, 200); + } + } + private Action action; public new Action Action { diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 39aa1d73e7..26c4acdcfd 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -20,7 +20,8 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { private readonly FilterControl filter; private readonly Container content; - private readonly FillFlowContainer roomsFlow; + private readonly SearchContainer search; + private readonly RoomsFilterContainer roomsFlow; private readonly RoomInspector roomInspector; protected override Container TransitionContent => content; @@ -46,6 +47,8 @@ namespace osu.Game.Screens.Multi.Screens.Lounge if (!enumerable.Contains(roomInspector.Room)) roomInspector.Room = null; + + filterRooms(); } } @@ -68,14 +71,17 @@ namespace osu.Game.Screens.Multi.Screens.Lounge Vertical = 35 - DrawableRoom.SELECTION_BORDER_WIDTH, Right = 20 - DrawableRoom.SELECTION_BORDER_WIDTH }, - Child = roomsFlow = new FillFlowContainer + Child = search = new SearchContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - LayoutEasing = Easing.OutQuint, - LayoutDuration = 200, - Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2), + Child = roomsFlow = new RoomsFilterContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2), + }, }, }, roomInspector = new RoomInspector @@ -89,6 +95,8 @@ namespace osu.Game.Screens.Multi.Screens.Lounge }, }; + filter.Search.Current.ValueChanged += s => filterRooms(); + filter.Tabs.Current.ValueChanged += t => filterRooms(); filter.Search.Exit += Exit; } @@ -133,6 +141,17 @@ namespace osu.Game.Screens.Multi.Screens.Lounge filter.Search.HoldFocus = false; } + private void filterRooms() + { + search.SearchTerm = filter.Search.Current.Value ?? string.Empty; + + foreach (DrawableRoom r in roomsFlow.Children) + { + r.MatchingFilter = r.MatchingFilter && + r.Room.Availability.Value == (RoomAvailability)filter.Tabs.Current.Value; + } + } + private void didSelect(DrawableRoom room) { roomsFlow.Children.ForEach(c => @@ -147,5 +166,26 @@ namespace osu.Game.Screens.Multi.Screens.Lounge if (room.State == SelectionState.Selected) Push(new Match(room.Room)); } + + private class RoomsFilterContainer : FillFlowContainer, IHasFilterableChildren + { + public IEnumerable FilterTerms => new string[] { }; + public IEnumerable FilterableChildren => Children; + + public bool MatchingFilter + { + set + { + if (value) + InvalidateLayout(); + } + } + + public RoomsFilterContainer() + { + LayoutDuration = 200; + LayoutEasing = Easing.OutQuint; + } + } } } From 662559d3c993859a9fd24c3aaab74c690edbdf82 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:22:23 -0300 Subject: [PATCH 047/253] More test steps. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 58 ++++++++++++++++++- .../Screens/Multi/Components/DrawableRoom.cs | 2 - .../Screens/Multi/Screens/Lounge/Lounge.cs | 48 +++++++-------- 3 files changed, 80 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index 9dbc4012d5..a89c12a1be 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -1,23 +1,29 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Screens.Lounge; using osu.Game.Users; +using OpenTK.Input; namespace osu.Game.Tests.Visual { [TestFixture] - public class TestCaseLounge : OsuTestCase + public class TestCaseLounge : ManualInputManagerTestCase { + private TestLounge lounge; + [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { - Lounge lounge = new Lounge(); + lounge = new TestLounge(); Room[] rooms = { @@ -26,6 +32,7 @@ namespace osu.Game.Tests.Visual Name = { Value = @"Just Another Room" }, Host = { Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } } }, Status = { Value = new RoomStatusPlaying() }, + Availability = { Value = RoomAvailability.Public }, Type = { Value = new GameTypeTagTeam() }, Beatmap = { @@ -70,6 +77,7 @@ namespace osu.Game.Tests.Visual Name = { Value = @"Not Just Any Room" }, Host = { Value = new User { Username = @"Monstrata", Id = 2706438, Country = new Country { FlagName = @"CA" } } }, Status = { Value = new RoomStatusOpen() }, + Availability = { Value = RoomAvailability.FriendsOnly }, Type = { Value = new GameTypeTeamVersus() }, Beatmap = { @@ -110,6 +118,7 @@ namespace osu.Game.Tests.Visual Name = { Value = @"room THE FINAL" }, Host = { Value = new User { Username = @"Delis", Id = 1603923, Country = new Country { FlagName = @"JP" } } }, Status = { Value = new RoomStatusPlaying() }, + Availability = { Value = RoomAvailability.Public }, Type = { Value = new GameTypeTagTeam() }, Beatmap = { @@ -150,9 +159,54 @@ namespace osu.Game.Tests.Visual AddStep(@"show", () => Add(lounge)); AddStep(@"set rooms", () => lounge.Rooms = rooms); + selectAssert(0); + AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); + AddAssert(@"no room selected", () => lounge.SelectedRoom == null); + AddStep(@"set rooms", () => lounge.Rooms = rooms); + selectAssert(1); + AddStep(@"open room 1", () => clickRoom(1)); + AddStep(@"make lounge current", lounge.MakeCurrent); + filterAssert(@"THE FINAL", LoungeTab.Public, 1); + filterAssert(string.Empty, LoungeTab.Public, 2); + filterAssert(string.Empty, LoungeTab.Private, 1); + filterAssert(string.Empty, LoungeTab.Public, 2); + filterAssert(@"no matches", LoungeTab.Public, 0); AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); AddStep(@"set rooms", () => lounge.Rooms = rooms); + AddAssert(@"no matches after clear", () => lounge.MatchedCount == 0); + filterAssert(string.Empty, LoungeTab.Public, 2); AddStep(@"exit", lounge.Exit); } + + private void clickRoom(int n) + { + InputManager.MoveMouseTo(lounge.ChildRooms[n]); + InputManager.Click(MouseButton.Left); + } + + private void selectAssert(int n) + { + AddStep($@"select room {n}", () => clickRoom(n)); + AddAssert($@"room {n} selected", () => lounge.SelectedRoom == lounge.ChildRooms[n].Room); + } + + private void filterAssert(string filter, LoungeTab tab, int endCount) + { + AddStep($@"filter '{filter}', {tab}", () => lounge.SetFilter(filter, tab)); + AddAssert(@"filtered correctly", () => lounge.MatchedCount == endCount); + } + + private class TestLounge : Lounge + { + public IReadOnlyList ChildRooms => RoomsContainer.Children; + public Room SelectedRoom => Inspector.Room; + public int MatchedCount => ChildRooms.Count(r => r.MatchingFilter); + + public void SetFilter(string filter, LoungeTab tab) + { + Filter.Search.Current.Value = filter; + Filter.Tabs.Current.Value = tab; + } + } } } diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 94f5f95062..d11d4a4795 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -72,9 +72,7 @@ namespace osu.Game.Screens.Multi.Components get { return matchingFilter; } set { - if (value == matchingFilter) return; matchingFilter = value; - this.FadeTo(MatchingFilter ? 1 : 0, 200); } } diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 26c4acdcfd..30ca897c1a 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -18,16 +18,16 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { public class Lounge : MultiplayerScreen { - private readonly FilterControl filter; private readonly Container content; private readonly SearchContainer search; - private readonly RoomsFilterContainer roomsFlow; - private readonly RoomInspector roomInspector; - protected override Container TransitionContent => content; + protected readonly FilterControl Filter; + protected readonly FillFlowContainer RoomsContainer; + protected readonly RoomInspector Inspector; public override string Title => "lounge"; public override string Name => "Lounge"; + protected override Container TransitionContent => content; private IEnumerable rooms; public IEnumerable Rooms @@ -40,13 +40,13 @@ namespace osu.Game.Screens.Multi.Screens.Lounge var enumerable = rooms.ToList(); - roomsFlow.Children = enumerable.Select(r => new DrawableRoom(r) + RoomsContainer.Children = enumerable.Select(r => new DrawableRoom(r) { Action = didSelect, }).ToList(); - if (!enumerable.Contains(roomInspector.Room)) - roomInspector.Room = null; + if (!enumerable.Contains(Inspector.Room)) + Inspector.Room = null; filterRooms(); } @@ -56,7 +56,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { Children = new Drawable[] { - filter = new FilterControl(), + Filter = new FilterControl(), content = new Container { RelativeSizeAxes = Axes.Both, @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Child = roomsFlow = new RoomsFilterContainer + Child = RoomsContainer = new RoomsFilterContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -84,7 +84,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge }, }, }, - roomInspector = new RoomInspector + Inspector = new RoomInspector { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -95,9 +95,9 @@ namespace osu.Game.Screens.Multi.Screens.Lounge }, }; - filter.Search.Current.ValueChanged += s => filterRooms(); - filter.Tabs.Current.ValueChanged += t => filterRooms(); - filter.Search.Exit += Exit; + Filter.Search.Current.ValueChanged += s => filterRooms(); + Filter.Tabs.Current.ValueChanged += t => filterRooms(); + Filter.Search.Exit += Exit; } protected override void UpdateAfterChildren() @@ -106,7 +106,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge content.Padding = new MarginPadding { - Top = filter.DrawHeight, + Top = Filter.DrawHeight, Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH, Right = SearchableListOverlay.WIDTH_PADDING, }; @@ -114,53 +114,53 @@ namespace osu.Game.Screens.Multi.Screens.Lounge protected override void OnFocus(InputState state) { - GetContainingInputManager().ChangeFocus(filter.Search); + GetContainingInputManager().ChangeFocus(Filter.Search); } protected override void OnEntering(Screen last) { base.OnEntering(last); - filter.Search.HoldFocus = true; + Filter.Search.HoldFocus = true; } protected override bool OnExiting(Screen next) { - filter.Search.HoldFocus = false; + Filter.Search.HoldFocus = false; return base.OnExiting(next); } protected override void OnResuming(Screen last) { base.OnResuming(last); - filter.Search.HoldFocus = true; + Filter.Search.HoldFocus = true; } protected override void OnSuspending(Screen next) { base.OnSuspending(next); - filter.Search.HoldFocus = false; + Filter.Search.HoldFocus = false; } private void filterRooms() { - search.SearchTerm = filter.Search.Current.Value ?? string.Empty; + search.SearchTerm = Filter.Search.Current.Value ?? string.Empty; - foreach (DrawableRoom r in roomsFlow.Children) + foreach (DrawableRoom r in RoomsContainer.Children) { r.MatchingFilter = r.MatchingFilter && - r.Room.Availability.Value == (RoomAvailability)filter.Tabs.Current.Value; + r.Room.Availability.Value == (RoomAvailability)Filter.Tabs.Current.Value; } } private void didSelect(DrawableRoom room) { - roomsFlow.Children.ForEach(c => + RoomsContainer.Children.ForEach(c => { if (c != room) c.State = SelectionState.NotSelected; }); - roomInspector.Room = room.Room; + Inspector.Room = room.Room; // open the room if its selected and is clicked again if (room.State == SelectionState.Selected) From fba79a4de651a3cab48ceb58b8acd2cd120df4fc Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:31:01 -0300 Subject: [PATCH 048/253] Test typo. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index a89c12a1be..8a3bc79e8d 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual Ruleset = rulesets.GetRuleset(3), Metadata = new BeatmapMetadata { - Title = @"663098", + Title = @"ONIGIRI FREEWAY", Artist = @"OISHII", AuthorString = @"Mentholzzz", }, From 3cc5bb516e6c875f415ca7d519ed78468eed2665 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:39:25 -0300 Subject: [PATCH 049/253] Remove unused Match ctor param. --- osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs | 2 +- osu.Game/Screens/Multi/Screens/Match.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 30ca897c1a..01a7510f76 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge // open the room if its selected and is clicked again if (room.State == SelectionState.Selected) - Push(new Match(room.Room)); + Push(new Match()); } private class RoomsFilterContainer : FillFlowContainer, IHasFilterableChildren diff --git a/osu.Game/Screens/Multi/Screens/Match.cs b/osu.Game/Screens/Multi/Screens/Match.cs index f6178d5691..d57f43fcd1 100644 --- a/osu.Game/Screens/Multi/Screens/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Screens; -using osu.Game.Online.Multiplayer; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play; using osu.Game.Screens.Select; @@ -22,7 +21,7 @@ namespace osu.Game.Screens.Multi.Screens protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - public Match(Room room) + public Match() { } From 349b0a33221acf335cb9bae3a99178fc2522036b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:46:08 -0300 Subject: [PATCH 050/253] Remove empty ctor. --- osu.Game/Screens/Multi/Screens/Match.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match.cs b/osu.Game/Screens/Multi/Screens/Match.cs index d57f43fcd1..4ba7fe9f6a 100644 --- a/osu.Game/Screens/Multi/Screens/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match.cs @@ -21,10 +21,6 @@ namespace osu.Game.Screens.Multi.Screens protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - public Match() - { - } - protected override void OnEntering(Screen last) { base.OnEntering(last); From 0b19b7d9e56f64032207c9c36ea0a4382919e781 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 02:08:50 -0300 Subject: [PATCH 051/253] Fix test case. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index 8a3bc79e8d..b96d705d5c 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -173,34 +173,33 @@ namespace osu.Game.Tests.Visual filterAssert(@"no matches", LoungeTab.Public, 0); AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); AddStep(@"set rooms", () => lounge.Rooms = rooms); - AddAssert(@"no matches after clear", () => lounge.MatchedCount == 0); + AddAssert(@"no matches after clear", () => !lounge.ChildRooms.Any()); filterAssert(string.Empty, LoungeTab.Public, 2); AddStep(@"exit", lounge.Exit); } private void clickRoom(int n) { - InputManager.MoveMouseTo(lounge.ChildRooms[n]); + InputManager.MoveMouseTo(lounge.ChildRooms.ElementAt(n)); InputManager.Click(MouseButton.Left); } private void selectAssert(int n) { AddStep($@"select room {n}", () => clickRoom(n)); - AddAssert($@"room {n} selected", () => lounge.SelectedRoom == lounge.ChildRooms[n].Room); + AddAssert($@"room {n} selected", () => lounge.SelectedRoom == lounge.ChildRooms.ElementAt(n).Room); } private void filterAssert(string filter, LoungeTab tab, int endCount) { AddStep($@"filter '{filter}', {tab}", () => lounge.SetFilter(filter, tab)); - AddAssert(@"filtered correctly", () => lounge.MatchedCount == endCount); + AddAssert(@"filtered correctly", () => lounge.ChildRooms.Count() == endCount); } private class TestLounge : Lounge { - public IReadOnlyList ChildRooms => RoomsContainer.Children; + public IEnumerable ChildRooms => RoomsContainer.Children.Where(r => r.MatchingFilter); public Room SelectedRoom => Inspector.Room; - public int MatchedCount => ChildRooms.Count(r => r.MatchingFilter); public void SetFilter(string filter, LoungeTab tab) { From a7bdaf75b0731125ddda2a5b7a3d84680279ceaf Mon Sep 17 00:00:00 2001 From: jorolf Date: Tue, 22 May 2018 13:05:15 +0200 Subject: [PATCH 052/253] Ensure badges are ordered correctly --- osu.Game/Overlays/Profile/Header/BadgeContainer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs index 36a9a9b01a..c97a4de464 100644 --- a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs @@ -113,7 +113,11 @@ namespace osu.Game.Overlays.Profile.Header { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - }, badgeFlowContainer.Add); + }, asyncBadge => + { + badgeFlowContainer.Add(asyncBadge); + badgeFlowContainer.ChangeChildDepth(asyncBadge, Array.IndexOf(badges, asyncBadge)); //Ensure the badges are ordered correctly + }); } } From be0fc24ad409fb0583c79edb423110ec79484961 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Tue, 22 May 2018 20:51:37 +0800 Subject: [PATCH 053/253] Fixed banana generation on catch specific maps --- osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs index 9dfe12f25e..5f9439534b 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs @@ -8,8 +8,9 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch /// /// Legacy osu!catch Spinner-type, used for parsing Beatmaps. /// - internal sealed class ConvertSpinner : HitObject, IHasEndTime + internal sealed class ConvertSpinner : HitObject, IHasEndTime, IHasXPosition { + public float X { get; set; } public double EndTime { get; set; } public double Duration => EndTime - StartTime; From b324337fa1457dcf4019c28036535f0406cf9a14 Mon Sep 17 00:00:00 2001 From: jorolf Date: Tue, 22 May 2018 15:29:52 +0200 Subject: [PATCH 054/253] Add icon next to beatmap title/username to open in browser --- .../Visual/TestCaseExternalLinkButton.cs | 20 +++++++ .../UserInterface/ExternalLinkButton.cs | 58 +++++++++++++++++++ osu.Game/Overlays/BeatmapSet/Header.cs | 24 +++++++- osu.Game/Overlays/Profile/ProfileHeader.cs | 45 +++++++------- 4 files changed, 119 insertions(+), 28 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs create mode 100644 osu.Game/Graphics/UserInterface/ExternalLinkButton.cs diff --git a/osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs b/osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs new file mode 100644 index 0000000000..bdb077ce5a --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using osu.Game.Graphics.UserInterface; +using OpenTK; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseExternalLinkButton : OsuTestCase + { + public override IReadOnlyList RequiredTypes => new[] { typeof(ExternalLinkButton) }; + + public TestCaseExternalLinkButton() + { + Child = new ExternalLinkButton("https://osu.ppy.sh/home") + { + Size = new Vector2(50) + }; + } + } +} diff --git a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs new file mode 100644 index 0000000000..800f77f547 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs @@ -0,0 +1,58 @@ +using System.Diagnostics; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Input; +using OpenTK.Graphics; + +namespace osu.Game.Graphics.UserInterface +{ + public class ExternalLinkButton : CompositeDrawable, IHasTooltip + { + public string Link { get; set; } + + private Color4 hoverColour; + + public ExternalLinkButton(string link = null) + { + Link = link; + InternalChild = new SpriteIcon + { + Icon = FontAwesome.fa_external_link, + RelativeSizeAxes = Axes.Both + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + hoverColour = colours.Yellow; + } + + protected override bool OnHover(InputState state) + { + InternalChild.FadeColour(hoverColour, 500, Easing.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + InternalChild.FadeColour(Color4.White, 500, Easing.OutQuint); + base.OnHoverLost(state); + } + + protected override bool OnClick(InputState state) + { + if(Link != null) + Process.Start(new ProcessStartInfo + { + FileName = Link, + UseShellExecute = true //see https://github.com/dotnet/corefx/issues/10361 + }); + return true; + } + + public string TooltipText => "View in browser"; + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 9b25d61f58..7d07816d11 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -11,6 +11,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.BeatmapSet.Buttons; using OpenTK; using OpenTK.Graphics; @@ -93,6 +94,7 @@ namespace osu.Game.Overlays.BeatmapSet public Header() { + ExternalLinkButton externalLink; RelativeSizeAxes = Axes.X; Height = 400; Masking = true; @@ -160,10 +162,25 @@ namespace osu.Game.Overlays.BeatmapSet Height = 113, Child = Picker = new BeatmapPicker(), }, - title = new OsuSpriteText + new FillFlowContainer { - Font = @"Exo2.0-BoldItalic", - TextSize = 37, + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + title = new OsuSpriteText + { + Font = @"Exo2.0-BoldItalic", + TextSize = 37, + }, + externalLink = new ExternalLinkButton + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Margin = new MarginPadding { Left = 3, Bottom = 4 }, //To better lineup with the font + Size = new Vector2(18), + }, + } }, artist = new OsuSpriteText { @@ -247,6 +264,7 @@ namespace osu.Game.Overlays.BeatmapSet }; Picker.Beatmap.ValueChanged += b => Details.Beatmap = b; + Picker.Beatmap.ValueChanged += b => externalLink.Link = $@"https://osu.ppy.sh/beatmapsets/{BeatmapSet?.OnlineBeatmapSetID}#{b?.Ruleset.ShortName}/{b?.OnlineBeatmapID}"; } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 4c411b3210..1a4a00da2b 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Diagnostics; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -10,13 +9,13 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Profile.Header; using osu.Game.Users; @@ -105,11 +104,29 @@ namespace osu.Game.Overlays.Profile Y = -75, Size = new Vector2(25, 25) }, - new ProfileLink(user) + new FillFlowContainer { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Y = -48, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = user.Username, + Font = @"Exo2.0-RegularItalic", + TextSize = 30, + }, + new ExternalLinkButton($@"https://osu.ppy.sh/users/{user.Id}") + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Margin = new MarginPadding { Left = 3, Bottom = 3 }, //To better lineup with the font + Size = new Vector2(18), + }, + } }, countryFlag = new DrawableFlag(user.Country) { @@ -455,28 +472,6 @@ namespace osu.Game.Overlays.Profile infoTextRight.NewLine(); } - private class ProfileLink : OsuHoverContainer, IHasTooltip - { - public string TooltipText => "View Profile in Browser"; - - public override bool HandleMouseInput => true; - - public ProfileLink(User user) - { - Action = () => Process.Start($@"https://osu.ppy.sh/users/{user.Id}"); - - AutoSizeAxes = Axes.Both; - - Child = new OsuSpriteText - { - Text = user.Username, - Font = @"Exo2.0-RegularItalic", - TextSize = 30, - }; - } - } - - private class GradeBadge : Container { private const float width = 50; From 8fbda5bc59a736ca837f33e369812791202f8caf Mon Sep 17 00:00:00 2001 From: jorolf Date: Tue, 22 May 2018 15:41:10 +0200 Subject: [PATCH 055/253] add license header --- osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs | 5 ++++- osu.Game/Graphics/UserInterface/ExternalLinkButton.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs b/osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs index bdb077ce5a..7d8535f428 100644 --- a/osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs +++ b/osu.Game.Tests/Visual/TestCaseExternalLinkButton.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using System.Collections.Generic; using osu.Game.Graphics.UserInterface; using OpenTK; diff --git a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs index 800f77f547..025874a1a2 100644 --- a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs +++ b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs @@ -1,4 +1,7 @@ -using System.Diagnostics; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From 50e2871c89ff774048cc4b58cc91972e35397943 Mon Sep 17 00:00:00 2001 From: Vidalee Date: Tue, 22 May 2018 21:29:41 +0200 Subject: [PATCH 056/253] 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 057/253] 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 058/253] 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 f894d73501d813d1999fb39d73bd193257b4f611 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 23 May 2018 14:36:09 +0900 Subject: [PATCH 059/253] Fix possible MusicController nullref --- osu.Game/Overlays/Music/PlaylistList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 8c8ff89420..966f09975d 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Music private void updateSelectedSet() { foreach (PlaylistItem s in items.Children) - s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value.BeatmapSetInfo.ID; + s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value?.BeatmapSetInfo?.ID; } public string SearchTerm From 28ad5398cc928deb58ec68fbb3d0d24313bec175 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Wed, 23 May 2018 13:46:12 +0800 Subject: [PATCH 060/253] Remove the changes in convert spinner --- osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs index 5f9439534b..9dfe12f25e 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs @@ -8,9 +8,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch /// /// Legacy osu!catch Spinner-type, used for parsing Beatmaps. /// - internal sealed class ConvertSpinner : HitObject, IHasEndTime, IHasXPosition + internal sealed class ConvertSpinner : HitObject, IHasEndTime { - public float X { get; set; } public double EndTime { get; set; } public double Duration => EndTime - StartTime; From fda7025ac3793c575da44ca4620edf1a31d7ddab Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Wed, 23 May 2018 13:47:33 +0800 Subject: [PATCH 061/253] Re-order positionData judgement for correct banana creation --- .../Beatmaps/CatchBeatmapConverter.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs index f40ef67dfb..60671d9383 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs @@ -28,7 +28,20 @@ namespace osu.Game.Rulesets.Catch.Beatmaps var endTime = obj as IHasEndTime; if (positionData == null) + { + if (endTime != null) + { + yield return new BananaShower + { + StartTime = obj.StartTime, + Samples = obj.Samples, + Duration = endTime.Duration, + NewCombo = comboData?.NewCombo ?? false + }; + + } yield break; + } if (curveData != null) { @@ -48,19 +61,6 @@ namespace osu.Game.Rulesets.Catch.Beatmaps yield break; } - if (endTime != null) - { - yield return new BananaShower - { - StartTime = obj.StartTime, - Samples = obj.Samples, - Duration = endTime.Duration, - NewCombo = comboData?.NewCombo ?? false - }; - - yield break; - } - yield return new Fruit { StartTime = obj.StartTime, From 6c0c932c485590545326e05949597ef58c80f0b3 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 23 May 2018 14:56:40 +0900 Subject: [PATCH 062/253] Reorder OsuGameBase methods --- osu.Game/OsuGameBase.cs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 487cb50c9a..5dba68b4c1 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -65,7 +65,8 @@ namespace osu.Game protected override Container Content => content; - public Bindable Beatmap { get; private set; } + public IBindable Beatmap { get; private set; } + private WorkingBeatmap lastBeatmap; private Bindable fpsDisplayVisible; @@ -204,6 +205,17 @@ namespace osu.Game dependencies.Cache(globalBinding); } + protected override void LoadComplete() + { + base.LoadComplete(); + + // TODO: This is temporary until we reimplement the local FPS display. + // It's just to allow end-users to access the framework FPS display without knowing the shortcut key. + fpsDisplayVisible = LocalConfig.GetBindable(OsuSetting.ShowFpsDisplay); + fpsDisplayVisible.ValueChanged += val => { FrameStatisticsMode = val ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; }; + fpsDisplayVisible.TriggerChange(); + } + private void runMigrations() { try @@ -225,19 +237,6 @@ namespace osu.Game } } - private WorkingBeatmap lastBeatmap; - - protected override void LoadComplete() - { - base.LoadComplete(); - - // TODO: This is temporary until we reimplement the local FPS display. - // It's just to allow end-users to access the framework FPS display without knowing the shortcut key. - fpsDisplayVisible = LocalConfig.GetBindable(OsuSetting.ShowFpsDisplay); - fpsDisplayVisible.ValueChanged += val => { FrameStatisticsMode = val ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; }; - fpsDisplayVisible.TriggerChange(); - } - public override void SetHost(GameHost host) { if (LocalConfig == null) From 8004b8af4d465af6c1eddfffdcb1c61dcac79e0b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 23 May 2018 17:37:39 +0900 Subject: [PATCH 063/253] Privatise the OsuGame beatmap, add local beatmap to OsuTestCase --- osu-framework | 2 +- .../UI/Cursor/GameplayCursor.cs | 6 +- .../Visual/TestCaseBeatmapInfoWedge.cs | 20 +++--- .../Visual/TestCaseEditorCompose.cs | 10 +-- .../Visual/TestCaseEditorComposeTimeline.cs | 11 +--- .../Visual/TestCaseEditorSeekSnapping.cs | 4 +- .../Visual/TestCaseEditorSummaryTimeline.cs | 9 +-- .../Visual/TestCaseHitObjectComposer.cs | 4 +- .../Visual/TestCaseMusicController.cs | 13 +--- .../Visual/TestCasePlaySongSelect.cs | 6 +- .../Visual/TestCasePlaybackControl.cs | 2 +- osu.Game.Tests/Visual/TestCasePlayerLoader.cs | 3 +- osu.Game.Tests/Visual/TestCaseReplay.cs | 5 +- osu.Game.Tests/Visual/TestCaseResults.cs | 16 ++--- osu.Game.Tests/Visual/TestCaseStoryboard.cs | 15 ++--- osu.Game.Tests/Visual/TestCaseWaveform.cs | 15 ++--- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 4 +- osu.Game/Beatmaps/GameBeatmap.cs | 26 ++++++++ osu.Game/Beatmaps/IGameBeatmap.cs | 14 ++++ .../Containers/BeatSyncedContainer.cs | 6 +- osu.Game/OsuGameBase.cs | 7 +- osu.Game/Overlays/Music/PlaylistList.cs | 4 +- osu.Game/Overlays/Music/PlaylistOverlay.cs | 26 ++++---- osu.Game/Overlays/MusicController.cs | 33 +++++----- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 6 +- .../Edit/Components/BottomBarContainer.cs | 6 +- .../Timelines/Summary/Parts/TimelinePart.cs | 9 ++- .../Timelines/Summary/SummaryTimeline.cs | 15 ++--- osu.Game/Screens/Edit/Editor.cs | 10 +-- .../Screens/Edit/Screens/Compose/Compose.cs | 5 +- .../Compose/Timeline/BeatmapWaveformGraph.cs | 4 +- .../Compose/Timeline/ScrollableTimeline.cs | 5 -- .../Timeline/ScrollingTimelineContainer.cs | 16 ++++- osu.Game/Screens/Edit/Screens/EditorScreen.cs | 9 ++- osu.Game/Screens/Menu/Intro.cs | 12 ++-- osu.Game/Screens/Menu/LogoVisualisation.cs | 6 +- osu.Game/Screens/Menu/MenuSideFlashes.cs | 6 +- osu.Game/Screens/OsuScreen.cs | 24 ++----- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- .../Play/ScreenWithBeatmapBackground.cs | 2 +- osu.Game/Screens/Ranking/Results.cs | 6 +- osu.Game/Screens/Select/PlaySongSelect.cs | 8 ++- osu.Game/Screens/Select/SongSelect.cs | 16 +++-- .../Drawables/DrawableStoryboardAnimation.cs | 5 +- .../Drawables/DrawableStoryboardSprite.cs | 5 +- osu.Game/Tests/Visual/EditorClockTestCase.cs | 17 +---- osu.Game/Tests/Visual/EditorTestCase.cs | 4 +- osu.Game/Tests/Visual/OsuTestCase.cs | 16 +++++ .../Tests/Visual/TestCasePerformancePoints.cs | 65 ++++++++++--------- osu.Game/Tests/Visual/TestCasePlayer.cs | 14 ++-- 51 files changed, 279 insertions(+), 277 deletions(-) create mode 100644 osu.Game/Beatmaps/GameBeatmap.cs create mode 100644 osu.Game/Beatmaps/IGameBeatmap.cs diff --git a/osu-framework b/osu-framework index eb076a3301..b36db536d9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit eb076a3301231eb73917073499051e49a9b12978 +Subproject commit b36db536d96d75ef1be2d12d14245dcca91f2497 diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index e7f17dd86b..d34ecfac22 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private Bindable cursorScale; private Bindable autoCursorScale; - private Bindable beatmap; + private IBindable beatmap; public OsuCursor() { @@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor } [BackgroundDependencyLoader] - private void load(OsuConfigManager config, OsuGameBase game) + private void load(OsuConfigManager config, IGameBeatmap beatmap) { Child = cursorContainer = new SkinnableDrawable("cursor", _ => new CircularContainer { @@ -160,7 +160,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor RelativeSizeAxes = Axes.Both, }; - beatmap = game.Beatmap.GetBoundCopy(); + this.beatmap = beatmap.GetBoundCopy(); beatmap.ValueChanged += v => calculateScale(); cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize); diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs index 0d3e08154f..328e1ef08e 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs @@ -6,7 +6,6 @@ using System.Linq; using NUnit.Framework; using OpenTK; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; @@ -29,14 +28,11 @@ namespace osu.Game.Tests.Visual private RulesetStore rulesets; private TestBeatmapInfoWedge infoWedge; private readonly List beatmaps = new List(); - private readonly Bindable beatmap = new Bindable(); [BackgroundDependencyLoader] - private void load(OsuGameBase game, RulesetStore rulesets) + private void load(RulesetStore rulesets) { this.rulesets = rulesets; - - beatmap.BindTo(game.Beatmap); } protected override void LoadComplete() @@ -53,11 +49,11 @@ namespace osu.Game.Tests.Visual AddStep("show", () => { infoWedge.State = Visibility.Visible; - infoWedge.UpdateBeatmap(beatmap); + infoWedge.UpdateBeatmap(Beatmap); }); // select part is redundant, but wait for load isn't - selectBeatmap(beatmap.Value.Beatmap); + selectBeatmap(Beatmap.Value.Beatmap); AddWaitStep(3); @@ -120,8 +116,8 @@ namespace osu.Game.Tests.Visual { selectNullBeatmap(); AddAssert("check empty version", () => string.IsNullOrEmpty(infoWedge.Info.VersionLabel.Text)); - AddAssert("check default title", () => infoWedge.Info.TitleLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Title); - AddAssert("check default artist", () => infoWedge.Info.ArtistLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Artist); + AddAssert("check default title", () => infoWedge.Info.TitleLabel.Text == Beatmap.Default.BeatmapInfo.Metadata.Title); + AddAssert("check default artist", () => infoWedge.Info.ArtistLabel.Text == Beatmap.Default.BeatmapInfo.Metadata.Artist); AddAssert("check empty author", () => !infoWedge.Info.MapperContainer.Children.Any()); AddAssert("check no infolabels", () => !infoWedge.Info.InfoLabelContainer.Children.Any()); } @@ -133,7 +129,7 @@ namespace osu.Game.Tests.Visual AddStep($"select {b.Metadata.Title} beatmap", () => { infoBefore = infoWedge.Info; - infoWedge.UpdateBeatmap(beatmap.Value = new TestWorkingBeatmap(b)); + infoWedge.UpdateBeatmap(Beatmap.Value = new TestWorkingBeatmap(b)); }); AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load"); @@ -143,8 +139,8 @@ namespace osu.Game.Tests.Visual { AddStep("select null beatmap", () => { - beatmap.Value = beatmap.Default; - infoWedge.UpdateBeatmap(beatmap); + Beatmap.Value = Beatmap.Default; + infoWedge.UpdateBeatmap(Beatmap); }); } diff --git a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs index 96a754a5ce..e7bcfbf500 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs @@ -17,14 +17,10 @@ namespace osu.Game.Tests.Visual public override IReadOnlyList RequiredTypes => new[] { typeof(Compose) }; [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + private void load() { - osuGame.Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); - - var compose = new Compose(); - compose.Beatmap.BindTo(osuGame.Beatmap); - - Child = compose; + Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); + Child = new Compose(); } } } diff --git a/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs b/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs index a5053bafe8..81b491799b 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorComposeTimeline.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using NUnit.Framework; using OpenTK; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Overlays; @@ -18,8 +17,6 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { typeof(ScrollableTimeline), typeof(ScrollingTimelineContainer), typeof(BeatmapWaveformGraph), typeof(TimelineButton) }; - private readonly ScrollableTimeline timeline; - public TestCaseEditorComposeTimeline() { Children = new Drawable[] @@ -30,7 +27,7 @@ namespace osu.Game.Tests.Visual Origin = Anchor.TopCentre, State = Visibility.Visible }, - timeline = new ScrollableTimeline + new ScrollableTimeline { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -38,11 +35,5 @@ namespace osu.Game.Tests.Visual } }; } - - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) - { - timeline.Beatmap.BindTo(osuGame.Beatmap); - } } } diff --git a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs index f037d70493..94b99d483c 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs @@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + private void load() { var testBeatmap = new Beatmap { @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual } }; - osuGame.Beatmap.Value = new TestWorkingBeatmap(testBeatmap); + Beatmap.Value = new TestWorkingBeatmap(testBeatmap); Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock }; diff --git a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs index d01c2d2b92..cafd1b6f1a 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs @@ -19,19 +19,16 @@ namespace osu.Game.Tests.Visual public override IReadOnlyList RequiredTypes => new[] { typeof(SummaryTimeline) }; [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + private void load() { - osuGame.Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); - SummaryTimeline summaryTimeline; - Add(summaryTimeline = new SummaryTimeline + Add(new SummaryTimeline { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(500, 50) }); - - summaryTimeline.Beatmap.BindTo(osuGame.Beatmap); } } } diff --git a/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs b/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs index d0c46ecdd7..557d976073 100644 --- a/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs +++ b/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs @@ -38,9 +38,9 @@ namespace osu.Game.Tests.Visual => dependencies = new DependencyContainer(parent); [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + private void load() { - osuGame.Beatmap.Value = new TestWorkingBeatmap(new Beatmap + Beatmap.Value = new TestWorkingBeatmap(new Beatmap { HitObjects = new List { diff --git a/osu.Game.Tests/Visual/TestCaseMusicController.cs b/osu.Game.Tests/Visual/TestCaseMusicController.cs index 10c813b2f8..5ba0167f12 100644 --- a/osu.Game.Tests/Visual/TestCaseMusicController.cs +++ b/osu.Game.Tests/Visual/TestCaseMusicController.cs @@ -2,12 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; -using osu.Game.Beatmaps; using osu.Game.Overlays; namespace osu.Game.Tests.Visual @@ -15,8 +12,6 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCaseMusicController : OsuTestCase { - private readonly Bindable beatmapBacking = new Bindable(); - public TestCaseMusicController() { Clock = new FramedClock(); @@ -30,13 +25,7 @@ namespace osu.Game.Tests.Visual AddToggleStep(@"toggle visibility", state => mc.State = state ? Visibility.Visible : Visibility.Hidden); AddStep(@"show", () => mc.State = Visibility.Visible); - AddToggleStep(@"toggle beatmap lock", state => beatmapBacking.Disabled = state); - } - - [BackgroundDependencyLoader] - private void load(OsuGameBase game) - { - beatmapBacking.BindTo(game.Beatmap); + AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state); } } } diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index 8c52360db8..1371db78b5 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(OsuGameBase game) + private void load() { TestSongSelect songSelect = null; @@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual dependencies.Cache(rulesets = new RulesetStore(factory)); dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null, null) { - DefaultBeatmap = defaultBeatmap = game.Beatmap.Default + DefaultBeatmap = defaultBeatmap = Beatmap.Default }); void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () => @@ -78,7 +78,7 @@ namespace osu.Game.Tests.Visual if (deleteMaps) { manager.Delete(manager.GetAllUsableBeatmapSets()); - game.Beatmap.SetDefault(); + Beatmap.SetDefault(); } if (songSelect != null) diff --git a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs index 24ebb534c1..4bed5bb595 100644 --- a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs +++ b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs @@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual Size = new Vector2(200,100) }; - playback.Beatmap.Value = new TestWorkingBeatmap(new Beatmap()); + Beatmap.Value = new TestWorkingBeatmap(new Beatmap()); Child = playback; } diff --git a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs index 1e7618232d..52a9db080d 100644 --- a/osu.Game.Tests/Visual/TestCasePlayerLoader.cs +++ b/osu.Game.Tests/Visual/TestCasePlayerLoader.cs @@ -12,9 +12,10 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load(OsuGameBase game) { + Beatmap.Value = new DummyWorkingBeatmap(game); + AddStep("load dummy beatmap", () => Add(new PlayerLoader(new Player { - InitialBeatmap = new DummyWorkingBeatmap(game), AllowPause = false, AllowLeadIn = false, AllowResults = false, diff --git a/osu.Game.Tests/Visual/TestCaseReplay.cs b/osu.Game.Tests/Visual/TestCaseReplay.cs index 5bc16fe420..4bcbc924b8 100644 --- a/osu.Game.Tests/Visual/TestCaseReplay.cs +++ b/osu.Game.Tests/Visual/TestCaseReplay.cs @@ -26,10 +26,7 @@ namespace osu.Game.Tests.Visual // Reset the mods beatmap.Mods.Value = beatmap.Mods.Value.Where(m => !(m is ModAutoplay)); - return new ReplayPlayer(replay) - { - InitialBeatmap = beatmap - }; + return new ReplayPlayer(replay); } } } diff --git a/osu.Game.Tests/Visual/TestCaseResults.cs b/osu.Game.Tests/Visual/TestCaseResults.cs index 35e1db7c9e..ee36fb0afc 100644 --- a/osu.Game.Tests/Visual/TestCaseResults.cs +++ b/osu.Game.Tests/Visual/TestCaseResults.cs @@ -32,18 +32,13 @@ namespace osu.Game.Tests.Visual this.beatmaps = beatmaps; } - private WorkingBeatmap beatmap; - protected override void LoadComplete() { base.LoadComplete(); - if (beatmap == null) - { - var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0); - if (beatmapInfo != null) - beatmap = beatmaps.GetWorkingBeatmap(beatmapInfo); - } + var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0); + if (beatmapInfo != null) + Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo); Add(new Results(new Score { @@ -63,10 +58,7 @@ namespace osu.Game.Tests.Visual { Username = "peppy", } - }) - { - InitialBeatmap = beatmap - }); + })); } } } diff --git a/osu.Game.Tests/Visual/TestCaseStoryboard.cs b/osu.Game.Tests/Visual/TestCaseStoryboard.cs index e721c5ced0..b63881ffa7 100644 --- a/osu.Game.Tests/Visual/TestCaseStoryboard.cs +++ b/osu.Game.Tests/Visual/TestCaseStoryboard.cs @@ -3,7 +3,6 @@ using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -18,8 +17,6 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCaseStoryboard : OsuTestCase { - private readonly Bindable beatmapBacking = new Bindable(); - private readonly Container storyboardContainer; private DrawableStoryboard storyboard; @@ -43,6 +40,7 @@ namespace osu.Game.Tests.Visual }, }, }); + Add(new MusicController { Origin = Anchor.TopRight, @@ -55,10 +53,9 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(OsuGameBase game) + private void load() { - beatmapBacking.BindTo(game.Beatmap); - beatmapBacking.ValueChanged += beatmapChanged; + Beatmap.ValueChanged += beatmapChanged; } private void beatmapChanged(WorkingBeatmap working) @@ -66,10 +63,10 @@ namespace osu.Game.Tests.Visual private void restart() { - var track = beatmapBacking.Value.Track; + var track = Beatmap.Value.Track; track.Reset(); - loadStoryboard(beatmapBacking.Value); + loadStoryboard(Beatmap); track.Start(); } @@ -81,7 +78,7 @@ namespace osu.Game.Tests.Visual var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true }; storyboardContainer.Clock = decoupledClock; - storyboard = working.Storyboard.CreateDrawable(beatmapBacking); + storyboard = working.Storyboard.CreateDrawable(Beatmap); storyboard.Passing = false; storyboardContainer.Add(storyboard); diff --git a/osu.Game.Tests/Visual/TestCaseWaveform.cs b/osu.Game.Tests/Visual/TestCaseWaveform.cs index 776adab0d1..b0966cf5c4 100644 --- a/osu.Game.Tests/Visual/TestCaseWaveform.cs +++ b/osu.Game.Tests/Visual/TestCaseWaveform.cs @@ -5,11 +5,9 @@ using NUnit.Framework; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osu.Game.Screens.Edit.Screens.Compose.Timeline; @@ -19,9 +17,8 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCaseWaveform : OsuTestCase { - private readonly Bindable beatmapBacking = new Bindable(); - - public TestCaseWaveform() + [BackgroundDependencyLoader] + private void load() { FillFlowContainer flow; Child = flow = new FillFlowContainer @@ -46,10 +43,11 @@ namespace osu.Game.Tests.Visual var newDisplay = new BeatmapWaveformGraph { RelativeSizeAxes = Axes.Both, - Resolution = 1f / i + Resolution = 1f / i, + Beatmap = Beatmap }; - newDisplay.Beatmap.BindTo(beatmapBacking); + Beatmap.ValueChanged += b => newDisplay.Beatmap = b; flow.Add(new Container { @@ -83,8 +81,5 @@ namespace osu.Game.Tests.Visual }); } } - - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) => beatmapBacking.BindTo(osuGame.Beatmap); } } diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 8094abe5ed..ee1fc6aec3 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -17,7 +17,7 @@ namespace osu.Game.Beatmaps { private readonly OsuGameBase game; - public DummyWorkingBeatmap(OsuGameBase game) + public DummyWorkingBeatmap(OsuGameBase game = null) : base(new BeatmapInfo { Metadata = new BeatmapMetadata @@ -43,7 +43,7 @@ namespace osu.Game.Beatmaps protected override IBeatmap GetBeatmap() => new Beatmap(); - protected override Texture GetBackground() => game.Textures.Get(@"Backgrounds/bg4"); + protected override Texture GetBackground() => game?.Textures.Get(@"Backgrounds/bg4"); protected override Track GetTrack() => new TrackVirtual(); diff --git a/osu.Game/Beatmaps/GameBeatmap.cs b/osu.Game/Beatmaps/GameBeatmap.cs new file mode 100644 index 0000000000..ac31b16533 --- /dev/null +++ b/osu.Game/Beatmaps/GameBeatmap.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.Configuration; + +namespace osu.Game.Beatmaps +{ + /// + /// A for the beatmap. + /// This should be used sparingly in-favour of . + /// + public class GameBeatmap : NonNullableBindable, IGameBeatmap + { + public GameBeatmap(WorkingBeatmap defaultValue) + : base(defaultValue) + { + } + + public GameBeatmap GetBoundCopy() + { + var copy = new GameBeatmap(Default); + copy.BindTo(this); + return copy; + } + } +} diff --git a/osu.Game/Beatmaps/IGameBeatmap.cs b/osu.Game/Beatmaps/IGameBeatmap.cs new file mode 100644 index 0000000000..89323c953b --- /dev/null +++ b/osu.Game/Beatmaps/IGameBeatmap.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Configuration; + +namespace osu.Game.Beatmaps +{ + /// + /// Read-only interface for the beatmap. + /// + public interface IGameBeatmap : IBindable + { + } +} diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index bf16af4706..92e38033a9 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -12,7 +12,7 @@ namespace osu.Game.Graphics.Containers { public class BeatSyncedContainer : Container { - protected readonly Bindable Beatmap = new Bindable(); + protected readonly IBindable Beatmap = new Bindable(); private int lastBeat; private TimingControlPoint lastTimingPoint; @@ -74,9 +74,9 @@ namespace osu.Game.Graphics.Containers } [BackgroundDependencyLoader] - private void load(OsuGameBase game) + private void load(IGameBeatmap beatmap) { - Beatmap.BindTo(game.Beatmap); + Beatmap.BindTo(beatmap); } protected virtual void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 5dba68b4c1..5546b5bcec 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -65,7 +65,7 @@ namespace osu.Game protected override Container Content => content; - public IBindable Beatmap { get; private set; } + protected GameBeatmap Beatmap; private WorkingBeatmap lastBeatmap; private Bindable fpsDisplayVisible; @@ -158,7 +158,7 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); var defaultBeatmap = new DummyWorkingBeatmap(this); - Beatmap = new NonNullableBindable(defaultBeatmap); + Beatmap = new GameBeatmap(defaultBeatmap); BeatmapManager.DefaultBeatmap = defaultBeatmap; // tracks play so loud our samples can't keep up. @@ -186,6 +186,9 @@ namespace osu.Game lastBeatmap = b; }; + dependencies.Cache(Beatmap); + dependencies.CacheAs(Beatmap); + FileStore.Cleanup(); AddInternal(api); diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 8c8ff89420..27c0b393c6 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -73,13 +73,13 @@ namespace osu.Game.Overlays.Music } [BackgroundDependencyLoader] - private void load(BeatmapManager beatmaps, OsuGameBase osuGame) + private void load(BeatmapManager beatmaps, IGameBeatmap beatmap) { beatmaps.GetAllUsableBeatmapSets().ForEach(addBeatmapSet); beatmaps.ItemAdded += addBeatmapSet; beatmaps.ItemRemoved += removeBeatmapSet; - beatmapBacking.BindTo(osuGame.Beatmap); + beatmapBacking.BindTo(beatmap); beatmapBacking.ValueChanged += _ => updateSelectedSet(); } diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 76c2222f8b..79f2c29c43 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -21,17 +20,22 @@ namespace osu.Game.Overlays.Music private const float transition_duration = 600; private const float playlist_height = 510; + /// + /// Invoked when the order of an item in the list has changed. + /// The second parameter indicates the new index of the item. + /// public Action OrderChanged; + private GameBeatmap beatmap; private BeatmapManager beatmaps; + private FilterControl filter; private PlaylistList list; - private readonly Bindable beatmapBacking = new Bindable(); - [BackgroundDependencyLoader] - private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours) + private void load(OsuColour colours, GameBeatmap beatmap, BeatmapManager beatmaps) { + this.beatmap = beatmap.GetBoundCopy(); this.beatmaps = beatmaps; Children = new Drawable[] @@ -73,13 +77,11 @@ namespace osu.Game.Overlays.Music }, }; - beatmapBacking.BindTo(game.Beatmap); - filter.Search.OnCommit = (sender, newText) => { - BeatmapInfo beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault(); - if (beatmap != null) - beatmapBacking.Value = beatmaps.GetWorkingBeatmap(beatmap); + BeatmapInfo toSelect = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault(); + if (toSelect != null) + beatmap.Value = beatmaps.GetWorkingBeatmap(toSelect); }; } @@ -102,13 +104,13 @@ namespace osu.Game.Overlays.Music private void itemSelected(BeatmapSetInfo set) { - if (set.ID == (beatmapBacking.Value?.BeatmapSetInfo?.ID ?? -1)) + if (set.ID == (beatmap.Value?.BeatmapSetInfo?.ID ?? -1)) { - beatmapBacking.Value?.Track?.Seek(0); + beatmap.Value?.Track?.Seek(0); return; } - beatmapBacking.Value = beatmaps.GetWorkingBeatmap(set.Beatmaps.First()); + beatmap.Value = beatmaps.GetWorkingBeatmap(set.Beatmaps.First()); } } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index fb4e278b0c..733b37cec0 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -30,11 +29,8 @@ namespace osu.Game.Overlays public class MusicController : OsuFocusedOverlayContainer { private const float player_height = 130; - private const float transition_length = 800; - private const float progress_height = 10; - private const float bottom_black_area_height = 55; private Drawable background; @@ -49,16 +45,17 @@ namespace osu.Game.Overlays private PlaylistOverlay playlist; + private BeatmapManager beatmaps; private LocalisationEngine localisation; - private BeatmapManager beatmaps; - private readonly Bindable beatmapBacking = new Bindable(); private List beatmapSets; private BeatmapSetInfo currentSet; private Container dragContainer; private Container playerContainer; + private GameBeatmap beatmap; + public MusicController() { Width = 400; @@ -97,8 +94,9 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation) + private void load(GameBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation) { + this.beatmap = beatmap.GetBoundCopy(); this.beatmaps = beatmaps; this.localisation = localisation; @@ -224,8 +222,6 @@ namespace osu.Game.Overlays beatmaps.ItemAdded += handleBeatmapAdded; beatmaps.ItemRemoved += handleBeatmapRemoved; - beatmapBacking.BindTo(game.Beatmap); - playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); } @@ -240,9 +236,10 @@ namespace osu.Game.Overlays protected override void LoadComplete() { - beatmapBacking.ValueChanged += beatmapChanged; - beatmapBacking.DisabledChanged += beatmapDisabledChanged; - beatmapBacking.TriggerChange(); + beatmap.ValueChanged += beatmapChanged; + beatmap.DisabledChanged += beatmapDisabledChanged; + + beatmapChanged(beatmap.Value); base.LoadComplete(); } @@ -276,7 +273,7 @@ namespace osu.Game.Overlays playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled && beatmapSets.Any()) + if (track.HasCompleted && !track.Looping && !beatmap.Disabled && beatmapSets.Any()) next(); } else @@ -289,7 +286,7 @@ namespace osu.Game.Overlays if (track == null) { - if (!beatmapBacking.Disabled) + if (!beatmap.Disabled) next(true); return; } @@ -307,8 +304,8 @@ namespace osu.Game.Overlays var playable = beatmapSets.TakeWhile(i => i.ID != current.BeatmapSetInfo.ID).LastOrDefault() ?? beatmapSets.LastOrDefault(); if (playable != null) { - beatmapBacking.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmapBacking); - beatmapBacking.Value.Track.Restart(); + beatmap.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value); + beatmap.Value.Track.Restart(); } } @@ -320,8 +317,8 @@ namespace osu.Game.Overlays var playable = beatmapSets.SkipWhile(i => i.ID != current.BeatmapSetInfo.ID).Skip(1).FirstOrDefault() ?? beatmapSets.FirstOrDefault(); if (playable != null) { - beatmapBacking.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmapBacking); - beatmapBacking.Value.Track.Restart(); + beatmap.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value); + beatmap.Value.Track.Restart(); } } diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 5f1b9a6bad..443b4fd756 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Edit private RulesetContainer rulesetContainer; private readonly List layerContainers = new List(); - private readonly Bindable beatmap = new Bindable(); + private readonly IBindable beatmap = new Bindable(); protected HitObjectComposer(Ruleset ruleset) { @@ -38,9 +38,9 @@ namespace osu.Game.Rulesets.Edit } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame, IFrameBasedClock framedClock) + private void load(IGameBeatmap beatmap, IFrameBasedClock framedClock) { - beatmap.BindTo(osuGame.Beatmap); + this.beatmap.BindTo(beatmap); try { diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs index 399f9274a6..e3f5cc7a3c 100644 --- a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs @@ -17,7 +17,7 @@ namespace osu.Game.Screens.Edit.Components private const float corner_radius = 5; private const float contents_padding = 15; - public readonly Bindable Beatmap = new Bindable(); + protected readonly IBindable Beatmap = new Bindable(); protected Track Track => Beatmap.Value.Track; private readonly Drawable background; @@ -42,8 +42,10 @@ namespace osu.Game.Screens.Edit.Components } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(IGameBeatmap beatmap, OsuColour colours) { + Beatmap.BindTo(beatmap); + background.Colour = colours.Gray1; } } diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs index c00e9ac4d5..0aeeef717e 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Allocation; using OpenTK; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -15,7 +16,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts /// public abstract class TimelinePart : CompositeDrawable { - public Bindable Beatmap = new Bindable(); + protected readonly IBindable Beatmap = new Bindable(); private readonly Container timeline; @@ -30,6 +31,12 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts }; } + [BackgroundDependencyLoader] + private void load(IGameBeatmap beatmap) + { + Beatmap.BindTo(beatmap); + } + private void updateRelativeChildSize() { // the track may not be loaded completely (only has a length once it is). diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs index 0301870588..77878288f9 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/SummaryTimeline.cs @@ -20,19 +20,17 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary [BackgroundDependencyLoader] private void load(OsuColour colours, IAdjustableClock adjustableClock) { - TimelinePart markerPart, controlPointPart, bookmarkPart, breakPart; - Children = new Drawable[] { - markerPart = new MarkerPart(adjustableClock) { RelativeSizeAxes = Axes.Both }, - controlPointPart = new ControlPointPart + new MarkerPart(adjustableClock) { RelativeSizeAxes = Axes.Both }, + new ControlPointPart { Anchor = Anchor.Centre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.Both, Height = 0.35f }, - bookmarkPart = new BookmarkPart + new BookmarkPart { Anchor = Anchor.Centre, Origin = Anchor.TopCentre, @@ -67,7 +65,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary }, } }, - breakPart = new BreakPart + new BreakPart { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -75,11 +73,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary Height = 0.25f } }; - - markerPart.Beatmap.BindTo(Beatmap); - controlPointPart.Beatmap.BindTo(Beatmap); - bookmarkPart.Beatmap.BindTo(Beatmap); - breakPart.Beatmap.BindTo(Beatmap); } } } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index b657fe5597..eec7a29823 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -128,9 +128,9 @@ namespace osu.Game.Screens.Edit { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = 10 }, - Child = timeInfo = new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, + Child = new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, }, - timeline = new SummaryTimeline + new SummaryTimeline { RelativeSizeAxes = Axes.Both, }, @@ -138,7 +138,7 @@ namespace osu.Game.Screens.Edit { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 10 }, - Child = playback = new PlaybackControl { RelativeSizeAxes = Axes.Both }, + Child = new PlaybackControl { RelativeSizeAxes = Axes.Both }, } }, } @@ -148,9 +148,6 @@ namespace osu.Game.Screens.Edit }, }; - timeInfo.Beatmap.BindTo(Beatmap); - timeline.Beatmap.BindTo(Beatmap); - playback.Beatmap.BindTo(Beatmap); menuBar.Mode.ValueChanged += onModeChanged; bottomBackground.Colour = colours.Gray2; @@ -178,7 +175,6 @@ namespace osu.Game.Screens.Edit break; } - currentScreen.Beatmap.BindTo(Beatmap); LoadComponentAsync(currentScreen, screenContainer.Add); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs index fea4883144..b991f7c2c0 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Compose.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Compose.cs @@ -28,7 +28,6 @@ namespace osu.Game.Screens.Edit.Screens.Compose if (beatDivisor != null) this.beatDivisor.BindTo(beatDivisor); - ScrollableTimeline timeline; Children = new Drawable[] { new GridContainer @@ -65,7 +64,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = 5 }, - Child = timeline = new ScrollableTimeline { RelativeSizeAxes = Axes.Both } + Child = new ScrollableTimeline { RelativeSizeAxes = Axes.Both } }, new BeatDivisorControl(beatDivisor) { RelativeSizeAxes = Axes.Both } }, @@ -94,8 +93,6 @@ namespace osu.Game.Screens.Edit.Screens.Compose }, }; - timeline.Beatmap.BindTo(Beatmap); - var ruleset = Beatmap.Value.BeatmapInfo.Ruleset?.CreateInstance(); if (ruleset == null) { diff --git a/osu.Game/Screens/Edit/Screens/Compose/Timeline/BeatmapWaveformGraph.cs b/osu.Game/Screens/Edit/Screens/Compose/Timeline/BeatmapWaveformGraph.cs index 72dda24b62..136ceb47c4 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Timeline/BeatmapWaveformGraph.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Timeline/BeatmapWaveformGraph.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.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Containers; @@ -11,14 +10,13 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline { public class BeatmapWaveformGraph : CompositeDrawable { - public readonly Bindable Beatmap = new Bindable(); + public WorkingBeatmap Beatmap { set => graph.Waveform = value.Waveform; } private readonly WaveformGraph graph; public BeatmapWaveformGraph() { InternalChild = graph = new WaveformGraph { RelativeSizeAxes = Axes.Both }; - Beatmap.ValueChanged += b => graph.Waveform = b.Waveform; } /// diff --git a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollableTimeline.cs b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollableTimeline.cs index 3223c08c1f..3bebf78b17 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollableTimeline.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollableTimeline.cs @@ -2,11 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; @@ -14,8 +12,6 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline { public class ScrollableTimeline : CompositeDrawable { - public readonly Bindable Beatmap = new Bindable(); - private readonly ScrollingTimelineContainer timelineContainer; public ScrollableTimeline() @@ -117,7 +113,6 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline hitSoundsCheckbox.Current.Value = true; waveformCheckbox.Current.Value = true; - timelineContainer.Beatmap.BindTo(Beatmap); timelineContainer.WaveformVisible.BindTo(waveformCheckbox.Current); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs index 83aa86ba61..80fd83ea4e 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Allocation; using OpenTK; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -17,7 +18,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline public readonly Bindable HitObjectsVisible = new Bindable(); public readonly Bindable HitSoundsVisible = new Bindable(); public readonly Bindable WaveformVisible = new Bindable(); - public readonly Bindable Beatmap = new Bindable(); + + private readonly IBindable beatmap = new Bindable(); private readonly BeatmapWaveformGraph waveform; @@ -36,12 +38,22 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline Content.AutoSizeAxes = Axes.None; Content.RelativeSizeAxes = Axes.Both; - waveform.Beatmap.BindTo(Beatmap); WaveformVisible.ValueChanged += waveformVisibilityChanged; Zoom = 10; } + [BackgroundDependencyLoader] + private void load(IGameBeatmap beatmap) + { + this.beatmap.BindTo(beatmap); + + beatmap.ValueChanged += beatmapChanged; + beatmapChanged(beatmap.Value); + } + + private void beatmapChanged(WorkingBeatmap beatmap) => waveform.Beatmap = beatmap; + private float minZoom = 1; /// /// The minimum zoom level allowed. diff --git a/osu.Game/Screens/Edit/Screens/EditorScreen.cs b/osu.Game/Screens/Edit/Screens/EditorScreen.cs index f70c462cd8..b7c0dee5e3 100644 --- a/osu.Game/Screens/Edit/Screens/EditorScreen.cs +++ b/osu.Game/Screens/Edit/Screens/EditorScreen.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 osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -13,7 +14,7 @@ namespace osu.Game.Screens.Edit.Screens /// public class EditorScreen : Container { - public readonly Bindable Beatmap = new Bindable(); + protected readonly IBindable Beatmap = new Bindable(); protected override Container Content => content; private readonly Container content; @@ -27,6 +28,12 @@ namespace osu.Game.Screens.Edit.Screens InternalChild = content = new Container { RelativeSizeAxes = Axes.Both }; } + [BackgroundDependencyLoader] + private void load(IGameBeatmap beatmap) + { + Beatmap.BindTo(beatmap); + } + protected override void LoadComplete() { base.LoadComplete(); diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index c174e2d470..7caad3d716 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -27,6 +27,8 @@ namespace osu.Game.Screens.Menu /// public bool DidLoadMenu; + private GameBeatmap beatmapBacking; + private MainMenu mainMenu; private SampleChannel welcome; private SampleChannel seeya; @@ -44,8 +46,10 @@ namespace osu.Game.Screens.Menu private WorkingBeatmap beatmap; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game) + private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, GameBeatmap beatmap) { + beatmapBacking = beatmap.GetBoundCopy(); + menuVoice = config.GetBindable(OsuSetting.MenuVoice); menuMusic = config.GetBindable(OsuSetting.MenuMusic); @@ -72,8 +76,8 @@ namespace osu.Game.Screens.Menu } } - beatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); - track = beatmap.Track; + this.beatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); + track = this.beatmap.Track; welcome = audio.Sample.Get(@"welcome"); seeya = audio.Sample.Get(@"seeya"); @@ -83,7 +87,7 @@ namespace osu.Game.Screens.Menu { base.OnEntering(last); - Game.Beatmap.Value = beatmap; + beatmapBacking.Value = beatmap; if (menuVoice) welcome.Play(); diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 1f2cb915b3..9773ca0834 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -21,7 +21,7 @@ namespace osu.Game.Screens.Menu { public class LogoVisualisation : Drawable, IHasAccentColour { - private readonly Bindable beatmap = new Bindable(); + private readonly IBindable beatmap = new Bindable(); /// /// The number of bars to jump each update iteration. @@ -78,9 +78,9 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(ShaderManager shaders, OsuGameBase game) + private void load(ShaderManager shaders, IGameBeatmap beatmap) { - beatmap.BindTo(game.Beatmap); + this.beatmap.BindTo(beatmap); shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED); } diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index fae3e72552..667be7d88d 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu public override bool HandleKeyboardInput => false; public override bool HandleMouseInput => false; - private readonly Bindable beatmap = new Bindable(); + private readonly IBindable beatmap = new Bindable(); private readonly Box leftBox; private readonly Box rightBox; @@ -66,9 +66,9 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(OsuGameBase game, OsuColour colours) + private void load(IGameBeatmap beatmap, OsuColour colours) { - beatmap.BindTo(game.Beatmap); + this.beatmap.BindTo(beatmap); // linear colour looks better in this case, so let's use it for now. Color4 gradientDark = colours.Blue.Opacity(0).ToLinear(); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 4b1562291b..7042c43b70 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.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 System; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -61,36 +60,21 @@ namespace osu.Game.Screens /// public virtual bool AllowBeatmapRulesetChange => true; - protected readonly Bindable Beatmap = new Bindable(); + protected readonly IBindable Beatmap = new Bindable(); protected virtual float BackgroundParallaxAmount => 1; private ParallaxContainer backgroundParallaxContainer; - public WorkingBeatmap InitialBeatmap - { - set - { - if (IsLoaded) throw new InvalidOperationException($"Cannot set {nameof(InitialBeatmap)} post-load."); - Beatmap.Value = value; - } - } - protected readonly Bindable Ruleset = new Bindable(); private SampleChannel sampleExit; [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio) + private void load(IGameBeatmap beatmap, OsuGame osuGame, AudioManager audio) { - if (game != null) - { - //if we were given a beatmap at ctor time, we want to pass this on to the game-wide beatmap. - var localMap = Beatmap.Value; - Beatmap.BindTo(game.Beatmap); - if (localMap != null) - Beatmap.Value = localMap; - } + if (beatmap != null) + Beatmap.BindTo(beatmap); if (osuGame != null) { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 0150d76251..fa6db09c06 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -117,7 +117,7 @@ namespace osu.Game.Screens.Play // let's try again forcing the beatmap's ruleset. ruleset = beatmap.BeatmapInfo.Ruleset; rulesetInstance = ruleset.CreateInstance(); - RulesetContainer = rulesetInstance.CreateRulesetContainerWith(Beatmap); + RulesetContainer = rulesetInstance.CreateRulesetContainerWith(Beatmap.Value); } if (!RulesetContainer.Objects.Any()) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 734837a4f1..cd9d68e50a 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load() { - Add(info = new BeatmapMetadataDisplay(Beatmap) + Add(info = new BeatmapMetadataDisplay(Beatmap.Value) { Alpha = 0, Anchor = Anchor.Centre, diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 1ccc5e2fe8..7f18305b1c 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -13,7 +13,7 @@ namespace osu.Game.Screens.Play { public abstract class ScreenWithBeatmapBackground : OsuScreen { - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); public override bool AllowBeatmapRulesetChange => false; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 32161a0b8e..cd61a692b5 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Ranking private static readonly Vector2 background_blur = new Vector2(20); - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); private const float overscan = 1.3f; @@ -272,10 +272,10 @@ namespace osu.Game.Screens.Ranking switch (mode) { case ResultMode.Summary: - currentPage = new ResultsPageScore(score, Beatmap); + currentPage = new ResultsPageScore(score, Beatmap.Value); break; case ResultMode.Ranking: - currentPage = new ResultsPageRanking(score, Beatmap); + currentPage = new ResultsPageRanking(score, Beatmap.Value); break; } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 7992930c45..f52a06bec0 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -30,6 +30,8 @@ namespace osu.Game.Screens.Select protected readonly BeatmapDetailArea BeatmapDetails; private bool removeAutoModOnResume; + private GameBeatmap beatmap; + public PlaySongSelect() { FooterPanels.Add(modSelect = new ModSelectOverlay @@ -53,8 +55,10 @@ namespace osu.Game.Screens.Select public readonly Bindable> SelectedMods = new Bindable>(new List()); [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu) + private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu, GameBeatmap beatmap) { + this.beatmap = beatmap.GetBoundCopy(); + if (osu != null) SelectedMods.BindTo(osu.SelectedMods); modSelect.SelectedMods.BindTo(SelectedMods); @@ -156,7 +160,7 @@ namespace osu.Game.Screens.Select } Beatmap.Value.Track.Looping = false; - Beatmap.Disabled = true; + beatmap.Disabled = true; sampleConfirm?.Play(); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4ffa9e2a90..11dfe4a3b4 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -65,6 +65,8 @@ namespace osu.Game.Screens.Select private CancellationTokenSource initialAddSetsTask; + private GameBeatmap beatmap; + private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); @@ -179,8 +181,10 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader(permitNulls: true)] - private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours) + private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours, GameBeatmap beatmap) { + this.beatmap = beatmap.GetBoundCopy(); + dependencies.CacheAs(this); if (Footer != null) @@ -212,14 +216,14 @@ namespace osu.Game.Screens.Select Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets(); Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled; - Beatmap.TriggerChange(); - Beatmap.ValueChanged += workingBeatmapChanged; + + workingBeatmapChanged(Beatmap.Value); } public void Edit(BeatmapInfo beatmap) { - Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap); + this.beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value); Push(new Editor()); } @@ -283,7 +287,7 @@ namespace osu.Game.Screens.Select { bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID; - Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap); + this.beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value); ensurePlayingSelected(preview); } @@ -370,7 +374,7 @@ namespace osu.Game.Screens.Select { if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending) { - UpdateBeatmap(Beatmap); + UpdateBeatmap(Beatmap.Value); ensurePlayingSelected(); } diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs index 135b5e2b1e..253902fb81 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Animations; using osu.Framework.Graphics.Textures; using System.Linq; +using osu.Game.Beatmaps; namespace osu.Game.Storyboards.Drawables { @@ -63,14 +64,14 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(OsuGameBase game, TextureStore textureStore) + private void load(IGameBeatmap beatmap, TextureStore textureStore) { var basePath = Animation.Path.ToLowerInvariant(); for (var frame = 0; frame < Animation.FrameCount; frame++) { var framePath = basePath.Replace(".", frame + "."); - var path = game.Beatmap.Value.BeatmapSetInfo.Files.FirstOrDefault(f => f.Filename.ToLowerInvariant() == framePath)?.FileInfo.StoragePath; + var path = beatmap.Value.BeatmapSetInfo.Files.FirstOrDefault(f => f.Filename.ToLowerInvariant() == framePath)?.FileInfo.StoragePath; if (path == null) continue; diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs index 9f22bebcc2..f3fb5e368a 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using System.Linq; +using osu.Game.Beatmaps; namespace osu.Game.Storyboards.Drawables { @@ -62,10 +63,10 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(OsuGameBase game, TextureStore textureStore) + private void load(IGameBeatmap beatmap, TextureStore textureStore) { var spritePath = Sprite.Path.ToLowerInvariant(); - var path = game.Beatmap.Value.BeatmapSetInfo.Files.FirstOrDefault(f => f.Filename.ToLowerInvariant() == spritePath)?.FileInfo.StoragePath; + var path = beatmap.Value.BeatmapSetInfo.Files.FirstOrDefault(f => f.Filename.ToLowerInvariant() == spritePath)?.FileInfo.StoragePath; if (path == null) return; diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index 43b20f7021..ae061ef6db 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -25,24 +25,20 @@ namespace osu.Game.Tests.Visual protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); - private OsuGameBase osuGame; - protected EditorClockTestCase() { Clock = new EditorClock(new ControlPointInfo(), BeatDivisor) { IsCoupled = false }; } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + private void load() { - this.osuGame = osuGame; - dependencies.Cache(BeatDivisor); dependencies.CacheAs(Clock); dependencies.CacheAs(Clock); - osuGame.Beatmap.ValueChanged += beatmapChanged; - beatmapChanged(osuGame.Beatmap.Value); + Beatmap.ValueChanged += beatmapChanged; + beatmapChanged(Beatmap.Value); } private void beatmapChanged(WorkingBeatmap working) @@ -68,12 +64,5 @@ namespace osu.Game.Tests.Visual return true; } - - protected override void Dispose(bool isDisposing) - { - osuGame.Beatmap.ValueChanged -= beatmapChanged; - - base.Dispose(isDisposing); - } } } diff --git a/osu.Game/Tests/Visual/EditorTestCase.cs b/osu.Game/Tests/Visual/EditorTestCase.cs index c0b72f56a4..2ab121fcc9 100644 --- a/osu.Game/Tests/Visual/EditorTestCase.cs +++ b/osu.Game/Tests/Visual/EditorTestCase.cs @@ -23,9 +23,9 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + private void load() { - osuGame.Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo); LoadComponentAsync(new Editor(), LoadScreen); } diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 2b677f1f42..e654b3aab1 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -3,12 +3,28 @@ using System.IO; using System.Reflection; +using osu.Framework.Allocation; using osu.Framework.Testing; +using osu.Game.Beatmaps; namespace osu.Game.Tests.Visual { public abstract class OsuTestCase : TestCase { + protected readonly GameBeatmap Beatmap = new GameBeatmap(new DummyWorkingBeatmap()); + + private DependencyContainer dependencies; + + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) + => dependencies = new DependencyContainer(parent); + + [BackgroundDependencyLoader] + private void load() + { + dependencies.CacheAs(Beatmap); + dependencies.Cache(Beatmap); + } + protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner(); public class OsuTestCaseTestRunner : OsuGameBase, ITestCaseTestRunner diff --git a/osu.Game/Tests/Visual/TestCasePerformancePoints.cs b/osu.Game/Tests/Visual/TestCasePerformancePoints.cs index 51460ecb6d..b6d92f4ec5 100644 --- a/osu.Game/Tests/Visual/TestCasePerformancePoints.cs +++ b/osu.Game/Tests/Visual/TestCasePerformancePoints.cs @@ -50,7 +50,7 @@ namespace osu.Game.Tests.Visual new ScrollContainer { RelativeSizeAxes = Axes.Both, - Child = new BeatmapList(ruleset) + Child = new BeatmapList(ruleset, Beatmap) } } }, @@ -108,10 +108,12 @@ namespace osu.Game.Tests.Visual { private readonly Container beatmapDisplays; private readonly Ruleset ruleset; + private readonly GameBeatmap beatmapBindable; - public BeatmapList(Ruleset ruleset) + public BeatmapList(Ruleset ruleset, GameBeatmap beatmapBindable) { this.ruleset = ruleset; + this.beatmapBindable = beatmapBindable; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -130,7 +132,7 @@ namespace osu.Game.Tests.Visual var sets = beatmaps.GetAllUsableBeatmapSets(); var allBeatmaps = sets.SelectMany(s => s.Beatmaps).Where(b => ruleset.LegacyID == null || b.RulesetID == ruleset.LegacyID); - allBeatmaps.ForEach(b => beatmapDisplays.Add(new BeatmapDisplay(b))); + allBeatmaps.ForEach(b => beatmapDisplays.Add(new BeatmapDisplay(b, beatmapBindable))); } private class BeatmapDisplay : CompositeDrawable, IHasTooltip @@ -138,27 +140,47 @@ namespace osu.Game.Tests.Visual private readonly OsuSpriteText text; private readonly BeatmapInfo beatmap; + private readonly GameBeatmap beatmapBindable; + private BeatmapManager beatmaps; - private OsuGameBase osuGame; private bool isSelected; public string TooltipText => text.Text; - public BeatmapDisplay(BeatmapInfo beatmap) + public BeatmapDisplay(BeatmapInfo beatmap, GameBeatmap beatmapBindable) { this.beatmap = beatmap; + this.beatmapBindable = beatmapBindable; AutoSizeAxes = Axes.Both; InternalChild = text = new OsuSpriteText(); + + this.beatmapBindable.ValueChanged += beatmapChanged; + } + + [BackgroundDependencyLoader] + private void load(BeatmapManager beatmaps) + { + this.beatmaps = beatmaps; + + var working = beatmaps.GetWorkingBeatmap(beatmap); + text.Text = $"{working.Metadata.Artist} - {working.Metadata.Title} ({working.Metadata.AuthorString}) [{working.BeatmapInfo.Version}]"; + } + + private void beatmapChanged(WorkingBeatmap newBeatmap) + { + if (isSelected) + this.FadeColour(Color4.White, 100); + isSelected = false; } protected override bool OnClick(InputState state) { - if (osuGame.Beatmap.Value.BeatmapInfo.ID == beatmap.ID) + if (beatmapBindable.Value.BeatmapInfo.ID == beatmap.ID) return false; - osuGame.Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap); + beatmapBindable.Value = beatmaps.GetWorkingBeatmap(beatmap); isSelected = true; return true; } @@ -177,25 +199,6 @@ namespace osu.Game.Tests.Visual return; this.FadeColour(Color4.White, 100); } - - [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame, BeatmapManager beatmaps) - { - this.osuGame = osuGame; - this.beatmaps = beatmaps; - - var working = beatmaps.GetWorkingBeatmap(beatmap); - text.Text = $"{working.Metadata.Artist} - {working.Metadata.Title} ({working.Metadata.AuthorString}) [{working.BeatmapInfo.Version}]"; - - osuGame.Beatmap.ValueChanged += beatmapChanged; - } - - private void beatmapChanged(WorkingBeatmap newBeatmap) - { - if (isSelected) - this.FadeColour(Color4.White, 100); - isSelected = false; - } } } @@ -204,7 +207,7 @@ namespace osu.Game.Tests.Visual private readonly FillFlowContainer scores; private APIAccess api; - private readonly Bindable currentBeatmap = new Bindable(); + private readonly IBindable currentBeatmap = new Bindable(); public PerformanceList() { @@ -220,7 +223,7 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame, APIAccess api) + private void load(IGameBeatmap beatmap, APIAccess api) { this.api = api; @@ -235,7 +238,7 @@ namespace osu.Game.Tests.Visual } currentBeatmap.ValueChanged += beatmapChanged; - currentBeatmap.BindTo(osuGame.Beatmap); + currentBeatmap.BindTo(beatmap); } private GetScoresRequest lastRequest; @@ -333,9 +336,9 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame) + private void load(IGameBeatmap beatmap) { - osuGame.Beatmap.ValueChanged += beatmapChanged; + beatmap.ValueChanged += beatmapChanged; } private Cached informationCache = new Cached(); diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index bda438d906..04ac62f6cd 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -19,8 +19,6 @@ namespace osu.Game.Tests.Visual protected Player Player; - private TestWorkingBeatmap working; - protected TestCasePlayer(Ruleset ruleset) { this.ruleset = ruleset; @@ -65,13 +63,13 @@ namespace osu.Game.Tests.Visual { var beatmap = CreateBeatmap(r); - working = new TestWorkingBeatmap(beatmap); - working.Mods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) }; + Beatmap.Value = new TestWorkingBeatmap(beatmap); + Beatmap.Value.Mods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) }; if (Player != null) Remove(Player); - var player = CreatePlayer(working, r); + var player = CreatePlayer(Beatmap, r); LoadComponentAsync(player, LoadScreen); @@ -82,14 +80,12 @@ namespace osu.Game.Tests.Visual { base.Update(); - if (working != null) - // note that this will override any mod rate application - working.Track.Rate = Clock.Rate; + // note that this will override any mod rate application + Beatmap.Value.Track.Rate = Clock.Rate; } protected virtual Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) => new Player { - InitialBeatmap = beatmap, AllowPause = false, AllowLeadIn = false, AllowResults = false, From a25462e10fc4d3841bda1edadd955552bbc0262e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 23 May 2018 18:52:09 +0900 Subject: [PATCH 064/253] Fix testcase audio + dependency overrides not working --- osu.Game/Beatmaps/GameBeatmap.cs | 34 ++++++++++++++++++++++++++-- osu.Game/OsuGameBase.cs | 25 +------------------- osu.Game/Tests/Visual/OsuTestCase.cs | 25 ++++++++++++++++---- 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/osu.Game/Beatmaps/GameBeatmap.cs b/osu.Game/Beatmaps/GameBeatmap.cs index ac31b16533..f432fa4a7c 100644 --- a/osu.Game/Beatmaps/GameBeatmap.cs +++ b/osu.Game/Beatmaps/GameBeatmap.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Diagnostics; +using osu.Framework.Audio; using osu.Framework.Configuration; namespace osu.Game.Beatmaps @@ -11,14 +13,42 @@ namespace osu.Game.Beatmaps /// public class GameBeatmap : NonNullableBindable, IGameBeatmap { - public GameBeatmap(WorkingBeatmap defaultValue) + private readonly AudioManager audioManager; + + private WorkingBeatmap lastBeatmap; + + public GameBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) : base(defaultValue) { + this.audioManager = audioManager; + + ValueChanged += registerAudioTrack; + } + + private void registerAudioTrack(WorkingBeatmap beatmap) + { + var trackLoaded = lastBeatmap?.TrackLoaded ?? false; + + // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) + if (!trackLoaded || lastBeatmap?.Track != beatmap.Track) + { + if (trackLoaded) + { + Debug.Assert(lastBeatmap != null); + Debug.Assert(lastBeatmap.Track != null); + + lastBeatmap.RecycleTrack(); + } + + audioManager.Track.AddItem(beatmap.Track); + } + + lastBeatmap = beatmap; } public GameBeatmap GetBoundCopy() { - var copy = new GameBeatmap(Default); + var copy = new GameBeatmap(Default, audioManager); copy.BindTo(this); return copy; } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 5546b5bcec..97f7f5a21e 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -66,7 +65,6 @@ namespace osu.Game protected override Container Content => content; protected GameBeatmap Beatmap; - private WorkingBeatmap lastBeatmap; private Bindable fpsDisplayVisible; @@ -158,34 +156,13 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); var defaultBeatmap = new DummyWorkingBeatmap(this); - Beatmap = new GameBeatmap(defaultBeatmap); + Beatmap = new GameBeatmap(defaultBeatmap, Audio); BeatmapManager.DefaultBeatmap = defaultBeatmap; // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); - Beatmap.ValueChanged += b => - { - var trackLoaded = lastBeatmap?.TrackLoaded ?? false; - - // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) - if (!trackLoaded || lastBeatmap?.Track != b.Track) - { - if (trackLoaded) - { - Debug.Assert(lastBeatmap != null); - Debug.Assert(lastBeatmap.Track != null); - - lastBeatmap.RecycleTrack(); - } - - Audio.Track.AddItem(b.Track); - } - - lastBeatmap = b; - }; - dependencies.Cache(Beatmap); dependencies.CacheAs(Beatmap); diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index e654b3aab1..e6d3407c42 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -4,6 +4,7 @@ using System.IO; using System.Reflection; using osu.Framework.Allocation; +using osu.Framework.Audio; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -11,18 +12,32 @@ namespace osu.Game.Tests.Visual { public abstract class OsuTestCase : TestCase { - protected readonly GameBeatmap Beatmap = new GameBeatmap(new DummyWorkingBeatmap()); + protected GameBeatmap Beatmap { get; private set; } private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(parent); - - [BackgroundDependencyLoader] - private void load() { + // The beatmap is constructed here rather than load() because our children get dependencies injected before our load() runs + Beatmap = new GameBeatmap(new DummyWorkingBeatmap(), parent.Get()); + + dependencies = new DependencyContainer(parent); + dependencies.CacheAs(Beatmap); dependencies.Cache(Beatmap); + + return dependencies; + } + + public override void Cleanup() + { + base.Cleanup(); + + if (Beatmap != null) + { + Beatmap.Disabled = true; + Beatmap.Value.Track.Stop(); + } } protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner(); From a5d2d744479c39d9d8bcfb8a04d0888419993eb8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 23 May 2018 19:01:27 +0900 Subject: [PATCH 065/253] Remove whitespace --- osu.Game/Screens/Edit/Components/BottomBarContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs index e3f5cc7a3c..81a5b24483 100644 --- a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs @@ -45,7 +45,6 @@ namespace osu.Game.Screens.Edit.Components private void load(IGameBeatmap beatmap, OsuColour colours) { Beatmap.BindTo(beatmap); - background.Colour = colours.Gray1; } } From fb78854485072b1a919c8a4318b261a799349286 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 23 May 2018 19:41:13 +0900 Subject: [PATCH 066/253] Fix audio playback getting paused if playlist changes beatmap --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 76c2222f8b..085a44ecba 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -79,7 +79,10 @@ namespace osu.Game.Overlays.Music { BeatmapInfo beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault(); if (beatmap != null) + { beatmapBacking.Value = beatmaps.GetWorkingBeatmap(beatmap); + beatmapBacking.Value.Track.Restart(); + } }; } @@ -109,6 +112,7 @@ namespace osu.Game.Overlays.Music } beatmapBacking.Value = beatmaps.GetWorkingBeatmap(set.Beatmaps.First()); + beatmapBacking.Value.Track.Restart(); } } From 542eb848b0ae6e56b056f6d75dab6f8f390fb4b6 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 24 May 2018 12:42:58 +0900 Subject: [PATCH 067/253] Fix GetBoundCopy on IGameBeatmap not working --- osu.Game/Beatmaps/GameBeatmap.cs | 8 +++++++- osu.Game/Beatmaps/IGameBeatmap.cs | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/GameBeatmap.cs b/osu.Game/Beatmaps/GameBeatmap.cs index f432fa4a7c..0b92fda7b7 100644 --- a/osu.Game/Beatmaps/GameBeatmap.cs +++ b/osu.Game/Beatmaps/GameBeatmap.cs @@ -46,7 +46,13 @@ namespace osu.Game.Beatmaps lastBeatmap = beatmap; } - public GameBeatmap GetBoundCopy() + IGameBeatmap IGameBeatmap.GetBoundCopy() => GetBoundCopy(); + + /// + /// Retrieve a new instance weakly bound to this . + /// If you are further binding to events of the retrieved , ensure a local reference is held. + /// + public new GameBeatmap GetBoundCopy() { var copy = new GameBeatmap(Default, audioManager); copy.BindTo(this); diff --git a/osu.Game/Beatmaps/IGameBeatmap.cs b/osu.Game/Beatmaps/IGameBeatmap.cs index 89323c953b..b2840f1c7e 100644 --- a/osu.Game/Beatmaps/IGameBeatmap.cs +++ b/osu.Game/Beatmaps/IGameBeatmap.cs @@ -10,5 +10,10 @@ namespace osu.Game.Beatmaps /// public interface IGameBeatmap : IBindable { + /// + /// Retrieve a new instance weakly bound to this . + /// If you are further binding to events of the retrieved , ensure a local reference is held. + /// + IGameBeatmap GetBoundCopy(); } } From 5a517bad630fd47f617358101548580cbe499f4f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 24 May 2018 12:53:32 +0900 Subject: [PATCH 068/253] Move beatmap cleanup to Dispose() --- osu.Game/Tests/Visual/OsuTestCase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index e6d3407c42..06481fc89f 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -29,9 +29,9 @@ namespace osu.Game.Tests.Visual return dependencies; } - public override void Cleanup() + protected override void Dispose(bool isDisposing) { - base.Cleanup(); + base.Dispose(isDisposing); if (Beatmap != null) { From f1ac84d95bbd15d87cf518c18500185ff1c88c2c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 24 May 2018 13:03:25 +0900 Subject: [PATCH 069/253] Fix base.CreateLocalDependencies sometimes not being called --- osu.Game.Tests/Visual/TestCaseChatLink.cs | 3 ++- osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs | 2 +- osu.Game.Tests/Visual/TestCasePlaySongSelect.cs | 3 ++- osu.Game.Tests/Visual/TestCasePlaybackControl.cs | 2 +- osu.Game.Tests/Visual/TestCaseSettings.cs | 3 ++- osu.Game/Screens/Edit/Editor.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 3 ++- osu.Game/Tests/Visual/EditorClockTestCase.cs | 2 +- osu.Game/Tests/Visual/OsuTestCase.cs | 2 +- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseChatLink.cs b/osu.Game.Tests/Visual/TestCaseChatLink.cs index 89b1c52010..608691cdf6 100644 --- a/osu.Game.Tests/Visual/TestCaseChatLink.cs +++ b/osu.Game.Tests/Visual/TestCaseChatLink.cs @@ -36,7 +36,8 @@ namespace osu.Game.Tests.Visual }; private DependencyContainer dependencies; - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); public TestCaseChatLink() { diff --git a/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs b/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs index 557d976073..0658de6576 100644 --- a/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs +++ b/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs @@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(parent); + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); [BackgroundDependencyLoader] private void load() diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index 1371db78b5..b90e6c1ca7 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -48,7 +48,8 @@ namespace osu.Game.Tests.Visual typeof(DrawableCarouselBeatmapSet), }; - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); private class TestSongSelect : PlaySongSelect { diff --git a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs index 4bed5bb595..5c0c0cb220 100644 --- a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs +++ b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs @@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(parent); + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); [BackgroundDependencyLoader] private void load() diff --git a/osu.Game.Tests/Visual/TestCaseSettings.cs b/osu.Game.Tests/Visual/TestCaseSettings.cs index 5dad48c6d7..91dd35e148 100644 --- a/osu.Game.Tests/Visual/TestCaseSettings.cs +++ b/osu.Game.Tests/Visual/TestCaseSettings.cs @@ -16,7 +16,8 @@ namespace osu.Game.Tests.Visual private DependencyContainer dependencies; - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); public TestCaseSettings() { diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index eec7a29823..f1d244f2de 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(parent); + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); [BackgroundDependencyLoader] private void load(OsuColour colours) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 11dfe4a3b4..16b6a855f7 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -68,7 +68,8 @@ namespace osu.Game.Screens.Select private GameBeatmap beatmap; private DependencyContainer dependencies; - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); protected SongSelect() { diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index ae061ef6db..0fe00d4ff3 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(parent); + => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); protected EditorClockTestCase() { diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 06481fc89f..c337563920 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual // The beatmap is constructed here rather than load() because our children get dependencies injected before our load() runs Beatmap = new GameBeatmap(new DummyWorkingBeatmap(), parent.Get()); - dependencies = new DependencyContainer(parent); + dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); dependencies.CacheAs(Beatmap); dependencies.Cache(Beatmap); From 3d1f0e50ed76573276a767c2feb54cf18c539e14 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 10:54:53 +0900 Subject: [PATCH 070/253] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index b36db536d9..2893a3ec94 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b36db536d96d75ef1be2d12d14245dcca91f2497 +Subproject commit 2893a3ec94b403bc11295fd435af0431dbe23b7a From 568d4882c681b187d80e4bba3b99d0b00abeaaae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 11:00:56 +0900 Subject: [PATCH 071/253] Remove unnecessary null coalesce --- osu.Game/Overlays/Music/PlaylistList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 966f09975d..d4bc8c5b27 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Music private void updateSelectedSet() { foreach (PlaylistItem s in items.Children) - s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value?.BeatmapSetInfo?.ID; + s.Selected = s.BeatmapSetInfo.ID == beatmapBacking.Value.BeatmapSetInfo?.ID; } public string SearchTerm From 5e4f83b80b158cdf0ddadd60db430a0fc1d83a15 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 17:29:52 +0900 Subject: [PATCH 072/253] Add more correct catch playfield sizing --- osu.Game.Rulesets.Catch/UI/CatchRulesetContainer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Catch/UI/CatchRulesetContainer.cs b/osu.Game.Rulesets.Catch/UI/CatchRulesetContainer.cs index 070dc19a6f..52763e09af 100644 --- a/osu.Game.Rulesets.Catch/UI/CatchRulesetContainer.cs +++ b/osu.Game.Rulesets.Catch/UI/CatchRulesetContainer.cs @@ -32,6 +32,8 @@ namespace osu.Game.Rulesets.Catch.UI public override PassThroughInputManager CreateInputManager() => new CatchInputManager(Ruleset.RulesetInfo); + protected override Vector2 PlayfieldArea => new Vector2(0.86f); // matches stable's vertical offset for catcher plate + protected override DrawableHitObject GetVisualRepresentation(CatchHitObject h) { switch (h) From 3fe25fe67d67d17eb5f0f6bca374317e97a17c96 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 17:32:07 +0900 Subject: [PATCH 073/253] Fix catcher sizing to (roughly) match stable --- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 34 ++++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 181536a91e..59d5ecd07f 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Catch.UI { public class CatcherArea : Container { - public const float CATCHER_SIZE = 172; + public const float CATCHER_SIZE = 84; protected readonly Catcher MovableCatcher; @@ -99,8 +99,6 @@ namespace osu.Game.Rulesets.Catch.UI public class Catcher : Container, IKeyBindingHandler { - private Texture texture; - private Container caughtFruit; public Container ExplodingFruitTarget; @@ -121,10 +119,8 @@ namespace osu.Game.Rulesets.Catch.UI } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private void load() { - texture = textures.Get(@"Play/Catch/fruit-catcher-idle"); - Children = new Drawable[] { caughtFruit = new Container @@ -196,13 +192,7 @@ namespace osu.Game.Rulesets.Catch.UI Scheduler.AddDelayed(beginTrail, HyperDashing ? 25 : 50); } - private Sprite createCatcherSprite() => new Sprite - { - Size = new Vector2(CATCHER_SIZE), - FillMode = FillMode.Fill, - Texture = texture, - OriginPosition = new Vector2(-3, 10) // temporary until the sprite is aligned correctly. - }; + private Sprite createCatcherSprite() => new CatcherSprite(); /// /// Add a caught fruit to the catcher's stack. @@ -411,6 +401,24 @@ namespace osu.Game.Rulesets.Catch.UI f.Expire(); } } + + private class CatcherSprite : Sprite + { + public CatcherSprite() + { + Size = new Vector2(CATCHER_SIZE); + FillMode = FillMode.Fill; + + // Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling. + OriginPosition = new Vector2(-0.02f, 0.06f) * CATCHER_SIZE; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + Texture = textures.Get(@"Play/Catch/fruit-catcher-idle"); + } + } } } } From bf25e81c945398bbada55b44ebf29413c25363c8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 17:32:22 +0900 Subject: [PATCH 074/253] Make drawable bananas testable --- .../TestCaseCatcherArea.cs | 2 +- .../TestCaseFruitObjects.cs | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestCaseCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestCaseCatcherArea.cs index f239290ed4..5119260c53 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestCaseCatcherArea.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestCaseCatcherArea.cs @@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Catch.Tests Child = catcherArea = new TestCatcherArea(new BeatmapDifficulty { CircleSize = size }) { Anchor = Anchor.CentreLeft, - Origin = Anchor.BottomLeft + Origin = Anchor.TopLeft }, }; } diff --git a/osu.Game.Rulesets.Catch.Tests/TestCaseFruitObjects.cs b/osu.Game.Rulesets.Catch.Tests/TestCaseFruitObjects.cs index 275752523d..e77dd76353 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestCaseFruitObjects.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestCaseFruitObjects.cs @@ -25,6 +25,7 @@ namespace osu.Game.Rulesets.Catch.Tests typeof(DrawableCatchHitObject), typeof(DrawableFruit), typeof(DrawableDroplet), + typeof(BananaShower), typeof(Pulp), }; @@ -53,12 +54,19 @@ namespace osu.Game.Rulesets.Catch.Tests private DrawableFruit createDrawable(int index) { - var fruit = new Fruit - { - StartTime = 1000000000000, - IndexInBeatmap = index, - Scale = 1.5f, - }; + Fruit fruit = index == 5 + ? new BananaShower.Banana + { + StartTime = 1000000000000, + IndexInBeatmap = index, + Scale = 1.5f, + } + : new Fruit + { + StartTime = 1000000000000, + IndexInBeatmap = index, + Scale = 1.5f, + }; return new DrawableFruit(fruit) { From f5ab93a712933f6540c852aa8cda691470221e98 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 17:33:05 +0900 Subject: [PATCH 075/253] Make all drawable fruit absolute values easily scalable --- .../Objects/Drawable/DrawableFruit.cs | 41 +++++++++---------- .../Objects/Drawable/Pieces/Pulp.cs | 24 +++++++---- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs index 41792b10a4..4603148114 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs @@ -18,12 +18,19 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { private Circle border; + private const float drawable_radius = (float)CatchHitObject.OBJECT_RADIUS * radius_adjust; + + /// + /// Because we're adding a border around the fruit, we need to scale down some. + /// + private const float radius_adjust = 1.1f; + public DrawableFruit(Fruit h) : base(h) { Origin = Anchor.Centre; - Size = new Vector2((float)CatchHitObject.OBJECT_RADIUS); + Size = new Vector2(drawable_radius); Masking = false; Rotation = (float)(RNG.NextDouble() - 0.5f) * 40; @@ -44,14 +51,14 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { Hollow = !HitObject.HyperDash, Type = EdgeEffectType.Glow, - Radius = 4, + Radius = 4 * radius_adjust, Colour = HitObject.HyperDash ? Color4.Red : AccentColour.Darken(1).Opacity(0.6f) }, - Size = new Vector2(Height * 1.5f), + Size = new Vector2(Height), Anchor = Anchor.Centre, Origin = Anchor.Centre, BorderColour = Color4.White, - BorderThickness = 4f, + BorderThickness = 3f * radius_adjust, Children = new Framework.Graphics.Drawable[] { new Box @@ -82,8 +89,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable private Framework.Graphics.Drawable createPulp(FruitVisualRepresentation representation) { - const float large_pulp_3 = 13f; - const float distance_from_centre_3 = 0.23f; + const float large_pulp_3 = 8f * radius_adjust; + const float distance_from_centre_3 = 0.15f; const float large_pulp_4 = large_pulp_3 * 0.925f; const float distance_from_centre_4 = distance_from_centre_3 / 0.925f; @@ -106,11 +113,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { new Pulp { - Anchor = Anchor.TopCentre, - Origin = Anchor.BottomCentre, AccentColour = AccentColour, Size = new Vector2(small_pulp), - Y = 0.05f, + Y = -0.34f, }, new Pulp { @@ -146,11 +151,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { new Pulp { - Anchor = Anchor.TopCentre, - Origin = Anchor.BottomCentre, AccentColour = AccentColour, Size = new Vector2(small_pulp), - Y = 0.1f, + Y = -0.3f, }, new Pulp { @@ -186,11 +189,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { new Pulp { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, AccentColour = AccentColour, Size = new Vector2(small_pulp), - Y = -0.1f, + Y = -0.33f, }, new Pulp { @@ -220,10 +221,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { new Pulp { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, AccentColour = AccentColour, Size = new Vector2(small_pulp), + Y = -0.25f, }, new Pulp { @@ -253,16 +253,15 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { new Pulp { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, AccentColour = AccentColour, Size = new Vector2(small_pulp), - Y = -0.15f + Y = -0.3f }, new Pulp { AccentColour = AccentColour, - Size = new Vector2(large_pulp_4 * 1.2f, large_pulp_4 * 3), + Size = new Vector2(large_pulp_4 * 0.8f, large_pulp_4 * 2.5f), + Y = 0.05f, }, } }; diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs index d17a72a165..250dc8c7f1 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/Pieces/Pulp.cs @@ -29,14 +29,24 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable.Pieces set { accentColour = value; - - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Glow, - Radius = 8, - Colour = accentColour.Darken(0.2f).Opacity(0.75f) - }; + if (IsLoaded) updateAccentColour(); } } + + private void updateAccentColour() + { + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Glow, + Radius = Size.X / 2, + Colour = accentColour.Darken(0.2f).Opacity(0.75f) + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + updateAccentColour(); + } } } From 7d06a08c3a3f3da1871cac6108c057afac4b5990 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 17:44:56 +0900 Subject: [PATCH 076/253] Fix quit button test occasionally failing --- osu.Game.Tests/Visual/TestCaseQuitButton.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseQuitButton.cs b/osu.Game.Tests/Visual/TestCaseQuitButton.cs index f0f8d41074..fd0d602ffd 100644 --- a/osu.Game.Tests/Visual/TestCaseQuitButton.cs +++ b/osu.Game.Tests/Visual/TestCaseQuitButton.cs @@ -31,10 +31,6 @@ namespace osu.Game.Tests.Visual var text = quitButton.Children.OfType().First(); - // initial display - AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); - AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible"); - AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(quitButton)); AddUntilStep(() => text.IsPresent && !exitAction, "Text visible"); AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One)); From 1cb7d50407e10b09ded9a4f0ea9ef086488e3efc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 18:51:57 +0900 Subject: [PATCH 077/253] Add and use default size (smaller than before) --- osu.Game/Graphics/UserInterface/ExternalLinkButton.cs | 2 ++ osu.Game/Overlays/BeatmapSet/Header.cs | 1 - osu.Game/Overlays/Profile/ProfileHeader.cs | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs index 025874a1a2..77079894cc 100644 --- a/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs +++ b/osu.Game/Graphics/UserInterface/ExternalLinkButton.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Input; +using OpenTK; using OpenTK.Graphics; namespace osu.Game.Graphics.UserInterface @@ -20,6 +21,7 @@ namespace osu.Game.Graphics.UserInterface public ExternalLinkButton(string link = null) { Link = link; + Size = new Vector2(12); InternalChild = new SpriteIcon { Icon = FontAwesome.fa_external_link, diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 7d07816d11..8833a89479 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -178,7 +178,6 @@ namespace osu.Game.Overlays.BeatmapSet Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Margin = new MarginPadding { Left = 3, Bottom = 4 }, //To better lineup with the font - Size = new Vector2(18), }, } }, diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 1a4a00da2b..067144c26e 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -124,7 +124,6 @@ namespace osu.Game.Overlays.Profile Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Margin = new MarginPadding { Left = 3, Bottom = 3 }, //To better lineup with the font - Size = new Vector2(18), }, } }, From 897767008839c64e56d29d92c4e19cdb85ab962d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 May 2018 19:08:46 +0900 Subject: [PATCH 078/253] Update framework --- osu-framework | 2 +- osu.Game.Tests/Visual/TestCaseQuitButton.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu-framework b/osu-framework index eb076a3301..a191c104b8 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit eb076a3301231eb73917073499051e49a9b12978 +Subproject commit a191c104b8e254e81a1a7bb1c200ccdf02628796 diff --git a/osu.Game.Tests/Visual/TestCaseQuitButton.cs b/osu.Game.Tests/Visual/TestCaseQuitButton.cs index f0f8d41074..c2ddc5fef5 100644 --- a/osu.Game.Tests/Visual/TestCaseQuitButton.cs +++ b/osu.Game.Tests/Visual/TestCaseQuitButton.cs @@ -44,13 +44,13 @@ namespace osu.Game.Tests.Visual { exitAction = false; InputManager.MoveMouseTo(quitButton); - InputManager.ButtonDown(MouseButton.Left); + InputManager.PressButton(MouseButton.Left); }); - AddStep("Early release", () => InputManager.ButtonUp(MouseButton.Left)); + AddStep("Early release", () => InputManager.ReleaseButton(MouseButton.Left)); AddAssert("action not triggered", () => !exitAction); - AddStep("Trigger exit action", () => InputManager.ButtonDown(MouseButton.Left)); + AddStep("Trigger exit action", () => InputManager.PressButton(MouseButton.Left)); AddUntilStep(() => exitAction, $"{nameof(quitButton.Action)} was triggered"); } } From 765a50d00737643039cf2789ad17f9605e0d0723 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 25 May 2018 20:05:53 +0900 Subject: [PATCH 079/253] Remove 0.5 offsets Checked up against DB values + server-side build versions, and these 0.5s don't seem to exist. Brings calculations more in-line with osu!stable. --- .../Difficulty/ManiaPerformanceCalculator.cs | 2 +- .../Difficulty/OsuPerformanceCalculator.cs | 6 +++--- .../Difficulty/TaikoPerformanceCalculator.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs index e6e3028d62..bebe07cdee 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs @@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty private double computeAccuracyValue(double strainValue) { - double hitWindowGreat = (Beatmap.HitObjects.First().HitWindows.Great / 2 - 0.5) / TimeRate; + double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; if (hitWindowGreat <= 0) return 0; diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index ae74f12339..9803ebaf52 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -61,11 +61,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty if (mods.Any(m => !m.Ranked)) return 0; - double hitWindowGreat = (Beatmap.HitObjects.First().HitWindows.Great / 2 - 0.5) / TimeRate; - double preEmpt = BeatmapDifficulty.DifficultyRange(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / TimeRate; + double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; + double preEmpt = (int)BeatmapDifficulty.DifficultyRange(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / TimeRate; realApproachRate = preEmpt > 1200 ? (1800 - preEmpt) / 120 : (1200 - preEmpt) / 150 + 5; - realOverallDifficulty = (80 - 0.5 - hitWindowGreat) / 6; + realOverallDifficulty = (80 - hitWindowGreat) / 6; // Custom multipliers for NoFail and SpunOut. double multiplier = 1.12f; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs index 9c9cd1f0fb..b1d73fc1ff 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs @@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty private double computeAccuracyValue() { - double hitWindowGreat = (Beatmap.HitObjects.First().HitWindows.Great / 2 - 0.5) / TimeRate; + double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; if (hitWindowGreat <= 0) return 0; From 215cc9fba7fedbf46d4c05b86eb677454a6a8e6b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 25 May 2018 20:07:14 +0900 Subject: [PATCH 080/253] Change all performance calculators to use int hitwindows Has a pretty large (>6) effect on pp for some maps. --- .../Difficulty/ManiaPerformanceCalculator.cs | 1 + osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs | 1 + .../Difficulty/TaikoPerformanceCalculator.cs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs index bebe07cdee..e1f5f38da7 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs @@ -105,6 +105,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty private double computeAccuracyValue(double strainValue) { + // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be remoevd in the future double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; if (hitWindowGreat <= 0) return 0; diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index 9803ebaf52..0158af87d8 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -61,6 +61,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty if (mods.Any(m => !m.Ranked)) return 0; + // Todo: These int casts are temporary to achieve 1:1 results with osu!stable, and should be remoevd in the future double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; double preEmpt = (int)BeatmapDifficulty.DifficultyRange(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / TimeRate; diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs index b1d73fc1ff..6b1a25d667 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs @@ -94,7 +94,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty private double computeAccuracyValue() { - double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; + // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be remoevd in the future + double hitWindowGreat = (int)(Beatmap.HitObjects.First().HitWindows.Great / 2) / TimeRate; if (hitWindowGreat <= 0) return 0; From e2d840c2dea4c880924c5cc3bfa3a71a858c801a Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 25 May 2018 21:13:40 +0200 Subject: [PATCH 081/253] Rename CursorOverrideContainer to MenuCursorContainer --- osu.Game.Tests/Visual/TestCaseCursors.cs | 12 ++++++------ osu.Game/Graphics/Cursor/CursorOverrideContainer.cs | 4 ++-- osu.Game/OsuGame.cs | 6 +++--- osu.Game/OsuGameBase.cs | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseCursors.cs b/osu.Game.Tests/Visual/TestCaseCursors.cs index 977f241f7a..0aa8e9691e 100644 --- a/osu.Game.Tests/Visual/TestCaseCursors.cs +++ b/osu.Game.Tests/Visual/TestCaseCursors.cs @@ -19,12 +19,12 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCaseCursors : ManualInputManagerTestCase { - private readonly CursorOverrideContainer cursorOverrideContainer; + private readonly MenuCursorContainer menuCursorContainer; private readonly CustomCursorBox[] cursorBoxes = new CustomCursorBox[6]; public TestCaseCursors() { - Child = cursorOverrideContainer = new CursorOverrideContainer + Child = menuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both, Children = new[] @@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual AddAssert("Check green cursor at mouse", () => checkAtMouse(cursorBoxes[0].Cursor)); AddStep("Move out", moveOut); AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor)); - AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor)); + AddAssert("Check global cursor visible", () => checkVisible(menuCursorContainer.Cursor)); } /// @@ -112,11 +112,11 @@ namespace osu.Game.Tests.Visual AddStep("Move to purple area", () => InputManager.MoveMouseTo(cursorBoxes[3])); AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor)); AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor)); - AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor)); - AddAssert("Check global cursor at mouse", () => checkAtMouse(cursorOverrideContainer.Cursor)); + AddAssert("Check global cursor visible", () => checkVisible(menuCursorContainer.Cursor)); + AddAssert("Check global cursor at mouse", () => checkAtMouse(menuCursorContainer.Cursor)); AddStep("Move out", moveOut); AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor)); - AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor)); + AddAssert("Check global cursor visible", () => checkVisible(menuCursorContainer.Cursor)); } /// diff --git a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs index 1e56cb6052..5823fad93a 100644 --- a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs +++ b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs @@ -12,7 +12,7 @@ namespace osu.Game.Graphics.Cursor /// /// A container which provides a which can be overridden by hovered s. /// - public class CursorOverrideContainer : Container, IProvideCursor + public class MenuCursorContainer : Container, IProvideCursor { protected override Container Content => content; private readonly Container content; @@ -25,7 +25,7 @@ namespace osu.Game.Graphics.Cursor public CursorContainer Cursor { get; } public bool ProvidingUserCursor => true; - public CursorOverrideContainer() + public MenuCursorContainer() { AddRangeInternal(new Drawable[] { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index ec93b1ae46..a43c1507b6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -212,7 +212,7 @@ namespace osu.Game protected override void LoadComplete() { - // this needs to be cached before base.LoadComplete as it is used by CursorOverrideContainer. + // this needs to be cached before base.LoadComplete as it is used by MenuCursorContainer. dependencies.Cache(screenshotManager = new ScreenshotManager()); base.LoadComplete(); @@ -220,7 +220,7 @@ namespace osu.Game // The next time this is updated is in UpdateAfterChildren, which occurs too late and results // in the cursor being shown for a few frames during the intro. // This prevents the cursor from showing until we have a screen with CursorVisible = true - CursorOverrideContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; + MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; // hook up notifications to components. SkinManager.PostNotification = n => notifications?.Post(n); @@ -548,7 +548,7 @@ namespace osu.Game mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; - CursorOverrideContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; + MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 487cb50c9a..a3a081d6d1 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -57,7 +57,7 @@ namespace osu.Game protected SettingsStore SettingsStore; - protected CursorOverrideContainer CursorOverrideContainer; + protected MenuCursorContainer MenuCursorContainer; protected override string MainResourceFile => @"osu.Game.Resources.dll"; @@ -191,14 +191,14 @@ namespace osu.Game GlobalActionContainer globalBinding; - CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both }; - CursorOverrideContainer.Child = globalBinding = new GlobalActionContainer(this) + MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }; + MenuCursorContainer.Child = globalBinding = new GlobalActionContainer(this) { RelativeSizeAxes = Axes.Both, - Child = content = new OsuTooltipContainer(CursorOverrideContainer.Cursor) { RelativeSizeAxes = Axes.Both } + Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both } }; - base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorOverrideContainer }); + base.Content.Add(new DrawSizePreservingFillContainer { Child = MenuCursorContainer }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); From 63fb9ddec4f7364e41f6ed11e48973ffe1ed70dc Mon Sep 17 00:00:00 2001 From: HoutarouOreki Date: Fri, 25 May 2018 21:20:42 +0200 Subject: [PATCH 082/253] Forgot file name --- .../Cursor/{CursorOverrideContainer.cs => MenuCursorContainer.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename osu.Game/Graphics/Cursor/{CursorOverrideContainer.cs => MenuCursorContainer.cs} (100%) diff --git a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs similarity index 100% rename from osu.Game/Graphics/Cursor/CursorOverrideContainer.cs rename to osu.Game/Graphics/Cursor/MenuCursorContainer.cs From d850e34003b2a7b307c93ae3c692c48aa88fe49c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 26 May 2018 09:25:16 +0900 Subject: [PATCH 083/253] Actually cast to int --- .../Difficulty/ManiaPerformanceCalculator.cs | 2 +- osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs index e1f5f38da7..93652f7610 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs @@ -106,7 +106,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty private double computeAccuracyValue(double strainValue) { // Todo: This int cast is temporary to achieve 1:1 results with osu!stable, and should be remoevd in the future - double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; + double hitWindowGreat = (int)(Beatmap.HitObjects.First().HitWindows.Great / 2) / TimeRate; if (hitWindowGreat <= 0) return 0; diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index 0158af87d8..57cf962fa7 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty return 0; // Todo: These int casts are temporary to achieve 1:1 results with osu!stable, and should be remoevd in the future - double hitWindowGreat = Beatmap.HitObjects.First().HitWindows.Great / 2 / TimeRate; + double hitWindowGreat = (int)(Beatmap.HitObjects.First().HitWindows.Great / 2) / TimeRate; double preEmpt = (int)BeatmapDifficulty.DifficultyRange(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / TimeRate; realApproachRate = preEmpt > 1200 ? (1800 - preEmpt) / 120 : (1200 - preEmpt) / 150 + 5; From 8b2a6b8ccefd62aa32e399a5ace23c26917af793 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 26 May 2018 12:38:33 +0900 Subject: [PATCH 084/253] Fix formatting --- osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs index 60671d9383..ad500606ed 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs @@ -38,8 +38,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps Duration = endTime.Duration, NewCombo = comboData?.NewCombo ?? false }; - } + yield break; } From 975ce82177f819a4dfdf1656f1b28ae90862a97e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 26 May 2018 14:46:05 +0900 Subject: [PATCH 085/253] Ensure autoplay tests actually increase score above zero --- osu.Game.Tests/Visual/TestCaseAutoplay.cs | 16 +++++++++++++++- osu.Game/Screens/Play/Player.cs | 18 +++++++++--------- osu.Game/Tests/Visual/TestCasePlayer.cs | 6 ++++-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseAutoplay.cs b/osu.Game.Tests/Visual/TestCaseAutoplay.cs index cecb327b6c..bf7aa725e5 100644 --- a/osu.Game.Tests/Visual/TestCaseAutoplay.cs +++ b/osu.Game.Tests/Visual/TestCaseAutoplay.cs @@ -5,6 +5,7 @@ using System.ComponentModel; using System.Linq; using osu.Game.Beatmaps; using osu.Game.Rulesets; +using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; namespace osu.Game.Tests.Visual @@ -15,7 +16,20 @@ namespace osu.Game.Tests.Visual protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) { beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); - return base.CreatePlayer(beatmap, ruleset); + return new ScoreAccessiblePlayer + { + InitialBeatmap = beatmap, + AllowPause = false, + AllowLeadIn = false, + AllowResults = false, + }; + } + + protected override bool ContinueCondition(Player player) => base.ContinueCondition(player) && ((ScoreAccessiblePlayer)player).ScoreProcessor.TotalScore > 0; + + private class ScoreAccessiblePlayer : Player + { + public new ScoreProcessor ScoreProcessor => base.ScoreProcessor; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 0150d76251..9985a24cab 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -70,7 +70,7 @@ namespace osu.Game.Screens.Play private SampleChannel sampleRestart; - private ScoreProcessor scoreProcessor; + protected ScoreProcessor ScoreProcessor; protected RulesetContainer RulesetContainer; private HUDOverlay hudOverlay; @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Play userAudioOffset.ValueChanged += v => offsetClock.Offset = v; userAudioOffset.TriggerChange(); - scoreProcessor = RulesetContainer.CreateScoreProcessor(); + ScoreProcessor = RulesetContainer.CreateScoreProcessor(); Children = new Drawable[] { @@ -176,7 +176,7 @@ namespace osu.Game.Screens.Play RelativeSizeAxes = Axes.Both, Child = RulesetContainer }, - new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks, scoreProcessor) + new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -184,7 +184,7 @@ namespace osu.Game.Screens.Play Breaks = beatmap.Breaks }, RulesetContainer.Cursor?.CreateProxy() ?? new Container(), - hudOverlay = new HUDOverlay(scoreProcessor, RulesetContainer, working, offsetClock, adjustableClock) + hudOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working, offsetClock, adjustableClock) { Clock = Clock, // hud overlay doesn't want to use the audio clock directly ProcessCustomClock = false, @@ -225,11 +225,11 @@ namespace osu.Game.Screens.Play initializeStoryboard(false); // Bind ScoreProcessor to ourselves - scoreProcessor.AllJudged += onCompletion; - scoreProcessor.Failed += onFail; + ScoreProcessor.AllJudged += onCompletion; + ScoreProcessor.Failed += onFail; foreach (var mod in Beatmap.Value.Mods.Value.OfType()) - mod.ApplyToScoreProcessor(scoreProcessor); + mod.ApplyToScoreProcessor(ScoreProcessor); } private void applyRateFromMods() @@ -254,7 +254,7 @@ namespace osu.Game.Screens.Play private void onCompletion() { // Only show the completion screen if the player hasn't failed - if (scoreProcessor.HasFailed || onCompletionEvent != null) + if (ScoreProcessor.HasFailed || onCompletionEvent != null) return; ValidForResume = false; @@ -272,7 +272,7 @@ namespace osu.Game.Screens.Play Beatmap = Beatmap.Value.BeatmapInfo, Ruleset = ruleset }; - scoreProcessor.PopulateScore(score); + ScoreProcessor.PopulateScore(score); score.User = RulesetContainer.Replay?.User ?? api.LocalUser.Value; Push(new Results(score)); }); diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index bda438d906..bf6236e4d5 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual { Player p = null; AddStep(ruleset.RulesetInfo.Name, () => p = loadPlayerFor(ruleset)); - AddUntilStep(() => p.IsLoaded); + AddUntilStep(() => ContinueCondition(p)); } else { @@ -52,11 +52,13 @@ namespace osu.Game.Tests.Visual { Player p = null; AddStep(r.Name, () => p = loadPlayerFor(r)); - AddUntilStep(() => p.IsLoaded); + AddUntilStep(() => ContinueCondition(p)); } } } + protected virtual bool ContinueCondition(Player player) => player.IsLoaded; + protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo); private Player loadPlayerFor(RulesetInfo ri) => loadPlayerFor(ri.CreateInstance()); From 95315e46f06dfc70acebf3cce07f03b166128150 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 27 May 2018 14:12:20 +0900 Subject: [PATCH 086/253] Make drawable rooms fade in when first displayed Stops filtered rooms from briefly displaying. --- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index d11d4a4795..8e93fda68f 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -297,6 +297,12 @@ namespace osu.Game.Screens.Multi.Components participantsBind.BindTo(Room.Participants); } + protected override void LoadComplete() + { + base.LoadComplete(); + this.FadeInFromZero(transition_duration); + } + protected override bool OnClick(InputState state) { if (Enabled.Value) From 4f0d7bd63ef09798dcbd6aa9ff59cae9533166a1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 27 May 2018 15:14:25 +0900 Subject: [PATCH 087/253] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index a191c104b8..84fdfc77a8 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a191c104b8e254e81a1a7bb1c200ccdf02628796 +Subproject commit 84fdfc77a86d581638e69f5e8061c118de4b30f9 From 8ae2a3696f84c2b535542c5066909eb49d5b0a2f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 28 May 2018 03:00:21 +0900 Subject: [PATCH 088/253] Apply platform universal offset at player level --- osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs | 11 ++--------- osu.Game/Screens/Play/Player.cs | 7 ++++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs index 2aee419d20..a83ac26fb3 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs @@ -8,7 +8,6 @@ using System.Linq; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Objects.Legacy; using osu.Game.Beatmaps.ControlPoints; -using osu.Framework; namespace osu.Game.Beatmaps.Formats { @@ -28,23 +27,17 @@ namespace osu.Game.Beatmaps.Formats AddDecoder(@"osu file format v", m => new LegacyBeatmapDecoder(int.Parse(m.Split('v').Last()))); } - /// - /// lazer's audio timings in general doesn't match stable. this is the result of user testing, albeit limited. - /// This only seems to be required on windows. We need to eventually figure out why, with a bit of luck. - /// - public static int UniversalOffset => RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? -22 : 0; - /// /// Whether or not beatmap or runtime offsets should be applied. Defaults on; only disable for testing purposes. /// public bool ApplyOffsets = true; - private readonly int offset = UniversalOffset; + private readonly int offset; public LegacyBeatmapDecoder(int version = LATEST_VERSION) : base(version) { // BeatmapVersion 4 and lower had an incorrect offset (stable has this set as 24ms off) - offset += FormatVersion < 5 ? 24 : 0; + offset = FormatVersion < 5 ? 24 : 0; } protected override void ParseStreamInto(StreamReader stream, Beatmap beatmap) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 9985a24cab..328a4021aa 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -143,8 +144,12 @@ namespace osu.Game.Screens.Play adjustableClock.ProcessFrame(); + // Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited. + // This only seems to be required on windows. We need to eventually figure out why, with a bit of luck. + var offsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0 }; + // the final usable gameplay clock with user-set offsets applied. - var offsetClock = new FramedOffsetClock(adjustableClock); + offsetClock = new FramedOffsetClock(offsetClock); userAudioOffset.ValueChanged += v => offsetClock.Offset = v; userAudioOffset.TriggerChange(); From 3abfd4711dcc8b58bce7f6bab5e7755e4b9145c5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 28 May 2018 03:34:58 +0900 Subject: [PATCH 089/253] Fix wrong clock being seeked when unpausing --- osu.Game/Screens/Play/PauseContainer.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index bd334ad2e2..6262f71ddc 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -44,13 +44,18 @@ namespace osu.Game.Screens.Play public Action OnResume; public Action OnPause; - private readonly IAdjustableClock adjustableClock; private readonly FramedClock framedClock; + private readonly DecoupleableInterpolatingFramedClock decoupledClock; - public PauseContainer(FramedClock framedClock, IAdjustableClock adjustableClock) + /// + /// Creates a new . + /// + /// The gameplay clock. This is the clock that will process frames. + /// The seekable clock. This is the clock that will be paused and resumed. + public PauseContainer(FramedClock framedClock, DecoupleableInterpolatingFramedClock decoupledClock) { this.framedClock = framedClock; - this.adjustableClock = adjustableClock; + this.decoupledClock = decoupledClock; RelativeSizeAxes = Axes.Both; @@ -80,7 +85,7 @@ namespace osu.Game.Screens.Play if (IsPaused) return; // stop the seekable clock (stops the audio eventually) - adjustableClock.Stop(); + decoupledClock.Stop(); IsPaused = true; OnPause?.Invoke(); @@ -97,10 +102,10 @@ namespace osu.Game.Screens.Play IsResuming = false; lastPauseActionTime = Time.Current; - // seek back to the time of the framed clock. - // this accounts for the audio clock potentially taking time to enter a completely stopped state. - adjustableClock.Seek(framedClock.CurrentTime); - adjustableClock.Start(); + // Seeking the decoupled clock to its current time ensures that its source clock will be seeked to the same time + // This accounts for the audio clock source potentially taking time to enter a completely stopped state + decoupledClock.Seek(decoupledClock.CurrentTime); + decoupledClock.Start(); OnResume?.Invoke(); pauseOverlay.Hide(); From b267ec3178aa07109d940559538c451629846fa4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 28 May 2018 03:48:09 +0900 Subject: [PATCH 090/253] Fix failing test --- osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs index c6863d1cb5..f9b055ed55 100644 --- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs @@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); Assert.AreEqual("Deif", meta.AuthorString); Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile); - Assert.AreEqual(164471 + LegacyBeatmapDecoder.UniversalOffset, meta.PreviewTime); + Assert.AreEqual(164471, meta.PreviewTime); Assert.AreEqual(string.Empty, meta.Source); Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags); Assert.AreEqual("Renatus", meta.Title); From 0ca6d73f0ec7d43773b404d66666cd89c77657e0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 12:28:11 +0900 Subject: [PATCH 091/253] Add a delay before the osu! logo appears when exiting multiplayer --- osu.Game/Screens/Multi/Multiplayer.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index ddaeb26806..7822fa68dc 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -8,6 +8,7 @@ using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; +using osu.Game.Screens.Menu; using osu.Game.Screens.Multi.Screens.Lounge; namespace osu.Game.Screens.Multi @@ -84,6 +85,13 @@ namespace osu.Game.Screens.Multi waves.Hide(); } + protected override void LogoExiting(OsuLogo logo) + { + // the wave overlay transition takes longer than expected to run. + logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut(); + base.LogoExiting(logo); + } + private class MultiplayerWaveContainer : WaveContainer { protected override bool StartHidden => true; From 02c37ebc1f928d96fbeaa79df5337e3cd1a1703e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 13:02:06 +0900 Subject: [PATCH 092/253] Move screen titles to OsuScreen --- .../Visual/TestCaseScreenBreadcrumbControl.cs | 7 ++----- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 3 ++- osu.Game/Screens/Multi/Header.cs | 2 +- osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs | 2 +- osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs | 5 ----- osu.Game/Screens/OsuScreen.cs | 10 +++++++++- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs index 7a743655f4..83bbbfddd1 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs @@ -84,12 +84,9 @@ namespace osu.Game.Tests.Visual private abstract class TestScreen : OsuScreen { - protected abstract string Title { get; } protected abstract string NextTitle { get; } protected abstract TestScreen CreateNextScreen(); - public override string ToString() => Title; - public TestScreen PushNext() { TestScreen screen = CreateNextScreen(); @@ -130,14 +127,14 @@ namespace osu.Game.Tests.Visual private class TestScreenOne : TestScreen { - protected override string Title => @"Screen One"; + public override string Title => @"Screen One"; protected override string NextTitle => @"Two"; protected override TestScreen CreateNextScreen() => new TestScreenTwo(); } private class TestScreenTwo : TestScreen { - protected override string Title => @"Screen Two"; + public override string Title => @"Screen Two"; protected override string NextTitle => @"One"; protected override TestScreen CreateNextScreen() => new TestScreenOne(); } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index fc14a9c6ba..d015a563f6 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -6,6 +6,7 @@ using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -157,7 +158,7 @@ namespace osu.Game.Graphics.UserInterface Margin = new MarginPadding { Top = 5, Bottom = 5 }, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Text = (value as Enum)?.GetDescription() ?? value.ToString(), + Text = (value as IHasDescription)?.Description ?? (value as Enum)?.GetDescription() ?? value.ToString(), TextSize = 14, Font = @"Exo2.0-Bold", // Font should only turn bold when active? }, diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index f6b7bbfcef..de71b20007 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -86,7 +86,7 @@ namespace osu.Game.Screens.Multi }, }; - breadcrumbs.Current.ValueChanged += s => screenTitle.Text = s is MultiplayerScreen m ? m.Title : s.ToString(); + breadcrumbs.Current.ValueChanged += s => screenTitle.Text = ((MultiplayerScreen)s).Title; breadcrumbs.Current.TriggerChange(); } diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 01a7510f76..60ffe2c0b9 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge protected readonly RoomInspector Inspector; public override string Title => "lounge"; - public override string Name => "Lounge"; + protected override Container TransitionContent => content; private IEnumerable rooms; diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs index 5a17a32d8c..191fe66037 100644 --- a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -15,11 +15,6 @@ namespace osu.Game.Screens.Multi.Screens protected virtual Container TransitionContent => Content; - public abstract string Title { get; } - public abstract string Name { get; } - - public override string ToString() => Name; - protected override void OnEntering(Screen last) { base.OnEntering(last); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index a188b7aa64..cd9cbe119f 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -20,10 +21,17 @@ using OpenTK.Input; namespace osu.Game.Screens { - public abstract class OsuScreen : Screen, IKeyBindingHandler + public abstract class OsuScreen : Screen, IKeyBindingHandler, IHasDescription { public BackgroundScreen Background { get; private set; } + /// + /// A user-facing title for this screen. + /// + public virtual string Title => GetType().ShortDisplayName(); + + public string Description => Title; + protected virtual bool AllowBackButton => true; /// From ed7c8608028149b4549026f09efe7de500cffc49 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 13:02:15 +0900 Subject: [PATCH 093/253] Adjust transitions of DrawableRoom --- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 8e93fda68f..1851f4618e 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Multi.Components { public const float SELECTION_BORDER_WIDTH = 4; private const float corner_radius = 5; - private const float transition_duration = 100; + private const float transition_duration = 60; private const float content_padding = 10; private const float height = 100; private const float side_strip_width = 5; @@ -254,7 +254,7 @@ namespace osu.Game.Screens.Multi.Components status.Text = s.Message; foreach (Drawable d in new Drawable[] { selectionBox, sideStrip, status }) - d.FadeColour(s.GetAppropriateColour(colours), 100); + d.FadeColour(s.GetAppropriateColour(colours), transition_duration); }; beatmapBind.ValueChanged += b => From 3a5228af4328b5fc6a9be5481e1fbe7115a21656 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 28 May 2018 17:55:41 +0900 Subject: [PATCH 094/253] Make GameBeatmap late-bind its AudioManager for ctor Beatmap access --- osu.Game/Beatmaps/GameBeatmap.cs | 33 ++++++++++++++++------- osu.Game/OsuGameBase.cs | 30 ++++++++++++++++++--- osu.Game/Tests/Visual/OsuTestCase.cs | 39 +++++++++++++++++++++------- 3 files changed, 79 insertions(+), 23 deletions(-) diff --git a/osu.Game/Beatmaps/GameBeatmap.cs b/osu.Game/Beatmaps/GameBeatmap.cs index 0b92fda7b7..ea19337c8c 100644 --- a/osu.Game/Beatmaps/GameBeatmap.cs +++ b/osu.Game/Beatmaps/GameBeatmap.cs @@ -1,8 +1,11 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Diagnostics; +using JetBrains.Annotations; using osu.Framework.Audio; +using osu.Framework.Audio.Track; using osu.Framework.Configuration; namespace osu.Game.Beatmaps @@ -11,18 +14,31 @@ namespace osu.Game.Beatmaps /// A for the beatmap. /// This should be used sparingly in-favour of . /// - public class GameBeatmap : NonNullableBindable, IGameBeatmap + public abstract class GameBeatmap : NonNullableBindable, IGameBeatmap { - private readonly AudioManager audioManager; - + private AudioManager audioManager; private WorkingBeatmap lastBeatmap; - public GameBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) + protected GameBeatmap(WorkingBeatmap defaultValue) : base(defaultValue) { + } + + /// + /// Registers an for s to be added to. + /// + /// The . + protected void RegisterAudioManager([NotNull] AudioManager audioManager) + { + if (this.audioManager != null) throw new InvalidOperationException($"Cannot register multiple {nameof(AudioManager)}s."); + this.audioManager = audioManager; ValueChanged += registerAudioTrack; + + // If the track has changed prior to this being called, let's register it + if (Value != Default) + registerAudioTrack(Value); } private void registerAudioTrack(WorkingBeatmap beatmap) @@ -46,17 +62,14 @@ namespace osu.Game.Beatmaps lastBeatmap = beatmap; } + [NotNull] IGameBeatmap IGameBeatmap.GetBoundCopy() => GetBoundCopy(); /// /// Retrieve a new instance weakly bound to this . /// If you are further binding to events of the retrieved , ensure a local reference is held. /// - public new GameBeatmap GetBoundCopy() - { - var copy = new GameBeatmap(Default, audioManager); - copy.BindTo(this); - return copy; - } + [NotNull] + public abstract GameBeatmap GetBoundCopy(); } } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 97f7f5a21e..ff0488a0ae 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -64,7 +64,8 @@ namespace osu.Game protected override Container Content => content; - protected GameBeatmap Beatmap; + private OsuGameBeatmap beatmap; + protected GameBeatmap Beatmap => beatmap; private Bindable fpsDisplayVisible; @@ -156,15 +157,15 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); var defaultBeatmap = new DummyWorkingBeatmap(this); - Beatmap = new GameBeatmap(defaultBeatmap, Audio); + beatmap = new OsuGameBeatmap(defaultBeatmap, Audio); BeatmapManager.DefaultBeatmap = defaultBeatmap; // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); - dependencies.Cache(Beatmap); - dependencies.CacheAs(Beatmap); + dependencies.CacheAs(beatmap); + dependencies.CacheAs(beatmap); FileStore.Cleanup(); @@ -235,5 +236,26 @@ namespace osu.Game } public string[] HandledExtensions => fileImporters.SelectMany(i => i.HandledExtensions).ToArray(); + + private class OsuGameBeatmap : GameBeatmap + { + public OsuGameBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) + : this(defaultValue) + { + RegisterAudioManager(audioManager); + } + + private OsuGameBeatmap(WorkingBeatmap defaultValue) + : base(defaultValue) + { + } + + public override GameBeatmap GetBoundCopy() + { + var copy = new OsuGameBeatmap(Default); + copy.BindTo(this); + return copy; + } + } } } diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index c337563920..ec1729ac5b 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -12,31 +12,35 @@ namespace osu.Game.Tests.Visual { public abstract class OsuTestCase : TestCase { - protected GameBeatmap Beatmap { get; private set; } + private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap()); + protected GameBeatmap Beatmap => beatmap; private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) { - // The beatmap is constructed here rather than load() because our children get dependencies injected before our load() runs - Beatmap = new GameBeatmap(new DummyWorkingBeatmap(), parent.Get()); - dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - dependencies.CacheAs(Beatmap); - dependencies.Cache(Beatmap); + dependencies.CacheAs(beatmap); + dependencies.CacheAs(beatmap); return dependencies; } + [BackgroundDependencyLoader] + private void load(AudioManager audioManager) + { + beatmap.SetAudioManager(audioManager); + } + protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - if (Beatmap != null) + if (beatmap != null) { - Beatmap.Disabled = true; - Beatmap.Value.Track.Stop(); + beatmap.Disabled = true; + beatmap.Value.Track.Stop(); } } @@ -58,5 +62,22 @@ namespace osu.Game.Tests.Visual public void RunTestBlocking(TestCase test) => runner.RunTestBlocking(test); } + + private class OsuTestBeatmap : GameBeatmap + { + public OsuTestBeatmap(WorkingBeatmap defaultValue) + : base(defaultValue) + { + } + + public void SetAudioManager(AudioManager audioManager) => RegisterAudioManager(audioManager); + + public override GameBeatmap GetBoundCopy() + { + var copy = new OsuTestBeatmap(Default); + copy.BindTo(this); + return copy; + } + } } } From 31cbec99a1ea272a82951187355d536ab4a03e33 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 28 May 2018 18:12:49 +0900 Subject: [PATCH 095/253] Fix mania hold notes displaying judgements --- osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs | 2 ++ osu.Game.Rulesets.Mania/UI/Column.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaStage.cs | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 8791e8ed86..f7de503fb3 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -18,6 +18,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableHoldNote : DrawableManiaHitObject, IKeyBindingHandler { + public override bool DisplayJudgement => false; + private readonly DrawableNote head; private readonly DrawableNote tail; diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 52d514221d..28cd1b6b39 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -213,7 +213,7 @@ namespace osu.Game.Rulesets.Mania.UI internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { - if (!judgement.IsHit) + if (!judgement.IsHit || !judgedObject.DisplayJudgement) return; explosionContainer.Add(new HitExplosion(judgedObject)); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs index 904be3a9e3..605794c795 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs @@ -171,6 +171,9 @@ namespace osu.Game.Rulesets.Mania.UI internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { + if (!judgedObject.DisplayJudgement) + return; + judgements.Clear(); judgements.Add(new DrawableManiaJudgement(judgement, judgedObject) { From 5be46307fdeda27cdc5556d0ca1303cff98285dc Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 28 May 2018 19:43:59 +0900 Subject: [PATCH 096/253] Fix results screen parallax being cut off Alternative to / closes #2549. Didn't want to reference the toolbar as was done, also wanted to remove the awkward scaling factors so rather than scaling down the inner one, we scale up the outer one. --- osu.Game/Screens/Ranking/Results.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 32161a0b8e..7cbd2e4403 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -57,6 +57,7 @@ namespace osu.Game.Screens.Ranking { base.OnEntering(last); (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 2500, Easing.OutQuint); + Background.ScaleTo(1.1f, transition_time, Easing.OutQuint); allCircles.ForEach(c => { @@ -102,6 +103,8 @@ namespace osu.Game.Screens.Ranking c.ScaleTo(0, transition_time, Easing.OutSine); }); + Background.ScaleTo(1f, transition_time / 4, Easing.OutQuint); + Content.FadeOut(transition_time / 4); return base.OnExiting(next); @@ -160,7 +163,6 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - Scale = new Vector2(1 / circle_outer_scale / overscan), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] From 2b3a6302706221035456fd37f4b2e57311a06109 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Mon, 28 May 2018 13:43:47 +0200 Subject: [PATCH 097/253] add OverlayActivation enum + fix Toolbar being toggleable when it shouldn't be able to + allow opening overlays in MenuState.Initial again --- .../Containers/OsuFocusedOverlayContainer.cs | 10 ++++-- osu.Game/OsuGame.cs | 22 ++++-------- osu.Game/Overlays/OverlayActivation.cs | 12 +++++++ osu.Game/Overlays/Toolbar/Toolbar.cs | 20 +++++++++++ osu.Game/Screens/Menu/ButtonSystem.cs | 20 ++++------- osu.Game/Screens/Menu/Disclaimer.cs | 4 ++- osu.Game/Screens/Menu/Intro.cs | 4 ++- osu.Game/Screens/Menu/MainMenu.cs | 6 +++- osu.Game/Screens/OsuScreen.cs | 35 +++++++++++++------ 9 files changed, 89 insertions(+), 44 deletions(-) create mode 100644 osu.Game/Overlays/OverlayActivation.cs diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 11a2034a8f..318632a403 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using OpenTK; using osu.Framework.Configuration; +using osu.Game.Overlays; namespace osu.Game.Graphics.Containers { @@ -16,13 +17,16 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; - private readonly BindableBool allowOpeningOverlays = new BindableBool(true); + /// + /// Defaults to so that the overlay works even if BDL couldn't pass an . + /// + private readonly Bindable allowOverlays = new Bindable(OverlayActivation.All); [BackgroundDependencyLoader(true)] private void load(OsuGame osuGame, AudioManager audio) { if (osuGame != null) - allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays); + allowOverlays.BindTo(osuGame.AllowOverlays); samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); @@ -52,7 +56,7 @@ namespace osu.Game.Graphics.Containers private void onStateChanged(Visibility visibility) { - if (allowOpeningOverlays) + if (allowOverlays == OverlayActivation.All) { switch (visibility) { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index a43c1507b6..35f29c3fd1 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -77,8 +77,7 @@ namespace osu.Game public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight; - public readonly BindableBool HideOverlaysOnEnter = new BindableBool(); - public readonly BindableBool AllowOpeningOverlays = new BindableBool(true); + public readonly Bindable AllowOverlays = new Bindable(); private OsuScreen screenStack; @@ -368,20 +367,13 @@ namespace osu.Game settings.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset(); - notifications.Enabled.BindTo(AllowOpeningOverlays); + AllowOverlays.ValueChanged += state => notifications.Enabled.Value = state == OverlayActivation.All; + } - HideOverlaysOnEnter.ValueChanged += hide => - { - //central game screen change logic. - if (hide) - { - hideAllOverlays(); - musicController.State = Visibility.Hidden; - Toolbar.State = Visibility.Hidden; - } - else - Toolbar.State = Visibility.Visible; - }; + public void CloseAllOverlays() + { + hideAllOverlays(); + musicController.State = Visibility.Hidden; } private void forwardLoggedErrorsToNotifications() diff --git a/osu.Game/Overlays/OverlayActivation.cs b/osu.Game/Overlays/OverlayActivation.cs new file mode 100644 index 0000000000..735682ed57 --- /dev/null +++ b/osu.Game/Overlays/OverlayActivation.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Overlays +{ + public enum OverlayActivation + { + Disabled, + //UserTriggered, // currently there is no way to discern user action + All + } +} diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 424a457110..78739c03fe 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -10,6 +10,8 @@ using osu.Framework.Input; using osu.Game.Graphics; using OpenTK; using osu.Framework.Graphics.Shapes; +using osu.Framework.Allocation; +using osu.Framework.Configuration; namespace osu.Game.Overlays.Toolbar { @@ -29,6 +31,11 @@ namespace osu.Game.Overlays.Toolbar private const float alpha_hovering = 0.8f; private const float alpha_normal = 0.6f; + /// + /// Defaults to so that the overlay works even if BDL couldn't pass an . + /// + private readonly Bindable allowOverlays = new Bindable(OverlayActivation.All); + public Toolbar() { Children = new Drawable[] @@ -76,6 +83,19 @@ namespace osu.Game.Overlays.Toolbar Size = new Vector2(1, HEIGHT); } + [BackgroundDependencyLoader(true)] + private void load(OsuGame osuGame) + { + if (osuGame != null) + allowOverlays.BindTo(osuGame.AllowOverlays); + + StateChanged += visibility => + { + if (allowOverlays == OverlayActivation.Disabled) + State = Visibility.Hidden; + }; + } + public class ToolbarBackground : Container { private readonly Box solidBackground; diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 8b88204ed0..40e115364d 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -20,6 +20,7 @@ using osu.Game.Input.Bindings; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; +using osu.Game.Overlays; namespace osu.Game.Screens.Menu { @@ -27,8 +28,7 @@ namespace osu.Game.Screens.Menu { public event Action StateChanged; - private readonly BindableBool hideOverlaysOnEnter = new BindableBool(); - private readonly BindableBool allowOpeningOverlays = new BindableBool(); + private readonly Bindable allowOverlays = new Bindable(); public Action OnEdit; public Action OnExit; @@ -137,10 +137,7 @@ namespace osu.Game.Screens.Menu private void load(AudioManager audio, OsuGame game) { if (game != null) - { - hideOverlaysOnEnter.BindTo(game.HideOverlaysOnEnter); - allowOpeningOverlays.BindTo(game.AllowOpeningOverlays); - } + allowOverlays.BindTo(game.AllowOverlays); sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } @@ -332,19 +329,19 @@ namespace osu.Game.Screens.Menu case MenuState.Exit: case MenuState.Initial: logoTracking = false; + allowOverlays.Value = OverlayActivation.Disabled; logoDelayedAction = Scheduler.AddDelayed(() => { - hideOverlaysOnEnter.Value = true; - allowOpeningOverlays.Value = false; - logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); logo.ScaleTo(1, 800, Easing.OutExpo); - }, 150); + if(state != MenuState.Exit) + allowOverlays.Value = OverlayActivation.All; + }, 150); break; case MenuState.TopLevel: case MenuState.Play: @@ -365,9 +362,6 @@ namespace osu.Game.Screens.Menu logoTracking = true; logo.Impact(); - - hideOverlaysOnEnter.Value = false; - allowOpeningOverlays.Value = true; }, 200); break; default: diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index b8cb7f2a4a..3671a54068 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -9,6 +9,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Game.Overlays; namespace osu.Game.Screens.Menu { @@ -19,7 +20,6 @@ namespace osu.Game.Screens.Menu private Color4 iconColour; protected override bool HideOverlaysOnEnter => true; - protected override bool AllowOpeningOverlays => false; public override bool CursorVisible => false; @@ -93,6 +93,8 @@ namespace osu.Game.Screens.Menu LoadComponentAsync(intro = new Intro()); iconColour = colours.Yellow; + + AllowOverlays.Value = OverlayActivation.Disabled; } protected override void OnEntering(Screen last) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index c174e2d470..aa89b86786 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -15,6 +15,7 @@ using osu.Game.IO.Archives; using osu.Game.Screens.Backgrounds; using OpenTK; using OpenTK.Graphics; +using osu.Game.Overlays; namespace osu.Game.Screens.Menu { @@ -32,7 +33,6 @@ namespace osu.Game.Screens.Menu private SampleChannel seeya; protected override bool HideOverlaysOnEnter => true; - protected override bool AllowOpeningOverlays => false; public override bool CursorVisible => false; @@ -77,6 +77,8 @@ namespace osu.Game.Screens.Menu welcome = audio.Sample.Get(@"welcome"); seeya = audio.Sample.Get(@"seeya"); + + AllowOverlays.Value = OverlayActivation.Disabled; } protected override void OnEntering(Screen last) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index d5f3b11467..728880b0f8 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -10,6 +10,7 @@ using osu.Framework.Input; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; +using osu.Game.Overlays; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Charts; using osu.Game.Screens.Direct; @@ -25,7 +26,6 @@ namespace osu.Game.Screens.Menu private readonly ButtonSystem buttons; protected override bool HideOverlaysOnEnter => buttons.State == MenuState.Initial; - protected override bool AllowOpeningOverlays => buttons.State != MenuState.Initial; protected override bool AllowBackButton => buttons.State != MenuState.Initial; @@ -64,6 +64,8 @@ namespace osu.Game.Screens.Menu }, sideFlashes = new MenuSideFlashes(), }; + + buttons.StateChanged += state => UpdateOverlayStates?.Invoke(); } [BackgroundDependencyLoader(true)] @@ -78,6 +80,8 @@ namespace osu.Game.Screens.Menu } preloadSongSelect(); + + AllowOverlays.Value = OverlayActivation.Disabled; } private void preloadSongSelect() diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index cd9cbe119f..e48d72b6fc 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -18,6 +18,8 @@ using osu.Game.Rulesets; using osu.Game.Screens.Menu; using OpenTK; using OpenTK.Input; +using osu.Game.Overlays; +using osu.Framework.Graphics.Containers; namespace osu.Game.Screens { @@ -40,19 +42,23 @@ namespace osu.Game.Screens /// protected virtual BackgroundScreen CreateBackground() => null; - private readonly BindableBool hideOverlaysOnEnter = new BindableBool(); + private Action updateOverlayStates; /// - /// Whether overlays should be hidden when this screen is entered or resumed. + /// Allows manually updating visibility of all overlays if is not enough. + /// + protected Action UpdateOverlayStates => updateOverlayStates; + + /// + /// Whether all overlays should be hidden when this screen is entered or resumed. /// protected virtual bool HideOverlaysOnEnter => false; - private readonly BindableBool allowOpeningOverlays = new BindableBool(); - /// - /// Whether overlays should be able to be opened while this screen is active. + /// Whether overlays should be able to be opened. + /// It's bound at load which means changes at construction will potentially disappear. /// - protected virtual bool AllowOpeningOverlays => true; + protected readonly Bindable AllowOverlays = new Bindable(); /// /// Whether this allows the cursor to be displayed. @@ -103,8 +109,18 @@ namespace osu.Game.Screens if (osuGame != null) { Ruleset.BindTo(osuGame.Ruleset); - hideOverlaysOnEnter.BindTo(osuGame.HideOverlaysOnEnter); - allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays); + AllowOverlays.BindTo(osuGame.AllowOverlays); + + updateOverlayStates = () => + { + if (HideOverlaysOnEnter) + { + osuGame.CloseAllOverlays(); + osuGame.Toolbar.State = Visibility.Hidden; + } + else + osuGame.Toolbar.State = Visibility.Visible; + }; } sampleExit = audio.Sample.Get(@"UI/screen-back"); @@ -236,8 +252,7 @@ namespace osu.Game.Screens if (backgroundParallaxContainer != null) backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; - hideOverlaysOnEnter.Value = HideOverlaysOnEnter; - allowOpeningOverlays.Value = AllowOpeningOverlays; + updateOverlayStates?.Invoke(); } private void onExitingLogo() From e920b8d5774beb09455e462ac09347e768e81a7e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 19:11:26 -0300 Subject: [PATCH 098/253] Add UpdateableBeatmapSetCover. --- .../Drawables/UpdateableBeatmapSetCover.cs | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs new file mode 100644 index 0000000000..e25f5a9431 --- /dev/null +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs @@ -0,0 +1,78 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using OpenTK.Graphics; + +namespace osu.Game.Beatmaps.Drawables +{ + public class UpdateableBeatmapSetCover : Container + { + private Drawable displayedCover; + + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + if (IsLoaded) + updateCover(); + } + } + + private BeatmapSetCoverType coverType = BeatmapSetCoverType.Cover; + public BeatmapSetCoverType CoverType + { + get { return coverType; } + set + { + if (value == coverType) return; + coverType = value; + + if (IsLoaded) + updateCover(); + } + } + + public UpdateableBeatmapSetCover() + { + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + updateCover(); + } + + private void updateCover() + { + displayedCover?.FadeOut(400); + displayedCover?.Expire(); + + if (beatmapSet != null) + { + Add(displayedCover = new DelayedLoadWrapper( + new BeatmapSetCover(beatmapSet, coverType) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), + }) + ); + } + } + } +} From bdfb5752cd46eda4f5f0e908e3aa721eb5222e54 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 19:31:20 -0300 Subject: [PATCH 099/253] Update existing drawables to use UpdateableBeatmapSetCover. --- osu.Game/Overlays/BeatmapSet/Header.cs | 25 +++------------ osu.Game/Overlays/Direct/DirectPanel.cs | 23 ++----------- .../Historical/DrawableMostPlayedRow.cs | 14 +++----- .../Screens/Multi/Components/DrawableRoom.cs | 29 +++-------------- .../Screens/Multi/Components/RoomInspector.cs | 32 +++---------------- 5 files changed, 19 insertions(+), 104 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 8833a89479..033f0b22d0 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet private const float buttons_spacing = 5; private readonly Box tabsBg; - private readonly Container coverContainer; + private readonly UpdateableBeatmapSetCover cover; private readonly OsuSpriteText title, artist; private readonly Container noVideoButtons; private readonly FillFlowContainer videoButtons; @@ -36,7 +36,6 @@ namespace osu.Game.Overlays.BeatmapSet public Details Details; private BeatmapManager beatmaps; - private DelayedLoadWrapper cover; public readonly BeatmapPicker Picker; @@ -63,7 +62,7 @@ namespace osu.Game.Overlays.BeatmapSet artist.Text = BeatmapSet?.Metadata.Artist ?? string.Empty; onlineStatusPill.Status = BeatmapSet?.OnlineInfo.Status ?? BeatmapSetOnlineStatus.None; - cover?.FadeOut(400, Easing.Out); + cover.BeatmapSet = null; if (BeatmapSet != null) { downloadButtonsContainer.FadeIn(transition_duration); @@ -72,18 +71,7 @@ namespace osu.Game.Overlays.BeatmapSet noVideoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 0 : 1, transition_duration); videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration); - coverContainer.Add(cover = new DelayedLoadWrapper( - new BeatmapSetCover(BeatmapSet) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), - }, 300) - { - RelativeSizeAxes = Axes.Both, - }); + cover.BeatmapSet = BeatmapSet; } else { @@ -130,12 +118,7 @@ namespace osu.Game.Overlays.BeatmapSet RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - coverContainer = new Container + cover = new UpdateableBeatmapSetCover { RelativeSizeAxes = Axes.Both, }, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index cc0123dabc..df784252ce 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -27,8 +27,6 @@ namespace osu.Game.Overlays.Direct { public readonly BeatmapSetInfo SetInfo; - protected Box BlackBackground; - private const double hover_transition_time = 400; private Container content; @@ -81,12 +79,6 @@ namespace osu.Game.Overlays.Direct EdgeEffect = edgeEffectNormal, Children = new[] { - // temporary blackness until the actual background loads. - BlackBackground = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, CreateBackground(), progressBar = new ProgressBar { @@ -215,21 +207,10 @@ namespace osu.Game.Overlays.Direct return icons; } - protected Drawable CreateBackground() => new DelayedLoadWrapper( - new BeatmapSetCover(SetInfo) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fill, - OnLoadComplete = d => - { - d.FadeInFromZero(400, Easing.Out); - BlackBackground.Delay(400).FadeOut(); - }, - }, 300) + protected Drawable CreateBackground() => new UpdateableBeatmapSetCover { RelativeSizeAxes = Axes.Both, + BeatmapSet = SetInfo, }; public class Statistic : FillFlowContainer diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs index be8e09105b..0a2b2fe121 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs @@ -24,19 +24,13 @@ namespace osu.Game.Overlays.Profile.Sections.Historical this.playCount = playCount; } - protected override Drawable CreateLeftVisual() => new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List) + protected override Drawable CreateLeftVisual() => new UpdateableBeatmapSetCover { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fit, - RelativeSizeAxes = Axes.Both, - OnLoadComplete = d => d.FadeInFromZero(500, Easing.OutQuint) - }) - { - Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, - RelativeSizeAxes = Axes.None, + Origin = Anchor.CentreLeft, Size = new Vector2(80, 50), + BeatmapSet = beatmap.BeatmapSet, + CoverType = BeatmapSetCoverType.List, }; [BackgroundDependencyLoader(true)] diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 1851f4618e..83d86d8159 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -111,7 +111,7 @@ namespace osu.Game.Screens.Multi.Components private void load(OsuColour colours, LocalisationEngine localisation) { Box sideStrip; - Container coverContainer; + UpdateableBeatmapSetCover cover; OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist; ParticipantInfo participantInfo; ModeTypeInfo modeTypeInfo; @@ -146,24 +146,12 @@ namespace osu.Game.Screens.Multi.Components RelativeSizeAxes = Axes.Y, Width = side_strip_width, }, - new Container + cover = new UpdateableBeatmapSetCover { Width = cover_width, RelativeSizeAxes = Axes.Y, Masking = true, Margin = new MarginPadding { Left = side_strip_width }, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - coverContainer = new Container - { - RelativeSizeAxes = Axes.Both, - }, - }, }, new Container { @@ -263,23 +251,14 @@ namespace osu.Game.Screens.Multi.Components if (b != null) { - coverContainer.FadeIn(transition_duration); - - LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), - }, coverContainer.Add); - + cover.BeatmapSet = b.BeatmapSet; beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title); beatmapDash.Text = @" - "; beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist); } else { - coverContainer.FadeOut(transition_duration); + cover.BeatmapSet = null; beatmapTitle.Current = null; beatmapArtist.Current = null; diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index 3bd054b042..a282e56d22 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Multi.Components private OsuColour colours; private Box statusStrip; - private Container coverContainer; + private UpdateableBeatmapSetCover cover; private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow, infoPanelFlow; private OsuSpriteText name, status; private ScrollContainer participantsScroll; @@ -105,21 +105,9 @@ namespace osu.Game.Screens.Multi.Components Masking = true, Children = new Drawable[] { - new Container + cover = new UpdateableBeatmapSetCover { RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - coverContainer = new Container - { - RelativeSizeAxes = Axes.Both, - }, - }, }, new Box { @@ -294,17 +282,7 @@ namespace osu.Game.Screens.Multi.Components if (b != null) { - coverContainer.FadeIn(transition_duration); - - LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet) - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), - }, coverContainer.Add); - + cover.BeatmapSet = b.BeatmapSet; beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title); beatmapDash.Text = @" - "; beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist); @@ -312,7 +290,7 @@ namespace osu.Game.Screens.Multi.Components } else { - coverContainer.FadeOut(transition_duration); + cover.BeatmapSet = null; beatmapTitle.Current = null; beatmapArtist.Current = null; @@ -367,7 +345,7 @@ namespace osu.Game.Screens.Multi.Components { if (Room == null) { - coverContainer.FadeOut(transition_duration); + cover.BeatmapSet = null; participantsFlow.FadeOut(transition_duration); participantNumbersFlow.FadeOut(transition_duration); infoPanelFlow.FadeOut(transition_duration); From 8b36e1dad088095b0e9aa4b8e7cc74f8fae1390d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 23:13:56 -0300 Subject: [PATCH 100/253] Add BeatmapTitle to encapsulate multiplayer beatmap title display logic. (cherry picked from commit 58e65afb45fbc675186e470cc4a268d9eaa2a539) --- .../Screens/Multi/Components/BeatmapTitle.cs | 90 +++++++++++++++++++ .../Screens/Multi/Components/DrawableRoom.cs | 40 ++------- .../Screens/Multi/Components/RoomInspector.cs | 37 ++------ 3 files changed, 104 insertions(+), 63 deletions(-) create mode 100644 osu.Game/Screens/Multi/Components/BeatmapTitle.cs diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs new file mode 100644 index 0000000000..a6cc472335 --- /dev/null +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -0,0 +1,90 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Localisation; +using osu.Game.Beatmaps; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Multi.Components +{ + public class BeatmapTitle : FillFlowContainer + { + private readonly OsuSpriteText beatmapTitle, beatmapDash, beatmapArtist; + + private LocalisationEngine localisation; + + public float TextSize + { + set { beatmapTitle.TextSize = beatmapDash.TextSize = beatmapArtist.TextSize = value; } + } + + private BeatmapInfo beatmap; + public BeatmapInfo Beatmap + { + get { return beatmap; } + set + { + if (value == beatmap) return; + beatmap = value; + + if (IsLoaded) + updateText(); + } + } + + public BeatmapTitle() + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + + Children = new[] + { + beatmapTitle = new OsuSpriteText + { + Font = @"Exo2.0-BoldItalic", + }, + beatmapDash = new OsuSpriteText + { + Font = @"Exo2.0-BoldItalic", + }, + beatmapArtist = new OsuSpriteText + { + Font = @"Exo2.0-RegularItalic", + }, + }; + } + + [BackgroundDependencyLoader] + private void load(LocalisationEngine localisation) + { + this.localisation = localisation; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + updateText(); + } + + private void updateText() + { + if (beatmap == null) + { + beatmapTitle.Current = beatmapArtist.Current = null; + + beatmapTitle.Text = "Changing map"; + beatmapDash.Text = beatmapArtist.Text = string.Empty; + } + else + { + beatmapTitle.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title); + beatmapDash.Text = @" - "; + beatmapArtist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist); + } + } + } +} diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 83d86d8159..f48846f707 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -112,8 +112,9 @@ namespace osu.Game.Screens.Multi.Components { Box sideStrip; UpdateableBeatmapSetCover cover; - OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist; + OsuSpriteText name, status; ParticipantInfo participantInfo; + BeatmapTitle beatmapTitle; ModeTypeInfo modeTypeInfo; Children = new Drawable[] @@ -193,30 +194,10 @@ namespace osu.Game.Screens.Multi.Components TextSize = 14, Font = @"Exo2.0-Bold", }, - new FillFlowContainer + beatmapTitle = new BeatmapTitle { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Colour = colours.Gray9, - Direction = FillDirection.Horizontal, - Children = new[] - { - beatmapTitle = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-BoldItalic", - }, - beatmapDash = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-BoldItalic", - }, - beatmapArtist = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-RegularItalic", - }, - }, + TextSize = 14, + Colour = colours.Gray9 }, }, }, @@ -252,19 +233,12 @@ namespace osu.Game.Screens.Multi.Components if (b != null) { cover.BeatmapSet = b.BeatmapSet; - beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title); - beatmapDash.Text = @" - "; - beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist); + beatmapTitle.Beatmap = b; } else { cover.BeatmapSet = null; - - beatmapTitle.Current = null; - beatmapArtist.Current = null; - - beatmapTitle.Text = "Changing map"; - beatmapDash.Text = beatmapArtist.Text = string.Empty; + beatmapTitle.Beatmap = null; } }; diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index a282e56d22..ee3dea7c0d 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -82,7 +82,8 @@ namespace osu.Game.Screens.Multi.Components this.colours = colours; ModeTypeInfo modeTypeInfo; - OsuSpriteText participants, participantsSlash, maxParticipants, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; + OsuSpriteText participants, participantsSlash, maxParticipants, beatmapAuthor; + BeatmapTitle beatmapTitle; Children = new Drawable[] { @@ -203,28 +204,9 @@ namespace osu.Game.Screens.Multi.Components AutoSizeAxes = Axes.X, RelativeSizeAxes = Axes.Y, Margin = new MarginPadding { Left = 5 }, - Children = new[] + Children = new Drawable[] { - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - beatmapTitle = new OsuSpriteText - { - Font = @"Exo2.0-BoldItalic", - }, - beatmapDash = new OsuSpriteText - { - Font = @"Exo2.0-BoldItalic", - }, - beatmapArtist = new OsuSpriteText - { - Font = @"Exo2.0-RegularItalic", - }, - }, - }, + beatmapTitle = new BeatmapTitle(), beatmapAuthor = new OsuSpriteText { Anchor = Anchor.BottomLeft, @@ -283,20 +265,15 @@ namespace osu.Game.Screens.Multi.Components if (b != null) { cover.BeatmapSet = b.BeatmapSet; - beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title); - beatmapDash.Text = @" - "; - beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist); + beatmapTitle.Beatmap = b; beatmapAuthor.Text = $"mapped by {b.Metadata.Author}"; } else { cover.BeatmapSet = null; + beatmapTitle.Beatmap = null; - beatmapTitle.Current = null; - beatmapArtist.Current = null; - - beatmapTitle.Text = "Changing map"; - beatmapDash.Text = beatmapArtist.Text = beatmapAuthor.Text = string.Empty; + beatmapAuthor.Text = string.Empty; } }; From 8b8d10349e67f6f3987efaeb32e7c616fb578e71 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 23:33:13 -0300 Subject: [PATCH 101/253] Move RoomInspector info panel content to BeatmapModeInfo to share with Match. (cherry picked from commit 257d9d13ac81d85583314f8b5dfabf05661b1572) --- .../Multi/Components/BeatmapModeInfo.cs | 74 +++++++++++++++++++ .../Screens/Multi/Components/DrawableRoom.cs | 3 +- .../Screens/Multi/Components/ModeTypeInfo.cs | 3 +- .../Screens/Multi/Components/RoomInspector.cs | 60 +++------------ 4 files changed, 86 insertions(+), 54 deletions(-) create mode 100644 osu.Game/Screens/Multi/Components/BeatmapModeInfo.cs diff --git a/osu.Game/Screens/Multi/Components/BeatmapModeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapModeInfo.cs new file mode 100644 index 0000000000..8bd7d7ea06 --- /dev/null +++ b/osu.Game/Screens/Multi/Components/BeatmapModeInfo.cs @@ -0,0 +1,74 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.Multiplayer; +using OpenTK; + +namespace osu.Game.Screens.Multi.Components +{ + public class BeatmapModeInfo : FillFlowContainer + { + private readonly ModeTypeInfo modeTypeInfo; + private readonly BeatmapTitle beatmapTitle; + private readonly OsuSpriteText beatmapAuthor; + + public BeatmapInfo Beatmap + { + set + { + modeTypeInfo.Beatmap = beatmapTitle.Beatmap = value; + + if (value == null) + beatmapAuthor.Text = string.Empty; + else + beatmapAuthor.Text = $"mapped by {value.Metadata.Author}"; + } + } + + public GameType Type + { + set { modeTypeInfo.Type = value; } + } + + public BeatmapModeInfo() + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + LayoutDuration = 100; + Spacing = new Vector2(5f, 0f); + + Children = new Drawable[] + { + modeTypeInfo = new ModeTypeInfo(), + new Container + { + AutoSizeAxes = Axes.X, + Height = 30, + Margin = new MarginPadding { Left = 5 }, + Children = new Drawable[] + { + beatmapTitle = new BeatmapTitle(), + beatmapAuthor = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + TextSize = 14, + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + beatmapAuthor.Colour = colours.Gray9; + } + } +} diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index f48846f707..70adf8c7db 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; -using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; @@ -108,7 +107,7 @@ namespace osu.Game.Screens.Multi.Components } [BackgroundDependencyLoader] - private void load(OsuColour colours, LocalisationEngine localisation) + private void load(OsuColour colours) { Box sideStrip; UpdateableBeatmapSetCover cover; diff --git a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs index e3aba685a7..26c391586a 100644 --- a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs @@ -55,7 +55,8 @@ namespace osu.Game.Screens.Multi.Components public ModeTypeInfo() { - AutoSizeAxes = Axes.Both; + AutoSizeAxes = Axes.X; + Height = height; Children = new[] { diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index ee3dea7c0d..c3b7d3a7ad 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; @@ -39,8 +38,9 @@ namespace osu.Game.Screens.Multi.Components private OsuColour colours; private Box statusStrip; private UpdateableBeatmapSetCover cover; - private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow, infoPanelFlow; + private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow; private OsuSpriteText name, status; + private BeatmapModeInfo beatmapModeInfo; private ScrollContainer participantsScroll; private ParticipantInfo participantInfo; @@ -77,13 +77,12 @@ namespace osu.Game.Screens.Multi.Components } [BackgroundDependencyLoader] - private void load(OsuColour colours, LocalisationEngine localisation) + private void load(OsuColour colours) { this.colours = colours; ModeTypeInfo modeTypeInfo; OsuSpriteText participants, participantsSlash, maxParticipants, beatmapAuthor; - BeatmapTitle beatmapTitle; Children = new Drawable[] { @@ -189,35 +188,7 @@ namespace osu.Game.Screens.Multi.Components TextSize = 14, Font = @"Exo2.0-Bold", }, - infoPanelFlow = new FillFlowContainer - { - AutoSizeAxes = Axes.X, - Height = 30, - Direction = FillDirection.Horizontal, - LayoutDuration = transition_duration, - Spacing = new Vector2(5f, 0f), - Children = new Drawable[] - { - modeTypeInfo = new ModeTypeInfo(), - new Container - { - AutoSizeAxes = Axes.X, - RelativeSizeAxes = Axes.Y, - Margin = new MarginPadding { Left = 5 }, - Children = new Drawable[] - { - beatmapTitle = new BeatmapTitle(), - beatmapAuthor = new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - TextSize = 14, - Colour = colours.Gray9, - }, - }, - }, - }, - }, + beatmapModeInfo = new BeatmapModeInfo(), }, }, }, @@ -255,26 +226,13 @@ namespace osu.Game.Screens.Multi.Components nameBind.ValueChanged += n => name.Text = n; hostBind.ValueChanged += h => participantInfo.Host = h; - typeBind.ValueChanged += t => modeTypeInfo.Type = t; + typeBind.ValueChanged += t => beatmapModeInfo.Type = t; statusBind.ValueChanged += displayStatus; beatmapBind.ValueChanged += b => { - modeTypeInfo.Beatmap = b; - - if (b != null) - { - cover.BeatmapSet = b.BeatmapSet; - beatmapTitle.Beatmap = b; - beatmapAuthor.Text = $"mapped by {b.Metadata.Author}"; - } - else - { - cover.BeatmapSet = null; - beatmapTitle.Beatmap = null; - - beatmapAuthor.Text = string.Empty; - } + cover.BeatmapSet = b?.BeatmapSet; + beatmapModeInfo.Beatmap = b; }; maxParticipantsBind.ValueChanged += m => @@ -325,7 +283,7 @@ namespace osu.Game.Screens.Multi.Components cover.BeatmapSet = null; participantsFlow.FadeOut(transition_duration); participantNumbersFlow.FadeOut(transition_duration); - infoPanelFlow.FadeOut(transition_duration); + beatmapModeInfo.FadeOut(transition_duration); name.FadeOut(transition_duration); participantInfo.FadeOut(transition_duration); @@ -335,7 +293,7 @@ namespace osu.Game.Screens.Multi.Components { participantsFlow.FadeIn(transition_duration); participantNumbersFlow.FadeIn(transition_duration); - infoPanelFlow.FadeIn(transition_duration); + beatmapModeInfo.FadeIn(transition_duration); name.FadeIn(transition_duration); participantInfo.FadeIn(transition_duration); From bd9af745dd898b770d7a8b7f1bc13b8641867dc5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 23:36:35 -0300 Subject: [PATCH 102/253] Cleanup. (cherry picked from commit fffa6a004cf074caf0cf5c8ae1408a80500859fa) --- osu.Game/Screens/Multi/Components/ModeTypeInfo.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs index 26c391586a..e3aba685a7 100644 --- a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs @@ -55,8 +55,7 @@ namespace osu.Game.Screens.Multi.Components public ModeTypeInfo() { - AutoSizeAxes = Axes.X; - Height = height; + AutoSizeAxes = Axes.Both; Children = new[] { From dcc39d96e2801d29fa671d1963546855a6b53fbe Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 23:45:59 -0300 Subject: [PATCH 103/253] BeatmapModeInfo -> BeatmapTypeInfo. --- .../{BeatmapModeInfo.cs => BeatmapTypeInfo.cs} | 4 ++-- osu.Game/Screens/Multi/Components/ModeTypeInfo.cs | 1 + osu.Game/Screens/Multi/Components/RoomInspector.cs | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) rename osu.Game/Screens/Multi/Components/{BeatmapModeInfo.cs => BeatmapTypeInfo.cs} (96%) diff --git a/osu.Game/Screens/Multi/Components/BeatmapModeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs similarity index 96% rename from osu.Game/Screens/Multi/Components/BeatmapModeInfo.cs rename to osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs index 8bd7d7ea06..753006c62d 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapModeInfo.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs @@ -12,7 +12,7 @@ using OpenTK; namespace osu.Game.Screens.Multi.Components { - public class BeatmapModeInfo : FillFlowContainer + public class BeatmapTypeInfo : FillFlowContainer { private readonly ModeTypeInfo modeTypeInfo; private readonly BeatmapTitle beatmapTitle; @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Multi.Components set { modeTypeInfo.Type = value; } } - public BeatmapModeInfo() + public BeatmapTypeInfo() { AutoSizeAxes = Axes.Both; Direction = FillDirection.Horizontal; diff --git a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs index e3aba685a7..e2d0268090 100644 --- a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs @@ -64,6 +64,7 @@ namespace osu.Game.Screens.Multi.Components AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(5f, 0f), + LayoutDuration = 100, Children = new[] { rulesetContainer = new Container diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index c3b7d3a7ad..d9a35808a8 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Multi.Components private UpdateableBeatmapSetCover cover; private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow; private OsuSpriteText name, status; - private BeatmapModeInfo beatmapModeInfo; + private BeatmapTypeInfo beatmapTypeInfo; private ScrollContainer participantsScroll; private ParticipantInfo participantInfo; @@ -188,7 +188,7 @@ namespace osu.Game.Screens.Multi.Components TextSize = 14, Font = @"Exo2.0-Bold", }, - beatmapModeInfo = new BeatmapModeInfo(), + beatmapTypeInfo = new BeatmapTypeInfo(), }, }, }, @@ -226,13 +226,13 @@ namespace osu.Game.Screens.Multi.Components nameBind.ValueChanged += n => name.Text = n; hostBind.ValueChanged += h => participantInfo.Host = h; - typeBind.ValueChanged += t => beatmapModeInfo.Type = t; + typeBind.ValueChanged += t => beatmapTypeInfo.Type = t; statusBind.ValueChanged += displayStatus; beatmapBind.ValueChanged += b => { cover.BeatmapSet = b?.BeatmapSet; - beatmapModeInfo.Beatmap = b; + beatmapTypeInfo.Beatmap = b; }; maxParticipantsBind.ValueChanged += m => @@ -283,7 +283,7 @@ namespace osu.Game.Screens.Multi.Components cover.BeatmapSet = null; participantsFlow.FadeOut(transition_duration); participantNumbersFlow.FadeOut(transition_duration); - beatmapModeInfo.FadeOut(transition_duration); + beatmapTypeInfo.FadeOut(transition_duration); name.FadeOut(transition_duration); participantInfo.FadeOut(transition_duration); @@ -293,7 +293,7 @@ namespace osu.Game.Screens.Multi.Components { participantsFlow.FadeIn(transition_duration); participantNumbersFlow.FadeIn(transition_duration); - beatmapModeInfo.FadeIn(transition_duration); + beatmapTypeInfo.FadeIn(transition_duration); name.FadeIn(transition_duration); participantInfo.FadeIn(transition_duration); From 7beac3a712138ec393b3cf84466f1742327d44b1 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 23:56:00 -0300 Subject: [PATCH 104/253] Cleanup DrawableRoom. --- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 70adf8c7db..d31019a259 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -227,18 +227,9 @@ namespace osu.Game.Screens.Multi.Components beatmapBind.ValueChanged += b => { + cover.BeatmapSet = b?.BeatmapSet; + beatmapTitle.Beatmap = b; modeTypeInfo.Beatmap = b; - - if (b != null) - { - cover.BeatmapSet = b.BeatmapSet; - beatmapTitle.Beatmap = b; - } - else - { - cover.BeatmapSet = null; - beatmapTitle.Beatmap = null; - } }; nameBind.BindTo(Room.Name); From 852d7ef48de64996af8fa109c8b4e8aedc0c5ec5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 00:07:33 -0300 Subject: [PATCH 105/253] Use ?: expression instead of if/else. --- osu.Game/Screens/Multi/Components/BeatmapTitle.cs | 1 - osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs index a6cc472335..daa362409a 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -24,7 +24,6 @@ namespace osu.Game.Screens.Multi.Components private BeatmapInfo beatmap; public BeatmapInfo Beatmap { - get { return beatmap; } set { if (value == beatmap) return; diff --git a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs index 753006c62d..78ffe01ef0 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs @@ -23,11 +23,7 @@ namespace osu.Game.Screens.Multi.Components set { modeTypeInfo.Beatmap = beatmapTitle.Beatmap = value; - - if (value == null) - beatmapAuthor.Text = string.Empty; - else - beatmapAuthor.Text = $"mapped by {value.Metadata.Author}"; + beatmapAuthor.Text = value == null ? string.Empty : $"mapped by {value.Metadata.Author}"; } } From d090323c0039c1a39a58bb4f5a8aead177be9a99 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 00:51:56 -0300 Subject: [PATCH 106/253] Add ParticipantCount to share with the Match screen. --- .../Multi/Components/ParticipantCount.cs | 67 +++++++++++++++++++ .../Screens/Multi/Components/RoomInspector.cs | 52 ++------------ 2 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 osu.Game/Screens/Multi/Components/ParticipantCount.cs diff --git a/osu.Game/Screens/Multi/Components/ParticipantCount.cs b/osu.Game/Screens/Multi/Components/ParticipantCount.cs new file mode 100644 index 0000000000..96e2bd7bee --- /dev/null +++ b/osu.Game/Screens/Multi/Components/ParticipantCount.cs @@ -0,0 +1,67 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Multi.Components +{ + public class ParticipantCount : FillFlowContainer + { + private const float text_size = 30; + private const float transition_duration = 100; + + private readonly OsuSpriteText count, slash, max; + + public int Count + { + set { count.Text = value.ToString(); } + } + + public int? Max + { + set + { + if (value == null) + { + slash.FadeOut(transition_duration); + max.FadeOut(transition_duration); + } + else + { + slash.FadeIn(transition_duration); + max.FadeIn(transition_duration); + max.Text = value.ToString(); + } + } + } + + public ParticipantCount() + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + LayoutDuration = transition_duration; + + Children = new[] + { + count = new OsuSpriteText + { + TextSize = text_size, + Font = @"Exo2.0-Bold" + }, + slash = new OsuSpriteText + { + Text = @"/", + TextSize = text_size, + Font = @"Exo2.0-Light" + }, + max = new OsuSpriteText + { + TextSize = text_size, + Font = @"Exo2.0-Light" + }, + }; + } + } +} diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index d9a35808a8..14f4feab05 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -38,7 +38,8 @@ namespace osu.Game.Screens.Multi.Components private OsuColour colours; private Box statusStrip; private UpdateableBeatmapSetCover cover; - private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow; + private ParticipantCount participantCount; + private FillFlowContainer topFlow, participantsFlow; private OsuSpriteText name, status; private BeatmapTypeInfo beatmapTypeInfo; private ScrollContainer participantsScroll; @@ -81,9 +82,6 @@ namespace osu.Game.Screens.Multi.Components { this.colours = colours; - ModeTypeInfo modeTypeInfo; - OsuSpriteText participants, participantsSlash, maxParticipants, beatmapAuthor; - Children = new Drawable[] { new Box @@ -120,32 +118,10 @@ namespace osu.Game.Screens.Multi.Components Padding = new MarginPadding(20), Children = new Drawable[] { - participantNumbersFlow = new FillFlowContainer + participantCount = new ParticipantCount { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - LayoutDuration = transition_duration, - Children = new[] - { - participants = new OsuSpriteText - { - TextSize = 30, - Font = @"Exo2.0-Bold" - }, - participantsSlash = new OsuSpriteText - { - Text = @"/", - TextSize = 30, - Font = @"Exo2.0-Light" - }, - maxParticipants = new OsuSpriteText - { - TextSize = 30, - Font = @"Exo2.0-Light" - }, - }, }, name = new OsuSpriteText { @@ -227,6 +203,7 @@ namespace osu.Game.Screens.Multi.Components nameBind.ValueChanged += n => name.Text = n; hostBind.ValueChanged += h => participantInfo.Host = h; typeBind.ValueChanged += t => beatmapTypeInfo.Type = t; + maxParticipantsBind.ValueChanged += m => participantCount.Max = m; statusBind.ValueChanged += displayStatus; beatmapBind.ValueChanged += b => @@ -235,24 +212,9 @@ namespace osu.Game.Screens.Multi.Components beatmapTypeInfo.Beatmap = b; }; - maxParticipantsBind.ValueChanged += m => - { - if (m == null) - { - participantsSlash.FadeOut(transition_duration); - maxParticipants.FadeOut(transition_duration); - } - else - { - participantsSlash.FadeIn(transition_duration); - maxParticipants.FadeIn(transition_duration); - maxParticipants.Text = m.ToString(); - } - }; - participantsBind.ValueChanged += p => { - participants.Text = p.Length.ToString(); + participantCount.Count = p.Length; participantInfo.Participants = p; participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)); }; @@ -282,7 +244,7 @@ namespace osu.Game.Screens.Multi.Components { cover.BeatmapSet = null; participantsFlow.FadeOut(transition_duration); - participantNumbersFlow.FadeOut(transition_duration); + participantCount.FadeOut(transition_duration); beatmapTypeInfo.FadeOut(transition_duration); name.FadeOut(transition_duration); participantInfo.FadeOut(transition_duration); @@ -292,7 +254,7 @@ namespace osu.Game.Screens.Multi.Components else { participantsFlow.FadeIn(transition_duration); - participantNumbersFlow.FadeIn(transition_duration); + participantCount.FadeIn(transition_duration); beatmapTypeInfo.FadeIn(transition_duration); name.FadeIn(transition_duration); participantInfo.FadeIn(transition_duration); From 4f73f6e0e02a62bfa6a10f0d2053a0c38ac2cc8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 29 May 2018 08:18:54 +0200 Subject: [PATCH 107/253] Add build tasks for visual tests and fix broken launch tasks --- .vscode/launch.json | 10 +++++----- .vscode/tasks.json | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index df5b11f63a..11141dc182 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -66,7 +66,7 @@ "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.0/osu.Game.Tests.dll" ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Debug, dotnet)", + "preLaunchTask": "Build tests (Debug, dotnet)", "env": {}, "console": "internalConsole" }, @@ -76,10 +76,10 @@ "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.0/osu.Game.Tests.dll" + "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.0/osu.Game.Tests.dll" ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Release, dotnet)", + "preLaunchTask": "Build tests (Release, dotnet)", "env": {}, "console": "internalConsole" }, @@ -92,7 +92,7 @@ "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.0/osu!.dll", ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Debug, dotnet)", + "preLaunchTask": "Build osu! (Debug, dotnet)", "env": {}, "console": "internalConsole" }, @@ -105,7 +105,7 @@ "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.0/osu!.dll", ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Release, dotnet)", + "preLaunchTask": "Build osu! (Release, dotnet)", "env": {}, "console": "internalConsole" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7144a584f3..0908ff6108 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -31,7 +31,7 @@ "problemMatcher": "$msCompile" }, { - "label": "Build (Debug, dotnet)", + "label": "Build osu! (Debug, dotnet)", "type": "shell", "command": "dotnet", "args": [ @@ -47,7 +47,7 @@ "problemMatcher": "$msCompile" }, { - "label": "Build (Release, dotnet)", + "label": "Build osu! (Release, dotnet)", "type": "shell", "command": "dotnet", "args": [ @@ -63,6 +63,39 @@ "group": "build", "problemMatcher": "$msCompile" }, + { + "label": "Build tests (Debug, dotnet)", + "type": "shell", + "command": "dotnet", + "args": [ + "build", + "--no-restore", + "osu.Game.Tests", + "/p:TargetFramework=netcoreapp2.0", + "/p:GenerateFullPaths=true", + "/m", + "/verbosity:m" + ], + "group": "build", + "problemMatcher": "$msCompile" + }, + { + "label": "Build tests (Release, dotnet)", + "type": "shell", + "command": "dotnet", + "args": [ + "build", + "--no-restore", + "osu.Game.Tests", + "/p:TargetFramework=netcoreapp2.0", + "/p:Configuration=Release", + "/p:GenerateFullPaths=true", + "/m", + "/verbosity:m" + ], + "group": "build", + "problemMatcher": "$msCompile" + }, { "label": "Restore (net471)", "type": "shell", From 2a87b851fae5d3fb783c936782155968006f1900 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 18:38:42 +0900 Subject: [PATCH 108/253] Add proper transaction rollback logic on exception --- osu.Game/Database/DatabaseWriteUsage.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/osu.Game/Database/DatabaseWriteUsage.cs b/osu.Game/Database/DatabaseWriteUsage.cs index 7858c1a0d1..07bebbf0c3 100644 --- a/osu.Game/Database/DatabaseWriteUsage.cs +++ b/osu.Game/Database/DatabaseWriteUsage.cs @@ -28,8 +28,19 @@ namespace osu.Game.Database if (isDisposed) return; isDisposed = true; - PerformedWrite |= Context.SaveChanges(transaction) > 0; - usageCompleted?.Invoke(this); + try + { + PerformedWrite |= Context.SaveChanges(transaction) > 0; + } + catch (Exception e) + { + transaction?.Rollback(); + throw; + } + finally + { + usageCompleted?.Invoke(this); + } } public void Dispose() From d4e7f08c20ce4311e9dba4ff1a6feade891d50aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 18:43:53 +0900 Subject: [PATCH 109/253] Bring entity framework up-to-date and re-enable transactions --- osu.Desktop/osu.Desktop.csproj | 6 +++--- osu.Game/Database/OsuDbContext.cs | 3 +-- osu.Game/osu.Game.csproj | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 3d64cab84e..3a35568f8f 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -1,4 +1,4 @@ - + net471;netcoreapp2.0 @@ -30,10 +30,10 @@ - + - + \ No newline at end of file diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index 1979ce3648..06503ffc5f 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -106,8 +106,7 @@ namespace osu.Game.Database public IDbContextTransaction BeginTransaction() { - // return Database.BeginTransaction(); - return null; + return Database.BeginTransaction(); } public int SaveChanges(IDbContextTransaction transaction = null) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1a75f1979a..afb656a260 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -17,7 +17,7 @@ - + From bcb04f616895f166cdfff223e781d11dda77aba0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 19:56:27 +0900 Subject: [PATCH 110/253] Improve transaction handling flexibility --- osu.Game/Database/ArchiveModelManager.cs | 66 +++++++++++++++++---- osu.Game/Database/DatabaseContextFactory.cs | 23 ++++++- osu.Game/Database/DatabaseWriteUsage.cs | 16 +++-- osu.Game/Database/OsuDbContext.cs | 13 ---- 4 files changed, 84 insertions(+), 34 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index e04559d547..28c25c873f 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -56,13 +56,42 @@ namespace osu.Game.Database // ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised) private ArchiveImportIPCChannel ipc; + private readonly List cachedEvents = new List(); + + private bool delayingEvents; + + private void cacheEvents() + { + delayingEvents = true; + } + + private void flushEvents(bool perform) + { + if (perform) + { + foreach (var a in cachedEvents) + a.Invoke(); + } + + cachedEvents.Clear(); + delayingEvents = false; + } + + private void handleEvent(Action a) + { + if (delayingEvents) + cachedEvents.Add(a); + else + a.Invoke(); + } + protected ArchiveModelManager(Storage storage, IDatabaseContextFactory contextFactory, MutableDatabaseBackedStore modelStore, IIpcHost importHost = null) { ContextFactory = contextFactory; ModelStore = modelStore; - ModelStore.ItemAdded += s => ItemAdded?.Invoke(s); - ModelStore.ItemRemoved += s => ItemRemoved?.Invoke(s); + ModelStore.ItemAdded += s => handleEvent(() => ItemAdded?.Invoke(s)); + ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s)); Files = new FileStore(contextFactory, storage); @@ -138,24 +167,37 @@ namespace osu.Game.Database /// The archive to be imported. public TModel Import(ArchiveReader archive) { - using (ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes. + TModel item = null; + cacheEvents(); + + try { - // create a new model (don't yet add to database) - var item = CreateModel(archive); + using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes. + { + if (!write.IsTransactionLeader) throw new InvalidOperationException($"Ensure there is no parent transaction so errors can correctly be handled by {this}"); - var existing = CheckForExisting(item); + // create a new model (don't yet add to database) + item = CreateModel(archive); - if (existing != null) return existing; + var existing = CheckForExisting(item); - item.Files = createFileInfos(archive, Files); + if (existing != null) return existing; - Populate(item, archive); + item.Files = createFileInfos(archive, Files); - // import to store - ModelStore.Add(item); + Populate(item, archive); - return item; + // import to store + ModelStore.Add(item); + } } + catch + { + item = null; + } + + flushEvents(item != null); + return item; } /// diff --git a/osu.Game/Database/DatabaseContextFactory.cs b/osu.Game/Database/DatabaseContextFactory.cs index 71960303b5..65a19e23c0 100644 --- a/osu.Game/Database/DatabaseContextFactory.cs +++ b/osu.Game/Database/DatabaseContextFactory.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using System.Threading; +using Microsoft.EntityFrameworkCore.Storage; using osu.Framework.Platform; namespace osu.Game.Database @@ -17,8 +19,12 @@ namespace osu.Game.Database private readonly object writeLock = new object(); private bool currentWriteDidWrite; + private bool currentWriteDidError; + private int currentWriteUsages; + private IDbContextTransaction currentWriteTransaction; + public DatabaseContextFactory(GameHost host) { this.host = host; @@ -40,9 +46,12 @@ namespace osu.Game.Database { Monitor.Enter(writeLock); + if (currentWriteTransaction == null) + currentWriteTransaction = threadContexts.Value.Database.BeginTransaction(); + Interlocked.Increment(ref currentWriteUsages); - return new DatabaseWriteUsage(threadContexts.Value, usageCompleted); + return new DatabaseWriteUsage(threadContexts.Value, usageCompleted) { IsTransactionLeader = currentWriteUsages == 1 }; } private void usageCompleted(DatabaseWriteUsage usage) @@ -52,16 +61,24 @@ namespace osu.Game.Database try { currentWriteDidWrite |= usage.PerformedWrite; + currentWriteDidError |= usage.Errors.Any(); if (usages > 0) return; + if (currentWriteDidError) + currentWriteTransaction.Rollback(); + else + currentWriteTransaction.Commit(); + + currentWriteTransaction = null; + currentWriteDidWrite = false; + currentWriteDidError = false; + if (currentWriteDidWrite) { // explicitly dispose to ensure any outstanding flushes happen as soon as possible (and underlying resources are purged). usage.Context.Dispose(); - currentWriteDidWrite = false; - // once all writes are complete, we want to refresh thread-specific contexts to make sure they don't have stale local caches. recycleThreadContexts(); } diff --git a/osu.Game/Database/DatabaseWriteUsage.cs b/osu.Game/Database/DatabaseWriteUsage.cs index 07bebbf0c3..8216c04b22 100644 --- a/osu.Game/Database/DatabaseWriteUsage.cs +++ b/osu.Game/Database/DatabaseWriteUsage.cs @@ -2,26 +2,31 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using Microsoft.EntityFrameworkCore.Storage; +using System.Collections.Generic; namespace osu.Game.Database { public class DatabaseWriteUsage : IDisposable { public readonly OsuDbContext Context; - private readonly IDbContextTransaction transaction; private readonly Action usageCompleted; public DatabaseWriteUsage(OsuDbContext context, Action onCompleted) { Context = context; - transaction = Context.BeginTransaction(); usageCompleted = onCompleted; } public bool PerformedWrite { get; private set; } private bool isDisposed; + public List Errors = new List(); + + /// + /// Whether this write usage will commit a transaction on completion. + /// If false, there is a parent usage responsible for transaction commit. + /// + public bool IsTransactionLeader = false; protected void Dispose(bool disposing) { @@ -30,12 +35,11 @@ namespace osu.Game.Database try { - PerformedWrite |= Context.SaveChanges(transaction) > 0; + PerformedWrite |= Context.SaveChanges() > 0; } catch (Exception e) { - transaction?.Rollback(); - throw; + Errors.Add(e); } finally { diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index 06503ffc5f..0ae197d62d 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -3,7 +3,6 @@ using System; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Logging; using osu.Framework.Logging; @@ -104,18 +103,6 @@ namespace osu.Game.Database modelBuilder.Entity().HasOne(b => b.BaseDifficulty); } - public IDbContextTransaction BeginTransaction() - { - return Database.BeginTransaction(); - } - - public int SaveChanges(IDbContextTransaction transaction = null) - { - var ret = base.SaveChanges(); - if (ret > 0) transaction?.Commit(); - return ret; - } - private class OsuDbLoggerFactory : ILoggerFactory { #region Disposal From 7b8211e6db51cd8b1d9a43f2172b55fd974c8a73 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 04:23:29 -0300 Subject: [PATCH 111/253] Add MultiplayerScreen.Type --- osu.Game/Screens/Multi/Header.cs | 8 ++++---- osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs | 3 ++- osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index de71b20007..fb4da45aca 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Multi { public const float HEIGHT = 121; - private readonly OsuSpriteText screenTitle; + private readonly OsuSpriteText screenType; private readonly HeaderBreadcrumbControl breadcrumbs; public Header(Screen initialScreen) @@ -67,7 +67,7 @@ namespace osu.Game.Screens.Multi Text = "multiplayer ", TextSize = 25, }, - screenTitle = new OsuSpriteText + screenType = new OsuSpriteText { TextSize = 25, Font = @"Exo2.0-Light", @@ -86,14 +86,14 @@ namespace osu.Game.Screens.Multi }, }; - breadcrumbs.Current.ValueChanged += s => screenTitle.Text = ((MultiplayerScreen)s).Title; + breadcrumbs.Current.ValueChanged += s => screenType.Text = ((MultiplayerScreen)s).Type; breadcrumbs.Current.TriggerChange(); } [BackgroundDependencyLoader] private void load(OsuColour colours) { - screenTitle.Colour = colours.Yellow; + screenType.Colour = colours.Yellow; breadcrumbs.StripColour = colours.Green; } diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 60ffe2c0b9..f0c93b1146 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -25,7 +25,8 @@ namespace osu.Game.Screens.Multi.Screens.Lounge protected readonly FillFlowContainer RoomsContainer; protected readonly RoomInspector Inspector; - public override string Title => "lounge"; + public override string Type => "lounge"; + public override string Title => "Lounge"; protected override Container TransitionContent => content; diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs index 191fe66037..cdfa17a7a6 100644 --- a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -15,6 +15,11 @@ namespace osu.Game.Screens.Multi.Screens protected virtual Container TransitionContent => Content; + /// + /// The type to display in the title of the . + /// + public abstract string Type { get; } + protected override void OnEntering(Screen last) { base.OnEntering(last); From a3287b8cf2e3734e606b20490c9f2f8d5ab4a962 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 21:45:05 +0900 Subject: [PATCH 112/253] Correctly rollback failed imports --- osu.Game/Database/ArchiveModelManager.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 28c25c873f..86af2fd0ed 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -58,13 +58,20 @@ namespace osu.Game.Database private readonly List cachedEvents = new List(); + /// + /// Allows delaying of outwards events until an operation is confirmed (at a database level). + /// private bool delayingEvents; - private void cacheEvents() - { - delayingEvents = true; - } + /// + /// Begin delaying outwards events. + /// + private void delayEvents() => delayingEvents = true; + /// + /// Flush delayed events and disable delaying. + /// + /// Whether the flushed events should be performed. private void flushEvents(bool perform) { if (perform) @@ -167,8 +174,8 @@ namespace osu.Game.Database /// The archive to be imported. public TModel Import(ArchiveReader archive) { - TModel item = null; - cacheEvents(); + TModel item; + delayEvents(); try { @@ -196,6 +203,7 @@ namespace osu.Game.Database item = null; } + // we only want to flush events after we've confirmed the write context didn't have any errors. flushEvents(item != null); return item; } From 80806be0471d1547e4b6af8b7b6f2ec520e780f4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 10:59:39 +0900 Subject: [PATCH 113/253] Don't start transactions for migration It looks like transactions are used internally during migration. --- osu.Game/Database/DatabaseContextFactory.cs | 11 ++++++----- osu.Game/Database/IDatabaseContextFactory.cs | 3 ++- osu.Game/Database/SingletonContextFactory.cs | 2 +- osu.Game/OsuGameBase.cs | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/osu.Game/Database/DatabaseContextFactory.cs b/osu.Game/Database/DatabaseContextFactory.cs index 65a19e23c0..ec408456e3 100644 --- a/osu.Game/Database/DatabaseContextFactory.cs +++ b/osu.Game/Database/DatabaseContextFactory.cs @@ -41,17 +41,18 @@ namespace osu.Game.Database /// Request a context for write usage. Can be consumed in a nested fashion (and will return the same underlying context). /// This method may block if a write is already active on a different thread. /// + /// Whether to start a transaction for this write. /// A usage containing a usable context. - public DatabaseWriteUsage GetForWrite() + public DatabaseWriteUsage GetForWrite(bool withTransaction = true) { Monitor.Enter(writeLock); - if (currentWriteTransaction == null) + if (currentWriteTransaction == null && withTransaction) currentWriteTransaction = threadContexts.Value.Database.BeginTransaction(); Interlocked.Increment(ref currentWriteUsages); - return new DatabaseWriteUsage(threadContexts.Value, usageCompleted) { IsTransactionLeader = currentWriteUsages == 1 }; + return new DatabaseWriteUsage(threadContexts.Value, usageCompleted) { IsTransactionLeader = currentWriteTransaction != null && currentWriteUsages == 1 }; } private void usageCompleted(DatabaseWriteUsage usage) @@ -66,9 +67,9 @@ namespace osu.Game.Database if (usages > 0) return; if (currentWriteDidError) - currentWriteTransaction.Rollback(); + currentWriteTransaction?.Rollback(); else - currentWriteTransaction.Commit(); + currentWriteTransaction?.Commit(); currentWriteTransaction = null; currentWriteDidWrite = false; diff --git a/osu.Game/Database/IDatabaseContextFactory.cs b/osu.Game/Database/IDatabaseContextFactory.cs index 372e1770e4..d38d15b252 100644 --- a/osu.Game/Database/IDatabaseContextFactory.cs +++ b/osu.Game/Database/IDatabaseContextFactory.cs @@ -14,7 +14,8 @@ namespace osu.Game.Database /// Request a context for write usage. Can be consumed in a nested fashion (and will return the same underlying context). /// This method may block if a write is already active on a different thread. /// + /// Whether to start a transaction for this write. /// A usage containing a usable context. - DatabaseWriteUsage GetForWrite(); + DatabaseWriteUsage GetForWrite(bool withTransaction = true); } } diff --git a/osu.Game/Database/SingletonContextFactory.cs b/osu.Game/Database/SingletonContextFactory.cs index 74951e8433..ce3fbf6881 100644 --- a/osu.Game/Database/SingletonContextFactory.cs +++ b/osu.Game/Database/SingletonContextFactory.cs @@ -14,6 +14,6 @@ namespace osu.Game.Database public OsuDbContext Get() => context; - public DatabaseWriteUsage GetForWrite() => new DatabaseWriteUsage(context, null); + public DatabaseWriteUsage GetForWrite(bool withTransaction = true) => new DatabaseWriteUsage(context, null); } } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index a3a081d6d1..b9d32a6322 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -208,7 +208,7 @@ namespace osu.Game { try { - using (var db = contextFactory.GetForWrite()) + using (var db = contextFactory.GetForWrite(false)) db.Context.Migrate(); } catch (MigrationFailedException e) @@ -220,7 +220,7 @@ namespace osu.Game contextFactory.ResetDatabase(); Logger.Log("Database purged successfully.", LoggingTarget.Database, LogLevel.Important); - using (var db = contextFactory.GetForWrite()) + using (var db = contextFactory.GetForWrite(false)) db.Context.Migrate(); } } From 72da640059e8aa05f193d0d3800bc0d6fee50cf6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 11:37:47 +0900 Subject: [PATCH 114/253] Change order of event firing in Update calls A remove event should not be fired before the update is successful. --- osu.Game/Database/MutableDatabaseBackedStore.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Database/MutableDatabaseBackedStore.cs b/osu.Game/Database/MutableDatabaseBackedStore.cs index 8569d81f01..69a1f57cc4 100644 --- a/osu.Game/Database/MutableDatabaseBackedStore.cs +++ b/osu.Game/Database/MutableDatabaseBackedStore.cs @@ -50,11 +50,10 @@ namespace osu.Game.Database /// The item to update. public void Update(T item) { - ItemRemoved?.Invoke(item); - using (var usage = ContextFactory.GetForWrite()) usage.Context.Update(item); + ItemRemoved?.Invoke(item); ItemAdded?.Invoke(item); } From 015fd9d0e7d256410dea6fe583b3e5e7c0043a02 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 11:44:42 +0900 Subject: [PATCH 115/253] Fix loading test method returning oldest import rather than newest --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index f60caf2397..740692395a 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -219,7 +219,7 @@ namespace osu.Game.Tests.Beatmaps.IO waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000); - return imported.FirstOrDefault(); + return imported.LastOrDefault(); } private void deleteBeatmapSet(BeatmapSetInfo imported, OsuGameBase osu) From cc081cad5a0d78367420b31bfdb8b7a2baff0686 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 11:57:11 +0900 Subject: [PATCH 116/253] Simplify test osz instantiation --- .../Beatmaps/IO/ImportBeatmapTest.cs | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 740692395a..38fd6e649b 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -162,8 +162,7 @@ namespace osu.Game.Tests.Beatmaps.IO var osu = loadOsu(host); - var temp = prepareTempCopy(osz_path); - Assert.IsTrue(File.Exists(temp)); + var temp = createTemporaryBeatmap(); var importer = new ArchiveImportIPCChannel(client); if (!importer.ImportAsync(temp).Wait(10000)) @@ -188,8 +187,7 @@ namespace osu.Game.Tests.Beatmaps.IO try { var osu = loadOsu(host); - var temp = prepareTempCopy(osz_path); - Assert.IsTrue(File.Exists(temp), "Temporary file copy never substantiated"); + var temp = createTemporaryBeatmap(); using (File.OpenRead(temp)) osu.Dependencies.Get().Import(temp); ensureLoaded(osu); @@ -203,11 +201,16 @@ namespace osu.Game.Tests.Beatmaps.IO } } - private BeatmapSetInfo loadOszIntoOsu(OsuGameBase osu) + private string createTemporaryBeatmap() { - var temp = prepareTempCopy(osz_path); - + var temp = new FileInfo(osz_path).CopyTo(Path.GetTempFileName(), true).FullName; Assert.IsTrue(File.Exists(temp)); + return temp; + } + + private BeatmapSetInfo loadOszIntoOsu(OsuGameBase osu, string path = null) + { + var temp = path ?? createTemporaryBeatmap(); var manager = osu.Dependencies.Get(); @@ -232,12 +235,6 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(manager.QueryBeatmapSets(_ => true).First().DeletePending); } - private string prepareTempCopy(string path) - { - var temp = Path.GetTempFileName(); - return new FileInfo(path).CopyTo(temp, true).FullName; - } - private OsuGameBase loadOsu(GameHost host) { var osu = new OsuGameBase(); From 3d3026a80cdce1dc15f04b88f242120ec09cfffc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 13:48:14 +0900 Subject: [PATCH 117/253] Report any error during import to the write context to allow for rollback --- osu.Game/Database/ArchiveModelManager.cs | 26 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 86af2fd0ed..99f1e9f581 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -181,21 +181,29 @@ namespace osu.Game.Database { using (var write = ContextFactory.GetForWrite()) // used to share a context for full import. keep in mind this will block all writes. { - if (!write.IsTransactionLeader) throw new InvalidOperationException($"Ensure there is no parent transaction so errors can correctly be handled by {this}"); + try + { + if (!write.IsTransactionLeader) throw new InvalidOperationException($"Ensure there is no parent transaction so errors can correctly be handled by {this}"); - // create a new model (don't yet add to database) - item = CreateModel(archive); + // create a new model (don't yet add to database) + item = CreateModel(archive); - var existing = CheckForExisting(item); + var existing = CheckForExisting(item); - if (existing != null) return existing; + if (existing != null) return existing; - item.Files = createFileInfos(archive, Files); + item.Files = createFileInfos(archive, Files); - Populate(item, archive); + Populate(item, archive); - // import to store - ModelStore.Add(item); + // import to store + ModelStore.Add(item); + } + catch (Exception e) + { + write.Errors.Add(e); + throw; + } } } catch From 203691b1c776728fb48564c51bef60a20bc0d499 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 13:48:27 +0900 Subject: [PATCH 118/253] Add import rollback test --- .../Beatmaps/IO/ImportBeatmapTest.cs | 75 +++++++++++++++++-- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 38fd6e649b..586217a05f 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -12,6 +12,7 @@ using osu.Framework.Platform; using osu.Game.IPC; using osu.Framework.Allocation; using osu.Game.Beatmaps; +using SharpCompress.Archives.Zip; namespace osu.Game.Tests.Beatmaps.IO { @@ -77,8 +78,69 @@ namespace osu.Game.Tests.Beatmaps.IO var manager = osu.Dependencies.Get(); - Assert.IsTrue(manager.GetAllUsableBeatmapSets().Count == 1); - Assert.IsTrue(manager.QueryBeatmapSets(_ => true).ToList().Count == 1); + Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); + Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); + } + finally + { + host.Exit(); + } + } + } + + [Test] + public void TestRollbackOnFailure() + { + //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. + using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestRollbackOnFailure")) + { + try + { + var osu = loadOsu(host); + var manager = osu.Dependencies.Get(); + + int fireCount = 0; + + // ReSharper disable once AccessToModifiedClosure + manager.ItemAdded += _ => fireCount++; + manager.ItemRemoved += _ => fireCount++; + + var imported = loadOszIntoOsu(osu); + + Assert.AreEqual(0, fireCount -= 1); + + imported.Hash += "-changed"; + manager.Update(imported); + + Assert.AreEqual(0, fireCount -= 2); + + var breakTemp = createTemporaryBeatmap(); + + MemoryStream brokenOsu = new MemoryStream(new byte[] { 1, 3, 3, 7 }); + MemoryStream brokenOsz = new MemoryStream(File.ReadAllBytes(breakTemp)); + + File.Delete(breakTemp); + + using (var outStream = File.Open(breakTemp, FileMode.CreateNew)) + using (var zip = ZipArchive.Open(brokenOsz)) + { + zip.AddEntry("broken.osu", brokenOsu, false); + zip.SaveTo(outStream, SharpCompress.Common.CompressionType.Deflate); + } + + Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); + Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); + Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); + + // this will trigger purging of the existing beatmap (online set id match) but should rollback due to broken osu. + manager.Import(breakTemp); + + // no events should be fired in the case of a rollback. + Assert.AreEqual(0, fireCount); + + Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); + Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); + Assert.AreEqual(12, manager.QueryBeatmaps(_ => true).ToList().Count); } finally { @@ -100,18 +162,17 @@ namespace osu.Game.Tests.Beatmaps.IO var imported = loadOszIntoOsu(osu); - //var change = manager.QueryBeatmapSets(_ => true).First(); imported.Hash += "-changed"; manager.Update(imported); var importedSecondTime = loadOszIntoOsu(osu); - // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. Assert.IsTrue(imported.ID != importedSecondTime.ID); Assert.IsTrue(imported.Beatmaps.First().ID < importedSecondTime.Beatmaps.First().ID); - Assert.IsTrue(manager.GetAllUsableBeatmapSets().Count == 1); - Assert.IsTrue(manager.QueryBeatmapSets(_ => true).ToList().Count == 1); + // only one beatmap will exist as the online set ID matched, causing purging of the first import. + Assert.AreEqual(1, manager.GetAllUsableBeatmapSets().Count); + Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); } finally { @@ -231,7 +292,7 @@ namespace osu.Game.Tests.Beatmaps.IO manager.Delete(imported); Assert.IsTrue(manager.GetAllUsableBeatmapSets().Count == 0); - Assert.IsTrue(manager.QueryBeatmapSets(_ => true).ToList().Count == 1); + Assert.AreEqual(1, manager.QueryBeatmapSets(_ => true).ToList().Count); Assert.IsTrue(manager.QueryBeatmapSets(_ => true).First().DeletePending); } From c1f416b1ccb6cea656d90c128c120048d9619a81 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 14:25:27 +0900 Subject: [PATCH 119/253] Add back missing rethrow --- osu.Game/Database/DatabaseWriteUsage.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Database/DatabaseWriteUsage.cs b/osu.Game/Database/DatabaseWriteUsage.cs index 8216c04b22..64ab24e824 100644 --- a/osu.Game/Database/DatabaseWriteUsage.cs +++ b/osu.Game/Database/DatabaseWriteUsage.cs @@ -40,6 +40,7 @@ namespace osu.Game.Database catch (Exception e) { Errors.Add(e); + throw; } finally { From de8c4e6d564da5f2cc4aa55518cd8210985260c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 16:13:02 +0900 Subject: [PATCH 120/253] Remove unique constraints on hash columns We are going to allow multiple instances of the same beatmap info hash as they could be in different beatmap sets. --- osu.Game/Database/OsuDbContext.cs | 4 +- ...54_RemoveUniqueHashConstraints.Designer.cs | 377 ++++++++++++++++++ ...80529055154_RemoveUniqueHashConstraints.cs | 53 +++ .../Migrations/OsuDbContextModelSnapshot.cs | 16 +- 4 files changed, 441 insertions(+), 9 deletions(-) create mode 100644 osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.Designer.cs create mode 100644 osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.cs diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index 0ae197d62d..7758b3eb25 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -82,8 +82,8 @@ namespace osu.Game.Database base.OnModelCreating(modelBuilder); modelBuilder.Entity().HasIndex(b => b.OnlineBeatmapID).IsUnique(); - modelBuilder.Entity().HasIndex(b => b.MD5Hash).IsUnique(); - modelBuilder.Entity().HasIndex(b => b.Hash).IsUnique(); + modelBuilder.Entity().HasIndex(b => b.MD5Hash); + modelBuilder.Entity().HasIndex(b => b.Hash); modelBuilder.Entity().HasIndex(b => b.OnlineBeatmapSetID).IsUnique(); modelBuilder.Entity().HasIndex(b => b.DeletePending); diff --git a/osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.Designer.cs b/osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.Designer.cs new file mode 100644 index 0000000000..f28408bfb3 --- /dev/null +++ b/osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.Designer.cs @@ -0,0 +1,377 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using osu.Game.Database; +using System; + +namespace osu.Game.Migrations +{ + [DbContext(typeof(OsuDbContext))] + [Migration("20180529055154_RemoveUniqueHashConstraints")] + partial class RemoveUniqueHashConstraints + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.0.3-rtm-10026"); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("ApproachRate"); + + b.Property("CircleSize"); + + b.Property("DrainRate"); + + b.Property("OverallDifficulty"); + + b.Property("SliderMultiplier"); + + b.Property("SliderTickRate"); + + b.HasKey("ID"); + + b.ToTable("BeatmapDifficulty"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("AudioLeadIn"); + + b.Property("BaseDifficultyID"); + + b.Property("BeatDivisor"); + + b.Property("BeatmapSetInfoID"); + + b.Property("Countdown"); + + b.Property("DistanceSpacing"); + + b.Property("GridSize"); + + b.Property("Hash"); + + b.Property("Hidden"); + + b.Property("LetterboxInBreaks"); + + b.Property("MD5Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapID"); + + b.Property("Path"); + + b.Property("RulesetID"); + + b.Property("SpecialStyle"); + + b.Property("StackLeniency"); + + b.Property("StarDifficulty"); + + b.Property("StoredBookmarks"); + + b.Property("TimelineZoom"); + + b.Property("Version"); + + b.Property("WidescreenStoryboard"); + + b.HasKey("ID"); + + b.HasIndex("BaseDifficultyID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("Hash"); + + b.HasIndex("MD5Hash"); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("BeatmapInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Artist"); + + b.Property("ArtistUnicode"); + + b.Property("AudioFile"); + + b.Property("AuthorString") + .HasColumnName("Author"); + + b.Property("BackgroundFile"); + + b.Property("PreviewTime"); + + b.Property("Source"); + + b.Property("Tags"); + + b.Property("Title"); + + b.Property("TitleUnicode"); + + b.HasKey("ID"); + + b.ToTable("BeatmapMetadata"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("BeatmapSetInfoID"); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.HasKey("ID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("FileInfoID"); + + b.ToTable("BeatmapSetFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapSetID"); + + b.Property("Protected"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapSetID") + .IsUnique(); + + b.ToTable("BeatmapSetInfo"); + }); + + modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntKey") + .HasColumnName("Key"); + + b.Property("RulesetID"); + + b.Property("StringValue") + .HasColumnName("Value"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntAction") + .HasColumnName("Action"); + + b.Property("KeysString") + .HasColumnName("Keys"); + + b.Property("RulesetID"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("IntAction"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("KeyBinding"); + }); + + modelBuilder.Entity("osu.Game.IO.FileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Hash"); + + b.Property("ReferenceCount"); + + b.HasKey("ID"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("ReferenceCount"); + + b.ToTable("FileInfo"); + }); + + modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Available"); + + b.Property("InstantiationInfo"); + + b.Property("Name"); + + b.Property("ShortName"); + + b.HasKey("ID"); + + b.HasIndex("Available"); + + b.HasIndex("ShortName") + .IsUnique(); + + b.ToTable("RulesetInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("SkinInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("SkinInfoID"); + + b.ToTable("SkinFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Creator"); + + b.Property("DeletePending"); + + b.Property("Name"); + + b.HasKey("ID"); + + b.ToTable("SkinInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty") + .WithMany() + .HasForeignKey("BaseDifficultyID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") + .WithMany("Beatmaps") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("Beatmaps") + .HasForeignKey("MetadataID"); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") + .WithMany("Files") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("BeatmapSets") + .HasForeignKey("MetadataID"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Skinning.SkinInfo") + .WithMany("Files") + .HasForeignKey("SkinInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.cs b/osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.cs new file mode 100644 index 0000000000..fe8c983a3f --- /dev/null +++ b/osu.Game/Migrations/20180529055154_RemoveUniqueHashConstraints.cs @@ -0,0 +1,53 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; + +namespace osu.Game.Migrations +{ + public partial class RemoveUniqueHashConstraints : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_BeatmapInfo_Hash", + table: "BeatmapInfo"); + + migrationBuilder.DropIndex( + name: "IX_BeatmapInfo_MD5Hash", + table: "BeatmapInfo"); + + migrationBuilder.CreateIndex( + name: "IX_BeatmapInfo_Hash", + table: "BeatmapInfo", + column: "Hash"); + + migrationBuilder.CreateIndex( + name: "IX_BeatmapInfo_MD5Hash", + table: "BeatmapInfo", + column: "MD5Hash"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_BeatmapInfo_Hash", + table: "BeatmapInfo"); + + migrationBuilder.DropIndex( + name: "IX_BeatmapInfo_MD5Hash", + table: "BeatmapInfo"); + + migrationBuilder.CreateIndex( + name: "IX_BeatmapInfo_Hash", + table: "BeatmapInfo", + column: "Hash", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_BeatmapInfo_MD5Hash", + table: "BeatmapInfo", + column: "MD5Hash", + unique: true); + } + } +} diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index 2abbe7785f..d750d50b5b 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -1,7 +1,11 @@ // using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; using osu.Game.Database; +using System; namespace osu.Game.Migrations { @@ -12,7 +16,7 @@ namespace osu.Game.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); + .HasAnnotation("ProductVersion", "2.0.3-rtm-10026"); modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => { @@ -27,9 +31,9 @@ namespace osu.Game.Migrations b.Property("OverallDifficulty"); - b.Property("SliderMultiplier"); + b.Property("SliderMultiplier"); - b.Property("SliderTickRate"); + b.Property("SliderTickRate"); b.HasKey("ID"); @@ -91,11 +95,9 @@ namespace osu.Game.Migrations b.HasIndex("BeatmapSetInfoID"); - b.HasIndex("Hash") - .IsUnique(); + b.HasIndex("Hash"); - b.HasIndex("MD5Hash") - .IsUnique(); + b.HasIndex("MD5Hash"); b.HasIndex("MetadataID"); From 47d88a48a246064a753499882cbc07e1ed721250 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 16:14:09 +0900 Subject: [PATCH 121/253] Add logging on import processes --- osu.Game/Beatmaps/BeatmapManager.cs | 3 ++- osu.Game/Database/ArchiveModelManager.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 36fde8a319..b7bece9492 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -107,6 +107,7 @@ namespace osu.Game.Beatmaps { Delete(existingOnlineId); beatmaps.PurgeDeletable(s => s.ID == existingOnlineId.ID); + Logger.Log($"Found existing beatmap set with same OnlineBeatmapSetID ({model.OnlineBeatmapSetID}). It has been purged.", LoggingTarget.Database); } } @@ -303,7 +304,7 @@ namespace osu.Game.Beatmaps { // let's make sure there are actually .osu files to import. string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu")); - if (string.IsNullOrEmpty(mapName)) throw new InvalidOperationException("No beatmap files found in the map folder."); + if (string.IsNullOrEmpty(mapName)) throw new InvalidOperationException("No beatmap files found in this beatmap archive."); BeatmapMetadata metadata; using (var stream = new StreamReader(reader.GetStream(mapName))) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 99f1e9f581..74c7b3df5d 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -190,7 +190,11 @@ namespace osu.Game.Database var existing = CheckForExisting(item); - if (existing != null) return existing; + if (existing != null) + { + Logger.Log($"Found existing {typeof(TModel)} for {archive.Name} (ID {existing.ID}). Skipping import.", LoggingTarget.Database); + return existing; + } item.Files = createFileInfos(archive, Files); @@ -205,9 +209,12 @@ namespace osu.Game.Database throw; } } + + Logger.Log($"Import of {archive.Name} successfully completed!", LoggingTarget.Database); } catch { + Logger.Log($"Import of {archive.Name} failed and has been rolled back.", LoggingTarget.Database); item = null; } From 0adc16f9bd4836030dde06cae1248d35a07f384f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 16:15:44 +0900 Subject: [PATCH 122/253] Handle online ID mismatches and clashes on beatmap import --- osu.Game/Beatmaps/BeatmapManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index b7bece9492..abc0351a82 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -81,7 +81,7 @@ namespace osu.Game.Beatmaps protected override void Populate(BeatmapSetInfo model, ArchiveReader archive) { - model.Beatmaps = createBeatmapDifficulties(archive); + model.Beatmaps = createBeatmapDifficulties(model, archive); // remove metadata from difficulties where it matches the set foreach (BeatmapInfo b in model.Beatmaps) @@ -322,7 +322,7 @@ namespace osu.Game.Beatmaps /// /// Create all required s for the provided archive. /// - private List createBeatmapDifficulties(ArchiveReader reader) + private List createBeatmapDifficulties(BeatmapSetInfo model, ArchiveReader reader) { var beatmapInfos = new List(); @@ -342,6 +342,14 @@ namespace osu.Game.Beatmaps beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash(); beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash(); + // ensure we have the same online set ID as the set itself. + beatmap.BeatmapInfo.OnlineBeatmapSetID = model.OnlineBeatmapSetID; + beatmap.BeatmapInfo.Metadata.OnlineBeatmapSetID = model.OnlineBeatmapSetID; + + // check that no existing beatmap exists that is imported with the same online beatmap ID. if so, give it precedence. + if (beatmap.BeatmapInfo.OnlineBeatmapID.HasValue && QueryBeatmap(b => b.OnlineBeatmapID.Value == beatmap.BeatmapInfo.OnlineBeatmapID.Value) != null) + beatmap.BeatmapInfo.OnlineBeatmapID = null; + RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID); beatmap.BeatmapInfo.Ruleset = ruleset; From 749a69567b7bf5a26123b361b0be743f38d7ebe3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 16:18:20 +0900 Subject: [PATCH 123/253] Add EF tooling references --- osu.Desktop/osu.Desktop.csproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 3a35568f8f..af027da2fc 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -20,6 +20,8 @@ osu.Desktop.Program + + @@ -36,4 +38,8 @@ + + + + \ No newline at end of file From 6f72e5a876762bb5d10b28b4d8da24ae5b5ddb71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 29 May 2018 10:27:21 +0200 Subject: [PATCH 124/253] Fix Debug mode instead of Release mode for mono debug target --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 11141dc182..32c82685c0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,7 +22,7 @@ }, "type": "mono", "request": "launch", - "program": "${workspaceRoot}/osu.Game.Tests/bin/Debug/net471/osu.Game.Tests.exe", + "program": "${workspaceRoot}/osu.Game.Tests/bin/Release/net471/osu.Game.Tests.exe", "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, msbuild)", "runtimeExecutable": null, From 4a18951cce0279731bf7afae07f330dda4d2d37f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 18:37:45 +0900 Subject: [PATCH 125/253] Report full error to log file --- osu.Game/Database/ArchiveModelManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 99f1e9f581..6a31182370 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -206,8 +206,9 @@ namespace osu.Game.Database } } } - catch + catch (Exception e) { + Logger.Error(e, $"Import of {archive.Name} failed and has been rolled back.", LoggingTarget.Database); item = null; } From c18a5b5ac8d089c88146d3b723e10def14e27a38 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 19:31:26 +0900 Subject: [PATCH 126/253] Fix importing long filenames from stable --- osu.Desktop/OsuGameDesktop.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a495d7048d..844db4a80f 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -12,6 +12,7 @@ using osu.Framework.Platform; using osu.Game; using OpenTK.Input; using Microsoft.Win32; +using osu.Framework.Platform.Windows; namespace osu.Desktop { @@ -40,7 +41,7 @@ namespace osu.Desktop /// /// A method of accessing an osu-stable install in a controlled fashion. /// - private class StableStorage : DesktopStorage + private class StableStorage : WindowsStorage { protected override string LocateBasePath() { From 31ab6f240841b5be96077c72e7761109e690c5e5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 May 2018 19:43:52 +0900 Subject: [PATCH 127/253] Fix event flushing sticking on early return --- osu.Game/Database/ArchiveModelManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 6a31182370..62d8c16946 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -174,7 +174,7 @@ namespace osu.Game.Database /// The archive to be imported. public TModel Import(ArchiveReader archive) { - TModel item; + TModel item = null; delayEvents(); try @@ -211,9 +211,12 @@ namespace osu.Game.Database Logger.Error(e, $"Import of {archive.Name} failed and has been rolled back.", LoggingTarget.Database); item = null; } + finally + { + // we only want to flush events after we've confirmed the write context didn't have any errors. + flushEvents(item != null); + } - // we only want to flush events after we've confirmed the write context didn't have any errors. - flushEvents(item != null); return item; } From e23e2bd3485045eb079b4c69f71b5cdf50b98260 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 13:37:52 +0900 Subject: [PATCH 128/253] Fix recycling never being performed due to incorrect ordering --- osu.Game/Database/DatabaseContextFactory.cs | 33 +++++++++++---------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/osu.Game/Database/DatabaseContextFactory.cs b/osu.Game/Database/DatabaseContextFactory.cs index ec408456e3..f57246453e 100644 --- a/osu.Game/Database/DatabaseContextFactory.cs +++ b/osu.Game/Database/DatabaseContextFactory.cs @@ -64,24 +64,25 @@ namespace osu.Game.Database currentWriteDidWrite |= usage.PerformedWrite; currentWriteDidError |= usage.Errors.Any(); - if (usages > 0) return; - - if (currentWriteDidError) - currentWriteTransaction?.Rollback(); - else - currentWriteTransaction?.Commit(); - - currentWriteTransaction = null; - currentWriteDidWrite = false; - currentWriteDidError = false; - - if (currentWriteDidWrite) + if (usages == 0) { - // explicitly dispose to ensure any outstanding flushes happen as soon as possible (and underlying resources are purged). - usage.Context.Dispose(); + if (currentWriteDidError) + currentWriteTransaction?.Rollback(); + else + currentWriteTransaction?.Commit(); - // once all writes are complete, we want to refresh thread-specific contexts to make sure they don't have stale local caches. - recycleThreadContexts(); + if (currentWriteDidWrite || currentWriteDidError) + { + // explicitly dispose to ensure any outstanding flushes happen as soon as possible (and underlying resources are purged). + usage.Context.Dispose(); + + // once all writes are complete, we want to refresh thread-specific contexts to make sure they don't have stale local caches. + recycleThreadContexts(); + } + + currentWriteTransaction = null; + currentWriteDidWrite = false; + currentWriteDidError = false; } } finally From 4a7de043e080aeb087de9d67eb7b3627a3471bf7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 13:43:25 +0900 Subject: [PATCH 129/253] Recycle all contexts on beginning a write operation for the time being --- osu.Game/Database/DatabaseContextFactory.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Database/DatabaseContextFactory.cs b/osu.Game/Database/DatabaseContextFactory.cs index f57246453e..a1d371f431 100644 --- a/osu.Game/Database/DatabaseContextFactory.cs +++ b/osu.Game/Database/DatabaseContextFactory.cs @@ -48,7 +48,14 @@ namespace osu.Game.Database Monitor.Enter(writeLock); if (currentWriteTransaction == null && withTransaction) + { + // this mitigates the fact that changes on tracked entities will not be rolled back with the transaction by ensuring write operations are always executed in isolated contexts. + // if this results in sub-optimal efficiency, we may need to look into removing Database-level transactions in favour of running SaveChanges where we currently commit the transaction. + if (threadContexts.IsValueCreated) + recycleThreadContexts(); + currentWriteTransaction = threadContexts.Value.Database.BeginTransaction(); + } Interlocked.Increment(ref currentWriteUsages); From eb893174947ae5cf8d050d932b27658cfab990cb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 13:43:43 +0900 Subject: [PATCH 130/253] Remove performance optimisation tracking disables to keep things simple for now --- osu.Game/Database/ArchiveModelManager.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 62d8c16946..1505ac0549 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -240,12 +240,8 @@ namespace osu.Game.Database /// The item to delete. public void Delete(TModel item) { - using (var usage = ContextFactory.GetForWrite()) + using (ContextFactory.GetForWrite()) { - var context = usage.Context; - - context.ChangeTracker.AutoDetectChangesEnabled = false; - // re-fetch the model on the import context. var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).First(s => s.ID == item.ID); @@ -253,8 +249,6 @@ namespace osu.Game.Database if (ModelStore.Delete(foundModel)) Files.Dereference(foundModel.Files.Select(f => f.FileInfo).ToArray()); - - context.ChangeTracker.AutoDetectChangesEnabled = true; } } From 54e53f71909258c67383cf02d6ab5674f84f5609 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 15:44:35 +0900 Subject: [PATCH 131/253] Fix player getting loaded when exiting song select --- .../Screens/Select/Carousel/DrawableCarouselBeatmap.cs | 2 +- osu.Game/Screens/Select/EditSongSelect.cs | 2 +- osu.Game/Screens/Select/MatchSongSelect.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 10 ++++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs index f39952dc31..c5996327b9 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Select.Carousel if (songSelect != null) { - startRequested = songSelect.FinaliseSelection; + startRequested = b => songSelect.FinaliseSelection(b); editRequested = songSelect.Edit; } diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index bca009e2c1..e1d71fdd05 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -7,7 +7,7 @@ namespace osu.Game.Screens.Select { protected override bool ShowFooter => false; - protected override bool OnSelectionFinalised() + protected override bool OnStart() { Exit(); return true; diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 3ffac591f3..a0c96d0cee 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -5,7 +5,7 @@ namespace osu.Game.Screens.Select { public class MatchSongSelect : SongSelect { - protected override bool OnSelectionFinalised() + protected override bool OnStart() { Schedule(() => { diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 7992930c45..8ce40fcfa0 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -137,7 +137,7 @@ namespace osu.Game.Screens.Select return false; } - protected override bool OnSelectionFinalised() + protected override bool OnStart() { if (player != null) return false; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4ffa9e2a90..cc725e7f05 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -227,7 +227,8 @@ namespace osu.Game.Screens.Select /// Call to make a selection and perform the default action for this SongSelect. /// /// An optional beatmap to override the current carousel selection. - public void FinaliseSelection(BeatmapInfo beatmap = null) + /// Whether to trigger . + public void FinaliseSelection(BeatmapInfo beatmap = null, bool performStartAction = true) { // if we have a pending filter operation, we want to run it now. // it could change selection (ie. if the ruleset has been changed). @@ -243,14 +244,15 @@ namespace osu.Game.Screens.Select selectionChangedDebounce = null; } - OnSelectionFinalised(); + if (performStartAction) + OnStart(); } /// /// Called when a selection is made. /// /// If a resultant action occurred that takes the user away from SongSelect. - protected abstract bool OnSelectionFinalised(); + protected abstract bool OnStart(); private ScheduledDelegate selectionChangedDebounce; @@ -395,7 +397,7 @@ namespace osu.Game.Screens.Select protected override bool OnExiting(Screen next) { - FinaliseSelection(); + FinaliseSelection(performStartAction: false); beatmapInfoWedge.State = Visibility.Hidden; From 5872b61988d2386dfce5e488d882395ebdf36563 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 15:47:31 +0900 Subject: [PATCH 132/253] Fix potential double-disposal of player if PlayerLoader is finalised --- osu.Game/Screens/Play/PlayerLoader.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 9c8961498a..2d5bc889c3 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -209,8 +209,11 @@ namespace osu.Game.Screens.Play { base.Dispose(isDisposing); - // if the player never got pushed, we should explicitly dispose it. - loadTask?.ContinueWith(_ => player.Dispose()); + if (isDisposing) + { + // if the player never got pushed, we should explicitly dispose it. + loadTask?.ContinueWith(_ => player.Dispose()); + } } private class BeatmapMetadataDisplay : Container From a28e71995d818c500c043fc5b83253d5ae57520f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 16:15:00 +0900 Subject: [PATCH 133/253] Offload database query to task Allows song select to load a touch faster, in theory. --- osu.Game/Beatmaps/BeatmapManager.cs | 8 +++++++- osu.Game/Screens/Select/SongSelect.cs | 9 +-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 36fde8a319..83f3fe7a35 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -241,7 +241,13 @@ namespace osu.Game.Beatmaps /// Returns a list of all usable s. /// /// A list of available . - public List GetAllUsableBeatmapSets() => beatmaps.ConsumableItems.Where(s => !s.DeletePending && !s.Protected).ToList(); + public List GetAllUsableBeatmapSets() => GetAllUsableBeatmapSetsEnumerable().ToList(); + + /// + /// Returns a list of all usable s. + /// + /// A list of available . + public IQueryable GetAllUsableBeatmapSetsEnumerable() => beatmaps.ConsumableItems.Where(s => !s.DeletePending && !s.Protected); /// /// Perform a lookup query on available s. diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4ffa9e2a90..41aba9a126 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Threading; using OpenTK; using OpenTK.Input; using osu.Framework.Allocation; @@ -63,8 +62,6 @@ namespace osu.Game.Screens.Select private SampleChannel sampleChangeDifficulty; private SampleChannel sampleChangeBeatmap; - private CancellationTokenSource initialAddSetsTask; - private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); @@ -207,9 +204,7 @@ namespace osu.Game.Screens.Select sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty"); sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand"); - initialAddSetsTask = new CancellationTokenSource(); - - Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets(); + Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSetsEnumerable(); Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled; Beatmap.TriggerChange(); @@ -417,8 +412,6 @@ namespace osu.Game.Screens.Select beatmaps.BeatmapHidden -= onBeatmapHidden; beatmaps.BeatmapRestored -= onBeatmapRestored; } - - initialAddSetsTask?.Cancel(); } /// From 6d6b186fb2625988f911ad01db16df6c11e175bc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 19:25:39 +0900 Subject: [PATCH 134/253] Fix delayed logo animations playing even if screen has already been exited --- osu.Game/Screens/OsuScreen.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index cd9cbe119f..db9807b9ab 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -231,7 +231,10 @@ namespace osu.Game.Screens private void applyArrivingDefaults(bool isResuming) { - logo.AppendAnimatingAction(() => LogoArriving(logo, isResuming), true); + logo.AppendAnimatingAction(() => + { + if (IsCurrentScreen) LogoArriving(logo, isResuming); + }, true); if (backgroundParallaxContainer != null) backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; From 0dafcf00b7038d41b1ef33e0aa87c76d115b4763 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 19:50:00 +0900 Subject: [PATCH 135/253] Fix some discrepancies with the main menu logo transitions --- osu.Game/Screens/Menu/ButtonSystem.cs | 51 +++++++++++++++------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 8b88204ed0..8282e7e2fe 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -325,52 +325,57 @@ namespace osu.Game.Screens.Menu { if (logo == null) return; - logoDelayedAction?.Cancel(); - switch (state) { case MenuState.Exit: case MenuState.Initial: - logoTracking = false; - + logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => - { - hideOverlaysOnEnter.Value = true; - allowOpeningOverlays.Value = false; + { + logoTracking = false; - logo.ClearTransforms(targetMember: nameof(Position)); - logo.RelativePositionAxes = Axes.Both; + hideOverlaysOnEnter.Value = true; + allowOpeningOverlays.Value = false; - logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); - logo.ScaleTo(1, 800, Easing.OutExpo); - }, 150); + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.Both; + logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); + logo.ScaleTo(1, 800, Easing.OutExpo); + }, buttonArea.Alpha * 150); break; case MenuState.TopLevel: case MenuState.Play: - logo.ClearTransforms(targetMember: nameof(Position)); - logo.RelativePositionAxes = Axes.None; - switch (lastState) { case MenuState.TopLevel: // coming from toplevel to play + break; case MenuState.Initial: - logoTracking = false; - logo.ScaleTo(0.5f, 200, Easing.In); + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.None; + + bool impact = logo.Scale.X > 0.6f; + + if (lastState == MenuState.Initial) + logo.ScaleTo(0.5f, 200, Easing.In); logo.MoveTo(logoTrackingPosition, lastState == MenuState.EnteringMode ? 0 : 200, Easing.In); + logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => - { - logoTracking = true; + { + logoTracking = true; - logo.Impact(); + if (impact) + logo.Impact(); - hideOverlaysOnEnter.Value = false; - allowOpeningOverlays.Value = true; - }, 200); + hideOverlaysOnEnter.Value = false; + allowOpeningOverlays.Value = true; + }, (1 - buttonArea.Alpha) * 200); break; default: + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.None; logoTracking = true; logo.ScaleTo(0.5f, 200, Easing.OutQuint); break; From 0caf15166e3bfc06ca34725664a816393c1e11ab Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 20:05:31 +0900 Subject: [PATCH 136/253] Remove unnecessary FinishTransforms --- osu.Game/Screens/Menu/ButtonSystem.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 8282e7e2fe..983ba70fa5 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -254,9 +254,6 @@ namespace osu.Game.Screens.Menu backButton.ContractStyle = 0; settingsButton.ContractStyle = 0; - if (state == MenuState.TopLevel) - buttonArea.FinishTransforms(true); - updateLogoState(lastState); using (buttonArea.BeginDelayedSequence(lastState == MenuState.Initial ? 150 : 0, true)) From 9497db0b0bb38e35c73f6ab6db54d9d09cfc22c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 20:21:25 +0900 Subject: [PATCH 137/253] Add a delay before the loading logo is displayed --- osu.Game/Screens/Loader.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index fb5c5ca84b..28b139c9f9 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -36,7 +36,13 @@ namespace osu.Game.Screens logo.Position = new Vector2(-40); logo.Scale = new Vector2(0.2f); - logo.FadeInFromZero(5000, Easing.OutQuint); + logo.Delay(500).FadeInFromZero(1000, Easing.OutQuint); + } + + protected override void LogoSuspending(OsuLogo logo) + { + base.LogoSuspending(logo); + logo.FadeOut(logo.Alpha * 1000); } private OsuScreen loadScreen; @@ -63,12 +69,6 @@ namespace osu.Game.Screens Push(loadScreen); } - protected override void LogoSuspending(OsuLogo logo) - { - base.LogoSuspending(logo); - logo.FadeOut(100); - } - [BackgroundDependencyLoader] private void load(OsuGameBase game) { From 9ea6ab28ea45ce90de2471f22a1b20de8ce44b5b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 May 2018 20:21:53 +0900 Subject: [PATCH 138/253] Fix intro potentially starting out-of-sync due to logo's outward animation --- osu.Game/Screens/Menu/Intro.cs | 48 ++++++++++++++++------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index c174e2d470..5aca184d24 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -79,31 +79,6 @@ namespace osu.Game.Screens.Menu seeya = audio.Sample.Get(@"seeya"); } - protected override void OnEntering(Screen last) - { - base.OnEntering(last); - - Game.Beatmap.Value = beatmap; - - if (menuVoice) - welcome.Play(); - - Scheduler.AddDelayed(delegate - { - // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu. - if (menuMusic) - track.Start(); - - LoadComponentAsync(mainMenu = new MainMenu()); - - Scheduler.AddDelayed(delegate - { - DidLoadMenu = true; - Push(mainMenu); - }, delay_step_one); - }, delay_step_two); - } - private const double delay_step_one = 2300; private const double delay_step_two = 600; @@ -113,6 +88,29 @@ namespace osu.Game.Screens.Menu { base.LogoArriving(logo, resuming); + if (!resuming) + { + Game.Beatmap.Value = beatmap; + + if (menuVoice) + welcome.Play(); + + Scheduler.AddDelayed(delegate + { + // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu. + if (menuMusic) + track.Start(); + + LoadComponentAsync(mainMenu = new MainMenu()); + + Scheduler.AddDelayed(delegate + { + DidLoadMenu = true; + Push(mainMenu); + }, delay_step_one); + }, delay_step_two); + } + logo.RelativePositionAxes = Axes.Both; logo.Colour = Color4.White; logo.Ripple = false; From ff93a54a64de5f81039f31f4faa7f08f2d0b432c Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 30 May 2018 23:16:54 -0300 Subject: [PATCH 139/253] Default Type to Title, use ToLower for the screen type title. --- osu.Game/Screens/Multi/Header.cs | 2 +- osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs | 1 - osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index fb4da45aca..46610a36d8 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -86,7 +86,7 @@ namespace osu.Game.Screens.Multi }, }; - breadcrumbs.Current.ValueChanged += s => screenType.Text = ((MultiplayerScreen)s).Type; + breadcrumbs.Current.ValueChanged += s => screenType.Text = ((MultiplayerScreen)s).Type.ToLower(); breadcrumbs.Current.TriggerChange(); } diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index f0c93b1146..016babcaa5 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -25,7 +25,6 @@ namespace osu.Game.Screens.Multi.Screens.Lounge protected readonly FillFlowContainer RoomsContainer; protected readonly RoomInspector Inspector; - public override string Type => "lounge"; public override string Title => "Lounge"; protected override Container TransitionContent => content; diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs index cdfa17a7a6..fa9b40684c 100644 --- a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -18,7 +18,7 @@ namespace osu.Game.Screens.Multi.Screens /// /// The type to display in the title of the . /// - public abstract string Type { get; } + public virtual string Type => Title; protected override void OnEntering(Screen last) { From 319faf12f7a9b4e010b318a8f470db825dadbd04 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 12:39:56 +0900 Subject: [PATCH 140/253] Fix incorrect naming of label --- osu.Game.Tests/Visual/TestCaseMods.cs | 8 ++++---- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMods.cs b/osu.Game.Tests/Visual/TestCaseMods.cs index cf26230868..3255478bea 100644 --- a/osu.Game.Tests/Visual/TestCaseMods.cs +++ b/osu.Game.Tests/Visual/TestCaseMods.cs @@ -199,13 +199,13 @@ namespace osu.Game.Tests.Visual private void testRankedText(Mod mod) { AddWaitStep(1, "wait for fade"); - AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha == 0); + AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0); selectNext(mod); AddWaitStep(1, "wait for fade"); - AddAssert("check for unranked", () => modSelect.RankedLabel.Alpha != 0); + AddAssert("check for unranked", () => modSelect.UnrankedLabel.Alpha != 0); selectPrevious(mod); AddWaitStep(1, "wait for fade"); - AddAssert("check for ranked", () => modSelect.RankedLabel.Alpha == 0); + AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0); } private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1)); @@ -241,7 +241,7 @@ namespace osu.Game.Tests.Visual } public new OsuSpriteText MultiplierLabel => base.MultiplierLabel; - public new OsuSpriteText RankedLabel => base.RankedLabel; + public new OsuSpriteText UnrankedLabel => base.UnrankedLabel; public new TriangleButton DeselectAllButton => base.DeselectAllButton; public new Color4 LowMultiplierColour => base.LowMultiplierColour; diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 69f409c3d2..3c44532627 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Mods protected Color4 LowMultiplierColour, HighMultiplierColour; protected readonly TriangleButton DeselectAllButton; - protected readonly OsuSpriteText MultiplierLabel, RankedLabel; + protected readonly OsuSpriteText MultiplierLabel, UnrankedLabel; private readonly FillFlowContainer footerContainer; protected override bool BlockPassThroughKeyboard => false; @@ -107,9 +107,9 @@ namespace osu.Game.Overlays.Mods MultiplierLabel.FadeColour(Color4.White, 200); if (ranked) - RankedLabel.FadeOut(200); + UnrankedLabel.FadeOut(200); else - RankedLabel.FadeIn(200); + UnrankedLabel.FadeIn(200); } protected override void PopOut() @@ -373,7 +373,7 @@ namespace osu.Game.Overlays.Mods Top = 5 } }, - RankedLabel = new OsuSpriteText + UnrankedLabel = new OsuSpriteText { Font = @"Exo2.0-Bold", Text = @"(Unranked)", From 205aa1a3cdd5adf2927e78dcd9187306bf4f8889 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 12:44:11 +0900 Subject: [PATCH 141/253] Fetch colour from OsuColour palette --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 3c44532627..5eb507c67c 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -58,6 +58,7 @@ namespace osu.Game.Overlays.Mods LowMultiplierColour = colours.Red; HighMultiplierColour = colours.Green; + UnrankedLabel.Colour = colours.Blue; if (osu != null) Ruleset.BindTo(osu.Ruleset); @@ -378,7 +379,6 @@ namespace osu.Game.Overlays.Mods Font = @"Exo2.0-Bold", Text = @"(Unranked)", TextSize = 30, - Colour = OsuColour.FromHex(@"66ccff"), Shadow = true, Margin = new MarginPadding { From 0f6c623ebb15b222cb21076a8d9d98a85d2ae3a7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 12:44:59 +0900 Subject: [PATCH 142/253] Tidy up some unnecessary lines --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 5eb507c67c..f1624721da 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -107,10 +107,7 @@ namespace osu.Game.Overlays.Mods else MultiplierLabel.FadeColour(Color4.White, 200); - if (ranked) - UnrankedLabel.FadeOut(200); - else - UnrankedLabel.FadeIn(200); + UnrankedLabel.FadeTo(ranked ? 0 : 1, 200); } protected override void PopOut() @@ -357,7 +354,6 @@ namespace osu.Game.Overlays.Mods { Text = @"Score Multiplier:", TextSize = 30, - Shadow = true, Margin = new MarginPadding { Top = 5, @@ -368,7 +364,6 @@ namespace osu.Game.Overlays.Mods { Font = @"Exo2.0-Bold", TextSize = 30, - Shadow = true, Margin = new MarginPadding { Top = 5 @@ -379,7 +374,6 @@ namespace osu.Game.Overlays.Mods Font = @"Exo2.0-Bold", Text = @"(Unranked)", TextSize = 30, - Shadow = true, Margin = new MarginPadding { Top = 5, From b7511251d99ee6158e918725a35a26134c5e3529 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 12:50:01 +0900 Subject: [PATCH 143/253] Remove pointless FillMode specification --- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 59d5ecd07f..d8c7b5130d 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -407,7 +407,6 @@ namespace osu.Game.Rulesets.Catch.UI public CatcherSprite() { Size = new Vector2(CATCHER_SIZE); - FillMode = FillMode.Fill; // Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling. OriginPosition = new Vector2(-0.02f, 0.06f) * CATCHER_SIZE; From e48b17fb0debb6d4a28c81d64ced8be3ef217c88 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 31 May 2018 15:17:59 +0900 Subject: [PATCH 144/253] Unindent --- osu.Game/Screens/Menu/ButtonSystem.cs | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 983ba70fa5..f212bfabf3 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -328,18 +328,18 @@ namespace osu.Game.Screens.Menu case MenuState.Initial: logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => - { - logoTracking = false; + { + logoTracking = false; - hideOverlaysOnEnter.Value = true; - allowOpeningOverlays.Value = false; + hideOverlaysOnEnter.Value = true; + allowOpeningOverlays.Value = false; - logo.ClearTransforms(targetMember: nameof(Position)); - logo.RelativePositionAxes = Axes.Both; + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.Both; - logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); - logo.ScaleTo(1, 800, Easing.OutExpo); - }, buttonArea.Alpha * 150); + logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); + logo.ScaleTo(1, 800, Easing.OutExpo); + }, buttonArea.Alpha * 150); break; case MenuState.TopLevel: case MenuState.Play: @@ -360,15 +360,15 @@ namespace osu.Game.Screens.Menu logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => - { - logoTracking = true; + { + logoTracking = true; - if (impact) - logo.Impact(); + if (impact) + logo.Impact(); - hideOverlaysOnEnter.Value = false; - allowOpeningOverlays.Value = true; - }, (1 - buttonArea.Alpha) * 200); + hideOverlaysOnEnter.Value = false; + allowOpeningOverlays.Value = true; + }, 200); break; default: logo.ClearTransforms(targetMember: nameof(Position)); From c161d8247479f401b0719b029459a9107ef3705f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 17:14:04 +0900 Subject: [PATCH 145/253] Reduce the length of the fadeout animation --- osu.Game/Screens/Loader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 28b139c9f9..c8a80d470b 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens protected override void LogoSuspending(OsuLogo logo) { base.LogoSuspending(logo); - logo.FadeOut(logo.Alpha * 1000); + logo.FadeOut(logo.Alpha * 400); } private OsuScreen loadScreen; From 7487c82ec151b2b3a9fffc7adc260f87794ce182 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 17:14:47 +0900 Subject: [PATCH 146/253] Stop the logo from beating --- osu.Game/Screens/Loader.cs | 1 + osu.Game/Screens/Menu/OsuLogo.cs | 4 ++++ osu.Game/Screens/OsuScreen.cs | 1 + 3 files changed, 6 insertions(+) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index c8a80d470b..b8c1c31b8c 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -30,6 +30,7 @@ namespace osu.Game.Screens { base.LogoArriving(logo, resuming); + logo.BeatMatching = false; logo.Triangles = false; logo.Origin = Anchor.BottomRight; logo.Anchor = Anchor.BottomRight; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 42a8dbd5da..16482b0e48 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -64,6 +64,8 @@ namespace osu.Game.Screens.Menu set { colourAndTriangles.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); } } + public bool BeatMatching = true; + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => logoContainer.ReceiveMouseInputAt(screenSpacePos); public bool Ripple @@ -264,6 +266,8 @@ namespace osu.Game.Screens.Menu { base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + if (!BeatMatching) return; + lastBeatIndex = beatIndex; var beatLength = timingPoint.BeatLength; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index db9807b9ab..7f68e5144b 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -225,6 +225,7 @@ namespace osu.Game.Screens logo.Anchor = Anchor.TopLeft; logo.Origin = Anchor.Centre; logo.RelativePositionAxes = Axes.None; + logo.BeatMatching = true; logo.Triangles = true; logo.Ripple = true; } From dfbcf4d7b7df2cde7194ea952a2eec221b81cd87 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 17:29:59 +0900 Subject: [PATCH 147/253] Add tests --- .../Visual/TestCaseLoaderAnimation.cs | 101 ++++++++++++++++++ osu.Game/Screens/Loader.cs | 4 +- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs diff --git a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs new file mode 100644 index 0000000000..066efb5116 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs @@ -0,0 +1,101 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Threading; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Game.Screens; +using osu.Game.Screens.Menu; +using OpenTK.Graphics; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseLoaderAnimation : OsuTestCase + { + private TestLoader loader; + + public TestCaseLoaderAnimation() + { + bool logoVisible = false; + + AddStep("almost instant display", () => Child = loader = new TestLoader(0.25f)); + AddUntilStep(() => + { + logoVisible = loader.Logo.Alpha > 0; + return !loader.IsCurrentScreen; + }, "loaded"); + AddAssert("logo not visible", () => !logoVisible); + + AddStep("short load", () => Child = loader = new TestLoader(0.8f)); + AddUntilStep(() => + { + logoVisible = loader.Logo.Alpha > 0; + return !loader.IsCurrentScreen; + }, "loaded"); + AddAssert("logo visible", () => logoVisible); + AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + + AddStep("longer load", () => Child = loader = new TestLoader(1.4f)); + AddUntilStep(() => + { + logoVisible = loader.Logo.Alpha > 0; + return !loader.IsCurrentScreen; + }, "loaded"); + AddAssert("logo visible", () => logoVisible); + AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + } + + private class TestLoader : Loader + { + private readonly float secondsDelay; + + public OsuLogo Logo; + + public TestLoader(float secondsDelay) + { + this.secondsDelay = secondsDelay; + } + + protected override void LogoArriving(OsuLogo logo, bool resuming) + { + Logo = logo; + base.LogoArriving(logo, resuming); + } + + protected override OsuScreen CreateLoadableScreen() => new TestScreen(secondsDelay); + + private class TestScreen : OsuScreen + { + private readonly float secondsDelay; + + public TestScreen(float secondsDelay) + { + this.secondsDelay = secondsDelay; + + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.DarkSlateGray, + Alpha = 0, + }; + } + + [BackgroundDependencyLoader] + private void load() + { + Thread.Sleep((int)(secondsDelay * 1000)); + } + + protected override void LogoArriving(OsuLogo logo, bool resuming) + { + base.LogoArriving(logo, resuming); + + Child.FadeInFromZero(200); + } + } + } + } +} diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index b8c1c31b8c..6335700a8f 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -49,12 +49,14 @@ namespace osu.Game.Screens private OsuScreen loadScreen; private ShaderPrecompiler precompiler; + protected virtual OsuScreen CreateLoadableScreen() => showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro(); + protected override void OnEntering(Screen last) { base.OnEntering(last); LoadComponentAsync(precompiler = new ShaderPrecompiler(loadIfReady), Add); - LoadComponentAsync(loadScreen = showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro(), s => loadIfReady()); + LoadComponentAsync(loadScreen = CreateLoadableScreen(), s => loadIfReady()); } private void loadIfReady() From 6781b81336ba61b053d91028ba9a7ec1d06108c6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 31 May 2018 05:48:42 -0300 Subject: [PATCH 148/253] Cleanup. --- osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs | 1 + osu.Game/Overlays/BeatmapSet/Header.cs | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs index e25f5a9431..1976db907c 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs @@ -59,6 +59,7 @@ namespace osu.Game.Beatmaps.Drawables { displayedCover?.FadeOut(400); displayedCover?.Expire(); + displayedCover = null; if (beatmapSet != null) { diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 033f0b22d0..89c141ef17 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -61,8 +61,8 @@ namespace osu.Game.Overlays.BeatmapSet title.Text = BeatmapSet?.Metadata.Title ?? string.Empty; artist.Text = BeatmapSet?.Metadata.Artist ?? string.Empty; onlineStatusPill.Status = BeatmapSet?.OnlineInfo.Status ?? BeatmapSetOnlineStatus.None; + cover.BeatmapSet = BeatmapSet; - cover.BeatmapSet = null; if (BeatmapSet != null) { downloadButtonsContainer.FadeIn(transition_duration); @@ -70,8 +70,6 @@ namespace osu.Game.Overlays.BeatmapSet noVideoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 0 : 1, transition_duration); videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration); - - cover.BeatmapSet = BeatmapSet; } else { From 4eb7a349442680ace0fb534b4f8bf5a03903c1b0 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 30 May 2018 21:49:49 +0900 Subject: [PATCH 149/253] Always update children when ruleset input manager is updated --- osu.Game/Rulesets/UI/RulesetInputManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index 58a66a5224..b35616985a 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -121,8 +121,6 @@ namespace osu.Game.Rulesets.UI /// private bool validState; - protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState; - private bool isAttached => replayInputHandler != null && !UseParentState; private const int max_catch_up_updates_per_frame = 50; From b68a5f5eabb589b787a844d96d0606915f44d55d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 20:07:44 +0900 Subject: [PATCH 150/253] Tidy up Loader logic --- osu.Game/Screens/Loader.cs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 6335700a8f..c3b3e747fd 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.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 System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; @@ -46,30 +45,32 @@ namespace osu.Game.Screens logo.FadeOut(logo.Alpha * 400); } - private OsuScreen loadScreen; + private OsuScreen loadableScreen; private ShaderPrecompiler precompiler; protected virtual OsuScreen CreateLoadableScreen() => showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro(); + protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler(); + protected override void OnEntering(Screen last) { base.OnEntering(last); - LoadComponentAsync(precompiler = new ShaderPrecompiler(loadIfReady), Add); - LoadComponentAsync(loadScreen = CreateLoadableScreen(), s => loadIfReady()); + LoadComponentAsync(precompiler = CreateShaderPrecompiler(), Add); + LoadComponentAsync(loadableScreen = CreateLoadableScreen()); + + checkIfLoaded(); } - private void loadIfReady() + private void checkIfLoaded() { - if (ChildScreen == loadScreen) return; - - if (loadScreen.LoadState != LoadState.Ready) + if (loadableScreen.LoadState != LoadState.Ready || !precompiler.FinishedCompiling) + { + Schedule(checkIfLoaded); return; + } - if (!precompiler.FinishedCompiling) - return; - - Push(loadScreen); + Push(loadableScreen); } [BackgroundDependencyLoader] @@ -83,16 +84,10 @@ namespace osu.Game.Screens /// public class ShaderPrecompiler : Drawable { - private readonly Action onLoaded; private readonly List loadTargets = new List(); public bool FinishedCompiling { get; private set; } - public ShaderPrecompiler(Action onLoaded) - { - this.onLoaded = onLoaded; - } - [BackgroundDependencyLoader] private void load(ShaderManager manager) { @@ -106,16 +101,17 @@ namespace osu.Game.Screens loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE)); } + protected virtual bool AllLoaded => loadTargets.All(s => s.Loaded); + protected override void Update() { base.Update(); // if our target is null we are done. - if (loadTargets.All(s => s.Loaded)) + if (AllLoaded) { FinishedCompiling = true; Expire(); - onLoaded?.Invoke(); } } } From a6f2561be83855dd1075495cc8a44cf5bb173c70 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 May 2018 20:07:55 +0900 Subject: [PATCH 151/253] Fix automated testing --- .../Visual/TestCaseLoaderAnimation.cs | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs index 066efb5116..600784f8db 100644 --- a/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs +++ b/osu.Game.Tests/Visual/TestCaseLoaderAnimation.cs @@ -1,9 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading; using NUnit.Framework; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; using osu.Game.Screens; @@ -17,46 +15,53 @@ namespace osu.Game.Tests.Visual { private TestLoader loader; - public TestCaseLoaderAnimation() + protected override void LoadComplete() { - bool logoVisible = false; + base.LoadComplete(); - AddStep("almost instant display", () => Child = loader = new TestLoader(0.25f)); + // required to preload the logo in a headless run (so it doesn't delay the loading itself). + Add(new OsuLogo()); + + bool logoVisible = false; + AddStep("almost instant display", () => Child = loader = new TestLoader(250)); AddUntilStep(() => { - logoVisible = loader.Logo.Alpha > 0; - return !loader.IsCurrentScreen; + logoVisible = loader.Logo?.Alpha > 0; + return loader.Logo != null && loader.ScreenLoaded; }, "loaded"); AddAssert("logo not visible", () => !logoVisible); - AddStep("short load", () => Child = loader = new TestLoader(0.8f)); + AddStep("short load", () => Child = loader = new TestLoader(800)); AddUntilStep(() => { - logoVisible = loader.Logo.Alpha > 0; - return !loader.IsCurrentScreen; + logoVisible = loader.Logo?.Alpha > 0; + return loader.Logo != null && loader.ScreenLoaded; }, "loaded"); AddAssert("logo visible", () => logoVisible); - AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone"); - AddStep("longer load", () => Child = loader = new TestLoader(1.4f)); + AddStep("longer load", () => Child = loader = new TestLoader(1400)); AddUntilStep(() => { - logoVisible = loader.Logo.Alpha > 0; - return !loader.IsCurrentScreen; + logoVisible = loader.Logo?.Alpha > 0; + return loader.Logo != null && loader.ScreenLoaded; }, "loaded"); AddAssert("logo visible", () => logoVisible); - AddUntilStep(() => loader.Logo.Alpha == 0, "logo gone"); + AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone"); } private class TestLoader : Loader { - private readonly float secondsDelay; + private readonly double delay; public OsuLogo Logo; + private TestScreen screen; - public TestLoader(float secondsDelay) + public bool ScreenLoaded => screen.IsCurrentScreen; + + public TestLoader(double delay) { - this.secondsDelay = secondsDelay; + this.delay = delay; } protected override void LogoArriving(OsuLogo logo, bool resuming) @@ -65,16 +70,32 @@ namespace osu.Game.Tests.Visual base.LogoArriving(logo, resuming); } - protected override OsuScreen CreateLoadableScreen() => new TestScreen(secondsDelay); + protected override OsuScreen CreateLoadableScreen() => screen = new TestScreen(); + protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler(delay); + + private class TestShaderPrecompiler : ShaderPrecompiler + { + private readonly double delay; + private double startTime; + + public TestShaderPrecompiler(double delay) + { + this.delay = delay; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + startTime = Time.Current; + } + + protected override bool AllLoaded => Time.Current > startTime + delay; + } private class TestScreen : OsuScreen { - private readonly float secondsDelay; - - public TestScreen(float secondsDelay) + public TestScreen() { - this.secondsDelay = secondsDelay; - Child = new Box { RelativeSizeAxes = Axes.Both, @@ -83,16 +104,9 @@ namespace osu.Game.Tests.Visual }; } - [BackgroundDependencyLoader] - private void load() - { - Thread.Sleep((int)(secondsDelay * 1000)); - } - protected override void LogoArriving(OsuLogo logo, bool resuming) { base.LogoArriving(logo, resuming); - Child.FadeInFromZero(200); } } From 1095669a5583a6ca81e8e27e65fdc8d45655a704 Mon Sep 17 00:00:00 2001 From: Joehu Date: Thu, 31 May 2018 08:09:19 -0700 Subject: [PATCH 152/253] Match panel with web --- osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 5 +++ .../API/Requests/APIResponseBeatmapSet.cs | 4 +++ osu.Game/Overlays/Direct/DirectGridPanel.cs | 33 +++++++++++++++---- osu.Game/Overlays/Direct/PlayButton.cs | 2 +- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index a70caf0207..8f985306e3 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs @@ -36,6 +36,11 @@ namespace osu.Game.Beatmaps /// public bool HasVideo { get; set; } + /// + /// Whether or not this beatmap set has a storyboard. + /// + public bool HasStoryboard { get; set; } + /// /// The different sizes of cover art for this beatmap set. /// diff --git a/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs b/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs index 2661303652..44c1216959 100644 --- a/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs @@ -30,6 +30,9 @@ namespace osu.Game.Online.API.Requests [JsonProperty(@"video")] private bool hasVideo { get; set; } + [JsonProperty(@"storyboard")] + private bool hasStoryboard { get; set; } + [JsonProperty(@"status")] private BeatmapSetOnlineStatus status { get; set; } @@ -65,6 +68,7 @@ namespace osu.Game.Online.API.Requests BPM = bpm, Status = status, HasVideo = hasVideo, + HasStoryboard = hasStoryboard, Submitted = submitted, Ranked = ranked, LastUpdated = lastUpdated, diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 9715615d14..1f0c097811 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -149,7 +149,7 @@ namespace osu.Game.Overlays.Direct { new OsuSpriteText { - Text = $"from {SetInfo.Metadata.Source}", + Text = $"{SetInfo.Metadata.Source}", TextSize = 14, Shadow = false, Colour = colours.Gray5, @@ -195,18 +195,18 @@ namespace osu.Game.Overlays.Direct new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), }, }, - playButton = new PlayButton(SetInfo) - { - Margin = new MarginPadding { Top = 5, Left = 10 }, - Size = new Vector2(30), - Alpha = 0, - }, statusContainer = new FillFlowContainer { AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Top = 5, Left = 5 }, Spacing = new Vector2(5), }, + playButton = new PlayButton(SetInfo) + { + Margin = new MarginPadding { Top = 5, Left = 10 }, + Size = new Vector2(30), + Alpha = 0, + }, }); if (SetInfo.OnlineInfo?.HasVideo ?? false) @@ -214,6 +214,11 @@ namespace osu.Game.Overlays.Direct statusContainer.Add(new IconPill(FontAwesome.fa_film)); } + if (SetInfo.OnlineInfo?.HasStoryboard ?? false) + { + statusContainer.Add(new IconPill(FontAwesome.fa_image)); + } + statusContainer.Add(new BeatmapSetOnlineStatusPill(12, new MarginPadding { Horizontal = 10, Vertical = 5 }) { Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, @@ -233,5 +238,19 @@ namespace osu.Game.Overlays.Direct statusContainer.FadeIn(120, Easing.InOutQuint); } + + protected override void Update() + { + base.Update(); + + if (PreviewPlaying) + { + statusContainer.Hide(); + } + else if (!IsHovered) + { + statusContainer.Show(); + } + } } } diff --git a/osu.Game/Overlays/Direct/PlayButton.cs b/osu.Game/Overlays/Direct/PlayButton.cs index 4913b11ae1..131083c6ff 100644 --- a/osu.Game/Overlays/Direct/PlayButton.cs +++ b/osu.Game/Overlays/Direct/PlayButton.cs @@ -126,7 +126,7 @@ namespace osu.Game.Overlays.Direct return; } - icon.Icon = playing ? FontAwesome.fa_pause : FontAwesome.fa_play; + icon.Icon = playing ? FontAwesome.fa_stop : FontAwesome.fa_play; icon.FadeColour(playing || IsHovered ? hoverColour : Color4.White, 120, Easing.InOutQuint); if (playing) From b4d621a2cb15f54ad4103bc17da019e0533db160 Mon Sep 17 00:00:00 2001 From: Joehu Date: Thu, 31 May 2018 10:21:22 -0700 Subject: [PATCH 153/253] Add link colour to beatmap source --- osu.Game/Overlays/BeatmapSet/Info.cs | 4 ++-- osu.Game/Screens/Select/BeatmapDetails.cs | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index cd0b7386e8..e10294bbce 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -135,8 +135,8 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - source.TextColour = description.TextColour = colours.Gray5; - tags.TextColour = colours.BlueDark; + description.TextColour = colours.Gray5; + source.TextColour = tags.TextColour = colours.BlueDark; updateDisplay(); } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index ca36f94eda..69f3cf0ae6 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -124,10 +124,7 @@ namespace osu.Game.Screens.Select { TextColour = Color4.White.Opacity(0.75f), }, - source = new MetadataSection("Source") - { - TextColour = Color4.White.Opacity(0.75f), - }, + source = new MetadataSection("Source"), tags = new MetadataSection("Tags"), }, }, @@ -167,7 +164,7 @@ namespace osu.Game.Screens.Select private void load(OsuColour colours, APIAccess api) { this.api = api; - tags.TextColour = colours.Yellow; + source.TextColour = tags.TextColour = colours.Yellow; } protected override void UpdateAfterChildren() From 729f2ec7251cc981b009412858d294adfc4477f3 Mon Sep 17 00:00:00 2001 From: Joehu Date: Thu, 31 May 2018 14:34:47 -0700 Subject: [PATCH 154/253] Match authorinfo with web --- osu.Game/Overlays/BeatmapSet/AuthorInfo.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index 66e3148065..398518ef2b 100644 --- a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -49,8 +49,8 @@ namespace osu.Game.Overlays.BeatmapSet fields.Children = new Drawable[] { - new Field("made by", BeatmapSet.Metadata.Author.Username, @"Exo2.0-RegularItalic"), - new Field("submitted on", online.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") + new Field("mapped by", BeatmapSet.Metadata.Author.Username, @"Exo2.0-RegularItalic"), + new Field("submitted on", online.Submitted.ToString(@"MMMM d, yyyy"), @"Exo2.0-Bold") { Margin = new MarginPadding { Top = 5 }, }, @@ -58,11 +58,11 @@ namespace osu.Game.Overlays.BeatmapSet if (online.Ranked.HasValue) { - fields.Add(new Field("ranked on ", online.Ranked.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); + fields.Add(new Field("ranked on", online.Ranked.Value.ToString(@"MMMM d, yyyy"), @"Exo2.0-Bold")); } else if (online.LastUpdated.HasValue) { - fields.Add(new Field("last updated on ", online.LastUpdated.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); + fields.Add(new Field("last updated on", online.LastUpdated.Value.ToString(@"MMMM d, yyyy"), @"Exo2.0-Bold")); } } From b9c601074d6659150b237d0f7c712d30d50ee3b6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Jun 2018 15:45:09 +0900 Subject: [PATCH 155/253] Formatting fixes --- .../Screens/Multi/Components/BeatmapTitle.cs | 18 ++++-------------- .../Multi/Components/ParticipantCount.cs | 4 ++-- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs index daa362409a..42863754c5 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -22,6 +22,7 @@ namespace osu.Game.Screens.Multi.Components } private BeatmapInfo beatmap; + public BeatmapInfo Beatmap { set @@ -41,18 +42,9 @@ namespace osu.Game.Screens.Multi.Components Children = new[] { - beatmapTitle = new OsuSpriteText - { - Font = @"Exo2.0-BoldItalic", - }, - beatmapDash = new OsuSpriteText - { - Font = @"Exo2.0-BoldItalic", - }, - beatmapArtist = new OsuSpriteText - { - Font = @"Exo2.0-RegularItalic", - }, + beatmapTitle = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", }, + beatmapDash = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", }, + beatmapArtist = new OsuSpriteText { Font = @"Exo2.0-RegularItalic", }, }; } @@ -65,7 +57,6 @@ namespace osu.Game.Screens.Multi.Components protected override void LoadComplete() { base.LoadComplete(); - updateText(); } @@ -74,7 +65,6 @@ namespace osu.Game.Screens.Multi.Components if (beatmap == null) { beatmapTitle.Current = beatmapArtist.Current = null; - beatmapTitle.Text = "Changing map"; beatmapDash.Text = beatmapArtist.Text = string.Empty; } diff --git a/osu.Game/Screens/Multi/Components/ParticipantCount.cs b/osu.Game/Screens/Multi/Components/ParticipantCount.cs index 96e2bd7bee..e47a529ff8 100644 --- a/osu.Game/Screens/Multi/Components/ParticipantCount.cs +++ b/osu.Game/Screens/Multi/Components/ParticipantCount.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Multi.Components public int Count { - set { count.Text = value.ToString(); } + set => count.Text = value.ToString(); } public int? Max @@ -31,8 +31,8 @@ namespace osu.Game.Screens.Multi.Components else { slash.FadeIn(transition_duration); - max.FadeIn(transition_duration); max.Text = value.ToString(); + max.FadeIn(transition_duration); } } } From 8dd36ee1a98a54ccf4ede99a4f829b1fc6b2ed19 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 1 Jun 2018 06:08:57 -0300 Subject: [PATCH 156/253] Default Max to null in ParticipantCount. --- osu.Game/Screens/Multi/Components/ParticipantCount.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Multi/Components/ParticipantCount.cs b/osu.Game/Screens/Multi/Components/ParticipantCount.cs index e47a529ff8..2e9183d047 100644 --- a/osu.Game/Screens/Multi/Components/ParticipantCount.cs +++ b/osu.Game/Screens/Multi/Components/ParticipantCount.cs @@ -62,6 +62,8 @@ namespace osu.Game.Screens.Multi.Components Font = @"Exo2.0-Light" }, }; + + Max = null; } } } From 59762c0393a01b14ba92467076dc19cd54fcef0a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 1 Jun 2018 06:15:23 -0300 Subject: [PATCH 157/253] Change Room.Participants to an IEnumerable. --- osu.Game/Online/Multiplayer/Room.cs | 3 ++- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 2 +- osu.Game/Screens/Multi/Components/RoomInspector.cs | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index ae3fb5ec6e..b076afbcdb 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.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 System.Collections.Generic; using osu.Framework.Configuration; using osu.Game.Beatmaps; using osu.Game.Users; @@ -16,6 +17,6 @@ namespace osu.Game.Online.Multiplayer public Bindable Type = new Bindable(); public Bindable Beatmap = new Bindable(); public Bindable MaxParticipants = new Bindable(); - public Bindable Participants = new Bindable(); + public Bindable> Participants = new Bindable>(); } } diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index d31019a259..54bd0ae7cc 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Multi.Components private readonly Bindable statusBind = new Bindable(); private readonly Bindable typeBind = new Bindable(); private readonly Bindable beatmapBind = new Bindable(); - private readonly Bindable participantsBind = new Bindable(); + private readonly Bindable> participantsBind = new Bindable>(); public readonly Room Room; diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index 14f4feab05..22bca1efc7 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.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 System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -33,7 +34,7 @@ namespace osu.Game.Screens.Multi.Components private readonly Bindable typeBind = new Bindable(); private readonly Bindable beatmapBind = new Bindable(); private readonly Bindable maxParticipantsBind = new Bindable(); - private readonly Bindable participantsBind = new Bindable(); + private readonly Bindable> participantsBind = new Bindable>(); private OsuColour colours; private Box statusStrip; @@ -214,7 +215,7 @@ namespace osu.Game.Screens.Multi.Components participantsBind.ValueChanged += p => { - participantCount.Count = p.Length; + participantCount.Count = p.Count(); participantInfo.Participants = p; participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)); }; From 5c2a2e394e2bff3b8a2a014c75c26218822423e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Jun 2018 18:03:16 +0900 Subject: [PATCH 158/253] Fix incorrect async logic in BeatmapInfoWedge Closes #2653. Alternative to #2657. --- .../Visual/TestCaseBeatmapInfoWedge.cs | 6 +- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 66 +++++++++++-------- osu.Game/Screens/Select/SongSelect.cs | 2 +- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs index 0d3e08154f..996c3b8695 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapInfoWedge.cs @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual AddStep("show", () => { infoWedge.State = Visibility.Visible; - infoWedge.UpdateBeatmap(beatmap); + infoWedge.Beatmap = beatmap; }); // select part is redundant, but wait for load isn't @@ -133,7 +133,7 @@ namespace osu.Game.Tests.Visual AddStep($"select {b.Metadata.Title} beatmap", () => { infoBefore = infoWedge.Info; - infoWedge.UpdateBeatmap(beatmap.Value = new TestWorkingBeatmap(b)); + infoWedge.Beatmap = beatmap.Value = new TestWorkingBeatmap(b); }); AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load"); @@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual AddStep("select null beatmap", () => { beatmap.Value = beatmap.Default; - infoWedge.UpdateBeatmap(beatmap); + infoWedge.Beatmap = beatmap; }); } diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 97f6371cb2..7950018554 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Select { if (osuGame != null) ruleset.BindTo(osuGame.Ruleset); - ruleset.ValueChanged += updateRuleset; + ruleset.ValueChanged += _ => updateDisplay(); } protected override bool BlockPassThroughMouse => false; @@ -78,66 +78,76 @@ namespace osu.Game.Screens.Select private WorkingBeatmap beatmap; - public void UpdateBeatmap(WorkingBeatmap beatmap) + public WorkingBeatmap Beatmap { - this.beatmap = beatmap; - loadBeatmap(); + get => beatmap; + set + { + if (beatmap == value) return; + + beatmap = value; + updateDisplay(); + } } - private void updateRuleset(RulesetInfo ruleset) => loadBeatmap(); + private BufferedWedgeInfo loadingInfo; - private void loadBeatmap() + private void updateDisplay() { - void updateState() + void removeOldInfo() { State = beatmap == null ? Visibility.Hidden : Visibility.Visible; Info?.FadeOut(250); Info?.Expire(); + Info = null; } if (beatmap == null) { - updateState(); + removeOldInfo(); return; } - LoadComponentAsync(new BufferedWedgeInfo(beatmap, ruleset.Value) + LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value) { Shear = -Shear, - Depth = Info?.Depth + 1 ?? 0, - }, newInfo => + Depth = Info?.Depth + 1 ?? 0 + }, loaded => { - updateState(); - Add(Info = newInfo); + // ensure we are the most recent loaded wedge. + if (loaded != loadingInfo) return; + + removeOldInfo(); + Add(Info = loaded); }); } public class BufferedWedgeInfo : BufferedContainer { - private readonly WorkingBeatmap working; public OsuSpriteText VersionLabel { get; private set; } public OsuSpriteText TitleLabel { get; private set; } public OsuSpriteText ArtistLabel { get; private set; } public FillFlowContainer MapperContainer { get; private set; } public FillFlowContainer InfoLabelContainer { get; private set; } + private UnicodeBindableString titleBinding; private UnicodeBindableString artistBinding; + private readonly WorkingBeatmap beatmap; private readonly RulesetInfo ruleset; - public BufferedWedgeInfo(WorkingBeatmap working, RulesetInfo userRuleset) + public BufferedWedgeInfo(WorkingBeatmap beatmap, RulesetInfo userRuleset) { - this.working = working; - - ruleset = userRuleset ?? working.BeatmapInfo.Ruleset; + this.beatmap = beatmap; + ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset; } [BackgroundDependencyLoader] private void load(LocalisationEngine localisation) { - var beatmapInfo = working.BeatmapInfo; - var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); + var beatmapInfo = beatmap.BeatmapInfo; + var metadata = beatmapInfo.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); PixelSnapping = true; CacheDrawnFrameBuffer = true; @@ -165,7 +175,7 @@ namespace osu.Game.Screens.Select Children = new[] { // Zoomed-in and cropped beatmap background - new BeatmapBackgroundSprite(working) + new BeatmapBackgroundSprite(beatmap) { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, @@ -248,27 +258,27 @@ namespace osu.Game.Screens.Select private InfoLabel[] getInfoLabels() { - var beatmap = working.Beatmap; + var b = beatmap.Beatmap; List labels = new List(); - if (beatmap?.HitObjects?.Any() == true) + if (b?.HitObjects?.Any() == true) { - HitObject lastObject = beatmap.HitObjects.LastOrDefault(); + HitObject lastObject = b.HitObjects.LastOrDefault(); double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0; labels.Add(new InfoLabel(new BeatmapStatistic { Name = "Length", Icon = FontAwesome.fa_clock_o, - Content = TimeSpan.FromMilliseconds(endTime - beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"), + Content = TimeSpan.FromMilliseconds(endTime - b.HitObjects.First().StartTime).ToString(@"m\:ss"), })); labels.Add(new InfoLabel(new BeatmapStatistic { Name = "BPM", Icon = FontAwesome.fa_circle, - Content = getBPMRange(beatmap), + Content = getBPMRange(b), })); IBeatmap playableBeatmap; @@ -276,12 +286,12 @@ namespace osu.Game.Screens.Select try { // Try to get the beatmap with the user's ruleset - playableBeatmap = working.GetPlayableBeatmap(ruleset); + playableBeatmap = beatmap.GetPlayableBeatmap(ruleset); } catch (BeatmapInvalidForRulesetException) { // Can't be converted to the user's ruleset, so use the beatmap's own ruleset - playableBeatmap = working.GetPlayableBeatmap(working.BeatmapInfo.Ruleset); + playableBeatmap = beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset); } labels.AddRange(playableBeatmap.GetStatistics().Select(s => new InfoLabel(s))); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e1271aebc4..41ba38cb0f 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -430,7 +430,7 @@ namespace osu.Game.Screens.Select backgroundModeBeatmap.FadeTo(1, 250); } - beatmapInfoWedge.UpdateBeatmap(beatmap); + beatmapInfoWedge.Beatmap = beatmap; } private void ensurePlayingSelected(bool preview = false) From 9b7741b353a6d71d88c836b51724ab26013de90f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Jun 2018 22:19:11 +0900 Subject: [PATCH 159/253] Avoid using update for fading logic --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 22 +++++---------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 1f0c097811..ed4630a8e7 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -223,34 +223,22 @@ namespace osu.Game.Overlays.Direct { Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, }); + + PreviewPlaying.ValueChanged += _ => updateStatusContainer(); } protected override bool OnHover(InputState state) { - statusContainer.FadeOut(120, Easing.InOutQuint); - + updateStatusContainer(); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { base.OnHoverLost(state); - - statusContainer.FadeIn(120, Easing.InOutQuint); + updateStatusContainer(); } - protected override void Update() - { - base.Update(); - - if (PreviewPlaying) - { - statusContainer.Hide(); - } - else if (!IsHovered) - { - statusContainer.Show(); - } - } + private void updateStatusContainer() => statusContainer.FadeTo(IsHovered || PreviewPlaying ? 0 : 1, 120, Easing.InOutQuint); } } From de64e4500ffcca65b31ccc36a77ff4fb31e553f3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Jun 2018 22:20:28 +0900 Subject: [PATCH 160/253] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index aebfa5bc5c..804a4b81b8 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit aebfa5bc5c634c1fd0c103e0c17518e5111a67c7 +Subproject commit 804a4b81b89cb4569af5221e6fa2296d559c28fb From cc32adf51fb008e5e9573397c5c320cb8e3ea075 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 1 Jun 2018 14:28:24 -0300 Subject: [PATCH 161/253] Move max text updating into updateMax. --- .../Multi/Components/ParticipantCount.cs | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/ParticipantCount.cs b/osu.Game/Screens/Multi/Components/ParticipantCount.cs index 2e9183d047..e7183cbd92 100644 --- a/osu.Game/Screens/Multi/Components/ParticipantCount.cs +++ b/osu.Game/Screens/Multi/Components/ParticipantCount.cs @@ -12,28 +12,23 @@ namespace osu.Game.Screens.Multi.Components private const float text_size = 30; private const float transition_duration = 100; - private readonly OsuSpriteText count, slash, max; + private readonly OsuSpriteText count, slash, maxText; public int Count { set => count.Text = value.ToString(); } + private int? max; public int? Max { + get => max; set { - if (value == null) - { - slash.FadeOut(transition_duration); - max.FadeOut(transition_duration); - } - else - { - slash.FadeIn(transition_duration); - max.Text = value.ToString(); - max.FadeIn(transition_duration); - } + if (value == max) return; + max = value; + + updateMax(); } } @@ -56,14 +51,29 @@ namespace osu.Game.Screens.Multi.Components TextSize = text_size, Font = @"Exo2.0-Light" }, - max = new OsuSpriteText + maxText = new OsuSpriteText { TextSize = text_size, Font = @"Exo2.0-Light" }, }; - Max = null; + updateMax(); + } + + private void updateMax() + { + if (Max == null) + { + slash.FadeOut(transition_duration); + maxText.FadeOut(transition_duration); + } + else + { + slash.FadeIn(transition_duration); + maxText.Text = Max.ToString(); + maxText.FadeIn(transition_duration); + } } } } From 5d1421c0e9b97a8d1bdbd4e422fddb6a6777dfc1 Mon Sep 17 00:00:00 2001 From: Joehu Date: Fri, 1 Jun 2018 15:31:25 -0700 Subject: [PATCH 162/253] Fix visual settings expand button colour --- .../Play/PlayerSettings/PlayerSettingsGroup.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs index 0ffcdf94a6..cdde11c5f8 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs @@ -50,11 +50,11 @@ namespace osu.Game.Screens.Play.PlayerSettings content.ResizeHeightTo(0, transition_duration, Easing.OutQuint); } - button.FadeColour(expanded ? buttonActiveColour : Color4.White, 200, Easing.OutQuint); + button.FadeColour(expanded ? expandedColour : Color4.White, 200, Easing.OutQuint); } } - private Color4 buttonActiveColour; + private Color4 expandedColour; protected PlayerSettingsGroup() { @@ -130,7 +130,16 @@ namespace osu.Game.Screens.Play.PlayerSettings [BackgroundDependencyLoader] private void load(OsuColour colours) { - button.Colour = buttonActiveColour = colours.Yellow; + if (expanded) + { + button.Colour = colours.Yellow; + } + else + { + button.Colour = Color4.White; + } + + expandedColour = colours.Yellow; } protected override Container Content => content; From 8d3de3affbba360fe7d8d755d8a71c07899dcd79 Mon Sep 17 00:00:00 2001 From: Joehu Date: Fri, 1 Jun 2018 15:58:05 -0700 Subject: [PATCH 163/253] Use '?:' expression instead --- .../Screens/Play/PlayerSettings/PlayerSettingsGroup.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs index cdde11c5f8..967cfd7fa0 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs @@ -130,14 +130,7 @@ namespace osu.Game.Screens.Play.PlayerSettings [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (expanded) - { - button.Colour = colours.Yellow; - } - else - { - button.Colour = Color4.White; - } + button.FadeColour(expanded ? colours.Yellow : Color4.White); expandedColour = colours.Yellow; } From a0c643fae50982f78040a64c219fe5fdb44bfa47 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Sat, 2 Jun 2018 11:25:49 +0200 Subject: [PATCH 164/253] Fix SongProgressInfo timespan formatting --- osu.Game/Screens/Play/SongProgressInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index b79c212ade..3156a646db 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -92,6 +92,6 @@ namespace osu.Game.Screens.Play } } - private string formatTime(TimeSpan timeSpan) => $"{(timeSpan < TimeSpan.Zero ? "-" : "")}{timeSpan.Duration().TotalMinutes:N0}:{timeSpan.Duration().Seconds:D2}"; + private string formatTime(TimeSpan timeSpan) => $"{(timeSpan < TimeSpan.Zero ? "-" : "")}{Math.Floor(timeSpan.Duration().TotalMinutes)}:{timeSpan.Duration().Seconds:D2}"; } } From d287e32fafb32f4d29817a4810f55643a8d870c3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 2 Jun 2018 22:20:17 +0900 Subject: [PATCH 165/253] Update project build configurations to target netcoreapp2.1 --- ...p2_0_.xml => VisualTests__netcoreapp2_1_.xml} | 6 +++--- ...tcoreapp2_0_.xml => osu___netcoreapp2_1_.xml} | 6 +++--- .vscode/launch.json | 16 ++++++++-------- .vscode/tasks.json | 10 +++++----- osu-framework | 2 +- osu.Desktop/osu.Desktop.csproj | 2 +- .../.vscode/launch.json | 8 ++++---- osu.Game.Rulesets.Catch.Tests/.vscode/tasks.json | 6 +++--- .../osu.Game.Rulesets.Catch.Tests.csproj | 2 +- .../.vscode/launch.json | 8 ++++---- osu.Game.Rulesets.Mania.Tests/.vscode/tasks.json | 6 +++--- .../osu.Game.Rulesets.Mania.Tests.csproj | 2 +- osu.Game.Rulesets.Osu.Tests/.vscode/launch.json | 8 ++++---- osu.Game.Rulesets.Osu.Tests/.vscode/tasks.json | 6 +++--- .../osu.Game.Rulesets.Osu.Tests.csproj | 2 +- .../.vscode/launch.json | 8 ++++---- osu.Game.Rulesets.Taiko.Tests/.vscode/tasks.json | 6 +++--- .../osu.Game.Rulesets.Taiko.Tests.csproj | 2 +- osu.Game.Tests/osu.Game.Tests.csproj | 2 +- 19 files changed, 54 insertions(+), 54 deletions(-) rename .idea/.idea.osu/.idea/runConfigurations/{VisualTests__netcoreapp2_0_.xml => VisualTests__netcoreapp2_1_.xml} (82%) rename .idea/.idea.osu/.idea/runConfigurations/{osu___netcoreapp2_0_.xml => osu___netcoreapp2_1_.xml} (82%) diff --git a/.idea/.idea.osu/.idea/runConfigurations/VisualTests__netcoreapp2_0_.xml b/.idea/.idea.osu/.idea/runConfigurations/VisualTests__netcoreapp2_1_.xml similarity index 82% rename from .idea/.idea.osu/.idea/runConfigurations/VisualTests__netcoreapp2_0_.xml rename to .idea/.idea.osu/.idea/runConfigurations/VisualTests__netcoreapp2_1_.xml index 08b4e38667..2d3a848922 100644 --- a/.idea/.idea.osu/.idea/runConfigurations/VisualTests__netcoreapp2_0_.xml +++ b/.idea/.idea.osu/.idea/runConfigurations/VisualTests__netcoreapp2_1_.xml @@ -1,6 +1,6 @@ - - \ No newline at end of file diff --git a/.idea/.idea.osu/.idea/runConfigurations/osu___netcoreapp2_0_.xml b/.idea/.idea.osu/.idea/runConfigurations/osu___netcoreapp2_1_.xml similarity index 82% rename from .idea/.idea.osu/.idea/runConfigurations/osu___netcoreapp2_0_.xml rename to .idea/.idea.osu/.idea/runConfigurations/osu___netcoreapp2_1_.xml index 2f5c137631..36efe211c6 100644 --- a/.idea/.idea.osu/.idea/runConfigurations/osu___netcoreapp2_0_.xml +++ b/.idea/.idea.osu/.idea/runConfigurations/osu___netcoreapp2_1_.xml @@ -1,6 +1,6 @@ - - \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 32c82685c0..b9bb75d5bb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -58,12 +58,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Debug, netcoreapp2.0)", + "name": "VisualTests (Debug, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.0/osu.Game.Tests.dll" + "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.1/osu.Game.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build tests (Debug, dotnet)", @@ -71,12 +71,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Release, netcoreapp2.0)", + "name": "VisualTests (Release, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.0/osu.Game.Tests.dll" + "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.1/osu.Game.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build tests (Release, dotnet)", @@ -84,12 +84,12 @@ "console": "internalConsole" }, { - "name": "osu! (Debug, netcoreapp2.0)", + "name": "osu! (Debug, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.0/osu!.dll", + "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.1/osu!.dll", ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build osu! (Debug, dotnet)", @@ -97,12 +97,12 @@ "console": "internalConsole" }, { - "name": "osu! (Release, netcoreapp2.0)", + "name": "osu! (Release, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.0/osu!.dll", + "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.1/osu!.dll", ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build osu! (Release, dotnet)", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0908ff6108..bebad750ca 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -38,7 +38,7 @@ "build", "--no-restore", "osu.Desktop", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:GenerateFullPaths=true", "/m", "/verbosity:m" @@ -54,7 +54,7 @@ "build", "--no-restore", "osu.Desktop", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:Configuration=Release", "/p:GenerateFullPaths=true", "/m", @@ -71,7 +71,7 @@ "build", "--no-restore", "osu.Game.Tests", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:GenerateFullPaths=true", "/m", "/verbosity:m" @@ -87,7 +87,7 @@ "build", "--no-restore", "osu.Game.Tests", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:Configuration=Release", "/p:GenerateFullPaths=true", "/m", @@ -106,7 +106,7 @@ "problemMatcher": [] }, { - "label": "Restore (netcoreapp2.0)", + "label": "Restore (netcoreapp2.1)", "type": "shell", "command": "dotnet", "args": [ diff --git a/osu-framework b/osu-framework index 804a4b81b8..39aae99f5c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 804a4b81b89cb4569af5221e6fa2296d559c28fb +Subproject commit 39aae99f5c21ac9c9f8003cb4dedea345c38c78c diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index af027da2fc..6b464ae4fe 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -1,7 +1,7 @@  - net471;netcoreapp2.0 + net471;netcoreapp2.1 WinExe AnyCPU true diff --git a/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json b/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json index eb80f4474c..c5005adfa5 100644 --- a/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json @@ -30,12 +30,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Debug, netcoreapp2.0)", + "name": "VisualTests (Debug, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Catch.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Catch.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Debug, dotnet)", @@ -43,12 +43,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Release, netcoreapp2.0)", + "name": "VisualTests (Release, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Catch.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Catch.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", diff --git a/osu.Game.Rulesets.Catch.Tests/.vscode/tasks.json b/osu.Game.Rulesets.Catch.Tests/.vscode/tasks.json index 41ae88f425..6c6d562512 100644 --- a/osu.Game.Rulesets.Catch.Tests/.vscode/tasks.json +++ b/osu.Game.Rulesets.Catch.Tests/.vscode/tasks.json @@ -40,7 +40,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Catch.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:GenerateFullPaths=true", "/m", "/verbosity:m" @@ -56,7 +56,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Catch.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:Configuration=Release", "/p:GenerateFullPaths=true", "/m", @@ -75,7 +75,7 @@ "problemMatcher": [] }, { - "label": "Restore (netcoreapp2.0)", + "label": "Restore (netcoreapp2.1)", "type": "shell", "command": "dotnet", "args": [ diff --git a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj index 3797edde61..93fa2c4d67 100644 --- a/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj +++ b/osu.Game.Rulesets.Catch.Tests/osu.Game.Rulesets.Catch.Tests.csproj @@ -2,7 +2,7 @@ WinExe - netcoreapp2.0;net471 + netcoreapp2.1;net471 diff --git a/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json b/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json index fceb403f30..637a5de1b5 100644 --- a/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json @@ -30,12 +30,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Debug, netcoreapp2.0)", + "name": "VisualTests (Debug, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Mania.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Mania.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Debug, dotnet)", @@ -43,12 +43,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Release, netcoreapp2.0)", + "name": "VisualTests (Release, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Mania.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Mania.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", diff --git a/osu.Game.Rulesets.Mania.Tests/.vscode/tasks.json b/osu.Game.Rulesets.Mania.Tests/.vscode/tasks.json index b04b068b0d..7fc2f7b2ef 100644 --- a/osu.Game.Rulesets.Mania.Tests/.vscode/tasks.json +++ b/osu.Game.Rulesets.Mania.Tests/.vscode/tasks.json @@ -40,7 +40,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Mania.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:GenerateFullPaths=true", "/m", "/verbosity:m" @@ -56,7 +56,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Mania.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:Configuration=Release", "/p:GenerateFullPaths=true", "/m", @@ -75,7 +75,7 @@ "problemMatcher": [] }, { - "label": "Restore (netcoreapp2.0)", + "label": "Restore (netcoreapp2.1)", "type": "shell", "command": "dotnet", "args": [ diff --git a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj index e90155568e..77504fdc3c 100644 --- a/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj +++ b/osu.Game.Rulesets.Mania.Tests/osu.Game.Rulesets.Mania.Tests.csproj @@ -2,7 +2,7 @@ WinExe - netcoreapp2.0;net471 + netcoreapp2.1;net471 diff --git a/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json b/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json index 714fb6db6f..65c801cef4 100644 --- a/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json @@ -30,12 +30,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Debug, netcoreapp2.0)", + "name": "VisualTests (Debug, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Osu.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Osu.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Debug, dotnet)", @@ -43,12 +43,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Release, netcoreapp2.0)", + "name": "VisualTests (Release, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Osu.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Osu.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", diff --git a/osu.Game.Rulesets.Osu.Tests/.vscode/tasks.json b/osu.Game.Rulesets.Osu.Tests/.vscode/tasks.json index 657fe07e1a..62cf51382f 100644 --- a/osu.Game.Rulesets.Osu.Tests/.vscode/tasks.json +++ b/osu.Game.Rulesets.Osu.Tests/.vscode/tasks.json @@ -40,7 +40,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Osu.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:GenerateFullPaths=true", "/m", "/verbosity:m" @@ -56,7 +56,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Osu.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:Configuration=Release", "/p:GenerateFullPaths=true", "/m", @@ -75,7 +75,7 @@ "problemMatcher": [] }, { - "label": "Restore (netcoreapp2.0)", + "label": "Restore (netcoreapp2.1)", "type": "shell", "command": "dotnet", "args": [ diff --git a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj index 1695ceacee..c5d9b26145 100644 --- a/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj +++ b/osu.Game.Rulesets.Osu.Tests/osu.Game.Rulesets.Osu.Tests.csproj @@ -2,7 +2,7 @@ WinExe - netcoreapp2.0;net471 + netcoreapp2.1;net471 diff --git a/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json b/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json index e1df54e99b..dbb1ab28e2 100644 --- a/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json @@ -30,12 +30,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Debug, netcoreapp2.0)", + "name": "VisualTests (Debug, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Taiko.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Taiko.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Debug, dotnet)", @@ -43,12 +43,12 @@ "console": "internalConsole" }, { - "name": "VisualTests (Release, netcoreapp2.0)", + "name": "VisualTests (Release, netcoreapp2.1)", "type": "coreclr", "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.0/osu.Game.Rulesets.Taiko.Tests.dll" + "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Taiko.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", diff --git a/osu.Game.Rulesets.Taiko.Tests/.vscode/tasks.json b/osu.Game.Rulesets.Taiko.Tests/.vscode/tasks.json index 8bdbcd8e8e..7c8beed00f 100644 --- a/osu.Game.Rulesets.Taiko.Tests/.vscode/tasks.json +++ b/osu.Game.Rulesets.Taiko.Tests/.vscode/tasks.json @@ -40,7 +40,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Taiko.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:GenerateFullPaths=true", "/m", "/verbosity:m" @@ -56,7 +56,7 @@ "build", "--no-restore", "osu.Game.Rulesets.Taiko.Tests.csproj", - "/p:TargetFramework=netcoreapp2.0", + "/p:TargetFramework=netcoreapp2.1", "/p:Configuration=Release", "/p:GenerateFullPaths=true", "/m", @@ -75,7 +75,7 @@ "problemMatcher": [] }, { - "label": "Restore (netcoreapp2.0)", + "label": "Restore (netcoreapp2.1)", "type": "shell", "command": "dotnet", "args": [ diff --git a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj index 1221584a2b..dea34d25e7 100644 --- a/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj +++ b/osu.Game.Rulesets.Taiko.Tests/osu.Game.Rulesets.Taiko.Tests.csproj @@ -2,7 +2,7 @@ WinExe - netcoreapp2.0;net471 + netcoreapp2.1;net471 diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 057c2c2de1..532915100b 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -2,7 +2,7 @@ WinExe - netcoreapp2.0;net471 + netcoreapp2.1;net471 From 6781807e23ab428d6b0e849048f597ae3fdb77e8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 00:28:10 +0900 Subject: [PATCH 166/253] Remove unnecessary EF tools references --- osu.Desktop/osu.Desktop.csproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 6b464ae4fe..b8efd76506 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -20,8 +20,6 @@ osu.Desktop.Program - - @@ -38,8 +36,4 @@ - - - - \ No newline at end of file From 88628812c64da355b1008282ba7375e96e795239 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 00:28:29 +0900 Subject: [PATCH 167/253] Logexceptions when loading ruleset DLLs --- osu.Game/Rulesets/RulesetStore.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs index 1847b63658..8d267f48e9 100644 --- a/osu.Game/Rulesets/RulesetStore.cs +++ b/osu.Game/Rulesets/RulesetStore.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using osu.Framework.Logging; using osu.Game.Database; namespace osu.Game.Rulesets @@ -114,8 +115,9 @@ namespace osu.Game.Rulesets var assembly = Assembly.LoadFrom(file); loaded_assemblies[assembly] = assembly.GetTypes().First(t => t.IsPublic && t.IsSubclassOf(typeof(Ruleset))); } - catch (Exception) + catch (Exception e) { + Logger.Error(e, "Failed to load ruleset"); } } } From 64eda2754724e473597dc2b252fb9be2933a3fbe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 02:28:11 +0900 Subject: [PATCH 168/253] Update framework --- osu-framework | 2 +- osu.Game/Overlays/KeyBinding/KeyBindingRow.cs | 4 ++-- osu.Game/Screens/Edit/Editor.cs | 4 ++-- .../Screens/Compose/Timeline/ScrollingTimelineContainer.cs | 6 +++--- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Tests/Visual/EditorClockTestCase.cs | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/osu-framework b/osu-framework index 39aae99f5c..b963ce8250 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 39aae99f5c21ac9c9f8003cb4dedea345c38c78c +Subproject commit b963ce82505bc953db0a0763679e1ec80a060811 diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs index 7406a9ec4f..ffe1560627 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs @@ -180,7 +180,7 @@ namespace osu.Game.Overlays.KeyBinding return true; } - protected override bool OnWheel(InputState state) + protected override bool OnScroll(InputState state) { if (HasFocus) { @@ -192,7 +192,7 @@ namespace osu.Game.Overlays.KeyBinding } } - return base.OnWheel(state); + return base.OnScroll(state); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index be08fffc77..b71d3aee18 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -182,9 +182,9 @@ namespace osu.Game.Screens.Edit LoadComponentAsync(currentScreen, screenContainer.Add); } - protected override bool OnWheel(InputState state) + protected override bool OnScroll(InputState state) { - if (state.Mouse.WheelDelta > 0) + if (state.Mouse.ScrollDelta.X + state.Mouse.ScrollDelta.Y > 0) clock.SeekBackward(true); else clock.SeekForward(true); diff --git a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs index 83aa86ba61..2902e74e00 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs @@ -123,15 +123,15 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline /// private float? localZoomTarget; - protected override bool OnWheel(InputState state) + protected override bool OnScroll(InputState state) { if (!state.Keyboard.ControlPressed) - return base.OnWheel(state); + return base.OnScroll(state); relativeContentZoomTarget = Content.ToLocalSpace(state.Mouse.NativeState.Position).X / Content.DrawSize.X; localZoomTarget = ToLocalSpace(state.Mouse.NativeState.Position).X; - Zoom += state.Mouse.WheelDelta; + Zoom += state.Mouse.ScrollDelta.Y; return true; } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 9985a24cab..c93e4b7b40 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -364,7 +364,7 @@ namespace osu.Game.Screens.Play Background?.FadeTo(1f, fade_out_duration); } - protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !pauseContainer.IsPaused; + protected override bool OnScroll(InputState state) => mouseWheelDisabled.Value && !pauseContainer.IsPaused; private void initializeStoryboard(bool asyncLoad) { diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index 85d3684530..1ce7023be0 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -59,9 +59,9 @@ namespace osu.Game.Tests.Visual Clock.ProcessFrame(); } - protected override bool OnWheel(InputState state) + protected override bool OnScroll(InputState state) { - if (state.Mouse.WheelDelta > 0) + if (state.Mouse.ScrollDelta.Y > 0) Clock.SeekBackward(true); else Clock.SeekForward(true); From ea3d97a757ae48791bdb0acd53382a188442b9b2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 02:36:56 +0900 Subject: [PATCH 169/253] Update appveyor to support netcore2.1 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 69bc762f4c..314faa617a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ clone_depth: 1 version: '{branch}-{build}' -image: Visual Studio 2017 +image: Visual Studio 2017 preview configuration: Debug cache: - C:\ProgramData\chocolatey\bin -> appveyor.yml From dc2a004c8741aa043ffa7c549d275dc5a8e65e47 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sat, 2 Jun 2018 12:04:58 -0700 Subject: [PATCH 170/253] Remove link colours for all unlinked text --- osu.Game/Overlays/BeatmapSet/Info.cs | 3 +-- osu.Game/Screens/Select/BeatmapDetails.cs | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index e10294bbce..35a66b1272 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -135,8 +135,7 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - description.TextColour = colours.Gray5; - source.TextColour = tags.TextColour = colours.BlueDark; + description.TextColour = source.TextColour = tags.TextColour = colours.Gray5; updateDisplay(); } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 69f3cf0ae6..013674b397 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using System.Linq; @@ -120,10 +119,7 @@ namespace osu.Game.Screens.Select Margin = new MarginPadding { Top = spacing * 2 }, Children = new[] { - description = new MetadataSection("Description") - { - TextColour = Color4.White.Opacity(0.75f), - }, + description = new MetadataSection("Description"), source = new MetadataSection("Source"), tags = new MetadataSection("Tags"), }, @@ -161,10 +157,10 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader] - private void load(OsuColour colours, APIAccess api) + private void load(APIAccess api) { this.api = api; - source.TextColour = tags.TextColour = colours.Yellow; + description.TextColour = source.TextColour = tags.TextColour = Color4.White.Opacity(0.75f); } protected override void UpdateAfterChildren() From 0f13acf67e4af21539a04e7a265b1e0d0bacdbcf Mon Sep 17 00:00:00 2001 From: Joehu Date: Sat, 2 Jun 2018 12:52:31 -0700 Subject: [PATCH 171/253] Use updateExpanded method --- .../Screens/Play/PlayerSettings/PlayerSettingsGroup.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs index 967cfd7fa0..cff3eca895 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Play.PlayerSettings content.ResizeHeightTo(0, transition_duration, Easing.OutQuint); } - button.FadeColour(expanded ? expandedColour : Color4.White, 200, Easing.OutQuint); + updateExpanded(); } } @@ -130,11 +130,13 @@ namespace osu.Game.Screens.Play.PlayerSettings [BackgroundDependencyLoader] private void load(OsuColour colours) { - button.FadeColour(expanded ? colours.Yellow : Color4.White); - expandedColour = colours.Yellow; + + updateExpanded(); } + private void updateExpanded() => button.FadeColour(expanded ? expandedColour : Color4.White, 200, Easing.InOutQuint); + protected override Container Content => content; protected override bool OnHover(InputState state) => true; From 645f6efce78edc8699f9d47443c86cdca3a3b1cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 13:01:52 +0900 Subject: [PATCH 172/253] Fix web request failures not being correctly handled at an APIRequest level --- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- osu.Game/Online/API/APIRequest.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index efc0279aa0..806bcc4132 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -170,7 +170,7 @@ namespace osu.Game.Beatmaps { if (error is OperationCanceledException) return; - downloadNotification.State = ProgressNotificationState.Completed; + downloadNotification.State = ProgressNotificationState.Cancelled; Logger.Error(error, "Beatmap download failed!"); currentDownloads.Remove(request); }; diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index 9af142b9e8..dfd181b98a 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -73,6 +73,7 @@ namespace osu.Game.Online.API throw new TimeoutException(@"API request timeout hit"); WebRequest = CreateWebRequest(); + WebRequest.Failed += Fail; WebRequest.AllowRetryOnTimeout = false; WebRequest.AddHeader("Authorization", $"Bearer {api.AccessToken}"); From 707af0209732ef29de79d4417c2aab9892ff8f89 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sun, 3 Jun 2018 11:30:58 +0200 Subject: [PATCH 173/253] apply feedback -don't directly set AllowOverlay Bindable this should be done specifically where needed -remove AllowOverlay Bindable from ButtonSystem -remove unnecessary xmldoc --- .../Containers/OsuFocusedOverlayContainer.cs | 3 --- osu.Game/Overlays/Toolbar/Toolbar.cs | 3 --- osu.Game/Screens/Menu/ButtonSystem.cs | 13 +------------ osu.Game/Screens/Menu/Disclaimer.cs | 3 +-- osu.Game/Screens/Menu/Intro.cs | 3 +-- osu.Game/Screens/Menu/MainMenu.cs | 3 --- osu.Game/Screens/OsuScreen.cs | 11 +++++++---- 7 files changed, 10 insertions(+), 29 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 318632a403..e9c02e84ec 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -17,9 +17,6 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; - /// - /// Defaults to so that the overlay works even if BDL couldn't pass an . - /// private readonly Bindable allowOverlays = new Bindable(OverlayActivation.All); [BackgroundDependencyLoader(true)] diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 78739c03fe..032ea01700 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -31,9 +31,6 @@ namespace osu.Game.Overlays.Toolbar private const float alpha_hovering = 0.8f; private const float alpha_normal = 0.6f; - /// - /// Defaults to so that the overlay works even if BDL couldn't pass an . - /// private readonly Bindable allowOverlays = new Bindable(OverlayActivation.All); public Toolbar() diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 40e115364d..bbbe918279 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -8,7 +8,6 @@ using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -20,7 +19,6 @@ using osu.Game.Input.Bindings; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; -using osu.Game.Overlays; namespace osu.Game.Screens.Menu { @@ -28,8 +26,6 @@ namespace osu.Game.Screens.Menu { public event Action StateChanged; - private readonly Bindable allowOverlays = new Bindable(); - public Action OnEdit; public Action OnExit; public Action OnDirect; @@ -134,11 +130,8 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader(true)] - private void load(AudioManager audio, OsuGame game) + private void load(AudioManager audio) { - if (game != null) - allowOverlays.BindTo(game.AllowOverlays); - sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } @@ -329,7 +322,6 @@ namespace osu.Game.Screens.Menu case MenuState.Exit: case MenuState.Initial: logoTracking = false; - allowOverlays.Value = OverlayActivation.Disabled; logoDelayedAction = Scheduler.AddDelayed(() => { @@ -338,9 +330,6 @@ namespace osu.Game.Screens.Menu logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); logo.ScaleTo(1, 800, Easing.OutExpo); - - if(state != MenuState.Exit) - allowOverlays.Value = OverlayActivation.All; }, 150); break; case MenuState.TopLevel: diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 3671a54068..2436f0a940 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -20,6 +20,7 @@ namespace osu.Game.Screens.Menu private Color4 iconColour; protected override bool HideOverlaysOnEnter => true; + protected override OverlayActivation OverlayActivationLevel => OverlayActivation.Disabled; public override bool CursorVisible => false; @@ -93,8 +94,6 @@ namespace osu.Game.Screens.Menu LoadComponentAsync(intro = new Intro()); iconColour = colours.Yellow; - - AllowOverlays.Value = OverlayActivation.Disabled; } protected override void OnEntering(Screen last) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index aa89b86786..494c92c698 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -33,6 +33,7 @@ namespace osu.Game.Screens.Menu private SampleChannel seeya; protected override bool HideOverlaysOnEnter => true; + protected override OverlayActivation OverlayActivationLevel => OverlayActivation.Disabled; public override bool CursorVisible => false; @@ -77,8 +78,6 @@ namespace osu.Game.Screens.Menu welcome = audio.Sample.Get(@"welcome"); seeya = audio.Sample.Get(@"seeya"); - - AllowOverlays.Value = OverlayActivation.Disabled; } protected override void OnEntering(Screen last) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 728880b0f8..8eddaaee93 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -10,7 +10,6 @@ using osu.Framework.Input; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; -using osu.Game.Overlays; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Charts; using osu.Game.Screens.Direct; @@ -80,8 +79,6 @@ namespace osu.Game.Screens.Menu } preloadSongSelect(); - - AllowOverlays.Value = OverlayActivation.Disabled; } private void preloadSongSelect() diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index e48d72b6fc..0bff75f53b 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -54,11 +54,12 @@ namespace osu.Game.Screens /// protected virtual bool HideOverlaysOnEnter => false; + private readonly Bindable allowOverlays = new Bindable(); + /// - /// Whether overlays should be able to be opened. - /// It's bound at load which means changes at construction will potentially disappear. + /// Whether overlays should be able to be opened once this screen is entered or resumed. /// - protected readonly Bindable AllowOverlays = new Bindable(); + protected virtual OverlayActivation OverlayActivationLevel => OverlayActivation.All; /// /// Whether this allows the cursor to be displayed. @@ -109,7 +110,7 @@ namespace osu.Game.Screens if (osuGame != null) { Ruleset.BindTo(osuGame.Ruleset); - AllowOverlays.BindTo(osuGame.AllowOverlays); + allowOverlays.BindTo(osuGame.AllowOverlays); updateOverlayStates = () => { @@ -252,6 +253,8 @@ namespace osu.Game.Screens if (backgroundParallaxContainer != null) backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; + allowOverlays.Value = OverlayActivationLevel; + updateOverlayStates?.Invoke(); } From 2afe0feb245b34ca0c5862ec84dda8d12d44518c Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sun, 3 Jun 2018 12:02:43 +0200 Subject: [PATCH 174/253] remove white space I think --- osu.Game/Screens/OsuScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 8a36645145..e705b6f298 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -257,7 +257,7 @@ namespace osu.Game.Screens backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; allowOverlays.Value = OverlayActivationLevel; - + updateOverlayStates?.Invoke(); } From 3795a55808a2f4e591f9f0982efc2c53973b8ec1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 3 Jun 2018 03:26:59 +0900 Subject: [PATCH 175/253] Fix menu flashes not extending to the edge of screen during parallax --- osu.Game/Screens/Menu/MenuSideFlashes.cs | 55 +++++++++++++----------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index fae3e72552..c321c98b24 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -24,8 +24,8 @@ namespace osu.Game.Screens.Menu private readonly Bindable beatmap = new Bindable(); - private readonly Box leftBox; - private readonly Box rightBox; + private Box leftBox; + private Box rightBox; private const float amplitude_dead_zone = 0.25f; private const float alpha_multiplier = (1 - amplitude_dead_zone) / 0.55f; @@ -42,27 +42,6 @@ namespace osu.Game.Screens.Menu RelativeSizeAxes = Axes.Both; Anchor = Anchor.Centre; Origin = Anchor.Centre; - Children = new Drawable[] - { - leftBox = new Box - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.Y, - Width = box_width, - Alpha = 0, - Blending = BlendingMode.Additive, - }, - rightBox = new Box - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - RelativeSizeAxes = Axes.Y, - Width = box_width, - Alpha = 0, - Blending = BlendingMode.Additive, - } - }; } [BackgroundDependencyLoader] @@ -72,10 +51,34 @@ namespace osu.Game.Screens.Menu // linear colour looks better in this case, so let's use it for now. Color4 gradientDark = colours.Blue.Opacity(0).ToLinear(); - Color4 gradientLight = colours.Blue.Opacity(0.3f).ToLinear(); + Color4 gradientLight = colours.Blue.Opacity(0.6f).ToLinear(); - leftBox.Colour = ColourInfo.GradientHorizontal(gradientLight, gradientDark); - rightBox.Colour = ColourInfo.GradientHorizontal(gradientDark, gradientLight); + Children = new Drawable[] + { + leftBox = new Box + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Y, + Width = box_width * 2, + // align off-screen to make sure our edges don't become visible during parallax. + X = -box_width, + Alpha = 0, + Blending = BlendingMode.Additive, + Colour = ColourInfo.GradientHorizontal(gradientLight, gradientDark) + }, + rightBox = new Box + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + RelativeSizeAxes = Axes.Y, + Width = box_width * 2, + X = box_width, + Alpha = 0, + Blending = BlendingMode.Additive, + Colour = ColourInfo.GradientHorizontal(gradientDark, gradientLight) + } + }; } protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) From ed1918cd43984e68e23da1bfd03f7f7375d1ba7f Mon Sep 17 00:00:00 2001 From: ekrctb Date: Sun, 3 Jun 2018 23:10:44 +0900 Subject: [PATCH 176/253] Wait for loading beatmaps --- .../Visual/TestCaseBeatmapCarousel.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs index f819e882d9..4679fca855 100644 --- a/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/TestCaseBeatmapCarousel.cs @@ -65,11 +65,7 @@ namespace osu.Game.Tests.Visual carousel.SelectionChanged = s => currentSelection = s; - AddStep("Load Beatmaps", () => { carousel.BeatmapSets = beatmapSets; }); - - bool changed = false; - carousel.BeatmapSetsChanged = () => changed = true; - AddUntilStep(() => changed, "Wait for load"); + loadBeatmaps(beatmapSets); testTraversal(); testFiltering(); @@ -84,6 +80,17 @@ namespace osu.Game.Tests.Visual testCarouselRootIsRandom(); } + private void loadBeatmaps(List beatmapSets) + { + bool changed = false; + AddStep($"Load {beatmapSets.Count} Beatmaps", () => + { + carousel.BeatmapSetsChanged = () => changed = true; + carousel.BeatmapSets = beatmapSets; + }); + AddUntilStep(() => changed, "Wait for load"); + } + private void ensureRandomFetchSuccess() => AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet); @@ -423,7 +430,7 @@ namespace osu.Game.Tests.Visual for (int i = 1; i <= 50; i++) beatmapSets.Add(createTestBeatmapSet(i)); - AddStep("Load 50 Beatmaps", () => { carousel.BeatmapSets = beatmapSets; }); + loadBeatmaps(beatmapSets); advanceSelection(direction: 1, diff: false); checkNonmatchingFilter(); checkNonmatchingFilter(); From 5c713ac2ababa6eb8f9b2db9ae8cb2a6d3cb9007 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 3 Jun 2018 07:51:57 -0700 Subject: [PATCH 177/253] Use default colour in MetadataSection --- osu.Game/Overlays/BeatmapSet/Info.cs | 3 +-- osu.Game/Screens/Select/BeatmapDetails.cs | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 35a66b1272..e962c885ba 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -135,7 +135,6 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - description.TextColour = source.TextColour = tags.TextColour = colours.Gray5; updateDisplay(); } @@ -194,7 +193,7 @@ namespace osu.Game.Overlays.BeatmapSet [BackgroundDependencyLoader] private void load(OsuColour colours) { - header.Colour = colours.Gray5; + header.Colour = textFlow.Colour = colours.Gray5; } } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 013674b397..68e308783e 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -160,7 +160,6 @@ namespace osu.Game.Screens.Select private void load(APIAccess api) { this.api = api; - description.TextColour = source.TextColour = tags.TextColour = Color4.White.Opacity(0.75f); } protected override void UpdateAfterChildren() @@ -374,6 +373,12 @@ namespace osu.Game.Screens.Select get { return textFlow.Colour; } set { textFlow.Colour = value; } } + + [BackgroundDependencyLoader] + private void load() + { + textFlow.Colour = Color4.White.Opacity(0.75f); + } } private class DimmedLoadingAnimation : VisibilityContainer From 7101533926317b26f22ef91f8bfba4d3273f3815 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 3 Jun 2018 08:02:57 -0700 Subject: [PATCH 178/253] Remove 'description' field --- osu.Game/Overlays/BeatmapSet/Info.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index e962c885ba..53216ad666 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet private const float metadata_width = 225; private const float spacing = 20; - private readonly MetadataSection description, source, tags; + private readonly MetadataSection source, tags; private readonly Box successRateBackground; private readonly SuccessRate successRate; @@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet Child = new Container { RelativeSizeAxes = Axes.Both, - Child = description = new MetadataSection("Description"), + Child = new MetadataSection("Description"), }, }, new Container From 3a823d6c254c1f4560b0a29b0785697b03f31fce Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 4 Jun 2018 02:07:02 +0900 Subject: [PATCH 179/253] Fix multiple issues causing database reset to fail --- osu.Game/Database/DatabaseContextFactory.cs | 41 ++++++++++++++------- osu.Game/Database/OsuDbContext.cs | 17 +++++++-- osu.Game/OsuGameBase.cs | 4 +- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/osu.Game/Database/DatabaseContextFactory.cs b/osu.Game/Database/DatabaseContextFactory.cs index a1d371f431..b5378b1311 100644 --- a/osu.Game/Database/DatabaseContextFactory.cs +++ b/osu.Game/Database/DatabaseContextFactory.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 System; using System.Linq; using System.Threading; using Microsoft.EntityFrameworkCore.Storage; @@ -46,20 +47,35 @@ namespace osu.Game.Database public DatabaseWriteUsage GetForWrite(bool withTransaction = true) { Monitor.Enter(writeLock); + OsuDbContext context; - if (currentWriteTransaction == null && withTransaction) + try { - // this mitigates the fact that changes on tracked entities will not be rolled back with the transaction by ensuring write operations are always executed in isolated contexts. - // if this results in sub-optimal efficiency, we may need to look into removing Database-level transactions in favour of running SaveChanges where we currently commit the transaction. - if (threadContexts.IsValueCreated) - recycleThreadContexts(); + if (currentWriteTransaction == null && withTransaction) + { + // this mitigates the fact that changes on tracked entities will not be rolled back with the transaction by ensuring write operations are always executed in isolated contexts. + // if this results in sub-optimal efficiency, we may need to look into removing Database-level transactions in favour of running SaveChanges where we currently commit the transaction. + if (threadContexts.IsValueCreated) + recycleThreadContexts(); - currentWriteTransaction = threadContexts.Value.Database.BeginTransaction(); + context = threadContexts.Value; + currentWriteTransaction = context.Database.BeginTransaction(); + } + else + { + context = threadContexts.Value; + } + } + catch (Exception e) + { + // retrieval of a context could trigger a fatal error. + Monitor.Exit(writeLock); + throw; } Interlocked.Increment(ref currentWriteUsages); - return new DatabaseWriteUsage(threadContexts.Value, usageCompleted) { IsTransactionLeader = currentWriteTransaction != null && currentWriteUsages == 1 }; + return new DatabaseWriteUsage(context, usageCompleted) { IsTransactionLeader = currentWriteTransaction != null && currentWriteUsages == 1 }; } private void usageCompleted(DatabaseWriteUsage usage) @@ -100,19 +116,18 @@ namespace osu.Game.Database private void recycleThreadContexts() => threadContexts = new ThreadLocal(CreateContext); - protected virtual OsuDbContext CreateContext() + protected virtual OsuDbContext CreateContext() => new OsuDbContext(host.Storage.GetDatabaseConnectionString(database_name)) { - var ctx = new OsuDbContext(host.Storage.GetDatabaseConnectionString(database_name)); - ctx.Database.AutoTransactionsEnabled = false; - - return ctx; - } + Database = { AutoTransactionsEnabled = false } + }; public void ResetDatabase() { lock (writeLock) { recycleThreadContexts(); + GC.Collect(); + GC.WaitForPendingFinalizers(); host.Storage.DeleteDatabase(database_name); } } diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index 7758b3eb25..4b0de57c4c 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -58,11 +58,20 @@ namespace osu.Game.Database this.connectionString = connectionString; var connection = Database.GetDbConnection(); - connection.Open(); - using (var cmd = connection.CreateCommand()) + try { - cmd.CommandText = "PRAGMA journal_mode=WAL;"; - cmd.ExecuteNonQuery(); + connection.Open(); + + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = "PRAGMA journal_mode=WAL;"; + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + connection.Close(); + throw; } } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index b9d32a6322..f6b3935689 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -211,15 +211,17 @@ namespace osu.Game using (var db = contextFactory.GetForWrite(false)) db.Context.Migrate(); } - catch (MigrationFailedException e) + catch (Exception e) { Logger.Error(e.InnerException ?? e, "Migration failed! We'll be starting with a fresh database.", LoggingTarget.Database); // if we failed, let's delete the database and start fresh. // todo: we probably want a better (non-destructive) migrations/recovery process at a later point than this. contextFactory.ResetDatabase(); + Logger.Log("Database purged successfully.", LoggingTarget.Database, LogLevel.Important); + // only run once more, then hard bail. using (var db = contextFactory.GetForWrite(false)) db.Context.Migrate(); } From bd7c9cd8bffcf880518b0cc8159a3f32ab5f2fc6 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 3 Jun 2018 17:41:34 -0700 Subject: [PATCH 180/253] Set 'Colour' when creating 'textFlow' --- osu.Game/Screens/Select/BeatmapDetails.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 68e308783e..f1bd2b945f 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -356,7 +356,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Colour = textFlow.Colour, + Colour = Color4.White.Opacity(0.75f), Text = text }, loaded => { @@ -367,18 +367,6 @@ namespace osu.Game.Screens.Select this.FadeIn(transition_duration); }); } - - public Color4 TextColour - { - get { return textFlow.Colour; } - set { textFlow.Colour = value; } - } - - [BackgroundDependencyLoader] - private void load() - { - textFlow.Colour = Color4.White.Opacity(0.75f); - } } private class DimmedLoadingAnimation : VisibilityContainer From db4c26e1ab5371ea7307f3c1e8c358143eef39d1 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 3 Jun 2018 22:22:44 -0300 Subject: [PATCH 181/253] Rewrite ScoreComponentLabel. --- .../Select/Leaderboards/LeaderboardScore.cs | 74 ++++++++++++------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index baab973ae5..c39c4e43d3 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -142,6 +142,8 @@ namespace osu.Game.Screens.Select.Leaderboards { flagBadgeContainer = new Container { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, Size = new Vector2(87f, 20f), Masking = true, Children = new Drawable[] @@ -155,10 +157,12 @@ namespace osu.Game.Screens.Select.Leaderboards }, new FillFlowContainer { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10f, 0f), - Margin = new MarginPadding { Left = edge_margin, }, + Margin = new MarginPadding { Left = edge_margin }, Children = new Drawable[] { maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString()), @@ -307,35 +311,55 @@ namespace osu.Game.Screens.Select.Leaderboards private class ScoreComponentLabel : Container { + private const float icon_size = 20; + + private readonly FillFlowContainer content; + + protected override Container Content => content; + public ScoreComponentLabel(FontAwesome icon, string value) { - Anchor = Anchor.CentreLeft; - Origin = Anchor.CentreLeft; - Size = new Vector2(60f, 20f); - Padding = new MarginPadding { Top = 10f, }; + AutoSizeAxes = Axes.Y; + Width = 60; - Children = new Drawable[] + InternalChild = content = new FillFlowContainer { - new SpriteIcon + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new Drawable[] { - Origin = Anchor.Centre, - Icon = FontAwesome.fa_square, - Colour = OsuColour.FromHex(@"3087ac"), - Rotation = 45, - Size = new Vector2(20), - Shadow = true, - }, - new SpriteIcon - { - Origin = Anchor.Centre, - Icon = icon, - Colour = OsuColour.FromHex(@"a4edff"), - Size = new Vector2(14), - }, - new GlowingSpriteText(value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa")) - { - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Left = 15, }, + new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Children = new[] + { + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(icon_size), + Rotation = 45, + Colour = OsuColour.FromHex(@"3087ac"), + Icon = FontAwesome.fa_square, + Shadow = true, + }, + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(icon_size - 6), + Colour = OsuColour.FromHex(@"a4edff"), + Icon = icon, + }, + }, + }, + new GlowingSpriteText(value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa")) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, }, }; } From a7bab14b303b70e59aa333519a7db16601b312ff Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 3 Jun 2018 22:26:30 -0300 Subject: [PATCH 182/253] Add tooltip to ScoreComponentLabel. --- .../Select/Leaderboards/LeaderboardScore.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index c39c4e43d3..19732107c7 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics; @@ -165,8 +166,8 @@ namespace osu.Game.Screens.Select.Leaderboards Margin = new MarginPadding { Left = edge_margin }, Children = new Drawable[] { - maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString()), - accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy)), + maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString(), "Max Combo"), + accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy), "Accuracy"), }, }, }, @@ -309,20 +310,24 @@ namespace osu.Game.Screens.Select.Leaderboards } } - private class ScoreComponentLabel : Container + private class ScoreComponentLabel : Container, IHasTooltip { private const float icon_size = 20; + private readonly string name; private readonly FillFlowContainer content; - protected override Container Content => content; + public override bool Contains(Vector2 screenSpacePos) => content.Contains(screenSpacePos); - public ScoreComponentLabel(FontAwesome icon, string value) + public string TooltipText => name; + + public ScoreComponentLabel(FontAwesome icon, string value, string name) { + this.name = name; AutoSizeAxes = Axes.Y; Width = 60; - InternalChild = content = new FillFlowContainer + Child = content = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, From 4b828b104817cfade7e3c24747ca6f769d0a98e0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 4 Jun 2018 10:37:24 +0900 Subject: [PATCH 183/253] Fix incorrect release build vscode configurations --- osu.Game.Rulesets.Catch.Tests/.vscode/launch.json | 4 ++-- osu.Game.Rulesets.Mania.Tests/.vscode/launch.json | 4 ++-- osu.Game.Rulesets.Osu.Tests/.vscode/launch.json | 4 ++-- osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json b/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json index c5005adfa5..2a82d65014 100644 --- a/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Catch.Tests/.vscode/launch.json @@ -22,7 +22,7 @@ }, "type": "mono", "request": "launch", - "program": "${workspaceRoot}/bin/Debug/net471/osu.Game.Rulesets.Catch.Tests.exe", + "program": "${workspaceRoot}/bin/Release/net471/osu.Game.Rulesets.Catch.Tests.exe", "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, msbuild)", "runtimeExecutable": null, @@ -48,7 +48,7 @@ "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Catch.Tests.dll" + "${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Catch.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", diff --git a/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json b/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json index 637a5de1b5..bc41d4ccf9 100644 --- a/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Mania.Tests/.vscode/launch.json @@ -22,7 +22,7 @@ }, "type": "mono", "request": "launch", - "program": "${workspaceRoot}/bin/Debug/net471/osu.Game.Rulesets.Mania.Tests.exe", + "program": "${workspaceRoot}/bin/Release/net471/osu.Game.Rulesets.Mania.Tests.exe", "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, msbuild)", "runtimeExecutable": null, @@ -48,7 +48,7 @@ "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Mania.Tests.dll" + "${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Mania.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", diff --git a/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json b/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json index 65c801cef4..13aba025fd 100644 --- a/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Osu.Tests/.vscode/launch.json @@ -22,7 +22,7 @@ }, "type": "mono", "request": "launch", - "program": "${workspaceRoot}/bin/Debug/net471/osu.Game.Rulesets.Osu.Tests.exe", + "program": "${workspaceRoot}/bin/Release/net471/osu.Game.Rulesets.Osu.Tests.exe", "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, msbuild)", "runtimeExecutable": null, @@ -48,7 +48,7 @@ "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Osu.Tests.dll" + "${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Osu.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", diff --git a/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json b/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json index dbb1ab28e2..df49e177dc 100644 --- a/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json +++ b/osu.Game.Rulesets.Taiko.Tests/.vscode/launch.json @@ -22,7 +22,7 @@ }, "type": "mono", "request": "launch", - "program": "${workspaceRoot}/bin/Debug/net471/osu.Game.Rulesets.Taiko.Tests.exe", + "program": "${workspaceRoot}/bin/Release/net471/osu.Game.Rulesets.Taiko.Tests.exe", "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, msbuild)", "runtimeExecutable": null, @@ -48,7 +48,7 @@ "request": "launch", "program": "dotnet", "args": [ - "${workspaceRoot}/bin/Debug/netcoreapp2.1/osu.Game.Rulesets.Taiko.Tests.dll" + "${workspaceRoot}/bin/Release/netcoreapp2.1/osu.Game.Rulesets.Taiko.Tests.dll" ], "cwd": "${workspaceRoot}", "preLaunchTask": "Build (Release, dotnet)", From 0f7b23d765a1724105c7b3a14d77bfe96a3e327c Mon Sep 17 00:00:00 2001 From: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com> Date: Mon, 4 Jun 2018 11:11:07 +0900 Subject: [PATCH 184/253] Add param explanatory blurb to xmldoc --- osu.Game/Beatmaps/GameBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/GameBeatmap.cs b/osu.Game/Beatmaps/GameBeatmap.cs index ea19337c8c..e470dd8ac5 100644 --- a/osu.Game/Beatmaps/GameBeatmap.cs +++ b/osu.Game/Beatmaps/GameBeatmap.cs @@ -27,7 +27,7 @@ namespace osu.Game.Beatmaps /// /// Registers an for s to be added to. /// - /// The . + /// The to register. protected void RegisterAudioManager([NotNull] AudioManager audioManager) { if (this.audioManager != null) throw new InvalidOperationException($"Cannot register multiple {nameof(AudioManager)}s."); From 7b7236929a0e2166b94d6f66eb6bbdc0334eb588 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 06:08:39 -0300 Subject: [PATCH 185/253] Add BeatmapSetDownloadButton. --- .../UserInterface/BeatmapSetDownloadButton.cs | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs diff --git a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs new file mode 100644 index 0000000000..091b0ddbd4 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs @@ -0,0 +1,83 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Input; +using osu.Game.Beatmaps; +using osu.Game.Graphics.Containers; +using osu.Game.Online.API; + +namespace osu.Game.Graphics.UserInterface +{ + public abstract class BeatmapSetDownloadButton : OsuClickableContainer + { + private readonly BeatmapSetInfo set; + private readonly bool noVideo; + private readonly BindableBool downloaded = new BindableBool(); + + private Action action; + public Action Action + { + get => action; + set => action = value; + } + + protected BeatmapSetDownloadButton(BeatmapSetInfo set, bool noVideo = false) + { + this.set = set; + this.noVideo = noVideo; + + downloaded.ValueChanged += e => + { + if (e) + Disable(); + else + Enable(); + }; + } + + [BackgroundDependencyLoader] + private void load(BeatmapManager beatmaps, APIAccess api) + { + beatmaps.ItemAdded += s => + { + if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) + downloaded.Value = true; + }; + + beatmaps.ItemRemoved += s => + { + if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) + downloaded.Value = false; + }; + + // initial downloaded value + downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; + + Action = () => + { + if (beatmaps.GetExistingDownload(set) != null) + { + AlreadyDownloading(); + return; + } + + beatmaps.Download(set, noVideo); + }; + } + + protected override bool OnClick(InputState state) + { + if (!downloaded.Value) + Action?.Invoke(); + return true; + } + + protected abstract void Enable(); + protected abstract void Disable(); + protected abstract void AlreadyDownloading(); + } +} From b332c22fe5c418438cd70fc72c1c6afe0a363062 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 06:29:35 -0300 Subject: [PATCH 186/253] Update DirectPanel to use BeatmapSetDownloadButton. --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 3 +-- osu.Game/Overlays/Direct/DirectListPanel.cs | 3 +-- osu.Game/Overlays/Direct/DirectPanel.cs | 16 -------------- osu.Game/Overlays/Direct/DownloadButton.cs | 21 ++++++++++++++++--- osu.Game/Overlays/DirectOverlay.cs | 23 +-------------------- 5 files changed, 21 insertions(+), 45 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index ed4630a8e7..723e9e8b35 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -166,14 +166,13 @@ namespace osu.Game.Overlays.Direct }, }, }, - new DownloadButton + new DownloadButton(SetInfo) { Size = new Vector2(30), Margin = new MarginPadding(horizontal_padding), Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, Colour = colours.Gray5, - Action = StartDownload }, }, }, diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 13398a4a32..c949e0d088 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -144,12 +144,11 @@ namespace osu.Game.Overlays.Direct }, }, }, - new DownloadButton + new DownloadButton(SetInfo) { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Size = new Vector2(height - vertical_padding * 2), - Action = StartDownload }, }, }, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index df784252ce..e767f6ec83 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -147,22 +147,6 @@ namespace osu.Game.Overlays.Direct protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo); - protected void StartDownload() - { - if (beatmaps.GetExistingDownload(SetInfo) != null) - { - // we already have an active download running. - content.MoveToX(-5, 50, Easing.OutSine).Then() - .MoveToX(5, 100, Easing.InOutSine).Then() - .MoveToX(-5, 100, Easing.InOutSine).Then() - .MoveToX(0, 50, Easing.InSine).Then(); - - return; - } - - beatmaps.Download(SetInfo); - } - private void attachDownload(DownloadBeatmapSetRequest request) { if (request.BeatmapSet.OnlineBeatmapSetID != SetInfo.OnlineBeatmapSetID) diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index f01c9dac59..a6d7a4215d 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -3,17 +3,18 @@ using osu.Framework.Graphics; using osu.Framework.Input; +using osu.Game.Beatmaps; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; using OpenTK; namespace osu.Game.Overlays.Direct { - public class DownloadButton : OsuClickableContainer + public class DownloadButton : BeatmapSetDownloadButton { private readonly SpriteIcon icon; - public DownloadButton() + public DownloadButton(BeatmapSetInfo set, bool noVideo = false) : base(set, noVideo) { Children = new Drawable[] { @@ -49,5 +50,19 @@ namespace osu.Game.Overlays.Direct { icon.ScaleTo(1f, 500, Easing.OutElastic); } + + protected override void Enable() + { + this.FadeIn(200); + } + + protected override void Disable() + { + this.FadeOut(200); + } + + protected override void AlreadyDownloading() + { + } } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index f437546888..99f6de8559 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -28,7 +28,6 @@ namespace osu.Game.Overlays private APIAccess api; private RulesetStore rulesets; - private BeatmapManager beatmaps; private readonly FillFlowContainer resultCountsContainer; private readonly OsuSpriteText resultCountsText; @@ -181,20 +180,10 @@ namespace osu.Game.Overlays { this.api = api; this.rulesets = rulesets; - this.beatmaps = beatmaps; resultCountsContainer.Colour = colours.Yellow; - - beatmaps.ItemAdded += setAdded; } - private void setAdded(BeatmapSetInfo set) => Schedule(() => - { - // if a new map was imported, we should remove it from search results (download completed etc.) - panels?.FirstOrDefault(p => p.SetInfo.OnlineBeatmapSetID == set.OnlineBeatmapSetID)?.FadeOut(400).Expire(); - BeatmapSets = BeatmapSets?.Where(b => b.OnlineBeatmapSetID != set.OnlineBeatmapSetID); - }); - private void updateResultCounts() { resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, Easing.OutQuint); @@ -297,9 +286,7 @@ namespace osu.Game.Overlays { Task.Run(() => { - var onlineIds = response.Select(r => r.OnlineBeatmapSetID).ToList(); - var presentOnlineIds = beatmaps.QueryBeatmapSets(s => onlineIds.Contains(s.OnlineBeatmapSetID) && !s.DeletePending).Select(r => r.OnlineBeatmapSetID).ToList(); - var sets = response.Select(r => r.ToBeatmapSet(rulesets)).Where(b => !presentOnlineIds.Contains(b.OnlineBeatmapSetID)).ToList(); + var sets = response.Select(r => r.ToBeatmapSet(rulesets)).ToList(); // may not need scheduling; loads async internally. Schedule(() => @@ -323,14 +310,6 @@ namespace osu.Game.Overlays private int distinctCount(List list) => list.Distinct().ToArray().Length; - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - - if (beatmaps != null) - beatmaps.ItemAdded -= setAdded; - } - public class ResultCounts { public readonly int Artists; From 7eeba2cf9a83934a13aade4fcaecf3b7e4206203 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 06:34:48 -0300 Subject: [PATCH 187/253] Unsubscribe from BeatmapManager events in Dispose. --- .../UserInterface/BeatmapSetDownloadButton.cs | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs index 091b0ddbd4..39bbc8216a 100644 --- a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs +++ b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs @@ -18,6 +18,8 @@ namespace osu.Game.Graphics.UserInterface private readonly bool noVideo; private readonly BindableBool downloaded = new BindableBool(); + private BeatmapManager beatmaps; + private Action action; public Action Action { @@ -42,17 +44,10 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(BeatmapManager beatmaps, APIAccess api) { - beatmaps.ItemAdded += s => - { - if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) - downloaded.Value = true; - }; + this.beatmaps = beatmaps; - beatmaps.ItemRemoved += s => - { - if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) - downloaded.Value = false; - }; + beatmaps.ItemAdded += setAdded; + beatmaps.ItemRemoved += setRemoved; // initial downloaded value downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; @@ -76,8 +71,31 @@ namespace osu.Game.Graphics.UserInterface return true; } + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (beatmaps != null) + { + beatmaps.ItemAdded -= setAdded; + beatmaps.ItemRemoved -= setRemoved; + } + } + protected abstract void Enable(); protected abstract void Disable(); protected abstract void AlreadyDownloading(); + + private void setAdded(BeatmapSetInfo s) + { + if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) + downloaded.Value = true; + } + + private void setRemoved(BeatmapSetInfo s) + { + if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) + downloaded.Value = false; + } } } From 416384956d1ac646b7c1fe48733652439f98abba Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 06:47:39 -0300 Subject: [PATCH 188/253] Use a protected Downloaded bindable instead of abstract methods. --- .../UserInterface/BeatmapSetDownloadButton.cs | 33 +++++-------------- osu.Game/Overlays/Direct/DownloadButton.cs | 22 +++++-------- 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs index 39bbc8216a..d55a133d18 100644 --- a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs +++ b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.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 System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -16,29 +15,15 @@ namespace osu.Game.Graphics.UserInterface { private readonly BeatmapSetInfo set; private readonly bool noVideo; - private readonly BindableBool downloaded = new BindableBool(); private BeatmapManager beatmaps; - private Action action; - public Action Action - { - get => action; - set => action = value; - } + protected readonly BindableBool Downloaded = new BindableBool(); protected BeatmapSetDownloadButton(BeatmapSetInfo set, bool noVideo = false) { this.set = set; this.noVideo = noVideo; - - downloaded.ValueChanged += e => - { - if (e) - Disable(); - else - Enable(); - }; } [BackgroundDependencyLoader] @@ -49,8 +34,8 @@ namespace osu.Game.Graphics.UserInterface beatmaps.ItemAdded += setAdded; beatmaps.ItemRemoved += setRemoved; - // initial downloaded value - downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; + // initial value + Downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; Action = () => { @@ -66,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnClick(InputState state) { - if (!downloaded.Value) + if (Enabled.Value && !Downloaded.Value) Action?.Invoke(); return true; } @@ -82,20 +67,20 @@ namespace osu.Game.Graphics.UserInterface } } - protected abstract void Enable(); - protected abstract void Disable(); - protected abstract void AlreadyDownloading(); + protected virtual void AlreadyDownloading() + { + } private void setAdded(BeatmapSetInfo s) { if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) - downloaded.Value = true; + Downloaded.Value = true; } private void setRemoved(BeatmapSetInfo s) { if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID) - downloaded.Value = false; + Downloaded.Value = false; } } } diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index a6d7a4215d..1b072a4101 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -26,6 +26,14 @@ namespace osu.Game.Overlays.Direct Icon = FontAwesome.fa_osu_chevron_down_o, }, }; + + Downloaded.ValueChanged += e => + { + if (e) + this.FadeOut(200); + else + this.FadeIn(200); + }; } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -50,19 +58,5 @@ namespace osu.Game.Overlays.Direct { icon.ScaleTo(1f, 500, Easing.OutElastic); } - - protected override void Enable() - { - this.FadeIn(200); - } - - protected override void Disable() - { - this.FadeOut(200); - } - - protected override void AlreadyDownloading() - { - } } } From 4bdc1fb7816c17f5362585e25f6874e4fe590323 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 07:10:33 -0300 Subject: [PATCH 189/253] Remove unused using. --- osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs index d55a133d18..3b889746ab 100644 --- a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs +++ b/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs @@ -7,7 +7,6 @@ using osu.Framework.Configuration; using osu.Framework.Input; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; -using osu.Game.Online.API; namespace osu.Game.Graphics.UserInterface { @@ -27,7 +26,7 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(BeatmapManager beatmaps, APIAccess api) + private void load(BeatmapManager beatmaps) { this.beatmaps = beatmaps; From b84441ab879271de900099b4b23a2c2bc1099db7 Mon Sep 17 00:00:00 2001 From: ekrctb Date: Mon, 4 Jun 2018 22:25:18 +0900 Subject: [PATCH 190/253] Fix TestImportOverIPC --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 586217a05f..645c76f265 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -264,7 +264,8 @@ namespace osu.Game.Tests.Beatmaps.IO private string createTemporaryBeatmap() { - var temp = new FileInfo(osz_path).CopyTo(Path.GetTempFileName(), true).FullName; + var temp = Path.GetTempFileName() + Guid.NewGuid() + ".osz"; + File.Copy(osz_path, temp, true); Assert.IsTrue(File.Exists(temp)); return temp; } @@ -344,12 +345,12 @@ namespace osu.Game.Tests.Beatmaps.IO private void waitForOrAssert(Func result, string failureMessage, int timeout = 60000) { - Action waitAction = () => + Task task = Task.Run(() => { while (!result()) Thread.Sleep(200); - }; + }); - Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), failureMessage); + Assert.IsTrue(task.Wait(timeout), failureMessage); } } } From 698a42f1454dc088004dcdeac29468d8ba8c449a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 20:12:43 -0300 Subject: [PATCH 191/253] BeatmapSetDownloadButton -> BeatmapSetDownloader Allows it to integrate better with existing buttons, like HeaderButton. --- ...nloadButton.cs => BeatmapSetDownloader.cs} | 42 ++++++++----------- osu.Game/Overlays/Direct/DownloadButton.cs | 11 +++-- 2 files changed, 26 insertions(+), 27 deletions(-) rename osu.Game/Graphics/UserInterface/{BeatmapSetDownloadButton.cs => BeatmapSetDownloader.cs} (67%) diff --git a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs b/osu.Game/Graphics/UserInterface/BeatmapSetDownloader.cs similarity index 67% rename from osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs rename to osu.Game/Graphics/UserInterface/BeatmapSetDownloader.cs index 3b889746ab..4fe1527283 100644 --- a/osu.Game/Graphics/UserInterface/BeatmapSetDownloadButton.cs +++ b/osu.Game/Graphics/UserInterface/BeatmapSetDownloader.cs @@ -1,25 +1,27 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; -using osu.Framework.Input; +using osu.Framework.Graphics; using osu.Game.Beatmaps; -using osu.Game.Graphics.Containers; namespace osu.Game.Graphics.UserInterface { - public abstract class BeatmapSetDownloadButton : OsuClickableContainer + public class BeatmapSetDownloader : Drawable { private readonly BeatmapSetInfo set; private readonly bool noVideo; private BeatmapManager beatmaps; - protected readonly BindableBool Downloaded = new BindableBool(); + public readonly BindableBool Downloaded = new BindableBool(); - protected BeatmapSetDownloadButton(BeatmapSetInfo set, bool noVideo = false) + public event Action OnAlreadyDownloading; + + public BeatmapSetDownloader(BeatmapSetInfo set, bool noVideo = false) { this.set = set; this.noVideo = noVideo; @@ -35,24 +37,6 @@ namespace osu.Game.Graphics.UserInterface // initial value Downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; - - Action = () => - { - if (beatmaps.GetExistingDownload(set) != null) - { - AlreadyDownloading(); - return; - } - - beatmaps.Download(set, noVideo); - }; - } - - protected override bool OnClick(InputState state) - { - if (Enabled.Value && !Downloaded.Value) - Action?.Invoke(); - return true; } protected override void Dispose(bool isDisposing) @@ -66,8 +50,18 @@ namespace osu.Game.Graphics.UserInterface } } - protected virtual void AlreadyDownloading() + public void Download() { + if (Downloaded.Value) + return; + + if (beatmaps.GetExistingDownload(set) != null) + { + OnAlreadyDownloading?.Invoke(); + return; + } + + beatmaps.Download(set, noVideo); } private void setAdded(BeatmapSetInfo s) diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 1b072a4101..66bca9ed17 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -5,19 +5,22 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using OpenTK; namespace osu.Game.Overlays.Direct { - public class DownloadButton : BeatmapSetDownloadButton + public class DownloadButton : OsuClickableContainer { private readonly SpriteIcon icon; - public DownloadButton(BeatmapSetInfo set, bool noVideo = false) : base(set, noVideo) + public DownloadButton(BeatmapSetInfo set, bool noVideo = false) { + BeatmapSetDownloader downloader; Children = new Drawable[] { + downloader = new BeatmapSetDownloader(set, noVideo), icon = new SpriteIcon { Anchor = Anchor.Centre, @@ -27,7 +30,9 @@ namespace osu.Game.Overlays.Direct }, }; - Downloaded.ValueChanged += e => + Action = downloader.Download; + + downloader.Downloaded.ValueChanged += e => { if (e) this.FadeOut(200); From 9377ffb784641d4d825b2472208cd03e11471a6f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 20:27:34 -0300 Subject: [PATCH 192/253] Update BeatmapSetOverlay to use BeatmapSetDownloader. --- .../BeatmapSet/Buttons/DownloadButton.cs | 16 ++++- osu.Game/Overlays/BeatmapSet/Header.cs | 70 +++++-------------- osu.Game/Overlays/Direct/DownloadButton.cs | 4 +- 3 files changed, 36 insertions(+), 54 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index c699ae2328..2dc0892704 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -3,18 +3,21 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using OpenTK; namespace osu.Game.Overlays.BeatmapSet.Buttons { public class DownloadButton : HeaderButton { - public DownloadButton(string title, string subtitle) + public DownloadButton(string title, string subtitle, BeatmapSetInfo set, bool noVideo = false) { Width = 120; + BeatmapSetDownloader downloader; Add(new Container { Depth = -1, @@ -22,6 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons Padding = new MarginPadding { Horizontal = 10 }, Children = new Drawable[] { + downloader = new BeatmapSetDownloader(set, noVideo), new FillFlowContainer { Anchor = Anchor.CentreLeft, @@ -54,6 +58,16 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, }, }); + + Action = downloader.Download; + + downloader.Downloaded.ValueChanged += d => + { + if (d) + this.FadeOut(200); + else + this.FadeIn(200); + }; } } } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 89c141ef17..a1ef82c995 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -35,8 +35,6 @@ namespace osu.Game.Overlays.BeatmapSet private readonly BeatmapSetOnlineStatusPill onlineStatusPill; public Details Details; - private BeatmapManager beatmaps; - public readonly BeatmapPicker Picker; private BeatmapSetInfo beatmapSet; @@ -68,8 +66,24 @@ namespace osu.Game.Overlays.BeatmapSet downloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); - noVideoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 0 : 1, transition_duration); - videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration); + if (BeatmapSet.OnlineInfo.HasVideo) + { + videoButtons.Children = new[] + { + new DownloadButton("Download", "with Video", BeatmapSet), + new DownloadButton("Download", "without Video", BeatmapSet, true), + }; + + videoButtons.FadeIn(transition_duration); + noVideoButtons.FadeOut(transition_duration); + } + else + { + noVideoButtons.Child = new DownloadButton("Download", string.Empty, BeatmapSet); + + noVideoButtons.FadeIn(transition_duration); + videoButtons.FadeOut(transition_duration); + } } else { @@ -192,27 +206,12 @@ namespace osu.Game.Overlays.BeatmapSet { RelativeSizeAxes = Axes.Both, Alpha = 0f, - Child = new DownloadButton("Download", @"") - { - Action = () => download(false), - }, }, videoButtons = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Spacing = new Vector2(buttons_spacing), Alpha = 0f, - Children = new[] - { - new DownloadButton("Download", "with Video") - { - Action = () => download(false), - }, - new DownloadButton("Download", "without Video") - { - Action = () => download(true), - }, - }, }, }, }, @@ -248,41 +247,10 @@ namespace osu.Game.Overlays.BeatmapSet } [BackgroundDependencyLoader] - private void load(OsuColour colours, BeatmapManager beatmaps) + private void load(OsuColour colours) { tabsBg.Colour = colours.Gray3; - this.beatmaps = beatmaps; - - beatmaps.ItemAdded += handleBeatmapAdd; - updateDisplay(); } - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - if (beatmaps != null) beatmaps.ItemAdded -= handleBeatmapAdd; - } - - private void handleBeatmapAdd(BeatmapSetInfo beatmap) => Schedule(() => - { - if (beatmap.OnlineBeatmapSetID == BeatmapSet?.OnlineBeatmapSetID) - downloadButtonsContainer.FadeOut(transition_duration); - }); - - private void download(bool noVideo) - { - if (beatmaps.GetExistingDownload(BeatmapSet) != null) - { - downloadButtonsContainer.MoveToX(-5, 50, Easing.OutSine).Then() - .MoveToX(5, 100, Easing.InOutSine).Then() - .MoveToX(-5, 100, Easing.InOutSine).Then() - .MoveToX(0, 50, Easing.InSine).Then(); - - return; - } - - beatmaps.Download(BeatmapSet, noVideo); - } } } diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 66bca9ed17..e40b7ae0cb 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -32,9 +32,9 @@ namespace osu.Game.Overlays.Direct Action = downloader.Download; - downloader.Downloaded.ValueChanged += e => + downloader.Downloaded.ValueChanged += d => { - if (e) + if (d) this.FadeOut(200); else this.FadeIn(200); From 01c5060bcf0f5cb966d397711f82b937ebfba515 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 20:30:54 -0300 Subject: [PATCH 193/253] Move BeatmapSetDownloader to osu.Game.Beatmaps.Drawables --- .../Drawables}/BeatmapSetDownloader.cs | 3 +-- osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs | 2 +- osu.Game/Overlays/Direct/DownloadButton.cs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) rename osu.Game/{Graphics/UserInterface => Beatmaps/Drawables}/BeatmapSetDownloader.cs (96%) diff --git a/osu.Game/Graphics/UserInterface/BeatmapSetDownloader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs similarity index 96% rename from osu.Game/Graphics/UserInterface/BeatmapSetDownloader.cs rename to osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs index 4fe1527283..e800eb5115 100644 --- a/osu.Game/Graphics/UserInterface/BeatmapSetDownloader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs @@ -6,9 +6,8 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Game.Beatmaps; -namespace osu.Game.Graphics.UserInterface +namespace osu.Game.Beatmaps.Drawables { public class BeatmapSetDownloader : Drawable { diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index 2dc0892704..310bfe3372 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -4,9 +4,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using OpenTK; namespace osu.Game.Overlays.BeatmapSet.Buttons diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index e40b7ae0cb..a55a6507b9 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -4,9 +4,9 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.UserInterface; using OpenTK; namespace osu.Game.Overlays.Direct From c524289b246a48e347f5031ca36647e09f23686d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 21:01:15 -0300 Subject: [PATCH 194/253] Update DirectListPanel to properly handle hiding DownloadButton. --- osu.Game/Overlays/Direct/DirectListPanel.cs | 98 ++++++++++++++------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index c949e0d088..6e3483604b 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -12,28 +12,31 @@ using osu.Game.Graphics.Sprites; using osu.Framework.Allocation; using osu.Framework.Localisation; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Game.Beatmaps; namespace osu.Game.Overlays.Direct { public class DirectListPanel : DirectPanel { + private const float transition_duration = 120; private const float horizontal_padding = 10; private const float vertical_padding = 5; private const float height = 70; + private PlayButton playButton; + private Box progressBar; + private Container downloadContainer; + + protected override PlayButton PlayButton => playButton; + protected override Box PreviewBar => progressBar; + public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap) { RelativeSizeAxes = Axes.X; Height = height; } - private PlayButton playButton; - private Box progressBar; - - protected override PlayButton PlayButton => playButton; - protected override Box PreviewBar => progressBar; - [BackgroundDependencyLoader] private void load(LocalisationEngine localisation, OsuColour colours) { @@ -59,7 +62,7 @@ namespace osu.Game.Overlays.Direct AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, LayoutEasing = Easing.OutQuint, - LayoutDuration = 120, + LayoutDuration = transition_duration, Spacing = new Vector2(10, 0), Children = new Drawable[] { @@ -104,52 +107,69 @@ namespace osu.Game.Overlays.Direct Anchor = Anchor.TopRight, Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding }, + Direction = FillDirection.Horizontal, + LayoutEasing = Easing.OutQuint, + LayoutDuration = transition_duration, Children = new Drawable[] { - new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0) + downloadContainer = new Container { - Margin = new MarginPadding { Right = 1 }, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Alpha = 0, + Child = new DownloadButton(SetInfo) + { + Size = new Vector2(height - vertical_padding * 2), + Margin = new MarginPadding { Left = vertical_padding }, + }, }, - new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), new FillFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] + Direction = FillDirection.Vertical, + Children = new Drawable[] { - new OsuSpriteText + new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0) { - Text = "mapped by ", - TextSize = 14, + Margin = new MarginPadding { Right = 1 }, + }, + new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Text = "mapped by ", + TextSize = 14, + }, + new OsuSpriteText + { + Text = SetInfo.Metadata.Author.Username, + TextSize = 14, + Font = @"Exo2.0-SemiBoldItalic", + }, + }, }, new OsuSpriteText { - Text = SetInfo.Metadata.Author.Username, + Text = $"from {SetInfo.Metadata.Source}", + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, TextSize = 14, - Font = @"Exo2.0-SemiBoldItalic", + Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, }, }, }, - new OsuSpriteText - { - Text = $"from {SetInfo.Metadata.Source}", - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - TextSize = 14, - Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, - }, }, }, - new DownloadButton(SetInfo) - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Size = new Vector2(height - vertical_padding * 2), - }, }, }, progressBar = new Box @@ -164,5 +184,17 @@ namespace osu.Game.Overlays.Direct }, }); } + + protected override bool OnHover(InputState state) + { + downloadContainer.FadeIn(transition_duration, Easing.InOutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + downloadContainer.FadeOut(transition_duration, Easing.InOutQuint); + base.OnHoverLost(state); + } } } From 61e135841034da3b047a586bb2b3c9db4d8d67e0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 21:07:17 -0300 Subject: [PATCH 195/253] Add OnAlreadyDownloading animations. --- osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs | 8 ++++++++ osu.Game/Overlays/Direct/DownloadButton.cs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index 310bfe3372..cf7d3cda5a 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -68,6 +68,14 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons else this.FadeIn(200); }; + + downloader.OnAlreadyDownloading += () => + { + Content.MoveToX(-5, 50, Easing.OutSine).Then() + .MoveToX(5, 100, Easing.InOutSine).Then() + .MoveToX(-5, 100, Easing.InOutSine).Then() + .MoveToX(0, 50, Easing.InSine); + }; } } } diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index a55a6507b9..a621199916 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -39,6 +39,14 @@ namespace osu.Game.Overlays.Direct else this.FadeIn(200); }; + + downloader.OnAlreadyDownloading += () => + { + Content.MoveToX(-5, 50, Easing.OutSine).Then() + .MoveToX(5, 100, Easing.InOutSine).Then() + .MoveToX(-5, 100, Easing.InOutSine).Then() + .MoveToX(0, 50, Easing.InSine); + }; } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) From d8154f8cad5b243674c9c214e517021a0036596d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 21:11:27 -0300 Subject: [PATCH 196/253] Fix BeatmapSetInfos with OnlineBeatmapSetID set to null being marked as downloaded. --- osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs index e800eb5115..cc4a9c6d15 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs @@ -35,7 +35,8 @@ namespace osu.Game.Beatmaps.Drawables beatmaps.ItemRemoved += setRemoved; // initial value - Downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; + if (set.OnlineBeatmapSetID != null) + Downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; } protected override void Dispose(bool isDisposing) From 4cf7a64636a0c354399dca8cc6fa93f81a00a3ea Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 4 Jun 2018 22:26:52 -0300 Subject: [PATCH 197/253] Remove unused parameter. --- osu.Game/Overlays/DirectOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 99f6de8559..b33f271986 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -176,7 +176,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuColour colours, APIAccess api, RulesetStore rulesets, BeatmapManager beatmaps) + private void load(OsuColour colours, APIAccess api, RulesetStore rulesets) { this.api = api; this.rulesets = rulesets; From 3b03a25ea5d70d63a4f38530276187ca4d7acc22 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Jun 2018 11:28:51 +0900 Subject: [PATCH 198/253] Fix beatmaps with subfolders importing incorrectly on windows Closes #2718. --- osu.Game/Database/ArchiveModelManager.cs | 3 ++- osu.Game/IO/Archives/LegacyFilesystemReader.cs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 7741fe9ab3..cbf0df3227 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.EntityFrameworkCore; +using osu.Framework.IO.File; using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.IO; @@ -364,7 +365,7 @@ namespace osu.Game.Database using (Stream s = reader.GetStream(file)) fileInfos.Add(new TFileModel { - Filename = file, + Filename = FileSafety.PathSanitise(file), FileInfo = files.Add(s) }); diff --git a/osu.Game/IO/Archives/LegacyFilesystemReader.cs b/osu.Game/IO/Archives/LegacyFilesystemReader.cs index 7871f1439a..fc52cb10dd 100644 --- a/osu.Game/IO/Archives/LegacyFilesystemReader.cs +++ b/osu.Game/IO/Archives/LegacyFilesystemReader.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using osu.Framework.IO.File; namespace osu.Game.IO.Archives { @@ -15,7 +14,8 @@ namespace osu.Game.IO.Archives { private readonly string path; - public LegacyFilesystemReader(string path) : base(Path.GetFileName(path)) + public LegacyFilesystemReader(string path) + : base(Path.GetFileName(path)) { this.path = path; } @@ -27,7 +27,7 @@ namespace osu.Game.IO.Archives // no-op } - public override IEnumerable Filenames => Directory.GetFiles(path, "*", SearchOption.AllDirectories).Select(f => FileSafety.GetRelativePath(f, path)).ToArray(); + public override IEnumerable Filenames => Directory.GetFiles(path, "*", SearchOption.AllDirectories).Select(f => f.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar)).ToArray(); public override Stream GetUnderlyingStream() => null; } From 601ef3b6f70e2190793b6e66ea864ee5451c0e62 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 4 Jun 2018 20:01:55 +0900 Subject: [PATCH 199/253] Consume osu.Framework via nuget --- osu-framework | 1 - osu.Desktop.Deploy/osu.Desktop.Deploy.csproj | 4 +--- osu.Desktop/osu.Desktop.csproj | 2 +- osu.Game/OsuGameBase.cs | 4 ++-- osu.Game/Tests/Visual/OsuTestCase.cs | 4 ---- osu.Game/osu.Game.csproj | 2 +- osu.TestProject.props | 3 +-- osu.sln | 6 ------ 8 files changed, 6 insertions(+), 20 deletions(-) delete mode 160000 osu-framework diff --git a/osu-framework b/osu-framework deleted file mode 160000 index b963ce8250..0000000000 --- a/osu-framework +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b963ce82505bc953db0a0763679e1ec80a060811 diff --git a/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj b/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj index 063fb89918..e5944187b3 100644 --- a/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj +++ b/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj @@ -6,12 +6,10 @@ AnyCPU true - - - + diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index b8efd76506..a3b4c5d195 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -20,7 +20,6 @@ osu.Desktop.Program - @@ -31,6 +30,7 @@ + diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index b9d32a6322..fcc2d42321 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -59,8 +59,6 @@ namespace osu.Game protected MenuCursorContainer MenuCursorContainer; - protected override string MainResourceFile => @"osu.Game.Resources.dll"; - private Container content; protected override Container Content => content; @@ -100,6 +98,8 @@ namespace osu.Game [BackgroundDependencyLoader] private void load() { + Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll")); + dependencies.Cache(contextFactory = new DatabaseContextFactory(Host)); dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(Resources, @"Textures")))); diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 2b677f1f42..fa441d8012 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.IO; -using System.Reflection; using osu.Framework.Testing; namespace osu.Game.Tests.Visual @@ -13,8 +11,6 @@ namespace osu.Game.Tests.Visual public class OsuTestCaseTestRunner : OsuGameBase, ITestCaseTestRunner { - protected override string MainResourceFile => File.Exists(base.MainResourceFile) ? base.MainResourceFile : Assembly.GetExecutingAssembly().Location; - private TestCaseTestRunner.TestRunner runner; protected override void LoadAsyncComplete() diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index afb656a260..55ee87dcb3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -11,7 +11,6 @@ - @@ -19,6 +18,7 @@ + diff --git a/osu.TestProject.props b/osu.TestProject.props index afdf895eac..b51ca13ed5 100644 --- a/osu.TestProject.props +++ b/osu.TestProject.props @@ -7,7 +7,6 @@ - @@ -18,7 +17,7 @@ - + VisualTestRunner.cs diff --git a/osu.sln b/osu.sln index 5c4b644489..b8ef7de9ea 100644 --- a/osu.sln +++ b/osu.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.27004.2006 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game", "osu.Game\osu.Game.csproj", "{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Framework", "osu-framework\osu.Framework\osu.Framework.csproj", "{C76BF5B3-985E-4D39-95FE-97C9C879B83A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Resources", "osu-resources\osu.Game.Resources\osu.Game.Resources.csproj", "{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Osu", "osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj", "{C92A607B-1FDD-4954-9F92-03FF547D9080}" @@ -41,10 +39,6 @@ Global {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.Build.0 = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.Build.0 = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.ActiveCfg = Release|Any CPU From 115595251d289fad981dbde2d361df74e9c13a7c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Jun 2018 15:02:34 +0900 Subject: [PATCH 200/253] Remove unnecessary reference in osu.Desktop --- osu.Desktop/osu.Desktop.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index a3b4c5d195..766f36fa74 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -30,7 +30,6 @@ - From 9af9b1c937362101fc3091c52fa9ee64417e7563 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Jun 2018 19:41:07 +0900 Subject: [PATCH 201/253] Remove framework submodule reference completely --- .gitmodules | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index ee1cc80880..f1c4f5d172 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "osu-framework"] - path = osu-framework - url = https://github.com/ppy/osu-framework [submodule "osu-resources"] path = osu-resources - url = https://github.com/ppy/osu-resources + url = https://github.com/ppy/osu-resources \ No newline at end of file From 59277de0df9b6b2c5ef75fbe35cc0fc087d170fd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Jun 2018 19:45:25 +0900 Subject: [PATCH 202/253] Remove osu.Desktop.Deploy --- osu.Desktop.Deploy/App.config | 21 - osu.Desktop.Deploy/GitHubObject.cs | 16 - osu.Desktop.Deploy/GitHubRelease.cs | 28 -- osu.Desktop.Deploy/Program.cs | 471 ------------------- osu.Desktop.Deploy/osu.Desktop.Deploy.csproj | 19 - osu.sln | 4 - 6 files changed, 559 deletions(-) delete mode 100644 osu.Desktop.Deploy/App.config delete mode 100644 osu.Desktop.Deploy/GitHubObject.cs delete mode 100644 osu.Desktop.Deploy/GitHubRelease.cs delete mode 100644 osu.Desktop.Deploy/Program.cs delete mode 100644 osu.Desktop.Deploy/osu.Desktop.Deploy.csproj diff --git a/osu.Desktop.Deploy/App.config b/osu.Desktop.Deploy/App.config deleted file mode 100644 index 9ec53d5a31..0000000000 --- a/osu.Desktop.Deploy/App.config +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.Desktop.Deploy/GitHubObject.cs b/osu.Desktop.Deploy/GitHubObject.cs deleted file mode 100644 index 02ff16fa69..0000000000 --- a/osu.Desktop.Deploy/GitHubObject.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using Newtonsoft.Json; - -namespace osu.Desktop.Deploy -{ - public class GitHubObject - { - [JsonProperty(@"id")] - public int Id; - - [JsonProperty(@"name")] - public string Name; - } -} diff --git a/osu.Desktop.Deploy/GitHubRelease.cs b/osu.Desktop.Deploy/GitHubRelease.cs deleted file mode 100644 index faf312d4f7..0000000000 --- a/osu.Desktop.Deploy/GitHubRelease.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using Newtonsoft.Json; - -namespace osu.Desktop.Deploy -{ - public class GitHubRelease - { - [JsonProperty(@"id")] - public int Id; - - [JsonProperty(@"tag_name")] - public string TagName => $"v{Name}"; - - [JsonProperty(@"name")] - public string Name; - - [JsonProperty(@"draft")] - public bool Draft; - - [JsonProperty(@"prerelease")] - public bool PreRelease; - - [JsonProperty(@"upload_url")] - public string UploadUrl; - } -} diff --git a/osu.Desktop.Deploy/Program.cs b/osu.Desktop.Deploy/Program.cs deleted file mode 100644 index a1c2a8aef2..0000000000 --- a/osu.Desktop.Deploy/Program.cs +++ /dev/null @@ -1,471 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Management.Automation; -using Newtonsoft.Json; -using osu.Framework.IO.Network; -using FileWebRequest = osu.Framework.IO.Network.FileWebRequest; -using WebRequest = osu.Framework.IO.Network.WebRequest; - -namespace osu.Desktop.Deploy -{ - internal static class Program - { - private static string packages => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages"); - private static string nugetPath => Path.Combine(packages, @"nuget.commandline\4.5.1\tools\NuGet.exe"); - private static string squirrelPath => Path.Combine(packages, @"squirrel.windows\1.8.0\tools\Squirrel.exe"); - private const string msbuild_path = @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"; - - public static string StagingFolder = ConfigurationManager.AppSettings["StagingFolder"]; - public static string ReleasesFolder = ConfigurationManager.AppSettings["ReleasesFolder"]; - public static string GitHubAccessToken = ConfigurationManager.AppSettings["GitHubAccessToken"]; - public static string GitHubUsername = ConfigurationManager.AppSettings["GitHubUsername"]; - public static string GitHubRepoName = ConfigurationManager.AppSettings["GitHubRepoName"]; - public static string SolutionName = ConfigurationManager.AppSettings["SolutionName"]; - public static string ProjectName = ConfigurationManager.AppSettings["ProjectName"]; - public static string NuSpecName = ConfigurationManager.AppSettings["NuSpecName"]; - public static string TargetNames = ConfigurationManager.AppSettings["TargetName"]; - public static string PackageName = ConfigurationManager.AppSettings["PackageName"]; - public static string IconName = ConfigurationManager.AppSettings["IconName"]; - public static string CodeSigningCertificate = ConfigurationManager.AppSettings["CodeSigningCertificate"]; - - public static string GitHubApiEndpoint => $"https://api.github.com/repos/{GitHubUsername}/{GitHubRepoName}/releases"; - public static string GitHubReleasePage => $"https://github.com/{GitHubUsername}/{GitHubRepoName}/releases"; - - /// - /// How many previous build deltas we want to keep when publishing. - /// - private const int keep_delta_count = 4; - - private static string codeSigningCmd => string.IsNullOrEmpty(codeSigningPassword) ? "" : $"-n \"/a /f {codeSigningCertPath} /p {codeSigningPassword} /t http://timestamp.comodoca.com/authenticode\""; - - private static string homeDir => Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - private static string codeSigningCertPath => Path.Combine(homeDir, CodeSigningCertificate); - private static string solutionPath => Environment.CurrentDirectory; - private static string stagingPath => Path.Combine(solutionPath, StagingFolder); - private static string iconPath => Path.Combine(solutionPath, ProjectName, IconName); - - private static string nupkgFilename(string ver) => $"{PackageName}.{ver}.nupkg"; - private static string nupkgDistroFilename(string ver) => $"{PackageName}-{ver}-full.nupkg"; - - private static readonly Stopwatch sw = new Stopwatch(); - - private static string codeSigningPassword; - - private static bool interactive; - - public static void Main(string[] args) - { - interactive = args.Length == 0; - - displayHeader(); - - findSolutionPath(); - - if (!Directory.Exists(ReleasesFolder)) - { - write("WARNING: No release directory found. Make sure you want this!", ConsoleColor.Yellow); - Directory.CreateDirectory(ReleasesFolder); - } - - checkGitHubReleases(); - - refreshDirectory(StagingFolder); - - //increment build number until we have a unique one. - string verBase = DateTime.Now.ToString("yyyy.Mdd."); - int increment = 0; - while (Directory.GetFiles(ReleasesFolder, $"*{verBase}{increment}*").Any()) - increment++; - - string version = $"{verBase}{increment}"; - - Console.ForegroundColor = ConsoleColor.White; - Console.Write($"Ready to deploy {version}!"); - pauseIfInteractive(); - - sw.Start(); - - if (!string.IsNullOrEmpty(CodeSigningCertificate)) - { - Console.Write("Enter code signing password: "); - codeSigningPassword = args.Length > 0 ? args[0] : readLineMasked(); - } - - write("Updating AssemblyInfo..."); - updateCsprojVersion(version); - updateAppveyorVersion(version); - - write("Running build process..."); - foreach (string targetName in TargetNames.Split(',')) - runCommand(msbuild_path, $"/v:quiet /m /t:{targetName.Replace('.', '_')} /p:OutputPath={stagingPath};Targets=\"Clean;Build\";Configuration=Release {SolutionName}.sln"); - - write("Creating NuGet deployment package..."); - runCommand(nugetPath, $"pack {NuSpecName} -Version {version} -Properties Configuration=Deploy -OutputDirectory {stagingPath} -BasePath {stagingPath}"); - - //prune once before checking for files so we can avoid erroring on files which aren't even needed for this build. - pruneReleases(); - - checkReleaseFiles(); - - write("Running squirrel build..."); - runCommand(squirrelPath, $"--releasify {stagingPath}\\{nupkgFilename(version)} --framework-version=net471 --setupIcon {iconPath} --icon {iconPath} {codeSigningCmd} --no-msi"); - - //prune again to clean up before upload. - pruneReleases(); - - //rename setup to install. - File.Copy(Path.Combine(ReleasesFolder, "Setup.exe"), Path.Combine(ReleasesFolder, "install.exe"), true); - File.Delete(Path.Combine(ReleasesFolder, "Setup.exe")); - - uploadBuild(version); - - //reset assemblyinfo. - updateCsprojVersion("0.0.0"); - - write("Done!", ConsoleColor.White); - pauseIfInteractive(); - } - - private static void displayHeader() - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(); - Console.WriteLine(" Please note that OSU! and PPY are registered trademarks and as such covered by trademark law."); - Console.WriteLine(" Do not distribute builds of this project publicly that make use of these."); - Console.ResetColor(); - Console.WriteLine(); - } - - /// - /// Ensure we have all the files in the release directory which are expected to be there. - /// This should have been accounted for in earlier steps, and just serves as a verification step. - /// - private static void checkReleaseFiles() - { - if (!canGitHub) return; - - var releaseLines = getReleaseLines(); - - //ensure we have all files necessary - foreach (var l in releaseLines) - if (!File.Exists(Path.Combine(ReleasesFolder, l.Filename))) - error($"Local file missing {l.Filename}"); - } - - private static IEnumerable getReleaseLines() => File.ReadAllLines(Path.Combine(ReleasesFolder, "RELEASES")).Select(l => new ReleaseLine(l)); - - private static void pruneReleases() - { - if (!canGitHub) return; - - write("Pruning RELEASES..."); - - var releaseLines = getReleaseLines().ToList(); - - var fulls = releaseLines.Where(l => l.Filename.Contains("-full")).Reverse().Skip(1); - - //remove any FULL releases (except most recent) - foreach (var l in fulls) - { - write($"- Removing old release {l.Filename}", ConsoleColor.Yellow); - File.Delete(Path.Combine(ReleasesFolder, l.Filename)); - releaseLines.Remove(l); - } - - //remove excess deltas - var deltas = releaseLines.Where(l => l.Filename.Contains("-delta")).ToArray(); - if (deltas.Length > keep_delta_count) - { - foreach (var l in deltas.Take(deltas.Length - keep_delta_count)) - { - write($"- Removing old delta {l.Filename}", ConsoleColor.Yellow); - File.Delete(Path.Combine(ReleasesFolder, l.Filename)); - releaseLines.Remove(l); - } - } - - var lines = new List(); - releaseLines.ForEach(l => lines.Add(l.ToString())); - File.WriteAllLines(Path.Combine(ReleasesFolder, "RELEASES"), lines); - } - - private static void uploadBuild(string version) - { - if (!canGitHub || string.IsNullOrEmpty(CodeSigningCertificate)) - return; - - write("Publishing to GitHub..."); - - write($"- Creating release {version}...", ConsoleColor.Yellow); - var req = new JsonWebRequest($"{GitHubApiEndpoint}") - { - Method = HttpMethod.POST, - }; - req.AddRaw(JsonConvert.SerializeObject(new GitHubRelease - { - Name = version, - Draft = true, - PreRelease = true - })); - req.AuthenticatedBlockingPerform(); - - var assetUploadUrl = req.ResponseObject.UploadUrl.Replace("{?name,label}", "?name={0}"); - foreach (var a in Directory.GetFiles(ReleasesFolder).Reverse()) //reverse to upload RELEASES first. - { - write($"- Adding asset {a}...", ConsoleColor.Yellow); - var upload = new WebRequest(assetUploadUrl, Path.GetFileName(a)) - { - Method = HttpMethod.POST, - Timeout = 240000, - ContentType = "application/octet-stream", - }; - - upload.AddRaw(File.ReadAllBytes(a)); - upload.AuthenticatedBlockingPerform(); - } - - openGitHubReleasePage(); - } - - private static void openGitHubReleasePage() => Process.Start(GitHubReleasePage); - - private static bool canGitHub => !string.IsNullOrEmpty(GitHubAccessToken); - - private static void checkGitHubReleases() - { - if (!canGitHub) return; - - write("Checking GitHub releases..."); - var req = new JsonWebRequest>($"{GitHubApiEndpoint}"); - req.AuthenticatedBlockingPerform(); - - var lastRelease = req.ResponseObject.FirstOrDefault(); - - if (lastRelease == null) - return; - - if (lastRelease.Draft) - { - openGitHubReleasePage(); - error("There's a pending draft release! You probably don't want to push a build with this present."); - } - - //there's a previous release for this project. - var assetReq = new JsonWebRequest>($"{GitHubApiEndpoint}/{lastRelease.Id}/assets"); - assetReq.AuthenticatedBlockingPerform(); - var assets = assetReq.ResponseObject; - - //make sure our RELEASES file is the same as the last build on the server. - var releaseAsset = assets.FirstOrDefault(a => a.Name == "RELEASES"); - - //if we don't have a RELEASES asset then the previous release likely wasn't a Squirrel one. - if (releaseAsset == null) return; - - write($"Last GitHub release was {lastRelease.Name}."); - - bool requireDownload = false; - - if (!File.Exists(Path.Combine(ReleasesFolder, nupkgDistroFilename(lastRelease.Name)))) - { - write("Last version's package not found locally.", ConsoleColor.Red); - requireDownload = true; - } - else - { - var lastReleases = new RawFileWebRequest($"{GitHubApiEndpoint}/assets/{releaseAsset.Id}"); - lastReleases.AuthenticatedBlockingPerform(); - if (File.ReadAllText(Path.Combine(ReleasesFolder, "RELEASES")) != lastReleases.ResponseString) - { - write("Server's RELEASES differed from ours.", ConsoleColor.Red); - requireDownload = true; - } - } - - if (!requireDownload) return; - - write("Refreshing local releases directory..."); - refreshDirectory(ReleasesFolder); - - foreach (var a in assets) - { - if (a.Name.EndsWith(".exe")) continue; - - write($"- Downloading {a.Name}...", ConsoleColor.Yellow); - new FileWebRequest(Path.Combine(ReleasesFolder, a.Name), $"{GitHubApiEndpoint}/assets/{a.Id}").AuthenticatedBlockingPerform(); - } - } - - private static void refreshDirectory(string directory) - { - if (Directory.Exists(directory)) - Directory.Delete(directory, true); - Directory.CreateDirectory(directory); - } - - private static void updateCsprojVersion(string version) - { - var toUpdate = new[] { "", "" }; - string file = Path.Combine(ProjectName, $"{ProjectName}.csproj"); - - var l1 = File.ReadAllLines(file); - List l2 = new List(); - foreach (var l in l1) - { - string line = l; - - foreach (var tag in toUpdate) - { - int startIndex = l.IndexOf(tag, StringComparison.InvariantCulture); - if (startIndex == -1) - continue; - startIndex += tag.Length; - - int endIndex = l.IndexOf("<", startIndex, StringComparison.InvariantCulture); - line = $"{l.Substring(0, startIndex)}{version}{l.Substring(endIndex)}"; - } - - l2.Add(line); - } - - File.WriteAllLines(file, l2); - } - - /// - /// Find the base path of the active solution (git checkout location) - /// - private static void findSolutionPath() - { - string path = Path.GetDirectoryName(Environment.CommandLine.Replace("\"", "").Trim()); - - if (string.IsNullOrEmpty(path)) - path = Environment.CurrentDirectory; - - while (!File.Exists(Path.Combine(path, $"{SolutionName}.sln"))) - path = path.Remove(path.LastIndexOf(Path.DirectorySeparatorChar)); - path += Path.DirectorySeparatorChar; - - Environment.CurrentDirectory = path; - } - - private static bool runCommand(string command, string args) - { - var psi = new ProcessStartInfo(command, args) - { - WorkingDirectory = solutionPath, - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - WindowStyle = ProcessWindowStyle.Hidden - }; - - Process p = Process.Start(psi); - if (p == null) return false; - - string output = p.StandardOutput.ReadToEnd(); - output += p.StandardError.ReadToEnd(); - - if (p.ExitCode == 0) return true; - - write(output); - error($"Command {command} {args} failed!"); - return false; - } - - private static string readLineMasked() - { - var fg = Console.ForegroundColor; - Console.ForegroundColor = Console.BackgroundColor; - var ret = Console.ReadLine(); - Console.ForegroundColor = fg; - - return ret; - } - - private static void error(string message) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"FATAL ERROR: {message}"); - - pauseIfInteractive(); - Environment.Exit(-1); - } - - private static void pauseIfInteractive() - { - if (interactive) - Console.ReadLine(); - else - Console.WriteLine(); - } - - private static bool updateAppveyorVersion(string version) - { - try - { - using (PowerShell ps = PowerShell.Create()) - { - ps.AddScript($"Update-AppveyorBuild -Version \"{version}\""); - ps.Invoke(); - } - return true; - } - catch - { - // we don't have appveyor and don't care - } - - return false; - } - - private static void write(string message, ConsoleColor col = ConsoleColor.Gray) - { - if (sw.ElapsedMilliseconds > 0) - { - Console.ForegroundColor = ConsoleColor.Green; - Console.Write(sw.ElapsedMilliseconds.ToString().PadRight(8)); - } - Console.ForegroundColor = col; - Console.WriteLine(message); - } - - public static void AuthenticatedBlockingPerform(this WebRequest r) - { - r.AddHeader("Authorization", $"token {GitHubAccessToken}"); - r.Perform(); - } - } - - internal class RawFileWebRequest : WebRequest - { - public RawFileWebRequest(string url) : base(url) - { - } - - protected override string Accept => "application/octet-stream"; - } - - internal class ReleaseLine - { - public string Hash; - public string Filename; - public int Filesize; - - public ReleaseLine(string line) - { - var split = line.Split(' '); - Hash = split[0]; - Filename = split[1]; - Filesize = int.Parse(split[2]); - } - - public override string ToString() => $"{Hash} {Filename} {Filesize}"; - } -} diff --git a/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj b/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj deleted file mode 100644 index 063fb89918..0000000000 --- a/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net471 - Exe - AnyCPU - true - - - - - - - - - - - - \ No newline at end of file diff --git a/osu.sln b/osu.sln index 5c4b644489..3646679539 100644 --- a/osu.sln +++ b/osu.sln @@ -17,8 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Taiko", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Mania", "osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj", "{48F4582B-7687-4621-9CBE-5C24197CB536}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Desktop.Deploy", "osu.Desktop.Deploy\osu.Desktop.Deploy.csproj", "{BAEA2F74-0315-4667-84E0-ACAC0B4BF785}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Tests", "osu.Game.Tests\osu.Game.Tests.csproj", "{54377672-20B1-40AF-8087-5CF73BF3953A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Desktop", "osu.Desktop\osu.Desktop.csproj", "{419659FD-72EA-4678-9EB8-B22A746CED70}" @@ -65,8 +63,6 @@ Global {48F4582B-7687-4621-9CBE-5C24197CB536}.Debug|Any CPU.Build.0 = Debug|Any CPU {48F4582B-7687-4621-9CBE-5C24197CB536}.Release|Any CPU.ActiveCfg = Release|Any CPU {48F4582B-7687-4621-9CBE-5C24197CB536}.Release|Any CPU.Build.0 = Release|Any CPU - {BAEA2F74-0315-4667-84E0-ACAC0B4BF785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BAEA2F74-0315-4667-84E0-ACAC0B4BF785}.Release|Any CPU.ActiveCfg = Release|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Debug|Any CPU.Build.0 = Debug|Any CPU {54377672-20B1-40AF-8087-5CF73BF3953A}.Release|Any CPU.ActiveCfg = Release|Any CPU From fe35c0220aac02167943f28703522f94ed156d2c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Jun 2018 18:52:39 +0900 Subject: [PATCH 203/253] Update deploy script --- appveyor.yml | 2 +- appveyor_deploy.yml | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 314faa617a..69bc762f4c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ clone_depth: 1 version: '{branch}-{build}' -image: Visual Studio 2017 preview +image: Visual Studio 2017 configuration: Debug cache: - C:\ProgramData\chocolatey\bin -> appveyor.yml diff --git a/appveyor_deploy.yml b/appveyor_deploy.yml index cadebd9d11..64ad927574 100644 --- a/appveyor_deploy.yml +++ b/appveyor_deploy.yml @@ -1,29 +1,26 @@ -branches: - only: - - release -skip_tags: true -skip_branch_with_pr: true clone_depth: 1 -version: '{branch}-{build}' +version: '{build}' +skip_non_tags: true image: Visual Studio 2017 -configuration: Debug cache: - - packages -> **\packages.config + - '%USERPROFILE%\.nuget\packages -> **\*.csproj' install: - - cmd: git submodule update --init --recursive --depth=5 + - git clone https://github.com/ppy/osu-deploy before_build: + - ps: if($env:appveyor_repo_tag -eq 'True') { Update-AppveyorBuild -Version $env:appveyor_repo_tag_name } + - cmd: git submodule update --init --recursive --depth=5 - cmd: nuget restore -verbosity quiet -build: - project: osu.Desktop.Deploy/osu.Desktop.Deploy.csproj - verbosity: minimal -after_build: +build_script: - ps: iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1')) - appveyor DownloadFile https://puu.sh/A6g5K/4d08705438.enc # signing certificate - cmd: appveyor-tools\secure-file -decrypt 4d08705438.enc -secret %decode_secret% -out %HOMEPATH%\deanherbert.pfx - appveyor DownloadFile https://puu.sh/A6g75/fdc6f19b04.enc # deploy configuration - - cmd: appveyor-tools\secure-file -decrypt fdc6f19b04.enc -secret %decode_secret% -out osu.Desktop.Deploy\bin\Debug\net471\osu.Desktop.Deploy.exe.config - - cd osu.Desktop.Deploy\bin\Debug\net471\ - - osu.Desktop.Deploy.exe %code_signing_password% + - cd osu-deploy + - nuget restore -verbosity quiet + - msbuild osu.Desktop.Deploy.csproj + - cmd: ..\appveyor-tools\secure-file -decrypt ..\fdc6f19b04.enc -secret %decode_secret% -out bin\Debug\net471\osu.Desktop.Deploy.exe.config + - cd bin\Debug\net471\ + - osu.Desktop.Deploy.exe %code_signing_password% %APPVEYOR_REPO_TAG_NAME% environment: TargetFramework: net471 decode_secret: @@ -31,4 +28,7 @@ environment: code_signing_password: secure: 34tLNqvjmmZEi97MLKfrnQ== artifacts: - - path: 'Releases\*' \ No newline at end of file + - path: 'Releases\*' +deploy: + - provider: Environment + name: github \ No newline at end of file From 80951eae68f68449ce1d139f7284a5e9850f228a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 5 Jun 2018 18:09:26 -0300 Subject: [PATCH 204/253] Inherit BeatmapSetDownloader from Component. --- osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs index cc4a9c6d15..779848dff6 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs @@ -9,7 +9,7 @@ using osu.Framework.Graphics; namespace osu.Game.Beatmaps.Drawables { - public class BeatmapSetDownloader : Drawable + public class BeatmapSetDownloader : Component { private readonly BeatmapSetInfo set; private readonly bool noVideo; From 1dd5bdcf72adc661febf0e39e1acf022488a9a36 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 12:32:59 +0900 Subject: [PATCH 205/253] 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 206/253] 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 207/253] 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 208/253] 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) From 86be1bef6b8856be4306cbaf3dcc763685096c77 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 15:10:09 +0900 Subject: [PATCH 209/253] Use UserTriggered in Player --- .../Containers/OsuFocusedOverlayContainer.cs | 20 +++++++++---------- osu.Game/Overlays/OverlayActivation.cs | 2 +- osu.Game/Screens/Play/Player.cs | 3 +++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index e9c02e84ec..51a9706ea4 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -53,20 +53,18 @@ namespace osu.Game.Graphics.Containers private void onStateChanged(Visibility visibility) { - if (allowOverlays == OverlayActivation.All) + switch (visibility) { - switch (visibility) - { - case Visibility.Visible: + case Visibility.Visible: + if (allowOverlays != OverlayActivation.Disabled) samplePopIn?.Play(); - break; - case Visibility.Hidden: - samplePopOut?.Play(); - break; - } + else + State = Visibility.Hidden; + break; + case Visibility.Hidden: + samplePopOut?.Play(); + break; } - else - State = Visibility.Hidden; } } } diff --git a/osu.Game/Overlays/OverlayActivation.cs b/osu.Game/Overlays/OverlayActivation.cs index 735682ed57..da4e153ce9 100644 --- a/osu.Game/Overlays/OverlayActivation.cs +++ b/osu.Game/Overlays/OverlayActivation.cs @@ -6,7 +6,7 @@ namespace osu.Game.Overlays public enum OverlayActivation { Disabled, - //UserTriggered, // currently there is no way to discern user action + UserTriggered, All } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c93e4b7b40..6e0f6cb1c5 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -21,6 +21,7 @@ using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; +using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; @@ -37,6 +38,8 @@ namespace osu.Game.Screens.Play protected override bool HideOverlaysOnEnter => true; + protected override OverlayActivation OverlayActivationLevel => OverlayActivation.UserTriggered; + public Action RestartRequested; public bool HasFailed { get; private set; } From df4c855aa202f1949c769dc289e11c34d637760b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 6 Jun 2018 03:13:37 -0300 Subject: [PATCH 210/253] Manage subtitle inside of DownloadButton. --- osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs | 9 +++++++-- osu.Game/Overlays/BeatmapSet/Header.cs | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index cf7d3cda5a..8c6c8dbaa1 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -13,10 +13,15 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { public class DownloadButton : HeaderButton { - public DownloadButton(string title, string subtitle, BeatmapSetInfo set, bool noVideo = false) + public DownloadButton(BeatmapSetInfo set, bool noVideo = false) { Width = 120; + string subtitle = string.Empty; + + if (set.OnlineInfo.HasVideo) + subtitle = noVideo ? "without Video" : "with Video"; + BeatmapSetDownloader downloader; Add(new Container { @@ -36,7 +41,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { new OsuSpriteText { - Text = title, + Text = "Download", TextSize = 13, Font = @"Exo2.0-Bold", }, diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index a1ef82c995..afba99f928 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -70,8 +70,8 @@ namespace osu.Game.Overlays.BeatmapSet { videoButtons.Children = new[] { - new DownloadButton("Download", "with Video", BeatmapSet), - new DownloadButton("Download", "without Video", BeatmapSet, true), + new DownloadButton(BeatmapSet), + new DownloadButton(BeatmapSet, true), }; videoButtons.FadeIn(transition_duration); @@ -79,7 +79,7 @@ namespace osu.Game.Overlays.BeatmapSet } else { - noVideoButtons.Child = new DownloadButton("Download", string.Empty, BeatmapSet); + noVideoButtons.Child = new DownloadButton(BeatmapSet); noVideoButtons.FadeIn(transition_duration); videoButtons.FadeOut(transition_duration); From 188272e15d0d4730d14a1e9faac0fcc3db08424c Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 6 Jun 2018 03:18:42 -0300 Subject: [PATCH 211/253] Replace OnAlreadyDownloading with returning a bool from Download. --- .../Drawables/BeatmapSetDownloader.cs | 12 ++++-------- .../BeatmapSet/Buttons/DownloadButton.cs | 19 ++++++++++--------- osu.Game/Overlays/Direct/DownloadButton.cs | 19 ++++++++++--------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs index 779848dff6..0a322f5b72 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs @@ -18,8 +18,6 @@ namespace osu.Game.Beatmaps.Drawables public readonly BindableBool Downloaded = new BindableBool(); - public event Action OnAlreadyDownloading; - public BeatmapSetDownloader(BeatmapSetInfo set, bool noVideo = false) { this.set = set; @@ -50,18 +48,16 @@ namespace osu.Game.Beatmaps.Drawables } } - public void Download() + public bool Download() { if (Downloaded.Value) - return; + return false; if (beatmaps.GetExistingDownload(set) != null) - { - OnAlreadyDownloading?.Invoke(); - return; - } + return false; beatmaps.Download(set, noVideo); + return true; } private void setAdded(BeatmapSetInfo s) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index 8c6c8dbaa1..37fa562a73 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -64,7 +64,16 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, }); - Action = downloader.Download; + Action = () => + { + if (!downloader.Download()) + { + Content.MoveToX(-5, 50, Easing.OutSine).Then() + .MoveToX(5, 100, Easing.InOutSine).Then() + .MoveToX(-5, 100, Easing.InOutSine).Then() + .MoveToX(0, 50, Easing.InSine); + } + }; downloader.Downloaded.ValueChanged += d => { @@ -73,14 +82,6 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons else this.FadeIn(200); }; - - downloader.OnAlreadyDownloading += () => - { - Content.MoveToX(-5, 50, Easing.OutSine).Then() - .MoveToX(5, 100, Easing.InOutSine).Then() - .MoveToX(-5, 100, Easing.InOutSine).Then() - .MoveToX(0, 50, Easing.InSine); - }; } } } diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index a621199916..1ffa8dbd35 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -30,7 +30,16 @@ namespace osu.Game.Overlays.Direct }, }; - Action = downloader.Download; + Action = () => + { + if (!downloader.Download()) + { + Content.MoveToX(-5, 50, Easing.OutSine).Then() + .MoveToX(5, 100, Easing.InOutSine).Then() + .MoveToX(-5, 100, Easing.InOutSine).Then() + .MoveToX(0, 50, Easing.InSine); + } + }; downloader.Downloaded.ValueChanged += d => { @@ -39,14 +48,6 @@ namespace osu.Game.Overlays.Direct else this.FadeIn(200); }; - - downloader.OnAlreadyDownloading += () => - { - Content.MoveToX(-5, 50, Easing.OutSine).Then() - .MoveToX(5, 100, Easing.InOutSine).Then() - .MoveToX(-5, 100, Easing.InOutSine).Then() - .MoveToX(0, 50, Easing.InSine); - }; } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) From 7819be7957c3d78932f94dba178533760914d6f7 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 6 Jun 2018 03:28:07 -0300 Subject: [PATCH 212/253] Remove unused using. --- osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs index 0a322f5b72..df4847b5db 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.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 System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; From d1fd09ed4767a3a3bd94493343057fc94ecd9071 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 15:49:27 +0900 Subject: [PATCH 213/253] Rename variables --- osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs | 6 +++--- osu.Game/OsuGame.cs | 2 +- osu.Game/Overlays/Toolbar/Toolbar.cs | 2 +- osu.Game/Screens/OsuScreen.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 51a9706ea4..0186a170c9 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -17,13 +17,13 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; - private readonly Bindable allowOverlays = new Bindable(OverlayActivation.All); + protected readonly Bindable OverlayActivationMode = new Bindable(OverlayActivation.All); [BackgroundDependencyLoader(true)] private void load(OsuGame osuGame, AudioManager audio) { if (osuGame != null) - allowOverlays.BindTo(osuGame.AllowOverlays); + OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); @@ -56,7 +56,7 @@ namespace osu.Game.Graphics.Containers switch (visibility) { case Visibility.Visible: - if (allowOverlays != OverlayActivation.Disabled) + if (OverlayActivationMode != OverlayActivation.Disabled) samplePopIn?.Play(); else State = Visibility.Hidden; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 35f29c3fd1..5c256ed5c8 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -77,7 +77,7 @@ namespace osu.Game public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight; - public readonly Bindable AllowOverlays = new Bindable(); + public readonly Bindable OverlayActivationMode = new Bindable(); private OsuScreen screenStack; diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 032ea01700..1eaf748011 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Toolbar private void load(OsuGame osuGame) { if (osuGame != null) - allowOverlays.BindTo(osuGame.AllowOverlays); + allowOverlays.BindTo(osuGame.OverlayActivationMode); StateChanged += visibility => { diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index a6e32cda7b..ba9c65e42d 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -110,7 +110,7 @@ namespace osu.Game.Screens if (osuGame != null) { Ruleset.BindTo(osuGame.Ruleset); - allowOverlays.BindTo(osuGame.AllowOverlays); + allowOverlays.BindTo(osuGame.OverlayActivationMode); updateOverlayStates = () => { From 9e25e02696de1d38735abb8590ff6ef72e34d1f7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 15:49:58 +0900 Subject: [PATCH 214/253] Ensure notifications don't appear during UserTriggered mode Closes #2640. --- osu.Game/OsuGame.cs | 2 - osu.Game/Overlays/NotificationOverlay.cs | 49 +++++++++++------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 5c256ed5c8..68c50dafab 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -366,8 +366,6 @@ namespace osu.Game settings.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset(); - - AllowOverlays.ValueChanged += state => notifications.Enabled.Value = state == OverlayActivation.All; } public void CloseAllOverlays() diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 09b6022ac5..3dc8f5ec15 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -22,11 +22,6 @@ namespace osu.Game.Overlays public const float TRANSITION_LENGTH = 600; - /// - /// Whether posted notifications should be processed. - /// - public readonly BindableBool Enabled = new BindableBool(true); - private FlowContainer sections; /// @@ -34,27 +29,6 @@ namespace osu.Game.Overlays /// public Func GetToolbarHeight; - public NotificationOverlay() - { - ScheduledDelegate notificationsEnabler = null; - Enabled.ValueChanged += v => - { - if (!IsLoaded) - { - processingPosts = v; - return; - } - - notificationsEnabler?.Cancel(); - - if (v) - // we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed. - notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, 1000); - else - processingPosts = false; - }; - } - [BackgroundDependencyLoader] private void load() { @@ -103,6 +77,29 @@ namespace osu.Game.Overlays }; } + private ScheduledDelegate notificationsEnabler; + private void updateProcessingMode() + { + bool enabled = OverlayActivationMode == OverlayActivation.All || State == Visibility.Visible; + + notificationsEnabler?.Cancel(); + + if (enabled) + // we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed. + notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State == Visibility.Visible ? 0 : 1000); + else + processingPosts = false; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + StateChanged += _ => updateProcessingMode(); + OverlayActivationMode.ValueChanged += _ => updateProcessingMode(); + OverlayActivationMode.TriggerChange(); + } + private int totalCount => sections.Select(c => c.DisplayedCount).Sum(); private int unreadCount => sections.Select(c => c.UnreadCount).Sum(); From 55921efffb5ab4533078a554c9483afb2064b584 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 16:17:51 +0900 Subject: [PATCH 215/253] Rewrite much state logic --- osu.Game/OsuGame.cs | 42 ++++++++++++++++----------- osu.Game/Screens/Menu/ButtonSystem.cs | 11 ++++++- osu.Game/Screens/Menu/Disclaimer.cs | 2 +- osu.Game/Screens/Menu/Intro.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 2 -- osu.Game/Screens/OsuScreen.cs | 16 +++------- osu.Game/Screens/Play/Player.cs | 2 +- 7 files changed, 42 insertions(+), 35 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 68c50dafab..36c76851c6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -93,6 +93,8 @@ namespace osu.Game private SettingsOverlay settings; + private readonly List overlays = new List(); + // todo: move this to SongSelect once Screen has the ability to unsuspend. public readonly Bindable> SelectedMods = new Bindable>(new List()); @@ -105,6 +107,17 @@ namespace osu.Game public void ToggleDirect() => direct.ToggleVisibility(); + /// + /// Close all game-wide overlays. + /// + /// Whether the toolbar should also be hidden. + public void CloseAllOverlays(bool toolbar = true) + { + foreach (var o in overlays) + o.State = Visibility.Hidden; + if (toolbar) Toolbar.State = Visibility.Hidden; + } + private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => @@ -250,7 +263,7 @@ namespace osu.Game Depth = -5, OnHome = delegate { - hideAllOverlays(); + CloseAllOverlays(false); intro?.ChildScreen?.MakeCurrent(); }, }, overlayContent.Add); @@ -307,6 +320,8 @@ namespace osu.Game // ensure only one of these overlays are open at once. var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct }; + overlays.AddRange(singleDisplayOverlays); + foreach (var overlay in singleDisplayOverlays) { overlay.StateChanged += state => @@ -322,6 +337,8 @@ namespace osu.Game } var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications }; + overlays.AddRange(singleDisplaySideOverlays); + foreach (var overlay in singleDisplaySideOverlays) { overlay.StateChanged += state => @@ -338,6 +355,8 @@ namespace osu.Game // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; + overlays.AddRange(informationalOverlays); + foreach (var overlay in informationalOverlays) { overlay.StateChanged += state => @@ -352,6 +371,11 @@ namespace osu.Game }; } + OverlayActivationMode.ValueChanged += v => + { + if (v != OverlayActivation.All) CloseAllOverlays(); + }; + void updateScreenOffset() { float offset = 0; @@ -368,12 +392,6 @@ namespace osu.Game notifications.StateChanged += _ => updateScreenOffset(); } - public void CloseAllOverlays() - { - hideAllOverlays(); - musicController.State = Visibility.Hidden; - } - private void forwardLoggedErrorsToNotifications() { int recentErrorCount = 0; @@ -488,16 +506,6 @@ namespace osu.Game private OsuScreen currentScreen; private FrameworkConfigManager frameworkConfig; - private void hideAllOverlays() - { - settings.State = Visibility.Hidden; - chat.State = Visibility.Hidden; - direct.State = Visibility.Hidden; - social.State = Visibility.Hidden; - userProfile.State = Visibility.Hidden; - notifications.State = Visibility.Hidden; - } - protected override bool OnExiting() { if (screenStack.ChildScreen == null) return false; diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index a0f2fc45cd..7235a96e15 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -16,6 +16,7 @@ using osu.Framework.Input.Bindings; using osu.Framework.Threading; using osu.Game.Graphics; using osu.Game.Input.Bindings; +using osu.Game.Overlays; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -129,9 +130,12 @@ namespace osu.Game.Screens.Menu buttonFlow.AddRange(buttonsTopLevel); } + private OsuGame game; + [BackgroundDependencyLoader(true)] - private void load(AudioManager audio) + private void load(AudioManager audio, OsuGame game) { + this.game = game; sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } @@ -321,6 +325,8 @@ namespace osu.Game.Screens.Menu { logoTracking = false; + game.OverlayActivationMode.Value = state == MenuState.Exit ? OverlayActivation.Disabled : OverlayActivation.UserTriggered; + logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; @@ -352,6 +358,9 @@ namespace osu.Game.Screens.Menu if (impact) logo.Impact(); + + game.OverlayActivationMode.Value = OverlayActivation.All; + game.Toolbar.State = Visibility.Visible; }, 200); break; default: diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 2436f0a940..0c70dbf570 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Menu private Color4 iconColour; protected override bool HideOverlaysOnEnter => true; - protected override OverlayActivation OverlayActivationLevel => OverlayActivation.Disabled; + protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; public override bool CursorVisible => false; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index d58f0e95b5..c5bd345a31 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -33,7 +33,7 @@ namespace osu.Game.Screens.Menu private SampleChannel seeya; protected override bool HideOverlaysOnEnter => true; - protected override OverlayActivation OverlayActivationLevel => OverlayActivation.Disabled; + protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; public override bool CursorVisible => false; diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 8eddaaee93..cbdd8b4e8b 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -63,8 +63,6 @@ namespace osu.Game.Screens.Menu }, sideFlashes = new MenuSideFlashes(), }; - - buttons.StateChanged += state => UpdateOverlayStates?.Invoke(); } [BackgroundDependencyLoader(true)] diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index ba9c65e42d..d98aac8f84 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -44,22 +44,17 @@ namespace osu.Game.Screens private Action updateOverlayStates; - /// - /// Allows manually updating visibility of all overlays if is not enough. - /// - protected Action UpdateOverlayStates => updateOverlayStates; - /// /// Whether all overlays should be hidden when this screen is entered or resumed. /// protected virtual bool HideOverlaysOnEnter => false; - private readonly Bindable allowOverlays = new Bindable(); + protected readonly Bindable OverlayActivationMode = new Bindable(); /// /// Whether overlays should be able to be opened once this screen is entered or resumed. /// - protected virtual OverlayActivation OverlayActivationLevel => OverlayActivation.All; + protected virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All; /// /// Whether this allows the cursor to be displayed. @@ -110,15 +105,12 @@ namespace osu.Game.Screens if (osuGame != null) { Ruleset.BindTo(osuGame.Ruleset); - allowOverlays.BindTo(osuGame.OverlayActivationMode); + OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); updateOverlayStates = () => { if (HideOverlaysOnEnter) - { osuGame.CloseAllOverlays(); - osuGame.Toolbar.State = Visibility.Hidden; - } else osuGame.Toolbar.State = Visibility.Visible; }; @@ -257,7 +249,7 @@ namespace osu.Game.Screens if (backgroundParallaxContainer != null) backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; - allowOverlays.Value = OverlayActivationLevel; + OverlayActivationMode.Value = InitialOverlayActivationMode; updateOverlayStates?.Invoke(); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 6e0f6cb1c5..54f65e3991 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play protected override bool HideOverlaysOnEnter => true; - protected override OverlayActivation OverlayActivationLevel => OverlayActivation.UserTriggered; + protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered; public Action RestartRequested; From aaaa8a3b7c8b77c8f9adb421a414c0e2ebce90e9 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Wed, 6 Jun 2018 09:55:16 +0200 Subject: [PATCH 216/253] match Bindable names --- osu.Game/Overlays/Toolbar/Toolbar.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 1eaf748011..48d0674b3d 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Toolbar private const float alpha_hovering = 0.8f; private const float alpha_normal = 0.6f; - private readonly Bindable allowOverlays = new Bindable(OverlayActivation.All); + private readonly Bindable overlayActivationMode = new Bindable(OverlayActivation.All); public Toolbar() { @@ -84,11 +84,11 @@ namespace osu.Game.Overlays.Toolbar private void load(OsuGame osuGame) { if (osuGame != null) - allowOverlays.BindTo(osuGame.OverlayActivationMode); + overlayActivationMode.BindTo(osuGame.OverlayActivationMode); StateChanged += visibility => { - if (allowOverlays == OverlayActivation.Disabled) + if (overlayActivationMode == OverlayActivation.Disabled) State = Visibility.Hidden; }; } From 9306fec4982e9b347481fd371ac2346a1c270bb7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 18:21:03 +0900 Subject: [PATCH 217/253] Fix missing null checks --- osu.Game/Screens/Menu/ButtonSystem.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 7235a96e15..42e25aad43 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -322,17 +322,18 @@ namespace osu.Game.Screens.Menu case MenuState.Initial: logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => - { - logoTracking = false; + { + logoTracking = false; - game.OverlayActivationMode.Value = state == MenuState.Exit ? OverlayActivation.Disabled : OverlayActivation.UserTriggered; + if (game != null) + game.OverlayActivationMode.Value = state == MenuState.Exit ? OverlayActivation.Disabled : OverlayActivation.UserTriggered; - logo.ClearTransforms(targetMember: nameof(Position)); - logo.RelativePositionAxes = Axes.Both; + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.Both; - logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); - logo.ScaleTo(1, 800, Easing.OutExpo); - }, buttonArea.Alpha * 150); + logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); + logo.ScaleTo(1, 800, Easing.OutExpo); + }, buttonArea.Alpha * 150); break; case MenuState.TopLevel: case MenuState.Play: @@ -359,8 +360,11 @@ namespace osu.Game.Screens.Menu if (impact) logo.Impact(); - game.OverlayActivationMode.Value = OverlayActivation.All; - game.Toolbar.State = Visibility.Visible; + if (game != null) + { + game.OverlayActivationMode.Value = OverlayActivation.All; + game.Toolbar.State = Visibility.Visible; + } }, 200); break; default: From 0a97b8ae2506c74c68b8fcf869a38c97c93993f8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 18:33:10 +0900 Subject: [PATCH 218/253] Implement DebugUtils locally Has been removed from framework --- osu.Game/OsuGameBase.cs | 2 +- osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- osu.Game/Utils/DebugUtils.cs | 21 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Utils/DebugUtils.cs diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index fcc2d42321..f170f1c00f 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -10,7 +10,6 @@ using System.Reflection; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Configuration; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.IO.Stores; @@ -31,6 +30,7 @@ using osu.Game.IO; using osu.Game.Rulesets; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; +using DebugUtils = osu.Game.Utils.DebugUtils; namespace osu.Game { diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 900f03fe7b..909fc20446 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -12,6 +11,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Rulesets; using OpenTK; using OpenTK.Graphics; +using DebugUtils = osu.Game.Utils.DebugUtils; namespace osu.Game.Overlays.Settings { diff --git a/osu.Game/Utils/DebugUtils.cs b/osu.Game/Utils/DebugUtils.cs new file mode 100644 index 0000000000..191662c690 --- /dev/null +++ b/osu.Game/Utils/DebugUtils.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Utils +{ + public static class DebugUtils + { + public static bool IsDebug + { + get + { + // ReSharper disable once RedundantAssignment + bool isDebug = false; + // Debug.Assert conditions are only evaluated in debug mode + System.Diagnostics.Debug.Assert(isDebug = true); + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + return isDebug; + } + } + } +} From aeeb03ff9cfaa77037a177137f612562539a8d80 Mon Sep 17 00:00:00 2001 From: ekrctb Date: Wed, 6 Jun 2018 18:36:43 +0900 Subject: [PATCH 219/253] simpler temporary path generation --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 645c76f265..1c9696901c 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -264,7 +264,7 @@ namespace osu.Game.Tests.Beatmaps.IO private string createTemporaryBeatmap() { - var temp = Path.GetTempFileName() + Guid.NewGuid() + ".osz"; + var temp = Path.GetTempFileName() + ".osz"; File.Copy(osz_path, temp, true); Assert.IsTrue(File.Exists(temp)); return temp; From 72cc53aded4395589606f15747a53c6f0bb3ddad Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 6 Jun 2018 20:16:20 +0900 Subject: [PATCH 220/253] Rename GameBeatmap -> BindableBeatmap --- .../UI/Cursor/GameplayCursor.cs | 2 +- .../{GameBeatmap.cs => BindableBeatmap.cs} | 14 ++++++------- .../{IGameBeatmap.cs => IBindableBeatmap.cs} | 8 ++++---- .../Containers/BeatSyncedContainer.cs | 2 +- osu.Game/OsuGameBase.cs | 20 +++++++++---------- osu.Game/Overlays/Music/PlaylistList.cs | 2 +- osu.Game/Overlays/Music/PlaylistOverlay.cs | 4 ++-- osu.Game/Overlays/MusicController.cs | 4 ++-- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 2 +- .../Edit/Components/BottomBarContainer.cs | 2 +- .../Timelines/Summary/Parts/TimelinePart.cs | 2 +- .../Timeline/ScrollingTimelineContainer.cs | 2 +- osu.Game/Screens/Edit/Screens/EditorScreen.cs | 2 +- osu.Game/Screens/Menu/Intro.cs | 4 ++-- osu.Game/Screens/Menu/LogoVisualisation.cs | 2 +- osu.Game/Screens/Menu/MenuSideFlashes.cs | 2 +- osu.Game/Screens/OsuScreen.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 4 ++-- .../Drawables/DrawableStoryboardAnimation.cs | 2 +- .../Drawables/DrawableStoryboardSprite.cs | 2 +- osu.Game/Tests/Visual/OsuTestCase.cs | 10 +++++----- .../Tests/Visual/TestCasePerformancePoints.cs | 12 +++++------ 23 files changed, 55 insertions(+), 55 deletions(-) rename osu.Game/Beatmaps/{GameBeatmap.cs => BindableBeatmap.cs} (79%) rename osu.Game/Beatmaps/{IGameBeatmap.cs => IBindableBeatmap.cs} (60%) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index d34ecfac22..b6e639ea52 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor } [BackgroundDependencyLoader] - private void load(OsuConfigManager config, IGameBeatmap beatmap) + private void load(OsuConfigManager config, IBindableBeatmap beatmap) { Child = cursorContainer = new SkinnableDrawable("cursor", _ => new CircularContainer { diff --git a/osu.Game/Beatmaps/GameBeatmap.cs b/osu.Game/Beatmaps/BindableBeatmap.cs similarity index 79% rename from osu.Game/Beatmaps/GameBeatmap.cs rename to osu.Game/Beatmaps/BindableBeatmap.cs index e470dd8ac5..34d9cd3d25 100644 --- a/osu.Game/Beatmaps/GameBeatmap.cs +++ b/osu.Game/Beatmaps/BindableBeatmap.cs @@ -12,14 +12,14 @@ namespace osu.Game.Beatmaps { /// /// A for the beatmap. - /// This should be used sparingly in-favour of . + /// This should be used sparingly in-favour of . /// - public abstract class GameBeatmap : NonNullableBindable, IGameBeatmap + public abstract class BindableBeatmap : NonNullableBindable, IBindableBeatmap { private AudioManager audioManager; private WorkingBeatmap lastBeatmap; - protected GameBeatmap(WorkingBeatmap defaultValue) + protected BindableBeatmap(WorkingBeatmap defaultValue) : base(defaultValue) { } @@ -63,13 +63,13 @@ namespace osu.Game.Beatmaps } [NotNull] - IGameBeatmap IGameBeatmap.GetBoundCopy() => GetBoundCopy(); + IBindableBeatmap IBindableBeatmap.GetBoundCopy() => GetBoundCopy(); /// - /// Retrieve a new instance weakly bound to this . - /// If you are further binding to events of the retrieved , ensure a local reference is held. + /// Retrieve a new instance weakly bound to this . + /// If you are further binding to events of the retrieved , ensure a local reference is held. /// [NotNull] - public abstract GameBeatmap GetBoundCopy(); + public abstract BindableBeatmap GetBoundCopy(); } } diff --git a/osu.Game/Beatmaps/IGameBeatmap.cs b/osu.Game/Beatmaps/IBindableBeatmap.cs similarity index 60% rename from osu.Game/Beatmaps/IGameBeatmap.cs rename to osu.Game/Beatmaps/IBindableBeatmap.cs index b2840f1c7e..329c0b6a3c 100644 --- a/osu.Game/Beatmaps/IGameBeatmap.cs +++ b/osu.Game/Beatmaps/IBindableBeatmap.cs @@ -8,12 +8,12 @@ namespace osu.Game.Beatmaps /// /// Read-only interface for the beatmap. /// - public interface IGameBeatmap : IBindable + public interface IBindableBeatmap : IBindable { /// - /// Retrieve a new instance weakly bound to this . - /// If you are further binding to events of the retrieved , ensure a local reference is held. + /// Retrieve a new instance weakly bound to this . + /// If you are further binding to events of the retrieved , ensure a local reference is held. /// - IGameBeatmap GetBoundCopy(); + IBindableBeatmap GetBoundCopy(); } } diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index 92e38033a9..f0d49af988 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.Containers } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap) + private void load(IBindableBeatmap beatmap) { Beatmap.BindTo(beatmap); } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index b258c059d9..395ae1bea9 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -64,8 +64,8 @@ namespace osu.Game protected override Container Content => content; - private OsuGameBeatmap beatmap; - protected GameBeatmap Beatmap => beatmap; + private OsuBindableBeatmap beatmap; + protected BindableBeatmap Beatmap => beatmap; private Bindable fpsDisplayVisible; @@ -157,15 +157,15 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light")); var defaultBeatmap = new DummyWorkingBeatmap(this); - beatmap = new OsuGameBeatmap(defaultBeatmap, Audio); + beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio); BeatmapManager.DefaultBeatmap = defaultBeatmap; // tracks play so loud our samples can't keep up. // this adds a global reduction of track volume for the time being. Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8)); - dependencies.CacheAs(beatmap); - dependencies.CacheAs(beatmap); + dependencies.CacheAs(beatmap); + dependencies.CacheAs(beatmap); FileStore.Cleanup(); @@ -237,22 +237,22 @@ namespace osu.Game public string[] HandledExtensions => fileImporters.SelectMany(i => i.HandledExtensions).ToArray(); - private class OsuGameBeatmap : GameBeatmap + private class OsuBindableBeatmap : BindableBeatmap { - public OsuGameBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) + public OsuBindableBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager) : this(defaultValue) { RegisterAudioManager(audioManager); } - private OsuGameBeatmap(WorkingBeatmap defaultValue) + private OsuBindableBeatmap(WorkingBeatmap defaultValue) : base(defaultValue) { } - public override GameBeatmap GetBoundCopy() + public override BindableBeatmap GetBoundCopy() { - var copy = new OsuGameBeatmap(Default); + var copy = new OsuBindableBeatmap(Default); copy.BindTo(this); return copy; } diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index ce1dd42015..19ce0cf932 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Music } [BackgroundDependencyLoader] - private void load(BeatmapManager beatmaps, IGameBeatmap beatmap) + private void load(BeatmapManager beatmaps, IBindableBeatmap beatmap) { beatmaps.GetAllUsableBeatmapSets().ForEach(addBeatmapSet); beatmaps.ItemAdded += addBeatmapSet; diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 5efe347ba5..440ac15791 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -26,14 +26,14 @@ namespace osu.Game.Overlays.Music /// public Action OrderChanged; - private GameBeatmap beatmap; + private BindableBeatmap beatmap; private BeatmapManager beatmaps; private FilterControl filter; private PlaylistList list; [BackgroundDependencyLoader] - private void load(OsuColour colours, GameBeatmap beatmap, BeatmapManager beatmaps) + private void load(OsuColour colours, BindableBeatmap beatmap, BeatmapManager beatmaps) { this.beatmap = beatmap.GetBoundCopy(); this.beatmaps = beatmaps; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 733b37cec0..2ef48f9ffa 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -54,7 +54,7 @@ namespace osu.Game.Overlays private Container dragContainer; private Container playerContainer; - private GameBeatmap beatmap; + private BindableBeatmap beatmap; public MusicController() { @@ -94,7 +94,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(GameBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation) + private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation) { this.beatmap = beatmap.GetBoundCopy(); this.beatmaps = beatmaps; diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 443b4fd756..0c91c9f548 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Edit } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap, IFrameBasedClock framedClock) + private void load(IBindableBeatmap beatmap, IFrameBasedClock framedClock) { this.beatmap.BindTo(beatmap); diff --git a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs index 81a5b24483..caf9ba27ff 100644 --- a/osu.Game/Screens/Edit/Components/BottomBarContainer.cs +++ b/osu.Game/Screens/Edit/Components/BottomBarContainer.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Edit.Components } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap, OsuColour colours) + private void load(IBindableBeatmap beatmap, OsuColour colours) { Beatmap.BindTo(beatmap); background.Colour = colours.Gray1; diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs index 0aeeef717e..07d9398d38 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/TimelinePart.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap) + private void load(IBindableBeatmap beatmap) { Beatmap.BindTo(beatmap); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs index 5f2e8525a6..dfc6b41432 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs @@ -44,7 +44,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap) + private void load(IBindableBeatmap beatmap) { this.beatmap.BindTo(beatmap); diff --git a/osu.Game/Screens/Edit/Screens/EditorScreen.cs b/osu.Game/Screens/Edit/Screens/EditorScreen.cs index b7c0dee5e3..f8402b9a9f 100644 --- a/osu.Game/Screens/Edit/Screens/EditorScreen.cs +++ b/osu.Game/Screens/Edit/Screens/EditorScreen.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Edit.Screens } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap) + private void load(IBindableBeatmap beatmap) { Beatmap.BindTo(beatmap); } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 927884f6d5..0f374c7d4d 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Menu /// public bool DidLoadMenu; - private GameBeatmap beatmapBacking; + private BindableBeatmap beatmapBacking; private MainMenu mainMenu; private SampleChannel welcome; @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Menu private WorkingBeatmap beatmap; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, GameBeatmap beatmap) + private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap) { beatmapBacking = beatmap.GetBoundCopy(); diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 9773ca0834..fb6130fa36 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(ShaderManager shaders, IGameBeatmap beatmap) + private void load(ShaderManager shaders, IBindableBeatmap beatmap) { this.beatmap.BindTo(beatmap); shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED); diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 4b65fb86f5..7d46aad089 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -45,7 +45,7 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap, OsuColour colours) + private void load(IBindableBeatmap beatmap, OsuColour colours) { this.beatmap.BindTo(beatmap); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 3494efb362..56d241d2c8 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -79,7 +79,7 @@ namespace osu.Game.Screens private SampleChannel sampleExit; [BackgroundDependencyLoader(permitNulls: true)] - private void load(IGameBeatmap beatmap, OsuGame osuGame, AudioManager audio) + private void load(IBindableBeatmap beatmap, OsuGame osuGame, AudioManager audio) { if (beatmap != null) Beatmap.BindTo(beatmap); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index a026857210..b73beb80a0 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -30,7 +30,7 @@ namespace osu.Game.Screens.Select protected readonly BeatmapDetailArea BeatmapDetails; private bool removeAutoModOnResume; - private GameBeatmap beatmap; + private BindableBeatmap beatmap; public PlaySongSelect() { @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select public readonly Bindable> SelectedMods = new Bindable>(new List()); [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu, GameBeatmap beatmap) + private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu, BindableBeatmap beatmap) { this.beatmap = beatmap.GetBoundCopy(); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index f0403d8b24..52880418b8 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Select private SampleChannel sampleChangeDifficulty; private SampleChannel sampleChangeBeatmap; - private GameBeatmap beatmap; + private BindableBeatmap beatmap; private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) @@ -179,7 +179,7 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader(permitNulls: true)] - private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours, GameBeatmap beatmap) + private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours, BindableBeatmap beatmap) { this.beatmap = beatmap.GetBoundCopy(); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs index 253902fb81..d15f3053a3 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs @@ -64,7 +64,7 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap, TextureStore textureStore) + private void load(IBindableBeatmap beatmap, TextureStore textureStore) { var basePath = Animation.Path.ToLowerInvariant(); for (var frame = 0; frame < Animation.FrameCount; frame++) diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs index f3fb5e368a..efbb3de253 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs @@ -63,7 +63,7 @@ namespace osu.Game.Storyboards.Drawables } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap, TextureStore textureStore) + private void load(IBindableBeatmap beatmap, TextureStore textureStore) { var spritePath = Sprite.Path.ToLowerInvariant(); var path = beatmap.Value.BeatmapSetInfo.Files.FirstOrDefault(f => f.Filename.ToLowerInvariant() == spritePath)?.FileInfo.StoragePath; diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index ec1729ac5b..f98aca4dff 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual public abstract class OsuTestCase : TestCase { private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap()); - protected GameBeatmap Beatmap => beatmap; + protected BindableBeatmap Beatmap => beatmap; private DependencyContainer dependencies; @@ -21,8 +21,8 @@ namespace osu.Game.Tests.Visual { dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - dependencies.CacheAs(beatmap); - dependencies.CacheAs(beatmap); + dependencies.CacheAs(beatmap); + dependencies.CacheAs(beatmap); return dependencies; } @@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual public void RunTestBlocking(TestCase test) => runner.RunTestBlocking(test); } - private class OsuTestBeatmap : GameBeatmap + private class OsuTestBeatmap : BindableBeatmap { public OsuTestBeatmap(WorkingBeatmap defaultValue) : base(defaultValue) @@ -72,7 +72,7 @@ namespace osu.Game.Tests.Visual public void SetAudioManager(AudioManager audioManager) => RegisterAudioManager(audioManager); - public override GameBeatmap GetBoundCopy() + public override BindableBeatmap GetBoundCopy() { var copy = new OsuTestBeatmap(Default); copy.BindTo(this); diff --git a/osu.Game/Tests/Visual/TestCasePerformancePoints.cs b/osu.Game/Tests/Visual/TestCasePerformancePoints.cs index b6d92f4ec5..dfae8fbc1d 100644 --- a/osu.Game/Tests/Visual/TestCasePerformancePoints.cs +++ b/osu.Game/Tests/Visual/TestCasePerformancePoints.cs @@ -108,9 +108,9 @@ namespace osu.Game.Tests.Visual { private readonly Container beatmapDisplays; private readonly Ruleset ruleset; - private readonly GameBeatmap beatmapBindable; + private readonly BindableBeatmap beatmapBindable; - public BeatmapList(Ruleset ruleset, GameBeatmap beatmapBindable) + public BeatmapList(Ruleset ruleset, BindableBeatmap beatmapBindable) { this.ruleset = ruleset; this.beatmapBindable = beatmapBindable; @@ -140,7 +140,7 @@ namespace osu.Game.Tests.Visual private readonly OsuSpriteText text; private readonly BeatmapInfo beatmap; - private readonly GameBeatmap beatmapBindable; + private readonly BindableBeatmap beatmapBindable; private BeatmapManager beatmaps; @@ -148,7 +148,7 @@ namespace osu.Game.Tests.Visual public string TooltipText => text.Text; - public BeatmapDisplay(BeatmapInfo beatmap, GameBeatmap beatmapBindable) + public BeatmapDisplay(BeatmapInfo beatmap, BindableBeatmap beatmapBindable) { this.beatmap = beatmap; this.beatmapBindable = beatmapBindable; @@ -223,7 +223,7 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap, APIAccess api) + private void load(IBindableBeatmap beatmap, APIAccess api) { this.api = api; @@ -336,7 +336,7 @@ namespace osu.Game.Tests.Visual } [BackgroundDependencyLoader] - private void load(IGameBeatmap beatmap) + private void load(IBindableBeatmap beatmap) { beatmap.ValueChanged += beatmapChanged; } From ff60f69f47be9a5703d2790956e379b7ff1a4ecd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 6 Jun 2018 20:19:30 +0900 Subject: [PATCH 221/253] Explicitly construct local beatmaps rather than using GetBoundCopy --- osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs | 4 ++-- osu.Game/Overlays/Music/PlaylistOverlay.cs | 5 +++-- osu.Game/Overlays/MusicController.cs | 5 +++-- osu.Game/Screens/Menu/Intro.cs | 12 ++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index b6e639ea52..240d8dc396 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private Bindable cursorScale; private Bindable autoCursorScale; - private IBindable beatmap; + private readonly IBindable beatmap = new Bindable(); public OsuCursor() { @@ -160,7 +160,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor RelativeSizeAxes = Axes.Both, }; - this.beatmap = beatmap.GetBoundCopy(); + this.beatmap.BindTo(beatmap); beatmap.ValueChanged += v => calculateScale(); cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize); diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 440ac15791..b74e7e1178 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -26,7 +27,7 @@ namespace osu.Game.Overlays.Music /// public Action OrderChanged; - private BindableBeatmap beatmap; + private readonly Bindable beatmap = new Bindable(); private BeatmapManager beatmaps; private FilterControl filter; @@ -35,7 +36,7 @@ namespace osu.Game.Overlays.Music [BackgroundDependencyLoader] private void load(OsuColour colours, BindableBeatmap beatmap, BeatmapManager beatmaps) { - this.beatmap = beatmap.GetBoundCopy(); + this.beatmap.BindTo(beatmap); this.beatmaps = beatmaps; Children = new Drawable[] diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 2ef48f9ffa..18e5379224 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -54,7 +55,7 @@ namespace osu.Game.Overlays private Container dragContainer; private Container playerContainer; - private BindableBeatmap beatmap; + private readonly Bindable beatmap = new Bindable(); public MusicController() { @@ -96,7 +97,7 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader] private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation) { - this.beatmap = beatmap.GetBoundCopy(); + this.beatmap.BindTo(beatmap); this.beatmaps = beatmaps; this.localisation = localisation; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 0f374c7d4d..b0472ae705 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Menu /// public bool DidLoadMenu; - private BindableBeatmap beatmapBacking; + private readonly Bindable beatmap = new Bindable(); private MainMenu mainMenu; private SampleChannel welcome; @@ -43,12 +43,12 @@ namespace osu.Game.Screens.Menu private Bindable menuVoice; private Bindable menuMusic; private Track track; - private WorkingBeatmap beatmap; + private WorkingBeatmap introBeatmap; [BackgroundDependencyLoader] private void load(AudioManager audio, OsuConfigManager config, BeatmapManager beatmaps, Framework.Game game, BindableBeatmap beatmap) { - beatmapBacking = beatmap.GetBoundCopy(); + this.beatmap.BindTo(beatmap); menuVoice = config.GetBindable(OsuSetting.MenuVoice); menuMusic = config.GetBindable(OsuSetting.MenuMusic); @@ -76,8 +76,8 @@ namespace osu.Game.Screens.Menu } } - this.beatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); - track = this.beatmap.Track; + introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); + track = introBeatmap.Track; welcome = audio.Sample.Get(@"welcome"); seeya = audio.Sample.Get(@"seeya"); @@ -94,7 +94,7 @@ namespace osu.Game.Screens.Menu if (!resuming) { - beatmapBacking.Value = beatmap; + beatmap.Value = introBeatmap; if (menuVoice) welcome.Play(); From e77084bec446f947a053a249336054a175f1ffad Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 6 Jun 2018 20:19:53 +0900 Subject: [PATCH 222/253] Give OsuScreen a mutable BindableBeatmap --- osu.Game/Screens/OsuScreen.cs | 6 +++--- osu.Game/Screens/Select/PlaySongSelect.cs | 8 ++------ osu.Game/Screens/Select/SongSelect.cs | 12 ++++-------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 56d241d2c8..bfe1778f39 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -68,7 +68,7 @@ namespace osu.Game.Screens /// public virtual bool AllowBeatmapRulesetChange => true; - protected readonly IBindable Beatmap = new Bindable(); + protected readonly Bindable Beatmap = new Bindable(); protected virtual float BackgroundParallaxAmount => 1; @@ -78,8 +78,8 @@ namespace osu.Game.Screens private SampleChannel sampleExit; - [BackgroundDependencyLoader(permitNulls: true)] - private void load(IBindableBeatmap beatmap, OsuGame osuGame, AudioManager audio) + [BackgroundDependencyLoader(true)] + private void load(BindableBeatmap beatmap, OsuGame osuGame, AudioManager audio) { if (beatmap != null) Beatmap.BindTo(beatmap); diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index b73beb80a0..8ce40fcfa0 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -30,8 +30,6 @@ namespace osu.Game.Screens.Select protected readonly BeatmapDetailArea BeatmapDetails; private bool removeAutoModOnResume; - private BindableBeatmap beatmap; - public PlaySongSelect() { FooterPanels.Add(modSelect = new ModSelectOverlay @@ -55,10 +53,8 @@ namespace osu.Game.Screens.Select public readonly Bindable> SelectedMods = new Bindable>(new List()); [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu, BindableBeatmap beatmap) + private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu) { - this.beatmap = beatmap.GetBoundCopy(); - if (osu != null) SelectedMods.BindTo(osu.SelectedMods); modSelect.SelectedMods.BindTo(SelectedMods); @@ -160,7 +156,7 @@ namespace osu.Game.Screens.Select } Beatmap.Value.Track.Looping = false; - beatmap.Disabled = true; + Beatmap.Disabled = true; sampleConfirm?.Play(); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 52880418b8..b04ffecf48 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -62,8 +62,6 @@ namespace osu.Game.Screens.Select private SampleChannel sampleChangeDifficulty; private SampleChannel sampleChangeBeatmap; - private BindableBeatmap beatmap; - private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); @@ -178,11 +176,9 @@ namespace osu.Game.Screens.Select } } - [BackgroundDependencyLoader(permitNulls: true)] - private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours, BindableBeatmap beatmap) + [BackgroundDependencyLoader(true)] + private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours) { - this.beatmap = beatmap.GetBoundCopy(); - dependencies.CacheAs(this); if (Footer != null) @@ -219,7 +215,7 @@ namespace osu.Game.Screens.Select public void Edit(BeatmapInfo beatmap) { - this.beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value); + Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value); Push(new Editor()); } @@ -285,7 +281,7 @@ namespace osu.Game.Screens.Select { bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID; - this.beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value); + Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value); ensurePlayingSelected(preview); } From f2ac5b8b2d7704835bf0283caaef949bed8d02f4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 6 Jun 2018 20:21:47 +0900 Subject: [PATCH 223/253] CreatePlayer shouldn't receive a beatmap --- osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs | 6 +++--- osu.Game.Tests/Visual/TestCaseAutoplay.cs | 5 ++--- osu.Game.Tests/Visual/TestCaseReplay.cs | 9 ++++----- osu.Game/Tests/Visual/TestCasePlayer.cs | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs b/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs index 097750d7e0..34e07170bd 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestCaseAutoJuiceStream.cs @@ -53,10 +53,10 @@ namespace osu.Game.Rulesets.Catch.Tests return beatmap; } - protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) + protected override Player CreatePlayer(Ruleset ruleset) { - beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); - return base.CreatePlayer(beatmap, ruleset); + Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); + return base.CreatePlayer(ruleset); } } } diff --git a/osu.Game.Tests/Visual/TestCaseAutoplay.cs b/osu.Game.Tests/Visual/TestCaseAutoplay.cs index a009027627..4abfec4371 100644 --- a/osu.Game.Tests/Visual/TestCaseAutoplay.cs +++ b/osu.Game.Tests/Visual/TestCaseAutoplay.cs @@ -3,7 +3,6 @@ using System.ComponentModel; using System.Linq; -using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; @@ -13,9 +12,9 @@ namespace osu.Game.Tests.Visual [Description("Player instantiated with an autoplay mod.")] public class TestCaseAutoplay : TestCasePlayer { - protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) + protected override Player CreatePlayer(Ruleset ruleset) { - beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); + Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); return new ScoreAccessiblePlayer { AllowPause = false, diff --git a/osu.Game.Tests/Visual/TestCaseReplay.cs b/osu.Game.Tests/Visual/TestCaseReplay.cs index 4bcbc924b8..1f2d99a7d8 100644 --- a/osu.Game.Tests/Visual/TestCaseReplay.cs +++ b/osu.Game.Tests/Visual/TestCaseReplay.cs @@ -3,7 +3,6 @@ using System.ComponentModel; using System.Linq; -using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Screens.Play; @@ -13,18 +12,18 @@ namespace osu.Game.Tests.Visual [Description("Player instantiated with a replay.")] public class TestCaseReplay : TestCasePlayer { - protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) + protected override Player CreatePlayer(Ruleset ruleset) { // We create a dummy RulesetContainer just to get the replay - we don't want to use mods here // to simulate setting a replay rather than having the replay already set for us - beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); - var dummyRulesetContainer = ruleset.CreateRulesetContainerWith(beatmap); + Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); + var dummyRulesetContainer = ruleset.CreateRulesetContainerWith(Beatmap.Value); // We have the replay var replay = dummyRulesetContainer.Replay; // Reset the mods - beatmap.Mods.Value = beatmap.Mods.Value.Where(m => !(m is ModAutoplay)); + Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Where(m => !(m is ModAutoplay)); return new ReplayPlayer(replay); } diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index be6468e308..3cdc496ee1 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual if (Player != null) Remove(Player); - var player = CreatePlayer(Beatmap, r); + var player = CreatePlayer(r); LoadComponentAsync(player, LoadScreen); @@ -86,7 +86,7 @@ namespace osu.Game.Tests.Visual Beatmap.Value.Track.Rate = Clock.Rate; } - protected virtual Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) => new Player + protected virtual Player CreatePlayer(Ruleset ruleset) => new Player { AllowPause = false, AllowLeadIn = false, From ebcfe97ccf3013d7c401f6fd4e8a1b5f5b41ffa2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 6 Jun 2018 20:25:40 +0900 Subject: [PATCH 224/253] Expose Dependencies from base OsuTestCase --- .../TestCaseManiaPlayfield.cs | 7 +------ osu.Game.Tests/Visual/TestCaseChatLink.cs | 6 +----- osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs | 9 ++------- osu.Game.Tests/Visual/TestCasePlaySongSelect.cs | 8 ++------ osu.Game.Tests/Visual/TestCasePlaybackControl.cs | 9 ++------- osu.Game.Tests/Visual/TestCaseSettings.cs | 7 +------ osu.Game/Tests/Visual/EditorClockTestCase.cs | 11 +++-------- osu.Game/Tests/Visual/OsuTestCase.cs | 10 +++++----- 8 files changed, 17 insertions(+), 50 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/TestCaseManiaPlayfield.cs b/osu.Game.Rulesets.Mania.Tests/TestCaseManiaPlayfield.cs index dff2b2d56a..b064d82a23 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestCaseManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestCaseManiaPlayfield.cs @@ -98,17 +98,12 @@ namespace osu.Game.Rulesets.Mania.Tests }); } - private DependencyContainer dependencies; - - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - [BackgroundDependencyLoader] private void load(RulesetStore rulesets, SettingsStore settings) { maniaRuleset = rulesets.GetRuleset(3); - dependencies.Cache(new ManiaConfigManager(settings, maniaRuleset, 4)); + Dependencies.Cache(new ManiaConfigManager(settings, maniaRuleset, 4)); } private ManiaPlayfield createPlayfield(int cols, bool inverted = false) diff --git a/osu.Game.Tests/Visual/TestCaseChatLink.cs b/osu.Game.Tests/Visual/TestCaseChatLink.cs index 608691cdf6..12a7ee9c12 100644 --- a/osu.Game.Tests/Visual/TestCaseChatLink.cs +++ b/osu.Game.Tests/Visual/TestCaseChatLink.cs @@ -35,10 +35,6 @@ namespace osu.Game.Tests.Visual typeof(MessageFormatter) }; - private DependencyContainer dependencies; - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - public TestCaseChatLink() { Add(textContainer = new TestChatLineContainer @@ -54,7 +50,7 @@ namespace osu.Game.Tests.Visual private void load(OsuColour colours) { linkColour = colours.Blue; - dependencies.Cache(new ChatOverlay + Dependencies.Cache(new ChatOverlay { AvailableChannels = { diff --git a/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs b/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs index 0658de6576..5df371dd09 100644 --- a/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs +++ b/osu.Game.Tests/Visual/TestCaseHitObjectComposer.cs @@ -32,11 +32,6 @@ namespace osu.Game.Tests.Visual typeof(NotNullAttribute) }; - private DependencyContainer dependencies; - - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - [BackgroundDependencyLoader] private void load() { @@ -63,8 +58,8 @@ namespace osu.Game.Tests.Visual }); var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - dependencies.CacheAs(clock); - dependencies.CacheAs(clock); + Dependencies.CacheAs(clock); + Dependencies.CacheAs(clock); Child = new OsuHitObjectComposer(new OsuRuleset()); } diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index b90e6c1ca7..10121738f1 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -27,7 +27,6 @@ namespace osu.Game.Tests.Visual private RulesetStore rulesets; - private DependencyContainer dependencies; private WorkingBeatmap defaultBeatmap; public override IReadOnlyList RequiredTypes => new[] @@ -48,9 +47,6 @@ namespace osu.Game.Tests.Visual typeof(DrawableCarouselBeatmapSet), }; - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - private class TestSongSelect : PlaySongSelect { public WorkingBeatmap CurrentBeatmap => Beatmap.Value; @@ -68,8 +64,8 @@ namespace osu.Game.Tests.Visual // this is by no means clean. should be replacing inside of OsuGameBase somehow. IDatabaseContextFactory factory = new SingletonContextFactory(new OsuDbContext()); - dependencies.Cache(rulesets = new RulesetStore(factory)); - dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null, null) + Dependencies.Cache(rulesets = new RulesetStore(factory)); + Dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null, null) { DefaultBeatmap = defaultBeatmap = Beatmap.Default }); diff --git a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs index 5c0c0cb220..36fb1bcedd 100644 --- a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs +++ b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs @@ -15,17 +15,12 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCasePlaybackControl : OsuTestCase { - private DependencyContainer dependencies; - - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - [BackgroundDependencyLoader] private void load() { var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - dependencies.CacheAs(clock); - dependencies.CacheAs(clock); + Dependencies.CacheAs(clock); + Dependencies.CacheAs(clock); var playback = new PlaybackControl { diff --git a/osu.Game.Tests/Visual/TestCaseSettings.cs b/osu.Game.Tests/Visual/TestCaseSettings.cs index 91dd35e148..c942342168 100644 --- a/osu.Game.Tests/Visual/TestCaseSettings.cs +++ b/osu.Game.Tests/Visual/TestCaseSettings.cs @@ -14,11 +14,6 @@ namespace osu.Game.Tests.Visual private readonly SettingsOverlay settings; private readonly DialogOverlay dialogOverlay; - private DependencyContainer dependencies; - - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - public TestCaseSettings() { settings = new MainSettings @@ -34,7 +29,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - dependencies.Cache(dialogOverlay); + Dependencies.Cache(dialogOverlay); Add(settings); } diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index 0a0d641c0e..0363fa75ba 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -20,11 +20,6 @@ namespace osu.Game.Tests.Visual protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor(); protected readonly EditorClock Clock; - private DependencyContainer dependencies; - - protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) - => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - protected EditorClockTestCase() { Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false }; @@ -33,9 +28,9 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - dependencies.Cache(BeatDivisor); - dependencies.CacheAs(Clock); - dependencies.CacheAs(Clock); + Dependencies.Cache(BeatDivisor); + Dependencies.CacheAs(Clock); + Dependencies.CacheAs(Clock); Beatmap.ValueChanged += beatmapChanged; beatmapChanged(Beatmap.Value); diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index f98aca4dff..f8c6219134 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -15,16 +15,16 @@ namespace osu.Game.Tests.Visual private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap()); protected BindableBeatmap Beatmap => beatmap; - private DependencyContainer dependencies; + protected DependencyContainer Dependencies { get; private set; } protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) { - dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); + Dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - dependencies.CacheAs(beatmap); - dependencies.CacheAs(beatmap); + Dependencies.CacheAs(beatmap); + Dependencies.CacheAs(beatmap); - return dependencies; + return Dependencies; } [BackgroundDependencyLoader] From 18fc63bac25db72bb994550bde22b52f63d92f29 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 6 Jun 2018 20:32:37 +0900 Subject: [PATCH 225/253] Add back removed using --- osu.Game/Screens/OsuScreen.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index c2da8ea6f3..61018f9e08 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.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 System; using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; From c756a89dafb7a4e37c5f5e90a086b8babf78225d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 20:55:42 +0900 Subject: [PATCH 226/253] Standardise path --- osu.Game/IO/Archives/LegacyFilesystemReader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/IO/Archives/LegacyFilesystemReader.cs b/osu.Game/IO/Archives/LegacyFilesystemReader.cs index fc52cb10dd..dcaaf41c77 100644 --- a/osu.Game/IO/Archives/LegacyFilesystemReader.cs +++ b/osu.Game/IO/Archives/LegacyFilesystemReader.cs @@ -17,14 +17,14 @@ namespace osu.Game.IO.Archives public LegacyFilesystemReader(string path) : base(Path.GetFileName(path)) { - this.path = path; + // re-get full path to standardise with Directory.GetFiles return values below. + this.path = Path.GetFullPath(path); } public override Stream GetStream(string name) => File.OpenRead(Path.Combine(path, name)); public override void Dispose() { - // no-op } public override IEnumerable Filenames => Directory.GetFiles(path, "*", SearchOption.AllDirectories).Select(f => f.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar)).ToArray(); From 00b4a2519f172671ae6db67283dda9f5e51b6596 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 21:10:18 +0900 Subject: [PATCH 227/253] Update framework --- osu.Desktop.Deploy/osu.Desktop.Deploy.csproj | 2 +- osu.Game/osu.Game.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj b/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj index e5944187b3..f6cf023e0d 100644 --- a/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj +++ b/osu.Desktop.Deploy/osu.Desktop.Deploy.csproj @@ -9,7 +9,7 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 55ee87dcb3..2300ba6a72 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - + From 2ec1fcd245abd637fd9d44d91264d8feb2f2fd74 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 21:29:45 +0900 Subject: [PATCH 228/253] Fix incorrect using --- osu.Desktop/Overlays/VersionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index b984c0bbba..d061aa8423 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using osu.Framework.Allocation; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -14,6 +13,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; +using osu.Game.Utils; using OpenTK; using OpenTK.Graphics; From 2eb59830c13b608b2aeef1f5d2b8d28fb7276e5a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 21:31:58 +0900 Subject: [PATCH 229/253] Fix vs version --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 314faa617a..69bc762f4c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ clone_depth: 1 version: '{branch}-{build}' -image: Visual Studio 2017 preview +image: Visual Studio 2017 configuration: Debug cache: - C:\ProgramData\chocolatey\bin -> appveyor.yml From 576acaa630f52cc0aac76e7e0f42304be0906c2a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 21:54:45 +0900 Subject: [PATCH 230/253] Merge upstream master into external-deploy --- .gitmodules | 5 +- osu-framework | 1 - osu.Desktop/Overlays/VersionManager.cs | 2 +- osu.Desktop/osu.Desktop.csproj | 1 - osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs | 19 ++-- .../Beatmaps/IO/ImportBeatmapTest.cs | 9 +- osu.Game/Configuration/OsuConfigManager.cs | 5 +- .../Containers/OsuFocusedOverlayContainer.cs | 25 +++--- osu.Game/OsuGame.cs | 54 ++++++----- osu.Game/OsuGameBase.cs | 6 +- osu.Game/Overlays/BeatmapSet/Info.cs | 8 +- osu.Game/Overlays/NotificationOverlay.cs | 49 +++++----- osu.Game/Overlays/OverlayActivation.cs | 12 +++ .../Sections/Gameplay/ModsSettings.cs | 26 ++++++ .../Settings/Sections/GameplaySection.cs | 3 +- osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- osu.Game/Overlays/Toolbar/Toolbar.cs | 17 ++++ osu.Game/Rulesets/Mods/IReadFromConfig.cs | 15 ++++ osu.Game/Rulesets/Mods/ModHidden.cs | 23 ++++- osu.Game/Rulesets/UI/RulesetContainer.cs | 16 ++-- osu.Game/Rulesets/UI/RulesetInputManager.cs | 2 - osu.Game/Screens/Menu/ButtonSystem.cs | 39 ++++---- osu.Game/Screens/Menu/Disclaimer.cs | 3 +- osu.Game/Screens/Menu/Intro.cs | 3 +- osu.Game/Screens/Menu/MainMenu.cs | 1 - osu.Game/Screens/OsuScreen.cs | 28 ++++-- osu.Game/Screens/Play/Player.cs | 3 + osu.Game/Screens/Select/BeatmapDetails.cs | 22 +---- .../Select/Leaderboards/LeaderboardScore.cs | 89 ++++++++++++------- osu.Game/Tests/Visual/OsuTestCase.cs | 4 - osu.Game/Utils/DebugUtils.cs | 21 +++++ osu.Game/osu.Game.csproj | 2 +- osu.TestProject.props | 3 +- osu.sln | 6 -- 34 files changed, 323 insertions(+), 201 deletions(-) delete mode 160000 osu-framework create mode 100644 osu.Game/Overlays/OverlayActivation.cs create mode 100644 osu.Game/Overlays/Settings/Sections/Gameplay/ModsSettings.cs create mode 100644 osu.Game/Rulesets/Mods/IReadFromConfig.cs create mode 100644 osu.Game/Utils/DebugUtils.cs diff --git a/.gitmodules b/.gitmodules index ee1cc80880..f1c4f5d172 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "osu-framework"] - path = osu-framework - url = https://github.com/ppy/osu-framework [submodule "osu-resources"] path = osu-resources - url = https://github.com/ppy/osu-resources + url = https://github.com/ppy/osu-resources \ No newline at end of file diff --git a/osu-framework b/osu-framework deleted file mode 160000 index b963ce8250..0000000000 --- a/osu-framework +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b963ce82505bc953db0a0763679e1ec80a060811 diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index b984c0bbba..d061aa8423 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using osu.Framework.Allocation; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -14,6 +13,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; +using osu.Game.Utils; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index b8efd76506..766f36fa74 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -20,7 +20,6 @@ osu.Desktop.Program - diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs index e72d667c0b..4220b72b16 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs @@ -7,33 +7,34 @@ 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; -using osu.Game.Rulesets.Osu.Objects.Drawables; 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 void ApplyToDrawableHitObjects(IEnumerable drawables) + public override void ApplyToDrawableHitObjects(IEnumerable drawables) { + void adjustFadeIn(OsuHitObject h) => h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; + foreach (var d in drawables.OfType()) { - d.ApplyCustomUpdateState += ApplyHiddenState; - - d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier; + adjustFadeIn(d.HitObject); foreach (var h in d.HitObject.NestedHitObjects.OfType()) - h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier; + adjustFadeIn(h); } + + base.ApplyToDrawableHitObjects(drawables); } - 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.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 586217a05f..1c9696901c 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -264,7 +264,8 @@ namespace osu.Game.Tests.Beatmaps.IO private string createTemporaryBeatmap() { - var temp = new FileInfo(osz_path).CopyTo(Path.GetTempFileName(), true).FullName; + var temp = Path.GetTempFileName() + ".osz"; + File.Copy(osz_path, temp, true); Assert.IsTrue(File.Exists(temp)); return temp; } @@ -344,12 +345,12 @@ namespace osu.Game.Tests.Beatmaps.IO private void waitForOrAssert(Func result, string failureMessage, int timeout = 60000) { - Action waitAction = () => + Task task = Task.Run(() => { while (!result()) Thread.Sleep(200); - }; + }); - Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), failureMessage); + Assert.IsTrue(task.Wait(timeout), failureMessage); } } } diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index b3082e49de..597960c352 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -82,6 +82,8 @@ namespace osu.Game.Configuration Set(OsuSetting.SpeedChangeVisualisation, SpeedChangeVisualisationMethod.Sequential); + Set(OsuSetting.IncreaseFirstObjectVisibility, true); + // Update Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer); @@ -144,6 +146,7 @@ namespace osu.Game.Configuration ScreenshotCaptureMenuCursor, SongSelectRightMouseScroll, BeatmapSkins, - BeatmapHitsounds + BeatmapHitsounds, + IncreaseFirstObjectVisibility } } diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 11a2034a8f..0186a170c9 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using OpenTK; using osu.Framework.Configuration; +using osu.Game.Overlays; namespace osu.Game.Graphics.Containers { @@ -16,13 +17,13 @@ namespace osu.Game.Graphics.Containers private SampleChannel samplePopIn; private SampleChannel samplePopOut; - private readonly BindableBool allowOpeningOverlays = new BindableBool(true); + protected readonly Bindable OverlayActivationMode = new Bindable(OverlayActivation.All); [BackgroundDependencyLoader(true)] private void load(OsuGame osuGame, AudioManager audio) { if (osuGame != null) - allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays); + OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in"); samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out"); @@ -52,20 +53,18 @@ namespace osu.Game.Graphics.Containers private void onStateChanged(Visibility visibility) { - if (allowOpeningOverlays) + switch (visibility) { - switch (visibility) - { - case Visibility.Visible: + case Visibility.Visible: + if (OverlayActivationMode != OverlayActivation.Disabled) samplePopIn?.Play(); - break; - case Visibility.Hidden: - samplePopOut?.Play(); - break; - } + else + State = Visibility.Hidden; + break; + case Visibility.Hidden: + samplePopOut?.Play(); + break; } - else - State = Visibility.Hidden; } } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index a43c1507b6..36c76851c6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -77,8 +77,7 @@ namespace osu.Game public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight; - public readonly BindableBool HideOverlaysOnEnter = new BindableBool(); - public readonly BindableBool AllowOpeningOverlays = new BindableBool(true); + public readonly Bindable OverlayActivationMode = new Bindable(); private OsuScreen screenStack; @@ -94,6 +93,8 @@ namespace osu.Game private SettingsOverlay settings; + private readonly List overlays = new List(); + // todo: move this to SongSelect once Screen has the ability to unsuspend. public readonly Bindable> SelectedMods = new Bindable>(new List()); @@ -106,6 +107,17 @@ namespace osu.Game public void ToggleDirect() => direct.ToggleVisibility(); + /// + /// Close all game-wide overlays. + /// + /// Whether the toolbar should also be hidden. + public void CloseAllOverlays(bool toolbar = true) + { + foreach (var o in overlays) + o.State = Visibility.Hidden; + if (toolbar) Toolbar.State = Visibility.Hidden; + } + private DependencyContainer dependencies; protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => @@ -251,7 +263,7 @@ namespace osu.Game Depth = -5, OnHome = delegate { - hideAllOverlays(); + CloseAllOverlays(false); intro?.ChildScreen?.MakeCurrent(); }, }, overlayContent.Add); @@ -308,6 +320,8 @@ namespace osu.Game // ensure only one of these overlays are open at once. var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct }; + overlays.AddRange(singleDisplayOverlays); + foreach (var overlay in singleDisplayOverlays) { overlay.StateChanged += state => @@ -323,6 +337,8 @@ namespace osu.Game } var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications }; + overlays.AddRange(singleDisplaySideOverlays); + foreach (var overlay in singleDisplaySideOverlays) { overlay.StateChanged += state => @@ -339,6 +355,8 @@ namespace osu.Game // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; + overlays.AddRange(informationalOverlays); + foreach (var overlay in informationalOverlays) { overlay.StateChanged += state => @@ -353,6 +371,11 @@ namespace osu.Game }; } + OverlayActivationMode.ValueChanged += v => + { + if (v != OverlayActivation.All) CloseAllOverlays(); + }; + void updateScreenOffset() { float offset = 0; @@ -367,21 +390,6 @@ namespace osu.Game settings.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset(); - - notifications.Enabled.BindTo(AllowOpeningOverlays); - - HideOverlaysOnEnter.ValueChanged += hide => - { - //central game screen change logic. - if (hide) - { - hideAllOverlays(); - musicController.State = Visibility.Hidden; - Toolbar.State = Visibility.Hidden; - } - else - Toolbar.State = Visibility.Visible; - }; } private void forwardLoggedErrorsToNotifications() @@ -498,16 +506,6 @@ namespace osu.Game private OsuScreen currentScreen; private FrameworkConfigManager frameworkConfig; - private void hideAllOverlays() - { - settings.State = Visibility.Hidden; - chat.State = Visibility.Hidden; - direct.State = Visibility.Hidden; - social.State = Visibility.Hidden; - userProfile.State = Visibility.Hidden; - notifications.State = Visibility.Hidden; - } - protected override bool OnExiting() { if (screenStack.ChildScreen == null) return false; diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index b9d32a6322..f170f1c00f 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -10,7 +10,6 @@ using System.Reflection; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Configuration; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.IO.Stores; @@ -31,6 +30,7 @@ using osu.Game.IO; using osu.Game.Rulesets; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; +using DebugUtils = osu.Game.Utils.DebugUtils; namespace osu.Game { @@ -59,8 +59,6 @@ namespace osu.Game protected MenuCursorContainer MenuCursorContainer; - protected override string MainResourceFile => @"osu.Game.Resources.dll"; - private Container content; protected override Container Content => content; @@ -100,6 +98,8 @@ namespace osu.Game [BackgroundDependencyLoader] private void load() { + Resources.AddStore(new DllResourceStore(@"osu.Game.Resources.dll")); + dependencies.Cache(contextFactory = new DatabaseContextFactory(Host)); dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(Resources, @"Textures")))); diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index cd0b7386e8..53216ad666 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet private const float metadata_width = 225; private const float spacing = 20; - private readonly MetadataSection description, source, tags; + private readonly MetadataSection source, tags; private readonly Box successRateBackground; private readonly SuccessRate successRate; @@ -83,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet Child = new Container { RelativeSizeAxes = Axes.Both, - Child = description = new MetadataSection("Description"), + Child = new MetadataSection("Description"), }, }, new Container @@ -135,8 +135,6 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - source.TextColour = description.TextColour = colours.Gray5; - tags.TextColour = colours.BlueDark; updateDisplay(); } @@ -195,7 +193,7 @@ namespace osu.Game.Overlays.BeatmapSet [BackgroundDependencyLoader] private void load(OsuColour colours) { - header.Colour = colours.Gray5; + header.Colour = textFlow.Colour = colours.Gray5; } } } diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 09b6022ac5..3dc8f5ec15 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -22,11 +22,6 @@ namespace osu.Game.Overlays public const float TRANSITION_LENGTH = 600; - /// - /// Whether posted notifications should be processed. - /// - public readonly BindableBool Enabled = new BindableBool(true); - private FlowContainer sections; /// @@ -34,27 +29,6 @@ namespace osu.Game.Overlays /// public Func GetToolbarHeight; - public NotificationOverlay() - { - ScheduledDelegate notificationsEnabler = null; - Enabled.ValueChanged += v => - { - if (!IsLoaded) - { - processingPosts = v; - return; - } - - notificationsEnabler?.Cancel(); - - if (v) - // we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed. - notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, 1000); - else - processingPosts = false; - }; - } - [BackgroundDependencyLoader] private void load() { @@ -103,6 +77,29 @@ namespace osu.Game.Overlays }; } + private ScheduledDelegate notificationsEnabler; + private void updateProcessingMode() + { + bool enabled = OverlayActivationMode == OverlayActivation.All || State == Visibility.Visible; + + notificationsEnabler?.Cancel(); + + if (enabled) + // we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed. + notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State == Visibility.Visible ? 0 : 1000); + else + processingPosts = false; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + StateChanged += _ => updateProcessingMode(); + OverlayActivationMode.ValueChanged += _ => updateProcessingMode(); + OverlayActivationMode.TriggerChange(); + } + private int totalCount => sections.Select(c => c.DisplayedCount).Sum(); private int unreadCount => sections.Select(c => c.UnreadCount).Sum(); diff --git a/osu.Game/Overlays/OverlayActivation.cs b/osu.Game/Overlays/OverlayActivation.cs new file mode 100644 index 0000000000..da4e153ce9 --- /dev/null +++ b/osu.Game/Overlays/OverlayActivation.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Overlays +{ + public enum OverlayActivation + { + Disabled, + UserTriggered, + All + } +} 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(), }; } diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 900f03fe7b..909fc20446 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -12,6 +11,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Rulesets; using OpenTK; using OpenTK.Graphics; +using DebugUtils = osu.Game.Utils.DebugUtils; namespace osu.Game.Overlays.Settings { diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 424a457110..48d0674b3d 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -10,6 +10,8 @@ using osu.Framework.Input; using osu.Game.Graphics; using OpenTK; using osu.Framework.Graphics.Shapes; +using osu.Framework.Allocation; +using osu.Framework.Configuration; namespace osu.Game.Overlays.Toolbar { @@ -29,6 +31,8 @@ namespace osu.Game.Overlays.Toolbar private const float alpha_hovering = 0.8f; private const float alpha_normal = 0.6f; + private readonly Bindable overlayActivationMode = new Bindable(OverlayActivation.All); + public Toolbar() { Children = new Drawable[] @@ -76,6 +80,19 @@ namespace osu.Game.Overlays.Toolbar Size = new Vector2(1, HEIGHT); } + [BackgroundDependencyLoader(true)] + private void load(OsuGame osuGame) + { + if (osuGame != null) + overlayActivationMode.BindTo(osuGame.OverlayActivationMode); + + StateChanged += visibility => + { + if (overlayActivationMode == OverlayActivation.Disabled) + State = Visibility.Hidden; + }; + } + public class ToolbarBackground : Container { private readonly Box solidBackground; diff --git a/osu.Game/Rulesets/Mods/IReadFromConfig.cs b/osu.Game/Rulesets/Mods/IReadFromConfig.cs new file mode 100644 index 0000000000..93c9ae0c34 --- /dev/null +++ b/osu.Game/Rulesets/Mods/IReadFromConfig.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +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); + } +} diff --git a/osu.Game/Rulesets/Mods/ModHidden.cs b/osu.Game/Rulesets/Mods/ModHidden.cs index b489a665d9..45da628ce8 100644 --- a/osu.Game/Rulesets/Mods/ModHidden.cs +++ b/osu.Game/Rulesets/Mods/ModHidden.cs @@ -1,16 +1,37 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +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, IApplicableToDrawableHitObjects { 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 virtual void ApplyToDrawableHitObjects(IEnumerable drawables) + { + // 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) { } } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index e42e74c245..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. /// @@ -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. /// @@ -194,6 +194,7 @@ namespace osu.Game.Rulesets.UI protected override Container Content => content; private Container content; + private IEnumerable mods; /// /// Whether to assume the beatmap passed into this is for the current ruleset. @@ -216,13 +217,10 @@ 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 - applyMods(Mods); } [BackgroundDependencyLoader] - private void load() + private void load(OsuConfigManager config) { KeyBindingInputManager.Add(content = new Container { @@ -235,6 +233,9 @@ namespace osu.Game.Rulesets.UI if (Cursor != null) KeyBindingInputManager.Add(Cursor); + // Apply mods + applyMods(Mods, config); + loadObjects(); } @@ -242,13 +243,16 @@ namespace osu.Game.Rulesets.UI /// 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>()) mod.ApplyToRulesetContainer(this); + + foreach (var mod in mods.OfType()) + mod.ReadFromConfig(config); } public override void SetReplay(Replay replay) diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index 58a66a5224..b35616985a 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -121,8 +121,6 @@ namespace osu.Game.Rulesets.UI /// private bool validState; - protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState; - private bool isAttached => replayInputHandler != null && !UseParentState; private const int max_catch_up_updates_per_frame = 50; diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index f212bfabf3..42e25aad43 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -8,7 +8,6 @@ using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -17,6 +16,7 @@ using osu.Framework.Input.Bindings; using osu.Framework.Threading; using osu.Game.Graphics; using osu.Game.Input.Bindings; +using osu.Game.Overlays; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -27,9 +27,6 @@ namespace osu.Game.Screens.Menu { public event Action StateChanged; - private readonly BindableBool hideOverlaysOnEnter = new BindableBool(); - private readonly BindableBool allowOpeningOverlays = new BindableBool(); - public Action OnEdit; public Action OnExit; public Action OnDirect; @@ -133,15 +130,12 @@ namespace osu.Game.Screens.Menu buttonFlow.AddRange(buttonsTopLevel); } + private OsuGame game; + [BackgroundDependencyLoader(true)] private void load(AudioManager audio, OsuGame game) { - if (game != null) - { - hideOverlaysOnEnter.BindTo(game.HideOverlaysOnEnter); - allowOpeningOverlays.BindTo(game.AllowOpeningOverlays); - } - + this.game = game; sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } @@ -328,18 +322,18 @@ namespace osu.Game.Screens.Menu case MenuState.Initial: logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => - { - logoTracking = false; + { + logoTracking = false; - hideOverlaysOnEnter.Value = true; - allowOpeningOverlays.Value = false; + if (game != null) + game.OverlayActivationMode.Value = state == MenuState.Exit ? OverlayActivation.Disabled : OverlayActivation.UserTriggered; - logo.ClearTransforms(targetMember: nameof(Position)); - logo.RelativePositionAxes = Axes.Both; + logo.ClearTransforms(targetMember: nameof(Position)); + logo.RelativePositionAxes = Axes.Both; - logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); - logo.ScaleTo(1, 800, Easing.OutExpo); - }, buttonArea.Alpha * 150); + logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); + logo.ScaleTo(1, 800, Easing.OutExpo); + }, buttonArea.Alpha * 150); break; case MenuState.TopLevel: case MenuState.Play: @@ -366,8 +360,11 @@ namespace osu.Game.Screens.Menu if (impact) logo.Impact(); - hideOverlaysOnEnter.Value = false; - allowOpeningOverlays.Value = true; + if (game != null) + { + game.OverlayActivationMode.Value = OverlayActivation.All; + game.Toolbar.State = Visibility.Visible; + } }, 200); break; default: diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index b8cb7f2a4a..0c70dbf570 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -9,6 +9,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Game.Overlays; namespace osu.Game.Screens.Menu { @@ -19,7 +20,7 @@ namespace osu.Game.Screens.Menu private Color4 iconColour; protected override bool HideOverlaysOnEnter => true; - protected override bool AllowOpeningOverlays => false; + protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; public override bool CursorVisible => false; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 5aca184d24..c5bd345a31 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -15,6 +15,7 @@ using osu.Game.IO.Archives; using osu.Game.Screens.Backgrounds; using OpenTK; using OpenTK.Graphics; +using osu.Game.Overlays; namespace osu.Game.Screens.Menu { @@ -32,7 +33,7 @@ namespace osu.Game.Screens.Menu private SampleChannel seeya; protected override bool HideOverlaysOnEnter => true; - protected override bool AllowOpeningOverlays => false; + protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; public override bool CursorVisible => false; diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index d5f3b11467..cbdd8b4e8b 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -25,7 +25,6 @@ namespace osu.Game.Screens.Menu private readonly ButtonSystem buttons; protected override bool HideOverlaysOnEnter => buttons.State == MenuState.Initial; - protected override bool AllowOpeningOverlays => buttons.State != MenuState.Initial; protected override bool AllowBackButton => buttons.State != MenuState.Initial; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 7f68e5144b..d98aac8f84 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -18,6 +18,8 @@ using osu.Game.Rulesets; using osu.Game.Screens.Menu; using OpenTK; using OpenTK.Input; +using osu.Game.Overlays; +using osu.Framework.Graphics.Containers; namespace osu.Game.Screens { @@ -40,19 +42,19 @@ namespace osu.Game.Screens /// protected virtual BackgroundScreen CreateBackground() => null; - private readonly BindableBool hideOverlaysOnEnter = new BindableBool(); + private Action updateOverlayStates; /// - /// Whether overlays should be hidden when this screen is entered or resumed. + /// Whether all overlays should be hidden when this screen is entered or resumed. /// protected virtual bool HideOverlaysOnEnter => false; - private readonly BindableBool allowOpeningOverlays = new BindableBool(); + protected readonly Bindable OverlayActivationMode = new Bindable(); /// - /// Whether overlays should be able to be opened while this screen is active. + /// Whether overlays should be able to be opened once this screen is entered or resumed. /// - protected virtual bool AllowOpeningOverlays => true; + protected virtual OverlayActivation InitialOverlayActivationMode => OverlayActivation.All; /// /// Whether this allows the cursor to be displayed. @@ -103,8 +105,15 @@ namespace osu.Game.Screens if (osuGame != null) { Ruleset.BindTo(osuGame.Ruleset); - hideOverlaysOnEnter.BindTo(osuGame.HideOverlaysOnEnter); - allowOpeningOverlays.BindTo(osuGame.AllowOpeningOverlays); + OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); + + updateOverlayStates = () => + { + if (HideOverlaysOnEnter) + osuGame.CloseAllOverlays(); + else + osuGame.Toolbar.State = Visibility.Visible; + }; } sampleExit = audio.Sample.Get(@"UI/screen-back"); @@ -240,8 +249,9 @@ namespace osu.Game.Screens if (backgroundParallaxContainer != null) backgroundParallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * BackgroundParallaxAmount; - hideOverlaysOnEnter.Value = HideOverlaysOnEnter; - allowOpeningOverlays.Value = AllowOpeningOverlays; + OverlayActivationMode.Value = InitialOverlayActivationMode; + + updateOverlayStates?.Invoke(); } private void onExitingLogo() diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c93e4b7b40..54f65e3991 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -21,6 +21,7 @@ using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; +using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; @@ -37,6 +38,8 @@ namespace osu.Game.Screens.Play protected override bool HideOverlaysOnEnter => true; + protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered; + public Action RestartRequested; public bool HasFailed { get; private set; } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index ca36f94eda..f1bd2b945f 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using System.Linq; @@ -120,14 +119,8 @@ namespace osu.Game.Screens.Select Margin = new MarginPadding { Top = spacing * 2 }, Children = new[] { - description = new MetadataSection("Description") - { - TextColour = Color4.White.Opacity(0.75f), - }, - source = new MetadataSection("Source") - { - TextColour = Color4.White.Opacity(0.75f), - }, + description = new MetadataSection("Description"), + source = new MetadataSection("Source"), tags = new MetadataSection("Tags"), }, }, @@ -164,10 +157,9 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader] - private void load(OsuColour colours, APIAccess api) + private void load(APIAccess api) { this.api = api; - tags.TextColour = colours.Yellow; } protected override void UpdateAfterChildren() @@ -364,7 +356,7 @@ namespace osu.Game.Screens.Select { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Colour = textFlow.Colour, + Colour = Color4.White.Opacity(0.75f), Text = text }, loaded => { @@ -375,12 +367,6 @@ namespace osu.Game.Screens.Select this.FadeIn(transition_duration); }); } - - public Color4 TextColour - { - get { return textFlow.Colour; } - set { textFlow.Colour = value; } - } } private class DimmedLoadingAnimation : VisibilityContainer diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index baab973ae5..19732107c7 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics; @@ -142,6 +143,8 @@ namespace osu.Game.Screens.Select.Leaderboards { flagBadgeContainer = new Container { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, Size = new Vector2(87f, 20f), Masking = true, Children = new Drawable[] @@ -155,14 +158,16 @@ namespace osu.Game.Screens.Select.Leaderboards }, new FillFlowContainer { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(10f, 0f), - Margin = new MarginPadding { Left = edge_margin, }, + Margin = new MarginPadding { Left = edge_margin }, Children = new Drawable[] { - maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString()), - accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy)), + maxCombo = new ScoreComponentLabel(FontAwesome.fa_link, Score.MaxCombo.ToString(), "Max Combo"), + accuracy = new ScoreComponentLabel(FontAwesome.fa_crosshairs, string.Format(Score.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", Score.Accuracy), "Accuracy"), }, }, }, @@ -305,37 +310,61 @@ namespace osu.Game.Screens.Select.Leaderboards } } - private class ScoreComponentLabel : Container + private class ScoreComponentLabel : Container, IHasTooltip { - public ScoreComponentLabel(FontAwesome icon, string value) - { - Anchor = Anchor.CentreLeft; - Origin = Anchor.CentreLeft; - Size = new Vector2(60f, 20f); - Padding = new MarginPadding { Top = 10f, }; + private const float icon_size = 20; - Children = new Drawable[] + private readonly string name; + private readonly FillFlowContainer content; + + public override bool Contains(Vector2 screenSpacePos) => content.Contains(screenSpacePos); + + public string TooltipText => name; + + public ScoreComponentLabel(FontAwesome icon, string value, string name) + { + this.name = name; + AutoSizeAxes = Axes.Y; + Width = 60; + + Child = content = new FillFlowContainer { - new SpriteIcon + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new Drawable[] { - Origin = Anchor.Centre, - Icon = FontAwesome.fa_square, - Colour = OsuColour.FromHex(@"3087ac"), - Rotation = 45, - Size = new Vector2(20), - Shadow = true, - }, - new SpriteIcon - { - Origin = Anchor.Centre, - Icon = icon, - Colour = OsuColour.FromHex(@"a4edff"), - Size = new Vector2(14), - }, - new GlowingSpriteText(value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa")) - { - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Left = 15, }, + new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Children = new[] + { + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(icon_size), + Rotation = 45, + Colour = OsuColour.FromHex(@"3087ac"), + Icon = FontAwesome.fa_square, + Shadow = true, + }, + new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(icon_size - 6), + Colour = OsuColour.FromHex(@"a4edff"), + Icon = icon, + }, + }, + }, + new GlowingSpriteText(value, @"Exo2.0-Bold", 17, Color4.White, OsuColour.FromHex(@"83ccfa")) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, }, }; } diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 2b677f1f42..fa441d8012 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.IO; -using System.Reflection; using osu.Framework.Testing; namespace osu.Game.Tests.Visual @@ -13,8 +11,6 @@ namespace osu.Game.Tests.Visual public class OsuTestCaseTestRunner : OsuGameBase, ITestCaseTestRunner { - protected override string MainResourceFile => File.Exists(base.MainResourceFile) ? base.MainResourceFile : Assembly.GetExecutingAssembly().Location; - private TestCaseTestRunner.TestRunner runner; protected override void LoadAsyncComplete() diff --git a/osu.Game/Utils/DebugUtils.cs b/osu.Game/Utils/DebugUtils.cs new file mode 100644 index 0000000000..191662c690 --- /dev/null +++ b/osu.Game/Utils/DebugUtils.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Utils +{ + public static class DebugUtils + { + public static bool IsDebug + { + get + { + // ReSharper disable once RedundantAssignment + bool isDebug = false; + // Debug.Assert conditions are only evaluated in debug mode + System.Diagnostics.Debug.Assert(isDebug = true); + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + return isDebug; + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index afb656a260..2300ba6a72 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -11,7 +11,6 @@ - @@ -19,6 +18,7 @@ + diff --git a/osu.TestProject.props b/osu.TestProject.props index afdf895eac..b51ca13ed5 100644 --- a/osu.TestProject.props +++ b/osu.TestProject.props @@ -7,7 +7,6 @@ - @@ -18,7 +17,7 @@ - + VisualTestRunner.cs diff --git a/osu.sln b/osu.sln index 3646679539..bf1b6d60e1 100644 --- a/osu.sln +++ b/osu.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.27004.2006 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game", "osu.Game\osu.Game.csproj", "{2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Framework", "osu-framework\osu.Framework\osu.Framework.csproj", "{C76BF5B3-985E-4D39-95FE-97C9C879B83A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Resources", "osu-resources\osu.Game.Resources\osu.Game.Resources.csproj", "{D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "osu.Game.Rulesets.Osu", "osu.Game.Rulesets.Osu\osu.Game.Rulesets.Osu.csproj", "{C92A607B-1FDD-4954-9F92-03FF547D9080}" @@ -39,10 +37,6 @@ Global {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A66DD92-ADB1-4994-89E2-C94E04ACDA0D}.Release|Any CPU.Build.0 = Release|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C76BF5B3-985E-4D39-95FE-97C9C879B83A}.Release|Any CPU.Build.0 = Release|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Debug|Any CPU.Build.0 = Debug|Any CPU {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58}.Release|Any CPU.ActiveCfg = Release|Any CPU From fa1106affe12f22341838fd91631bfa74c4d6038 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 21:57:53 +0900 Subject: [PATCH 231/253] Disable caches --- appveyor.yml | 5 ----- appveyor_deploy.yml | 2 -- 2 files changed, 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 69bc762f4c..ac6d6ebff8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,11 +2,6 @@ clone_depth: 1 version: '{branch}-{build}' image: Visual Studio 2017 configuration: Debug -cache: - - C:\ProgramData\chocolatey\bin -> appveyor.yml - - C:\ProgramData\chocolatey\lib -> appveyor.yml - - inspectcode -> appveyor.yml - - packages -> **\packages.config install: - cmd: git submodule update --init --recursive --depth=5 - cmd: choco install resharper-clt -y diff --git a/appveyor_deploy.yml b/appveyor_deploy.yml index 64ad927574..0247714cdf 100644 --- a/appveyor_deploy.yml +++ b/appveyor_deploy.yml @@ -2,8 +2,6 @@ clone_depth: 1 version: '{build}' skip_non_tags: true image: Visual Studio 2017 -cache: - - '%USERPROFILE%\.nuget\packages -> **\*.csproj' install: - git clone https://github.com/ppy/osu-deploy before_build: From a60c888ae5295a3596d869db5c613c94b39df2fb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Jun 2018 22:05:25 +0900 Subject: [PATCH 232/253] Add comment about reasoning for local context variable --- osu.Game/Database/DatabaseContextFactory.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Database/DatabaseContextFactory.cs b/osu.Game/Database/DatabaseContextFactory.cs index b5378b1311..5160239c38 100644 --- a/osu.Game/Database/DatabaseContextFactory.cs +++ b/osu.Game/Database/DatabaseContextFactory.cs @@ -63,6 +63,7 @@ namespace osu.Game.Database } else { + // we want to try-catch the retrieval of the context because it could throw an error (in CreateContext). context = threadContexts.Value; } } From f491a18d40800455fa22e7102671fc84b72d882a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 01:49:34 +0900 Subject: [PATCH 233/253] Fix notifications not showing at main osu! logo on menu --- osu.Game/Screens/Menu/ButtonSystem.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 42e25aad43..81abc4cd3d 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -326,7 +326,10 @@ namespace osu.Game.Screens.Menu logoTracking = false; if (game != null) - game.OverlayActivationMode.Value = state == MenuState.Exit ? OverlayActivation.Disabled : OverlayActivation.UserTriggered; + { + game.OverlayActivationMode.Value = state == MenuState.Exit ? OverlayActivation.Disabled : OverlayActivation.All; + game.Toolbar.Hide(); + } logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; From fdf212085266331f37ef8e215b6e7b2871357964 Mon Sep 17 00:00:00 2001 From: jai_ Date: Wed, 6 Jun 2018 18:08:43 +0100 Subject: [PATCH 234/253] Update notfication now points to new changelog page --- osu.Desktop/Overlays/VersionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index d061aa8423..26e80b3f48 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -118,7 +118,7 @@ namespace osu.Desktop.Overlays Icon = FontAwesome.fa_check_square; Activated = delegate { - Process.Start($"https://github.com/ppy/osu/releases/tag/v{version}"); + Process.Start($"https://osu.ppy.sh/home/changelog/{version}"); return true; }; } From dc10277d500b3a514d5566da32bde8a01d06464e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 11:16:26 +0900 Subject: [PATCH 235/253] Thicker bar lines and new design colour --- osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 2147c5a761..d0fc6aa3d6 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -5,6 +5,7 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; using osu.Game.Rulesets.Objects.Drawables; +using OpenTK.Graphics; namespace osu.Game.Rulesets.Mania.Objects.Drawables { @@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables : base(barLine) { RelativeSizeAxes = Axes.X; - Height = 1; + Height = 2f; AddInternal(new Box { @@ -36,6 +37,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.Both, + Colour = new Color4(255, 204, 33, 255), }); bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; From 81a3a8a1a4fb1b7eae217e3d97971adb09e4468b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 11:19:36 +0900 Subject: [PATCH 236/253] Add corner radius --- osu.Game.Rulesets.Mania/UI/Column.cs | 28 +++++++++++++++++------- osu.Game.Rulesets.Mania/UI/ManiaStage.cs | 10 ++++----- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 28cd1b6b39..bdc8107e2a 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -33,6 +33,7 @@ namespace osu.Game.Rulesets.Mania.UI public ManiaAction Action; private readonly Box background; + private readonly Box backgroundOverlay; private readonly Container hitTargetBar; private readonly Container keyIcon; @@ -42,22 +43,32 @@ namespace osu.Game.Rulesets.Mania.UI protected override Container Content => content; private readonly Container content; - private const float opacity_released = 0.1f; - private const float opacity_pressed = 0.25f; - public Column() : base(ScrollingDirection.Up) { RelativeSizeAxes = Axes.Y; Width = column_width; + Masking = true; + CornerRadius = 5; + InternalChildren = new Drawable[] { background = new Box { Name = "Background", RelativeSizeAxes = Axes.Both, - Alpha = opacity_released + Alpha = 0.3f + }, + backgroundOverlay = new Box + { + Name = "Background Gradient Overlay", + RelativeSizeAxes = Axes.Both, + // Height = 0.5f, (doesn't work) + // Anchor = Anchor.BottomLeft, + // Origin = Anchor.BottomLeft, + Blending = BlendingMode.Additive, + Alpha = 0 }, new Container { @@ -182,6 +193,7 @@ namespace osu.Game.Rulesets.Mania.UI accentColour = value; background.Colour = accentColour; + backgroundOverlay.Colour = ColourInfo.GradientVertical(accentColour.Opacity(0.3f), accentColour.Opacity(0)); hitTargetBar.EdgeEffect = new EdgeEffectParameters { @@ -223,8 +235,8 @@ namespace osu.Game.Rulesets.Mania.UI { if (action == Action) { - background.FadeTo(opacity_pressed, 50, Easing.OutQuint); - keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint); + backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint); + keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint); } return false; @@ -234,8 +246,8 @@ namespace osu.Game.Rulesets.Mania.UI { if (action == Action) { - background.FadeTo(opacity_released, 800, Easing.OutQuart); - keyIcon.ScaleTo(1f, 400, Easing.OutQuart); + backgroundOverlay.FadeTo(0, 250, Easing.OutQuint); + keyIcon.ScaleTo(1f, 125, Easing.OutQuint); } return false; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs index 605794c795..cb93613c7d 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs @@ -9,7 +9,6 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; @@ -78,6 +77,7 @@ namespace osu.Game.Rulesets.Mania.UI RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Masking = true, + CornerRadius = 5, Children = new Drawable[] { new Box @@ -183,15 +183,15 @@ namespace osu.Game.Rulesets.Mania.UI } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { normalColumnColours = new List { - colours.RedDark, - colours.GreenDark + new Color4(94, 0, 57, 255), + new Color4(6, 84, 0, 255) }; - specialColumnColour = colours.BlueDark; + specialColumnColour = new Color4(0, 48, 63, 255); // Set the special column + colour + key foreach (var column in Columns) From d516a0a05c22c4511c331eb89d7c230f5ec41c68 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 7 Jun 2018 13:42:31 +0900 Subject: [PATCH 237/253] Store platform offset clock in variable for visibility --- osu.Game/Screens/Play/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 879bc7a707..9832c430be 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -149,10 +149,10 @@ namespace osu.Game.Screens.Play // Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited. // This only seems to be required on windows. We need to eventually figure out why, with a bit of luck. - var offsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0 }; + var platformOffsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0 }; // the final usable gameplay clock with user-set offsets applied. - offsetClock = new FramedOffsetClock(offsetClock); + var offsetClock = new FramedOffsetClock(platformOffsetClock); userAudioOffset.ValueChanged += v => offsetClock.Offset = v; userAudioOffset.TriggerChange(); From 56ea1c1d6325a533cbeda6c2dfdbaf97abf9c8ad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 12:20:35 +0900 Subject: [PATCH 238/253] Adjust hold note visibility and glow composition --- .../Objects/Drawables/DrawableHoldNote.cs | 23 ++----------------- .../Objects/Drawables/DrawableNote.cs | 23 ++++++++++--------- .../Objects/Drawables/Pieces/BodyPiece.cs | 4 ++-- 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index f7de503fb3..104425a3ac 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -23,7 +23,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly DrawableNote head; private readonly DrawableNote tail; - private readonly GlowPiece glowPiece; private readonly BodyPiece bodyPiece; private readonly Container fullHeightContainer; @@ -45,17 +44,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables InternalChildren = new Drawable[] { - // The hit object itself cannot be used for various elements because the tail overshoots it - // So a specialized container that is updated to contain the tail height is used - fullHeightContainer = new Container - { - RelativeSizeAxes = Axes.X, - Child = glowPiece = new GlowPiece() - }, bodyPiece = new BodyPiece { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.X, }, tickContainer = new Container @@ -92,7 +82,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { base.AccentColour = value; - glowPiece.AccentColour = value; bodyPiece.AccentColour = value; head.AccentColour = value; tail.AccentColour = value; @@ -121,12 +110,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables base.Update(); // Make the body piece not lie under the head note - bodyPiece.Y = head.Height; - bodyPiece.Height = DrawHeight - head.Height; - - // Make the fullHeightContainer "contain" the height of the tail note, keeping in mind - // that the tail note overshoots the height of this hit object - fullHeightContainer.Height = DrawHeight + tail.Height; + bodyPiece.Y = head.Height / 2; + bodyPiece.Height = DrawHeight - head.Height / 2 + tail.Height / 2; } public bool OnPressed(ManiaAction action) @@ -175,8 +160,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables : base(holdNote.HitObject.Head, action) { this.holdNote = holdNote; - - GlowPiece.Alpha = 0; } public override bool OnPressed(ManiaAction action) @@ -219,8 +202,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables : base(holdNote.HitObject.Tail, action) { this.holdNote = holdNote; - - GlowPiece.Alpha = 0; } protected override void CheckForJudgements(bool userTriggered, double timeOffset) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 0340e6bba3..856fc97a87 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -1,8 +1,10 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Extensions.Color4Extensions; using OpenTK.Graphics; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; @@ -16,9 +18,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableNote : DrawableManiaHitObject, IKeyBindingHandler { - protected readonly GlowPiece GlowPiece; - - private readonly LaneGlowPiece laneGlowPiece; private readonly NotePiece headPiece; public DrawableNote(Note hitObject, ManiaAction action) @@ -27,14 +26,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + CornerRadius = 5; + Masking = true; + InternalChildren = new Drawable[] { - laneGlowPiece = new LaneGlowPiece - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre - }, - GlowPiece = new GlowPiece(), headPiece = new NotePiece { Anchor = Anchor.TopCentre, @@ -49,9 +45,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables set { base.AccentColour = value; - laneGlowPiece.AccentColour = AccentColour; - GlowPiece.AccentColour = AccentColour; headPiece.AccentColour = AccentColour; + + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Glow, + Colour = AccentColour.Lighten(1f).Opacity(0.6f), + Radius = 10, + }; } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index 17644a78a5..d18cb57421 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -123,8 +123,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces if (!IsLoaded) return; - foreground.Colour = AccentColour.Opacity(0.4f); - background.Colour = AccentColour.Opacity(0.2f); + foreground.Colour = AccentColour.Opacity(0.8f); + background.Colour = AccentColour.Opacity(0.5f); subtractionCache.Invalidate(); } From dff4b360b7f1145140f15e59f4e8fabcf0578e1b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 14:27:39 +0900 Subject: [PATCH 239/253] Fix ticks not getting accent colour --- .../Objects/Drawables/DrawableHoldNote.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 104425a3ac..adf84ceb7c 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -36,10 +36,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// private bool hasBroken; + private readonly Container tickContainer; + public DrawableHoldNote(HoldNote hitObject, ManiaAction action) : base(hitObject, action) { - Container tickContainer; RelativeSizeAxes = Axes.X; InternalChildren = new Drawable[] @@ -85,17 +86,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables bodyPiece.AccentColour = value; head.AccentColour = value; tail.AccentColour = value; - } - } - - protected override void UpdateState(ArmedState state) - { - switch (state) - { - case ArmedState.Hit: - // Good enough for now, we just want them to have a lifetime end - this.Delay(2000).Expire(); - break; + tickContainer.ForEach(t=>t.AccentColour=value); } } From f9449e841a0daa727e8d1520033909c99f37da19 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 14:27:59 +0900 Subject: [PATCH 240/253] Improve overall visual clarity and explosion effects --- .../Objects/Drawables/DrawableHoldNote.cs | 13 +----- .../Objects/Drawables/DrawableHoldNoteTick.cs | 10 ----- .../Drawables/DrawableManiaHitObject.cs | 13 ++++++ .../Objects/Drawables/DrawableNote.cs | 12 ------ .../Objects/Drawables/Pieces/BodyPiece.cs | 4 +- .../Objects/Drawables/Pieces/NotePiece.cs | 4 +- osu.Game.Rulesets.Mania/UI/Column.cs | 8 ++-- osu.Game.Rulesets.Mania/UI/HitExplosion.cs | 42 ++++++++++--------- 8 files changed, 44 insertions(+), 62 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index adf84ceb7c..04c03c1247 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Linq; -using osu.Game.Rulesets.Objects.Drawables; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; @@ -24,7 +24,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly DrawableNote tail; private readonly BodyPiece bodyPiece; - private readonly Container fullHeightContainer; /// /// Time at which the user started holding this hold note. Null if the user is not holding this hold note. @@ -168,11 +167,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return true; } - - protected override void UpdateState(ArmedState state) - { - // The holdnote keeps scrolling through for now, so having the head disappear looks weird - } } /// @@ -225,11 +219,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables }); } - protected override void UpdateState(ArmedState state) - { - // The holdnote keeps scrolling through, so having the tail disappear looks weird - } - public override bool OnPressed(ManiaAction action) => false; // Tail doesn't handle key down public override bool OnReleased(ManiaAction action) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 74c17ad0fb..d84024fa15 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -87,16 +87,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect }); } - protected override void UpdateState(ArmedState state) - { - switch (State.Value) - { - case ArmedState.Hit: - AccentColour = Color4.Green; - break; - } - } - protected override void Update() { if (AllJudged) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index db1fec40de..fbf1ee8460 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -27,5 +27,18 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (action != null) Action = action.Value; } + + protected override void UpdateState(ArmedState state) + { + switch (state) + { + case ArmedState.Miss: + this.FadeOut(150, Easing.In).Expire(); + break; + case ArmedState.Hit: + this.FadeOut(150, Easing.OutQuint).Expire(); + break; + } + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 856fc97a87..3de0a9c5cc 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Mania.Objects.Drawables @@ -72,17 +71,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables AddJudgement(new ManiaJudgement { Result = result }); } - protected override void UpdateState(ArmedState state) - { - switch (state) - { - case ArmedState.Hit: - case ArmedState.Miss: - this.FadeOut(100).Expire(); - break; - } - } - public virtual bool OnPressed(ManiaAction action) { if (action != Action) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index d18cb57421..4ab2da208a 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -123,8 +123,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces if (!IsLoaded) return; - foreground.Colour = AccentColour.Opacity(0.8f); - background.Colour = AccentColour.Opacity(0.5f); + foreground.Colour = AccentColour.Opacity(0.9f); + background.Colour = AccentColour.Opacity(0.6f); subtractionCache.Invalidate(); } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index e23b24508b..9ebeb91e0c 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces /// internal class NotePiece : Container, IHasAccentColour { - private const float head_height = 10; + public const float NOTE_HEIGHT = 10; private const float head_colour_height = 6; private readonly Box colouredBox; @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public NotePiece() { RelativeSizeAxes = Axes.X; - Height = head_height; + Height = NOTE_HEIGHT; Children = new[] { diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index bdc8107e2a..dee113c82f 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -64,9 +64,9 @@ namespace osu.Game.Rulesets.Mania.UI { Name = "Background Gradient Overlay", RelativeSizeAxes = Axes.Both, - // Height = 0.5f, (doesn't work) - // Anchor = Anchor.BottomLeft, - // Origin = Anchor.BottomLeft, + Height = 0.5f, + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, Blending = BlendingMode.Additive, Alpha = 0 }, @@ -193,7 +193,7 @@ namespace osu.Game.Rulesets.Mania.UI accentColour = value; background.Colour = accentColour; - backgroundOverlay.Colour = ColourInfo.GradientVertical(accentColour.Opacity(0.3f), accentColour.Opacity(0)); + backgroundOverlay.Colour = ColourInfo.GradientVertical(accentColour.Opacity(0.6f), accentColour.Opacity(0)); hitTargetBar.EdgeEffect = new EdgeEffectParameters { diff --git a/osu.Game.Rulesets.Mania/UI/HitExplosion.cs b/osu.Game.Rulesets.Mania/UI/HitExplosion.cs index f01dfc0db1..7d94d9113e 100644 --- a/osu.Game.Rulesets.Mania/UI/HitExplosion.cs +++ b/osu.Game.Rulesets.Mania/UI/HitExplosion.cs @@ -1,19 +1,22 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; +using osu.Framework.Extensions.Color4Extensions; using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.MathUtils; using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Objects.Drawables; +using OpenTK; namespace osu.Game.Rulesets.Mania.UI { internal class HitExplosion : CompositeDrawable { - private readonly Box inner; + private readonly CircularContainer circle; public HitExplosion(DrawableHitObject judgedObject) { @@ -22,33 +25,32 @@ namespace osu.Game.Rulesets.Mania.UI Anchor = Anchor.TopCentre; Origin = Anchor.Centre; - RelativeSizeAxes = Axes.Both; - Size = new Vector2(isTick ? 0.5f : 1); - FillMode = FillMode.Fit; + RelativeSizeAxes = Axes.X; + Y = NotePiece.NOTE_HEIGHT / 2; + Height = NotePiece.NOTE_HEIGHT; - Blending = BlendingMode.Additive; + // scale roughly in-line with visual appearance of notes + Scale = new Vector2(isTick ? 0.4f : 0.8f); - Color4 accent = isTick ? Color4.White : judgedObject.AccentColour; - - InternalChild = new CircularContainer + InternalChild = circle = new CircularContainer { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Masking = true, - BorderThickness = 1, - BorderColour = accent, + // we want our size to be very small so the glow dominates it. + Size = new Vector2(0.1f), EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Glow, - Colour = accent, - Radius = 10, - Hollow = true + Colour = Interpolation.ValueAt(0.1f, judgedObject.AccentColour, Color4.White, 0, 1), + Radius = 100, }, - Child = inner = new Box + Child = new Box { + Alpha = 0, RelativeSizeAxes = Axes.Both, - Colour = accent, - Alpha = 1, - AlwaysPresent = true, + AlwaysPresent = true } }; } @@ -57,8 +59,8 @@ namespace osu.Game.Rulesets.Mania.UI { base.LoadComplete(); - this.ScaleTo(2f, 600, Easing.OutQuint).FadeOut(500); - inner.FadeOut(250); + circle.ResizeTo(circle.Size * new Vector2(4, 20), 1000, Easing.OutQuint); + this.FadeIn(16).Then().FadeOut(500, Easing.OutQuint); Expire(true); } From e73442c8622679aeff7efe8639e788f09922829a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 15:02:54 +0900 Subject: [PATCH 241/253] Remove net471 build configurations This doesn't actually remove the targets just yet (that will require a bit more work), but rather remove the target options from our IDE configurations to reduce accidental usage of net471/mono. --- .../RulesetTests__catch_.xml | 10 +-- .../RulesetTests__mania_.xml | 10 +-- .../runConfigurations/RulesetTests__osu__.xml | 10 +-- .../RulesetTests__taiko_.xml | 10 +-- .../VisualTests__net471_.xml | 18 ----- .../.idea/runConfigurations/osu___net471_.xml | 18 ----- .vscode/launch.json | 72 +++---------------- .vscode/tasks.json | 44 ++---------- 8 files changed, 24 insertions(+), 168 deletions(-) delete mode 100644 .idea/.idea.osu/.idea/runConfigurations/VisualTests__net471_.xml delete mode 100644 .idea/.idea.osu/.idea/runConfigurations/osu___net471_.xml diff --git a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__catch_.xml b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__catch_.xml index be69e92748..1c988fe6fd 100644 --- a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__catch_.xml +++ b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__catch_.xml @@ -1,21 +1,17 @@ - diff --git a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__mania_.xml b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__mania_.xml index da968b54b7..d7bb0f90f1 100644 --- a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__mania_.xml +++ b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__mania_.xml @@ -1,21 +1,17 @@ - diff --git a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__osu__.xml b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__osu__.xml index f2b8155e37..997ac6b078 100644 --- a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__osu__.xml +++ b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__osu__.xml @@ -1,21 +1,17 @@ - diff --git a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__taiko_.xml b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__taiko_.xml index 941455f8b4..b7a070174c 100644 --- a/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__taiko_.xml +++ b/.idea/.idea.osu/.idea/runConfigurations/RulesetTests__taiko_.xml @@ -1,21 +1,17 @@ - diff --git a/.idea/.idea.osu/.idea/runConfigurations/VisualTests__net471_.xml b/.idea/.idea.osu/.idea/runConfigurations/VisualTests__net471_.xml deleted file mode 100644 index 20a15f985f..0000000000 --- a/.idea/.idea.osu/.idea/runConfigurations/VisualTests__net471_.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.osu/.idea/runConfigurations/osu___net471_.xml b/.idea/.idea.osu/.idea/runConfigurations/osu___net471_.xml deleted file mode 100644 index 7196e486d2..0000000000 --- a/.idea/.idea.osu/.idea/runConfigurations/osu___net471_.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index b9bb75d5bb..ed67fa92cc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,63 +2,7 @@ "version": "0.2.0", "configurations": [ { - "name": "VisualTests (Debug, net471)", - "windows": { - "type": "clr" - }, - "type": "mono", - "request": "launch", - "program": "${workspaceRoot}/osu.Game.Tests/bin/Debug/net471/osu.Game.Tests.exe", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Debug, msbuild)", - "runtimeExecutable": null, - "env": {}, - "console": "internalConsole" - }, - { - "name": "VisualTests (Release, net471)", - "windows": { - "type": "clr" - }, - "type": "mono", - "request": "launch", - "program": "${workspaceRoot}/osu.Game.Tests/bin/Release/net471/osu.Game.Tests.exe", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Release, msbuild)", - "runtimeExecutable": null, - "env": {}, - "console": "internalConsole" - }, - { - "name": "osu! (Debug, net471)", - "windows": { - "type": "clr" - }, - "type": "mono", - "request": "launch", - "program": "${workspaceRoot}/osu.Desktop/bin/Debug/net471/osu!.exe", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Debug, msbuild)", - "runtimeExecutable": null, - "env": {}, - "console": "internalConsole" - }, - { - "name": "osu! (Release, net471)", - "windows": { - "type": "clr" - }, - "type": "mono", - "request": "launch", - "program": "${workspaceRoot}/osu.Desktop/bin/Release/net471/osu!.exe", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Release, msbuild)", - "runtimeExecutable": null, - "env": {}, - "console": "internalConsole" - }, - { - "name": "VisualTests (Debug, netcoreapp2.1)", + "name": "VisualTests (Debug)", "type": "coreclr", "request": "launch", "program": "dotnet", @@ -66,12 +10,12 @@ "${workspaceRoot}/osu.Game.Tests/bin/Debug/netcoreapp2.1/osu.Game.Tests.dll" ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build tests (Debug, dotnet)", + "preLaunchTask": "Build tests (Debug)", "env": {}, "console": "internalConsole" }, { - "name": "VisualTests (Release, netcoreapp2.1)", + "name": "VisualTests (Release)", "type": "coreclr", "request": "launch", "program": "dotnet", @@ -79,12 +23,12 @@ "${workspaceRoot}/osu.Game.Tests/bin/Release/netcoreapp2.1/osu.Game.Tests.dll" ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build tests (Release, dotnet)", + "preLaunchTask": "Build tests (Release)", "env": {}, "console": "internalConsole" }, { - "name": "osu! (Debug, netcoreapp2.1)", + "name": "osu! (Debug)", "type": "coreclr", "request": "launch", "program": "dotnet", @@ -92,12 +36,12 @@ "${workspaceRoot}/osu.Desktop/bin/Debug/netcoreapp2.1/osu!.dll", ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build osu! (Debug, dotnet)", + "preLaunchTask": "Build osu! (Debug)", "env": {}, "console": "internalConsole" }, { - "name": "osu! (Release, netcoreapp2.1)", + "name": "osu! (Release)", "type": "coreclr", "request": "launch", "program": "dotnet", @@ -105,7 +49,7 @@ "${workspaceRoot}/osu.Desktop/bin/Release/netcoreapp2.1/osu!.dll", ], "cwd": "${workspaceRoot}", - "preLaunchTask": "Build osu! (Release, dotnet)", + "preLaunchTask": "Build osu! (Release)", "env": {}, "console": "internalConsole" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index bebad750ca..188f20b69f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,34 +4,7 @@ "version": "2.0.0", "tasks": [ { - "label": "Build (Debug, msbuild)", - "type": "shell", - "command": "msbuild", - "args": [ - "/p:TargetFramework=net471", - "/p:GenerateFullPaths=true", - "/m", - "/verbosity:m" - ], - "group": "build", - "problemMatcher": "$msCompile" - }, - { - "label": "Build (Release, msbuild)", - "type": "shell", - "command": "msbuild", - "args": [ - "/p:Configuration=Release", - "/p:TargetFramework=net471", - "/p:GenerateFullPaths=true", - "/m", - "/verbosity:m" - ], - "group": "build", - "problemMatcher": "$msCompile" - }, - { - "label": "Build osu! (Debug, dotnet)", + "label": "Build osu! (Debug)", "type": "shell", "command": "dotnet", "args": [ @@ -47,7 +20,7 @@ "problemMatcher": "$msCompile" }, { - "label": "Build osu! (Release, dotnet)", + "label": "Build osu! (Release)", "type": "shell", "command": "dotnet", "args": [ @@ -64,7 +37,7 @@ "problemMatcher": "$msCompile" }, { - "label": "Build tests (Debug, dotnet)", + "label": "Build tests (Debug)", "type": "shell", "command": "dotnet", "args": [ @@ -80,7 +53,7 @@ "problemMatcher": "$msCompile" }, { - "label": "Build tests (Release, dotnet)", + "label": "Build tests (Release)", "type": "shell", "command": "dotnet", "args": [ @@ -96,15 +69,6 @@ "group": "build", "problemMatcher": "$msCompile" }, - { - "label": "Restore (net471)", - "type": "shell", - "command": "nuget", - "args": [ - "restore" - ], - "problemMatcher": [] - }, { "label": "Restore (netcoreapp2.1)", "type": "shell", From 8d0161c2fc60b263f20e3dc3bbf3244449b35f95 Mon Sep 17 00:00:00 2001 From: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com> Date: Thu, 7 Jun 2018 15:07:15 +0900 Subject: [PATCH 242/253] Refactoring --- osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs | 2 +- .../Objects/Drawables/DrawableHoldNoteTick.cs | 1 - osu.Game.Rulesets.Mania/UI/HitExplosion.cs | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 04c03c1247..e008fa952e 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables bodyPiece.AccentColour = value; head.AccentColour = value; tail.AccentColour = value; - tickContainer.ForEach(t=>t.AccentColour=value); + tickContainer.ForEach(t => t.AccentColour = value); } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index d84024fa15..5df6079efa 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -8,7 +8,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Mania.Judgements; -using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Graphics.Shapes; using osu.Game.Rulesets.Scoring; diff --git a/osu.Game.Rulesets.Mania/UI/HitExplosion.cs b/osu.Game.Rulesets.Mania/UI/HitExplosion.cs index 7d94d9113e..f19c3a811b 100644 --- a/osu.Game.Rulesets.Mania/UI/HitExplosion.cs +++ b/osu.Game.Rulesets.Mania/UI/HitExplosion.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.Extensions.Color4Extensions; using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From 475fb065591e031300728cbc98dd8522083d9105 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Jun 2018 16:46:54 +0900 Subject: [PATCH 243/253] Use new bind method --- osu.Game/Overlays/MusicController.cs | 7 ++----- .../Screens/Compose/Timeline/ScrollingTimelineContainer.cs | 4 +--- osu.Game/Screens/Select/SongSelect.cs | 6 ++---- osu.Game/Tests/Visual/EditorClockTestCase.cs | 3 +-- osu.Game/osu.Game.csproj | 2 +- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 18e5379224..d96bb40165 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -237,11 +237,8 @@ namespace osu.Game.Overlays protected override void LoadComplete() { - beatmap.ValueChanged += beatmapChanged; - beatmap.DisabledChanged += beatmapDisabledChanged; - - beatmapChanged(beatmap.Value); - + beatmap.BindValueChanged(beatmapChanged, true); + beatmap.BindDisabledChanged(beatmapDisabledChanged, true); base.LoadComplete(); } diff --git a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs index dfc6b41432..cc51ae1096 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Timeline/ScrollingTimelineContainer.cs @@ -47,9 +47,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline private void load(IBindableBeatmap beatmap) { this.beatmap.BindTo(beatmap); - - beatmap.ValueChanged += beatmapChanged; - beatmapChanged(beatmap.Value); + this.beatmap.BindValueChanged(beatmapChanged, true); } private void beatmapChanged(WorkingBeatmap beatmap) => waveform.Beatmap = beatmap; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index b04ffecf48..70b473bcd9 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -207,10 +207,8 @@ namespace osu.Game.Screens.Select Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSetsEnumerable(); - Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled; - Beatmap.ValueChanged += workingBeatmapChanged; - - workingBeatmapChanged(Beatmap.Value); + Beatmap.BindDisabledChanged(disabled => Carousel.AllowSelection = !disabled, true); + Beatmap.BindValueChanged(workingBeatmapChanged); } public void Edit(BeatmapInfo beatmap) diff --git a/osu.Game/Tests/Visual/EditorClockTestCase.cs b/osu.Game/Tests/Visual/EditorClockTestCase.cs index 0363fa75ba..08dc6a3bbd 100644 --- a/osu.Game/Tests/Visual/EditorClockTestCase.cs +++ b/osu.Game/Tests/Visual/EditorClockTestCase.cs @@ -32,8 +32,7 @@ namespace osu.Game.Tests.Visual Dependencies.CacheAs(Clock); Dependencies.CacheAs(Clock); - Beatmap.ValueChanged += beatmapChanged; - beatmapChanged(Beatmap.Value); + Beatmap.BindValueChanged(beatmapChanged, true); } private void beatmapChanged(WorkingBeatmap working) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2300ba6a72..1e97fb6a68 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - + From b3cab35a2c1c5831d38c7688dfc8c2441e084a0c Mon Sep 17 00:00:00 2001 From: rootyElf Date: Thu, 7 Jun 2018 15:46:31 +0100 Subject: [PATCH 244/253] Update EntityFramework libraries Updated Microsoft.EntityFrameworkCore.Sqlite and Microsoft.EntityFrameworkCore.Sqlite.Core to 2.1.0 to enable the app to run on arm linux platforms. This also updates SQLitePCLRaw.lib.e_sqlite3.linux from 1.1.7 to 1.1.11. While 1.1.7 only provides native libraries for linux-x64 and linux-x86, 1.1.11 adds alpine-x64, linux-arm, linux-arm64, linux-armel and linux-musl-x64. --- osu.Game/osu.Game.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1e97fb6a68..363fc7d7bb 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -15,12 +15,12 @@ - - + + - + - \ No newline at end of file + From 95bc3127995a1d89e06680baa9ff6d6e72923b61 Mon Sep 17 00:00:00 2001 From: rootyElf Date: Thu, 7 Jun 2018 15:48:06 +0100 Subject: [PATCH 245/253] Update EntityFramework libraries --- osu.Desktop/osu.Desktop.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 766f36fa74..0d4efc7eed 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -29,10 +29,10 @@ - + - \ No newline at end of file + From 8aaaa42c5036ac33d5de157ae256cb55b15277ba Mon Sep 17 00:00:00 2001 From: rootyElf Date: Thu, 7 Jun 2018 15:51:09 +0100 Subject: [PATCH 246/253] Update EntityFramework libraries --- osu.TestProject.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.TestProject.props b/osu.TestProject.props index b51ca13ed5..cf8276eee1 100644 --- a/osu.TestProject.props +++ b/osu.TestProject.props @@ -11,7 +11,7 @@ - + @@ -25,4 +25,4 @@ false - \ No newline at end of file + From 0fae49ee21d28a24d9585f4e2cec830385463b4a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 7 Jun 2018 20:47:27 -0300 Subject: [PATCH 247/253] Don't add a 'with Video' subtitle. --- osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs index 37fa562a73..4fce6a49fb 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs @@ -17,11 +17,6 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { Width = 120; - string subtitle = string.Empty; - - if (set.OnlineInfo.HasVideo) - subtitle = noVideo ? "without Video" : "with Video"; - BeatmapSetDownloader downloader; Add(new Container { @@ -47,7 +42,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, new OsuSpriteText { - Text = subtitle, + Text = set.OnlineInfo.HasVideo && noVideo ? "without Video" : string.Empty, TextSize = 11, Font = @"Exo2.0-Bold", }, From 59e5a8556f91b3a47a3d8088c1041331a3c243df Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Jun 2018 18:15:03 +0900 Subject: [PATCH 248/253] Fix volume control adjustment being extreme when precision scrolling --- osu.Game/Overlays/Volume/VolumeMeter.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 64106967f4..b2cf43704b 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -167,9 +167,25 @@ namespace osu.Game.Overlays.Volume private set => Bindable.Value = value; } - public void Increase() => Volume += 0.05f; + private const float adjust_step = 0.05f; - public void Decrease() => Volume -= 0.05f; + public void Increase() => adjust(1); + public void Decrease() => adjust(-1); + + private void adjust(int direction) + { + float amount = adjust_step * direction; + + var mouse = GetContainingInputManager().CurrentState.Mouse; + if (mouse.HasPreciseScroll) + { + float scrollDelta = mouse.ScrollDelta.Y; + if (scrollDelta != 0) + amount *= Math.Abs(scrollDelta / 10); + } + + Volume += amount; + } public bool OnPressed(GlobalAction action) { From 064e8190beebe798760b9fbb2de999fe1a8e8537 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Jun 2018 20:53:58 +0900 Subject: [PATCH 249/253] Add basic documentation --- osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs index df4847b5db..63c5c8b6e6 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs @@ -8,6 +8,9 @@ using osu.Framework.Graphics; namespace osu.Game.Beatmaps.Drawables { + /// + /// A component to allow downloading of a beatmap set. Automatically handles state syncing between other instances. + /// public class BeatmapSetDownloader : Component { private readonly BeatmapSetInfo set; @@ -15,6 +18,9 @@ namespace osu.Game.Beatmaps.Drawables private BeatmapManager beatmaps; + /// + /// Whether the associated beatmap set has been downloading (by this instance or any other instance). + /// public readonly BindableBool Downloaded = new BindableBool(); public BeatmapSetDownloader(BeatmapSetInfo set, bool noVideo = false) @@ -47,6 +53,10 @@ namespace osu.Game.Beatmaps.Drawables } } + /// + /// Begin downloading the associated beatmap set. + /// + /// True if downloading began. False if an existing download is active or completed. public bool Download() { if (Downloaded.Value) From ecc0f5e5756a6401be39c3f4ea96df270c089087 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Jun 2018 20:54:09 +0900 Subject: [PATCH 250/253] Use Any() instead of Count() --- osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs index 63c5c8b6e6..6acb58e165 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs @@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps.Drawables // initial value if (set.OnlineBeatmapSetID != null) - Downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Count() != 0; + Downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Any(); } protected override void Dispose(bool isDisposing) From 9bdb3113ce0883afd6c1be0aa7f84153af381de3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Jun 2018 21:05:28 +0900 Subject: [PATCH 251/253] Revert "Always update children when ruleset input manager is updated" This reverts commit 4eb7a349442680ace0fb534b4f8bf5a03903c1b0. --- osu.Game/Rulesets/UI/RulesetInputManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index b35616985a..58a66a5224 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -121,6 +121,8 @@ namespace osu.Game.Rulesets.UI /// private bool validState; + protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState; + private bool isAttached => replayInputHandler != null && !UseParentState; private const int max_catch_up_updates_per_frame = 50; From a880e626d87bd3f7344b7b1b6609526e18033688 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Jun 2018 21:20:15 +0900 Subject: [PATCH 252/253] Use for loop and SetLayoutPosition --- osu.Game/Overlays/Profile/Header/BadgeContainer.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs index c97a4de464..f968f94187 100644 --- a/osu.Game/Overlays/Profile/Header/BadgeContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BadgeContainer.cs @@ -107,16 +107,19 @@ namespace osu.Game.Overlays.Profile.Header visibleBadge = 0; badgeFlowContainer.Clear(); - foreach (var badge in badges) + for (var index = 0; index < badges.Length; index++) { - LoadComponentAsync(new DrawableBadge(badge) + int displayIndex = index; + LoadComponentAsync(new DrawableBadge(badges[index]) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, asyncBadge => { badgeFlowContainer.Add(asyncBadge); - badgeFlowContainer.ChangeChildDepth(asyncBadge, Array.IndexOf(badges, asyncBadge)); //Ensure the badges are ordered correctly + + // load in stable order regardless of async load order. + badgeFlowContainer.SetLayoutPosition(asyncBadge, displayIndex); }); } } From fd4f61fc88da37317e060f4d810da0c2b713008b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Jun 2018 21:51:43 +0900 Subject: [PATCH 253/253] Update framework and other packages --- osu.Desktop/osu.Desktop.csproj | 4 ++-- osu.Game/osu.Game.csproj | 6 +++--- osu.TestProject.props | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 0d4efc7eed..3cf95e9b3e 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -26,7 +26,7 @@ - + @@ -35,4 +35,4 @@ - + \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 363fc7d7bb..e35b6dbe1b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -17,10 +17,10 @@ - - + + - + \ No newline at end of file diff --git a/osu.TestProject.props b/osu.TestProject.props index cf8276eee1..8f7128f8b7 100644 --- a/osu.TestProject.props +++ b/osu.TestProject.props @@ -13,7 +13,7 @@ - +