diff --git a/osu.Game/Graphics/UserInterface/Nub.cs b/osu.Game/Graphics/UserInterface/Nub.cs index 974708af97..b715c80fb6 100644 --- a/osu.Game/Graphics/UserInterface/Nub.cs +++ b/osu.Game/Graphics/UserInterface/Nub.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; @@ -99,7 +100,20 @@ namespace osu.Game.Graphics.UserInterface } } - public Bindable Current { get; } = new Bindable(); + private readonly Bindable current = new Bindable(); + + public Bindable Current + { + get => current; + set + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + current.UnbindBindings(); + current.BindTo(value); + } + } private Color4 accentColour; public Color4 AccentColour diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 75e22f85d1..680e7ac416 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using System.Linq; using osuTK; using osuTK.Graphics; using osu.Framework.Allocation; @@ -19,6 +20,7 @@ using osu.Game.Online.Chat; using osu.Game.Overlays.Chat; using osu.Game.Overlays.Chat.Selection; using osu.Game.Overlays.Chat.Tabs; +using osuTK.Input; namespace osu.Game.Overlays { @@ -222,7 +224,7 @@ namespace osu.Game.Overlays else { currentChannelContainer.Clear(false); - Scheduler.Add(() => currentChannelContainer.Add(loaded)); + currentChannelContainer.Add(loaded); } } @@ -262,6 +264,39 @@ namespace osu.Game.Overlays return base.OnDragEnd(e); } + private void selectTab(int index) + { + var channel = channelTabControl.Items.Skip(index).FirstOrDefault(); + if (channel != null && channel.Name != "+") + channelTabControl.Current.Value = channel; + } + + protected override bool OnKeyDown(KeyDownEvent e) + { + if (e.AltPressed) + { + switch (e.Key) + { + case Key.Number1: + case Key.Number2: + case Key.Number3: + case Key.Number4: + case Key.Number5: + case Key.Number6: + case Key.Number7: + case Key.Number8: + case Key.Number9: + selectTab((int)e.Key - (int)Key.Number1); + return true; + case Key.Number0: + selectTab(9); + return true; + } + } + + return base.OnKeyDown(e); + } + public override bool AcceptsFocus => true; protected override void OnFocus(FocusEvent e) diff --git a/osu.Game/Overlays/Volume/MuteButton.cs b/osu.Game/Overlays/Volume/MuteButton.cs index e31b349827..dddfddedef 100644 --- a/osu.Game/Overlays/Volume/MuteButton.cs +++ b/osu.Game/Overlays/Volume/MuteButton.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; @@ -18,7 +19,20 @@ namespace osu.Game.Overlays.Volume { public class MuteButton : Container, IHasCurrentValue { - public Bindable Current { get; } = new Bindable(); + private readonly Bindable current = new Bindable(); + + public Bindable Current + { + get => current; + set + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + current.UnbindBindings(); + current.BindTo(value); + } + } private Color4 hoveredColour, unhoveredColour; private const float width = 100; diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index 9509c7acae..c6f39b4705 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; +using System.Linq; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -11,7 +13,6 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using osuTK; using osu.Game.Graphics.Containers; -using System.Linq; using osu.Framework.Input.Events; namespace osu.Game.Screens.Play.HUD @@ -20,9 +21,20 @@ namespace osu.Game.Screens.Play.HUD { private const int fade_duration = 1000; - private readonly Bindable> mods = new Bindable>(); + private readonly Bindable> current = new Bindable>(); - public Bindable> Current => mods; + public Bindable> Current + { + get => current; + set + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + current.UnbindBindings(); + current.BindTo(value); + } + } private readonly FillFlowContainer iconsContainer; private readonly OsuSpriteText unrankedText; @@ -50,7 +62,7 @@ namespace osu.Game.Screens.Play.HUD } }; - mods.ValueChanged += mods => + Current.ValueChanged += mods => { iconsContainer.Clear(); foreach (Mod mod in mods) @@ -66,7 +78,7 @@ namespace osu.Game.Screens.Play.HUD protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - mods.UnbindAll(); + Current.UnbindAll(); } protected override void LoadComplete() @@ -77,7 +89,7 @@ namespace osu.Game.Screens.Play.HUD private void appearTransform() { - if (mods.Value.Any(m => !m.Ranked)) + if (Current.Value.Any(m => !m.Ranked)) unrankedText.FadeInFromZero(fade_duration, Easing.OutQuint); else unrankedText.Hide(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8ae644c06a..18addaefb6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - +