mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Merge pull request #3889 from peppy/add-alt-select-support
Add ability to select chat tabs with alt-1-9
This commit is contained in:
commit
a54951b72d
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<bool> Current { get; } = new Bindable<bool>();
|
||||
private readonly Bindable<bool> current = new Bindable<bool>();
|
||||
|
||||
public Bindable<bool> Current
|
||||
{
|
||||
get => current;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
|
||||
current.UnbindBindings();
|
||||
current.BindTo(value);
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 accentColour;
|
||||
public Color4 AccentColour
|
||||
|
@ -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)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<bool>
|
||||
{
|
||||
public Bindable<bool> Current { get; } = new Bindable<bool>();
|
||||
private readonly Bindable<bool> current = new Bindable<bool>();
|
||||
|
||||
public Bindable<bool> 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;
|
||||
|
@ -1,7 +1,9 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
|
||||
private readonly Bindable<IEnumerable<Mod>> current = new Bindable<IEnumerable<Mod>>();
|
||||
|
||||
public Bindable<IEnumerable<Mod>> Current => mods;
|
||||
public Bindable<IEnumerable<Mod>> Current
|
||||
{
|
||||
get => current;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
|
||||
current.UnbindBindings();
|
||||
current.BindTo(value);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly FillFlowContainer<ModIcon> 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();
|
||||
|
@ -18,7 +18,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2018.1219.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2018.1221.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.22.0" />
|
||||
<PackageReference Include="NUnit" Version="3.11.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user