1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:23:22 +08:00

Make Room.Name non-bindable

This commit is contained in:
Dan Balasescu 2024-11-13 16:55:18 +09:00
parent a2a930aa35
commit 6160df1586
No known key found for this signature in database
29 changed files with 200 additions and 153 deletions

View File

@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.DailyChallenge
var room = new Room
{
RoomID = 1234,
Name = { Value = "Daily Challenge: June 4, 2024" },
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.DailyChallenge
var room = new Room
{
RoomID = 1234,
Name = { Value = "Daily Challenge: June 4, 2024" },
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())
@ -92,7 +92,7 @@ namespace osu.Game.Tests.Visual.DailyChallenge
var room = new Room
{
RoomID = 1234,
Name = { Value = "Daily Challenge: June 4, 2024" },
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
new PlaylistItem(TestResources.CreateTestBeatmapSetInfo().Beatmaps.First())

View File

@ -69,7 +69,7 @@ namespace osu.Game.Tests.Visual.DailyChallenge
API.Perform(new CreateRoomRequest(room = new Room
{
RoomID = roomId,
Name = { Value = "Daily Challenge: June 4, 2024" },
Name = "Daily Challenge: June 4, 2024",
Playlist =
{
new PlaylistItem(CreateAPIBeatmap(new OsuRuleset().RulesetInfo))

View File

@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Menus
getRoomRequest.TriggerSuccess(new Room
{
RoomID = 1234,
Name = { Value = "Aug 8, 2024" },
Name = "Aug 8, 2024",
Playlist =
{
new PlaylistItem(beatmap)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -30,16 +28,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
protected abstract QueueMode Mode { get; }
protected BeatmapInfo InitialBeatmap { get; private set; }
protected BeatmapInfo OtherBeatmap { get; private set; }
protected BeatmapInfo InitialBeatmap { get; private set; } = null!;
protected BeatmapInfo OtherBeatmap { get; private set; } = null!;
protected IScreen CurrentScreen => multiplayerComponents.CurrentScreen;
protected IScreen CurrentSubScreen => multiplayerComponents.MultiplayerScreen.CurrentSubScreen;
private BeatmapManager beatmaps;
private BeatmapSetInfo importedSet;
private BeatmapManager beatmaps = null!;
private BeatmapSetInfo importedSet = null!;
private TestMultiplayerComponents multiplayerComponents;
private TestMultiplayerComponents multiplayerComponents = null!;
protected TestMultiplayerClient MultiplayerClient => multiplayerComponents.MultiplayerClient;
@ -75,7 +73,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for lounge", () => multiplayerComponents.ChildrenOfType<LoungeSubScreen>().SingleOrDefault()?.IsLoaded == true);
AddStep("open room", () => multiplayerComponents.ChildrenOfType<LoungeSubScreen>().Single().Open(new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
QueueMode = { Value = Mode },
Playlist =
{

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using System.Linq;
using NUnit.Framework;
@ -32,12 +30,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Cached]
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
private readonly Bindable<Room> selectedRoom = new Bindable<Room>();
private readonly Bindable<Room?> selectedRoom = new Bindable<Room?>();
[Test]
public void TestMultipleStatuses()
{
FillFlowContainer rooms = null;
FillFlowContainer rooms = null!;
AddStep("create rooms", () =>
{
@ -77,7 +75,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createLoungeRoom(new Room
{
Name = { Value = "Multiplayer room" },
Name = "Multiplayer room",
Status = { Value = new RoomStatusOpen() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
Type = { Value = MatchType.HeadToHead },
@ -86,7 +84,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}),
createLoungeRoom(new Room
{
Name = { Value = "Private room" },
Name = "Private room",
Status = { Value = new RoomStatusOpenPrivate() },
HasPassword = { Value = true },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
@ -96,7 +94,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
}),
createLoungeRoom(new Room
{
Name = { Value = "Playlist room with multiple beatmaps" },
Name = "Playlist room with multiple beatmaps",
Status = { Value = new RoomStatusPlaying() },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
Playlist = { item1, item2 },
@ -104,19 +102,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
}),
createLoungeRoom(new Room
{
Name = { Value = "Finished room" },
Name = "Finished room",
Status = { Value = new RoomStatusEnded() },
EndDate = { Value = DateTimeOffset.Now },
}),
createLoungeRoom(new Room
{
Name = { Value = "Spotlight room" },
Name = "Spotlight room",
Status = { Value = new RoomStatusOpen() },
Category = { Value = RoomCategory.Spotlight },
}),
createLoungeRoom(new Room
{
Name = { Value = "Featured artist room" },
Name = "Featured artist room",
Status = { Value = new RoomStatusOpen() },
Category = { Value = RoomCategory.FeaturedArtist },
}),
@ -132,12 +130,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Test]
public void TestEnableAndDisablePassword()
{
DrawableRoom drawableRoom = null;
Room room = null;
DrawableRoom drawableRoom = null!;
Room room = null!;
AddStep("create room", () => Child = drawableRoom = createLoungeRoom(room = new Room
{
Name = { Value = "Room with password" },
Name = "Room with password",
Status = { Value = new RoomStatusOpen() },
Type = { Value = MatchType.HeadToHead },
}));
@ -166,30 +164,30 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
new DrawableMatchRoom(new Room
{
Name = { Value = "A host-only room" },
Name = "A host-only room",
QueueMode = { Value = QueueMode.HostOnly },
Type = { Value = MatchType.HeadToHead },
})
{
SelectedItem = new Bindable<PlaylistItem>()
SelectedItem = new Bindable<PlaylistItem?>()
},
new DrawableMatchRoom(new Room
{
Name = { Value = "An all-players, team-versus room" },
Name = "An all-players, team-versus room",
QueueMode = { Value = QueueMode.AllPlayers },
Type = { Value = MatchType.TeamVersus }
})
{
SelectedItem = new Bindable<PlaylistItem>()
SelectedItem = new Bindable<PlaylistItem?>()
},
new DrawableMatchRoom(new Room
{
Name = { Value = "A round-robin room" },
Name = "A round-robin room",
QueueMode = { Value = QueueMode.AllPlayersRoundRobin },
Type = { Value = MatchType.HeadToHead }
})
{
SelectedItem = new Bindable<PlaylistItem>()
SelectedItem = new Bindable<PlaylistItem?>()
},
}
});

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
@ -17,7 +15,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
public partial class TestSceneDrawableRoomParticipantsList : OnlinePlayTestScene
{
private DrawableRoomParticipantsList list;
private DrawableRoomParticipantsList list = null!;
public override void SetUpSteps()
{
@ -27,7 +25,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
SelectedRoom.Value = new Room
{
Name = { Value = "test room" },
Name = "test room",
Host =
{
Value = new APIUser

View File

@ -103,7 +103,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -238,7 +238,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
roomManager.AddServerSideRoom(new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -288,7 +288,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
roomManager.AddServerSideRoom(new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -317,7 +317,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Password = { Value = "password" },
Playlist =
{
@ -338,7 +338,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
roomManager.AddServerSideRoom(new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Password = { Value = "password" },
Playlist =
{
@ -370,7 +370,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Password = { Value = "password" },
Playlist =
{
@ -401,7 +401,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -430,7 +430,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
};
return new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist = { item }
};
});
@ -471,7 +471,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
};
return new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist = { item }
};
});
@ -512,7 +512,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
};
return new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist = { item }
};
});
@ -548,7 +548,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -581,7 +581,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -620,7 +620,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -639,7 +639,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -679,7 +679,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -724,7 +724,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -754,7 +754,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -791,7 +791,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
roomManager.AddServerSideRoom(new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
QueueMode = { Value = QueueMode.AllPlayers },
Playlist =
{
@ -810,7 +810,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("disable polling", () => this.ChildrenOfType<ListingPollingComponent>().Single().TimeBetweenPolls.Value = 0);
AddStep("change server-side settings", () =>
{
roomManager.ServerSideRooms[0].Name.Value = "New name";
roomManager.ServerSideRooms[0].Name = "New name";
roomManager.ServerSideRooms[0].Playlist.Add(new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
{
ID = 2,
@ -825,7 +825,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("local room has correct settings", () =>
{
var localRoom = this.ChildrenOfType<MultiplayerMatchSubScreen>().Single().Room;
return localRoom.Name.Value == roomManager.ServerSideRooms[0].Name.Value
return localRoom.Name == roomManager.ServerSideRooms[0].Name
&& localRoom.Playlist.SequenceEqual(roomManager.ServerSideRooms[0].Playlist);
});
}
@ -836,7 +836,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
QueueMode = { Value = QueueMode.AllPlayers },
Playlist =
{
@ -872,7 +872,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
QueueMode = { Value = QueueMode.AllPlayers },
Playlist =
{
@ -911,7 +911,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
QueueMode = { Value = QueueMode.AllPlayers },
Playlist =
{
@ -942,7 +942,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
QueueMode = { Value = QueueMode.AllPlayers },
Playlist =
{
@ -976,7 +976,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
@ -1022,7 +1022,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
QueueMode = { Value = QueueMode.AllPlayers },
Playlist =
{

View File

@ -69,7 +69,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
AddStep("load match", () =>
{
SelectedRoom.Value = new Room { Name = { Value = "Test Room" } };
SelectedRoom.Value = new Room { Name = "Test Room" };
LoadScreen(screen = new TestMultiplayerMatchSubScreen(SelectedRoom.Value));
});

View File

@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
RoomManager.CreateRoom(new Room
{
Name = { Value = "test name" },
Name = "test name",
Playlist =
{
new PlaylistItem(new TestBeatmap(Ruleset.Value).BeatmapInfo)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using System.Linq;
using NUnit.Framework;
@ -29,10 +27,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
public partial class TestSceneTeamVersus : ScreenTestScene
{
private BeatmapManager beatmaps;
private BeatmapSetInfo importedSet;
private BeatmapManager beatmaps = null!;
private BeatmapSetInfo importedSet = null!;
private TestMultiplayerComponents multiplayerComponents;
private TestMultiplayerComponents multiplayerComponents = null!;
private TestMultiplayerClient multiplayerClient => multiplayerComponents.MultiplayerClient;
@ -64,7 +62,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Type = { Value = MatchType.TeamVersus },
Playlist =
{
@ -84,7 +82,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Type = { Value = MatchType.TeamVersus },
Playlist =
{
@ -121,7 +119,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Type = { Value = MatchType.HeadToHead },
Playlist =
{
@ -147,7 +145,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Name = "Test Room",
Playlist =
{
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using NUnit.Framework;
using osu.Framework.Bindables;
@ -22,7 +20,7 @@ namespace osu.Game.Tests.Visual.Playlists
{
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
private TestRoomSettings settings;
private TestRoomSettings settings = null!;
protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new TestDependencies();
@ -47,19 +45,19 @@ namespace osu.Game.Tests.Visual.Playlists
{
AddStep("clear name and beatmap", () =>
{
SelectedRoom.Value.Name.Value = "";
SelectedRoom.Value.Name = "";
SelectedRoom.Value.Playlist.Clear();
});
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
AddStep("set name", () => SelectedRoom.Value.Name.Value = "Room name");
AddStep("set name", () => SelectedRoom.Value.Name = "Room name");
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
AddStep("set beatmap", () => SelectedRoom.Value.Playlist.Add(new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo)));
AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value);
AddStep("clear name", () => SelectedRoom.Value.Name.Value = "");
AddStep("clear name", () => SelectedRoom.Value.Name = "");
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
}
@ -69,7 +67,7 @@ namespace osu.Game.Tests.Visual.Playlists
const string expected_name = "expected name";
TimeSpan expectedDuration = TimeSpan.FromMinutes(15);
Room createdRoom = null;
Room createdRoom = null!;
AddStep("setup", () =>
{
@ -85,7 +83,7 @@ namespace osu.Game.Tests.Visual.Playlists
});
AddStep("create room", () => settings.ApplyButton.Action.Invoke());
AddAssert("has correct name", () => createdRoom.Name.Value == expected_name);
AddAssert("has correct name", () => createdRoom.Name == expected_name);
AddAssert("has correct duration", () => createdRoom.Duration.Value == expectedDuration);
}
@ -94,13 +92,13 @@ namespace osu.Game.Tests.Visual.Playlists
{
const string not_found_prefix = "beatmaps not found:";
string errorMessage = null;
string errorMessage = null!;
AddStep("setup", () =>
{
var beatmap = CreateBeatmap(Ruleset.Value).BeatmapInfo;
SelectedRoom.Value.Name.Value = "Test Room";
SelectedRoom.Value.Name = "Test Room";
SelectedRoom.Value.Playlist.Add(new PlaylistItem(beatmap));
errorMessage = $"{not_found_prefix} {beatmap.OnlineID}";
@ -127,7 +125,7 @@ namespace osu.Game.Tests.Visual.Playlists
AddStep("setup", () =>
{
SelectedRoom.Value.Name.Value = "Test Room";
SelectedRoom.Value.Name = "Test Room";
SelectedRoom.Value.Playlist.Add(new PlaylistItem(CreateBeatmap(Ruleset.Value).BeatmapInfo));
RoomManager.CreateRequested = _ => failText;
@ -169,7 +167,7 @@ namespace osu.Game.Tests.Visual.Playlists
protected class TestRoomManager : IRoomManager
{
public Func<Room, string> CreateRequested;
public Func<Room, string>? CreateRequested;
public event Action RoomsUpdated
{
@ -187,7 +185,7 @@ namespace osu.Game.Tests.Visual.Playlists
public void ClearRooms() => throw new NotImplementedException();
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
public void CreateRoom(Room room, Action<Room>? onSuccess = null, Action<string>? onError = null)
{
if (CreateRequested == null)
return;
@ -200,7 +198,7 @@ namespace osu.Game.Tests.Visual.Playlists
onSuccess?.Invoke(room);
}
public void JoinRoom(Room room, string password, Action<Room> onSuccess = null, Action<string> onError = null) => throw new NotImplementedException();
public void JoinRoom(Room room, string? password, Action<Room>? onSuccess = null, Action<string>? onError = null) => throw new NotImplementedException();
public void PartRoom() => throw new NotImplementedException();
}

View File

@ -1,12 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -35,11 +32,9 @@ namespace osu.Game.Tests.Visual.Playlists
{
public partial class TestScenePlaylistsRoomCreation : OnlinePlayTestScene
{
private BeatmapManager manager;
private TestPlaylistsRoomSubScreen match;
private BeatmapSetInfo importedBeatmap;
private BeatmapManager manager = null!;
private TestPlaylistsRoomSubScreen match = null!;
private BeatmapSetInfo importedBeatmap = null!;
[BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio)
@ -52,11 +47,11 @@ namespace osu.Game.Tests.Visual.Playlists
[SetUpSteps]
public void SetupSteps()
{
AddStep("set room", () => SelectedRoom!.Value = new Room());
AddStep("set room", () => SelectedRoom.Value = new Room());
importBeatmap();
AddStep("load match", () => LoadScreen(match = new TestPlaylistsRoomSubScreen(SelectedRoom!.Value)));
AddStep("load match", () => LoadScreen(match = new TestPlaylistsRoomSubScreen(SelectedRoom.Value)));
AddUntilStep("wait for load", () => match.IsCurrentScreen());
}
@ -65,7 +60,7 @@ namespace osu.Game.Tests.Visual.Playlists
{
setupAndCreateRoom(room =>
{
room.Name.Value = "my awesome room";
room.Name = "my awesome room";
room.Host.Value = API.LocalUser.Value;
room.RecentParticipants.Add(room.Host.Value);
room.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
@ -88,7 +83,7 @@ namespace osu.Game.Tests.Visual.Playlists
{
setupAndCreateRoom(room =>
{
room.Name.Value = "my awesome room";
room.Name = "my awesome room";
room.MaxAttempts.Value = 5;
room.Host.Value = API.LocalUser.Value;
room.RecentParticipants.Add(room.Host.Value);
@ -107,7 +102,7 @@ namespace osu.Game.Tests.Visual.Playlists
{
setupAndCreateRoom(room =>
{
room.Name.Value = "my awesome room";
room.Name = "my awesome room";
room.Host.Value = API.LocalUser.Value;
room.Playlist.Add(new PlaylistItem(importedBeatmap.Beatmaps.First())
{
@ -115,13 +110,13 @@ namespace osu.Game.Tests.Visual.Playlists
});
});
AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom!.Value.Playlist[0]);
AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom.Value.Playlist[0]);
}
[Test]
public void TestBeatmapUpdatedOnReImport()
{
string realHash = null;
string realHash = null!;
int realOnlineId = 0;
int realOnlineSetId = 0;
@ -139,26 +134,23 @@ namespace osu.Game.Tests.Visual.Playlists
BeatmapInfo =
{
OnlineID = realOnlineId,
Metadata = new BeatmapMetadata(),
BeatmapSet =
{
OnlineID = realOnlineSetId
}
Metadata = new BeatmapMetadata()
},
};
Debug.Assert(modifiedBeatmap.BeatmapInfo.BeatmapSet != null);
modifiedBeatmap.BeatmapInfo.BeatmapSet!.OnlineID = realOnlineSetId;
modifiedBeatmap.HitObjects.Clear();
modifiedBeatmap.HitObjects.Add(new HitCircle { StartTime = 5000 });
Debug.Assert(modifiedBeatmap.BeatmapInfo.BeatmapSet != null);
manager.Import(modifiedBeatmap.BeatmapInfo.BeatmapSet);
});
// Create the room using the real beatmap values.
setupAndCreateRoom(room =>
{
room.Name.Value = "my awesome room";
room.Name = "my awesome room";
room.Host.Value = API.LocalUser.Value;
room.Playlist.Add(new PlaylistItem(new BeatmapInfo
{
@ -181,17 +173,11 @@ namespace osu.Game.Tests.Visual.Playlists
{
var originalBeatmap = new TestBeatmap(new OsuRuleset().RulesetInfo)
{
BeatmapInfo =
{
OnlineID = realOnlineId,
BeatmapSet =
{
OnlineID = realOnlineSetId
}
},
BeatmapInfo = { OnlineID = realOnlineId },
};
Debug.Assert(originalBeatmap.BeatmapInfo.BeatmapSet != null);
originalBeatmap.BeatmapInfo.BeatmapSet.OnlineID = realOnlineSetId;
manager.Import(originalBeatmap.BeatmapInfo.BeatmapSet);
});
@ -201,7 +187,7 @@ namespace osu.Game.Tests.Visual.Playlists
private void setupAndCreateRoom(Action<Room> room)
{
AddStep("setup room", () => room(SelectedRoom!.Value));
AddStep("setup room", () => room(SelectedRoom.Value));
AddStep("click create button", () =>
{
@ -215,8 +201,7 @@ namespace osu.Game.Tests.Visual.Playlists
var beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
Debug.Assert(beatmap.BeatmapInfo.BeatmapSet != null);
importedBeatmap = manager.Import(beatmap.BeatmapInfo.BeatmapSet)?.Value.Detach();
importedBeatmap = manager.Import(beatmap.BeatmapInfo.BeatmapSet)!.Value.Detach();
});
private partial class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
@ -226,8 +211,7 @@ namespace osu.Game.Tests.Visual.Playlists
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
[Resolved(canBeNull: true)]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }
private IDialogOverlay? dialogOverlay { get; set; }
public TestPlaylistsRoomSubScreen(Room room)
: base(room)

View File

@ -459,7 +459,7 @@ namespace osu.Game.Online.Multiplayer
if (apiUser == null || apiRoom == null) return;
PostNotification?.Invoke(
new UserAvatarNotification(apiUser, NotificationsStrings.InvitedYouToTheMultiplayer(apiUser.Username, apiRoom.Name.Value))
new UserAvatarNotification(apiUser, NotificationsStrings.InvitedYouToTheMultiplayer(apiUser.Username, apiRoom.Name))
{
Activated = () =>
{
@ -841,7 +841,7 @@ namespace osu.Game.Online.Multiplayer
// Update a few properties of the room instantaneously.
Room.Settings = settings;
APIRoom.Name.Value = Room.Settings.Name;
APIRoom.Name = Room.Settings.Name;
APIRoom.Password.Value = Room.Settings.Password;
APIRoom.Status.Value = string.IsNullOrEmpty(Room.Settings.Password) ? new RoomStatusOpen() : new RoomStatusOpenPrivate();
APIRoom.Type.Value = Room.Settings.MatchType;

View File

@ -30,6 +30,15 @@ namespace osu.Game.Online.Rooms
set => SetField(ref roomId, value);
}
/// <summary>
/// The room name.
/// </summary>
public string Name
{
get => name;
set => SetField(ref name, value);
}
/// <summary>
/// Represents the current item selected within the room.
/// </summary>
@ -45,13 +54,12 @@ namespace osu.Game.Online.Rooms
[JsonProperty("id")]
private long? roomId;
[JsonProperty("name")]
private string name = string.Empty;
[JsonProperty("current_playlist_item")]
private PlaylistItem? currentPlaylistItem;
[Cached]
[JsonProperty("name")]
public readonly Bindable<string> Name = new Bindable<string>();
[Cached]
[JsonProperty("host")]
public readonly Bindable<APIUser?> Host = new Bindable<APIUser?>();
@ -205,7 +213,7 @@ namespace osu.Game.Online.Rooms
public void CopyFrom(Room other)
{
RoomID = other.RoomID;
Name.Value = other.Name.Value;
Name = other.Name;
Category.Value = other.Category.Value;

View File

@ -122,7 +122,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
}
catch (Exception ex)
{
Logger.Error(ex, $"Failed to update room: {room.Name.Value}.");
Logger.Error(ex, $"Failed to update room: {room.Name}.");
ignoredRooms.Add(room.RoomID.Value);
rooms.Remove(room);

View File

@ -169,7 +169,7 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = room.Name.Value.Split(':', StringSplitOptions.TrimEntries).Last(),
Text = room.Name.Split(':', StringSplitOptions.TrimEntries).Last(),
Margin = new MarginPadding { Horizontal = 10f, Vertical = 5f },
Shear = new Vector2(-OsuGame.SHEAR, 0f),
Font = OsuFont.GetFont(size: 32, weight: FontWeight.Light, typeface: Typeface.TorusAlternate),

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using osu.Framework.Allocation;
@ -26,6 +27,7 @@ using osu.Game.Overlays;
using osu.Game.Screens.OnlinePlay.Components;
using osuTK;
using osuTK.Graphics;
using Container = osu.Framework.Graphics.Containers.Container;
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
@ -47,6 +49,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private RoomSpecialCategoryPill? specialCategoryPill;
private PasswordProtectedIcon? passwordIcon;
private EndDateInfo? endDateInfo;
private SpriteText? roomName;
private UpdateableBeatmapBackgroundSprite background = null!;
private DelayedLoadWrapper wrapper = null!;
@ -181,11 +184,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new TruncatingSpriteText
roomName = new TruncatingSpriteText
{
RelativeSizeAxes = Axes.X,
Font = OsuFont.GetFont(size: 28),
Current = { BindTarget = Room.Name }
Font = OsuFont.GetFont(size: 28)
},
new RoomStatusText
{
@ -247,6 +249,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
base.LoadComplete();
Room.PropertyChanged += onRoomPropertyChanged;
wrapper.DelayedLoadComplete += _ =>
{
Debug.Assert(specialCategoryPill != null);
@ -272,11 +276,25 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
hasPassword.BindTo(Room.HasPassword);
hasPassword.BindValueChanged(v => passwordIcon.Alpha = v.NewValue ? 1 : 0, true);
updateRoomName();
};
SelectedItem.BindValueChanged(item => background.Beatmap.Value = item.NewValue?.Beatmap, true);
}
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Room.Name))
updateRoomName();
}
private void updateRoomName()
{
if (roomName != null)
roomName.Text = Room.Name;
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
return new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent))
@ -332,6 +350,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
return pills;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
Room.PropertyChanged -= onRoomPropertyChanged;
}
private partial class RoomStatusText : OnlinePlayComposite
{
public readonly IBindable<PlaylistItem?> SelectedItem = new Bindable<PlaylistItem?>();

View File

@ -121,7 +121,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
public bool FilteringActive { get; set; }
public IEnumerable<LocalisableString> FilterTerms => new LocalisableString[] { Room.Name.Value };
public IEnumerable<LocalisableString> FilterTerms => new LocalisableString[] { Room.Name };
private bool matchingFilter = true;

View File

@ -350,7 +350,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
};
TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue.GetLocalisableDescription(), true);
RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true);
Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true);
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true);
@ -374,8 +373,21 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
drawablePlaylist.Items.BindTo(Playlist);
drawablePlaylist.SelectedItem.BindTo(SelectedItem);
room.PropertyChanged += onRoomPropertyChanged;
updateRoomName();
}
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Room.Name))
updateRoomName();
}
private void updateRoomName()
=> NameField.Text = room.Name;
protected override void Update()
{
base.Update();
@ -417,7 +429,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
}
else
{
room.Name.Value = NameField.Text;
room.Name = NameField.Text;
room.Type.Value = TypePicker.Current.Value;
room.Password.Value = PasswordTextBox.Current.Value;
room.QueueMode.Value = QueueModeDropdown.Current.Value;
@ -467,6 +479,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
applyingSettingsOperation.Dispose();
applyingSettingsOperation = null;
});
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
room.PropertyChanged -= onRoomPropertyChanged;
}
}
public partial class CreateOrUpdateButton : RoundedButton

View File

@ -73,7 +73,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
protected override Room CreateNewRoom() => new Room
{
Name = { Value = $"{api.LocalUser}'s awesome room" },
Name = $"{api.LocalUser}'s awesome room",
Type = { Value = MatchType.HeadToHead },
};

View File

@ -54,7 +54,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public MultiplayerMatchSubScreen(Room room)
: base(room)
{
Title = room.RoomID == null ? "New room" : room.Name.Value;
Title = room.RoomID == null ? "New room" : room.Name;
Activity.Value = new UserActivity.InLobby(room);
}

View File

@ -16,9 +16,6 @@ namespace osu.Game.Screens.OnlinePlay
/// </summary>
public partial class OnlinePlayComposite : CompositeDrawable
{
[Resolved(typeof(Room), nameof(Room.Name))]
protected Bindable<string> RoomName { get; private set; } = null!;
[Resolved(typeof(Room))]
protected Bindable<APIUser> Host { get; private set; } = null!;

View File

@ -67,7 +67,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{
return new Room
{
Name = { Value = $"{api.LocalUser}'s awesome playlist" },
Name = $"{api.LocalUser}'s awesome playlist",
Type = { Value = MatchType.Playlists }
};
}

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using Humanizer;
using Humanizer.Localisation;
@ -25,6 +26,7 @@ using osu.Game.Screens.OnlinePlay.Match.Components;
using osuTK;
using osu.Game.Localisation;
using osu.Game.Rulesets;
using Container = osu.Framework.Graphics.Containers.Container;
namespace osu.Game.Screens.OnlinePlay.Playlists
{
@ -142,7 +144,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{
RelativeSizeAxes = Axes.X,
TabbableContentContainer = this,
LengthLimit = 100
LengthLimit = 100,
Text = room.Name
},
},
new Section("Duration")
@ -313,7 +316,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
loadingLayer = new LoadingLayer(true)
};
RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true);
Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true);
MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true);
MaxAttempts.BindValueChanged(count => MaxAttemptsField.Text = count.NewValue?.ToString(), true);
@ -337,6 +339,24 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
Playlist.BindCollectionChanged(onPlaylistChanged, true);
}
protected override void LoadComplete()
{
base.LoadComplete();
room.PropertyChanged += onRoomPropertyChanged;
updateRoomName();
}
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Room.Name))
updateRoomName();
}
private void updateRoomName()
=> NameField.Text = room.Name;
private void populateDurations(ValueChangedEvent<APIUser> user)
{
// roughly correct (see https://github.com/Humanizr/Humanizer/blob/18167e56c082449cc4fe805b8429e3127a7b7f93/readme.md?plain=1#L427)
@ -384,7 +404,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
hideError();
RoomName.Value = NameField.Text;
room.Name = NameField.Text;
Availability.Value = AvailabilityPicker.Current.Value;
if (int.TryParse(MaxParticipantsField.Text, out int max))
@ -436,6 +456,12 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
ErrorText.FadeIn(50);
loadingLayer.Hide();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
room.PropertyChanged -= onRoomPropertyChanged;
}
}
public partial class CreateRoomButton : RoundedButton

View File

@ -42,7 +42,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
public PlaylistsRoomSubScreen(Room room)
: base(room, false) // Editing is temporarily not allowed.
{
Title = room.RoomID == null ? "New playlist" : room.Name.Value;
Title = room.RoomID == null ? "New playlist" : room.Name;
Activity.Value = new UserActivity.InLobby(room);
}

View File

@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
return new Room
{
Name = { Value = "test name" },
Name = "test name",
Type = { Value = MatchType.HeadToHead },
Playlist =
{

View File

@ -230,7 +230,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Settings =
{
Name = ServerAPIRoom.Name.Value,
Name = ServerAPIRoom.Name,
MatchType = ServerAPIRoom.Type.Value,
Password = password ?? string.Empty,
QueueMode = ServerAPIRoom.QueueMode.Value,

View File

@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
var room = new Room
{
RoomID = -currentRoomId,
Name = { Value = $@"Room {currentRoomId}" },
Name = $@"Room {currentRoomId}",
Host = { Value = new APIUser { Username = @"Host" } },
EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) },
Category = { Value = withSpotlightRooms && i % 2 == 0 ? RoomCategory.Spotlight : RoomCategory.Normal },

View File

@ -249,7 +249,7 @@ namespace osu.Game.Users
public InLobby(Room room)
{
RoomID = room.RoomID ?? -1;
RoomName = room.Name.Value;
RoomName = room.Name;
}
[SerializationConstructor]