mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
Merge branch 'master' into rename-ef-model-properties
This commit is contained in:
commit
4db2ad1cb3
@ -10,6 +10,7 @@ using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
@ -97,16 +98,24 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
|
||||
AddAssert("user on team 0", () => (client.Room?.Users.FirstOrDefault()?.MatchState as TeamVersusUserState)?.TeamID == 0);
|
||||
AddStep("add another user", () => client.AddUser(new APIUser { Username = "otheruser", Id = 44 }));
|
||||
|
||||
AddStep("press button", () =>
|
||||
AddStep("press own button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(multiplayerScreenStack.ChildrenOfType<TeamDisplay>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("user on team 1", () => (client.Room?.Users.FirstOrDefault()?.MatchState as TeamVersusUserState)?.TeamID == 1);
|
||||
|
||||
AddStep("press button", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("press own button again", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("user on team 0", () => (client.Room?.Users.FirstOrDefault()?.MatchState as TeamVersusUserState)?.TeamID == 0);
|
||||
|
||||
AddStep("press other user's button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(multiplayerScreenStack.ChildrenOfType<TeamDisplay>().ElementAt(1));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("user still on team 0", () => (client.Room?.Users.FirstOrDefault()?.MatchState as TeamVersusUserState)?.TeamID == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
15
osu.Game/Rulesets/RulesetLoadException.cs
Normal file
15
osu.Game/Rulesets/RulesetLoadException.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Rulesets
|
||||
{
|
||||
public class RulesetLoadException : Exception
|
||||
{
|
||||
public RulesetLoadException(string message)
|
||||
: base(@$"Ruleset could not be loaded ({message})")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Database;
|
||||
@ -129,12 +128,15 @@ namespace osu.Game.Rulesets
|
||||
{
|
||||
try
|
||||
{
|
||||
var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo).AsNonNull())).RulesetInfo;
|
||||
var resolvedType = Type.GetType(r.InstantiationInfo)
|
||||
?? throw new RulesetLoadException(@"Type could not be resolved");
|
||||
|
||||
var instanceInfo = (Activator.CreateInstance(resolvedType) as Ruleset)?.RulesetInfo
|
||||
?? throw new RulesetLoadException(@"Instantiation failure");
|
||||
|
||||
r.Name = instanceInfo.Name;
|
||||
r.ShortName = instanceInfo.ShortName;
|
||||
r.InstantiationInfo = instanceInfo.InstantiationInfo;
|
||||
|
||||
r.Available = true;
|
||||
}
|
||||
catch
|
||||
|
@ -51,7 +51,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
Alpha = 0,
|
||||
Scale = new Vector2(0, 1),
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Action = changeTeam,
|
||||
Child = box = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
|
@ -147,19 +147,15 @@ namespace osu.Game.Stores
|
||||
{
|
||||
try
|
||||
{
|
||||
var type = Type.GetType(r.InstantiationInfo);
|
||||
var resolvedType = Type.GetType(r.InstantiationInfo)
|
||||
?? throw new RulesetLoadException(@"Type could not be resolved");
|
||||
|
||||
if (type == null)
|
||||
throw new InvalidOperationException(@"Type resolution failure.");
|
||||
var instanceInfo = (Activator.CreateInstance(resolvedType) as Ruleset)?.RulesetInfo
|
||||
?? throw new RulesetLoadException(@"Instantiation failure");
|
||||
|
||||
var rInstance = (Activator.CreateInstance(type) as Ruleset)?.RulesetInfo;
|
||||
|
||||
if (rInstance == null)
|
||||
throw new InvalidOperationException(@"Instantiation failure.");
|
||||
|
||||
r.Name = rInstance.Name;
|
||||
r.ShortName = rInstance.ShortName;
|
||||
r.InstantiationInfo = rInstance.InstantiationInfo;
|
||||
r.Name = instanceInfo.Name;
|
||||
r.ShortName = instanceInfo.ShortName;
|
||||
r.InstantiationInfo = instanceInfo.InstantiationInfo;
|
||||
r.Available = true;
|
||||
|
||||
detachedRulesets.Add(r.Clone());
|
||||
|
@ -71,6 +71,21 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
// We want the user to be immediately available for testing, so force a scheduler update to run the update-bound continuation.
|
||||
Scheduler.Update();
|
||||
|
||||
switch (Room?.MatchState)
|
||||
{
|
||||
case TeamVersusRoomState teamVersus:
|
||||
Debug.Assert(Room != null);
|
||||
|
||||
// simulate the server's automatic assignment of users to teams on join.
|
||||
// the "best" team is the one with the least users on it.
|
||||
int bestTeam = teamVersus.Teams
|
||||
.Select(team => (teamID: team.ID, userCount: Room.Users.Count(u => (u.MatchState as TeamVersusUserState)?.TeamID == team.ID)))
|
||||
.OrderBy(pair => pair.userCount)
|
||||
.First().teamID;
|
||||
((IMultiplayerClient)this).MatchUserStateChanged(user.UserID, new TeamVersusUserState { TeamID = bestTeam }).Wait();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveUser(APIUser user)
|
||||
|
Loading…
Reference in New Issue
Block a user