mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 03:02:56 +08:00
Merge branch 'master' into update-inspections
This commit is contained in:
commit
dd6337c5a5
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -32,7 +31,6 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
private TestBeatmapDifficultyCache difficultyCache;
|
private TestBeatmapDifficultyCache difficultyCache;
|
||||||
|
|
||||||
private IBindable<StarDifficulty?> starDifficultyBindable;
|
private IBindable<StarDifficulty?> starDifficultyBindable;
|
||||||
private Queue<ValueChangedEvent<StarDifficulty?>> starDifficultyChangesQueue;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGameBase osu)
|
private void load(OsuGameBase osu)
|
||||||
@ -49,14 +47,10 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
Child = difficultyCache = new TestBeatmapDifficultyCache();
|
Child = difficultyCache = new TestBeatmapDifficultyCache();
|
||||||
|
|
||||||
starDifficultyChangesQueue = new Queue<ValueChangedEvent<StarDifficulty?>>();
|
|
||||||
starDifficultyBindable = difficultyCache.GetBindableDifficulty(importedSet.Beatmaps.First());
|
starDifficultyBindable = difficultyCache.GetBindableDifficulty(importedSet.Beatmaps.First());
|
||||||
starDifficultyBindable.BindValueChanged(starDifficultyChangesQueue.Enqueue);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert($"star difficulty -> {BASE_STARS}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS}", () => starDifficultyBindable.Value?.Stars == BASE_STARS);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -65,19 +59,13 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
OsuModDoubleTime dt = null;
|
OsuModDoubleTime dt = null;
|
||||||
|
|
||||||
AddStep("change selected mod to DT", () => SelectedMods.Value = new[] { dt = new OsuModDoubleTime { SpeedChange = { Value = 1.5 } } });
|
AddStep("change selected mod to DT", () => SelectedMods.Value = new[] { dt = new OsuModDoubleTime { SpeedChange = { Value = 1.5 } } });
|
||||||
AddAssert($"star difficulty -> {BASE_STARS + 1.5}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS + 1.5}", () => starDifficultyBindable.Value?.Stars == BASE_STARS + 1.5);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS + 1.5 &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
|
|
||||||
AddStep("change DT speed to 1.25", () => dt.SpeedChange.Value = 1.25);
|
AddStep("change DT speed to 1.25", () => dt.SpeedChange.Value = 1.25);
|
||||||
AddAssert($"star difficulty -> {BASE_STARS + 1.25}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS + 1.25}", () => starDifficultyBindable.Value?.Stars == BASE_STARS + 1.25);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS + 1.25 &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
|
|
||||||
AddStep("change selected mod to NC", () => SelectedMods.Value = new[] { new OsuModNightcore { SpeedChange = { Value = 1.75 } } });
|
AddStep("change selected mod to NC", () => SelectedMods.Value = new[] { new OsuModNightcore { SpeedChange = { Value = 1.75 } } });
|
||||||
AddAssert($"star difficulty -> {BASE_STARS + 1.75}", () =>
|
AddUntilStep($"star difficulty -> {BASE_STARS + 1.75}", () => starDifficultyBindable.Value?.Stars == BASE_STARS + 1.75);
|
||||||
starDifficultyChangesQueue.Dequeue().NewValue?.Stars == BASE_STARS + 1.75 &&
|
|
||||||
starDifficultyChangesQueue.Count == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
@ -66,7 +65,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
protected class OverlayTestPlayer : TestPlayer
|
protected class OverlayTestPlayer : TestPlayer
|
||||||
{
|
{
|
||||||
public new OverlayActivation OverlayActivationMode => base.OverlayActivationMode.Value;
|
public new OverlayActivation OverlayActivationMode => base.OverlayActivationMode.Value;
|
||||||
public new Bindable<bool> LocalUserPlaying => base.LocalUserPlaying;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,131 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class TestSceneGameplayChatDisplay : MultiplayerTestScene
|
||||||
|
{
|
||||||
|
private GameplayChatDisplay chatDisplay;
|
||||||
|
|
||||||
|
[Cached(typeof(ILocalUserPlayInfo))]
|
||||||
|
private ILocalUserPlayInfo localUserInfo;
|
||||||
|
|
||||||
|
private readonly Bindable<bool> localUserPlaying = new Bindable<bool>();
|
||||||
|
|
||||||
|
private TextBox textBox => chatDisplay.ChildrenOfType<TextBox>().First();
|
||||||
|
|
||||||
|
public TestSceneGameplayChatDisplay()
|
||||||
|
{
|
||||||
|
var mockLocalUserInfo = new Mock<ILocalUserPlayInfo>();
|
||||||
|
mockLocalUserInfo.SetupGet(i => i.IsPlaying).Returns(localUserPlaying);
|
||||||
|
|
||||||
|
localUserInfo = mockLocalUserInfo.Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public override void SetUpSteps()
|
||||||
|
{
|
||||||
|
base.SetUpSteps();
|
||||||
|
|
||||||
|
AddStep("load chat display", () => Child = chatDisplay = new GameplayChatDisplay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Width = 0.5f,
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("expand", () => chatDisplay.Expanded.Value = true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCantClickWhenPlaying()
|
||||||
|
{
|
||||||
|
setLocalUserPlaying(true);
|
||||||
|
|
||||||
|
AddStep("attempt focus chat", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(textBox);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
assertChatFocused(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFocusDroppedWhenPlaying()
|
||||||
|
{
|
||||||
|
assertChatFocused(false);
|
||||||
|
|
||||||
|
AddStep("focus chat", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(textBox);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
setLocalUserPlaying(true);
|
||||||
|
assertChatFocused(false);
|
||||||
|
|
||||||
|
// should still stay non-focused even after entering a new break section.
|
||||||
|
setLocalUserPlaying(false);
|
||||||
|
assertChatFocused(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFocusOnTabKeyWhenExpanded()
|
||||||
|
{
|
||||||
|
setLocalUserPlaying(true);
|
||||||
|
|
||||||
|
assertChatFocused(false);
|
||||||
|
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||||
|
assertChatFocused(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFocusOnTabKeyWhenNotExpanded()
|
||||||
|
{
|
||||||
|
AddStep("set not expanded", () => chatDisplay.Expanded.Value = false);
|
||||||
|
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||||
|
|
||||||
|
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||||
|
assertChatFocused(true);
|
||||||
|
AddUntilStep("is visible", () => chatDisplay.IsPresent);
|
||||||
|
|
||||||
|
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||||
|
assertChatFocused(false);
|
||||||
|
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFocusToggleViaAction()
|
||||||
|
{
|
||||||
|
AddStep("set not expanded", () => chatDisplay.Expanded.Value = false);
|
||||||
|
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||||
|
|
||||||
|
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||||
|
assertChatFocused(true);
|
||||||
|
AddUntilStep("is visible", () => chatDisplay.IsPresent);
|
||||||
|
|
||||||
|
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||||
|
assertChatFocused(false);
|
||||||
|
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertChatFocused(bool isFocused) =>
|
||||||
|
AddAssert($"chat {(isFocused ? "focused" : "not focused")}", () => textBox.HasFocus == isFocused);
|
||||||
|
|
||||||
|
private void setLocalUserPlaying(bool playing) =>
|
||||||
|
AddStep($"local user {(playing ? "playing" : "not playing")}", () => localUserPlaying.Value = playing);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class TestSceneMultiplayerPlayer : MultiplayerTestScene
|
||||||
|
{
|
||||||
|
private MultiplayerPlayer player;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public override void SetUpSteps()
|
||||||
|
{
|
||||||
|
base.SetUpSteps();
|
||||||
|
|
||||||
|
AddStep("set beatmap", () =>
|
||||||
|
{
|
||||||
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("initialise gameplay", () =>
|
||||||
|
{
|
||||||
|
Stack.Push(player = new MultiplayerPlayer(Client.CurrentMatchPlayingItem.Value, Client.Room?.Users.ToArray()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestGameplay()
|
||||||
|
{
|
||||||
|
AddUntilStep("wait for gameplay start", () => player.LocalUserPlaying.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -28,6 +28,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Scheduler.Add(() => GetContainingInputManager().ChangeFocus(this), false);
|
Scheduler.Add(() => GetContainingInputManager().ChangeFocus(this), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new void KillFocus() => base.KillFocus();
|
||||||
|
|
||||||
public bool HoldFocus
|
public bool HoldFocus
|
||||||
{
|
{
|
||||||
get => allowImmediateFocus && focus;
|
get => allowImmediateFocus && focus;
|
||||||
|
@ -90,6 +90,7 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(InputKey.Left, GlobalAction.SeekReplayBackward),
|
new KeyBinding(InputKey.Left, GlobalAction.SeekReplayBackward),
|
||||||
new KeyBinding(InputKey.Right, GlobalAction.SeekReplayForward),
|
new KeyBinding(InputKey.Right, GlobalAction.SeekReplayForward),
|
||||||
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
|
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
|
||||||
|
new KeyBinding(InputKey.Tab, GlobalAction.ToggleChatFocus),
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<KeyBinding> SongSelectKeyBindings => new[]
|
public IEnumerable<KeyBinding> SongSelectKeyBindings => new[]
|
||||||
@ -280,5 +281,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[Description("Seek replay backward")]
|
[Description("Seek replay backward")]
|
||||||
SeekReplayBackward,
|
SeekReplayBackward,
|
||||||
|
|
||||||
|
[Description("Toggle chat focus")]
|
||||||
|
ToggleChatFocus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Chat;
|
using osu.Game.Overlays.Chat;
|
||||||
@ -22,7 +23,7 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
public readonly Bindable<Channel> Channel = new Bindable<Channel>();
|
public readonly Bindable<Channel> Channel = new Bindable<Channel>();
|
||||||
|
|
||||||
private readonly FocusedTextBox textbox;
|
protected readonly ChatTextBox Textbox;
|
||||||
|
|
||||||
protected ChannelManager ChannelManager;
|
protected ChannelManager ChannelManager;
|
||||||
|
|
||||||
@ -30,6 +31,8 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
private readonly bool postingTextbox;
|
private readonly bool postingTextbox;
|
||||||
|
|
||||||
|
protected readonly Box Background;
|
||||||
|
|
||||||
private const float textbox_height = 30;
|
private const float textbox_height = 30;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -44,7 +47,7 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
Background = new Box
|
||||||
{
|
{
|
||||||
Colour = Color4.Black,
|
Colour = Color4.Black,
|
||||||
Alpha = 0.8f,
|
Alpha = 0.8f,
|
||||||
@ -54,7 +57,7 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
if (postingTextbox)
|
if (postingTextbox)
|
||||||
{
|
{
|
||||||
AddInternal(textbox = new FocusedTextBox
|
AddInternal(Textbox = new ChatTextBox
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = textbox_height,
|
Height = textbox_height,
|
||||||
@ -65,7 +68,7 @@ namespace osu.Game.Online.Chat
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
});
|
});
|
||||||
|
|
||||||
textbox.OnCommit += postMessage;
|
Textbox.OnCommit += postMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.BindValueChanged(channelChanged);
|
Channel.BindValueChanged(channelChanged);
|
||||||
@ -82,7 +85,7 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
private void postMessage(TextBox sender, bool newtext)
|
private void postMessage(TextBox sender, bool newtext)
|
||||||
{
|
{
|
||||||
var text = textbox.Text.Trim();
|
var text = Textbox.Text.Trim();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
return;
|
return;
|
||||||
@ -92,7 +95,7 @@ namespace osu.Game.Online.Chat
|
|||||||
else
|
else
|
||||||
ChannelManager?.PostMessage(text, target: Channel.Value);
|
ChannelManager?.PostMessage(text, target: Channel.Value);
|
||||||
|
|
||||||
textbox.Text = string.Empty;
|
Textbox.Text = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual ChatLine CreateMessage(Message message) => new StandAloneMessage(message);
|
protected virtual ChatLine CreateMessage(Message message) => new StandAloneMessage(message);
|
||||||
@ -110,6 +113,25 @@ namespace osu.Game.Online.Chat
|
|||||||
AddInternal(drawableChannel);
|
AddInternal(drawableChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ChatTextBox : FocusedTextBox
|
||||||
|
{
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
BackgroundUnfocused = new Color4(10, 10, 10, 10);
|
||||||
|
BackgroundFocused = new Color4(10, 10, 10, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnFocusLost(FocusLostEvent e)
|
||||||
|
{
|
||||||
|
base.OnFocusLost(e);
|
||||||
|
FocusLost?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action FocusLost;
|
||||||
|
}
|
||||||
|
|
||||||
public class StandAloneDrawableChannel : DrawableChannel
|
public class StandAloneDrawableChannel : DrawableChannel
|
||||||
{
|
{
|
||||||
public Func<Message, ChatLine> CreateChatLineAction;
|
public Func<Message, ChatLine> CreateChatLineAction;
|
||||||
|
@ -19,9 +19,12 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private ChannelManager channelManager { get; set; }
|
private ChannelManager channelManager { get; set; }
|
||||||
|
|
||||||
public MatchChatDisplay()
|
private readonly bool leaveChannelOnDispose;
|
||||||
|
|
||||||
|
public MatchChatDisplay(bool leaveChannelOnDispose = true)
|
||||||
: base(true)
|
: base(true)
|
||||||
{
|
{
|
||||||
|
this.leaveChannelOnDispose = leaveChannelOnDispose;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -42,7 +45,9 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
channelManager?.LeaveChannel(Channel.Value);
|
|
||||||
|
if (leaveChannelOnDispose)
|
||||||
|
channelManager?.LeaveChannel(Channel.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
111
osu.Game/Screens/OnlinePlay/Multiplayer/GameplayChatDisplay.cs
Normal file
111
osu.Game/Screens/OnlinePlay/Multiplayer/GameplayChatDisplay.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||||
|
{
|
||||||
|
public class GameplayChatDisplay : MatchChatDisplay, IKeyBindingHandler<GlobalAction>
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private ILocalUserPlayInfo localUserInfo { get; set; }
|
||||||
|
|
||||||
|
private IBindable<bool> localUserPlaying = new Bindable<bool>();
|
||||||
|
|
||||||
|
public override bool PropagatePositionalInputSubTree => !localUserPlaying.Value;
|
||||||
|
|
||||||
|
public Bindable<bool> Expanded = new Bindable<bool>();
|
||||||
|
|
||||||
|
private readonly Bindable<bool> expandedFromTextboxFocus = new Bindable<bool>();
|
||||||
|
|
||||||
|
private const float height = 100;
|
||||||
|
|
||||||
|
public override bool PropagateNonPositionalInputSubTree => true;
|
||||||
|
|
||||||
|
public GameplayChatDisplay()
|
||||||
|
: base(leaveChannelOnDispose: false)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
Background.Alpha = 0.2f;
|
||||||
|
|
||||||
|
Textbox.FocusLost = () => expandedFromTextboxFocus.Value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
localUserPlaying = localUserInfo.IsPlaying.GetBoundCopy();
|
||||||
|
localUserPlaying.BindValueChanged(playing =>
|
||||||
|
{
|
||||||
|
// for now let's never hold focus. this avoid misdirected gameplay keys entering chat.
|
||||||
|
// note that this is done within this callback as it triggers an un-focus as well.
|
||||||
|
Textbox.HoldFocus = false;
|
||||||
|
|
||||||
|
// only hold focus (after sending a message) during breaks
|
||||||
|
Textbox.ReleaseFocusOnCommit = playing.NewValue;
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
Expanded.BindValueChanged(_ => updateExpandedState(), true);
|
||||||
|
expandedFromTextboxFocus.BindValueChanged(focus =>
|
||||||
|
{
|
||||||
|
if (focus.NewValue)
|
||||||
|
updateExpandedState();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// on finishing typing a message there should be a brief delay before hiding.
|
||||||
|
using (BeginDelayedSequence(600))
|
||||||
|
updateExpandedState();
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.ToggleChatFocus:
|
||||||
|
if (Textbox.HasFocus)
|
||||||
|
{
|
||||||
|
Schedule(() => Textbox.KillFocus());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expandedFromTextboxFocus.Value = true;
|
||||||
|
|
||||||
|
// schedule required to ensure the textbox has become present from above bindable update.
|
||||||
|
Schedule(() => Textbox.TakeFocus());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(GlobalAction action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateExpandedState()
|
||||||
|
{
|
||||||
|
if (Expanded.Value || expandedFromTextboxFocus.Value)
|
||||||
|
{
|
||||||
|
this.FadeIn(300, Easing.OutQuint);
|
||||||
|
this.ResizeHeightTo(height, 500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.FadeOut(300, Easing.OutQuint);
|
||||||
|
this.ResizeHeightTo(0, 500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -68,6 +68,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(5)
|
||||||
});
|
});
|
||||||
|
|
||||||
// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
|
// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
|
||||||
@ -78,7 +79,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
((IBindable<bool>)leaderboard.Expanded).BindTo(HUDOverlay.ShowHud);
|
((IBindable<bool>)leaderboard.Expanded).BindTo(HUDOverlay.ShowHud);
|
||||||
|
|
||||||
leaderboardFlow.Add(l);
|
leaderboardFlow.Insert(0, l);
|
||||||
|
|
||||||
if (leaderboard.TeamScores.Count >= 2)
|
if (leaderboard.TeamScores.Count >= 2)
|
||||||
{
|
{
|
||||||
@ -87,10 +88,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
Team1Score = { BindTarget = leaderboard.TeamScores.First().Value },
|
Team1Score = { BindTarget = leaderboard.TeamScores.First().Value },
|
||||||
Team2Score = { BindTarget = leaderboard.TeamScores.Last().Value },
|
Team2Score = { BindTarget = leaderboard.TeamScores.Last().Value },
|
||||||
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
||||||
}, leaderboardFlow.Add);
|
}, scoreDisplay => leaderboardFlow.Insert(1, scoreDisplay));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
LoadComponentAsync(new GameplayChatDisplay
|
||||||
|
{
|
||||||
|
Expanded = { BindTarget = HUDOverlay.ShowHud },
|
||||||
|
}, chat => leaderboardFlow.Insert(2, chat));
|
||||||
|
|
||||||
HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
|
HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
protected readonly Bindable<bool> LocalUserPlaying = new Bindable<bool>();
|
public IBindable<bool> LocalUserPlaying => localUserPlaying;
|
||||||
|
|
||||||
|
private readonly Bindable<bool> localUserPlaying = new Bindable<bool>();
|
||||||
|
|
||||||
public int RestartCount;
|
public int RestartCount;
|
||||||
|
|
||||||
@ -442,7 +444,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value;
|
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value;
|
||||||
OverlayActivationMode.Value = inGameplay ? OverlayActivation.Disabled : OverlayActivation.UserTriggered;
|
OverlayActivationMode.Value = inGameplay ? OverlayActivation.Disabled : OverlayActivation.UserTriggered;
|
||||||
LocalUserPlaying.Value = inGameplay;
|
localUserPlaying.Value = inGameplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSampleDisabledState()
|
private void updateSampleDisabledState()
|
||||||
|
Loading…
Reference in New Issue
Block a user