1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Immediately select newly-created rooms

This commit is contained in:
smoogipoo 2018-12-03 20:50:40 +09:00
parent 6a28e8c696
commit e22cefc27d
6 changed files with 58 additions and 44 deletions

View File

@ -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 osu.Framework.Configuration;
using osu.Game.Beatmaps;
using osu.Game.Users;
@ -17,6 +18,6 @@ namespace osu.Game.Online.Multiplayer
public Bindable<GameType> Type = new Bindable<GameType>(new GameTypeVersus());
public Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public Bindable<int?> MaxParticipants = new Bindable<int?>();
public Bindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>();
public Bindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>(Enumerable.Empty<User>());
}
}

View File

@ -34,6 +34,8 @@ namespace osu.Game.Screens.Multi.Components
private const float side_strip_width = 5;
private const float cover_width = 145;
public Action SelectionRequested;
private readonly Box selectionBox;
private readonly Bindable<string> nameBind = new Bindable<string>();
@ -76,17 +78,6 @@ namespace osu.Game.Screens.Multi.Components
}
}
private Action<DrawableRoom> action;
public new Action<DrawableRoom> Action
{
get { return action; }
set
{
action = value;
Enabled.Value = action != null;
}
}
public event Action<SelectionState> StateChanged;
public DrawableRoom(Room room)
@ -248,12 +239,7 @@ namespace osu.Game.Screens.Multi.Components
protected override bool OnClick(ClickEvent e)
{
if (Enabled.Value)
{
Action?.Invoke(this);
State = SelectionState.Selected;
}
return true;
}
}

View File

@ -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.Graphics;
@ -21,6 +22,16 @@ namespace osu.Game.Screens.Multi.Components
private const float transition_duration = 350;
private const float field_padding = 45;
/// <summary>
/// Invoked when room settings were applied.
/// </summary>
public Action Applied;
/// <summary>
/// The room which settings are being applied to.
/// </summary>
public readonly Room Room;
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
@ -36,6 +47,8 @@ namespace osu.Game.Screens.Multi.Components
public RoomSettingsOverlay(Room room)
{
Room = room;
Masking = true;
Child = content = new Container
@ -185,7 +198,7 @@ namespace osu.Game.Screens.Multi.Components
else
maxParticipantsBind.Value = null;
Hide();
Applied?.Invoke();
}
private class SettingsTextBox : OsuTextBox

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -30,29 +29,6 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
protected override Container<Drawable> TransitionContent => content;
private IEnumerable<Room> rooms;
public IEnumerable<Room> Rooms
{
get { return rooms; }
set
{
if (Equals(value, rooms)) return;
rooms = value;
var enumerable = rooms.ToList();
RoomsContainer.Children = enumerable.Select(r => new DrawableRoom(r)
{
Action = didSelect,
}).ToList();
if (!enumerable.Contains(Inspector.Room))
Inspector.Room = null;
filterRooms();
}
}
public Lounge()
{
Children = new Drawable[]
@ -108,6 +84,12 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
Filter.Search.Current.ValueChanged += s => filterRooms();
Filter.Tabs.Current.ValueChanged += t => filterRooms();
Filter.Search.Exit += Exit;
settings.Applied = () =>
{
var drawableRoom = addRoom(settings.Room);
drawableRoom.State = SelectionState.Selected;
};
}
protected override void UpdateAfterChildren()
@ -122,6 +104,35 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
};
}
public IEnumerable<Room> Rooms
{
set
{
RoomsContainer.ForEach(r => r.Action = null);
RoomsContainer.Clear();
foreach (var room in value)
addRoom(room);
}
}
private DrawableRoom addRoom(Room room)
{
var drawableRoom = new DrawableRoom(room);
drawableRoom.StateChanged += s =>
{
if (s == SelectionState.Selected)
didSelect(drawableRoom);
};
RoomsContainer.Add(drawableRoom);
filterRooms();
return drawableRoom;
}
protected override void OnFocus(FocusEvent e)
{
GetContainingInputManager().ChangeFocus(Filter.Search);

View File

@ -88,6 +88,8 @@ namespace osu.Game.Screens.Multi.Screens.Match
header.Tabs.Current.Value = MatchHeaderPage.Room;
};
settings.Applied = () => settings.Hide();
nameBind.BindTo(room.Name);
nameBind.BindValueChanged(n => info.Name = n, true);

View File

@ -19,7 +19,8 @@ namespace osu.Game.Screens.Multi.Screens.Match
public IEnumerable<User> Users
{
set {
set
{
usersFlow.Children = value.Select(u => new UserPanel(u)
{
Anchor = Anchor.TopCentre,