mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 15:12:57 +08:00
Use DI to open the copy rather than passing in an ugly action
This commit is contained in:
parent
6d22f0e196
commit
437ca91b94
@ -38,11 +38,12 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
|
||||
public event Action<SelectionState> StateChanged;
|
||||
|
||||
public Action DuplicateRoom;
|
||||
|
||||
private readonly Box selectionBox;
|
||||
private CachedModelDependencyContainer<Room> dependencies;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private Multiplayer multiplayer { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
@ -239,7 +240,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem("Create copy", MenuItemType.Standard, DuplicateRoom)
|
||||
new OsuMenuItem("Create copy", MenuItemType.Standard, () =>
|
||||
{
|
||||
multiplayer?.CreateRoom(Room.CreateCopy());
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -111,14 +111,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
{
|
||||
roomFlow.Add(new DrawableRoom(room)
|
||||
{
|
||||
DuplicateRoom = () =>
|
||||
{
|
||||
Room newRoom = room.CreateCopy();
|
||||
if (!newRoom.Name.Value.StartsWith("Copy of "))
|
||||
newRoom.Name.Value = $"Copy of {room.Name.Value}";
|
||||
|
||||
loungeSubScreen?.Open(newRoom);
|
||||
},
|
||||
Action = () =>
|
||||
{
|
||||
if (room == selectedRoom.Value)
|
||||
|
@ -134,7 +134,7 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Action = createRoom
|
||||
Action = () => CreateRoom()
|
||||
},
|
||||
roomManager = new RoomManager()
|
||||
}
|
||||
@ -289,10 +289,11 @@ namespace osu.Game.Screens.Multi
|
||||
logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut();
|
||||
}
|
||||
|
||||
private void createRoom()
|
||||
{
|
||||
loungeSubScreen.Open(new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } });
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a new room.
|
||||
/// </summary>
|
||||
/// <param name="room">An optional template to use when creating the room.</param>
|
||||
public void CreateRoom(Room room = null) => loungeSubScreen.Open(room ?? new Room { Name = { Value = $"{api.LocalUser}'s awesome room" } });
|
||||
|
||||
private void beginHandlingTrack()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user