mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Re-implement MultiplayerSubScreen
This commit is contained in:
@ -2,12 +2,10 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Overlays.SearchableList;
|
using osu.Game.Overlays.SearchableList;
|
||||||
@ -16,19 +14,9 @@ using osu.Game.Screens.Multi.Match;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Lounge
|
namespace osu.Game.Screens.Multi.Lounge
|
||||||
{
|
{
|
||||||
public class LoungeSubScreen : CompositeDrawable, IMultiplayerSubScreen
|
public class LoungeSubScreen : MultiplayerSubScreen
|
||||||
{
|
{
|
||||||
public bool AllowBeatmapRulesetChange => true;
|
public override string Title => "Lounge";
|
||||||
public bool AllowExternalScreenChange => true;
|
|
||||||
public bool CursorVisible => true;
|
|
||||||
|
|
||||||
public string Title => "Lounge";
|
|
||||||
public string ShortTitle => Title;
|
|
||||||
|
|
||||||
public bool ValidForResume { get; set; } = true;
|
|
||||||
public bool ValidForPush { get; set; } = true;
|
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
|
||||||
|
|
||||||
protected readonly FilterControl Filter;
|
protected readonly FilterControl Filter;
|
||||||
|
|
||||||
@ -37,15 +25,10 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
private readonly Action<Screen> pushGameplayScreen;
|
private readonly Action<Screen> pushGameplayScreen;
|
||||||
private readonly ProcessingOverlay processingOverlay;
|
private readonly ProcessingOverlay processingOverlay;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private IRoomManager roomManager { get; set; }
|
|
||||||
|
|
||||||
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
|
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
|
||||||
{
|
{
|
||||||
this.pushGameplayScreen = pushGameplayScreen;
|
this.pushGameplayScreen = pushGameplayScreen;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
RoomInspector inspector;
|
RoomInspector inspector;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
@ -112,49 +95,34 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
GetContainingInputManager().ChangeFocus(Filter.Search);
|
GetContainingInputManager().ChangeFocus(Filter.Search);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
{
|
{
|
||||||
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
base.OnEntering(last);
|
||||||
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
||||||
this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
||||||
|
|
||||||
Filter.Search.HoldFocus = true;
|
Filter.Search.HoldFocus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
|
|
||||||
Filter.Search.HoldFocus = false;
|
Filter.Search.HoldFocus = false;
|
||||||
|
return base.OnExiting(next);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnResuming(IScreen last)
|
public override void OnSuspending(IScreen next)
|
||||||
{
|
{
|
||||||
this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
base.OnSuspending(next);
|
||||||
this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnSuspending(IScreen next)
|
|
||||||
{
|
|
||||||
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
|
|
||||||
Filter.Search.HoldFocus = false;
|
Filter.Search.HoldFocus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterRooms()
|
private void filterRooms()
|
||||||
{
|
{
|
||||||
rooms.Filter(Filter.CreateCriteria());
|
rooms.Filter(Filter.CreateCriteria());
|
||||||
roomManager?.Filter(Filter.CreateCriteria());
|
Manager?.Filter(Filter.CreateCriteria());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void joinRequested(Room room)
|
private void joinRequested(Room room)
|
||||||
{
|
{
|
||||||
processingOverlay.Show();
|
processingOverlay.Show();
|
||||||
roomManager?.JoinRoom(room, r =>
|
Manager?.JoinRoom(room, r =>
|
||||||
{
|
{
|
||||||
Push(room);
|
Push(room);
|
||||||
processingOverlay.Hide();
|
processingOverlay.Hide();
|
||||||
@ -172,7 +140,5 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
|
|
||||||
this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => Title;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Multiplayer.GameTypes;
|
using osu.Game.Online.Multiplayer.GameTypes;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -19,19 +18,11 @@ using osu.Game.Screens.Select;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Match
|
namespace osu.Game.Screens.Multi.Match
|
||||||
{
|
{
|
||||||
public class MatchSubScreen : CompositeDrawable, IMultiplayerSubScreen
|
public class MatchSubScreen : MultiplayerSubScreen
|
||||||
{
|
{
|
||||||
public bool AllowBeatmapRulesetChange => false;
|
public bool AllowBeatmapRulesetChange => false;
|
||||||
public bool AllowExternalScreenChange => true;
|
public override string Title => room.RoomID.Value == null ? "New room" : room.Name.Value;
|
||||||
public bool CursorVisible => true;
|
public override string ShortTitle => "room";
|
||||||
|
|
||||||
public string Title => room.RoomID.Value == null ? "New room" : room.Name.Value;
|
|
||||||
public string ShortTitle => "room";
|
|
||||||
|
|
||||||
public bool ValidForResume { get; set; } = true;
|
|
||||||
public bool ValidForPush { get; set; } = true;
|
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
|
||||||
|
|
||||||
private readonly RoomBindings bindings = new RoomBindings();
|
private readonly RoomBindings bindings = new RoomBindings();
|
||||||
|
|
||||||
@ -42,25 +33,14 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
[Cached]
|
[Cached]
|
||||||
private readonly Room room;
|
private readonly Room room;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private IBindableBeatmap beatmap { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private OsuGame game { get; set; }
|
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private IRoomManager manager { get; set; }
|
|
||||||
|
|
||||||
public MatchSubScreen(Room room, Action<Screen> pushGameplayScreen)
|
public MatchSubScreen(Room room, Action<Screen> pushGameplayScreen)
|
||||||
{
|
{
|
||||||
this.room = room;
|
this.room = room;
|
||||||
this.pushGameplayScreen = pushGameplayScreen;
|
this.pushGameplayScreen = pushGameplayScreen;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
bindings.Room = room;
|
bindings.Room = room;
|
||||||
|
|
||||||
MatchChatDisplay chat;
|
MatchChatDisplay chat;
|
||||||
@ -149,33 +129,10 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
beatmapManager.ItemAdded += beatmapAdded;
|
beatmapManager.ItemAdded += beatmapAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnEntering(IScreen last)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
Manager?.PartRoom();
|
||||||
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
return base.OnExiting(next);
|
||||||
this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool OnExiting(IScreen next)
|
|
||||||
{
|
|
||||||
manager?.PartRoom();
|
|
||||||
|
|
||||||
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnResuming(IScreen last)
|
|
||||||
{
|
|
||||||
this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
||||||
this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnSuspending(IScreen next)
|
|
||||||
{
|
|
||||||
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -191,7 +148,7 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
|
// Retrieve the corresponding local beatmap, since we can't directly use the playlist's beatmap info
|
||||||
var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID);
|
var localBeatmap = beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == beatmap.OnlineBeatmapID);
|
||||||
|
|
||||||
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
|
Game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRuleset(RulesetInfo ruleset)
|
private void setRuleset(RulesetInfo ruleset)
|
||||||
@ -199,12 +156,12 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
if (ruleset == null)
|
if (ruleset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
game?.ForcefullySetRuleset(ruleset);
|
Game?.ForcefullySetRuleset(ruleset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() =>
|
private void beatmapAdded(BeatmapSetInfo model, bool existing, bool silent) => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (beatmap.Value != beatmapManager.DefaultBeatmap)
|
if (Beatmap.Value != beatmapManager.DefaultBeatmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (bindings.CurrentBeatmap.Value == null)
|
if (bindings.CurrentBeatmap.Value == null)
|
||||||
@ -214,7 +171,7 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == bindings.CurrentBeatmap.Value.OnlineBeatmapID);
|
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == bindings.CurrentBeatmap.Value.OnlineBeatmapID);
|
||||||
|
|
||||||
if (localBeatmap != null)
|
if (localBeatmap != null)
|
||||||
game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
|
Game?.ForcefullySetBeatmap(beatmapManager.GetWorkingBeatmap(localBeatmap));
|
||||||
});
|
});
|
||||||
|
|
||||||
private void addPlaylistItem(PlaylistItem item)
|
private void addPlaylistItem(PlaylistItem item)
|
||||||
@ -225,7 +182,7 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
|
|
||||||
private void onStart()
|
private void onStart()
|
||||||
{
|
{
|
||||||
beatmap.Value.Mods.Value = bindings.CurrentMods.Value.ToArray();
|
Beatmap.Value.Mods.Value = bindings.CurrentMods.Value.ToArray();
|
||||||
|
|
||||||
switch (bindings.Type.Value)
|
switch (bindings.Type.Value)
|
||||||
{
|
{
|
||||||
@ -239,8 +196,6 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => Title;
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
87
osu.Game/Screens/Multi/MultiplayerSubScreen.cs
Normal file
87
osu.Game/Screens/Multi/MultiplayerSubScreen.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// Copyright (c) 2007-2019 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Multi
|
||||||
|
{
|
||||||
|
public abstract class MultiplayerSubScreen : CompositeDrawable, IMultiplayerSubScreen, IKeyBindingHandler<GlobalAction>
|
||||||
|
{
|
||||||
|
public bool AllowBeatmapRulesetChange => true;
|
||||||
|
public bool AllowExternalScreenChange => true;
|
||||||
|
public bool CursorVisible => true;
|
||||||
|
|
||||||
|
public bool ValidForResume { get; set; } = true;
|
||||||
|
public bool ValidForPush { get; set; } = true;
|
||||||
|
|
||||||
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
|
public abstract string Title { get; }
|
||||||
|
public virtual string ShortTitle => Title;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected IBindableBeatmap Beatmap { get; private set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
protected OsuGame Game { get; private set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
protected IRoomManager Manager { get; private set; }
|
||||||
|
|
||||||
|
protected MultiplayerSubScreen()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnEntering(IScreen last)
|
||||||
|
{
|
||||||
|
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
||||||
|
this.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
||||||
|
this.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool OnExiting(IScreen next)
|
||||||
|
{
|
||||||
|
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
||||||
|
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnResuming(IScreen last)
|
||||||
|
{
|
||||||
|
this.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
||||||
|
this.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnSuspending(IScreen next)
|
||||||
|
{
|
||||||
|
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
||||||
|
this.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
if (!this.IsCurrentScreen()) return false;
|
||||||
|
|
||||||
|
if (action == GlobalAction.Back)
|
||||||
|
{
|
||||||
|
this.Exit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
|
||||||
|
|
||||||
|
public override string ToString() => Title;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user