From f6e0e0bc38197ba9086b0e44a89e9da7f015dd42 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 3 Jun 2017 19:21:21 +0200 Subject: [PATCH 01/18] 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 02/18] 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 03/18] 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 f8cc4238ffa88e96e42a8744986e1adfe65b3288 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 24 Aug 2017 22:13:20 +0200 Subject: [PATCH 04/18] 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 05/18] 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 67b3cbce2f9fa436d19f5ffa77982c83521a3442 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2017 13:04:32 +0900 Subject: [PATCH 06/18] 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 07/18] 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 08/18] 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 9374bf925ef2771cb74a9f94cec78fe219d57858 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 25 Aug 2017 16:39:49 +0200 Subject: [PATCH 09/18] 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 161718947502777d0e7feeedaef99d0e032ea29d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 28 Aug 2017 17:53:03 +0800 Subject: [PATCH 10/18] 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 11/18] 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 b91757793f3e65da3c84d9fb9bd3302e4b9c94b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 29 Aug 2017 15:20:56 +0900 Subject: [PATCH 12/18] 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 13/18] 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 fb3ba4fe0cfa01ce725337e5a04b9c8934050495 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 29 Aug 2017 00:26:16 +0800 Subject: [PATCH 14/18] 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 15/18] 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 16/18] 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 17/18] 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 18/18] 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; }