From f6e0e0bc38197ba9086b0e44a89e9da7f015dd42 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 3 Jun 2017 19:21:21 +0200 Subject: [PATCH 001/107] add caps lock warning --- .../UserInterface/OsuPasswordTextBox.cs | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs index 904aa14aa7..8ad3febf19 100644 --- a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs @@ -1,11 +1,14 @@ // Copyright (c) 2007-2017 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.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Sprites; +using System; namespace osu.Game.Graphics.UserInterface { @@ -15,6 +18,14 @@ namespace osu.Game.Graphics.UserInterface public override bool AllowClipboardExport => false; + public OsuPasswordTextBox() + { + Add(new CapsWarning + { + TextSize = 20, + }); + } + public class PasswordMaskChar : Container { private readonly CircularContainer circle; @@ -51,5 +62,36 @@ namespace osu.Game.Graphics.UserInterface circle.ResizeTo(new Vector2(0.8f), 500, EasingTypes.OutQuint); } } + + private class CapsWarning : TextAwesome, IHasTooltip + { + public string TooltipText => Console.CapsLock ? @"Caps lock is active" : string.Empty; + + public override bool HandleInput => true; + + public CapsWarning() + { + Icon = FontAwesome.fa_warning; + Origin = Anchor.CentreRight; + Anchor = Anchor.CentreRight; + Margin = new MarginPadding { Right = 10 }; + AlwaysPresent = true; + Alpha = 0; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + Colour = colour.YellowLight; + } + + protected override void Update() + { + base.Update(); + updateVisibility(); + } + + private void updateVisibility() => FadeTo(Console.CapsLock ? 1 : 0, 250, EasingTypes.OutQuint); + } } } From c29d3437ba7e4f14f7e218a4effb5232be419c41 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 22 Aug 2017 13:35:30 +0200 Subject: [PATCH 002/107] fix merge changes --- osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs index 70879006e9..3b0a1bda99 100644 --- a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs @@ -22,7 +22,7 @@ namespace osu.Game.Graphics.UserInterface { Add(new CapsWarning { - TextSize = 20, + Size = new Vector2(20), }); } @@ -63,7 +63,7 @@ namespace osu.Game.Graphics.UserInterface } } - private class CapsWarning : TextAwesome, IHasTooltip + private class CapsWarning : SpriteIcon, IHasTooltip { public string TooltipText => Console.CapsLock ? @"Caps lock is active" : string.Empty; @@ -91,7 +91,7 @@ namespace osu.Game.Graphics.UserInterface updateVisibility(); } - private void updateVisibility() => FadeTo(Console.CapsLock ? 1 : 0, 250, EasingTypes.OutQuint); + private void updateVisibility() => this.FadeTo(Console.CapsLock ? 1 : 0, 250, Easing.OutQuint); } } } From d81956e9741b7dbfdfae35d514e1a1eba002fe5e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 22 Aug 2017 15:43:45 +0200 Subject: [PATCH 003/107] use GameHost to check if caps lock is enabled --- osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs index 3b0a1bda99..2b175b9eed 100644 --- a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using System; using osu.Framework.Graphics.Shapes; +using osu.Framework.Platform; namespace osu.Game.Graphics.UserInterface { @@ -65,10 +66,12 @@ namespace osu.Game.Graphics.UserInterface private class CapsWarning : SpriteIcon, IHasTooltip { - public string TooltipText => Console.CapsLock ? @"Caps lock is active" : string.Empty; + public string TooltipText => host.CapsLockEnabled ? @"Caps lock is active" : string.Empty; public override bool HandleInput => true; + private GameHost host; + public CapsWarning() { Icon = FontAwesome.fa_warning; @@ -80,9 +83,10 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(OsuColour colour) + private void load(OsuColour colour, GameHost host) { Colour = colour.YellowLight; + this.host = host; } protected override void Update() @@ -91,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface updateVisibility(); } - private void updateVisibility() => this.FadeTo(Console.CapsLock ? 1 : 0, 250, Easing.OutQuint); + private void updateVisibility() => this.FadeTo(host.CapsLockEnabled ? 1 : 0, 250, Easing.OutQuint); } } } From 189988236b91f63b5e374f9289025ac938cebf4d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 15:23:17 +0900 Subject: [PATCH 004/107] Move PlayerInputManager logic inside RulesetInputManager --- osu.Game/Rulesets/UI/RulesetContainer.cs | 20 +-- osu.Game/Rulesets/UI/RulesetInputManager.cs | 163 +++++++++++++++++++- osu.Game/Screens/Play/PlayerInputManager.cs | 140 ----------------- osu.Game/osu.Game.csproj | 1 - 4 files changed, 169 insertions(+), 155 deletions(-) delete mode 100644 osu.Game/Screens/Play/PlayerInputManager.cs diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 84cadeb2a1..0a16335c77 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -9,7 +9,6 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Screens.Play; using System; using System.Collections.Generic; using System.Diagnostics; @@ -43,7 +42,7 @@ namespace osu.Game.Rulesets.UI /// /// The input manager for this RulesetContainer. /// - internal readonly PlayerInputManager InputManager = new PlayerInputManager(); + internal IHasReplayHandler ReplayInputManager => (IHasReplayHandler)KeyBindingInputManager; /// /// The key conversion input manager for this RulesetContainer. @@ -58,7 +57,7 @@ namespace osu.Game.Rulesets.UI /// /// Whether we have a replay loaded currently. /// - public bool HasReplayLoaded => InputManager.ReplayInputHandler != null; + public bool HasReplayLoaded => ReplayInputManager.ReplayInputHandler != null; public abstract IEnumerable Objects { get; } @@ -76,11 +75,7 @@ namespace osu.Game.Rulesets.UI internal RulesetContainer(Ruleset ruleset) { Ruleset = ruleset; - } - [BackgroundDependencyLoader] - private void load() - { KeyBindingInputManager = CreateInputManager(); KeyBindingInputManager.RelativeSizeAxes = Axes.Both; } @@ -113,7 +108,7 @@ namespace osu.Game.Rulesets.UI public virtual void SetReplay(Replay replay) { Replay = replay; - InputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null; + ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null; } } @@ -267,13 +262,12 @@ namespace osu.Game.Rulesets.UI [BackgroundDependencyLoader] private void load() { - InputManager.Add(content = new Container + KeyBindingInputManager.Add(content = new Container { RelativeSizeAxes = Axes.Both, - Children = new[] { KeyBindingInputManager } }); - AddInternal(InputManager); + AddInternal(KeyBindingInputManager); KeyBindingInputManager.Add(Playfield = CreatePlayfield()); loadObjects(); @@ -283,8 +277,8 @@ namespace osu.Game.Rulesets.UI { base.SetReplay(replay); - if (InputManager?.ReplayInputHandler != null) - InputManager.ReplayInputHandler.ToScreenSpace = Playfield.ScaledContent.ToScreenSpace; + if (ReplayInputManager?.ReplayInputHandler != null) + ReplayInputManager.ReplayInputHandler.ToScreenSpace = input => Playfield.ScaledContent.ToScreenSpace(input); } /// diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index 6d22b2e91e..bd7e51e937 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -1,20 +1,176 @@ // Copyright (c) 2007-2017 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; +using osu.Framework.Input; using osu.Framework.Input.Bindings; +using osu.Framework.Timing; +using osu.Game.Configuration; using osu.Game.Input.Bindings; +using osu.Game.Input.Handlers; using osu.Game.Screens.Play; +using OpenTK.Input; namespace osu.Game.Rulesets.UI { - public abstract class RulesetInputManager : DatabasedKeyBindingInputManager, ICanAttachKeyCounter + public abstract class RulesetInputManager : DatabasedKeyBindingInputManager, ICanAttachKeyCounter, IHasReplayHandler where T : struct { protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) : base(ruleset, variant, unique) { } + private List lastPressedActions = new List(); + + protected override void HandleNewState(InputState state) + { + base.HandleNewState(state); + + var replayState = state as ReplayInputHandler.ReplayState; + + if (replayState == null) return; + + // Here we handle states specifically coming from a replay source. + // These have extra action information rather than keyboard keys or mouse buttons. + + List newActions = replayState.PressedActions; + + foreach (var released in lastPressedActions.Except(newActions)) + PropagateReleased(KeyBindingInputQueue, released); + + foreach (var pressed in newActions.Except(lastPressedActions)) + PropagatePressed(KeyBindingInputQueue, pressed); + + lastPressedActions = newActions; + } + + private ManualClock clock; + private IFrameBasedClock parentClock; + + private ReplayInputHandler replayInputHandler; + public ReplayInputHandler ReplayInputHandler + { + get + { + return replayInputHandler; + } + set + { + if (replayInputHandler != null) RemoveHandler(replayInputHandler); + + replayInputHandler = value; + UseParentState = replayInputHandler == null; + + if (replayInputHandler != null) + AddHandler(replayInputHandler); + } + } + + private Bindable mouseDisabled; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + mouseDisabled = config.GetBindable(OsuSetting.MouseDisableButtons); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + //our clock will now be our parent's clock, but we want to replace this to allow manual control. + parentClock = Clock; + + Clock = new FramedClock(clock = new ManualClock + { + CurrentTime = parentClock.CurrentTime, + Rate = parentClock.Rate, + }); + } + + /// + /// Whether we running up-to-date with our parent clock. + /// If not, we will need to keep processing children until we catch up. + /// + private bool requireMoreUpdateLoops; + + /// + /// Whether we in a valid state (ie. should we keep processing children frames). + /// This should be set to false when the replay is, for instance, waiting for future frames to arrive. + /// + 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; + + public override bool UpdateSubTree() + { + requireMoreUpdateLoops = true; + validState = true; + + int loops = 0; + + while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame) + if (!base.UpdateSubTree()) + return false; + + return true; + } + + protected override void Update() + { + if (parentClock == null) return; + + clock.Rate = parentClock.Rate; + clock.IsRunning = parentClock.IsRunning; + + if (!isAttached) + { + clock.CurrentTime = parentClock.CurrentTime; + } + else + { + double? newTime = replayInputHandler.SetFrameFromTime(parentClock.CurrentTime); + + if (newTime == null) + { + // we shouldn't execute for this time value. probably waiting on more replay data. + validState = false; + return; + } + + clock.CurrentTime = newTime.Value; + } + + requireMoreUpdateLoops = clock.CurrentTime != parentClock.CurrentTime; + base.Update(); + } + + protected override void TransformState(InputState state) + { + base.TransformState(state); + + // we don't want to transform the state if a replay is present (for now, at least). + if (replayInputHandler != null) return; + + var mouse = state.Mouse as Framework.Input.MouseState; + + if (mouse != null) + { + if (mouseDisabled.Value) + { + mouse.SetPressed(MouseButton.Left, false); + mouse.SetPressed(MouseButton.Right, false); + } + } + } + public void Attach(KeyCounterCollection keyCounter) { var receptor = new ActionReceptor(keyCounter); @@ -37,6 +193,11 @@ namespace osu.Game.Rulesets.UI } } + public interface IHasReplayHandler + { + ReplayInputHandler ReplayInputHandler { get; set; } + } + public interface ICanAttachKeyCounter { void Attach(KeyCounterCollection keyCounter); diff --git a/osu.Game/Screens/Play/PlayerInputManager.cs b/osu.Game/Screens/Play/PlayerInputManager.cs deleted file mode 100644 index f5e57f9e9d..0000000000 --- a/osu.Game/Screens/Play/PlayerInputManager.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK.Input; -using osu.Framework.Allocation; -using osu.Framework.Configuration; -using osu.Framework.Input; -using osu.Framework.Timing; -using osu.Game.Configuration; -using osu.Game.Input.Handlers; - -namespace osu.Game.Screens.Play -{ - public class PlayerInputManager : PassThroughInputManager - { - private ManualClock clock; - private IFrameBasedClock parentClock; - - private ReplayInputHandler replayInputHandler; - public ReplayInputHandler ReplayInputHandler - { - get - { - return replayInputHandler; - } - set - { - if (replayInputHandler != null) RemoveHandler(replayInputHandler); - - replayInputHandler = value; - UseParentState = replayInputHandler == null; - - if (replayInputHandler != null) - AddHandler(replayInputHandler); - } - } - - private Bindable mouseDisabled; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - mouseDisabled = config.GetBindable(OsuSetting.MouseDisableButtons); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - //our clock will now be our parent's clock, but we want to replace this to allow manual control. - parentClock = Clock; - - Clock = new FramedClock(clock = new ManualClock - { - CurrentTime = parentClock.CurrentTime, - Rate = parentClock.Rate, - }); - } - - /// - /// Whether we running up-to-date with our parent clock. - /// If not, we will need to keep processing children until we catch up. - /// - private bool requireMoreUpdateLoops; - - /// - /// Whether we in a valid state (ie. should we keep processing children frames). - /// This should be set to false when the replay is, for instance, waiting for future frames to arrive. - /// - 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; - - public override bool UpdateSubTree() - { - requireMoreUpdateLoops = true; - validState = true; - - int loops = 0; - - while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame) - if (!base.UpdateSubTree()) - return false; - - return true; - } - - protected override void Update() - { - if (parentClock == null) return; - - clock.Rate = parentClock.Rate; - clock.IsRunning = parentClock.IsRunning; - - if (!isAttached) - { - clock.CurrentTime = parentClock.CurrentTime; - } - else - { - double? newTime = replayInputHandler.SetFrameFromTime(parentClock.CurrentTime); - - if (newTime == null) - { - // we shouldn't execute for this time value. probably waiting on more replay data. - validState = false; - return; - } - - clock.CurrentTime = newTime.Value; - } - - requireMoreUpdateLoops = clock.CurrentTime != parentClock.CurrentTime; - base.Update(); - } - - protected override void TransformState(InputState state) - { - base.TransformState(state); - - // we don't want to transform the state if a replay is present (for now, at least). - if (replayInputHandler != null) return; - - var mouse = state.Mouse as Framework.Input.MouseState; - - if (mouse != null) - { - if (mouseDisabled.Value) - { - mouse.SetPressed(MouseButton.Left, false); - mouse.SetPressed(MouseButton.Right, false); - } - } - } - } -} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 32a8df6357..4e9e769cb7 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -321,7 +321,6 @@ - From a7a7e0323f8ff199d10b3ccb11d6c3c9539348b8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 15:36:42 +0900 Subject: [PATCH 005/107] Update autoplay and replay handling to result in actions, not keys --- .../Replays/OsuReplayInputHandler.cs | 32 +++++++++++++++++++ .../UI/OsuRulesetContainer.cs | 4 +++ .../osu.Game.Rulesets.Osu.csproj | 1 + .../Replays/TaikoFramedReplayInputHandler.cs | 16 ++++------ osu.Game/Input/Handlers/ReplayInputHandler.cs | 15 +++++++++ .../Replays/FramedReplayInputHandler.cs | 28 +++------------- osu.Game/Rulesets/UI/RulesetContainer.cs | 2 +- 7 files changed, 64 insertions(+), 34 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs diff --git a/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs b/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs new file mode 100644 index 0000000000..a54679b8cc --- /dev/null +++ b/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using osu.Framework.Input; +using osu.Game.Rulesets.Replays; +using OpenTK; + +namespace osu.Game.Rulesets.Osu.Replays +{ + public class OsuReplayInputHandler : FramedReplayInputHandler + { + public OsuReplayInputHandler(Replay replay) + : base(replay) + { + } + + public override List GetPendingStates() + { + List actions = new List(); + + if (CurrentFrame?.MouseLeft ?? false) actions.Add(OsuAction.LeftButton); + if (CurrentFrame?.MouseRight ?? false) actions.Add(OsuAction.RightButton); + + return new List + { + new ReplayState + { + Mouse = new ReplayMouseState(ToScreenSpace(Position ?? Vector2.Zero)), + PressedActions = actions + } + }; + } + } +} diff --git a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs index 083f11945c..0b87bf7346 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs @@ -10,9 +10,11 @@ using osu.Game.Rulesets.Osu.Beatmaps; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Osu.Replays; using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; +using osu.Game.Rulesets.Replays; namespace osu.Game.Rulesets.Osu.UI { @@ -49,6 +51,8 @@ namespace osu.Game.Rulesets.Osu.UI return null; } + protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuReplayInputHandler(replay); + protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(0.75f); } } diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 1422ded407..0c9e53cf69 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -78,6 +78,7 @@ + diff --git a/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs b/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs index f6425dd66f..89093ae05e 100644 --- a/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs +++ b/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs @@ -4,7 +4,6 @@ using osu.Game.Rulesets.Replays; using System.Collections.Generic; using osu.Framework.Input; -using OpenTK.Input; namespace osu.Game.Rulesets.Taiko.Replays { @@ -17,21 +16,18 @@ namespace osu.Game.Rulesets.Taiko.Replays public override List GetPendingStates() { - var keys = new List(); + var keys = new List(); if (CurrentFrame?.MouseRight1 == true) - keys.Add(Key.F); + keys.Add(TaikoAction.LeftCentre); if (CurrentFrame?.MouseRight2 == true) - keys.Add(Key.J); + keys.Add(TaikoAction.RightCentre); if (CurrentFrame?.MouseLeft1 == true) - keys.Add(Key.D); + keys.Add(TaikoAction.LeftRim); if (CurrentFrame?.MouseLeft2 == true) - keys.Add(Key.K); + keys.Add(TaikoAction.RightRim); - return new List - { - new InputState { Keyboard = new ReplayKeyboardState(keys) } - }; + return new List { new ReplayState { PressedActions = keys } }; } } } diff --git a/osu.Game/Input/Handlers/ReplayInputHandler.cs b/osu.Game/Input/Handlers/ReplayInputHandler.cs index 76e038048c..5f86495580 100644 --- a/osu.Game/Input/Handlers/ReplayInputHandler.cs +++ b/osu.Game/Input/Handlers/ReplayInputHandler.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; +using osu.Framework.Input; using osu.Framework.Input.Handlers; using osu.Framework.Platform; using OpenTK; @@ -29,5 +31,18 @@ namespace osu.Game.Input.Handlers public override bool IsActive => true; public override int Priority => 0; + + public class ReplayState : InputState + where T : struct + { + public List PressedActions; + + public override InputState Clone() + { + var clone = (ReplayState)base.Clone(); + clone.PressedActions = new List(PressedActions); + return clone; + } + } } } \ No newline at end of file diff --git a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs index 60da35fd91..f0d68c0467 100644 --- a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs +++ b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Game.Input.Handlers; @@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Replays /// The ReplayHandler will take a replay and handle the propagation of updates to the input stack. /// It handles logic of any frames which *must* be executed. /// - public class FramedReplayInputHandler : ReplayInputHandler + public abstract class FramedReplayInputHandler : ReplayInputHandler { private readonly Replay replay; @@ -31,7 +30,7 @@ namespace osu.Game.Rulesets.Replays private int nextFrameIndex => MathHelper.Clamp(currentFrameIndex + (currentDirection > 0 ? 1 : -1), 0, Frames.Count - 1); - public FramedReplayInputHandler(Replay replay) + protected FramedReplayInputHandler(Replay replay) { this.replay = replay; } @@ -51,7 +50,7 @@ namespace osu.Game.Rulesets.Replays { } - private Vector2? position + protected Vector2? Position { get { @@ -62,23 +61,7 @@ namespace osu.Game.Rulesets.Replays } } - public override List GetPendingStates() - { - var buttons = new HashSet(); - if (CurrentFrame?.MouseLeft ?? false) - buttons.Add(MouseButton.Left); - if (CurrentFrame?.MouseRight ?? false) - buttons.Add(MouseButton.Right); - - return new List - { - new InputState - { - Mouse = new ReplayMouseState(ToScreenSpace(position ?? Vector2.Zero), buttons), - Keyboard = new ReplayKeyboardState(new List()) - } - }; - } + public override List GetPendingStates() => new List(); public bool AtLastFrame => currentFrameIndex == Frames.Count - 1; public bool AtFirstFrame => currentFrameIndex == 0; @@ -133,10 +116,9 @@ namespace osu.Game.Rulesets.Replays protected class ReplayMouseState : MouseState { - public ReplayMouseState(Vector2 position, IEnumerable list) + public ReplayMouseState(Vector2 position) { Position = position; - list.ForEach(b => SetPressed(b, true)); } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 0a16335c77..17417856a1 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.UI /// The input manager. public abstract PassThroughInputManager CreateInputManager(); - protected virtual FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new FramedReplayInputHandler(replay); + protected virtual FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => null; public Replay Replay { get; private set; } From f0635af40deeae8f3c44bcd328a9a39a6c9c7583 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 15:48:40 +0900 Subject: [PATCH 006/107] Add documentation and regions to RulesetInputManager --- osu.Game/Rulesets/UI/RulesetInputManager.cs | 43 +++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index bd7e51e937..75e273adea 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -23,6 +23,8 @@ namespace osu.Game.Rulesets.UI { } + #region Action mapping (for replays) + private List lastPressedActions = new List(); protected override void HandleNewState(InputState state) @@ -47,8 +49,9 @@ namespace osu.Game.Rulesets.UI lastPressedActions = newActions; } - private ManualClock clock; - private IFrameBasedClock parentClock; + #endregion + + #region IHasReplayHandler private ReplayInputHandler replayInputHandler; public ReplayInputHandler ReplayInputHandler @@ -69,13 +72,12 @@ namespace osu.Game.Rulesets.UI } } - private Bindable mouseDisabled; + #endregion - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - mouseDisabled = config.GetBindable(OsuSetting.MouseDisableButtons); - } + #region Clock control + + private ManualClock clock; + private IFrameBasedClock parentClock; protected override void LoadComplete() { @@ -152,6 +154,18 @@ namespace osu.Game.Rulesets.UI base.Update(); } + #endregion + + #region Setting application (disables etc.) + + private Bindable mouseDisabled; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + mouseDisabled = config.GetBindable(OsuSetting.MouseDisableButtons); + } + protected override void TransformState(InputState state) { base.TransformState(state); @@ -171,6 +185,10 @@ namespace osu.Game.Rulesets.UI } } + #endregion + + #region Key Counter Attachment + public void Attach(KeyCounterCollection keyCounter) { var receptor = new ActionReceptor(keyCounter); @@ -191,13 +209,22 @@ namespace osu.Game.Rulesets.UI public bool OnReleased(T action) => Target.Children.OfType>().Any(c => c.OnReleased(action)); } + + #endregion } + /// + /// Expose the in a capable . + /// public interface IHasReplayHandler { ReplayInputHandler ReplayInputHandler { get; set; } } + /// + /// Supports attaching a . + /// Keys will be populated automatically and a receptor will be injected inside. + /// public interface ICanAttachKeyCounter { void Attach(KeyCounterCollection keyCounter); From 76a95495d36e8069159775cc82a008317c47abc0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 17:30:10 +0900 Subject: [PATCH 007/107] Move shared code to base class --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 11 ----------- osu.Game/Overlays/Direct/DirectListPanel.cs | 15 --------------- osu.Game/Overlays/Direct/DirectPanel.cs | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 98ab5e88f8..822edd02df 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -26,22 +26,11 @@ namespace osu.Game.Overlays.Direct { Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) CornerRadius = 4; - Masking = true; - - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0f, 1f), - Radius = 3f, - Colour = Color4.Black.Opacity(0.25f), - }; } protected override void LoadComplete() { base.LoadComplete(); - - this.FadeInFromZero(200, Easing.Out); bottomPanel.LayoutDuration = 200; bottomPanel.LayoutEasing = Easing.Out; bottomPanel.Origin = Anchor.BottomLeft; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 5b45fc7725..0821fbea3a 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -29,21 +29,6 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.X; Height = height; CornerRadius = 5; - Masking = true; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0f, 1f), - Radius = 3f, - Colour = Color4.Black.Opacity(0.25f), - }; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - this.FadeInFromZero(200, Easing.Out); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 2f048b0e3d..9395e6817d 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Framework.Extensions.Color4Extensions; using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -10,6 +11,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK.Graphics; namespace osu.Game.Overlays.Direct { @@ -20,6 +22,21 @@ namespace osu.Game.Overlays.Direct protected DirectPanel(BeatmapSetInfo setInfo) { SetInfo = setInfo; + + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 3f, + Colour = Color4.Black.Opacity(0.25f), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + this.FadeInFromZero(200, Easing.Out); } protected List GetDifficultyIcons() From 4e1cf329c88628cfaa537dd81c420c3350534e6d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 17:39:39 +0900 Subject: [PATCH 008/107] Move background logic to base class; reduce overdraw after set fades in --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 10 ++------- osu.Game/Overlays/Direct/DirectPanel.cs | 25 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 822edd02df..5b648633c1 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -39,14 +39,8 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation) { - Children = new[] + AddRange(new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - CreateBackground(), new Box { RelativeSizeAxes = Axes.Both, @@ -174,7 +168,7 @@ namespace osu.Game.Overlays.Direct new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), }, }, - }; + }); } } } diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 9395e6817d..a56c15b532 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -2,10 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; @@ -19,6 +21,8 @@ namespace osu.Game.Overlays.Direct { protected readonly BeatmapSetInfo SetInfo; + protected Box BlackBackground; + protected DirectPanel(BeatmapSetInfo setInfo) { SetInfo = setInfo; @@ -33,6 +37,21 @@ namespace osu.Game.Overlays.Direct }; } + [BackgroundDependencyLoader] + private void load() + { + AddRange(new[] + { + // temporary blackness until the actual background loads. + BlackBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + CreateBackground(), + }); + } + protected override void LoadComplete() { base.LoadComplete(); @@ -55,7 +74,11 @@ namespace osu.Game.Overlays.Direct Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), + OnLoadComplete = d => + { + d.FadeInFromZero(400, Easing.Out); + BlackBackground.Delay(400).FadeOut(); + }, }) { RelativeSizeAxes = Axes.Both, From a2549157ca578f548a4342e7f6d7a3ba0ffcbf90 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 18:18:03 +0900 Subject: [PATCH 009/107] Add hover effects --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 3 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 13 +--- osu.Game/Overlays/Direct/DirectPanel.cs | 85 +++++++++++++++++---- 3 files changed, 76 insertions(+), 25 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 5b648633c1..0cc1c18d8d 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -25,7 +25,6 @@ namespace osu.Game.Overlays.Direct public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap) { Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) - CornerRadius = 4; } protected override void LoadComplete() @@ -39,6 +38,8 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation) { + Content.CornerRadius = 4; + AddRange(new Drawable[] { new Box diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 0821fbea3a..d284c50bc4 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -28,20 +28,15 @@ namespace osu.Game.Overlays.Direct { RelativeSizeAxes = Axes.X; Height = height; - CornerRadius = 5; } [BackgroundDependencyLoader] private void load(LocalisationEngine localisation) { - Children = new[] + Content.CornerRadius = 5; + + AddRange(new Drawable[] { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - CreateBackground(), new Box { RelativeSizeAxes = Axes.Both, @@ -132,7 +127,7 @@ namespace osu.Game.Overlays.Direct }, }, }, - }; + }); } private class DownloadButton : OsuClickableContainer diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index a56c15b532..7e95c1674b 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -9,11 +9,14 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK.Graphics; +using osu.Framework.Input; +using osu.Framework.MathUtils; namespace osu.Game.Overlays.Direct { @@ -23,35 +26,62 @@ namespace osu.Game.Overlays.Direct protected Box BlackBackground; + private const double hover_transition_time = 400; + + private Container content; + + protected override Container Content => content; + protected DirectPanel(BeatmapSetInfo setInfo) { SetInfo = setInfo; - - Masking = true; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0f, 1f), - Radius = 3f, - Colour = Color4.Black.Opacity(0.25f), - }; } [BackgroundDependencyLoader] private void load() { - AddRange(new[] + AddInternal(content = new Container { - // temporary blackness until the actual background loads. - BlackBackground = new Box + RelativeSizeAxes = Axes.Both, + Masking = true, + EdgeEffect = new EdgeEffectParameters { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 2f, + Colour = Color4.Black.Opacity(0.25f), }, - CreateBackground(), + Children = new[] + { + // temporary blackness until the actual background loads. + BlackBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + CreateBackground(), + } }); } + protected override bool OnHover(InputState state) + { + content.FadeEdgeEffectTo(1f, hover_transition_time, Easing.OutQuint); + content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 14, hover_transition_time, Easing.OutQuint)); + content.MoveToY(-4, hover_transition_time, Easing.OutQuint); + + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + content.FadeEdgeEffectTo(0.25f, hover_transition_time, Easing.OutQuint); + content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 2, hover_transition_time, Easing.OutQuint)); + content.MoveToY(0, hover_transition_time, Easing.OutQuint); + + base.OnHoverLost(state); + } + protected override void LoadComplete() { base.LoadComplete(); @@ -127,5 +157,30 @@ namespace osu.Game.Overlays.Direct Value = value; } } + + private class TransformEdgeEffectRadius : Transform + { + /// + /// Current value of the transformed colour in linear colour space. + /// + private float valueAt(double time) + { + if (time < StartTime) return StartValue; + if (time >= EndTime) return EndValue; + + return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); + } + + public override string TargetMember => "EdgeEffect.Colour"; + + protected override void Apply(Container c, double time) + { + EdgeEffectParameters e = c.EdgeEffect; + e.Radius = valueAt(time); + c.EdgeEffect = e; + } + + protected override void ReadIntoStartValue(Container d) => StartValue = d.EdgeEffect.Radius; + } } } From 36629f52074162d881c245d2293f139e889b39da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 18:51:34 +0900 Subject: [PATCH 010/107] Make ProgressBar usable in more places than just MusicController --- .../Graphics/UserInterface/ProgressBar.cs | 67 +++++++++++++++++++ osu.Game/Overlays/MusicController.cs | 45 ------------- osu.Game/osu.Game.csproj | 1 + 3 files changed, 68 insertions(+), 45 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/ProgressBar.cs diff --git a/osu.Game/Graphics/UserInterface/ProgressBar.cs b/osu.Game/Graphics/UserInterface/ProgressBar.cs new file mode 100644 index 0000000000..f22983a6e6 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/ProgressBar.cs @@ -0,0 +1,67 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; +using OpenTK.Graphics; + +namespace osu.Game.Graphics.UserInterface +{ + public class ProgressBar : SliderBar + { + public Action OnSeek; + + private readonly Box fill; + private readonly Box background; + + public Color4 FillColour + { + set { fill.Colour = value; } + } + + public Color4 BackgroundColour + { + set + { + background.Alpha = 1; + background.Colour = value; + } + } + + public double EndTime + { + set { CurrentNumber.MaxValue = value; } + } + + public double CurrentTime + { + set { CurrentNumber.Value = value; } + } + + public ProgressBar() + { + CurrentNumber.MinValue = 0; + CurrentNumber.MaxValue = 1; + RelativeSizeAxes = Axes.X; + + Children = new Drawable[] + { + background = new Box + { + Alpha = 0, + RelativeSizeAxes = Axes.Both + }, + fill = new Box { RelativeSizeAxes = Axes.Y } + }; + } + + protected override void UpdateValue(float value) + { + fill.Width = value * UsableWidth; + } + + protected override void OnUserChange() => OnSeek?.Invoke(Current); + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index d970089942..f2c90f009a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -15,7 +15,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.Localisation; using osu.Framework.Threading; @@ -434,49 +433,5 @@ namespace osu.Game.Overlays sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4"); } } - - private class ProgressBar : SliderBar - { - public Action OnSeek; - - private readonly Box fill; - - public Color4 FillColour - { - set { fill.Colour = value; } - } - - public double EndTime - { - set { CurrentNumber.MaxValue = value; } - } - - public double CurrentTime - { - set { CurrentNumber.Value = value; } - } - - public ProgressBar() - { - CurrentNumber.MinValue = 0; - CurrentNumber.MaxValue = 1; - RelativeSizeAxes = Axes.X; - - Children = new Drawable[] - { - fill = new Box - { - RelativeSizeAxes = Axes.Y - } - }; - } - - protected override void UpdateValue(float value) - { - fill.Width = value * UsableWidth; - } - - protected override void OnUserChange() => OnSeek?.Invoke(Current); - } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 32a8df6357..f361c141f1 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -116,6 +116,7 @@ + From cacf256aade865ecc9748219827b56a06510125e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 18:51:50 +0900 Subject: [PATCH 011/107] Add placeholder download method with progress bar --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 7 +++++ osu.Game/Overlays/Direct/DirectListPanel.cs | 1 + osu.Game/Overlays/Direct/DirectPanel.cs | 29 ++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 0cc1c18d8d..3a9e75bd38 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -12,6 +12,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; +using osu.Framework.Input; namespace osu.Game.Overlays.Direct { @@ -171,5 +172,11 @@ namespace osu.Game.Overlays.Direct }, }); } + + protected override bool OnClick(InputState state) + { + StartDownload(); + return true; + } } } diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index d284c50bc4..b3502b0827 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -124,6 +124,7 @@ namespace osu.Game.Overlays.Direct 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 7e95c1674b..8738d8ea90 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -17,6 +17,8 @@ using osu.Game.Graphics.Sprites; using OpenTK.Graphics; using osu.Framework.Input; using osu.Framework.MathUtils; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; namespace osu.Game.Overlays.Direct { @@ -30,6 +32,9 @@ namespace osu.Game.Overlays.Direct private Container content; + private APIAccess api; + private ProgressBar progressBar; + protected override Container Content => content; protected DirectPanel(BeatmapSetInfo setInfo) @@ -38,8 +43,10 @@ namespace osu.Game.Overlays.Direct } [BackgroundDependencyLoader] - private void load() + private void load(APIAccess api, OsuColour colours) { + this.api = api; + AddInternal(content = new Container { RelativeSizeAxes = Axes.Both, @@ -60,6 +67,16 @@ namespace osu.Game.Overlays.Direct Colour = Color4.Black, }, CreateBackground(), + progressBar = new ProgressBar + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Height = 0, + Alpha = 0, + BackgroundColour = Color4.Black.Opacity(0.7f), + FillColour = colours.Blue, + Depth = -1, + }, } }); } @@ -82,6 +99,16 @@ namespace osu.Game.Overlays.Direct base.OnHoverLost(state); } + protected void StartDownload() + { + progressBar.FadeIn(400, Easing.OutQuint); + progressBar.ResizeHeightTo(4, 400, Easing.OutQuint); + + progressBar.Current.Value = 0.5f; + + api.Queue(new APIRequest()); + } + protected override void LoadComplete() { base.LoadComplete(); From dac54c362a4050107ac11135ecf1445aff8af809 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 15:39:35 +0900 Subject: [PATCH 012/107] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 1ba1e8ef1e..da5fbf8c58 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1ba1e8ef1e5ec0466632be02492023a081cb85ab +Subproject commit da5fbf8c580b079671298f6da54be10a00bf434c From 314108146a9ae75bcdb82b7413bd998794febc94 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:14:17 +0900 Subject: [PATCH 013/107] Add a download API request --- osu.Game/Online/API/APIRequest.cs | 43 +++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index 23268a9ca9..307afb2d2b 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -11,11 +11,11 @@ namespace osu.Game.Online.API /// An API request with a well-defined response type. /// /// Type of the response (used for deserialisation). - public class APIRequest : APIRequest + public abstract class APIRequest : APIRequest { protected override WebRequest CreateWebRequest() => new JsonWebRequest(Uri); - public APIRequest() + protected APIRequest() { base.Success += onSuccess; } @@ -28,10 +28,36 @@ namespace osu.Game.Online.API public new event APISuccessHandler Success; } + public abstract class APIDownloadRequest : APIRequest + { + protected override WebRequest CreateWebRequest() + { + var request = new WebRequest(Uri); + request.DownloadProgress += request_Progress; + return request; + } + + private void request_Progress(WebRequest request, long current, long total) => API.Scheduler.Add(delegate { Progress?.Invoke(current, total); }); + + protected APIDownloadRequest() + { + base.Success += onSuccess; + } + + private void onSuccess() + { + Success?.Invoke(WebRequest.ResponseData); + } + + public event APIProgressHandler Progress; + + public new event APISuccessHandler Success; + } + /// /// AN API request with no specified response type. /// - public class APIRequest + public abstract class APIRequest { /// /// The maximum amount of time before this request will fail. @@ -42,7 +68,7 @@ namespace osu.Game.Online.API protected virtual WebRequest CreateWebRequest() => new WebRequest(Uri); - protected virtual string Uri => $@"{api.Endpoint}/api/v2/{Target}"; + protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}"; private double remainingTime => Math.Max(0, Timeout - (DateTime.Now.TotalMilliseconds() - (startTime ?? 0))); @@ -52,7 +78,7 @@ namespace osu.Game.Online.API public double StartTime => startTime ?? -1; - private APIAccess api; + protected APIAccess API; protected WebRequest WebRequest; public event APISuccessHandler Success; @@ -64,7 +90,7 @@ namespace osu.Game.Online.API public void Perform(APIAccess api) { - this.api = api; + API = api; if (checkAndProcessFailure()) return; @@ -109,9 +135,9 @@ namespace osu.Game.Online.API /// Whether we are in a failed or cancelled state. private bool checkAndProcessFailure() { - if (api == null || pendingFailure == null) return cancelled; + if (API == null || pendingFailure == null) return cancelled; - api.Scheduler.Add(pendingFailure); + API.Scheduler.Add(pendingFailure); pendingFailure = null; return true; } @@ -119,5 +145,6 @@ namespace osu.Game.Online.API public delegate void APIFailureHandler(Exception e); public delegate void APISuccessHandler(); + public delegate void APIProgressHandler(long current, long total); public delegate void APISuccessHandler(T content); } From 3c10b2d3d9b44e06bf95f88a8c26371d976634b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:14:35 +0900 Subject: [PATCH 014/107] Populate set IDs in GetBeatmapSetsResponse --- osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index ca984d3511..e4763f73ee 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -46,6 +46,9 @@ namespace osu.Game.Online.API.Requests [JsonProperty(@"favourite_count")] private int favouriteCount { get; set; } + [JsonProperty(@"id")] + private int onlineId { get; set; } + [JsonProperty(@"beatmaps")] private IEnumerable beatmaps { get; set; } @@ -53,6 +56,7 @@ namespace osu.Game.Online.API.Requests { return new BeatmapSetInfo { + OnlineBeatmapSetID = onlineId, Metadata = this, OnlineInfo = new BeatmapSetOnlineInfo { From 9c82593c9e82a23ebc9f435674f1b6172a1351e6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:15:45 +0900 Subject: [PATCH 015/107] Add cancel event to ProgressNotification --- osu.Game/Overlays/Notifications/ProgressNotification.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index f42b4b6cb3..a31291e1b8 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -152,11 +152,14 @@ namespace osu.Game.Overlays.Notifications break; case ProgressNotificationState.Active: case ProgressNotificationState.Queued: - State = ProgressNotificationState.Cancelled; + if (CancelRequested?.Invoke() != false) + State = ProgressNotificationState.Cancelled; break; } } + public Func CancelRequested { get; set; } + /// /// The function to post completion notifications back to. /// From 32a23c7fe41fd2c4f978385fdb6f32f576d9e0dc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:16:03 +0900 Subject: [PATCH 016/107] Add initial osu!direct beatmap download and import process --- osu.Game/Overlays/Direct/DirectPanel.cs | 82 ++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 8738d8ea90..b44a100d3c 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; +using System.IO; +using System.Threading.Tasks; using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -19,6 +21,9 @@ using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; +using osu.Framework.Logging; +using osu.Game.Beatmaps.IO; +using osu.Game.Overlays.Notifications; namespace osu.Game.Overlays.Direct { @@ -34,6 +39,8 @@ namespace osu.Game.Overlays.Direct private APIAccess api; private ProgressBar progressBar; + private BeatmapManager beatmaps; + private NotificationOverlay notifications; protected override Container Content => content; @@ -43,9 +50,11 @@ namespace osu.Game.Overlays.Direct } [BackgroundDependencyLoader] - private void load(APIAccess api, OsuColour colours) + private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications) { this.api = api; + this.beatmaps = beatmaps; + this.notifications = notifications; AddInternal(content = new Container { @@ -101,12 +110,79 @@ namespace osu.Game.Overlays.Direct protected void StartDownload() { + if (!api.LocalUser.Value.IsSupporter) + { + notifications.Post(new SimpleNotification + { + Icon = FontAwesome.fa_superpowers, + Text = "You gotta be a supporter to download for now 'yo" + }); + return; + } + progressBar.FadeIn(400, Easing.OutQuint); progressBar.ResizeHeightTo(4, 400, Easing.OutQuint); - progressBar.Current.Value = 0.5f; + progressBar.Current.Value = 0; - api.Queue(new APIRequest()); + ProgressNotification downloadNotification = new ProgressNotification + { + Text = $"Downloading {SetInfo.Metadata.Artist} - {SetInfo.Metadata.Title}", + }; + + var request = new DownloadBeatmapSetRequest(SetInfo); + request.Failure += e => + { + progressBar.Current.Value = 0; + progressBar.FadeOut(500); + downloadNotification.State = ProgressNotificationState.Completed; + Logger.Error(e, "Failed to get beatmap download information"); + }; + + request.Progress += (current, total) => + { + float progress = (float)current / total; + + progressBar.Current.Value = progress; + + downloadNotification.State = ProgressNotificationState.Active; + downloadNotification.Progress = progress; + }; + + request.Success += data => + { + progressBar.Current.Value = 1; + progressBar.FadeOut(500); + + downloadNotification.State = ProgressNotificationState.Completed; + + using (var stream = new MemoryStream(data)) + using (var archive = new OszArchiveReader(stream)) + beatmaps.Import(archive); + }; + + downloadNotification.CancelRequested += () => + { + request.Cancel(); + return true; + }; + + notifications.Post(downloadNotification); + + // don't run in the main api queue as this is a long-running task. + Task.Run(() => request.Perform(api)); + } + + public class DownloadBeatmapSetRequest : APIDownloadRequest + { + private readonly BeatmapSetInfo beatmapSet; + + public DownloadBeatmapSetRequest(BeatmapSetInfo beatmapSet) + { + this.beatmapSet = beatmapSet; + } + + protected override string Target => $@"beatmapsets/{beatmapSet.OnlineBeatmapSetID}/download"; } protected override void LoadComplete() From 9adff5f697221b0d7f8ab9460315c681345a6a3f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:18:47 +0900 Subject: [PATCH 017/107] Add osu!direct toggle to toolbar --- osu.Game/OsuGame.cs | 1 + osu.Game/Overlays/Toolbar/Toolbar.cs | 1 + .../Overlays/Toolbar/ToolbarDirectButton.cs | 19 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 22 insertions(+) create mode 100644 osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 8c82071c23..43e3731166 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -219,6 +219,7 @@ namespace osu.Game dependencies.Cache(settings); dependencies.Cache(social); + dependencies.Cache(direct); dependencies.Cache(chat); dependencies.Cache(userProfile); dependencies.Cache(musicController); diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 32344ca7eb..e36db1f9da 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -58,6 +58,7 @@ namespace osu.Game.Overlays.Toolbar AutoSizeAxes = Axes.X, Children = new Drawable[] { + new ToolbarDirectButton(), new ToolbarChatButton(), new ToolbarSocialButton(), new ToolbarMusicButton(), diff --git a/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs b/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs new file mode 100644 index 0000000000..484b079d23 --- /dev/null +++ b/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs @@ -0,0 +1,19 @@ +using osu.Framework.Allocation; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Toolbar +{ + internal class ToolbarDirectButton : ToolbarOverlayToggleButton + { + public ToolbarDirectButton() + { + SetIcon(FontAwesome.fa_download); + } + + [BackgroundDependencyLoader] + private void load(DirectOverlay direct) + { + StateContainer = direct; + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f361c141f1..15c400b21e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -130,6 +130,7 @@ + From 0082640548d3e6cab5cdfbfe0ed2cb442511ccda Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:25:18 +0900 Subject: [PATCH 018/107] Add missing licence header --- osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs b/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs index 484b079d23..32e149b31a 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs @@ -1,3 +1,6 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + using osu.Framework.Allocation; using osu.Game.Graphics; From a7e6efd34fc83ceb33cf7c8a31200d3d709e1dad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:30:18 +0900 Subject: [PATCH 019/107] Rename keys -> actions --- .../Replays/TaikoFramedReplayInputHandler.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs b/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs index 89093ae05e..fce0179721 100644 --- a/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs +++ b/osu.Game.Rulesets.Taiko/Replays/TaikoFramedReplayInputHandler.cs @@ -16,18 +16,18 @@ namespace osu.Game.Rulesets.Taiko.Replays public override List GetPendingStates() { - var keys = new List(); + var actions = new List(); if (CurrentFrame?.MouseRight1 == true) - keys.Add(TaikoAction.LeftCentre); + actions.Add(TaikoAction.LeftCentre); if (CurrentFrame?.MouseRight2 == true) - keys.Add(TaikoAction.RightCentre); + actions.Add(TaikoAction.RightCentre); if (CurrentFrame?.MouseLeft1 == true) - keys.Add(TaikoAction.LeftRim); + actions.Add(TaikoAction.LeftRim); if (CurrentFrame?.MouseLeft2 == true) - keys.Add(TaikoAction.RightRim); + actions.Add(TaikoAction.RightRim); - return new List { new ReplayState { PressedActions = keys } }; + return new List { new ReplayState { PressedActions = actions } }; } } } From c9f90efb8ac418d52949628a0018f31bf605b0a1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:31:57 +0900 Subject: [PATCH 020/107] Add more checks and remove direct cast --- 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 17417856a1..a7472f4dbc 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.UI /// /// The input manager for this RulesetContainer. /// - internal IHasReplayHandler ReplayInputManager => (IHasReplayHandler)KeyBindingInputManager; + internal IHasReplayHandler ReplayInputManager => KeyBindingInputManager as IHasReplayHandler; /// /// The key conversion input manager for this RulesetContainer. @@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.UI /// /// Whether we have a replay loaded currently. /// - public bool HasReplayLoaded => ReplayInputManager.ReplayInputHandler != null; + public bool HasReplayLoaded => ReplayInputManager?.ReplayInputHandler != null; public abstract IEnumerable Objects { get; } @@ -107,6 +107,9 @@ namespace osu.Game.Rulesets.UI /// The replay, null for local input. public virtual void SetReplay(Replay replay) { + if (ReplayInputManager == null) + throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports replay loading is not available"); + Replay = replay; ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null; } From 2b667cf789a57ac5c73a5c274dbceef2ba544086 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:32:55 +0900 Subject: [PATCH 021/107] Fix typos --- osu.Game/Rulesets/UI/RulesetInputManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index 75e273adea..0419070b42 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -94,13 +94,13 @@ namespace osu.Game.Rulesets.UI } /// - /// Whether we running up-to-date with our parent clock. + /// Whether we are running up-to-date with our parent clock. /// If not, we will need to keep processing children until we catch up. /// private bool requireMoreUpdateLoops; /// - /// Whether we in a valid state (ie. should we keep processing children frames). + /// Whether we are in a valid state (ie. should we keep processing children frames). /// This should be set to false when the replay is, for instance, waiting for future frames to arrive. /// private bool validState; @@ -229,4 +229,4 @@ namespace osu.Game.Rulesets.UI { void Attach(KeyCounterCollection keyCounter); } -} \ No newline at end of file +} From 1b0a1dd4108285dbec840ad8cf9a9ef1b014d066 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 20:37:03 +0900 Subject: [PATCH 022/107] Add missing licence header --- osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs b/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs index a54679b8cc..0811a68392 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; using osu.Framework.Input; using osu.Game.Rulesets.Replays; using OpenTK; From febf0348be646d1af5aeda1ae1ee8dcf5206a298 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2017 21:26:50 +0900 Subject: [PATCH 023/107] Permit nulls to allow test cases to run successfully --- osu.Game/Overlays/Direct/DirectPanel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index b44a100d3c..bc30fb83f5 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -49,7 +49,7 @@ namespace osu.Game.Overlays.Direct SetInfo = setInfo; } - [BackgroundDependencyLoader] + [BackgroundDependencyLoader(permitNulls: true)] private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications) { this.api = api; @@ -110,6 +110,8 @@ namespace osu.Game.Overlays.Direct protected void StartDownload() { + if (api == null) return; + if (!api.LocalUser.Value.IsSupporter) { notifications.Post(new SimpleNotification From f8cc4238ffa88e96e42a8744986e1adfe65b3288 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 24 Aug 2017 22:13:20 +0200 Subject: [PATCH 024/107] cleanup code --- .../UserInterface/OsuPasswordTextBox.cs | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs index 2b175b9eed..2fdbf64d08 100644 --- a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs @@ -7,8 +7,8 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; -using System; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Framework.Platform; namespace osu.Game.Graphics.UserInterface @@ -19,14 +19,35 @@ namespace osu.Game.Graphics.UserInterface public override bool AllowClipboardExport => false; + private readonly CapsWarning warning; + + private GameHost host; + public OsuPasswordTextBox() { - Add(new CapsWarning + Add(warning = new CapsWarning { Size = new Vector2(20), + Origin = Anchor.CentreRight, + Anchor = Anchor.CentreRight, + Margin = new MarginPadding { Right = 10 }, + Alpha = 0, }); } + [BackgroundDependencyLoader] + private void load(GameHost host) + { + this.host = host; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Key == OpenTK.Input.Key.CapsLock) + warning.FadeTo(host.CapsLockEnabled ? 1 : 0, 250, Easing.OutQuint); + return base.OnKeyDown(state, args); + } + public class PasswordMaskChar : Container { private readonly CircularContainer circle; @@ -66,36 +87,18 @@ namespace osu.Game.Graphics.UserInterface private class CapsWarning : SpriteIcon, IHasTooltip { - public string TooltipText => host.CapsLockEnabled ? @"Caps lock is active" : string.Empty; - - public override bool HandleInput => true; - - private GameHost host; + public string TooltipText => @"Caps lock is active"; public CapsWarning() { Icon = FontAwesome.fa_warning; - Origin = Anchor.CentreRight; - Anchor = Anchor.CentreRight; - Margin = new MarginPadding { Right = 10 }; - AlwaysPresent = true; - Alpha = 0; } [BackgroundDependencyLoader] - private void load(OsuColour colour, GameHost host) + private void load(OsuColour colour) { Colour = colour.YellowLight; - this.host = host; } - - protected override void Update() - { - base.Update(); - updateVisibility(); - } - - private void updateVisibility() => this.FadeTo(host.CapsLockEnabled ? 1 : 0, 250, Easing.OutQuint); } } } From 2dd3e513732d7c0cde6ecd5e0c8d0b3543d337ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 10:51:28 +0900 Subject: [PATCH 025/107] Ensure other full-screen overlays are closed when direct is open (and vice-versa) --- osu.Game/OsuGame.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 43e3731166..82177ab05e 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -226,6 +226,23 @@ namespace osu.Game dependencies.Cache(notificationOverlay); dependencies.Cache(dialogOverlay); + // ensure only one of these overlays are open at once. + var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct }; + foreach (var overlay in singleDisplayOverlays) + { + overlay.StateChanged += (container, state) => + { + if (state == Visibility.Hidden) return; + + foreach (var c in singleDisplayOverlays) + { + if (c == container) continue; + c.State = Visibility.Hidden; + } + }; + } + + // ensure both overlays aren't presented at the same time chat.StateChanged += (container, state) => social.State = state == Visibility.Visible ? Visibility.Hidden : social.State; social.StateChanged += (container, state) => chat.State = state == Visibility.Visible ? Visibility.Hidden : chat.State; From 7f617e2c3659ab1dad686c6971e056be0e169884 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 11:53:41 +0900 Subject: [PATCH 026/107] Remove downloaded beatmap panels from osu!direct --- osu.Game/Overlays/DirectOverlay.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index b1c7dab778..f270aec43e 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -161,11 +161,19 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuColour colours, APIAccess api, RulesetStore rulesets) + private void load(OsuColour colours, APIAccess api, RulesetStore rulesets, BeatmapManager beatmaps) { this.api = api; this.rulesets = rulesets; resultCountsContainer.Colour = colours.Yellow; + + beatmaps.BeatmapSetAdded += setAdded; + } + + private void setAdded(BeatmapSetInfo set) + { + // 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(); } private void updateResultCounts() From ca0d1b79b2b772e2c789be0b78c2a0dd7d50aa33 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 11:54:18 +0900 Subject: [PATCH 027/107] Disallow multiple download requests for the same panel --- osu.Game/Overlays/Direct/DirectPanel.cs | 30 +++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index bc30fb83f5..4f02ce1bf6 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Direct { public abstract class DirectPanel : Container { - protected readonly BeatmapSetInfo SetInfo; + public readonly BeatmapSetInfo SetInfo; protected Box BlackBackground; @@ -108,10 +108,23 @@ namespace osu.Game.Overlays.Direct base.OnHoverLost(state); } + // this should eventually be moved to a more central place, like BeatmapManager. + private DownloadBeatmapSetRequest downloadRequest; + protected void StartDownload() { if (api == null) return; + // we already have an active download running. + if (downloadRequest != null) + { + 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; + } + if (!api.LocalUser.Value.IsSupporter) { notifications.Post(new SimpleNotification @@ -132,16 +145,18 @@ namespace osu.Game.Overlays.Direct Text = $"Downloading {SetInfo.Metadata.Artist} - {SetInfo.Metadata.Title}", }; - var request = new DownloadBeatmapSetRequest(SetInfo); - request.Failure += e => + downloadRequest = new DownloadBeatmapSetRequest(SetInfo); + downloadRequest.Failure += e => { progressBar.Current.Value = 0; progressBar.FadeOut(500); downloadNotification.State = ProgressNotificationState.Completed; Logger.Error(e, "Failed to get beatmap download information"); + + downloadRequest = null; }; - request.Progress += (current, total) => + downloadRequest.Progress += (current, total) => { float progress = (float)current / total; @@ -151,7 +166,7 @@ namespace osu.Game.Overlays.Direct downloadNotification.Progress = progress; }; - request.Success += data => + downloadRequest.Success += data => { progressBar.Current.Value = 1; progressBar.FadeOut(500); @@ -165,14 +180,15 @@ namespace osu.Game.Overlays.Direct downloadNotification.CancelRequested += () => { - request.Cancel(); + downloadRequest.Cancel(); + downloadRequest = null; return true; }; notifications.Post(downloadNotification); // don't run in the main api queue as this is a long-running task. - Task.Run(() => request.Perform(api)); + Task.Run(() => downloadRequest.Perform(api)); } public class DownloadBeatmapSetRequest : APIDownloadRequest From 7055cb581d71a9d7fe438f7ec9e6beeba26824e4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 11:54:35 +0900 Subject: [PATCH 028/107] Load direct panels more asynchronously to avoid stutter --- osu.Game/Overlays/DirectOverlay.cs | 60 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index f270aec43e..f734e43826 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays private readonly FillFlowContainer resultCountsContainer; private readonly OsuSpriteText resultCountsText; - private readonly FillFlowContainer panels; + private FillFlowContainer panels; protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74"); protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71"); @@ -48,17 +48,6 @@ namespace osu.Game.Overlays if (beatmapSets?.Equals(value) ?? false) return; beatmapSets = value; - if (BeatmapSets == null) - { - foreach (var p in panels.Children) - { - p.FadeOut(200); - p.Expire(); - } - - return; - } - recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value); } } @@ -108,13 +97,6 @@ namespace osu.Game.Overlays }, } }, - panels = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(panel_padding), - Margin = new MarginPadding { Top = 10 }, - }, }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; @@ -193,18 +175,38 @@ namespace osu.Game.Overlays private void recreatePanels(PanelDisplayStyle displayStyle) { + if (panels != null) + { + panels.FadeOut(200); + panels.Expire(); + panels = null; + } + if (BeatmapSets == null) return; - panels.ChildrenEnumerable = BeatmapSets.Select(b => - { - switch (displayStyle) - { - case PanelDisplayStyle.Grid: - return new DirectGridPanel(b) { Width = 400 }; - default: - return new DirectListPanel(b); - } - }); + var newPanels = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(panel_padding), + Margin = new MarginPadding { Top = 10 }, + ChildrenEnumerable = BeatmapSets.Select(b => + { + switch (displayStyle) + { + case PanelDisplayStyle.Grid: + return new DirectGridPanel(b) { Width = 400 }; + default: + return new DirectListPanel(b); + } + }) + }; + + LoadComponentAsync(newPanels, p => + { + if (panels != null) ScrollFlow.Remove(panels); + ScrollFlow.Add(panels = newPanels); + }); } private GetBeatmapSetsRequest getSetsRequest; From 86bde4b6b253e87fd92ae8026878a4a5128f35cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 13:03:34 +0900 Subject: [PATCH 029/107] Use the correct icon for osu!direct in the toolbar --- osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs b/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs index 32e149b31a..dacb6d67b8 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarDirectButton.cs @@ -10,7 +10,7 @@ namespace osu.Game.Overlays.Toolbar { public ToolbarDirectButton() { - SetIcon(FontAwesome.fa_download); + SetIcon(FontAwesome.fa_osu_chevron_down_o); } [BackgroundDependencyLoader] From 67b3cbce2f9fa436d19f5ffa77982c83521a3442 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 13:04:32 +0900 Subject: [PATCH 030/107] Fix beatmap background being disposed too early Causes weird transitions on the music controller --- osu.Game/OsuGameBase.cs | 8 ++------ osu.Game/Overlays/MusicController.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 952dc900a2..a7136ce803 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -152,14 +152,10 @@ namespace osu.Game Beatmap.ValueChanged += b => { - // compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) + // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) if (lastBeatmap?.Track != b.Track) { - // this disposal is done to stop the audio track. - // it may not be exactly what we want for cases beatmaps are reused, as it will - // trigger a fresh load of contained resources. - lastBeatmap?.Dispose(); - + lastBeatmap?.Track?.Dispose(); Audio.Track.AddItem(b.Track); } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index f2c90f009a..cb4628825e 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -348,23 +348,23 @@ namespace osu.Game.Overlays playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap) { - OnLoadComplete = d => + OnLoadComplete = newBackground => { switch (direction) { case TransformDirection.Next: - d.Position = new Vector2(400, 0); - d.MoveToX(0, 500, Easing.OutCubic); + newBackground.Position = new Vector2(400, 0); + newBackground.MoveToX(0, 500, Easing.OutCubic); currentBackground.MoveToX(-400, 500, Easing.OutCubic); break; case TransformDirection.Prev: - d.Position = new Vector2(-400, 0); - d.MoveToX(0, 500, Easing.OutCubic); + newBackground.Position = new Vector2(-400, 0); + newBackground.MoveToX(0, 500, Easing.OutCubic); currentBackground.MoveToX(400, 500, Easing.OutCubic); break; } currentBackground.Expire(); - currentBackground = d; + currentBackground = newBackground; } }) { From 72a16e31dd9468912df4c555d72ba10010e49adf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 13:07:10 +0900 Subject: [PATCH 031/107] Remove unnecessary old code --- osu.Game/OsuGame.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 82177ab05e..30bc09d50f 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -242,11 +242,6 @@ namespace osu.Game }; } - - // ensure both overlays aren't presented at the same time - chat.StateChanged += (container, state) => social.State = state == Visibility.Visible ? Visibility.Hidden : social.State; - social.StateChanged += (container, state) => chat.State = state == Visibility.Visible ? Visibility.Hidden : chat.State; - LoadComponentAsync(Toolbar = new Toolbar { Depth = -4, From 70154d10365fbf7929987778c65c15df104f30d0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 14:36:14 +0900 Subject: [PATCH 032/107] Update usage of FadeEdgeEffect Improves the visual appearance of DirectPanels' shadows too. --- osu-framework | 2 +- osu.Game/Overlays/Direct/DirectPanel.cs | 58 +++++++------------ osu.Game/Overlays/KeyBinding/KeyBindingRow.cs | 4 +- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/osu-framework b/osu-framework index da5fbf8c58..3db7e23165 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit da5fbf8c580b079671298f6da54be10a00bf434c +Subproject commit 3db7e231653ec6ffe28b5dcd1a86230ec754cc1c diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 4f02ce1bf6..a642f72821 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -11,14 +11,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK.Graphics; using osu.Framework.Input; -using osu.Framework.MathUtils; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Framework.Logging; @@ -49,6 +47,23 @@ namespace osu.Game.Overlays.Direct SetInfo = setInfo; } + private readonly EdgeEffectParameters edgeEffectNormal = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 2f, + Colour = Color4.Black.Opacity(0.25f), + }; + + private readonly EdgeEffectParameters edgeEffectHovered = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 5f), + Radius = 10f, + Colour = Color4.Black.Opacity(0.3f), + }; + + [BackgroundDependencyLoader(permitNulls: true)] private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications) { @@ -60,13 +75,7 @@ namespace osu.Game.Overlays.Direct { RelativeSizeAxes = Axes.Both, Masking = true, - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0f, 1f), - Radius = 2f, - Colour = Color4.Black.Opacity(0.25f), - }, + EdgeEffect = edgeEffectNormal, Children = new[] { // temporary blackness until the actual background loads. @@ -92,8 +101,7 @@ namespace osu.Game.Overlays.Direct protected override bool OnHover(InputState state) { - content.FadeEdgeEffectTo(1f, hover_transition_time, Easing.OutQuint); - content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 14, hover_transition_time, Easing.OutQuint)); + content.TweenEdgeEffectTo(edgeEffectHovered, hover_transition_time, Easing.OutQuint); content.MoveToY(-4, hover_transition_time, Easing.OutQuint); return base.OnHover(state); @@ -101,8 +109,7 @@ namespace osu.Game.Overlays.Direct protected override void OnHoverLost(InputState state) { - content.FadeEdgeEffectTo(0.25f, hover_transition_time, Easing.OutQuint); - content.TransformTo(content.PopulateTransform(new TransformEdgeEffectRadius(), 2, hover_transition_time, Easing.OutQuint)); + content.TweenEdgeEffectTo(edgeEffectNormal, hover_transition_time, Easing.OutQuint); content.MoveToY(0, hover_transition_time, Easing.OutQuint); base.OnHoverLost(state); @@ -278,30 +285,5 @@ namespace osu.Game.Overlays.Direct Value = value; } } - - private class TransformEdgeEffectRadius : Transform - { - /// - /// Current value of the transformed colour in linear colour space. - /// - private float valueAt(double time) - { - if (time < StartTime) return StartValue; - if (time >= EndTime) return EndValue; - - return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); - } - - public override string TargetMember => "EdgeEffect.Colour"; - - protected override void Apply(Container c, double time) - { - EdgeEffectParameters e = c.EdgeEffect; - e.Radius = valueAt(time); - c.EdgeEffect = e; - } - - protected override void ReadIntoStartValue(Container d) => StartValue = d.EdgeEffect.Radius; - } } } diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs index ee997a2185..046e56573f 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs @@ -122,14 +122,14 @@ namespace osu.Game.Overlays.KeyBinding protected override bool OnHover(InputState state) { - this.FadeEdgeEffectTo(1, transition_time, Easing.OutQuint); + FadeEdgeEffectTo(1, transition_time, Easing.OutQuint); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { - this.FadeEdgeEffectTo(0, transition_time, Easing.OutQuint); + FadeEdgeEffectTo(0, transition_time, Easing.OutQuint); base.OnHoverLost(state); } From 06c392d6f2690a4f34d895b775c61f2326dde344 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:09:07 +0900 Subject: [PATCH 033/107] Update OsuMenu in line with framework. --- osu-framework | 2 +- osu.Game/Graphics/UserInterface/OsuMenu.cs | 23 ++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/osu-framework b/osu-framework index da5fbf8c58..5a189d1050 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit da5fbf8c580b079671298f6da54be10a00bf434c +Subproject commit 5a189d1050579b217bfe6b6c17c3ee6d6ef9c839 diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index e597bc44b5..79519e26a0 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -5,28 +5,39 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { - public class OsuMenu : Menu + public class OsuMenu : Menu + where TItem : MenuItem { public OsuMenu() { CornerRadius = 4; - Background.Colour = Color4.Black.Opacity(0.5f); - - ItemsContainer.Padding = new MarginPadding(5); + BackgroundColour = Color4.Black.Opacity(0.5f); } protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint); - protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint); - protected override void UpdateContentHeight() + protected override void UpdateMenuHeight() { var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight; this.ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, Easing.OutQuint); } + + protected override FlowContainer CreateItemsFlow() + { + var flow = base.CreateItemsFlow(); + flow.Padding = new MarginPadding(5); + + return flow; + } + } + + public class OsuMenu : OsuMenu + { } } From 7467d24d35849fa9dbfe9b69530f5ca7a91d6447 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:10:12 +0900 Subject: [PATCH 034/107] Update OsuContextMenu in line with framework. --- .../Graphics/UserInterface/OsuContextMenu.cs | 149 +++++++++++++++--- .../UserInterface/OsuContextMenuItem.cs | 107 ++----------- 2 files changed, 133 insertions(+), 123 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs index d4882cce1e..ddb91d42a1 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs @@ -1,52 +1,151 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { - public class OsuContextMenu : ContextMenu - where TItem : ContextMenuItem + public class OsuContextMenu : OsuMenu + where TItem : OsuContextMenuItem { - protected override Menu CreateMenu() => new CustomMenu(); + private const int fade_duration = 250; - public class CustomMenu : Menu + public OsuContextMenu() { - private const int fade_duration = 250; - - public CustomMenu() + CornerRadius = 5; + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.1f), + Radius = 4, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.ContextMenuGray; + } + + protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint); + protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint); + + protected override FlowContainer CreateItemsFlow() + { + var flow = base.CreateItemsFlow(); + flow.Padding = new MarginPadding { Vertical = OsuContextMenuItemRepresentation.MARGIN_VERTICAL }; + + return flow; + } + + protected override MenuItemRepresentation CreateMenuItemRepresentation(TItem model) => new OsuContextMenuItemRepresentation(this, model); + + #region OsuContextMenuItemRepresentation + private class OsuContextMenuItemRepresentation : MenuItemRepresentation + { + private const int margin_horizontal = 17; + private const int text_size = 17; + private const int transition_length = 80; + public const int MARGIN_VERTICAL = 4; + + private SampleChannel sampleClick; + private SampleChannel sampleHover; + + private OsuSpriteText text; + private OsuSpriteText textBold; + + public OsuContextMenuItemRepresentation(Menu menu, TItem model) + : base(menu, model) { - CornerRadius = 5; - ItemsContainer.Padding = new MarginPadding { Vertical = OsuContextMenuItem.MARGIN_VERTICAL }; - Masking = true; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.1f), - Radius = 4, - }; } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(AudioManager audio) { - Background.Colour = colours.ContextMenuGray; + sampleHover = audio.Sample.Get(@"UI/generic-hover"); + sampleClick = audio.Sample.Get(@"UI/generic-click"); + + BackgroundColour = Color4.Transparent; + BackgroundColourHover = OsuColour.FromHex(@"172023"); + + updateTextColour(); } - protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint); - protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint); - - protected override void UpdateContentHeight() + private void updateTextColour() { - var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight; - this.ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, Easing.OutQuint); + switch (Model.Type) + { + case MenuItemType.Standard: + textBold.Colour = text.Colour = Color4.White; + break; + case MenuItemType.Destructive: + textBold.Colour = text.Colour = Color4.Red; + break; + case MenuItemType.Highlighted: + textBold.Colour = text.Colour = OsuColour.FromHex(@"ffcc22"); + break; + } } + + protected override bool OnHover(InputState state) + { + sampleHover.Play(); + textBold.FadeIn(transition_length, Easing.OutQuint); + text.FadeOut(transition_length, Easing.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + textBold.FadeOut(transition_length, Easing.OutQuint); + text.FadeIn(transition_length, Easing.OutQuint); + base.OnHoverLost(state); + } + + protected override bool OnClick(InputState state) + { + sampleClick.Play(); + return base.OnClick(state); + } + + protected override Drawable CreateText(string title) => new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Children = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = text_size, + Text = title, + Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, + }, + textBold = new OsuSpriteText + { + AlwaysPresent = true, + Alpha = 0, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = text_size, + Text = title, + Font = @"Exo2.0-Bold", + Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, + } + } + }; } + #endregion } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs index 196e905bdc..bf00208b88 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs @@ -1,114 +1,25 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; +using System; using osu.Framework.Graphics.UserInterface; -using osu.Framework.Input; -using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { - public class OsuContextMenuItem : ContextMenuItem + public class OsuContextMenuItem : MenuItem { - private const int transition_length = 80; - private const int margin_horizontal = 17; - public const int MARGIN_VERTICAL = 4; - private const int text_size = 17; + public readonly MenuItemType Type; - private OsuSpriteText text; - private OsuSpriteText textBold; - - private SampleChannel sampleClick; - private SampleChannel sampleHover; - - private readonly MenuItemType type; - - protected override Container CreateTextContainer(string title) => new Container + public OsuContextMenuItem(string text, MenuItemType type = MenuItemType.Standard) + : base(text) { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Children = new Drawable[] - { - text = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = text_size, - Text = title, - Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, - }, - textBold = new OsuSpriteText - { - AlwaysPresent = true, - Alpha = 0, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = text_size, - Text = title, - Font = @"Exo2.0-Bold", - Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, - } - } - }; - - public OsuContextMenuItem(string title, MenuItemType type = MenuItemType.Standard) : base(title) - { - this.type = type; + Type = type; } - [BackgroundDependencyLoader] - private void load(AudioManager audio) + public OsuContextMenuItem(string text, MenuItemType type, Action action) + : base(text, action) { - sampleHover = audio.Sample.Get(@"UI/generic-hover"); - sampleClick = audio.Sample.Get(@"UI/generic-click"); - - BackgroundColour = Color4.Transparent; - BackgroundColourHover = OsuColour.FromHex(@"172023"); - - updateTextColour(); - } - - private void updateTextColour() - { - switch (type) - { - case MenuItemType.Standard: - textBold.Colour = text.Colour = Color4.White; - break; - case MenuItemType.Destructive: - textBold.Colour = text.Colour = Color4.Red; - break; - case MenuItemType.Highlighted: - textBold.Colour = text.Colour = OsuColour.FromHex(@"ffcc22"); - break; - } - } - - protected override bool OnHover(InputState state) - { - sampleHover.Play(); - textBold.FadeIn(transition_length, Easing.OutQuint); - text.FadeOut(transition_length, Easing.OutQuint); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - textBold.FadeOut(transition_length, Easing.OutQuint); - text.FadeIn(transition_length, Easing.OutQuint); - base.OnHoverLost(state); - } - - protected override bool OnClick(InputState state) - { - sampleClick.Play(); - return base.OnClick(state); + Type = type; } } } \ No newline at end of file From 4fb95706184c4b5310daf96b3c6c76bfeb28dfbc Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:10:29 +0900 Subject: [PATCH 035/107] Create IHasOsuContextMenu and update OsuContextMenuContainer in line with framework. --- .../Visual/TestCaseContextMenu.cs | 19 +++++++++---------- .../Graphics/Cursor/IHasOsuContextMenu.cs | 9 +++++++++ .../Cursor/OsuContextMenuContainer.cs | 4 ++-- osu.Game/osu.Game.csproj | 1 + 4 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs diff --git a/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs b/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs index f0894f794a..2ac3a28bd4 100644 --- a/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs +++ b/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs @@ -3,9 +3,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; @@ -67,9 +66,9 @@ namespace osu.Desktop.Tests.Visual ); } - private class MyContextMenuContainer : Container, IHasContextMenu + private class MyContextMenuContainer : Container, IHasOsuContextMenu { - public ContextMenuItem[] ContextMenuItems => new ContextMenuItem[] + public OsuContextMenuItem[] ContextMenuItems => new[] { new OsuContextMenuItem(@"Some option"), new OsuContextMenuItem(@"Highlighted option", MenuItemType.Highlighted), @@ -81,16 +80,16 @@ namespace osu.Desktop.Tests.Visual }; } - private class AnotherContextMenuContainer : Container, IHasContextMenu + private class AnotherContextMenuContainer : Container, IHasOsuContextMenu { - public ContextMenuItem[] ContextMenuItems => new ContextMenuItem[] + public OsuContextMenuItem[] ContextMenuItems => new[] { new OsuContextMenuItem(@"Simple option"), new OsuContextMenuItem(@"Simple very very long option"), - new OsuContextMenuItem(@"Change width", MenuItemType.Highlighted) { Action = () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint) }, - new OsuContextMenuItem(@"Change height", MenuItemType.Highlighted) { Action = () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint) }, - new OsuContextMenuItem(@"Change width back", MenuItemType.Destructive) { Action = () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint) }, - new OsuContextMenuItem(@"Change height back", MenuItemType.Destructive) { Action = () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint) }, + new OsuContextMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)), + new OsuContextMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)), + new OsuContextMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)), + new OsuContextMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)), }; } } diff --git a/osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs b/osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs new file mode 100644 index 0000000000..6fb1a3d31f --- /dev/null +++ b/osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs @@ -0,0 +1,9 @@ +using osu.Framework.Graphics.Cursor; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Graphics.Cursor +{ + public interface IHasOsuContextMenu : IHasContextMenu + { + } +} diff --git a/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs b/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs index 9162fd6893..4ee3e31707 100644 --- a/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs @@ -7,8 +7,8 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Graphics.Cursor { - public class OsuContextMenuContainer : ContextMenuContainer + public class OsuContextMenuContainer : ContextMenuContainer { - protected override ContextMenu CreateContextMenu() => new OsuContextMenu(); + protected override Menu CreateMenu() => new OsuContextMenu(); } } \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 97cf1db803..0c710fd242 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -84,6 +84,7 @@ + From b42c9d21fe6922c5733366d43aec415f9a0206ff Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:57:43 +0900 Subject: [PATCH 036/107] Update LoginSettings in line with framework. --- osu-framework | 2 +- .../Sections/General/LoginSettings.cs | 90 ++++++++++++------- 2 files changed, 57 insertions(+), 35 deletions(-) diff --git a/osu-framework b/osu-framework index 5a189d1050..2f0674792a 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 5a189d1050579b217bfe6b6c17c3ee6d6ef9c839 +Subproject commit 2f0674792adaf123dcf44ea0099c5707df4a6d60 diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 7ae45159d9..111dba7151 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -257,9 +257,15 @@ namespace osu.Game.Overlays.Settings.Sections.General private class UserDropdown : OsuEnumDropdown { - protected override DropdownHeader CreateHeader() => new UserDropdownHeader { AccentColour = AccentColour }; - protected override Menu CreateMenu() => new UserDropdownMenu(); - protected override DropdownMenuItem CreateMenuItem(string text, UserAction value) => new UserDropdownMenuItem(text, value) { AccentColour = AccentColour }; + protected override DropdownHeader CreateHeader() + { + var newHeader = new UserDropdownHeader(); + newHeader.AccentColour.BindTo(AccentColour); + + return newHeader; + } + + protected override DropdownMenu CreateMenu() => new UserDropdownMenu(); public Color4 StatusColour { @@ -274,7 +280,52 @@ namespace osu.Game.Overlays.Settings.Sections.General [BackgroundDependencyLoader] private void load(OsuColour colours) { - AccentColour = colours.Gray5; + AccentColour.Value = colours.Gray5; + } + + private class UserDropdownMenu : OsuDropdownMenu + { + public UserDropdownMenu() + { + Masking = true; + CornerRadius = 5; + + Margin = new MarginPadding { Bottom = 5 }; + + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Gray3; + } + + protected override FlowContainer CreateItemsFlow() + { + var flow = base.CreateItemsFlow(); + flow.Padding = new MarginPadding(0); + + return flow; + } + + protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem model) => new UserDropdownMenuItem(this, model); + + private class UserDropdownMenuItem : OsuDropdownMenuItemRepresentation + { + public UserDropdownMenuItem(Menu> menu, DropdownMenuItem model) + : base(menu, model) + { + Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 }; + Label.Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 }; + CornerRadius = 5; + } + } } private class UserDropdownHeader : OsuDropdownHeader @@ -324,38 +375,9 @@ namespace osu.Game.Overlays.Settings.Sections.General } } - private class UserDropdownMenu : OsuMenu - { - public UserDropdownMenu() - { - Margin = new MarginPadding { Bottom = 5 }; - CornerRadius = 5; - ItemsContainer.Padding = new MarginPadding(0); - Masking = true; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.25f), - Radius = 4, - }; - } - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Background.Colour = colours.Gray3; - } - } - private class UserDropdownMenuItem : OsuDropdownMenuItem - { - public UserDropdownMenuItem(string text, UserAction current) : base(text, current) - { - Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 }; - Label.Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 }; - CornerRadius = 5; - } - } + } private enum UserAction From 923ffae42c3cbd6403380756474f78cccc2c4e34 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:57:55 +0900 Subject: [PATCH 037/107] Update SlimEnumDropdown in line with framework --- .../Overlays/SearchableList/SlimEnumDropdown.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs b/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs index 38e3e44911..e68cddb293 100644 --- a/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs +++ b/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs @@ -12,8 +12,15 @@ namespace osu.Game.Overlays.SearchableList { public class SlimEnumDropdown : OsuEnumDropdown { - protected override DropdownHeader CreateHeader() => new SlimDropdownHeader { AccentColour = AccentColour }; - protected override Menu CreateMenu() => new SlimMenu(); + protected override DropdownHeader CreateHeader() + { + var newHeader = new SlimDropdownHeader(); + newHeader.AccentColour.BindTo(AccentColour); + + return newHeader; + } + + protected override DropdownMenu CreateMenu() => new SlimMenu(); private class SlimDropdownHeader : OsuDropdownHeader { @@ -31,11 +38,11 @@ namespace osu.Game.Overlays.SearchableList } } - private class SlimMenu : OsuMenu + private class SlimMenu : OsuDropdownMenu { public SlimMenu() { - Background.Colour = Color4.Black.Opacity(0.7f); + BackgroundColour = Color4.Black.Opacity(0.7f); } } } From e83a554ffc311f03d73a53551b752395957d47a5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:58:09 +0900 Subject: [PATCH 038/107] Update CollectionsDropdown in line with framework --- .../Overlays/Music/CollectionsDropdown.cs | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/osu.Game/Overlays/Music/CollectionsDropdown.cs b/osu.Game/Overlays/Music/CollectionsDropdown.cs index 0c0a636be8..be72d4481a 100644 --- a/osu.Game/Overlays/Music/CollectionsDropdown.cs +++ b/osu.Game/Overlays/Music/CollectionsDropdown.cs @@ -15,13 +15,41 @@ namespace osu.Game.Overlays.Music { public class CollectionsDropdown : OsuDropdown { - protected override DropdownHeader CreateHeader() => new CollectionsHeader { AccentColour = AccentColour }; - protected override Menu CreateMenu() => new CollectionsMenu(); - [BackgroundDependencyLoader] private void load(OsuColour colours) { - AccentColour = colours.Gray6; + AccentColour.Value = colours.Gray6; + } + + protected override DropdownHeader CreateHeader() + { + var newHeader = new CollectionsHeader(); + newHeader.AccentColour.BindTo(AccentColour); + + return newHeader; + } + + protected override DropdownMenu CreateMenu() => new CollectionsMenu(); + + private class CollectionsMenu : OsuDropdownMenu + { + public CollectionsMenu() + { + CornerRadius = 5; + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.3f), + Radius = 3, + Offset = new Vector2(0f, 1f), + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Gray4; + } } private class CollectionsHeader : OsuDropdownHeader @@ -48,26 +76,5 @@ namespace osu.Game.Overlays.Music }; } } - - private class CollectionsMenu : OsuMenu - { - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Background.Colour = colours.Gray4; - } - - public CollectionsMenu() - { - CornerRadius = 5; - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.3f), - Radius = 3, - Offset = new Vector2(0f, 1f), - }; - } - } } } From a3a5a89636d4cf93b3c8872d62d9cb9d2aa674ca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:58:21 +0900 Subject: [PATCH 039/107] Update OsuDropdown in line with framework --- .../Graphics/UserInterface/OsuDropdown.cs | 165 ++++++++++-------- 1 file changed, 89 insertions(+), 76 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index f5a4219707..d556c58bdd 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -1,9 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -16,52 +16,96 @@ namespace osu.Game.Graphics.UserInterface { public class OsuDropdown : Dropdown { - protected override DropdownHeader CreateHeader() => new OsuDropdownHeader { AccentColour = AccentColour }; - - protected override Menu CreateMenu() => new OsuMenu(); - - private Color4? accentColour; - public virtual Color4 AccentColour - { - get { return accentColour.GetValueOrDefault(); } - set - { - accentColour = value; - if (Header != null) - ((OsuDropdownHeader)Header).AccentColour = value; - foreach (var item in MenuItems.OfType()) - item.AccentColour = value; - } - } + public readonly Bindable AccentColour = new Bindable(); [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (accentColour == null) - AccentColour = colours.PinkDarker; + if (AccentColour.Value == null) + AccentColour.Value = colours.PinkDarker; } - protected override DropdownMenuItem CreateMenuItem(string text, T value) => new OsuDropdownMenuItem(text, value) { AccentColour = AccentColour }; - - public class OsuDropdownMenuItem : DropdownMenuItem + protected override DropdownHeader CreateHeader() { - public OsuDropdownMenuItem(string text, T current) : base(text, current) + var newHeader = new OsuDropdownHeader(); + newHeader.AccentColour.BindTo(AccentColour); + + return newHeader; + } + + protected override DropdownMenu CreateMenu() + { + var newMenu = new OsuDropdownMenu(); + newMenu.AccentColour.BindTo(AccentColour); + + return newMenu; + } + + #region OsuDropdownMenu + protected class OsuDropdownMenu : DropdownMenu + { + public readonly Bindable AccentColour = new Bindable(); + + protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem model) { - Foreground.Padding = new MarginPadding(2); + var newItem = new OsuDropdownMenuItemRepresentation(this, model); + newItem.AccentColour.BindTo(AccentColour); - Masking = true; - CornerRadius = 6; + return newItem; + } - Children = new[] + #region OsuDropdownMenuItemRepresentation + protected class OsuDropdownMenuItemRepresentation : DropdownMenuItemRepresentation + { + public readonly Bindable AccentColour = new Bindable(); + + private SpriteIcon chevron; + protected OsuSpriteText Label; + + private Color4 nonAccentHoverColour; + private Color4 nonAccentSelectedColour; + + public OsuDropdownMenuItemRepresentation(Menu> menu, DropdownMenuItem model) + : base(menu, model) { - new FillFlowContainer + Foreground.Padding = new MarginPadding(2); + + Masking = true; + CornerRadius = 6; + + AccentColour.ValueChanged += updateAccent; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = Color4.Transparent; + nonAccentHoverColour = colours.PinkDarker; + nonAccentSelectedColour = Color4.Black.Opacity(0.5f); + } + + private void updateAccent(Color4? newValue) + { + BackgroundColourHover = newValue ?? nonAccentHoverColour; + BackgroundColourSelected = newValue ?? nonAccentSelectedColour; + AnimateBackground(IsHovered); + AnimateForeground(IsHovered); + } + + protected override void AnimateForeground(bool hover) + { + base.AnimateForeground(hover); + chevron.Alpha = hover ? 1 : 0; + } + + protected override Drawable CreateText(string title) => new FillFlowContainer { Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Children = new Drawable[] { - Chevron = new SpriteIcon + chevron = new SpriteIcon { AlwaysPresent = true, Icon = FontAwesome.fa_chevron_right, @@ -72,47 +116,18 @@ namespace osu.Game.Graphics.UserInterface Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, }, - Label = new OsuSpriteText { - Text = text, + Label = new OsuSpriteText + { + Text = title, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, } } - } - }; - } - - private Color4? accentColour; - - protected readonly SpriteIcon Chevron; - protected readonly OsuSpriteText Label; - - protected override void FormatForeground(bool hover = false) - { - base.FormatForeground(hover); - Chevron.Alpha = hover ? 1 : 0; - } - - public Color4 AccentColour - { - get { return accentColour.GetValueOrDefault(); } - set - { - accentColour = value; - BackgroundColourHover = BackgroundColourSelected = value; - FormatBackground(); - FormatForeground(); - } - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - BackgroundColour = Color4.Transparent; - BackgroundColourHover = accentColour ?? colours.PinkDarker; - BackgroundColourSelected = Color4.Black.Opacity(0.5f); + }; } + #endregion } + #endregion public class OsuDropdownHeader : DropdownHeader { @@ -125,16 +140,7 @@ namespace osu.Game.Graphics.UserInterface protected readonly SpriteIcon Icon; - private Color4? accentColour; - public virtual Color4 AccentColour - { - get { return accentColour.GetValueOrDefault(); } - set - { - accentColour = value; - BackgroundColourHover = value; - } - } + public readonly Bindable AccentColour = new Bindable(); public OsuDropdownHeader() { @@ -161,13 +167,20 @@ namespace osu.Game.Graphics.UserInterface Size = new Vector2(20), } }; + + AccentColour.ValueChanged += accentColourChanged; } [BackgroundDependencyLoader] private void load(OsuColour colours) { BackgroundColour = Color4.Black.Opacity(0.5f); - BackgroundColourHover = accentColour ?? colours.PinkDarker; + BackgroundColourHover = AccentColour?.Value ?? colours.PinkDarker; + } + + private void accentColourChanged(Color4? newValue) + { + BackgroundColourHover = newValue ?? Color4.White; } } } From ce644138b9f117de9094ffab9cada87a1ebd3df0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:58:30 +0900 Subject: [PATCH 040/107] Update OsuTabControl in line with framework --- .../Graphics/UserInterface/OsuTabControl.cs | 101 ++++++++++-------- 1 file changed, 59 insertions(+), 42 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 5ad412965c..bc673a7af6 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -50,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface accentColour = value; var dropDown = Dropdown as OsuTabDropdown; if (dropDown != null) - dropDown.AccentColour = value; + dropDown.AccentColour.Value = value; foreach (var item in TabContainer.Children.OfType()) item.AccentColour = value; } @@ -142,55 +142,53 @@ namespace osu.Game.Graphics.UserInterface private class OsuTabDropdown : OsuDropdown { - protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader - { - AccentColour = AccentColour, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - }; - - protected override DropdownMenuItem CreateMenuItem(string text, T value) - { - var item = base.CreateMenuItem(text, value); - item.ForegroundColourHover = Color4.Black; - return item; - } - public OsuTabDropdown() { - DropdownMenu.Anchor = Anchor.TopRight; - DropdownMenu.Origin = Anchor.TopRight; - RelativeSizeAxes = Axes.X; - DropdownMenu.Background.Colour = Color4.Black.Opacity(0.7f); - DropdownMenu.MaxHeight = 400; + + } + + protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu(); + + protected override DropdownHeader CreateHeader() + { + var newHeader = new OsuTabDropdownHeader + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight + }; + + newHeader.AccentColour.BindTo(AccentColour); + + return newHeader; + } + + private class OsuTabDropdownMenu : OsuDropdownMenu + { + public OsuTabDropdownMenu() + { + Anchor = Anchor.TopRight; + Origin = Anchor.TopRight; + + BackgroundColour = Color4.Black.Opacity(0.7f); + MaxHeight = 400; + } + + protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem model) => new OsuTabDropdownMenuItemRepresentation(this, model); + + private class OsuTabDropdownMenuItemRepresentation : OsuDropdownMenuItemRepresentation + { + public OsuTabDropdownMenuItemRepresentation(Menu> menu, DropdownMenuItem model) + : base(menu, model) + { + ForegroundColourHover = Color4.Black; + } + } } protected class OsuTabDropdownHeader : OsuDropdownHeader { - public override Color4 AccentColour - { - get { return base.AccentColour; } - set - { - base.AccentColour = value; - Foreground.Colour = value; - } - } - - protected override bool OnHover(InputState state) - { - Foreground.Colour = BackgroundColour; - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - Foreground.Colour = BackgroundColourHover; - base.OnHoverLost(state); - } - public OsuTabDropdownHeader() { RelativeSizeAxes = Axes.None; @@ -219,6 +217,25 @@ namespace osu.Game.Graphics.UserInterface }; Padding = new MarginPadding { Left = 5, Right = 5 }; + + AccentColour.ValueChanged += accentColourChanged; + } + + private void accentColourChanged(Color4? newValue) + { + Foreground.Colour = newValue ?? Color4.White; + } + + protected override bool OnHover(InputState state) + { + Foreground.Colour = BackgroundColour; + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + Foreground.Colour = BackgroundColourHover; + base.OnHoverLost(state); } } } From 9f02000174808c0f99f4d97035305e94a1aaa6d2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 15:58:42 +0900 Subject: [PATCH 041/107] Update FilterControl using new AccentColour definition --- osu.Game/Overlays/Direct/FilterControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 28d26d0641..ca9e8667e6 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader(true)] private void load(OsuGame game, RulesetStore rulesets, OsuColour colours) { - DisplayStyleControl.Dropdown.AccentColour = colours.BlueDark; + DisplayStyleControl.Dropdown.AccentColour.Value = colours.BlueDark; Ruleset.BindTo(game?.Ruleset ?? new Bindable { Value = rulesets.GetRuleset(0) }); foreach (var r in rulesets.AllRulesets) From 3ffc46770472e1d91f2a160350f46e521f0147f7 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 25 Aug 2017 16:27:01 +0900 Subject: [PATCH 042/107] Fix crappy resizing. --- osu-framework | 2 +- osu.Game/Graphics/UserInterface/OsuMenu.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index 2f0674792a..56ce220e7f 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2f0674792adaf123dcf44ea0099c5707df4a6d60 +Subproject commit 56ce220e7f631ce2890597e505d073cdfc0233a1 diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index 79519e26a0..45bee216ad 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface protected override void UpdateMenuHeight() { var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight; - this.ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, Easing.OutQuint); + this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint); } protected override FlowContainer CreateItemsFlow() From ee85515d951846d1cdd5241c89ec47a77a5efa10 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 18:41:12 +0900 Subject: [PATCH 043/107] Changes in line with framework changes --- osu-framework | 2 +- .../Graphics/UserInterface/OsuContextMenu.cs | 26 ++++------ .../Graphics/UserInterface/OsuDropdown.cs | 48 ++++++++++++++----- osu.Game/Graphics/UserInterface/OsuMenu.cs | 14 +----- .../Graphics/UserInterface/OsuTabControl.cs | 32 ++++++++----- .../Sections/General/LoginSettings.cs | 20 +++----- 6 files changed, 75 insertions(+), 67 deletions(-) diff --git a/osu-framework b/osu-framework index 56ce220e7f..926d7c971d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 56ce220e7f631ce2890597e505d073cdfc0233a1 +Subproject commit 926d7c971d059c7aeb3ccfb09d06910c46aa3a40 diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs index ddb91d42a1..ad4cd1edbc 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs @@ -39,18 +39,12 @@ namespace osu.Game.Graphics.UserInterface protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint); protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint); - protected override FlowContainer CreateItemsFlow() - { - var flow = base.CreateItemsFlow(); - flow.Padding = new MarginPadding { Vertical = OsuContextMenuItemRepresentation.MARGIN_VERTICAL }; + protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Vertical = DrawableOsuContextMenuItem.MARGIN_VERTICAL }; - return flow; - } + protected override DrawableMenuItem CreateDrawableMenuItem(TItem item) => new DrawableOsuContextMenuItem(this, item); - protected override MenuItemRepresentation CreateMenuItemRepresentation(TItem model) => new OsuContextMenuItemRepresentation(this, model); - - #region OsuContextMenuItemRepresentation - private class OsuContextMenuItemRepresentation : MenuItemRepresentation + #region DrawableOsuContextMenuItem + private class DrawableOsuContextMenuItem : DrawableMenuItem { private const int margin_horizontal = 17; private const int text_size = 17; @@ -63,8 +57,8 @@ namespace osu.Game.Graphics.UserInterface private OsuSpriteText text; private OsuSpriteText textBold; - public OsuContextMenuItemRepresentation(Menu menu, TItem model) - : base(menu, model) + public DrawableOsuContextMenuItem(Menu menu, TItem item) + : base(item) { } @@ -82,7 +76,7 @@ namespace osu.Game.Graphics.UserInterface private void updateTextColour() { - switch (Model.Type) + switch (Item.Type) { case MenuItemType.Standard: textBold.Colour = text.Colour = Color4.White; @@ -117,7 +111,7 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - protected override Drawable CreateText(string title) => new Container + protected override Drawable CreateContent() => new Container { AutoSizeAxes = Axes.Both, Anchor = Anchor.CentreLeft, @@ -129,7 +123,7 @@ namespace osu.Game.Graphics.UserInterface Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, TextSize = text_size, - Text = title, + Text = Item.Text, Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, }, textBold = new OsuSpriteText @@ -139,7 +133,7 @@ namespace osu.Game.Graphics.UserInterface Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, TextSize = text_size, - Text = title, + Text = Item.Text, Font = @"Exo2.0-Bold", Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, } diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index d556c58bdd..2c691b7763 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -44,18 +44,40 @@ namespace osu.Game.Graphics.UserInterface #region OsuDropdownMenu protected class OsuDropdownMenu : DropdownMenu { + // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring + public OsuDropdownMenu() + { + CornerRadius = 4; + BackgroundColour = Color4.Black.Opacity(0.5f); + } + + // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring + protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint); + protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint); + + // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring + protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(5); + + // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring + protected override void UpdateMenuHeight() + { + var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight; + this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint); + } + public readonly Bindable AccentColour = new Bindable(); - protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem model) + + protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem item) { - var newItem = new OsuDropdownMenuItemRepresentation(this, model); + var newItem = new DrawableOsuDropdownMenuItem(item); newItem.AccentColour.BindTo(AccentColour); return newItem; } - #region OsuDropdownMenuItemRepresentation - protected class OsuDropdownMenuItemRepresentation : DropdownMenuItemRepresentation + #region DrawableOsuDropdownMenuItem + protected class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem { public readonly Bindable AccentColour = new Bindable(); @@ -65,8 +87,8 @@ namespace osu.Game.Graphics.UserInterface private Color4 nonAccentHoverColour; private Color4 nonAccentSelectedColour; - public OsuDropdownMenuItemRepresentation(Menu> menu, DropdownMenuItem model) - : base(menu, model) + public DrawableOsuDropdownMenuItem(DropdownMenuItem item) + : base(item) { Foreground.Padding = new MarginPadding(2); @@ -88,17 +110,17 @@ namespace osu.Game.Graphics.UserInterface { BackgroundColourHover = newValue ?? nonAccentHoverColour; BackgroundColourSelected = newValue ?? nonAccentSelectedColour; - AnimateBackground(IsHovered); - AnimateForeground(IsHovered); + UpdateBackgroundColour(); + UpdateForegroundColour(); } - protected override void AnimateForeground(bool hover) + protected override void UpdateForegroundColour() { - base.AnimateForeground(hover); - chevron.Alpha = hover ? 1 : 0; + base.UpdateForegroundColour(); + chevron.Alpha = IsHovered ? 1 : 0; } - protected override Drawable CreateText(string title) => new FillFlowContainer + protected override Drawable CreateContent() => new FillFlowContainer { Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X, @@ -118,7 +140,7 @@ namespace osu.Game.Graphics.UserInterface }, Label = new OsuSpriteText { - Text = title, + Text = Item.Text, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, } diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index 45bee216ad..0c5bfa2947 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -1,11 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface @@ -28,16 +26,6 @@ namespace osu.Game.Graphics.UserInterface this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint); } - protected override FlowContainer CreateItemsFlow() - { - var flow = base.CreateItemsFlow(); - flow.Padding = new MarginPadding(5); - - return flow; - } - } - - public class OsuMenu : OsuMenu - { + protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(5); } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index bc673a7af6..58d853d97e 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -48,9 +48,9 @@ namespace osu.Game.Graphics.UserInterface set { accentColour = value; - var dropDown = Dropdown as OsuTabDropdown; - if (dropDown != null) - dropDown.AccentColour.Value = value; + var dropdown = Dropdown as OsuTabDropdown; + if (dropdown != null) + dropdown.AccentColour.Value = value; foreach (var item in TabContainer.Children.OfType()) item.AccentColour = value; } @@ -140,16 +140,20 @@ namespace osu.Game.Graphics.UserInterface protected override void OnDeactivated() => fadeInactive(); } + // todo: this needs to go private class OsuTabDropdown : OsuDropdown { public OsuTabDropdown() { RelativeSizeAxes = Axes.X; - - } - protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu(); + protected override DropdownMenu CreateMenu() + { + var menu = new OsuTabDropdownMenu(); + menu.AccentColour.BindTo(AccentColour); + return menu; + } protected override DropdownHeader CreateHeader() { @@ -175,18 +179,24 @@ namespace osu.Game.Graphics.UserInterface MaxHeight = 400; } - protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem model) => new OsuTabDropdownMenuItemRepresentation(this, model); - - private class OsuTabDropdownMenuItemRepresentation : OsuDropdownMenuItemRepresentation + protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem item) { - public OsuTabDropdownMenuItemRepresentation(Menu> menu, DropdownMenuItem model) - : base(menu, model) + var poop = new DrawableOsuTabDropdownMenuItem(this, item); + poop.AccentColour.BindTo(AccentColour); + return poop; + } + + private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem + { + public DrawableOsuTabDropdownMenuItem(Menu> menu, DropdownMenuItem item) + : base(item) { ForegroundColourHover = Color4.Black; } } } + protected class OsuTabDropdownHeader : OsuDropdownHeader { public OsuTabDropdownHeader() diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 111dba7151..ad7c7cf092 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -306,20 +306,14 @@ namespace osu.Game.Overlays.Settings.Sections.General BackgroundColour = colours.Gray3; } - protected override FlowContainer CreateItemsFlow() + protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(); + + protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem item) => new DrawableUserDropdownMenuItem(this, item); + + private class DrawableUserDropdownMenuItem : DrawableOsuDropdownMenuItem { - var flow = base.CreateItemsFlow(); - flow.Padding = new MarginPadding(0); - - return flow; - } - - protected override MenuItemRepresentation CreateMenuItemRepresentation(DropdownMenuItem model) => new UserDropdownMenuItem(this, model); - - private class UserDropdownMenuItem : OsuDropdownMenuItemRepresentation - { - public UserDropdownMenuItem(Menu> menu, DropdownMenuItem model) - : base(menu, model) + public DrawableUserDropdownMenuItem(Menu> menu, DropdownMenuItem item) + : base(item) { Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 }; Label.Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 }; From 9374bf925ef2771cb74a9f94cec78fe219d57858 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 25 Aug 2017 16:39:49 +0200 Subject: [PATCH 044/107] only show warning when focused --- .../Graphics/UserInterface/OsuPasswordTextBox.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs index 2fdbf64d08..c3cc4fe77b 100644 --- a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs @@ -44,10 +44,24 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Key == OpenTK.Input.Key.CapsLock) - warning.FadeTo(host.CapsLockEnabled ? 1 : 0, 250, Easing.OutQuint); + updateCapsWarning(host.CapsLockEnabled); return base.OnKeyDown(state, args); } + protected override void OnFocus(InputState state) + { + updateCapsWarning(host.CapsLockEnabled); + base.OnFocus(state); + } + + protected override void OnFocusLost(InputState state) + { + updateCapsWarning(false); + base.OnFocusLost(state); + } + + private void updateCapsWarning(bool visible) => warning.FadeTo(visible ? 1 : 0, 250, Easing.OutQuint); + public class PasswordMaskChar : Container { private readonly CircularContainer circle; From 4385edeb453103fe817e6af7326046d040dd046b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 28 Aug 2017 11:01:53 +0900 Subject: [PATCH 045/107] Update usages of Menu to reflect ValueChanged events. --- osu-framework | 2 +- .../Graphics/UserInterface/OsuContextMenu.cs | 59 +++++++++++-------- .../Graphics/UserInterface/OsuDropdown.cs | 50 +++++++++------- 3 files changed, 64 insertions(+), 47 deletions(-) diff --git a/osu-framework b/osu-framework index 926d7c971d..743ad1129e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 926d7c971d059c7aeb3ccfb09d06910c46aa3a40 +Subproject commit 743ad1129edbc1cb8faa14ebc9a6d1846780795c diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs index ad4cd1edbc..9bc2f381c0 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs @@ -111,34 +111,45 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - protected override Drawable CreateContent() => new Container + protected override Drawable CreateContent() { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Children = new Drawable[] + var container = new Container { - text = new OsuSpriteText + AutoSizeAxes = Axes.Both, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Children = new Drawable[] { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = text_size, - Text = Item.Text, - Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, - }, - textBold = new OsuSpriteText - { - AlwaysPresent = true, - Alpha = 0, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = text_size, - Text = Item.Text, - Font = @"Exo2.0-Bold", - Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, + text = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = text_size, + Text = Item.Text, + Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, + }, + textBold = new OsuSpriteText + { + AlwaysPresent = true, + Alpha = 0, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = text_size, + Text = Item.Text, + Font = @"Exo2.0-Bold", + Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, + } } - } - }; + }; + + Item.Text.ValueChanged += newText => + { + text.Text = newText; + textBold.Text = newText; + }; + + return container; + } } #endregion } diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 2c691b7763..8984ba1eba 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -120,32 +120,38 @@ namespace osu.Game.Graphics.UserInterface chevron.Alpha = IsHovered ? 1 : 0; } - protected override Drawable CreateContent() => new FillFlowContainer + protected override Drawable CreateContent() { - Direction = FillDirection.Horizontal, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] + var container = new FillFlowContainer { - chevron = new SpriteIcon + Direction = FillDirection.Horizontal, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] { - AlwaysPresent = true, - Icon = FontAwesome.fa_chevron_right, - Colour = Color4.Black, - Alpha = 0.5f, - Size = new Vector2(8), - Margin = new MarginPadding { Left = 3, Right = 3 }, - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - }, - Label = new OsuSpriteText - { - Text = Item.Text, - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, + chevron = new SpriteIcon + { + AlwaysPresent = true, + Icon = FontAwesome.fa_chevron_right, + Colour = Color4.Black, + Alpha = 0.5f, + Size = new Vector2(8), + Margin = new MarginPadding { Left = 3, Right = 3 }, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + }, + Label = new OsuSpriteText + { + Text = Item.Text, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + } } - } - }; + }; + + Item.Text.ValueChanged += newText => Label.Text = newText; + return container; + } } #endregion } From b5c1c05af5443246a1ec19a4cf09d03a7384ed88 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 28 Aug 2017 11:03:51 +0900 Subject: [PATCH 046/107] Remove poop. --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 58d853d97e..faa7b269bb 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -181,9 +181,9 @@ namespace osu.Game.Graphics.UserInterface protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem item) { - var poop = new DrawableOsuTabDropdownMenuItem(this, item); - poop.AccentColour.BindTo(AccentColour); - return poop; + var result = new DrawableOsuTabDropdownMenuItem(this, item); + result.AccentColour.BindTo(AccentColour); + return result; } private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem From 66db3389f6f8f7ce58e42fb008980fb923739366 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 28 Aug 2017 12:33:31 +0900 Subject: [PATCH 047/107] Update in line with framework changes. --- osu-framework | 2 +- .../Graphics/UserInterface/OsuContextMenu.cs | 63 ++++++++++--------- .../Graphics/UserInterface/OsuDropdown.cs | 38 ++++++----- .../Sections/General/LoginSettings.cs | 6 +- 4 files changed, 64 insertions(+), 45 deletions(-) diff --git a/osu-framework b/osu-framework index 743ad1129e..2958d6fda1 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 743ad1129edbc1cb8faa14ebc9a6d1846780795c +Subproject commit 2958d6fda1be252a0f479609090e72814b177c91 diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs index 9bc2f381c0..4ec349edd7 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs @@ -8,6 +8,7 @@ using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; @@ -54,8 +55,7 @@ namespace osu.Game.Graphics.UserInterface private SampleChannel sampleClick; private SampleChannel sampleHover; - private OsuSpriteText text; - private OsuSpriteText textBold; + private TextContainer text; public DrawableOsuContextMenuItem(Menu menu, TItem item) : base(item) @@ -79,13 +79,13 @@ namespace osu.Game.Graphics.UserInterface switch (Item.Type) { case MenuItemType.Standard: - textBold.Colour = text.Colour = Color4.White; + text.Colour = Color4.White; break; case MenuItemType.Destructive: - textBold.Colour = text.Colour = Color4.Red; + text.Colour = Color4.Red; break; case MenuItemType.Highlighted: - textBold.Colour = text.Colour = OsuColour.FromHex(@"ffcc22"); + text.Colour = OsuColour.FromHex(@"ffcc22"); break; } } @@ -93,15 +93,15 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { sampleHover.Play(); - textBold.FadeIn(transition_length, Easing.OutQuint); - text.FadeOut(transition_length, Easing.OutQuint); + text.BoldText.FadeIn(transition_length, Easing.OutQuint); + text.NormalText.FadeOut(transition_length, Easing.OutQuint); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { - textBold.FadeOut(transition_length, Easing.OutQuint); - text.FadeIn(transition_length, Easing.OutQuint); + text.BoldText.FadeOut(transition_length, Easing.OutQuint); + text.NormalText.FadeIn(transition_length, Easing.OutQuint); base.OnHoverLost(state); } @@ -111,44 +111,51 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - protected override Drawable CreateContent() + protected override Drawable CreateContent() => text = new TextContainer(); + + private class TextContainer : Container, IHasText { - var container = new Container + public string Text { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, + get { return NormalText.Text; } + set + { + NormalText.Text = value; + BoldText.Text = value; + } + } + + public readonly SpriteText NormalText; + public readonly SpriteText BoldText; + + public TextContainer() + { + Anchor = Anchor.CentreLeft; + Origin = Anchor.CentreLeft; + + AutoSizeAxes = Axes.Both; + Children = new Drawable[] { - text = new OsuSpriteText + NormalText = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, TextSize = text_size, - Text = Item.Text, Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, }, - textBold = new OsuSpriteText + BoldText = new OsuSpriteText { AlwaysPresent = true, Alpha = 0, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, TextSize = text_size, - Text = Item.Text, Font = @"Exo2.0-Bold", Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, } - } - }; - - Item.Text.ValueChanged += newText => - { - text.Text = newText; - textBold.Text = newText; - }; - - return container; + }; + } } } #endregion diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 8984ba1eba..d67a995e67 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -81,8 +81,7 @@ namespace osu.Game.Graphics.UserInterface { public readonly Bindable AccentColour = new Bindable(); - private SpriteIcon chevron; - protected OsuSpriteText Label; + private TextContainer textContainer; private Color4 nonAccentHoverColour; private Color4 nonAccentSelectedColour; @@ -117,19 +116,32 @@ namespace osu.Game.Graphics.UserInterface protected override void UpdateForegroundColour() { base.UpdateForegroundColour(); - chevron.Alpha = IsHovered ? 1 : 0; + + textContainer.Chevron.Alpha = IsHovered ? 1 : 0; } - protected override Drawable CreateContent() + protected override Drawable CreateContent() => textContainer = new TextContainer(); + + protected class TextContainer : FillFlowContainer, IHasText { - var container = new FillFlowContainer + public string Text { - Direction = FillDirection.Horizontal, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + get { return Label.Text; } + set { Label.Text = value; } + } + + public readonly OsuSpriteText Label; + public readonly SpriteIcon Chevron; + + public TextContainer() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Horizontal; + Children = new Drawable[] { - chevron = new SpriteIcon + Chevron = new SpriteIcon { AlwaysPresent = true, Icon = FontAwesome.fa_chevron_right, @@ -142,15 +154,11 @@ namespace osu.Game.Graphics.UserInterface }, Label = new OsuSpriteText { - Text = Item.Text, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, } - } - }; - - Item.Text.ValueChanged += newText => Label.Text = newText; - return container; + }; + } } } #endregion diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index ad7c7cf092..609b4b1e16 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -316,9 +316,13 @@ namespace osu.Game.Overlays.Settings.Sections.General : base(item) { Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 }; - Label.Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 }; CornerRadius = 5; } + + protected override Drawable CreateContent() => new TextContainer + { + Label = { Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 } } + }; } } From fc6c682d886b2d93217c57896e08f764e7d810d5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 28 Aug 2017 14:42:52 +0900 Subject: [PATCH 048/107] Update in-line with framework changes. --- osu-framework | 2 +- .../Visual/TestCaseContextMenu.cs | 37 ++++++++++--------- .../Graphics/Cursor/IHasOsuContextMenu.cs | 9 ----- .../Cursor/OsuContextMenuContainer.cs | 4 +- .../Graphics/UserInterface/OsuContextMenu.cs | 12 +++--- .../Graphics/UserInterface/OsuDropdown.cs | 4 +- osu.Game/Graphics/UserInterface/OsuMenu.cs | 3 +- .../{OsuContextMenuItem.cs => OsuMenuItem.cs} | 6 +-- .../Graphics/UserInterface/OsuTabControl.cs | 6 +-- .../Sections/General/LoginSettings.cs | 4 +- osu.Game/osu.Game.csproj | 3 +- 11 files changed, 41 insertions(+), 49 deletions(-) delete mode 100644 osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs rename osu.Game/Graphics/UserInterface/{OsuContextMenuItem.cs => OsuMenuItem.cs} (65%) diff --git a/osu-framework b/osu-framework index 2958d6fda1..2cb3e59c8b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2958d6fda1be252a0f479609090e72814b177c91 +Subproject commit 2cb3e59c8bc7e67edef4dfe7f9c7dfc01db386a7 diff --git a/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs b/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs index 2ac3a28bd4..0d9c5e7ed1 100644 --- a/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs +++ b/osu.Desktop.Tests/Visual/TestCaseContextMenu.cs @@ -3,8 +3,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics.Cursor; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; @@ -66,30 +67,30 @@ namespace osu.Desktop.Tests.Visual ); } - private class MyContextMenuContainer : Container, IHasOsuContextMenu + private class MyContextMenuContainer : Container, IHasContextMenu { - public OsuContextMenuItem[] ContextMenuItems => new[] + public MenuItem[] ContextMenuItems => new MenuItem[] { - new OsuContextMenuItem(@"Some option"), - new OsuContextMenuItem(@"Highlighted option", MenuItemType.Highlighted), - new OsuContextMenuItem(@"Another option"), - new OsuContextMenuItem(@"Choose me please"), - new OsuContextMenuItem(@"And me too"), - new OsuContextMenuItem(@"Trying to fill"), - new OsuContextMenuItem(@"Destructive option", MenuItemType.Destructive), + new OsuMenuItem(@"Some option"), + new OsuMenuItem(@"Highlighted option", MenuItemType.Highlighted), + new OsuMenuItem(@"Another option"), + new OsuMenuItem(@"Choose me please"), + new OsuMenuItem(@"And me too"), + new OsuMenuItem(@"Trying to fill"), + new OsuMenuItem(@"Destructive option", MenuItemType.Destructive), }; } - private class AnotherContextMenuContainer : Container, IHasOsuContextMenu + private class AnotherContextMenuContainer : Container, IHasContextMenu { - public OsuContextMenuItem[] ContextMenuItems => new[] + public MenuItem[] ContextMenuItems => new MenuItem[] { - new OsuContextMenuItem(@"Simple option"), - new OsuContextMenuItem(@"Simple very very long option"), - new OsuContextMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)), - new OsuContextMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)), - new OsuContextMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)), - new OsuContextMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)), + new OsuMenuItem(@"Simple option"), + new OsuMenuItem(@"Simple very very long option"), + new OsuMenuItem(@"Change width", MenuItemType.Highlighted, () => this.ResizeWidthTo(Width * 2, 100, Easing.OutQuint)), + new OsuMenuItem(@"Change height", MenuItemType.Highlighted, () => this.ResizeHeightTo(Height * 2, 100, Easing.OutQuint)), + new OsuMenuItem(@"Change width back", MenuItemType.Destructive, () => this.ResizeWidthTo(Width / 2, 100, Easing.OutQuint)), + new OsuMenuItem(@"Change height back", MenuItemType.Destructive, () => this.ResizeHeightTo(Height / 2, 100, Easing.OutQuint)), }; } } diff --git a/osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs b/osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs deleted file mode 100644 index 6fb1a3d31f..0000000000 --- a/osu.Game/Graphics/Cursor/IHasOsuContextMenu.cs +++ /dev/null @@ -1,9 +0,0 @@ -using osu.Framework.Graphics.Cursor; -using osu.Game.Graphics.UserInterface; - -namespace osu.Game.Graphics.Cursor -{ - public interface IHasOsuContextMenu : IHasContextMenu - { - } -} diff --git a/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs b/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs index 4ee3e31707..1ece10bc60 100644 --- a/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs @@ -7,8 +7,8 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Graphics.Cursor { - public class OsuContextMenuContainer : ContextMenuContainer + public class OsuContextMenuContainer : ContextMenuContainer { - protected override Menu CreateMenu() => new OsuContextMenu(); + protected override Menu CreateMenu() => new OsuContextMenu(); } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs index 4ec349edd7..9a2917cd66 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -15,8 +16,7 @@ using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { - public class OsuContextMenu : OsuMenu - where TItem : OsuContextMenuItem + public class OsuContextMenu : OsuMenu { private const int fade_duration = 250; @@ -42,7 +42,7 @@ namespace osu.Game.Graphics.UserInterface protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Vertical = DrawableOsuContextMenuItem.MARGIN_VERTICAL }; - protected override DrawableMenuItem CreateDrawableMenuItem(TItem item) => new DrawableOsuContextMenuItem(this, item); + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuContextMenuItem(item); #region DrawableOsuContextMenuItem private class DrawableOsuContextMenuItem : DrawableMenuItem @@ -57,9 +57,11 @@ namespace osu.Game.Graphics.UserInterface private TextContainer text; - public DrawableOsuContextMenuItem(Menu menu, TItem item) + public DrawableOsuContextMenuItem(MenuItem item) : base(item) { + if (!(Item is OsuMenuItem)) + throw new ArgumentException($"{nameof(item)} must be a {nameof(OsuMenuItem)}."); } [BackgroundDependencyLoader] @@ -76,7 +78,7 @@ namespace osu.Game.Graphics.UserInterface private void updateTextColour() { - switch (Item.Type) + switch (((OsuMenuItem)Item).Type) { case MenuItemType.Standard: text.Colour = Color4.White; diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index d67a995e67..9c816b8230 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -68,7 +68,7 @@ namespace osu.Game.Graphics.UserInterface public readonly Bindable AccentColour = new Bindable(); - protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem item) + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) { var newItem = new DrawableOsuDropdownMenuItem(item); newItem.AccentColour.BindTo(AccentColour); @@ -86,7 +86,7 @@ namespace osu.Game.Graphics.UserInterface private Color4 nonAccentHoverColour; private Color4 nonAccentSelectedColour; - public DrawableOsuDropdownMenuItem(DropdownMenuItem item) + public DrawableOsuDropdownMenuItem(MenuItem item) : base(item) { Foreground.Padding = new MarginPadding(2); diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index 0c5bfa2947..6b64e9e367 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -8,8 +8,7 @@ using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { - public class OsuMenu : Menu - where TItem : MenuItem + public class OsuMenu : Menu { public OsuMenu() { diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuMenuItem.cs similarity index 65% rename from osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs rename to osu.Game/Graphics/UserInterface/OsuMenuItem.cs index bf00208b88..1f78666d20 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenuItem.cs @@ -6,17 +6,17 @@ using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { - public class OsuContextMenuItem : MenuItem + public class OsuMenuItem : MenuItem { public readonly MenuItemType Type; - public OsuContextMenuItem(string text, MenuItemType type = MenuItemType.Standard) + public OsuMenuItem(string text, MenuItemType type = MenuItemType.Standard) : base(text) { Type = type; } - public OsuContextMenuItem(string text, MenuItemType type, Action action) + public OsuMenuItem(string text, MenuItemType type, Action action) : base(text, action) { Type = type; diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index faa7b269bb..32d2bc7c53 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -179,16 +179,16 @@ namespace osu.Game.Graphics.UserInterface MaxHeight = 400; } - protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem item) + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) { - var result = new DrawableOsuTabDropdownMenuItem(this, item); + var result = new DrawableOsuTabDropdownMenuItem(item); result.AccentColour.BindTo(AccentColour); return result; } private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem { - public DrawableOsuTabDropdownMenuItem(Menu> menu, DropdownMenuItem item) + public DrawableOsuTabDropdownMenuItem(MenuItem item) : base(item) { ForegroundColourHover = Color4.Black; diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 609b4b1e16..cf12c8a8e8 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -308,11 +308,11 @@ namespace osu.Game.Overlays.Settings.Sections.General protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(); - protected override DrawableMenuItem CreateDrawableMenuItem(DropdownMenuItem item) => new DrawableUserDropdownMenuItem(this, item); + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableUserDropdownMenuItem(item); private class DrawableUserDropdownMenuItem : DrawableOsuDropdownMenuItem { - public DrawableUserDropdownMenuItem(Menu> menu, DropdownMenuItem item) + public DrawableUserDropdownMenuItem(MenuItem item) : base(item) { Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 }; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0c710fd242..325cfba986 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -84,7 +84,6 @@ - @@ -92,7 +91,7 @@ - + From 7bf6d4aa656a50e0373cec1d099f69037dc284c1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 28 Aug 2017 15:33:24 +0900 Subject: [PATCH 049/107] Rename DrawableOsuContextMenuItem -> DrawableOsuMenuItem, and move to OsuMenu. --- .../Graphics/UserInterface/OsuContextMenu.cs | 129 +----------------- osu.Game/Graphics/UserInterface/OsuMenu.cs | 126 +++++++++++++++++ 2 files changed, 127 insertions(+), 128 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs index 9a2917cd66..808c72ee5d 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs @@ -1,18 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.UserInterface; -using osu.Framework.Input; -using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { @@ -40,126 +33,6 @@ namespace osu.Game.Graphics.UserInterface protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint); protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint); - protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Vertical = DrawableOsuContextMenuItem.MARGIN_VERTICAL }; - - protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuContextMenuItem(item); - - #region DrawableOsuContextMenuItem - private class DrawableOsuContextMenuItem : DrawableMenuItem - { - private const int margin_horizontal = 17; - private const int text_size = 17; - private const int transition_length = 80; - public const int MARGIN_VERTICAL = 4; - - private SampleChannel sampleClick; - private SampleChannel sampleHover; - - private TextContainer text; - - public DrawableOsuContextMenuItem(MenuItem item) - : base(item) - { - if (!(Item is OsuMenuItem)) - throw new ArgumentException($"{nameof(item)} must be a {nameof(OsuMenuItem)}."); - } - - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - sampleHover = audio.Sample.Get(@"UI/generic-hover"); - sampleClick = audio.Sample.Get(@"UI/generic-click"); - - BackgroundColour = Color4.Transparent; - BackgroundColourHover = OsuColour.FromHex(@"172023"); - - updateTextColour(); - } - - private void updateTextColour() - { - switch (((OsuMenuItem)Item).Type) - { - case MenuItemType.Standard: - text.Colour = Color4.White; - break; - case MenuItemType.Destructive: - text.Colour = Color4.Red; - break; - case MenuItemType.Highlighted: - text.Colour = OsuColour.FromHex(@"ffcc22"); - break; - } - } - - protected override bool OnHover(InputState state) - { - sampleHover.Play(); - text.BoldText.FadeIn(transition_length, Easing.OutQuint); - text.NormalText.FadeOut(transition_length, Easing.OutQuint); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - text.BoldText.FadeOut(transition_length, Easing.OutQuint); - text.NormalText.FadeIn(transition_length, Easing.OutQuint); - base.OnHoverLost(state); - } - - protected override bool OnClick(InputState state) - { - sampleClick.Play(); - return base.OnClick(state); - } - - protected override Drawable CreateContent() => text = new TextContainer(); - - private class TextContainer : Container, IHasText - { - public string Text - { - get { return NormalText.Text; } - set - { - NormalText.Text = value; - BoldText.Text = value; - } - } - - public readonly SpriteText NormalText; - public readonly SpriteText BoldText; - - public TextContainer() - { - Anchor = Anchor.CentreLeft; - Origin = Anchor.CentreLeft; - - AutoSizeAxes = Axes.Both; - - Children = new Drawable[] - { - NormalText = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = text_size, - Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, - }, - BoldText = new OsuSpriteText - { - AlwaysPresent = true, - Alpha = 0, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = text_size, - Font = @"Exo2.0-Bold", - Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, - } - }; - } - } - } - #endregion + protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Vertical = DrawableOsuMenuItem.MARGIN_VERTICAL }; } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index 6b64e9e367..fa56b183a5 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -1,10 +1,18 @@ // Copyright (c) 2007-2017 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; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { @@ -26,5 +34,123 @@ namespace osu.Game.Graphics.UserInterface } protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(5); + + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuMenuItem(item); + + protected class DrawableOsuMenuItem : DrawableMenuItem + { + private const int margin_horizontal = 17; + private const int text_size = 17; + private const int transition_length = 80; + public const int MARGIN_VERTICAL = 4; + + private SampleChannel sampleClick; + private SampleChannel sampleHover; + + private TextContainer text; + + public DrawableOsuMenuItem(MenuItem item) + : base(item) + { + if (!(Item is OsuMenuItem)) + throw new ArgumentException($"{nameof(item)} must be a {nameof(OsuMenuItem)}."); + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + sampleHover = audio.Sample.Get(@"UI/generic-hover"); + sampleClick = audio.Sample.Get(@"UI/generic-click"); + + BackgroundColour = Color4.Transparent; + BackgroundColourHover = OsuColour.FromHex(@"172023"); + + updateTextColour(); + } + + private void updateTextColour() + { + switch (((OsuMenuItem)Item).Type) + { + case MenuItemType.Standard: + text.Colour = Color4.White; + break; + case MenuItemType.Destructive: + text.Colour = Color4.Red; + break; + case MenuItemType.Highlighted: + text.Colour = OsuColour.FromHex(@"ffcc22"); + break; + } + } + + protected override bool OnHover(InputState state) + { + sampleHover.Play(); + text.BoldText.FadeIn(transition_length, Easing.OutQuint); + text.NormalText.FadeOut(transition_length, Easing.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + text.BoldText.FadeOut(transition_length, Easing.OutQuint); + text.NormalText.FadeIn(transition_length, Easing.OutQuint); + base.OnHoverLost(state); + } + + protected override bool OnClick(InputState state) + { + sampleClick.Play(); + return base.OnClick(state); + } + + protected override Drawable CreateContent() => text = new TextContainer(); + + private class TextContainer : Container, IHasText + { + public string Text + { + get { return NormalText.Text; } + set + { + NormalText.Text = value; + BoldText.Text = value; + } + } + + public readonly SpriteText NormalText; + public readonly SpriteText BoldText; + + public TextContainer() + { + Anchor = Anchor.CentreLeft; + Origin = Anchor.CentreLeft; + + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + NormalText = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = text_size, + Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, + }, + BoldText = new OsuSpriteText + { + AlwaysPresent = true, + Alpha = 0, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = text_size, + Font = @"Exo2.0-Bold", + Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL }, + } + }; + } + } + } } } From 83fe8514a49de4af590d2d076751220d7e2ba709 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 28 Aug 2017 15:44:05 +0900 Subject: [PATCH 050/107] Remove unnecessary exception, replace with default value. --- osu.Game/Graphics/UserInterface/OsuMenu.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index fa56b183a5..efc6998ca7 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -52,8 +52,7 @@ namespace osu.Game.Graphics.UserInterface public DrawableOsuMenuItem(MenuItem item) : base(item) { - if (!(Item is OsuMenuItem)) - throw new ArgumentException($"{nameof(item)} must be a {nameof(OsuMenuItem)}."); + } [BackgroundDependencyLoader] @@ -70,8 +69,9 @@ namespace osu.Game.Graphics.UserInterface private void updateTextColour() { - switch (((OsuMenuItem)Item).Type) + switch ((Item as OsuMenuItem)?.Type) { + default: case MenuItemType.Standard: text.Colour = Color4.White; break; From 5c3b7ac12ca35da401f06f981ff814791be0b97b Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Mon, 28 Aug 2017 00:22:18 -0700 Subject: [PATCH 051/107] Allow rearranging playlist tracks --- osu.Game/Overlays/Music/PlaylistItem.cs | 43 ++++++++++++++++++++++++- osu.Game/Overlays/Music/PlaylistList.cs | 7 ++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 4145a8d1f0..6c38755e72 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -28,6 +29,7 @@ namespace osu.Game.Overlays.Music private IEnumerable titleSprites; private UnicodeBindableString titleBind; private UnicodeBindableString artistBind; + private FillFlowContainer Playlist; public readonly BeatmapSetInfo BeatmapSetInfo; @@ -48,8 +50,9 @@ namespace osu.Game.Overlays.Music } } - public PlaylistItem(BeatmapSetInfo setInfo) + public PlaylistItem(FillFlowContainer playlist, BeatmapSetInfo setInfo) { + Playlist = playlist; BeatmapSetInfo = setInfo; RelativeSizeAxes = Axes.X; @@ -132,6 +135,44 @@ namespace osu.Game.Overlays.Music return true; } + protected override bool OnDragStart(InputState state) + { + return true; + } + + // Maybe render some ghost text + protected override bool OnDrag(InputState state) + { + return true; + } + + private int clamp(int value, int min, int max) + { + return (value <= min) ? min : (value >= max) ? max : value; + } + + protected override bool OnDragEnd(InputState state) + { + int src = (int) Depth; + int dst = clamp((int) ((state.Mouse.Position.Y - Parent.DrawPosition.Y) / Height), 0, Playlist.Count - 1); + + if (src == dst) + return true; + + if (src < dst) + { + for (int i = src + 1; i <= dst; i++) + Playlist.ChangeChildDepth(Playlist[i], i - 1); + } + else + { + for (int i = dst; i < src; i++) + Playlist.ChangeChildDepth(Playlist[i], i + 1); + } + Playlist.ChangeChildDepth(this, dst); + return true; + } + public string[] FilterTerms { get; private set; } private bool matching = true; diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 3dd514edeb..3cbef8c22e 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Music { set { - items.Children = value.Select(item => new PlaylistItem(item) { OnSelect = itemSelected }).ToList(); + items.Children = value.Select((item, index) => new PlaylistItem(items, item) { OnSelect = itemSelected, Depth = index }).ToList(); } } @@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Music public void AddBeatmapSet(BeatmapSetInfo beatmapSet) { - items.Add(new PlaylistItem(beatmapSet) { OnSelect = itemSelected }); + items.Add(new PlaylistItem(items, beatmapSet) { OnSelect = itemSelected, Depth = items.Count }); } public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) @@ -96,6 +96,9 @@ namespace osu.Game.Overlays.Music } } + // Compare with reversed ChildID and Depth + protected override int Compare(Drawable x, Drawable y) => base.Compare(y, x); + public IEnumerable FilterableChildren => Children; public ItemSearchContainer() From 97ebf382883210c1828a276b9a2685c2f5e071f5 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Mon, 28 Aug 2017 00:56:03 -0700 Subject: [PATCH 052/107] Use PlaylistList to manage Prev/Next tracks --- osu.Game/Overlays/Music/PlaylistItem.cs | 2 +- osu.Game/Overlays/Music/PlaylistList.cs | 18 ++++++++++++++++++ osu.Game/Overlays/Music/PlaylistOverlay.cs | 16 ++++++++-------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 6c38755e72..f6ba78c897 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -29,8 +29,8 @@ namespace osu.Game.Overlays.Music private IEnumerable titleSprites; private UnicodeBindableString titleBind; private UnicodeBindableString artistBind; - private FillFlowContainer Playlist; + private readonly FillFlowContainer Playlist; public readonly BeatmapSetInfo BeatmapSetInfo; public Action OnSelect; diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 3cbef8c22e..019049eb96 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -46,6 +46,24 @@ namespace osu.Game.Overlays.Music } } + public BeatmapSetInfo NextItem + { + get + { + var available = items.Children; + return (available.SkipWhile(i => !i.Selected).Skip(1).FirstOrDefault() ?? available.FirstOrDefault())?.BeatmapSetInfo; + } + } + + public BeatmapSetInfo PreviousItem + { + get + { + var available = items.Children.Reverse(); + return (available.SkipWhile(i => !i.Selected).Skip(1).FirstOrDefault() ?? available.FirstOrDefault())?.BeatmapSetInfo; + } + } + public PlaylistList() { Children = new Drawable[] diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 83e92c5554..e987e7a5c1 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -126,24 +126,24 @@ namespace osu.Game.Overlays.Music public void PlayPrevious() { - var currentID = beatmapBacking.Value?.BeatmapSetInfo.ID ?? -1; - var available = BeatmapSets.Reverse(); - - var playable = available.SkipWhile(b => b.ID != currentID).Skip(1).FirstOrDefault() ?? available.FirstOrDefault(); + var playable = list.PreviousItem; if (playable != null) + { playSpecified(playable.Beatmaps[0]); + list.SelectedItem = playable; + } } public void PlayNext() { - var currentID = beatmapBacking.Value?.BeatmapSetInfo.ID ?? -1; - var available = BeatmapSets; - - var playable = available.SkipWhile(b => b.ID != currentID).Skip(1).FirstOrDefault() ?? available.FirstOrDefault(); + var playable = list.NextItem; if (playable != null) + { playSpecified(playable.Beatmaps[0]); + list.SelectedItem = playable; + } } private void playSpecified(BeatmapInfo info) From 2f5d8a7f884a365b0302f8f0d863146d1c1e34a9 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Mon, 28 Aug 2017 01:08:51 -0700 Subject: [PATCH 053/107] Fixed code style errors --- osu.Game/Overlays/Music/PlaylistItem.cs | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index f6ba78c897..85c8cd0c93 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Music private UnicodeBindableString titleBind; private UnicodeBindableString artistBind; - private readonly FillFlowContainer Playlist; + private readonly FillFlowContainer playlist; public readonly BeatmapSetInfo BeatmapSetInfo; public Action OnSelect; @@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Music public PlaylistItem(FillFlowContainer playlist, BeatmapSetInfo setInfo) { - Playlist = playlist; + this.playlist = playlist; BeatmapSetInfo = setInfo; RelativeSizeAxes = Axes.X; @@ -117,19 +117,19 @@ namespace osu.Game.Overlays.Music }); } - protected override bool OnHover(Framework.Input.InputState state) + protected override bool OnHover(InputState state) { handle.FadeIn(fade_duration); return base.OnHover(state); } - protected override void OnHoverLost(Framework.Input.InputState state) + protected override void OnHoverLost(InputState state) { handle.FadeOut(fade_duration); } - protected override bool OnClick(Framework.Input.InputState state) + protected override bool OnClick(InputState state) { OnSelect?.Invoke(BeatmapSetInfo); return true; @@ -146,15 +146,10 @@ namespace osu.Game.Overlays.Music return true; } - private int clamp(int value, int min, int max) - { - return (value <= min) ? min : (value >= max) ? max : value; - } - protected override bool OnDragEnd(InputState state) { int src = (int) Depth; - int dst = clamp((int) ((state.Mouse.Position.Y - Parent.DrawPosition.Y) / Height), 0, Playlist.Count - 1); + int dst = clamp((int) ((state.Mouse.Position.Y - Parent.DrawPosition.Y) / Height), 0, playlist.Count - 1); if (src == dst) return true; @@ -162,17 +157,22 @@ namespace osu.Game.Overlays.Music if (src < dst) { for (int i = src + 1; i <= dst; i++) - Playlist.ChangeChildDepth(Playlist[i], i - 1); + playlist.ChangeChildDepth(playlist[i], i - 1); } else { for (int i = dst; i < src; i++) - Playlist.ChangeChildDepth(Playlist[i], i + 1); + playlist.ChangeChildDepth(playlist[i], i + 1); } - Playlist.ChangeChildDepth(this, dst); + playlist.ChangeChildDepth(this, dst); return true; } + private int clamp(int value, int min, int max) + { + return value <= min ? min : value >= max ? max : value; + } + public string[] FilterTerms { get; private set; } private bool matching = true; From 161718947502777d0e7feeedaef99d0e032ea29d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 28 Aug 2017 17:53:03 +0800 Subject: [PATCH 054/107] Set DummyWorkingBeatmap's DeletePending to true. --- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 479f274efb..bc4b28168a 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -26,7 +26,7 @@ namespace osu.Game.Beatmaps Title = "no beatmaps available!", Author = "no one", }, - BeatmapSet = new BeatmapSetInfo(), + BeatmapSet = new BeatmapSetInfo { DeletePending = true }, Difficulty = new BeatmapDifficulty { DrainRate = 0, From 4aa5ce8b413eb8afa2cdeaa521d2fef1b42c21c4 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 28 Aug 2017 17:53:57 +0800 Subject: [PATCH 055/107] Always load background and info wedge when no beatmap available. --- osu.Game/Screens/Select/SongSelect.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index aa554152f9..6c149c3f30 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -248,8 +248,7 @@ namespace osu.Game.Screens.Select if (beatmap == null) { - if (!Beatmap.IsDefault) - performLoad(); + performLoad(); } else { From 12be5b417d58b0a02773888472a40eb2e90847f6 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Mon, 28 Aug 2017 22:51:26 -0700 Subject: [PATCH 056/107] Use MathHelper.Clamp - Fix formatting --- osu.Game/Overlays/Music/PlaylistItem.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 85c8cd0c93..a86cca117a 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -148,8 +148,8 @@ namespace osu.Game.Overlays.Music protected override bool OnDragEnd(InputState state) { - int src = (int) Depth; - int dst = clamp((int) ((state.Mouse.Position.Y - Parent.DrawPosition.Y) / Height), 0, playlist.Count - 1); + int src = (int)Depth; + int dst = MathHelper.Clamp((int)(state.Mouse.Position.Y / Height), 0, playlist.Count - 1); if (src == dst) return true; @@ -164,15 +164,11 @@ namespace osu.Game.Overlays.Music for (int i = dst; i < src; i++) playlist.ChangeChildDepth(playlist[i], i + 1); } + playlist.ChangeChildDepth(this, dst); return true; } - private int clamp(int value, int min, int max) - { - return value <= min ? min : value >= max ? max : value; - } - public string[] FilterTerms { get; private set; } private bool matching = true; From 636492b9cf8297347e416776a89868bbc43d5b0b Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Mon, 28 Aug 2017 22:59:28 -0700 Subject: [PATCH 057/107] Rearrange tracks in OnDrag --- osu.Game/Overlays/Music/PlaylistItem.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index a86cca117a..6c7e590a88 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -140,13 +140,7 @@ namespace osu.Game.Overlays.Music return true; } - // Maybe render some ghost text protected override bool OnDrag(InputState state) - { - return true; - } - - protected override bool OnDragEnd(InputState state) { int src = (int)Depth; int dst = MathHelper.Clamp((int)(state.Mouse.Position.Y / Height), 0, playlist.Count - 1); From b91757793f3e65da3c84d9fb9bd3302e4b9c94b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 Aug 2017 15:20:56 +0900 Subject: [PATCH 058/107] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 2cb3e59c8b..167d5cda8f 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2cb3e59c8bc7e67edef4dfe7f9c7dfc01db386a7 +Subproject commit 167d5cda8f3ddae702ffc8d8d22dac67e48b509c From 85f876a934ae831c786568e1631f7588fd006540 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 Aug 2017 15:23:32 +0900 Subject: [PATCH 059/107] Remove unused using statement --- osu.Game/Graphics/UserInterface/OsuMenu.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index efc6998ca7..ab37fd2c90 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 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; From 458c3a355fd0c6d20d656a68aaac7e73c5c9cd04 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Mon, 28 Aug 2017 23:28:58 -0700 Subject: [PATCH 060/107] Rearrange dragging using cheeseburger icon only --- osu.Game/Overlays/Music/PlaylistItem.cs | 77 ++++++++++++++----------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 6c7e590a88..876ad4f767 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -71,15 +71,9 @@ namespace osu.Game.Overlays.Music Children = new Drawable[] { - handle = new SpriteIcon + handle = new PlaylistItemHandle(playlist) { - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Size = new Vector2(12), Colour = colours.Gray5, - Icon = FontAwesome.fa_bars, - Alpha = 0f, - Margin = new MarginPadding { Left = 5, Top = 2 }, }, text = new OsuTextFlowContainer { @@ -135,34 +129,6 @@ namespace osu.Game.Overlays.Music return true; } - protected override bool OnDragStart(InputState state) - { - return true; - } - - protected override bool OnDrag(InputState state) - { - int src = (int)Depth; - int dst = MathHelper.Clamp((int)(state.Mouse.Position.Y / Height), 0, playlist.Count - 1); - - if (src == dst) - return true; - - if (src < dst) - { - for (int i = src + 1; i <= dst; i++) - playlist.ChangeChildDepth(playlist[i], i - 1); - } - else - { - for (int i = dst; i < src; i++) - playlist.ChangeChildDepth(playlist[i], i + 1); - } - - playlist.ChangeChildDepth(this, dst); - return true; - } - public string[] FilterTerms { get; private set; } private bool matching = true; @@ -179,5 +145,46 @@ namespace osu.Game.Overlays.Music this.FadeTo(matching ? 1 : 0, 200); } } + + private class PlaylistItemHandle : SpriteIcon + { + private readonly FillFlowContainer playlist; + + public PlaylistItemHandle(FillFlowContainer playlist) + { + this.playlist = playlist; + Anchor = Anchor.TopLeft; + Origin = Anchor.TopLeft; + Size = new Vector2(12); + Icon = FontAwesome.fa_bars; + Alpha = 0f; + Margin = new MarginPadding { Left = 5, Top = 2 }; + } + + protected override bool OnDragStart(InputState state) => true; + + protected override bool OnDrag(InputState state) + { + int src = (int)Parent.Depth; + int dst = MathHelper.Clamp((int)((state.Mouse.Position.Y + Parent.Position.Y) / Parent.Height), 0, playlist.Count - 1); + + if (src == dst) + return true; + + if (src < dst) + { + for (int i = src + 1; i <= dst; i++) + playlist.ChangeChildDepth(playlist[i], i - 1); + } + else + { + for (int i = dst; i < src; i++) + playlist.ChangeChildDepth(playlist[i], i + 1); + } + + playlist.ChangeChildDepth(Parent as PlaylistItem, dst); + return true; + } + } } } From 1eb31afd146305e5204d016a95f2ea43599737b9 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Tue, 29 Aug 2017 00:39:17 -0700 Subject: [PATCH 061/107] Get destination index using binarysearch --- osu.Game/Overlays/Music/PlaylistItem.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 876ad4f767..941b858364 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -166,7 +166,7 @@ namespace osu.Game.Overlays.Music protected override bool OnDrag(InputState state) { int src = (int)Parent.Depth; - int dst = MathHelper.Clamp((int)((state.Mouse.Position.Y + Parent.Position.Y) / Parent.Height), 0, playlist.Count - 1); + int dst = getIndex(state.Mouse.Position.Y + Parent.Position.Y); if (src == dst) return true; @@ -185,6 +185,24 @@ namespace osu.Game.Overlays.Music playlist.ChangeChildDepth(Parent as PlaylistItem, dst); return true; } + + private int getIndex(float position) { + IReadOnlyList items = playlist.Children; + + // Binary Search without matching exact + int min = 0; + int max = items.Count - 1; + while (min <= max) + { + int m = (min + max) / 2; + if (items[m].Y < position) + min = m + 1; + else if (items[m].Y > position) + max = m - 1; + } + + return (int)items[min - 1].Depth; + } } } } From e5bf3f6a6af29f753b3b619293a8b9de6ff477c2 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Tue, 29 Aug 2017 00:46:11 -0700 Subject: [PATCH 062/107] Fix out of bounds --- osu.Game/Overlays/Music/PlaylistItem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 941b858364..1491d7d0dd 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -201,7 +202,7 @@ namespace osu.Game.Overlays.Music max = m - 1; } - return (int)items[min - 1].Depth; + return (int)items[Math.Max(0, min - 1)].Depth; } } } From fb3ba4fe0cfa01ce725337e5a04b9c8934050495 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 29 Aug 2017 00:26:16 +0800 Subject: [PATCH 063/107] Add comment for DeletePending. --- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index bc4b28168a..4fc135a7e4 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -26,7 +26,7 @@ namespace osu.Game.Beatmaps Title = "no beatmaps available!", Author = "no one", }, - BeatmapSet = new BeatmapSetInfo { DeletePending = true }, + BeatmapSet = new BeatmapSetInfo { DeletePending = true }, //let song select show no beatmaps available if this is the only one Difficulty = new BeatmapDifficulty { DrainRate = 0, From 5b8349f90ed14ad09b8a165f4122f86f1cb2d892 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 29 Aug 2017 18:05:27 +0900 Subject: [PATCH 064/107] Revert DummyWorkingBeatmap changes. --- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 4fc135a7e4..479f274efb 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -26,7 +26,7 @@ namespace osu.Game.Beatmaps Title = "no beatmaps available!", Author = "no one", }, - BeatmapSet = new BeatmapSetInfo { DeletePending = true }, //let song select show no beatmaps available if this is the only one + BeatmapSet = new BeatmapSetInfo(), Difficulty = new BeatmapDifficulty { DrainRate = 0, From 39b5b047002d54bc1a9e623a912418fca4be887b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 Aug 2017 18:17:01 +0900 Subject: [PATCH 065/107] Don't use Bindable for AccentColour Implements IHasAccentColour for conformity to rest of project. Also fixes a nullref when opening the login menu. --- .../Graphics/UserInterface/OsuDropdown.cs | 127 ++++++++++-------- .../Graphics/UserInterface/OsuTabControl.cs | 74 +++++----- osu.Game/Overlays/Direct/FilterControl.cs | 2 +- .../Overlays/Music/CollectionsDropdown.cs | 10 +- .../SearchableList/SlimEnumDropdown.cs | 8 +- .../Sections/General/LoginSettings.cs | 12 +- 6 files changed, 113 insertions(+), 120 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 9c816b8230..37bd4f2395 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -1,9 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -14,35 +14,43 @@ using OpenTK; namespace osu.Game.Graphics.UserInterface { - public class OsuDropdown : Dropdown + public class OsuDropdown : Dropdown, IHasAccentColour { - public readonly Bindable AccentColour = new Bindable(); + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + accentColour = value; + updateAccentColour(); + } + } [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (AccentColour.Value == null) - AccentColour.Value = colours.PinkDarker; + if (accentColour == default(Color4)) + accentColour = colours.PinkDarker; + updateAccentColour(); + } - protected override DropdownHeader CreateHeader() + private void updateAccentColour() { - var newHeader = new OsuDropdownHeader(); - newHeader.AccentColour.BindTo(AccentColour); + var header = Header as IHasAccentColour; + if (header != null) header.AccentColour = accentColour; - return newHeader; + var menu = Menu as IHasAccentColour; + if (menu != null) menu.AccentColour = accentColour; } - protected override DropdownMenu CreateMenu() - { - var newMenu = new OsuDropdownMenu(); - newMenu.AccentColour.BindTo(AccentColour); + protected override DropdownHeader CreateHeader() => new OsuDropdownHeader(); - return newMenu; - } + protected override DropdownMenu CreateMenu() => new OsuDropdownMenu(); #region OsuDropdownMenu - protected class OsuDropdownMenu : DropdownMenu + protected class OsuDropdownMenu : DropdownMenu, IHasAccentColour { // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring public OsuDropdownMenu() @@ -65,23 +73,41 @@ namespace osu.Game.Graphics.UserInterface this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint); } - public readonly Bindable AccentColour = new Bindable(); - - - protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) + private Color4 accentColour; + public Color4 AccentColour { - var newItem = new DrawableOsuDropdownMenuItem(item); - newItem.AccentColour.BindTo(AccentColour); - - return newItem; + get { return accentColour; } + set + { + accentColour = value; + foreach (var c in Children.OfType()) + c.AccentColour = value; + } } - #region DrawableOsuDropdownMenuItem - protected class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem - { - public readonly Bindable AccentColour = new Bindable(); + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuDropdownMenuItem(item) { AccentColour = accentColour }; - private TextContainer textContainer; + #region DrawableOsuDropdownMenuItem + protected class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem, IHasAccentColour + { + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour ?? nonAccentSelectedColour; } + set + { + accentColour = value; + updateColours(); + } + } + + private void updateColours() + { + BackgroundColourHover = accentColour ?? nonAccentHoverColour; + BackgroundColourSelected = accentColour ?? nonAccentSelectedColour; + UpdateBackgroundColour(); + UpdateForegroundColour(); + } private Color4 nonAccentHoverColour; private Color4 nonAccentSelectedColour; @@ -93,36 +119,29 @@ namespace osu.Game.Graphics.UserInterface Masking = true; CornerRadius = 6; - - AccentColour.ValueChanged += updateAccent; } [BackgroundDependencyLoader] private void load(OsuColour colours) { BackgroundColour = Color4.Transparent; + nonAccentHoverColour = colours.PinkDarker; nonAccentSelectedColour = Color4.Black.Opacity(0.5f); - } - - private void updateAccent(Color4? newValue) - { - BackgroundColourHover = newValue ?? nonAccentHoverColour; - BackgroundColourSelected = newValue ?? nonAccentSelectedColour; - UpdateBackgroundColour(); - UpdateForegroundColour(); + updateColours(); } protected override void UpdateForegroundColour() { base.UpdateForegroundColour(); - textContainer.Chevron.Alpha = IsHovered ? 1 : 0; + var content = Foreground.Child as Content; + if (content != null) content.Chevron.Alpha = IsHovered ? 1 : 0; } - protected override Drawable CreateContent() => textContainer = new TextContainer(); + protected override Drawable CreateContent() => new Content(); - protected class TextContainer : FillFlowContainer, IHasText + protected class Content : FillFlowContainer, IHasText { public string Text { @@ -133,7 +152,7 @@ namespace osu.Game.Graphics.UserInterface public readonly OsuSpriteText Label; public readonly SpriteIcon Chevron; - public TextContainer() + public Content() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -165,7 +184,7 @@ namespace osu.Game.Graphics.UserInterface } #endregion - public class OsuDropdownHeader : DropdownHeader + public class OsuDropdownHeader : DropdownHeader, IHasAccentColour { protected readonly SpriteText Text; protected override string Label @@ -176,7 +195,16 @@ namespace osu.Game.Graphics.UserInterface protected readonly SpriteIcon Icon; - public readonly Bindable AccentColour = new Bindable(); + private Color4 accentColour; + public virtual Color4 AccentColour + { + get { return accentColour; } + set + { + accentColour = value; + BackgroundColourHover = accentColour; + } + } public OsuDropdownHeader() { @@ -203,20 +231,13 @@ namespace osu.Game.Graphics.UserInterface Size = new Vector2(20), } }; - - AccentColour.ValueChanged += accentColourChanged; } [BackgroundDependencyLoader] private void load(OsuColour colours) { BackgroundColour = Color4.Black.Opacity(0.5f); - BackgroundColourHover = AccentColour?.Value ?? colours.PinkDarker; - } - - private void accentColourChanged(Color4? newValue) - { - BackgroundColourHover = newValue ?? Color4.White; + BackgroundColourHover = colours.PinkDarker; } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 32d2bc7c53..89b1f4124b 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -37,34 +37,34 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (accentColour == null) + if (accentColour == default(Color4)) AccentColour = colours.Blue; } - private Color4? accentColour; + private Color4 accentColour; public Color4 AccentColour { - get { return accentColour.GetValueOrDefault(); } + get { return accentColour; } set { accentColour = value; - var dropdown = Dropdown as OsuTabDropdown; + var dropdown = Dropdown as IHasAccentColour; if (dropdown != null) - dropdown.AccentColour.Value = value; - foreach (var item in TabContainer.Children.OfType()) - item.AccentColour = value; + dropdown.AccentColour = value; + foreach (var i in TabContainer.Children.OfType()) + i.AccentColour = value; } } - public class OsuTabItem : TabItem + public class OsuTabItem : TabItem, IHasAccentColour { protected readonly SpriteText Text; private readonly Box box; - private Color4? accentColour; + private Color4 accentColour; public Color4 AccentColour { - get { return accentColour.GetValueOrDefault(); } + get { return accentColour; } set { accentColour = value; @@ -103,7 +103,7 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (accentColour == null) + if (accentColour == default(Color4)) AccentColour = colours.Blue; } @@ -148,25 +148,13 @@ namespace osu.Game.Graphics.UserInterface RelativeSizeAxes = Axes.X; } - protected override DropdownMenu CreateMenu() + protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu(); + + protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader { - var menu = new OsuTabDropdownMenu(); - menu.AccentColour.BindTo(AccentColour); - return menu; - } - - protected override DropdownHeader CreateHeader() - { - var newHeader = new OsuTabDropdownHeader - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight - }; - - newHeader.AccentColour.BindTo(AccentColour); - - return newHeader; - } + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight + }; private class OsuTabDropdownMenu : OsuDropdownMenu { @@ -179,12 +167,7 @@ namespace osu.Game.Graphics.UserInterface MaxHeight = 400; } - protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) - { - var result = new DrawableOsuTabDropdownMenuItem(item); - result.AccentColour.BindTo(AccentColour); - return result; - } + protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuTabDropdownMenuItem(item) { AccentColour = AccentColour }; private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem { @@ -199,6 +182,20 @@ namespace osu.Game.Graphics.UserInterface protected class OsuTabDropdownHeader : OsuDropdownHeader { + public override Color4 AccentColour + { + get + { + return base.AccentColour; + } + + set + { + base.AccentColour = value; + Foreground.Colour = value; + } + } + public OsuTabDropdownHeader() { RelativeSizeAxes = Axes.None; @@ -227,13 +224,6 @@ namespace osu.Game.Graphics.UserInterface }; Padding = new MarginPadding { Left = 5, Right = 5 }; - - AccentColour.ValueChanged += accentColourChanged; - } - - private void accentColourChanged(Color4? newValue) - { - Foreground.Colour = newValue ?? Color4.White; } protected override bool OnHover(InputState state) diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index ca9e8667e6..28d26d0641 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader(true)] private void load(OsuGame game, RulesetStore rulesets, OsuColour colours) { - DisplayStyleControl.Dropdown.AccentColour.Value = colours.BlueDark; + DisplayStyleControl.Dropdown.AccentColour = colours.BlueDark; Ruleset.BindTo(game?.Ruleset ?? new Bindable { Value = rulesets.GetRuleset(0) }); foreach (var r in rulesets.AllRulesets) diff --git a/osu.Game/Overlays/Music/CollectionsDropdown.cs b/osu.Game/Overlays/Music/CollectionsDropdown.cs index be72d4481a..3b11d9f52a 100644 --- a/osu.Game/Overlays/Music/CollectionsDropdown.cs +++ b/osu.Game/Overlays/Music/CollectionsDropdown.cs @@ -18,16 +18,10 @@ namespace osu.Game.Overlays.Music [BackgroundDependencyLoader] private void load(OsuColour colours) { - AccentColour.Value = colours.Gray6; + AccentColour = colours.Gray6; } - protected override DropdownHeader CreateHeader() - { - var newHeader = new CollectionsHeader(); - newHeader.AccentColour.BindTo(AccentColour); - - return newHeader; - } + protected override DropdownHeader CreateHeader() => new CollectionsHeader(); protected override DropdownMenu CreateMenu() => new CollectionsMenu(); diff --git a/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs b/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs index e68cddb293..2870607519 100644 --- a/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs +++ b/osu.Game/Overlays/SearchableList/SlimEnumDropdown.cs @@ -12,13 +12,7 @@ namespace osu.Game.Overlays.SearchableList { public class SlimEnumDropdown : OsuEnumDropdown { - protected override DropdownHeader CreateHeader() - { - var newHeader = new SlimDropdownHeader(); - newHeader.AccentColour.BindTo(AccentColour); - - return newHeader; - } + protected override DropdownHeader CreateHeader() => new SlimDropdownHeader(); protected override DropdownMenu CreateMenu() => new SlimMenu(); diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index cf12c8a8e8..a816fa56c1 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -257,13 +257,7 @@ namespace osu.Game.Overlays.Settings.Sections.General private class UserDropdown : OsuEnumDropdown { - protected override DropdownHeader CreateHeader() - { - var newHeader = new UserDropdownHeader(); - newHeader.AccentColour.BindTo(AccentColour); - - return newHeader; - } + protected override DropdownHeader CreateHeader() => new UserDropdownHeader(); protected override DropdownMenu CreateMenu() => new UserDropdownMenu(); @@ -280,7 +274,7 @@ namespace osu.Game.Overlays.Settings.Sections.General [BackgroundDependencyLoader] private void load(OsuColour colours) { - AccentColour.Value = colours.Gray5; + AccentColour = colours.Gray5; } private class UserDropdownMenu : OsuDropdownMenu @@ -319,7 +313,7 @@ namespace osu.Game.Overlays.Settings.Sections.General CornerRadius = 5; } - protected override Drawable CreateContent() => new TextContainer + protected override Drawable CreateContent() => new Content { Label = { Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 } } }; From 2535313f4f29db31928f5d2a20a95e48c27919f6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 29 Aug 2017 18:18:36 +0900 Subject: [PATCH 066/107] Use using. --- osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs index c3cc4fe77b..7f193a0e1a 100644 --- a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs @@ -3,6 +3,7 @@ using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -43,7 +44,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Key == OpenTK.Input.Key.CapsLock) + if (args.Key == Key.CapsLock) updateCapsWarning(host.CapsLockEnabled); return base.OnKeyDown(state, args); } From 24a2dc3d1e2d93185beae32d7d7b9919108db2b9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 Aug 2017 18:31:51 +0900 Subject: [PATCH 067/107] Don't use child --- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 37bd4f2395..dde154bb61 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -135,7 +135,7 @@ namespace osu.Game.Graphics.UserInterface { base.UpdateForegroundColour(); - var content = Foreground.Child as Content; + var content = Foreground.Children.FirstOrDefault() as Content; if (content != null) content.Chevron.Alpha = IsHovered ? 1 : 0; } From 0e363fce1e05118e929e3d598f10fef75f0c1ce3 Mon Sep 17 00:00:00 2001 From: Kelvin <2yangk23@gmail.com> Date: Tue, 29 Aug 2017 22:25:04 -0700 Subject: [PATCH 068/107] Try to fix stuttering behavior --- osu.Game/Overlays/Music/PlaylistItem.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 1491d7d0dd..9df15bfd04 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -151,6 +150,9 @@ namespace osu.Game.Overlays.Music { private readonly FillFlowContainer playlist; + private const int line_height = 22; + private const int rearrange_buffer = 3; + public PlaylistItemHandle(FillFlowContainer playlist) { this.playlist = playlist; @@ -202,7 +204,12 @@ namespace osu.Game.Overlays.Music max = m - 1; } - return (int)items[Math.Max(0, min - 1)].Depth; + int index = Math.Max(0, min - 1); + // Only move if mouse falls within buffer + if (position - items[index].Y > rearrange_buffer && position - items[index].Y < line_height - rearrange_buffer) { + return (int)items[index].Depth; + } + return (int)Parent.Depth; } } } From 07da29ea1ce6e4c4fb6551f16efcbcf002fdfcd0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 Aug 2017 20:41:41 +0900 Subject: [PATCH 069/107] Add context menu to beatmap set header --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 3 +++ .../Beatmaps/Drawables/BeatmapSetHeader.cs | 23 ++++++++++++++++++- osu.Game/Screens/Select/BeatmapCarousel.cs | 3 +++ osu.Game/Screens/Select/SongSelect.cs | 14 +++++++---- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index ad9a0a787b..dc68c9a49e 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -23,6 +23,8 @@ namespace osu.Game.Beatmaps.Drawables /// public Action StartRequested; + public Action DeleteRequested; + public BeatmapSetHeader Header; private BeatmapGroupState state; @@ -66,6 +68,7 @@ namespace osu.Game.Beatmaps.Drawables Header = new BeatmapSetHeader(beatmap) { GainedSelection = headerGainedSelection, + DeleteRequested = b => DeleteRequested(b), RelativeSizeAxes = Axes.X, }; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index a2457ba78e..6510f92547 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -9,16 +9,22 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Game.Graphics.Sprites; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Beatmaps.Drawables { - public class BeatmapSetHeader : Panel + public class BeatmapSetHeader : Panel, IHasContextMenu { public Action GainedSelection; + + public Action DeleteRequested; + private readonly SpriteText title; private readonly SpriteText artist; @@ -148,5 +154,20 @@ namespace osu.Game.Beatmaps.Drawables foreach (var p in panels) difficultyIcons.Add(new DifficultyIcon(p.Beatmap)); } + + public MenuItem[] ContextMenuItems + { + get + { + List items = new List(); + + if (State == PanelSelectedState.NotSelected) + items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => State = PanelSelectedState.Selected)); + + items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(beatmap))); + + return items.ToArray(); + } + } } } \ No newline at end of file diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 264636b258..448f5395b6 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -140,6 +140,8 @@ namespace osu.Game.Screens.Select public Action StartRequested; + public Action DeleteRequested; + public void SelectNext(int direction = 1, bool skipDifficulties = true) { if (groups.All(g => g.State == BeatmapGroupState.Hidden)) @@ -305,6 +307,7 @@ namespace osu.Game.Screens.Select { SelectionChanged = (g, p) => selectGroup(g, p), StartRequested = b => StartRequested?.Invoke(), + DeleteRequested = b => DeleteRequested?.Invoke(b), State = BeatmapGroupState.Collapsed }; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6c149c3f30..4eb6da4f88 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -106,6 +106,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.CentreRight, SelectionChanged = carouselSelectionChanged, BeatmapsChanged = carouselBeatmapsLoaded, + DeleteRequested = b => promptDelete(b), StartRequested = () => carouselRaisedStart(), }); Add(FilterControl = new FilterControl @@ -163,7 +164,7 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap), Key.Number4, float.MaxValue); } if (manager == null) @@ -389,10 +390,12 @@ namespace osu.Game.Screens.Select Beatmap.SetDefault(); } - private void promptDelete() + private void promptDelete(WorkingBeatmap beatmap) { - if (Beatmap != null && !Beatmap.IsDefault) - dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap)); + if (beatmap == null) + return; + + dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) @@ -408,7 +411,8 @@ namespace osu.Game.Screens.Select case Key.Delete: if (state.Keyboard.ShiftPressed) { - promptDelete(); + if (!Beatmap.IsDefault) + promptDelete(Beatmap); return true; } break; From 8619f28ced14952e50aa9a1f96adb60ae5734f05 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 Aug 2017 20:41:53 +0900 Subject: [PATCH 070/107] Add context menu to beatmap difficulty (wip) --- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 429ecaf416..f963931c7c 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -5,6 +5,7 @@ using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; @@ -14,16 +15,19 @@ using OpenTK.Graphics; using osu.Framework.Input; using osu.Game.Graphics.Sprites; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Beatmaps.Drawables { - public class BeatmapPanel : Panel + public class BeatmapPanel : Panel, IHasContextMenu { public BeatmapInfo Beatmap; private readonly Sprite background; public Action GainedSelection; public Action StartRequested; + public Action DeleteRequested; + private readonly Triangles triangles; private readonly StarCounter starCounter; @@ -148,5 +152,12 @@ namespace osu.Game.Beatmaps.Drawables } }; } + + public MenuItem[] ContextMenuItems => new MenuItem[] + { + new OsuMenuItem("Play", MenuItemType.Highlighted), + new OsuMenuItem("Edit"), + new OsuMenuItem("Delete", MenuItemType.Destructive), + }; } } From 2fb4126ffc07eb84c9428009f8a8917f25313655 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 Aug 2017 20:53:33 +0900 Subject: [PATCH 071/107] Use BeatmapSetInfo instead of WorkingBeatmap --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 2 +- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 2 +- osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index dc68c9a49e..a4c7da71d8 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -23,7 +23,7 @@ namespace osu.Game.Beatmaps.Drawables /// public Action StartRequested; - public Action DeleteRequested; + public Action DeleteRequested; public BeatmapSetHeader Header; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index f963931c7c..235c98b43c 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -157,7 +157,7 @@ namespace osu.Game.Beatmaps.Drawables { new OsuMenuItem("Play", MenuItemType.Highlighted), new OsuMenuItem("Edit"), - new OsuMenuItem("Delete", MenuItemType.Destructive), + new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(Beatmap)), }; } } diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 6510f92547..b475a23ffd 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -23,7 +23,7 @@ namespace osu.Game.Beatmaps.Drawables { public Action GainedSelection; - public Action DeleteRequested; + public Action DeleteRequested; private readonly SpriteText title; private readonly SpriteText artist; @@ -164,7 +164,7 @@ namespace osu.Game.Beatmaps.Drawables if (State == PanelSelectedState.NotSelected) items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => State = PanelSelectedState.Selected)); - items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(beatmap))); + items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(beatmap.BeatmapSetInfo))); return items.ToArray(); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4eb6da4f88..6cd47aa9f6 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -249,7 +249,8 @@ namespace osu.Game.Screens.Select if (beatmap == null) { - performLoad(); + if (!Beatmap.IsDefault) + performLoad(); } else { @@ -390,7 +391,7 @@ namespace osu.Game.Screens.Select Beatmap.SetDefault(); } - private void promptDelete(WorkingBeatmap beatmap) + private void promptDelete(BeatmapSetInfo beatmap) { if (beatmap == null) return; @@ -412,7 +413,7 @@ namespace osu.Game.Screens.Select if (state.Keyboard.ShiftPressed) { if (!Beatmap.IsDefault) - promptDelete(Beatmap); + promptDelete(Beatmap.Value.BeatmapSetInfo); return true; } break; From 3b4b4b669bb88d4f3a35d54542399499a771fec9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 Aug 2017 21:12:46 +0900 Subject: [PATCH 072/107] Add framework for deleting difficulties --- osu.Game/Beatmaps/BeatmapManager.cs | 12 +++++++++- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 3 +++ osu.Game/Screens/Select/BeatmapCarousel.cs | 5 +++- .../Screens/Select/BeatmapDeleteDialog.cs | 23 ++++++++++++------- osu.Game/Screens/Select/SongSelect.cs | 11 ++++++++- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 1dcab6cb5d..c52576fb9f 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -170,7 +170,7 @@ namespace osu.Game.Beatmaps /// Delete a beatmap from the manager. /// Is a no-op for already deleted beatmaps. /// - /// The beatmap to delete. + /// The beatmap set to delete. public void Delete(BeatmapSetInfo beatmapSet) { lock (beatmaps) @@ -180,6 +180,16 @@ namespace osu.Game.Beatmaps files.Dereference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); } + /// + /// Delete a beatmap from the manager. + /// Is a no-op for already deleted beatmaps. + /// + /// The beatmap difficulty to delete. + public void Delete(BeatmapInfo beatmap) + { + //todo: implement + } + /// /// Returns a to a usable state if it has previously been deleted but not yet purged. /// Is a no-op for already usable beatmaps. diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index a4c7da71d8..b47210620d 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -25,6 +25,8 @@ namespace osu.Game.Beatmaps.Drawables public Action DeleteRequested; + public Action DeleteDifficultyRequested; + public BeatmapSetHeader Header; private BeatmapGroupState state; @@ -77,6 +79,7 @@ namespace osu.Game.Beatmaps.Drawables { Alpha = 0, GainedSelection = panelGainedSelection, + DeleteRequested = p => DeleteDifficultyRequested?.Invoke(p), StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, RelativeSizeAxes = Axes.X, }).ToList(); diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 448f5395b6..a1c7f64188 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -140,7 +140,9 @@ namespace osu.Game.Screens.Select public Action StartRequested; - public Action DeleteRequested; + public Action DeleteRequested; + + public Action DeleteDifficultyRequested; public void SelectNext(int direction = 1, bool skipDifficulties = true) { @@ -308,6 +310,7 @@ namespace osu.Game.Screens.Select SelectionChanged = (g, p) => selectGroup(g, p), StartRequested = b => StartRequested?.Invoke(), DeleteRequested = b => DeleteRequested?.Invoke(b), + DeleteDifficultyRequested = b => DeleteDifficultyRequested?.Invoke(b), State = BeatmapGroupState.Collapsed }; } diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index 96caf2f236..15ec84a7d8 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -13,29 +13,36 @@ namespace osu.Game.Screens.Select { private BeatmapManager manager; + private readonly Action deleteAction; + [BackgroundDependencyLoader] private void load(BeatmapManager beatmapManager) { manager = beatmapManager; } - public BeatmapDeleteDialog(WorkingBeatmap beatmap) + public BeatmapDeleteDialog(BeatmapSetInfo beatmap) : this() { - if (beatmap == null) throw new ArgumentNullException(nameof(beatmap)); + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} (ALL DIFFICULTIES)"; + deleteAction = () => manager.Delete(beatmap); + } + public BeatmapDeleteDialog(BeatmapInfo beatmap) : this() + { + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} [{beatmap.Version}]"; + deleteAction = () => manager.Delete(beatmap); + } + + public BeatmapDeleteDialog() + { Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton { Text = @"Yes. Totally. Delete it.", - Action = () => - { - beatmap.Dispose(); - manager.Delete(beatmap.BeatmapSetInfo); - }, + Action = () => deleteAction(), }, new PopupDialogCancelButton { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6cd47aa9f6..b3ee33e7c6 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -107,6 +107,7 @@ namespace osu.Game.Screens.Select SelectionChanged = carouselSelectionChanged, BeatmapsChanged = carouselBeatmapsLoaded, DeleteRequested = b => promptDelete(b), + DeleteDifficultyRequested = b => promptDelete(b), StartRequested = () => carouselRaisedStart(), }); Add(FilterControl = new FilterControl @@ -164,7 +165,7 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap), Key.Number4, float.MaxValue); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); } if (manager == null) @@ -399,6 +400,14 @@ namespace osu.Game.Screens.Select dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); } + private void promptDelete(BeatmapInfo beatmap) + { + if (beatmap == null) + return; + + dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Repeat) return false; From 5a58489adf72eacb03c182b419381d24a6c2a954 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 Aug 2017 21:12:58 +0900 Subject: [PATCH 073/107] Hook up play and edit (kinda) --- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 235c98b43c..1006380a2b 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -26,6 +26,7 @@ namespace osu.Game.Beatmaps.Drawables public Action GainedSelection; public Action StartRequested; + public Action EditRequested; public Action DeleteRequested; private readonly Triangles triangles; @@ -155,8 +156,8 @@ namespace osu.Game.Beatmaps.Drawables public MenuItem[] ContextMenuItems => new MenuItem[] { - new OsuMenuItem("Play", MenuItemType.Highlighted), - new OsuMenuItem("Edit"), + new OsuMenuItem("Play", MenuItemType.Highlighted, () => StartRequested?.Invoke(this)), + new OsuMenuItem("Edit", MenuItemType.Standard, () => EditRequested?.Invoke(this)), new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(Beatmap)), }; } From d252af8ab45f4048525da834bbc6f2450b3b5454 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 31 Aug 2017 02:36:25 -0400 Subject: [PATCH 074/107] basic implementation of hp --- .../Scoring/OsuScoreProcessor.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index 856ca0c98d..df97e06118 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Scoring { base.Reset(); - Health.Value = 1; + Health.Value = 0.5; Accuracy.Value = 1; scoreResultCounts.Clear(); @@ -56,13 +56,21 @@ namespace osu.Game.Rulesets.Osu.Scoring scoreResultCounts[judgement.Score] = scoreResultCounts.GetOrDefault(judgement.Score) + 1; comboResultCounts[judgement.Combo] = comboResultCounts.GetOrDefault(judgement.Combo) + 1; } - - switch (judgement.Result) + switch (judgement.Score) { - case HitResult.Hit: - Health.Value += 0.1f; + case OsuScoreResult.Hit300: + Health.Value += 0.01f; break; - case HitResult.Miss: + + case OsuScoreResult.Hit100: + Health.Value -= 0.01f; + break; + + case OsuScoreResult.Hit50: + Health.Value -= 0.05f; + break; + + case OsuScoreResult.Miss: Health.Value -= 0.2f; break; } From cbc35e0cf3040caff865a33b5a64c3e018951b0d Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 31 Aug 2017 04:31:48 -0400 Subject: [PATCH 075/107] implemented hp --- .../Scoring/OsuScoreProcessor.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index df97e06118..3a06ef2260 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -23,6 +23,14 @@ namespace osu.Game.Rulesets.Osu.Scoring { } + + float beatmapHp = 0; + + protected override void ComputeTargets(Game.Beatmaps.Beatmap beatmap) + { + beatmapHp = beatmap.BeatmapInfo.Difficulty.DrainRate; + } + protected override void Reset() { base.Reset(); @@ -59,19 +67,19 @@ namespace osu.Game.Rulesets.Osu.Scoring switch (judgement.Score) { case OsuScoreResult.Hit300: - Health.Value += 0.01f; + Health.Value += (10.2 - beatmapHp) * 0.02; break; case OsuScoreResult.Hit100: - Health.Value -= 0.01f; + Health.Value += (8 - beatmapHp) * 0.02; break; case OsuScoreResult.Hit50: - Health.Value -= 0.05f; + Health.Value += (4 - beatmapHp) * 0.02; break; case OsuScoreResult.Miss: - Health.Value -= 0.2f; + Health.Value -= beatmapHp * 0.04; break; } } From af2f45a98058f175b52b89703478c10cd0fb8d34 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 31 Aug 2017 04:44:00 -0400 Subject: [PATCH 076/107] slight edits --- osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index 3a06ef2260..a0662ab51d 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Scoring } - float beatmapHp = 0; + float beatmapHp; protected override void ComputeTargets(Game.Beatmaps.Beatmap beatmap) { @@ -78,6 +78,10 @@ namespace osu.Game.Rulesets.Osu.Scoring Health.Value += (4 - beatmapHp) * 0.02; break; + case OsuScoreResult.SliderTick: + Health.Value += System.Math.Max(7 - beatmapHp, 0) * 0.01; + break; + case OsuScoreResult.Miss: Health.Value -= beatmapHp * 0.04; break; From 04596fee6122886b6488b0dc547b0a65bde61350 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 31 Aug 2017 08:26:06 -0400 Subject: [PATCH 077/107] Update OsuScoreProcessor.cs --- osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index a0662ab51d..7760e773d3 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Osu.Scoring { base.Reset(); - Health.Value = 0.5; + Health.Value = 1; Accuracy.Value = 1; scoreResultCounts.Clear(); From 472710e5db861b3065bbcc7554ad92eb4d1371e4 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 31 Aug 2017 21:35:30 -0400 Subject: [PATCH 078/107] trim whitespace --- osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index a0662ab51d..a079eb4c80 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -23,7 +23,6 @@ namespace osu.Game.Rulesets.Osu.Scoring { } - float beatmapHp; protected override void ComputeTargets(Game.Beatmaps.Beatmap beatmap) From 1f646e6d548a988fba0fbc102a09e02574a35c85 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2017 15:49:56 +0900 Subject: [PATCH 079/107] Add hiding support for beatmap difficulties --- osu-framework | 2 +- osu.Game/Beatmaps/BeatmapInfo.cs | 2 + osu.Game/Beatmaps/BeatmapManager.cs | 57 ++++++++++++------- osu.Game/Beatmaps/BeatmapStore.cs | 43 +++++++++++++- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 5 +- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 2 +- .../Beatmaps/Drawables/BeatmapSetHeader.cs | 6 ++ osu.Game/Screens/Select/BeatmapCarousel.cs | 38 +++++++++++-- .../Screens/Select/BeatmapDeleteDialog.cs | 19 +------ osu.Game/Screens/Select/SongSelect.cs | 21 +++---- 10 files changed, 136 insertions(+), 59 deletions(-) diff --git a/osu-framework b/osu-framework index 167d5cda8f..2804e052ca 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 167d5cda8f3ddae702ffc8d8d22dac67e48b509c +Subproject commit 2804e052ca2ce068f015771d28170d18573687e1 diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index ebf77bf9df..c962201fe3 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -52,6 +52,8 @@ namespace osu.Game.Beatmaps [JsonProperty("file_sha2")] public string Hash { get; set; } + public bool Hidden { get; set; } + /// /// MD5 is kept for legacy support (matching against replays, osu-web-10 etc.). /// diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index c52576fb9f..551612330b 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -33,11 +33,21 @@ namespace osu.Game.Beatmaps /// public event Action BeatmapSetAdded; + /// + /// Fired when a single difficulty has been hidden. + /// + public event Action BeatmapHidden; + /// /// Fired when a is removed from the database. /// public event Action BeatmapSetRemoved; + /// + /// Fired when a single difficulty has been restored. + /// + public event Action BeatmapRestored; + /// /// A default representation of a WorkingBeatmap to use when no beatmap is available. /// @@ -71,6 +81,8 @@ namespace osu.Game.Beatmaps beatmaps = new BeatmapStore(connection); beatmaps.BeatmapSetAdded += s => BeatmapSetAdded?.Invoke(s); beatmaps.BeatmapSetRemoved += s => BeatmapSetRemoved?.Invoke(s); + beatmaps.BeatmapHidden += b => BeatmapHidden?.Invoke(b); + beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b); this.storage = storage; this.files = files; @@ -162,8 +174,7 @@ namespace osu.Game.Beatmaps // If we have an ID then we already exist in the database. if (beatmapSetInfo.ID != 0) return; - lock (beatmaps) - beatmaps.Add(beatmapSetInfo); + beatmaps.Add(beatmapSetInfo); } /// @@ -173,22 +184,23 @@ namespace osu.Game.Beatmaps /// The beatmap set to delete. public void Delete(BeatmapSetInfo beatmapSet) { - lock (beatmaps) - if (!beatmaps.Delete(beatmapSet)) return; + if (!beatmaps.Delete(beatmapSet)) return; if (!beatmapSet.Protected) files.Dereference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); } /// - /// Delete a beatmap from the manager. - /// Is a no-op for already deleted beatmaps. + /// Delete a beatmap difficulty. /// - /// The beatmap difficulty to delete. - public void Delete(BeatmapInfo beatmap) - { - //todo: implement - } + /// The beatmap difficulty to hide. + public void Hide(BeatmapInfo beatmap) => beatmaps.Hide(beatmap); + + /// + /// Restore a beatmap difficulty. + /// + /// The beatmap difficulty to restore. + public void Restore(BeatmapInfo beatmap) => beatmaps.Restore(beatmap); /// /// Returns a to a usable state if it has previously been deleted but not yet purged. @@ -197,8 +209,7 @@ namespace osu.Game.Beatmaps /// The beatmap to restore. public void Undelete(BeatmapSetInfo beatmapSet) { - lock (beatmaps) - if (!beatmaps.Undelete(beatmapSet)) return; + if (!beatmaps.Undelete(beatmapSet)) return; if (!beatmapSet.Protected) files.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); @@ -258,6 +269,13 @@ namespace osu.Game.Beatmaps } } + /// + /// Refresh an existing instance of a from the store. + /// + /// A stale instance. + /// A fresh instance. + public BeatmapSetInfo Refresh(BeatmapSetInfo beatmapSet) => QueryBeatmapSet(s => s.ID == beatmapSet.ID); + /// /// Perform a lookup query on available s. /// @@ -265,7 +283,7 @@ namespace osu.Game.Beatmaps /// Results from the provided query. public List QueryBeatmapSets(Expression> query) { - lock (beatmaps) return beatmaps.QueryAndPopulate(query); + return beatmaps.QueryAndPopulate(query); } /// @@ -275,15 +293,12 @@ namespace osu.Game.Beatmaps /// The first result for the provided query, or null if no results were found. public BeatmapInfo QueryBeatmap(Func query) { - lock (beatmaps) - { - BeatmapInfo set = beatmaps.Query().FirstOrDefault(query); + BeatmapInfo set = beatmaps.Query().FirstOrDefault(query); - if (set != null) - beatmaps.Populate(set); + if (set != null) + beatmaps.Populate(set); - return set; - } + return set; } /// diff --git a/osu.Game/Beatmaps/BeatmapStore.cs b/osu.Game/Beatmaps/BeatmapStore.cs index 8212712bf9..0f2d8cffa6 100644 --- a/osu.Game/Beatmaps/BeatmapStore.cs +++ b/osu.Game/Beatmaps/BeatmapStore.cs @@ -16,11 +16,14 @@ namespace osu.Game.Beatmaps public event Action BeatmapSetAdded; public event Action BeatmapSetRemoved; + public event Action BeatmapHidden; + public event Action BeatmapRestored; + /// /// The current version of this store. Used for migrations (see ). /// The initial version is 1. /// - protected override int StoreVersion => 3; + protected override int StoreVersion => 4; public BeatmapStore(SQLiteConnection connection) : base(connection) @@ -81,6 +84,10 @@ namespace osu.Game.Beatmaps // Added MD5Hash column to BeatmapInfo Connection.MigrateTable(); break; + case 4: + // Added Hidden column to BeatmapInfo + Connection.MigrateTable(); + break; } } } @@ -100,7 +107,7 @@ namespace osu.Game.Beatmaps } /// - /// Delete a to the database. + /// Delete a from the database. /// /// The beatmap to delete. /// Whether the beatmap's was changed. @@ -131,6 +138,38 @@ namespace osu.Game.Beatmaps return true; } + /// + /// Hide a in the database. + /// + /// The beatmap to hide. + /// Whether the beatmap's was changed. + public bool Hide(BeatmapInfo beatmap) + { + if (beatmap.Hidden) return false; + + beatmap.Hidden = true; + Connection.Update(beatmap); + + BeatmapHidden?.Invoke(beatmap); + return true; + } + + /// + /// Restore a previously hidden . + /// + /// The beatmap to restore. + /// Whether the beatmap's was changed. + public bool Restore(BeatmapInfo beatmap) + { + if (!beatmap.Hidden) return false; + + beatmap.Hidden = false; + Connection.Update(beatmap); + + BeatmapRestored?.Invoke(beatmap); + return true; + } + private void cleanupPendingDeletions() { Connection.RunInTransaction(() => diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index b47210620d..19dfc22506 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -25,6 +25,8 @@ namespace osu.Game.Beatmaps.Drawables public Action DeleteRequested; + public Action RestoreHiddenRequested; + public Action DeleteDifficultyRequested; public BeatmapSetHeader Header; @@ -71,10 +73,11 @@ namespace osu.Game.Beatmaps.Drawables { GainedSelection = headerGainedSelection, DeleteRequested = b => DeleteRequested(b), + RestoreHiddenRequested = b => RestoreHiddenRequested(b), RelativeSizeAxes = Axes.X, }; - BeatmapSet.Beatmaps = BeatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList(); + BeatmapSet.Beatmaps = BeatmapSet.Beatmaps.Where(b => !b.Hidden).OrderBy(b => b.StarDifficulty).ToList(); BeatmapPanels = BeatmapSet.Beatmaps.Select(b => new BeatmapPanel(b) { Alpha = 0, diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 1006380a2b..6b17b3bb8b 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -158,7 +158,7 @@ namespace osu.Game.Beatmaps.Drawables { new OsuMenuItem("Play", MenuItemType.Highlighted, () => StartRequested?.Invoke(this)), new OsuMenuItem("Edit", MenuItemType.Standard, () => EditRequested?.Invoke(this)), - new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(Beatmap)), + new OsuMenuItem("Hide", MenuItemType.Destructive, () => DeleteRequested?.Invoke(Beatmap)), }; } } diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index b475a23ffd..ee75b77747 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -25,6 +26,8 @@ namespace osu.Game.Beatmaps.Drawables public Action DeleteRequested; + public Action RestoreHiddenRequested; + private readonly SpriteText title; private readonly SpriteText artist; @@ -164,6 +167,9 @@ namespace osu.Game.Beatmaps.Drawables if (State == PanelSelectedState.NotSelected) items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => State = PanelSelectedState.Selected)); + if (beatmap.BeatmapSetInfo.Beatmaps.Any(b => b.Hidden)) + items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => RestoreHiddenRequested?.Invoke(beatmap.BeatmapSetInfo))); + items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(beatmap.BeatmapSetInfo))); return items.ToArray(); diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index a1c7f64188..5d495a61f0 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -107,12 +107,39 @@ namespace osu.Game.Screens.Select }); } - public void RemoveBeatmap(BeatmapSetInfo beatmapSet) + public void RemoveBeatmap(BeatmapSetInfo beatmapSet) => removeGroup(groups.Find(b => b.BeatmapSet.ID == beatmapSet.ID)); + + internal void UpdateBeatmap(BeatmapInfo beatmap) { - Schedule(delegate + // todo: this method should not run more than once for the same BeatmapSetInfo. + var set = manager.Refresh(beatmap.BeatmapSet); + + // todo: this method should be smarter as to not recreate panels that haven't changed, etc. + var group = groups.Find(b => b.BeatmapSet.ID == set.ID); + + if (group == null) + return; + + var newGroup = createGroup(set); + + int i = groups.IndexOf(group); + groups.RemoveAt(i); + groups.Insert(i, newGroup); + + if (selectedGroup == group && newGroup.BeatmapPanels.Count == 0) + selectedGroup = null; + + Filter(null, false); + + //check if we can/need to maintain our current selection. + if (selectedGroup == group && newGroup.BeatmapPanels.Count > 0) { - removeGroup(groups.Find(b => b.BeatmapSet.ID == beatmapSet.ID)); - }); + var newSelection = + newGroup.BeatmapPanels.Find(p => p.Beatmap.ID == selectedPanel?.Beatmap.ID) ?? + newGroup.BeatmapPanels[Math.Min(newGroup.BeatmapPanels.Count - 1, group.BeatmapPanels.IndexOf(selectedPanel))]; + + selectGroup(newGroup, newSelection); + } } public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true) @@ -142,6 +169,8 @@ namespace osu.Game.Screens.Select public Action DeleteRequested; + public Action RestoreRequested; + public Action DeleteDifficultyRequested; public void SelectNext(int direction = 1, bool skipDifficulties = true) @@ -310,6 +339,7 @@ namespace osu.Game.Screens.Select SelectionChanged = (g, p) => selectGroup(g, p), StartRequested = b => StartRequested?.Invoke(), DeleteRequested = b => DeleteRequested?.Invoke(b), + RestoreHiddenRequested = s => RestoreRequested?.Invoke(s), DeleteDifficultyRequested = b => DeleteDifficultyRequested?.Invoke(b), State = BeatmapGroupState.Collapsed }; diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index 15ec84a7d8..aa37705cdf 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -13,28 +12,16 @@ namespace osu.Game.Screens.Select { private BeatmapManager manager; - private readonly Action deleteAction; - [BackgroundDependencyLoader] private void load(BeatmapManager beatmapManager) { manager = beatmapManager; } - public BeatmapDeleteDialog(BeatmapSetInfo beatmap) : this() + public BeatmapDeleteDialog(BeatmapSetInfo beatmap) { - BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} (ALL DIFFICULTIES)"; - deleteAction = () => manager.Delete(beatmap); - } + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; - public BeatmapDeleteDialog(BeatmapInfo beatmap) : this() - { - BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} [{beatmap.Version}]"; - deleteAction = () => manager.Delete(beatmap); - } - - public BeatmapDeleteDialog() - { Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; Buttons = new PopupDialogButton[] @@ -42,7 +29,7 @@ namespace osu.Game.Screens.Select new PopupDialogOkButton { Text = @"Yes. Totally. Delete it.", - Action = () => deleteAction(), + Action = () => manager.Delete(beatmap), }, new PopupDialogCancelButton { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index b3ee33e7c6..b743af5351 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -107,7 +107,8 @@ namespace osu.Game.Screens.Select SelectionChanged = carouselSelectionChanged, BeatmapsChanged = carouselBeatmapsLoaded, DeleteRequested = b => promptDelete(b), - DeleteDifficultyRequested = b => promptDelete(b), + RestoreRequested = s => { foreach (var b in s.Beatmaps) manager.Restore(b); }, + DeleteDifficultyRequested = b => manager.Hide(b), StartRequested = () => carouselRaisedStart(), }); Add(FilterControl = new FilterControl @@ -176,6 +177,8 @@ namespace osu.Game.Screens.Select manager.BeatmapSetAdded += onBeatmapSetAdded; manager.BeatmapSetRemoved += onBeatmapSetRemoved; + manager.BeatmapHidden += onBeatmapHidden; + manager.BeatmapRestored += onBeatmapRestored; dialogOverlay = dialog; @@ -192,6 +195,9 @@ namespace osu.Game.Screens.Select carousel.AllowSelection = !Beatmap.Disabled; } + private void onBeatmapRestored(BeatmapInfo b) => carousel.UpdateBeatmap(b); + private void onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmap(b); + private void carouselBeatmapsLoaded() { if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false) @@ -380,10 +386,7 @@ namespace osu.Game.Screens.Select } } - private void addBeatmapSet(BeatmapSetInfo beatmapSet) - { - carousel.AddBeatmap(beatmapSet); - } + private void addBeatmapSet(BeatmapSetInfo beatmapSet) => carousel.AddBeatmap(beatmapSet); private void removeBeatmapSet(BeatmapSetInfo beatmapSet) { @@ -400,14 +403,6 @@ namespace osu.Game.Screens.Select dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); } - private void promptDelete(BeatmapInfo beatmap) - { - if (beatmap == null) - return; - - dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); - } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Repeat) return false; From f9d02afb007870f8bf9d778f99fd4de9d047af46 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Sep 2017 18:13:21 +0900 Subject: [PATCH 080/107] Don't allow selection of a hidden beatmap --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 5d495a61f0..8cdfcf1db0 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -144,7 +144,7 @@ namespace osu.Game.Screens.Select public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true) { - if (beatmap == null) + if (beatmap == null || beatmap.Hidden) { SelectNext(); return; From 3d61cde266f3aac7149e9f18893bff6a8ecfd211 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Sep 2017 18:22:38 +0900 Subject: [PATCH 081/107] Correctly delay loading of PlaySongSelect-specific components --- osu.Game/Screens/Select/PlaySongSelect.cs | 6 ++---- osu.Game/Screens/Select/SongSelect.cs | 11 ++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 662e1d55a2..7e03707d18 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -54,13 +54,11 @@ namespace osu.Game.Screens.Select ValidForResume = false; Push(new Editor()); }, Key.Number3); - - Beatmap.ValueChanged += beatmap_ValueChanged; } - private void beatmap_ValueChanged(WorkingBeatmap beatmap) + protected override void UpdateBeatmap(WorkingBeatmap beatmap) { - if (!IsCurrentScreen) return; + base.UpdateBeatmap(beatmap); beatmap.Mods.BindTo(modSelect.SelectedMods); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index b743af5351..e0e27e069d 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -244,7 +244,7 @@ namespace osu.Game.Screens.Select ensurePlayingSelected(preview); } - changeBackground(Beatmap.Value); + UpdateBeatmap(Beatmap.Value); }; selectionChangedDebounce?.Cancel(); @@ -312,7 +312,7 @@ namespace osu.Game.Screens.Select { if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending) { - changeBackground(Beatmap); + UpdateBeatmap(Beatmap); ensurePlayingSelected(); } @@ -358,7 +358,12 @@ namespace osu.Game.Screens.Select initialAddSetsTask?.Cancel(); } - private void changeBackground(WorkingBeatmap beatmap) + /// + /// Allow components in SongSelect to update their loaded beatmap details. + /// This is a debounced call (unlike directly binding to WorkingBeatmap.ValueChanged). + /// + /// The working beatmap. + protected virtual void UpdateBeatmap(WorkingBeatmap beatmap) { var backgroundModeBeatmap = Background as BackgroundScreenBeatmap; if (backgroundModeBeatmap != null) From 8e0d18d36f73ddca1d66ef44e3707f900e6c0d8d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Sep 2017 18:26:01 +0900 Subject: [PATCH 082/107] Add a button to restore all hidden difficulties --- .../Sections/Maintenance/GeneralSettings.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 9d13a2ae2f..233ca7be60 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -13,6 +13,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance { private OsuButton importButton; private OsuButton deleteButton; + private OsuButton restoreButton; protected override string Header => "General"; @@ -41,6 +42,20 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); } }, + restoreButton = new OsuButton + { + RelativeSizeAxes = Axes.X, + Text = "Restore all hidden difficulties", + Action = () => + { + restoreButton.Enabled.Value = false; + Task.Run(() => + { + foreach (var b in beatmaps.QueryBeatmaps(b => b.Hidden)) + beatmaps.Restore(b); + }).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true)); + } + }, }; } } From b19ae7c44ed3c9df5d1fb7200c11a53d59b84651 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Sep 2017 18:37:46 +0900 Subject: [PATCH 083/107] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 2804e052ca..2bd341b29d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2804e052ca2ce068f015771d28170d18573687e1 +Subproject commit 2bd341b29d6a7ed864aa9c1c5fad4668dafe03a4 From 3ede685ee9985065c079e2099dd2cf0a4706bb2a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Sep 2017 18:44:51 +0900 Subject: [PATCH 084/107] Fix crash on random selection from a previously null selection --- osu.Game/Screens/Select/BeatmapCarousel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 264636b258..556ba68e95 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -191,7 +191,8 @@ namespace osu.Game.Screens.Select if (!visibleGroups.Any()) return; - randomSelectedBeatmaps.Push(new KeyValuePair(selectedGroup, selectedGroup.SelectedPanel)); + if (selectedGroup != null) + randomSelectedBeatmaps.Push(new KeyValuePair(selectedGroup, selectedGroup.SelectedPanel)); BeatmapGroup group; From c6b226b017f7a9212a195164983202ddbcf0bf42 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Fri, 1 Sep 2017 15:32:03 -0400 Subject: [PATCH 085/107] refactor --- osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index db39629d45..a66ac3298f 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Scoring { } - float beatmapHp; + private float beatmapHp; protected override void ComputeTargets(Game.Beatmaps.Beatmap beatmap) { From dd26c80837edb47bb5287c740e1d67b3e5338cb7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 4 Sep 2017 07:59:32 +0900 Subject: [PATCH 086/107] Delete -> Hide --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 4 ++-- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 4 ++-- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 19dfc22506..4a389101e2 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -27,7 +27,7 @@ namespace osu.Game.Beatmaps.Drawables public Action RestoreHiddenRequested; - public Action DeleteDifficultyRequested; + public Action HideDifficultyRequested; public BeatmapSetHeader Header; @@ -82,7 +82,7 @@ namespace osu.Game.Beatmaps.Drawables { Alpha = 0, GainedSelection = panelGainedSelection, - DeleteRequested = p => DeleteDifficultyRequested?.Invoke(p), + HideRequested = p => HideDifficultyRequested?.Invoke(p), StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, RelativeSizeAxes = Axes.X, }).ToList(); diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 6b17b3bb8b..e216f1b83e 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -27,7 +27,7 @@ namespace osu.Game.Beatmaps.Drawables public Action GainedSelection; public Action StartRequested; public Action EditRequested; - public Action DeleteRequested; + public Action HideRequested; private readonly Triangles triangles; private readonly StarCounter starCounter; @@ -158,7 +158,7 @@ namespace osu.Game.Beatmaps.Drawables { new OsuMenuItem("Play", MenuItemType.Highlighted, () => StartRequested?.Invoke(this)), new OsuMenuItem("Edit", MenuItemType.Standard, () => EditRequested?.Invoke(this)), - new OsuMenuItem("Hide", MenuItemType.Destructive, () => DeleteRequested?.Invoke(Beatmap)), + new OsuMenuItem("Hide", MenuItemType.Destructive, () => HideRequested?.Invoke(Beatmap)), }; } } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 7044447508..94ae740c74 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -171,7 +171,7 @@ namespace osu.Game.Screens.Select public Action RestoreRequested; - public Action DeleteDifficultyRequested; + public Action HideDifficultyRequested; public void SelectNext(int direction = 1, bool skipDifficulties = true) { @@ -341,7 +341,7 @@ namespace osu.Game.Screens.Select StartRequested = b => StartRequested?.Invoke(), DeleteRequested = b => DeleteRequested?.Invoke(b), RestoreHiddenRequested = s => RestoreRequested?.Invoke(s), - DeleteDifficultyRequested = b => DeleteDifficultyRequested?.Invoke(b), + HideDifficultyRequested = b => HideDifficultyRequested?.Invoke(b), State = BeatmapGroupState.Collapsed }; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e0e27e069d..8925732128 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -108,7 +108,7 @@ namespace osu.Game.Screens.Select BeatmapsChanged = carouselBeatmapsLoaded, DeleteRequested = b => promptDelete(b), RestoreRequested = s => { foreach (var b in s.Beatmaps) manager.Restore(b); }, - DeleteDifficultyRequested = b => manager.Hide(b), + HideDifficultyRequested = b => manager.Hide(b), StartRequested = () => carouselRaisedStart(), }); Add(FilterControl = new FilterControl From 543a71efcc7a8dfff9c5c40d5f99bef42509e0b8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 4 Sep 2017 08:21:07 +0900 Subject: [PATCH 087/107] Fix ObjectDisposal exceptions due to lingering event binds --- osu.Game/Screens/Select/SongSelect.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 8925732128..f97c4fe420 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -353,6 +353,8 @@ namespace osu.Game.Screens.Select { manager.BeatmapSetAdded -= onBeatmapSetAdded; manager.BeatmapSetRemoved -= onBeatmapSetRemoved; + manager.BeatmapHidden -= onBeatmapHidden; + manager.BeatmapRestored -= onBeatmapRestored; } initialAddSetsTask?.Cancel(); From 57678a13d9d3faf49fe0f422b8716893a73bf7f8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 09:10:04 +0900 Subject: [PATCH 088/107] Update in-line with framework changes. --- osu-framework | 2 +- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 9 ++++++++- osu.Game/Beatmaps/Drawables/Panel.cs | 9 ++++++++- .../Containers/OsuFocusedOverlayContainer.cs | 6 +++--- .../Graphics/UserInterface/BreadcrumbControl.cs | 6 ++++++ .../Graphics/UserInterface/OsuContextMenu.cs | 9 +++++---- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 14 +++++--------- osu.Game/Graphics/UserInterface/OsuMenu.cs | 16 +++++++--------- osu.Game/OsuGame.cs | 4 ++-- osu.Game/Overlays/ChatOverlay.cs | 2 +- osu.Game/Overlays/DialogOverlay.cs | 2 +- osu.Game/Overlays/MainSettings.cs | 2 +- osu.Game/Overlays/MedalSplash/DrawableMedal.cs | 5 +++++ osu.Game/Overlays/MusicController.cs | 2 +- .../Settings/Sections/General/LoginSettings.cs | 4 ++-- osu.Game/Overlays/Settings/Sidebar.cs | 6 ++++++ .../Toolbar/ToolbarOverlayToggleButton.cs | 2 +- osu.Game/Overlays/WaveOverlayContainer.cs | 5 +++++ osu.Game/Screens/Menu/Button.cs | 4 ++++ osu.Game/Screens/Menu/ButtonSystem.cs | 4 ++++ osu.Game/Screens/Play/SkipButton.cs | 8 +++++++- osu.Game/Screens/Play/SquareGraph.cs | 6 ++++++ .../Select/Leaderboards/LeaderboardScore.cs | 8 ++++++++ 23 files changed, 97 insertions(+), 38 deletions(-) diff --git a/osu-framework b/osu-framework index 2bd341b29d..5c0e50379e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2bd341b29d6a7ed864aa9c1c5fad4668dafe03a4 +Subproject commit 5c0e50379e47a3805097dbc36a713decc64f49ce diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 4a389101e2..c66bf637e2 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -11,6 +11,8 @@ namespace osu.Game.Beatmaps.Drawables { public class BeatmapGroup : IStateful { + public event Action StateChanged; + public BeatmapPanel SelectedPanel; /// @@ -42,6 +44,10 @@ namespace osu.Game.Beatmaps.Drawables get { return state; } set { + if (state == value) + return; + state = value; + switch (value) { case BeatmapGroupState.Expanded: @@ -60,7 +66,8 @@ namespace osu.Game.Beatmaps.Drawables panel.State = PanelSelectedState.Hidden; break; } - state = value; + + StateChanged?.Invoke(state); } } diff --git a/osu.Game/Beatmaps/Drawables/Panel.cs b/osu.Game/Beatmaps/Drawables/Panel.cs index d07be88392..d6ed306b39 100644 --- a/osu.Game/Beatmaps/Drawables/Panel.cs +++ b/osu.Game/Beatmaps/Drawables/Panel.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -15,6 +16,8 @@ namespace osu.Game.Beatmaps.Drawables { public const float MAX_HEIGHT = 80; + public event Action StateChanged; + public override bool RemoveWhenNotAlive => false; private readonly Container nestedContainer; @@ -77,11 +80,15 @@ namespace osu.Game.Beatmaps.Drawables set { - if (state == value) return; + if (state == value) + return; var last = state; state = value; + ApplyState(last); + + StateChanged?.Invoke(State); } } diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 0713fa1a52..4ea4f4cdc3 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -19,12 +19,12 @@ namespace osu.Game.Graphics.Containers samplePopIn = audio.Sample.Get(@"UI/melodic-5"); samplePopOut = audio.Sample.Get(@"UI/melodic-4"); - StateChanged += OsuFocusedOverlayContainer_StateChanged; + StateChanged += onStateChanged; } - private void OsuFocusedOverlayContainer_StateChanged(VisibilityContainer arg1, Visibility arg2) + private void onStateChanged(Visibility visibility) { - switch (arg2) + switch (visibility) { case Visibility.Visible: samplePopIn?.Play(); diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index b3e53280fb..65ece51a70 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using osu.Framework; using osu.Framework.Graphics; @@ -35,6 +36,8 @@ namespace osu.Game.Graphics.UserInterface private class BreadcrumbTabItem : OsuTabItem, IStateful { + public event Action StateChanged; + public readonly SpriteIcon Chevron; //don't allow clicking between transitions and don't make the chevron clickable @@ -42,6 +45,7 @@ namespace osu.Game.Graphics.UserInterface public override bool HandleInput => State == Visibility.Visible; private Visibility state; + public Visibility State { get { return state; } @@ -62,6 +66,8 @@ namespace osu.Game.Graphics.UserInterface this.FadeOut(transition_duration, Easing.OutQuint); this.ScaleTo(new Vector2(0.8f, 1f), transition_duration, Easing.OutQuint); } + + StateChanged?.Invoke(State); } } diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs index 808c72ee5d..4ce6c98744 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenu.cs @@ -14,14 +14,17 @@ namespace osu.Game.Graphics.UserInterface private const int fade_duration = 250; public OsuContextMenu() + : base(Direction.Vertical) { - CornerRadius = 5; - EdgeEffect = new EdgeEffectParameters + MaskingContainer.CornerRadius = 5; + MaskingContainer.EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.1f), Radius = 4, }; + + ItemsContainer.Padding = new MarginPadding { Vertical = DrawableOsuMenuItem.MARGIN_VERTICAL }; } [BackgroundDependencyLoader] @@ -32,7 +35,5 @@ namespace osu.Game.Graphics.UserInterface protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint); protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint); - - protected override MarginPadding ItemFlowContainerPadding => new MarginPadding { Vertical = DrawableOsuMenuItem.MARGIN_VERTICAL }; } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index dde154bb61..275cc2ab64 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -57,6 +57,9 @@ namespace osu.Game.Graphics.UserInterface { CornerRadius = 4; BackgroundColour = Color4.Black.Opacity(0.5f); + + // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring + ItemsContainer.Padding = new MarginPadding(5); } // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring @@ -64,14 +67,7 @@ namespace osu.Game.Graphics.UserInterface protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint); // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring - protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(5); - - // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring - protected override void UpdateMenuHeight() - { - var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight; - this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint); - } + protected override void UpdateSize(Vector2 newSize) => this.ResizeTo(newSize, 300, Easing.OutQuint); private Color4 accentColour; public Color4 AccentColour @@ -141,7 +137,7 @@ namespace osu.Game.Graphics.UserInterface protected override Drawable CreateContent() => new Content(); - protected class Content : FillFlowContainer, IHasText + protected new class Content : FillFlowContainer, IHasText { public string Text { diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index ab37fd2c90..a8cb8cafbb 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -12,27 +12,25 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; +using OpenTK; namespace osu.Game.Graphics.UserInterface { public class OsuMenu : Menu { - public OsuMenu() + public OsuMenu(Direction direction) + : base(direction) { - CornerRadius = 4; BackgroundColour = Color4.Black.Opacity(0.5f); + + MaskingContainer.CornerRadius = 4; + ItemsContainer.Padding = new MarginPadding(5); } protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint); protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint); - protected override void UpdateMenuHeight() - { - var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight; - this.ResizeHeightTo(State == MenuState.Opened ? actualHeight : 0, 300, Easing.OutQuint); - } - - protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(5); + protected override void UpdateSize(Vector2 newSize) => this.ResizeTo(newSize, 300, Easing.OutQuint); protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuMenuItem(item); diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 30bc09d50f..c020675881 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -230,13 +230,13 @@ namespace osu.Game var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct }; foreach (var overlay in singleDisplayOverlays) { - overlay.StateChanged += (container, state) => + overlay.StateChanged += state => { if (state == Visibility.Hidden) return; foreach (var c in singleDisplayOverlays) { - if (c == container) continue; + if (c == overlay) continue; c.State = Visibility.Hidden; } }; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 6dd5425fd1..b5bb1a2d9f 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -169,7 +169,7 @@ namespace osu.Game.Overlays channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel; channelTabs.ChannelSelectorActive.ValueChanged += value => channelSelection.State = value ? Visibility.Visible : Visibility.Hidden; - channelSelection.StateChanged += (overlay, state) => + channelSelection.StateChanged += state => { channelTabs.ChannelSelectorActive.Value = state == Visibility.Visible; diff --git a/osu.Game/Overlays/DialogOverlay.cs b/osu.Game/Overlays/DialogOverlay.cs index 012e93f10d..7853eefd2c 100644 --- a/osu.Game/Overlays/DialogOverlay.cs +++ b/osu.Game/Overlays/DialogOverlay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays dialogContainer.Add(currentDialog); currentDialog.Show(); - currentDialog.StateChanged += onDialogOnStateChanged; + currentDialog.StateChanged += state => onDialogOnStateChanged(dialog, state); State = Visibility.Visible; } diff --git a/osu.Game/Overlays/MainSettings.cs b/osu.Game/Overlays/MainSettings.cs index b4d9cac045..4fe86d62fd 100644 --- a/osu.Game/Overlays/MainSettings.cs +++ b/osu.Game/Overlays/MainSettings.cs @@ -53,7 +53,7 @@ namespace osu.Game.Overlays private const float hidden_width = 120; - private void keyBindingOverlay_StateChanged(VisibilityContainer container, Visibility visibility) + private void keyBindingOverlay_StateChanged(Visibility visibility) { switch (visibility) { diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index 56b26e7176..3ac8af7b2b 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework; using OpenTK; using osu.Framework.Allocation; @@ -19,6 +20,8 @@ namespace osu.Game.Overlays.MedalSplash private const float scale_when_unlocked = 0.76f; private const float scale_when_full = 0.6f; + public event Action StateChanged; + private readonly Medal medal; private readonly Container medalContainer; private readonly Sprite medalSprite, medalGlow; @@ -132,6 +135,8 @@ namespace osu.Game.Overlays.MedalSplash state = value; updateState(); + + StateChanged?.Invoke(State); } } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index cb4628825e..0a06439c3e 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -204,7 +204,7 @@ namespace osu.Game.Overlays beatmapBacking.BindTo(game.Beatmap); - playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); + playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); } protected override void LoadComplete() diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index a816fa56c1..e62050fae1 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -292,6 +292,8 @@ namespace osu.Game.Overlays.Settings.Sections.General Colour = Color4.Black.Opacity(0.25f), Radius = 4, }; + + ItemsContainer.Padding = new MarginPadding(); } [BackgroundDependencyLoader] @@ -300,8 +302,6 @@ namespace osu.Game.Overlays.Settings.Sections.General BackgroundColour = colours.Gray3; } - protected override MarginPadding ItemFlowContainerPadding => new MarginPadding(); - protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableUserDropdownMenuItem(item); private class DrawableUserDropdownMenuItem : DrawableOsuDropdownMenuItem diff --git a/osu.Game/Overlays/Settings/Sidebar.cs b/osu.Game/Overlays/Settings/Sidebar.cs index b22a5ab126..55167188a3 100644 --- a/osu.Game/Overlays/Settings/Sidebar.cs +++ b/osu.Game/Overlays/Settings/Sidebar.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Linq; using osu.Framework; using OpenTK; @@ -19,6 +20,9 @@ namespace osu.Game.Overlays.Settings private readonly FillFlowContainer content; internal const float DEFAULT_WIDTH = ToolbarButton.WIDTH; internal const int EXPANDED_WIDTH = 200; + + public event Action StateChanged; + protected override Container Content => content; public Sidebar() @@ -102,6 +106,8 @@ namespace osu.Game.Overlays.Settings this.ResizeTo(new Vector2(EXPANDED_WIDTH, Height), 500, Easing.OutQuint); break; } + + StateChanged?.Invoke(State); } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs index 6d61a096b2..c530e8d7ff 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs @@ -45,7 +45,7 @@ namespace osu.Game.Overlays.Toolbar stateContainer.StateChanged -= stateChanged; } - private void stateChanged(VisibilityContainer c, Visibility state) + private void stateChanged(Visibility state) { switch (state) { diff --git a/osu.Game/Overlays/WaveOverlayContainer.cs b/osu.Game/Overlays/WaveOverlayContainer.cs index fd89dcfbc4..4f9783a762 100644 --- a/osu.Game/Overlays/WaveOverlayContainer.cs +++ b/osu.Game/Overlays/WaveOverlayContainer.cs @@ -167,6 +167,8 @@ namespace osu.Game.Overlays private class Wave : Container, IStateful { + public event Action StateChanged; + public float FinalPosition; public Wave() @@ -200,6 +202,7 @@ namespace osu.Game.Overlays } private Visibility state; + public Visibility State { get { return state; } @@ -216,6 +219,8 @@ namespace osu.Game.Overlays this.MoveToY(FinalPosition, APPEAR_DURATION, easing_show); break; } + + StateChanged?.Invoke(State); } } } diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 0898c079ce..aca169c3dc 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -28,6 +28,8 @@ namespace osu.Game.Screens.Menu /// public class Button : BeatSyncedContainer, IStateful { + public event Action StateChanged; + private readonly Container iconText; private readonly Container box; private readonly Box boxHoverLayer; @@ -266,6 +268,8 @@ namespace osu.Game.Screens.Menu this.FadeOut(explode_duration / 4f * 3); break; } + + StateChanged?.Invoke(State); } } } diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 71f2a16c09..e4dbe00a80 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -22,6 +22,8 @@ namespace osu.Game.Screens.Menu { public class ButtonSystem : Container, IStateful { + public event Action StateChanged; + public Action OnEdit; public Action OnExit; public Action OnDirect; @@ -294,6 +296,8 @@ namespace osu.Game.Screens.Menu backButton.State = state == MenuState.Play ? ButtonState.Expanded : ButtonState.Contracted; settingsButton.State = state == MenuState.TopLevel ? ButtonState.Expanded : ButtonState.Contracted; } + + StateChanged?.Invoke(State); } } diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipButton.cs index 3cf371f1e1..6519a8db36 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipButton.cs @@ -133,6 +133,8 @@ namespace osu.Game.Screens.Play private class FadeContainer : Container, IStateful { + public event Action StateChanged; + private Visibility state; private ScheduledDelegate scheduledHide; @@ -144,8 +146,10 @@ namespace osu.Game.Screens.Play } set { - var lastState = state; + if (state == value) + return; + var lastState = state; state = value; scheduledHide?.Cancel(); @@ -164,6 +168,8 @@ namespace osu.Game.Screens.Play this.FadeOut(1000, Easing.OutExpo); break; } + + StateChanged?.Invoke(State); } } diff --git a/osu.Game/Screens/Play/SquareGraph.cs b/osu.Game/Screens/Play/SquareGraph.cs index f3bb523611..81dbf3eca4 100644 --- a/osu.Game/Screens/Play/SquareGraph.cs +++ b/osu.Game/Screens/Play/SquareGraph.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 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; @@ -170,6 +171,8 @@ namespace osu.Game.Screens.Play private const float padding = 2; public const float WIDTH = cube_size + padding; + public event Action StateChanged; + private readonly List drawableRows = new List(); private float filled; @@ -186,6 +189,7 @@ namespace osu.Game.Screens.Play } private ColumnState state; + public ColumnState State { get { return state; } @@ -196,6 +200,8 @@ namespace osu.Game.Screens.Play if (IsLoaded) fillActive(); + + StateChanged?.Invoke(State); } } diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index d7c85fff90..2987f4476c 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics; @@ -21,6 +22,8 @@ namespace osu.Game.Screens.Select.Leaderboards { public static readonly float HEIGHT = 60; + public event Action StateChanged; + public readonly int RankPosition; public readonly Score Score; @@ -41,11 +44,14 @@ namespace osu.Game.Screens.Select.Leaderboards private readonly FillFlowContainer modsContainer; private Visibility state; + public Visibility State { get { return state; } set { + if (state == value) + return; state = value; switch (state) @@ -88,6 +94,8 @@ namespace osu.Game.Screens.Select.Leaderboards break; } + + StateChanged?.Invoke(State); } } From 2a64bcda85aaa686fbefee7e22fb0a0dca9bd928 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 09:32:44 +0900 Subject: [PATCH 089/107] Fix resizing bug(?). --- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 14 +++++++++++++- osu.Game/Graphics/UserInterface/OsuMenu.cs | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 275cc2ab64..b69186e8b0 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -67,7 +67,19 @@ namespace osu.Game.Graphics.UserInterface protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint); // todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring - protected override void UpdateSize(Vector2 newSize) => this.ResizeTo(newSize, 300, Easing.OutQuint); + protected override void UpdateSize(Vector2 newSize) + { + if (Direction == Direction.Vertical) + { + Width = newSize.X; + this.ResizeHeightTo(newSize.Y, 300, Easing.OutQuint); + } + else + { + Height = newSize.Y; + this.ResizeWidthTo(newSize.X, 300, Easing.OutQuint); + } + } private Color4 accentColour; public Color4 AccentColour diff --git a/osu.Game/Graphics/UserInterface/OsuMenu.cs b/osu.Game/Graphics/UserInterface/OsuMenu.cs index a8cb8cafbb..103155dd1f 100644 --- a/osu.Game/Graphics/UserInterface/OsuMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuMenu.cs @@ -30,7 +30,19 @@ namespace osu.Game.Graphics.UserInterface protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint); protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint); - protected override void UpdateSize(Vector2 newSize) => this.ResizeTo(newSize, 300, Easing.OutQuint); + protected override void UpdateSize(Vector2 newSize) + { + if (Direction == Direction.Vertical) + { + Width = newSize.X; + this.ResizeHeightTo(newSize.Y, 300, Easing.OutQuint); + } + else + { + Height = newSize.Y; + this.ResizeWidthTo(newSize.X, 300, Easing.OutQuint); + } + } protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuMenuItem(item); From 9078444a6292fce1bd4e8a4ec6019c5c487a2f9f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 11:03:04 +0900 Subject: [PATCH 090/107] Fix items jumping between two indices in the edge case, use a linear search for now. --- osu.Game/Overlays/Music/PlaylistItem.cs | 45 ++++++++++--------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 9df15bfd04..44bb2687f7 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -150,9 +151,6 @@ namespace osu.Game.Overlays.Music { private readonly FillFlowContainer playlist; - private const int line_height = 22; - private const int rearrange_buffer = 3; - public PlaylistItemHandle(FillFlowContainer playlist) { this.playlist = playlist; @@ -169,7 +167,23 @@ namespace osu.Game.Overlays.Music protected override bool OnDrag(InputState state) { int src = (int)Parent.Depth; - int dst = getIndex(state.Mouse.Position.Y + Parent.Position.Y); + + var matchingItem = playlist.Children.LastOrDefault(c => c.Position.Y < state.Mouse.Position.Y + Parent.Position.Y); + if (matchingItem == null) + return true; + + int dst = (int)matchingItem.Depth; + + // Due to the position predicate above, there is an edge case to consider when an item is moved upwards: + // At the point where the two items cross there will be two items sharing the same condition, and the items will jump back + // and forth between the two positions because of this. This is accentuated if the items span differing line heights. + // The easiest way to avoid this is to ensure the movement direction matches the expected mouse delta + + if (state.Mouse.Delta.Y <= 0 && dst > src) + return true; + + if (state.Mouse.Delta.Y >= 0 && dst < src) + return true; if (src == dst) return true; @@ -188,29 +202,6 @@ namespace osu.Game.Overlays.Music playlist.ChangeChildDepth(Parent as PlaylistItem, dst); return true; } - - private int getIndex(float position) { - IReadOnlyList items = playlist.Children; - - // Binary Search without matching exact - int min = 0; - int max = items.Count - 1; - while (min <= max) - { - int m = (min + max) / 2; - if (items[m].Y < position) - min = m + 1; - else if (items[m].Y > position) - max = m - 1; - } - - int index = Math.Max(0, min - 1); - // Only move if mouse falls within buffer - if (position - items[index].Y > rearrange_buffer && position - items[index].Y < line_height - rearrange_buffer) { - return (int)items[index].Depth; - } - return (int)Parent.Depth; - } } } } From 9b0309e6835a61f7d314e2cfbe6cc97bb4d456ec Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 11:28:15 +0900 Subject: [PATCH 091/107] Use TakeWhile instead of reversing the list. --- osu.Game/Overlays/Music/PlaylistList.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 019049eb96..f463d382b0 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -59,8 +59,8 @@ namespace osu.Game.Overlays.Music { get { - var available = items.Children.Reverse(); - return (available.SkipWhile(i => !i.Selected).Skip(1).FirstOrDefault() ?? available.FirstOrDefault())?.BeatmapSetInfo; + var available = items.Children; + return (available.TakeWhile(i => !i.Selected).LastOrDefault() ?? available.LastOrDefault())?.BeatmapSetInfo; } } From 3b575444bedcfe4db9906abcd8ef7bafb4bd4d65 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 13:12:12 +0900 Subject: [PATCH 092/107] Rewrite PlaylistList as CompositeDrawable and remove all backwards PlaylistList references Now handles drag at a PlaylistList.ItemsScrollContainer level (private class), and PlaylistList itself is no longer a Container so it only supports adding BeatmapSets. Sorry for the rewrite x.x. --- osu.Game/Overlays/Music/PlaylistItem.cs | 66 ++---- osu.Game/Overlays/Music/PlaylistList.cs | 256 ++++++++++++++------- osu.Game/Overlays/Music/PlaylistOverlay.cs | 10 +- 3 files changed, 188 insertions(+), 144 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 44bb2687f7..2aaa182685 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -18,7 +17,7 @@ using OpenTK; namespace osu.Game.Overlays.Music { - internal class PlaylistItem : Container, IFilterable + internal class PlaylistItem : Container, IFilterable, IDraggable { private const float fade_duration = 100; @@ -31,11 +30,12 @@ namespace osu.Game.Overlays.Music private UnicodeBindableString titleBind; private UnicodeBindableString artistBind; - private readonly FillFlowContainer playlist; public readonly BeatmapSetInfo BeatmapSetInfo; public Action OnSelect; + public bool IsDraggable => handle.IsHovered; + private bool selected; public bool Selected { @@ -51,9 +51,8 @@ namespace osu.Game.Overlays.Music } } - public PlaylistItem(FillFlowContainer playlist, BeatmapSetInfo setInfo) + public PlaylistItem(BeatmapSetInfo setInfo) { - this.playlist = playlist; BeatmapSetInfo = setInfo; RelativeSizeAxes = Axes.X; @@ -72,9 +71,9 @@ namespace osu.Game.Overlays.Music Children = new Drawable[] { - handle = new PlaylistItemHandle(playlist) + handle = new PlaylistItemHandle { - Colour = colours.Gray5, + Colour = colours.Gray5 }, text = new OsuTextFlowContainer { @@ -149,11 +148,9 @@ namespace osu.Game.Overlays.Music private class PlaylistItemHandle : SpriteIcon { - private readonly FillFlowContainer playlist; - public PlaylistItemHandle(FillFlowContainer playlist) + public PlaylistItemHandle() { - this.playlist = playlist; Anchor = Anchor.TopLeft; Origin = Anchor.TopLeft; Size = new Vector2(12); @@ -161,47 +158,14 @@ namespace osu.Game.Overlays.Music Alpha = 0f; Margin = new MarginPadding { Left = 5, Top = 2 }; } - - protected override bool OnDragStart(InputState state) => true; - - protected override bool OnDrag(InputState state) - { - int src = (int)Parent.Depth; - - var matchingItem = playlist.Children.LastOrDefault(c => c.Position.Y < state.Mouse.Position.Y + Parent.Position.Y); - if (matchingItem == null) - return true; - - int dst = (int)matchingItem.Depth; - - // Due to the position predicate above, there is an edge case to consider when an item is moved upwards: - // At the point where the two items cross there will be two items sharing the same condition, and the items will jump back - // and forth between the two positions because of this. This is accentuated if the items span differing line heights. - // The easiest way to avoid this is to ensure the movement direction matches the expected mouse delta - - if (state.Mouse.Delta.Y <= 0 && dst > src) - return true; - - if (state.Mouse.Delta.Y >= 0 && dst < src) - return true; - - if (src == dst) - return true; - - if (src < dst) - { - for (int i = src + 1; i <= dst; i++) - playlist.ChangeChildDepth(playlist[i], i - 1); - } - else - { - for (int i = dst; i < src; i++) - playlist.ChangeChildDepth(playlist[i], i + 1); - } - - playlist.ChangeChildDepth(Parent as PlaylistItem, dst); - return true; - } } } + + public interface IDraggable : IDrawable + { + /// + /// Whether this can be dragged in its current state. + /// + bool IsDraggable { get; } + } } diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index f463d382b0..a4550f7f52 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -4,125 +4,205 @@ using System; 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.Game.Beatmaps; using osu.Game.Graphics.Containers; +using OpenTK; namespace osu.Game.Overlays.Music { - internal class PlaylistList : Container + internal class PlaylistList : CompositeDrawable { - private readonly FillFlowContainer items; - - public IEnumerable BeatmapSets - { - set - { - items.Children = value.Select((item, index) => new PlaylistItem(items, item) { OnSelect = itemSelected, Depth = index }).ToList(); - } - } - - public BeatmapSetInfo FirstVisibleSet => items.Children.FirstOrDefault(i => i.MatchingFilter)?.BeatmapSetInfo; - - private void itemSelected(BeatmapSetInfo b) - { - OnSelect?.Invoke(b); - } - public Action OnSelect; - private readonly SearchContainer search; - - public void Filter(string searchTerm) => search.SearchTerm = searchTerm; - - public BeatmapSetInfo SelectedItem - { - get { return items.Children.FirstOrDefault(i => i.Selected)?.BeatmapSetInfo; } - set - { - foreach (PlaylistItem s in items.Children) - s.Selected = s.BeatmapSetInfo.ID == value?.ID; - } - } - - public BeatmapSetInfo NextItem - { - get - { - var available = items.Children; - return (available.SkipWhile(i => !i.Selected).Skip(1).FirstOrDefault() ?? available.FirstOrDefault())?.BeatmapSetInfo; - } - } - - public BeatmapSetInfo PreviousItem - { - get - { - var available = items.Children; - return (available.TakeWhile(i => !i.Selected).LastOrDefault() ?? available.LastOrDefault())?.BeatmapSetInfo; - } - } + private readonly ItemsScrollContainer items; public PlaylistList() { - Children = new Drawable[] + InternalChild = items = new ItemsScrollContainer { - new OsuScrollContainer - { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - search = new SearchContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] - { - items = new ItemSearchContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, - } - } - }, - }, + RelativeSizeAxes = Axes.Both, + OnSelect = set => OnSelect?.Invoke(set) }; } - public void AddBeatmapSet(BeatmapSetInfo beatmapSet) + public new MarginPadding Padding { - items.Add(new PlaylistItem(items, beatmapSet) { OnSelect = itemSelected, Depth = items.Count }); + get { return base.Padding; } + set { base.Padding = value; } } - public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) + public IEnumerable BeatmapSets { set { items.Sets = value; } } + + public BeatmapSetInfo FirstVisibleSet => items.FirstVisibleSet; + public BeatmapSetInfo NextSet => items.NextSet; + public BeatmapSetInfo PreviousSet => items.PreviousSet; + + public BeatmapSetInfo SelectedSet { - PlaylistItem itemToRemove = items.Children.FirstOrDefault(item => item.BeatmapSetInfo.ID == beatmapSet.ID); - if (itemToRemove != null) items.Remove(itemToRemove); + get { return items.SelectedSet; } + set { items.SelectedSet = value; } } - private class ItemSearchContainer : FillFlowContainer, IHasFilterableChildren + public void AddBeatmapSet(BeatmapSetInfo beatmapSet) => items.AddBeatmapSet(beatmapSet); + public bool RemoveBeatmapSet(BeatmapSetInfo beatmapSet) => items.RemoveBeatmapSet(beatmapSet); + + public void Filter(string searchTerm) => items.SearchTerm = searchTerm; + + private class ItemsScrollContainer : OsuScrollContainer { - public string[] FilterTerms => new string[] { }; - public bool MatchingFilter + public Action OnSelect; + + private readonly SearchContainer search; + private readonly FillFlowContainer items; + + private PlaylistItem draggedItem; + + public ItemsScrollContainer() + { + Children = new Drawable[] + { + search = new SearchContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + items = new ItemSearchContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + } + } + }; + } + + public IEnumerable Sets { set { - if (value) - InvalidateLayout(); + items.Clear(); + value.ForEach(AddBeatmapSet); } } - // Compare with reversed ChildID and Depth - protected override int Compare(Drawable x, Drawable y) => base.Compare(y, x); - - public IEnumerable FilterableChildren => Children; - - public ItemSearchContainer() + public string SearchTerm { - LayoutDuration = 200; - LayoutEasing = Easing.OutQuint; + get { return search.SearchTerm; } + set { search.SearchTerm = value; } + } + + public void AddBeatmapSet(BeatmapSetInfo beatmapSet) + { + items.Add(new PlaylistItem(beatmapSet) + { + OnSelect = set => OnSelect?.Invoke(set), + Depth = items.Count + }); + } + + public bool RemoveBeatmapSet(BeatmapSetInfo beatmapSet) + { + var itemToRemove = items.FirstOrDefault(i => i.BeatmapSetInfo.ID == beatmapSet.ID); + if (itemToRemove == null) + return false; + return items.Remove(itemToRemove); + } + + public BeatmapSetInfo SelectedSet + { + get { return items.FirstOrDefault(i => i.Selected)?.BeatmapSetInfo; } + set + { + foreach (PlaylistItem s in items.Children) + s.Selected = s.BeatmapSetInfo.ID == value?.ID; + } + } + + public BeatmapSetInfo FirstVisibleSet => items.FirstOrDefault(i => i.MatchingFilter)?.BeatmapSetInfo; + public BeatmapSetInfo NextSet => (items.SkipWhile(i => !i.Selected).Skip(1).FirstOrDefault() ?? items.FirstOrDefault())?.BeatmapSetInfo; + public BeatmapSetInfo PreviousSet => (items.TakeWhile(i => !i.Selected).LastOrDefault() ?? items.LastOrDefault())?.BeatmapSetInfo; + + protected override bool OnDragStart(InputState state) + { + draggedItem = items.FirstOrDefault(d => d.IsDraggable); + return draggedItem != null || base.OnDragStart(state); + } + + protected override bool OnDrag(InputState state) + { + if (draggedItem == null) + return base.OnDrag(state); + + // Mouse position in the position space of the items container + Vector2 itemsPos = items.ToLocalSpace(state.Mouse.NativeState.Position); + + int src = (int)draggedItem.Depth; + + var matchingItem = items.LastOrDefault(c => c.Position.Y < itemsPos.Y); + if (matchingItem == null) + return true; + + int dst = (int)matchingItem.Depth; + + // Due to the position predicate above, there is an edge case to consider when an item is moved upwards: + // At the point where the two items cross there will be two items sharing the same condition, and the items will jump back + // and forth between the two positions because of this. This is accentuated if the items span differing line heights. + // The easiest way to avoid this is to ensure the movement direction matches the expected mouse delta + + if (state.Mouse.Delta.Y <= 0 && dst > src) + return true; + + if (state.Mouse.Delta.Y >= 0 && dst < src) + return true; + + if (src == dst) + return true; + + if (src < dst) + { + for (int i = src + 1; i <= dst; i++) + items.ChangeChildDepth(items[i], i - 1); + } + else + { + for (int i = dst; i < src; i++) + items.ChangeChildDepth(items[i], i + 1); + } + + items.ChangeChildDepth(draggedItem, dst); + + return true; + } + + protected override bool OnDragEnd(InputState state) => draggedItem != null || base.OnDragEnd(state); + + private class ItemSearchContainer : FillFlowContainer, IHasFilterableChildren + { + public string[] FilterTerms => new string[] { }; + public bool MatchingFilter + { + set + { + if (value) + InvalidateLayout(); + } + } + + // Compare with reversed ChildID and Depth + protected override int Compare(Drawable x, Drawable y) => base.Compare(y, x); + + public IEnumerable FilterableChildren => Children; + + public ItemSearchContainer() + { + LayoutDuration = 200; + LayoutEasing = Easing.OutQuint; + } } } } diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index e987e7a5c1..d05ad85726 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -92,7 +92,7 @@ namespace osu.Game.Overlays.Music protected override void LoadComplete() { base.LoadComplete(); - beatmapBacking.ValueChanged += b => list.SelectedItem = b?.BeatmapSetInfo; + beatmapBacking.ValueChanged += b => list.SelectedSet = b?.BeatmapSetInfo; beatmapBacking.TriggerChange(); } @@ -126,23 +126,23 @@ namespace osu.Game.Overlays.Music public void PlayPrevious() { - var playable = list.PreviousItem; + var playable = list.PreviousSet; if (playable != null) { playSpecified(playable.Beatmaps[0]); - list.SelectedItem = playable; + list.SelectedSet = playable; } } public void PlayNext() { - var playable = list.NextItem; + var playable = list.NextSet; if (playable != null) { playSpecified(playable.Beatmaps[0]); - list.SelectedItem = playable; + list.SelectedSet = playable; } } From 2ed20f5a6f6ba54b498971d15fb1299aa5ab15e2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 14:20:40 +0900 Subject: [PATCH 093/107] Add better fix for items swapping erratically. --- osu.Game/Overlays/Music/PlaylistList.cs | 27 +++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index a4550f7f52..8af8943ded 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -143,22 +143,19 @@ namespace osu.Game.Overlays.Music int src = (int)draggedItem.Depth; - var matchingItem = items.LastOrDefault(c => c.Position.Y < itemsPos.Y); - if (matchingItem == null) - return true; + // Find the last item with position < mouse position. Note we can't directly use + // the item positions as they are being transformed + float heightAccumulator = 0; + int dst = 0; + for (; dst < items.Count; dst++) + { + // Using BoundingBox here takes care of scale, paddings, etc... + heightAccumulator += items[dst].BoundingBox.Height; + if (heightAccumulator > itemsPos.Y) + break; + } - int dst = (int)matchingItem.Depth; - - // Due to the position predicate above, there is an edge case to consider when an item is moved upwards: - // At the point where the two items cross there will be two items sharing the same condition, and the items will jump back - // and forth between the two positions because of this. This is accentuated if the items span differing line heights. - // The easiest way to avoid this is to ensure the movement direction matches the expected mouse delta - - if (state.Mouse.Delta.Y <= 0 && dst > src) - return true; - - if (state.Mouse.Delta.Y >= 0 && dst < src) - return true; + dst = MathHelper.Clamp(dst, 0, items.Count - 1); if (src == dst) return true; From 04c3801fcc19c0a21064ee82dceff414f635dc20 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 14:58:28 +0900 Subject: [PATCH 094/107] Add scrolling points so items can be dragged beyond the list. --- osu.Game/Overlays/Music/PlaylistList.cs | 73 +++++++++++++++++++------ 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 8af8943ded..ad964f7458 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -137,46 +137,87 @@ namespace osu.Game.Overlays.Music { if (draggedItem == null) return base.OnDrag(state); + return true; + } - // Mouse position in the position space of the items container - Vector2 itemsPos = items.ToLocalSpace(state.Mouse.NativeState.Position); + protected override bool OnDragEnd(InputState state) + { + var handled = draggedItem != null || base.OnDragEnd(state); + draggedItem = null; - int src = (int)draggedItem.Depth; + return handled; + } + + protected override void Update() + { + base.Update(); + + if (draggedItem == null) + return; + + var mouseState = GetContainingInputManager().CurrentState.Mouse; + + updateScrollPosition(mouseState); + updateDragPosition(mouseState); + } + + private void updateScrollPosition(IMouseState mouseState) + { + const float start_offset = 10; + const double max_power = 50; + const double exp_base = 1.05; + + var localPos = ToLocalSpace(mouseState.Position); + + if (localPos.Y < start_offset) + { + var power = Math.Min(max_power, Math.Abs(start_offset - localPos.Y)); + ScrollBy(-(float)Math.Pow(exp_base, power)); + } + else if (localPos.Y > DrawHeight - start_offset) + { + var power = Math.Min(max_power, Math.Abs(DrawHeight - start_offset - localPos.Y)); + ScrollBy((float)Math.Pow(exp_base, power)); + } + } + + private void updateDragPosition(IMouseState mouseState) + { + var itemsPos = items.ToLocalSpace(mouseState.Position); + + int srcIndex = (int)draggedItem.Depth; // Find the last item with position < mouse position. Note we can't directly use // the item positions as they are being transformed float heightAccumulator = 0; - int dst = 0; - for (; dst < items.Count; dst++) + int dstIndex = 0; + for (; dstIndex < items.Count; dstIndex++) { // Using BoundingBox here takes care of scale, paddings, etc... - heightAccumulator += items[dst].BoundingBox.Height; + heightAccumulator += items[dstIndex].BoundingBox.Height; if (heightAccumulator > itemsPos.Y) break; } - dst = MathHelper.Clamp(dst, 0, items.Count - 1); + dstIndex = MathHelper.Clamp(dstIndex, 0, items.Count - 1); - if (src == dst) - return true; + if (srcIndex == dstIndex) + return; - if (src < dst) + if (srcIndex < dstIndex) { - for (int i = src + 1; i <= dst; i++) + for (int i = srcIndex + 1; i <= dstIndex; i++) items.ChangeChildDepth(items[i], i - 1); } else { - for (int i = dst; i < src; i++) + for (int i = dstIndex; i < srcIndex; i++) items.ChangeChildDepth(items[i], i + 1); } - items.ChangeChildDepth(draggedItem, dst); - - return true; + items.ChangeChildDepth(draggedItem, dstIndex); } - protected override bool OnDragEnd(InputState state) => draggedItem != null || base.OnDragEnd(state); private class ItemSearchContainer : FillFlowContainer, IHasFilterableChildren { From 722b7419d634e4627cf5eed409ee6acc45be702f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 15:06:21 +0900 Subject: [PATCH 095/107] Clamp at the end points. --- osu.Game/Overlays/Music/PlaylistList.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index ad964f7458..6c8fb61ef2 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -8,6 +8,7 @@ using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; using OpenTK; @@ -171,11 +172,17 @@ namespace osu.Game.Overlays.Music if (localPos.Y < start_offset) { + if (Current <= 0) + return; + var power = Math.Min(max_power, Math.Abs(start_offset - localPos.Y)); ScrollBy(-(float)Math.Pow(exp_base, power)); } else if (localPos.Y > DrawHeight - start_offset) { + if (IsScrolledToEnd()) + return; + var power = Math.Min(max_power, Math.Abs(DrawHeight - start_offset - localPos.Y)); ScrollBy((float)Math.Pow(exp_base, power)); } From ad966f41f5cc559f60681cac7e64a745c99b30f9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 4 Sep 2017 15:08:41 +0900 Subject: [PATCH 096/107] Fix CI error. --- osu.Game/Overlays/Music/PlaylistList.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index 6c8fb61ef2..e98fc45915 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -8,7 +8,6 @@ using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; -using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; using OpenTK; From ed0f2a654baccd5425c7a4b0ff8629cd32e8dae2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 4 Sep 2017 18:51:50 +0900 Subject: [PATCH 097/107] Rename variable --- osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index a66ac3298f..8ba92a8d30 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -23,11 +23,11 @@ namespace osu.Game.Rulesets.Osu.Scoring { } - private float beatmapHp; + private float hpDrainRate; protected override void ComputeTargets(Game.Beatmaps.Beatmap beatmap) { - beatmapHp = beatmap.BeatmapInfo.Difficulty.DrainRate; + hpDrainRate = beatmap.BeatmapInfo.Difficulty.DrainRate; } protected override void Reset() @@ -66,23 +66,23 @@ namespace osu.Game.Rulesets.Osu.Scoring switch (judgement.Score) { case OsuScoreResult.Hit300: - Health.Value += (10.2 - beatmapHp) * 0.02; + Health.Value += (10.2 - hpDrainRate) * 0.02; break; case OsuScoreResult.Hit100: - Health.Value += (8 - beatmapHp) * 0.02; + Health.Value += (8 - hpDrainRate) * 0.02; break; case OsuScoreResult.Hit50: - Health.Value += (4 - beatmapHp) * 0.02; + Health.Value += (4 - hpDrainRate) * 0.02; break; case OsuScoreResult.SliderTick: - Health.Value += System.Math.Max(7 - beatmapHp, 0) * 0.01; + Health.Value += System.Math.Max(7 - hpDrainRate, 0) * 0.01; break; case OsuScoreResult.Miss: - Health.Value -= beatmapHp * 0.04; + Health.Value -= hpDrainRate * 0.04; break; } } From e9f076244065fa732782bac35293bb7c9027cf1c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 5 Sep 2017 10:29:51 +0900 Subject: [PATCH 098/107] Don't query GetContainingInputManager every Update. --- osu.Game/Overlays/Music/PlaylistList.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index e98fc45915..ff1a8dd0dc 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -59,8 +59,6 @@ namespace osu.Game.Overlays.Music private readonly SearchContainer search; private readonly FillFlowContainer items; - private PlaylistItem draggedItem; - public ItemsScrollContainer() { Children = new Drawable[] @@ -127,14 +125,19 @@ namespace osu.Game.Overlays.Music public BeatmapSetInfo NextSet => (items.SkipWhile(i => !i.Selected).Skip(1).FirstOrDefault() ?? items.FirstOrDefault())?.BeatmapSetInfo; public BeatmapSetInfo PreviousSet => (items.TakeWhile(i => !i.Selected).LastOrDefault() ?? items.LastOrDefault())?.BeatmapSetInfo; + private InputState dragInputState; + private PlaylistItem draggedItem; + protected override bool OnDragStart(InputState state) { + dragInputState = state; draggedItem = items.FirstOrDefault(d => d.IsDraggable); return draggedItem != null || base.OnDragStart(state); } protected override bool OnDrag(InputState state) { + dragInputState = state; if (draggedItem == null) return base.OnDrag(state); return true; @@ -142,6 +145,7 @@ namespace osu.Game.Overlays.Music protected override bool OnDragEnd(InputState state) { + dragInputState = state; var handled = draggedItem != null || base.OnDragEnd(state); draggedItem = null; @@ -155,19 +159,17 @@ namespace osu.Game.Overlays.Music if (draggedItem == null) return; - var mouseState = GetContainingInputManager().CurrentState.Mouse; - - updateScrollPosition(mouseState); - updateDragPosition(mouseState); + updateScrollPosition(); + updateDragPosition(); } - private void updateScrollPosition(IMouseState mouseState) + private void updateScrollPosition() { const float start_offset = 10; const double max_power = 50; const double exp_base = 1.05; - var localPos = ToLocalSpace(mouseState.Position); + var localPos = ToLocalSpace(dragInputState.Mouse.NativeState.Position); if (localPos.Y < start_offset) { @@ -187,9 +189,9 @@ namespace osu.Game.Overlays.Music } } - private void updateDragPosition(IMouseState mouseState) + private void updateDragPosition() { - var itemsPos = items.ToLocalSpace(mouseState.Position); + var itemsPos = items.ToLocalSpace(dragInputState.Mouse.NativeState.Position); int srcIndex = (int)draggedItem.Depth; @@ -250,4 +252,4 @@ namespace osu.Game.Overlays.Music } } } -} \ No newline at end of file +} From 1904b5edfe93bbffdd153a20b4803314c9655234 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 5 Sep 2017 10:37:49 +0900 Subject: [PATCH 099/107] Only store native position instead of input state. --- osu.Game/Overlays/Music/PlaylistList.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs index ff1a8dd0dc..360e2ad843 100644 --- a/osu.Game/Overlays/Music/PlaylistList.cs +++ b/osu.Game/Overlays/Music/PlaylistList.cs @@ -125,19 +125,19 @@ namespace osu.Game.Overlays.Music public BeatmapSetInfo NextSet => (items.SkipWhile(i => !i.Selected).Skip(1).FirstOrDefault() ?? items.FirstOrDefault())?.BeatmapSetInfo; public BeatmapSetInfo PreviousSet => (items.TakeWhile(i => !i.Selected).LastOrDefault() ?? items.LastOrDefault())?.BeatmapSetInfo; - private InputState dragInputState; + private Vector2 nativeDragPosition; private PlaylistItem draggedItem; protected override bool OnDragStart(InputState state) { - dragInputState = state; + nativeDragPosition = state.Mouse.NativeState.Position; draggedItem = items.FirstOrDefault(d => d.IsDraggable); return draggedItem != null || base.OnDragStart(state); } protected override bool OnDrag(InputState state) { - dragInputState = state; + nativeDragPosition = state.Mouse.NativeState.Position; if (draggedItem == null) return base.OnDrag(state); return true; @@ -145,7 +145,7 @@ namespace osu.Game.Overlays.Music protected override bool OnDragEnd(InputState state) { - dragInputState = state; + nativeDragPosition = state.Mouse.NativeState.Position; var handled = draggedItem != null || base.OnDragEnd(state); draggedItem = null; @@ -169,7 +169,7 @@ namespace osu.Game.Overlays.Music const double max_power = 50; const double exp_base = 1.05; - var localPos = ToLocalSpace(dragInputState.Mouse.NativeState.Position); + var localPos = ToLocalSpace(nativeDragPosition); if (localPos.Y < start_offset) { @@ -191,7 +191,7 @@ namespace osu.Game.Overlays.Music private void updateDragPosition() { - var itemsPos = items.ToLocalSpace(dragInputState.Mouse.NativeState.Position); + var itemsPos = items.ToLocalSpace(nativeDragPosition); int srcIndex = (int)draggedItem.Depth; From d69b8d7784f1eb2d8b63b5c62d52ad750e5af958 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Sep 2017 17:09:58 +0900 Subject: [PATCH 100/107] Add basic combo score factor to osu! ruleset --- .../Scoring/OsuScoreProcessor.cs | 80 ++++++++++++++++--- 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index 8ba92a8d30..8432c5b26a 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -1,8 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; +using osu.Framework.Configuration; using osu.Framework.Extensions; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Objects; @@ -14,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Scoring { internal class OsuScoreProcessor : ScoreProcessor { + public readonly Bindable Mode = new Bindable(ScoringMode.Exponential); + public OsuScoreProcessor() { } @@ -25,9 +30,28 @@ namespace osu.Game.Rulesets.Osu.Scoring private float hpDrainRate; - protected override void ComputeTargets(Game.Beatmaps.Beatmap beatmap) + private int totalAccurateJudgements; + + private readonly Dictionary scoreResultCounts = new Dictionary(); + private readonly Dictionary comboResultCounts = new Dictionary(); + + private double comboMaxScore; + + protected override void ComputeTargets(Beatmap beatmap) { hpDrainRate = beatmap.BeatmapInfo.Difficulty.DrainRate; + totalAccurateJudgements = beatmap.HitObjects.Count; + + foreach (var h in beatmap.HitObjects) + { + // TODO: add support for other object types. + AddJudgement(new OsuJudgement + { + MaxScore = OsuScoreResult.Hit300, + Score = OsuScoreResult.Hit300, + Result = HitResult.Hit + }); + } } protected override void Reset() @@ -41,9 +65,6 @@ namespace osu.Game.Rulesets.Osu.Scoring comboResultCounts.Clear(); } - private readonly Dictionary scoreResultCounts = new Dictionary(); - private readonly Dictionary comboResultCounts = new Dictionary(); - public override void PopulateScore(Score score) { base.PopulateScore(score); @@ -63,6 +84,7 @@ namespace osu.Game.Rulesets.Osu.Scoring scoreResultCounts[judgement.Score] = scoreResultCounts.GetOrDefault(judgement.Score) + 1; comboResultCounts[judgement.Combo] = comboResultCounts.GetOrDefault(judgement.Combo) + 1; } + switch (judgement.Score) { case OsuScoreResult.Hit300: @@ -78,7 +100,7 @@ namespace osu.Game.Rulesets.Osu.Scoring break; case OsuScoreResult.SliderTick: - Health.Value += System.Math.Max(7 - hpDrainRate, 0) * 0.01; + Health.Value += Math.Max(7 - hpDrainRate, 0) * 0.01; break; case OsuScoreResult.Miss: @@ -87,17 +109,53 @@ namespace osu.Game.Rulesets.Osu.Scoring } } - int score = 0; - int maxScore = 0; + calculateScore(); + + calculateScore(); + } + + private void calculateScore() + { + int baseScore = 0; + double comboScore = 0; + + int baseMaxScore = 0; foreach (var j in Judgements) { - score += j.ScoreValue; - maxScore += j.MaxScoreValue; + baseScore += j.ScoreValue; + baseMaxScore += j.MaxScoreValue; + + comboScore += j.ScoreValue * (1 + Combo.Value / 10d); } - TotalScore.Value = score; - Accuracy.Value = (double)score / maxScore; + Accuracy.Value = (double)baseScore / baseMaxScore; + + if (comboScore > comboMaxScore) + comboMaxScore = comboScore; + + if (baseScore == 0) + TotalScore.Value = 0; + else + { + // temporary to make scoring feel more like score v1 without being score v1. + float exponentialFactor = Mode.Value == ScoringMode.Exponential ? (float)Judgements.Count / 100 : 1; + + TotalScore.Value = + (int) + ( + exponentialFactor * + 700000 * comboScore / comboMaxScore + + 300000 * Math.Pow(Accuracy.Value, 10) * ((double)Judgements.Count / totalAccurateJudgements) + + 0 /* bonusScore */ + ); + } + } + + public enum ScoringMode + { + Standardised, + Exponential } } } From 24f7fbe1e5d7ad1d0b4637a1b750c25bc787ccf0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 5 Sep 2017 19:14:37 +0900 Subject: [PATCH 101/107] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 5c0e50379e..3edf658577 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 5c0e50379e47a3805097dbc36a713decc64f49ce +Subproject commit 3edf65857759f32d5a6d07ed523a2892b09c3c6a From b871323ed8091577a151cd3285152408db0e6643 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 5 Sep 2017 19:26:28 +0900 Subject: [PATCH 102/107] Fix BeatmapGroup initialization not correctly setting panels to Hidden. --- osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index c66bf637e2..9c62289bfa 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -33,19 +33,16 @@ namespace osu.Game.Beatmaps.Drawables public BeatmapSetHeader Header; - private BeatmapGroupState state; - public List BeatmapPanels; public BeatmapSetInfo BeatmapSet; + private BeatmapGroupState state; public BeatmapGroupState State { get { return state; } set { - if (state == value) - return; state = value; switch (value) @@ -97,6 +94,7 @@ namespace osu.Game.Beatmaps.Drawables Header.AddDifficultyIcons(BeatmapPanels); } + private void headerGainedSelection(BeatmapSetHeader panel) { State = BeatmapGroupState.Expanded; From 0fc2e49ce6b12f2003f043135189293653ea2247 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Sep 2017 19:33:20 +0900 Subject: [PATCH 103/107] Remove second calculateScore call --- osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index 8432c5b26a..41e0dbff41 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -110,8 +110,6 @@ namespace osu.Game.Rulesets.Osu.Scoring } calculateScore(); - - calculateScore(); } private void calculateScore() From 05f5dfba81c5dd0d2cdf52c8cf933d921f3515db Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 5 Sep 2017 13:57:30 +0200 Subject: [PATCH 104/107] Change difficulty colors and add ExpertPlus ExpertPlus is for beatmaps above 6.75* --- .../Drawables/DifficultyColouredContainer.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs index 2614baa116..41b77f6584 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs @@ -33,7 +33,8 @@ namespace osu.Game.Beatmaps.Drawables Normal, Hard, Insane, - Expert + Expert, + ExpertPlus } private DifficultyRating getDifficultyRating(BeatmapInfo beatmap) @@ -44,7 +45,8 @@ namespace osu.Game.Beatmaps.Drawables if (rating < 2.25) return DifficultyRating.Normal; if (rating < 3.75) return DifficultyRating.Hard; if (rating < 5.25) return DifficultyRating.Insane; - return DifficultyRating.Expert; + if (rating < 6.75) return DifficultyRating.Expert; + return DifficultyRating.ExpertPlus; } private Color4 getColour(BeatmapInfo beatmap) @@ -55,12 +57,14 @@ namespace osu.Game.Beatmaps.Drawables return palette.Green; default: case DifficultyRating.Normal: - return palette.Yellow; + return palette.Blue; case DifficultyRating.Hard: - return palette.Pink; + return palette.Yellow; case DifficultyRating.Insane: - return palette.Purple; + return palette.Pink; case DifficultyRating.Expert: + return palette.Purple; + case DifficultyRating.ExpertPlus: return palette.Gray0; } } From 081b98ef39c3678ce7c5960505e86fe41627a711 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Sep 2017 21:30:14 +0900 Subject: [PATCH 105/107] "Use" the hitobject Obviously temporary. --- .../Scoring/OsuScoreProcessor.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index 41e0dbff41..3ee8f56665 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -44,13 +44,16 @@ namespace osu.Game.Rulesets.Osu.Scoring foreach (var h in beatmap.HitObjects) { - // TODO: add support for other object types. - AddJudgement(new OsuJudgement + if (h != null) { - MaxScore = OsuScoreResult.Hit300, - Score = OsuScoreResult.Hit300, - Result = HitResult.Hit - }); + // TODO: add support for other object types. + AddJudgement(new OsuJudgement + { + MaxScore = OsuScoreResult.Hit300, + Score = OsuScoreResult.Hit300, + Result = HitResult.Hit + }); + } } } From 1e10d977f9c3e7e166a1a4cdecdd1c7837c61073 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 5 Sep 2017 15:39:27 +0200 Subject: [PATCH 106/107] Accuracy starts at 100% instead of 0% --- osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs index 647a1381c6..83203f5a7e 100644 --- a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs +++ b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs @@ -268,6 +268,7 @@ namespace osu.Game.Rulesets.Taiko.Scoring base.Reset(); Health.Value = 0; + Accuracy.Value = 1; bonusScore = 0; comboPortion = 0; From 4f4b0a1f351bca177c094a190e274e5ed50cc72d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Sep 2017 20:26:01 +0900 Subject: [PATCH 107/107] Allow posting to chat in all channels --- osu.Game/Online/Chat/Channel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index bec4aadb18..77683ae857 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -30,7 +30,7 @@ namespace osu.Game.Online.Chat public Bindable Joined = new Bindable(); - public bool ReadOnly => Name != "#lazer"; + public bool ReadOnly => false; public const int MAX_HISTORY = 300;