mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 01:37:31 +08:00
Move from lobby into match for creation process
This commit is contained in:
parent
3b688c702c
commit
77193eeea4
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing.Input;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osu.Game.Screens.Multi.Screens.Match;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
|
@ -19,5 +19,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
public Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
public Bindable<int?> MaxParticipants = new Bindable<int?>();
|
||||
public Bindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>(Enumerable.Empty<User>());
|
||||
|
||||
public Bindable<bool> Created = new Bindable<bool>();
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
// Copyright (c) 2007-2018 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.Game.Online.API;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
{
|
||||
public class CreateRoomOverlay : RoomSettingsOverlay
|
||||
{
|
||||
[Resolved]
|
||||
private APIAccess api { get; set; }
|
||||
|
||||
public CreateRoomOverlay()
|
||||
{
|
||||
MaxParticipantsField.ReadOnly = true;
|
||||
AvailabilityPicker.ReadOnly.Value = true;
|
||||
TypePicker.ReadOnly.Value = true;
|
||||
PasswordField.ReadOnly = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Room.Host.Value = api.LocalUser;
|
||||
}
|
||||
|
||||
public override Room Room
|
||||
{
|
||||
get => base.Room;
|
||||
set
|
||||
{
|
||||
base.Room = value;
|
||||
|
||||
if (api != null && value != null)
|
||||
value.Host.Value = api.LocalUser;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
{
|
||||
private readonly Container content;
|
||||
private readonly SearchContainer search;
|
||||
private readonly CreateRoomOverlay createRoomOverlay;
|
||||
|
||||
protected readonly FilterControl Filter;
|
||||
protected readonly FillFlowContainer<DrawableRoom> RoomsContainer;
|
||||
@ -68,16 +67,6 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.45f,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = createRoomOverlay = new CreateRoomOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 0.9f,
|
||||
Room = new Room()
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
@ -85,8 +74,6 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
Filter.Search.Current.ValueChanged += s => filterRooms();
|
||||
Filter.Tabs.Current.ValueChanged += t => filterRooms();
|
||||
Filter.Search.Exit += Exit;
|
||||
|
||||
createRoomOverlay.Applied = () => createRoom(createRoomOverlay.Room);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
@ -147,8 +134,6 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
{
|
||||
base.OnResuming(last);
|
||||
|
||||
createRoomOverlay.Room = new Room();
|
||||
|
||||
Filter.Search.HoldFocus = true;
|
||||
}
|
||||
|
||||
@ -161,9 +146,10 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
private void filterRooms()
|
||||
{
|
||||
if (Filter.Tabs.Current.Value == LoungeTab.Create)
|
||||
createRoomOverlay.Show();
|
||||
else
|
||||
createRoomOverlay.Hide();
|
||||
{
|
||||
Filter.Tabs.Current.Value = LoungeTab.Public;
|
||||
createRoom(new Room());
|
||||
}
|
||||
|
||||
search.SearchTerm = Filter.Search.Current.Value ?? string.Empty;
|
||||
|
||||
|
@ -15,7 +15,6 @@ using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -29,7 +28,7 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
|
||||
private readonly Box tabStrip;
|
||||
|
||||
public readonly PageTabControl<MatchHeaderPage> Tabs;
|
||||
public readonly MatchTabControl Tabs;
|
||||
|
||||
public Action OnRequestSelectBeatmap;
|
||||
|
||||
@ -78,11 +77,11 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
Tabs = new PageTabControl<MatchHeaderPage>
|
||||
Tabs = new MatchTabControl
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.X
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -7,8 +7,8 @@ using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -16,7 +16,6 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
{
|
||||
public class Match : MultiplayerScreen
|
||||
{
|
||||
private readonly Room room;
|
||||
private readonly Participants participants;
|
||||
|
||||
private readonly Bindable<string> nameBind = new Bindable<string>();
|
||||
@ -33,9 +32,17 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
|
||||
public override string ShortTitle => "room";
|
||||
|
||||
private readonly Header header;
|
||||
|
||||
[Cached]
|
||||
private readonly Room room;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmapManager { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private APIAccess api { get; set; }
|
||||
|
||||
public Match(Room room)
|
||||
{
|
||||
this.room = room;
|
||||
@ -48,7 +55,6 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
participantsBind.BindTo(room.Participants);
|
||||
maxParticipantsBind.BindTo(room.MaxParticipants);
|
||||
|
||||
Header header;
|
||||
RoomSettingsOverlay settings;
|
||||
Info info;
|
||||
|
||||
@ -86,7 +92,7 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
|
||||
header.Tabs.Current.ValueChanged += t =>
|
||||
{
|
||||
if (t == MatchHeaderPage.Settings)
|
||||
if (t is SettingsMatchPage)
|
||||
settings.Show();
|
||||
else
|
||||
settings.Hide();
|
||||
@ -95,7 +101,7 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
settings.StateChanged += s =>
|
||||
{
|
||||
if (s == Visibility.Hidden)
|
||||
header.Tabs.Current.Value = MatchHeaderPage.Room;
|
||||
header.Tabs.Current.Value = new RoomMatchPage();
|
||||
};
|
||||
|
||||
settings.Applied = () => settings.Hide();
|
||||
|
28
osu.Game/Screens/Multi/Screens/Match/MatchPage.cs
Normal file
28
osu.Game/Screens/Multi/Screens/Match/MatchPage.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Screens.Match
|
||||
{
|
||||
public abstract class MatchPage
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
|
||||
public readonly BindableBool Enabled = new BindableBool(true);
|
||||
|
||||
public override string ToString() => Name;
|
||||
public override int GetHashCode() => GetType().GetHashCode();
|
||||
public override bool Equals(object obj) => GetType() == obj?.GetType();
|
||||
}
|
||||
|
||||
public class SettingsMatchPage : MatchPage
|
||||
{
|
||||
public override string Name => "Settings";
|
||||
}
|
||||
|
||||
public class RoomMatchPage : MatchPage
|
||||
{
|
||||
public override string Name => "Room";
|
||||
}
|
||||
}
|
68
osu.Game/Screens/Multi/Screens/Match/MatchTabControl.cs
Normal file
68
osu.Game/Screens/Multi/Screens/Match/MatchTabControl.cs
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2007-2018 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.Configuration;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Screens.Match
|
||||
{
|
||||
public class MatchTabControl : PageTabControl<MatchPage>
|
||||
{
|
||||
private readonly IBindable<bool> created = new Bindable<bool>();
|
||||
|
||||
[Resolved]
|
||||
private Room room { get; set; }
|
||||
|
||||
public MatchTabControl()
|
||||
{
|
||||
AddItem(new SettingsMatchPage());
|
||||
AddItem(new RoomMatchPage());
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
created.BindTo(room.Created);
|
||||
created.BindValueChanged(v =>
|
||||
{
|
||||
if (v)
|
||||
{
|
||||
Items.ForEach(t => t.Enabled.Value = !(t is SettingsMatchPage));
|
||||
Current.Value = new RoomMatchPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
Items.ForEach(t => t.Enabled.Value = t is SettingsMatchPage);
|
||||
Current.Value = new SettingsMatchPage();
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override TabItem<MatchPage> CreateTabItem(MatchPage value) => new TabItem(value);
|
||||
|
||||
private class TabItem : PageTabItem
|
||||
{
|
||||
private readonly IBindable<bool> enabled = new BindableBool();
|
||||
|
||||
public TabItem(MatchPage value)
|
||||
: base(value)
|
||||
{
|
||||
enabled.BindTo(value.Enabled);
|
||||
enabled.BindValueChanged(v => Colour = v ? Color4.White : Color4.Gray);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!enabled.Value)
|
||||
return true;
|
||||
return base.OnClick(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,10 +12,11 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Components
|
||||
namespace osu.Game.Screens.Multi.Screens.Match
|
||||
{
|
||||
public class RoomSettingsOverlay : FocusedOverlayContainer
|
||||
{
|
Loading…
x
Reference in New Issue
Block a user