1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 12:22:57 +08:00
This commit is contained in:
Dean Herbert 2018-12-26 20:05:57 +09:00
parent 532a970c0f
commit 2353c204ee
16 changed files with 54 additions and 43 deletions

View File

@ -71,14 +71,14 @@ namespace osu.Game.Tests.Visual
private class TestRoomManager : IRoomManager
{
public event Action<Room> OpenRequested;
public event Action<Room> RoomJoined;
public readonly BindableCollection<Room> Rooms = new BindableCollection<Room>();
IBindableCollection<Room> IRoomManager.Rooms => Rooms;
public void CreateRoom(Room room) => Rooms.Add(room);
public void JoinRoom(Room room) => OpenRequested?.Invoke(room);
public void JoinRoom(Room room) => RoomJoined?.Invoke(room);
public void PartRoom()
{

View File

@ -102,7 +102,7 @@ namespace osu.Game.Tests.Visual
{
public Action<Room> CreateRequested;
public event Action<Room> OpenRequested;
public event Action<Room> RoomJoined;
public IBindableCollection<Room> Rooms { get; } = null;

View File

@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual
{
int index = 0;
OsuScreen currentScreen = new TestMultiplayerScreen(index);
OsuScreen currentScreen = new TestMultiplayerSubScreen(index);
Children = new Drawable[]
{
@ -23,16 +23,16 @@ namespace osu.Game.Tests.Visual
new Header(currentScreen)
};
AddStep("push multi screen", () => currentScreen.Push(currentScreen = new TestMultiplayerScreen(++index)));
AddStep("push multi screen", () => currentScreen.Push(currentScreen = new TestMultiplayerSubScreen(++index)));
}
private class TestMultiplayerScreen : OsuScreen, IMultiplayerScreen
private class TestMultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen
{
private readonly int index;
public string ShortTitle => $"Screen {index}";
public TestMultiplayerScreen(int index)
public TestMultiplayerSubScreen(int index)
{
this.index = index;
}

View File

@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(MultiResults),
typeof(MatchResults),
typeof(RoomLeaderboardPageInfo),
typeof(RoomRankingResultsPage)
};
@ -38,22 +38,22 @@ namespace osu.Game.Tests.Visual
if (beatmapInfo != null)
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
Child = new TestMultiResults(new ScoreInfo
Child = new TestMatchResults(new ScoreInfo
{
User = new User { Id = 10 },
});
}
private class TestMultiResults : MultiResults
private class TestMatchResults : MatchResults
{
private readonly Room room;
public TestMultiResults(ScoreInfo score)
public TestMatchResults(ScoreInfo score)
: this(score, new Room())
{
}
public TestMultiResults(ScoreInfo score, Room room)
public TestMatchResults(ScoreInfo score, Room room)
: base(score, room)
{
this.room = room;

View File

@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(Multiplayer),
typeof(LoungeScreen),
typeof(LoungeSubScreen),
typeof(FilterControl)
};

View File

@ -87,7 +87,7 @@ namespace osu.Game.Screens.Multi
breadcrumbs.Current.ValueChanged += s =>
{
if (s is IMultiplayerScreen mpScreen)
if (s is IMultiplayerSubScreen mpScreen)
screenType.Text = mpScreen.ShortTitle.ToLowerInvariant();
};

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.Multi
{
public interface IMultiplayerScreen
public interface IMultiplayerSubScreen
{
string ShortTitle { get; }
}

View File

@ -11,9 +11,9 @@ namespace osu.Game.Screens.Multi
public interface IRoomManager
{
/// <summary>
/// Invoked when this <see cref="IRoomManager"/> requests a <see cref="Room"/> to be opened.
/// Invoked when a room is joined.
/// </summary>
event Action<Room> OpenRequested;
event Action<Room> RoomJoined;
/// <summary>
/// All the active <see cref="Room"/>s.

View File

@ -14,7 +14,7 @@ using osu.Game.Screens.Multi.Match;
namespace osu.Game.Screens.Multi.Lounge
{
public class LoungeScreen : MultiplayerScreen
public class LoungeSubScreen : MultiplayerSubScreen
{
protected readonly FilterControl Filter;
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Multi.Lounge
protected override Drawable TransitionContent => content;
public LoungeScreen(Action<Screen> pushGameplayScreen)
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
{
this.pushGameplayScreen = pushGameplayScreen;
@ -78,7 +78,7 @@ namespace osu.Game.Screens.Multi.Lounge
private void load()
{
if (roomManager != null)
roomManager.OpenRequested += Open;
roomManager.RoomJoined += Open;
}
protected override void UpdateAfterChildren()
@ -109,7 +109,8 @@ namespace osu.Game.Screens.Multi.Lounge
roomManager?.PartRoom();
Filter.Search.HoldFocus = false;
return base.OnExiting(next);
// no base call; don't animate
return false;
}
protected override void OnResuming(Screen last)
@ -137,7 +138,7 @@ namespace osu.Game.Screens.Multi.Lounge
if (!IsCurrentScreen)
return;
Push(new MatchScreen(room, s => pushGameplayScreen?.Invoke(s)));
Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
}
protected override void Dispose(bool isDisposing)
@ -145,7 +146,7 @@ namespace osu.Game.Screens.Multi.Lounge
base.Dispose(isDisposing);
if (roomManager != null)
roomManager.OpenRequested -= Open;
roomManager.RoomJoined -= Open;
}
}
}

View File

@ -20,7 +20,7 @@ using osu.Game.Screens.Select;
namespace osu.Game.Screens.Multi.Match
{
public class MatchScreen : MultiplayerScreen
public class MatchSubScreen : MultiplayerSubScreen
{
public override bool AllowBeatmapRulesetChange => false;
public override string Title => room.RoomID.Value == null ? "New room" : room.Name.Value;
@ -44,7 +44,7 @@ namespace osu.Game.Screens.Multi.Match
[Resolved(CanBeNull = true)]
private IRoomManager manager { get; set; }
public MatchScreen(Room room, Action<Screen> pushGameplayScreen)
public MatchSubScreen(Room room, Action<Screen> pushGameplayScreen)
{
this.room = room;
this.pushGameplayScreen = pushGameplayScreen;
@ -119,6 +119,12 @@ namespace osu.Game.Screens.Multi.Match
chat.Exit += Exit;
}
protected override bool OnExiting(Screen next)
{
manager?.PartRoom();
return base.OnExiting(next);
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -28,7 +28,7 @@ namespace osu.Game.Screens.Multi
public override bool AllowBeatmapRulesetChange => currentScreen?.AllowBeatmapRulesetChange ?? base.AllowBeatmapRulesetChange;
private readonly OsuButton createButton;
private readonly LoungeScreen loungeScreen;
private readonly LoungeSubScreen loungeSubScreen;
private OsuScreen currentScreen;
@ -71,9 +71,9 @@ namespace osu.Game.Screens.Multi
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT },
Child = loungeScreen = new LoungeScreen(Push),
Child = loungeSubScreen = new LoungeSubScreen(Push),
},
new Header(loungeScreen),
new Header(loungeSubScreen),
createButton = new HeaderButton
{
Anchor = Anchor.TopRight,
@ -86,19 +86,22 @@ namespace osu.Game.Screens.Multi
Right = 10,
},
Text = "Create room",
Action = () => loungeScreen.Open(new Room
Action = () => loungeSubScreen.Open(new Room
{
Name = { Value = $"{api.LocalUser}'s awesome room" }
}),
},
roomManager = new RoomManager()
});
screenAdded(loungeScreen);
loungeScreen.Exited += s => Exit();
screenAdded(loungeSubScreen);
loungeSubScreen.Exited += _ => Exit();
}
protected override void OnEntering(Screen last)
{
Content.FadeIn();
base.OnEntering(last);
waves.Show();
}
@ -107,12 +110,13 @@ namespace osu.Game.Screens.Multi
{
waves.Hide();
Content.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut();
var track = Beatmap.Value.Track;
if (track != null)
track.Looping = false;
loungeScreen.MakeCurrent();
loungeScreen.Exit();
loungeSubScreen.MakeCurrent();
return base.OnExiting(next);
}
@ -144,7 +148,7 @@ namespace osu.Game.Screens.Multi
{
base.Update();
if (currentScreen is MatchScreen)
if (currentScreen is MatchSubScreen)
{
var track = Beatmap.Value.Track;
if (track != null)
@ -161,7 +165,7 @@ namespace osu.Game.Screens.Multi
createButton.Hide();
}
else if (currentScreen is LoungeScreen)
else if (currentScreen is LoungeSubScreen)
createButton.Show();
}
@ -175,7 +179,7 @@ namespace osu.Game.Screens.Multi
private void screenRemoved(Screen newScreen)
{
if (currentScreen is MatchScreen)
if (currentScreen is MatchSubScreen)
{
var track = Beatmap.Value.Track;
if (track != null)

View File

@ -7,7 +7,7 @@ using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.Multi
{
public abstract class MultiplayerScreen : OsuScreen, IMultiplayerScreen
public abstract class MultiplayerSubScreen : OsuScreen, IMultiplayerSubScreen
{
protected virtual Drawable TransitionContent => Content;

View File

@ -72,6 +72,6 @@ namespace osu.Game.Screens.Multi.Play
return score;
}
protected override Results CreateResults(ScoreInfo score) => new MultiResults(score, room);
protected override Results CreateResults(ScoreInfo score) => new MatchResults(score, room);
}
}

View File

@ -10,11 +10,11 @@ using osu.Game.Screens.Ranking.Types;
namespace osu.Game.Screens.Multi.Ranking
{
public class MultiResults : Results
public class MatchResults : Results
{
private readonly Room room;
public MultiResults(ScoreInfo score, Room room)
public MatchResults(ScoreInfo score, Room room)
: base(score)
{
this.room = room;

View File

@ -19,7 +19,7 @@ namespace osu.Game.Screens.Multi
{
public class RoomManager : PollingComponent, IRoomManager
{
public event Action<Room> OpenRequested;
public event Action<Room> RoomJoined;
private readonly BindableCollection<Room> rooms = new BindableCollection<Room>();
public IBindableCollection<Room> Rooms => rooms;
@ -64,7 +64,7 @@ namespace osu.Game.Screens.Multi
currentJoinRoomRequest.Success += () =>
{
currentRoom = room;
OpenRequested?.Invoke(room);
RoomJoined?.Invoke(room);
};
currentJoinRoomRequest.Failure += exception => Logger.Log($"Failed to join room: {exception}");

View File

@ -8,7 +8,7 @@ using osu.Game.Screens.Multi;
namespace osu.Game.Screens.Select
{
public class MatchSongSelect : SongSelect, IMultiplayerScreen
public class MatchSongSelect : SongSelect, IMultiplayerSubScreen
{
public Action<PlaylistItem> Selected;