mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Fix creating a new room re-using the existing model
This commit is contained in:
parent
e22cefc27d
commit
d8739d9dee
@ -105,7 +105,7 @@ namespace osu.Game.Tests.Visual
|
||||
set => TypePicker.Current.Value = value;
|
||||
}
|
||||
|
||||
public TestRoomSettingsOverlay(Room room) : base(room)
|
||||
public TestRoomSettingsOverlay(Room room) : base()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,6 @@ namespace osu.Game.Screens.Multi.Components
|
||||
/// </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>();
|
||||
@ -45,10 +40,8 @@ namespace osu.Game.Screens.Multi.Components
|
||||
protected readonly GameTypePicker TypePicker;
|
||||
protected readonly TriangleButton ApplyButton;
|
||||
|
||||
public RoomSettingsOverlay(Room room)
|
||||
public RoomSettingsOverlay()
|
||||
{
|
||||
Room = room;
|
||||
|
||||
Masking = true;
|
||||
|
||||
Child = content = new Container
|
||||
@ -156,10 +149,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
typeBind.ValueChanged += t => TypePicker.Current.Value = t;
|
||||
maxParticipantsBind.ValueChanged += m => MaxParticipantsField.Text = m?.ToString();
|
||||
|
||||
nameBind.BindTo(room.Name);
|
||||
availabilityBind.BindTo(room.Availability);
|
||||
typeBind.BindTo(room.Type);
|
||||
maxParticipantsBind.BindTo(room.MaxParticipants);
|
||||
Room = new Room();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -168,6 +158,36 @@ namespace osu.Game.Screens.Multi.Components
|
||||
typeLabel.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
private Room room;
|
||||
|
||||
/// <summary>
|
||||
/// The room which settings are being applied to.
|
||||
/// </summary>
|
||||
public Room Room
|
||||
{
|
||||
get => room;
|
||||
set
|
||||
{
|
||||
if (room == value)
|
||||
return;
|
||||
|
||||
room = value;
|
||||
|
||||
nameBind.UnbindBindings();
|
||||
availabilityBind.UnbindBindings();
|
||||
typeBind.UnbindBindings();
|
||||
maxParticipantsBind.UnbindBindings();
|
||||
|
||||
if (room != null)
|
||||
{
|
||||
nameBind.BindTo(room.Name);
|
||||
availabilityBind.BindTo(room.Availability);
|
||||
typeBind.BindTo(room.Type);
|
||||
maxParticipantsBind.BindTo(room.MaxParticipants);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
// reapply the rooms values if the overlay was completely closed
|
||||
|
@ -71,10 +71,11 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = settings = new RoomSettingsOverlay(new Room())
|
||||
Child = settings = new RoomSettingsOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 0.9f,
|
||||
Room = new Room()
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -153,6 +154,9 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
|
||||
protected override void OnResuming(Screen last)
|
||||
{
|
||||
base.OnResuming(last);
|
||||
|
||||
settings.Room = new Room();
|
||||
|
||||
Filter.Search.HoldFocus = true;
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,11 @@ namespace osu.Game.Screens.Multi.Screens.Match
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = Header.HEIGHT },
|
||||
Child = settings = new RoomSettingsOverlay(room)
|
||||
Child = settings = new RoomSettingsOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 0.9f,
|
||||
Room = room
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user